:root {
  --font: 'DM Sans', system-ui, sans-serif;

  --bg:          #12100a;
  --surface:     #1b1810;
  --surface-2:   #231f15;
  --border:      #2b2618;
  --border-2:    #332e20;
  --border-focus: #4a4030;

  --text:        #ede8de;
  --text-muted:  #c8bfae;
  --text-dim:    #a09278;
  --text-faint:  #857060;
  --text-ghost:  #56483c;

  --heading:     #fff8ee;
  --icon:        #9a8a6e;
  --arrow:       #604e38;
  --footer:      #7a6a52;
  --footer-border: #211d12;

  --btn-bg:      #f5e6c0;
  --btn-bg-hover: #f0d898;
  --btn-text:    #12100a;

  --spinner-track: #2b2618;
  --spinner-head:  #8a7a60;

  --warn:  #b87a00;
  --error: #e05555;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg:          #faf7f0;
    --surface:     #f2ece0;
    --surface-2:   #ece4d4;
    --border:      #d8cdb8;
    --border-2:    #c8baa0;
    --border-focus: #a89070;

    --text:        #2a2218;
    --text-muted:  #5a4e3c;
    --text-dim:    #8a7a62;
    --text-faint:  #b0a088;
    --text-ghost:  #cfc0a8;

    --heading:     #1a1208;
    --icon:        #9a8868;
    --arrow:       #cfc0a8;
    --footer:      #8a7a62;
    --footer-border: #d8cdb8;

    --btn-bg:      #3d3020;
    --btn-bg-hover: #524030;
    --btn-text:    #faf7f0;

    --spinner-track: #d8cdb8;
    --spinner-head:  #8a7a62;

    --warn:  #9a6000;
    --error: #cc3333;
  }
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4rem 2rem 0;
}

main {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.5rem;
  padding-bottom: 3rem;
}

/* ---- Hero ---- */

.hero {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.hero-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.site-logo {
  width: 52px;
  height: 52px;
}

h1 {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -0.05em;
  color: var(--heading);
}

.subtitle {
  color: var(--text-dim);
  font-size: 1.05rem;
}

.tagline {
  color: var(--text-faint);
  font-size: 0.85rem;
  margin-top: 0.4rem;
}

/* ---- How it works ---- */

.how-it-works {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  max-width: 680px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem 2rem;
}

.how-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  text-align: center;
  flex: 1;
}

.how-icon {
  width: 40px;
  height: 40px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--icon);
}

.how-icon svg {
  width: 17px;
  height: 17px;
}

.how-title {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-muted);
}

.how-body {
  font-size: 0.76rem;
  color: var(--text-dim);
  line-height: 1.45;
}

.how-arrow {
  color: var(--arrow);
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.how-arrow svg {
  width: 15px;
  height: 15px;
}

/* ---- Form ---- */

form {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.areas {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.area-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.area-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 2rem;
}

label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--icon);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

textarea {
  width: 100%;
  height: 340px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  font-size: 0.95rem;
  line-height: 1.6;
  resize: vertical;
  font-family: inherit;
  transition: border-color 0.2s;
  outline: none;
  outline-offset: 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--text-faint) transparent;
}

textarea::-webkit-scrollbar {
  width: 4px;
}

textarea::-webkit-scrollbar-track {
  background: transparent;
}

textarea::-webkit-scrollbar-thumb {
  background: var(--text-faint);
  border-radius: 2px;
}

textarea:focus {
  border-color: var(--border-focus);
  outline: 2px solid var(--btn-bg);
}

textarea[readonly] {
  color: var(--text-muted);
}

textarea::placeholder {
  color: var(--text-ghost);
}

.counts {
  font-size: 0.75rem;
  color: var(--text-faint);
  text-align: right;
  transition: color 0.2s;
}

.counts--warn {
  color: var(--warn);
}

.counts--over {
  color: var(--error);
  font-weight: 600;
}

.copy-btn {
  font-size: 0.75rem;
  font-weight: 600;
  background: transparent;
  color: var(--icon);
  border: 1px solid var(--border-2);
  border-radius: 5px;
  padding: 0.2rem 0.6rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  letter-spacing: 0.04em;
}

.copy-btn:hover:not(:disabled) {
  color: var(--text-muted);
  border-color: var(--border-focus);
}

.copy-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.changes {
  height: 0;
  overflow: hidden;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid transparent;
  transition: height 0.25s ease-out, border-color 0.15s ease-out;
}

.changes--visible {
  height: 9rem;
  border-color: var(--border);
}

.changes-inner {
  height: 9rem;
  overflow-y: auto;
  padding: 0.65rem 0.9rem;
  scrollbar-width: thin;
  scrollbar-color: var(--text-faint) transparent;
}

.changes-inner::-webkit-scrollbar {
  width: 4px;
}

.changes-inner::-webkit-scrollbar-track {
  background: transparent;
}

.changes-inner::-webkit-scrollbar-thumb {
  background: var(--text-faint);
  border-radius: 2px;
}

.changes-title {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--icon);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.45rem;
}

.changes-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.changes-list li {
  font-size: 0.82rem;
  color: var(--text-dim);
  line-height: 1.45;
  display: flex;
  gap: 0.45rem;
}

.changes-list li::before {
  content: '-';
  color: var(--text-faint);
  flex-shrink: 0;
}

.error-msg {
  color: var(--error);
  font-size: 0.9rem;
  text-align: center;
}

.submit-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

button[type="submit"] {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.85rem 2.75rem;
  font-size: 1.05rem;
  font-weight: 700;
  background: var(--btn-bg);
  color: var(--btn-text);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  letter-spacing: 0.01em;
}

button[type="submit"]:hover {
  background: var(--btn-bg-hover);
}

button[type="submit"]:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

.spinner {
  width: 17px;
  height: 17px;
  border: 2px solid var(--spinner-track);
  border-top-color: var(--spinner-head);
  border-radius: 50%;
  display: none;
  flex-shrink: 0;
}

form.loading .btn-icon {
  display: none;
}

form.loading .spinner {
  display: block;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---- Footer ---- */

.site-footer {
  width: 100%;
  padding: 1.75rem 2rem;
  text-align: center;
  color: var(--footer);
  font-size: 0.78rem;
  border-top: 1px solid var(--footer-border);
  margin-top: auto;
}

/* ---- Responsive ---- */

@media (max-width: 700px) {
  body {
    padding: 2.5rem 1.25rem 0;
  }

  .areas {
    grid-template-columns: 1fr;
  }

  .how-it-works {
    flex-direction: column;
    padding: 1.25rem 1.5rem;
    gap: 0.75rem;
  }

  .how-arrow svg {
    transform: rotate(90deg);
  }
}
