/* ---------- Tokens ---------- */
:root{
  --bg: #EEF1F3;
  --surface: #FFFFFF;
  --surface-2: #E4E8EC;
  --ink: #12181F;
  --ink-soft: #4A5361;
  --border: #D4DAE0;
  --accent: #2F5DFF;
  --accent-ink: #FFFFFF;
  --accent-soft: #E7ECFF;
  --stamp: #E4572E;
  --success: #1F9E6D;
  --danger: #C4432B;
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 9px;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --shadow-card: 0 1px 2px rgba(18,24,31,0.04), 0 12px 32px -16px rgba(18,24,31,0.18);
  color-scheme: light;
}

:root[data-theme="dark"]{
  --bg: #0F1319;
  --surface: #171D26;
  --surface-2: #1F2632;
  --ink: #EDEFF3;
  --ink-soft: #9AA5B4;
  --border: #2A3241;
  --accent: #6E8CFF;
  --accent-ink: #0F1319;
  --accent-soft: #212B45;
  --stamp: #FF8A5C;
  --success: #3FC28C;
  --danger: #FF7A63;
  --shadow-card: 0 1px 2px rgba(0,0,0,0.3), 0 20px 48px -20px rgba(0,0,0,0.55);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]):not([data-theme="dark"]){
    --bg: #0F1319; --surface: #171D26; --surface-2: #1F2632; --ink: #EDEFF3;
    --ink-soft: #9AA5B4; --border: #2A3241; --accent: #6E8CFF; --accent-ink: #0F1319;
    --accent-soft: #212B45; --stamp: #FF8A5C; --success: #3FC28C; --danger: #FF7A63;
    --shadow-card: 0 1px 2px rgba(0,0,0,0.3), 0 20px 48px -20px rgba(0,0,0,0.55);
    color-scheme: dark;
  }
}

*{ box-sizing: border-box; }
html{ scroll-behavior: smooth; }
body{
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background .2s ease, color .2s ease;
}

img{ max-width: 100%; display: block; }

.wrap{ max-width: 1080px; margin: 0 auto; padding: 0 24px; }
.wrap-narrow{ max-width: 720px; }

.skip-link{
  position: absolute; left: -9999px; top: auto;
  background: var(--accent); color: var(--accent-ink);
  padding: 12px 18px; border-radius: var(--radius-sm); z-index: 100;
}
.skip-link:focus{ left: 24px; top: 24px; }

:focus-visible{ outline: 2.5px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

/* ---------- Header ---------- */
.site-header{
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-row{ display: flex; align-items: center; justify-content: space-between; padding-block: 16px; }
.logo{ font-family: var(--serif); font-size: 1.35rem; font-weight: 600; letter-spacing: -0.01em; }

.icon-btn{
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 50%; border: 1px solid var(--border); background: var(--surface);
  color: var(--ink); cursor: pointer;
}
.icon-btn:hover{ background: var(--surface-2); }
.icon-moon{ display: none; }
[data-theme="dark"] .icon-sun{ display: none; }
[data-theme="dark"] .icon-moon{ display: block; }

/* ---------- Hero ---------- */
.hero{ padding: 56px 0 40px; }
.hero-grid{ display: grid; gap: 40px; align-items: start; }
@media (min-width: 900px){
  .hero-grid{ grid-template-columns: 1fr 1fr; gap: 56px; }
}

.hero-copy h1{
  font-family: var(--serif); font-weight: 600;
  font-size: clamp(1.9rem, 4vw, 2.7rem);
  line-height: 1.14; letter-spacing: -0.01em; margin: 0 0 18px;
}
.hero-copy .lede{ font-size: 1.08rem; color: var(--ink-soft); max-width: 46ch; }

/* ---------- Generator card ---------- */
.generator-card{
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 24px;
  box-shadow: var(--shadow-card);
}

.field-label{ display: block; font-size: 0.86rem; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }

textarea, select, input[type="text"]{
  width: 100%; font: inherit; color: var(--ink); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 12px 14px;
}
textarea{ resize: vertical; min-height: 96px; }
textarea:focus, select:focus, input[type="text"]:focus{ background: var(--surface); }

.char-count{ text-align: right; font-size: 0.78rem; color: var(--ink-soft); margin: 4px 2px 16px; }

.field-row{ display: grid; gap: 14px; margin-bottom: 16px; }
@media (min-width: 520px){ .field-row{ grid-template-columns: 1fr 1fr; } }

/* Combobox */
.combobox{ position: relative; }
.combobox-list{
  position: absolute; z-index: 10; top: calc(100% + 6px); left: 0; right: 0;
  max-height: 240px; overflow-y: auto; margin: 0; padding: 6px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-card); list-style: none;
}
.combobox-list li{
  padding: 9px 10px; border-radius: var(--radius-sm); cursor: pointer; font-size: 0.94rem;
  display: flex; justify-content: space-between; gap: 10px;
}
.combobox-list li .native{ color: var(--ink-soft); font-size: 0.86rem; }
.combobox-list li[aria-selected="true"], .combobox-list li:hover{ background: var(--accent-soft); }

/* Buttons */
.btn-primary{
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--accent); color: var(--accent-ink); border: none;
  font: inherit; font-weight: 600; font-size: 1rem;
  padding: 14px 20px; border-radius: var(--radius-md); cursor: pointer;
  transition: transform .12s ease, opacity .12s ease;
}
.btn-primary:hover{ opacity: 0.92; }
.btn-primary:active{ transform: scale(0.99); }
.btn-primary:disabled{ opacity: 0.6; cursor: progress; }

.btn-spinner{
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--accent-ink) 35%, transparent);
  border-top-color: var(--accent-ink); display: none;
  animation: spin .7s linear infinite;
}
.btn-primary[data-loading="true"] .btn-spinner{ display: inline-block; }
@keyframes spin{ to{ transform: rotate(360deg); } }

.btn-secondary{
  background: var(--surface-2); color: var(--ink); border: 1px solid var(--border);
  font: inherit; font-weight: 600; font-size: 0.92rem;
  padding: 10px 16px; border-radius: var(--radius-sm); cursor: pointer;
}
.btn-secondary:hover{ background: var(--accent-soft); }

.status-line{ min-height: 1.2em; font-size: 0.9rem; margin-top: 10px; }
.status-line[data-tone="error"]{ color: var(--danger); }

/* Result card */
.result-card{
  margin-top: 18px; padding: 18px; border-radius: var(--radius-md);
  background: var(--accent-soft); border: 1px solid var(--border);
}
.result-label{ margin: 0 0 6px; font-size: 0.82rem; font-weight: 600; color: var(--ink-soft); }
.result-text{ margin: 0 0 14px; font-family: var(--serif); font-size: 1.28rem; line-height: 1.4; }
.result-actions{ display: flex; gap: 10px; flex-wrap: wrap; }
.copy-confirm{ margin: 10px 0 0; font-size: 0.85rem; color: var(--success); min-height: 1.1em; }

/* ---------- Sections ---------- */
.section{ padding: 56px 0; border-top: 1px solid var(--border); }
.section h2{ font-family: var(--serif); font-size: clamp(1.5rem, 3vw, 2rem); margin: 0 0 8px; letter-spacing: -0.01em; }
.section-sub{ color: var(--ink-soft); margin: 0 0 28px; max-width: 60ch; }

.steps{ list-style: none; margin: 32px 0 0; padding: 0; display: grid; gap: 24px; }
@media (min-width: 720px){ .steps{ grid-template-columns: repeat(3, 1fr); } }
.steps li{ display: flex; gap: 14px; }
.step-num{
  flex-shrink: 0; width: 34px; height: 34px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border);
  display: grid; place-items: center; font-family: var(--serif); font-weight: 600;
  color: var(--accent);
}
.steps h3{ margin: 0 0 4px; font-size: 1.02rem; }
.steps p{ margin: 0; color: var(--ink-soft); font-size: 0.94rem; }

.example-grid{ margin-top: 24px; display: grid; gap: 16px; }
@media (min-width: 720px){ .example-grid{ grid-template-columns: 1fr 1fr; } }
.example-card{
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 18px;
}
.example-meaning{ margin: 0 0 10px; color: var(--ink-soft); font-size: 0.9rem; }
.example-meaning::before{ content: "“"; }
.example-meaning::after{ content: "”"; }
.example-lang{ font-size: 0.78rem; font-weight: 600; color: var(--stamp); margin: 0 0 4px; }
.example-output{ margin: 0; font-family: var(--serif); font-size: 1.08rem; }

.lang-chip-grid{
  list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px;
}
.lang-chip-grid li{
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  padding: 8px 16px; font-size: 0.9rem;
}

.faq details{
  border-bottom: 1px solid var(--border); padding: 16px 0;
}
.faq summary{ cursor: pointer; font-weight: 600; font-size: 1rem; }
.faq p{ color: var(--ink-soft); margin: 10px 0 0; }

/* ---------- Footer ---------- */
.site-footer{ border-top: 1px solid var(--border); padding: 32px 0 48px; }
.footer-row{ display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; color: var(--ink-soft); font-size: 0.86rem; }
.footer-row p{ margin: 0; }

@media (prefers-reduced-motion: reduce){
  *{ animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
  html{ scroll-behavior: auto; }
}
