:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --text: #1c1917;
  --muted: #6b665f;
  --line: #e4e1da;
  --accent: #0f766e;
  --accent-strong: #0b5c56;
  --accent-soft: #e3f2ef;
  --error: #b42318;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(28, 25, 23, 0.06), 0 8px 24px rgba(28, 25, 23, 0.06);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141412;
    --surface: #1e1d1a;
    --text: #f2f0eb;
    --muted: #a8a399;
    --line: #34322d;
    --accent: #2dd4bf;
    --accent-strong: #5eead4;
    --accent-soft: #123b37;
    --error: #f97066;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 16px 24px;
}

/* Header */
.hero { text-align: center; margin-bottom: 28px; }
.logo { display: block; margin: 0 auto 10px; border-radius: 50%; box-shadow: 0 0 0 3px var(--accent-soft); }
h1 {
  margin: 0;
  font-family: ui-serif, Georgia, "Times New Roman", serif;
  font-size: clamp(2.2rem, 7vw, 3.4rem);
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--accent);
}
.tagline { margin: 8px 0 0; color: var(--muted); font-size: 1.15rem; }

/* Form card */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend {
  padding: 0;
  margin-bottom: 10px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

input[type="text"] {
  width: 100%;
  min-width: 0;
  padding: 12px 14px;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="text"]::placeholder { color: var(--muted); opacity: 0.7; }
input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.synonyms {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.or {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--muted);
  font-size: 0.85rem;
}
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.sentence {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
}
.blank {
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.05em;
  user-select: none;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin-top: 24px;
  padding: 14px 20px;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
@media (prefers-color-scheme: dark) { button { color: #0b1f1d; } }
button:hover { background: var(--accent-strong); }
button:active { transform: translateY(1px); }
button:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 2px; }
button:disabled { cursor: wait; opacity: 0.75; }

.spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
button.loading .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.status { min-height: 1.4em; margin: 12px 0 0; text-align: center; color: var(--muted); font-size: 0.95rem; }
.status.error { color: var(--error); }

/* Results */
.results { margin-top: 28px; }
.results-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.results h2 { margin: 0; font-size: 1.15rem; }
.hint { margin: 0; color: var(--muted); font-size: 0.9rem; }

.word-list {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.word-list button {
  margin: 0;
  justify-content: flex-start;
  gap: 12px;
  padding: 12px 14px;
  font-weight: 500;
  text-align: left;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  animation: rise 0.25s ease both;
}
.word-list button:hover { background: var(--accent-soft); border-color: var(--accent); }
.word-list .rank { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; min-width: 1.5em; }
.word-list .word { font-size: 1.1rem; overflow-wrap: anywhere; }
.word-list .copied { margin-left: auto; color: var(--accent); font-size: 0.85rem; }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } }

/* About */
.about {
  margin-top: 56px;
  color: var(--muted);
}
.about:has(.mascot) {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 24px;
  align-items: center;
}
.mascot { width: 100%; height: auto; border-radius: 12px; }
blockquote {
  margin: 0 0 12px;
  font-family: ui-serif, Georgia, serif;
  font-size: 1.2rem;
  line-height: 1.45;
  color: var(--text);
}
cite { display: block; margin-top: 6px; font-family: ui-sans-serif, system-ui, sans-serif; font-size: 0.9rem; font-style: normal; color: var(--muted); }
.about p { margin: 0 0 8px; }

.footer { padding: 32px 16px; text-align: center; color: var(--muted); font-size: 0.85rem; }

@media (max-width: 640px) {
  .page { padding-top: 32px; }
  .card { padding: 18px; }
  .synonyms { grid-template-columns: 1fr; }
  .sentence { grid-template-columns: 1fr; }
  .blank { text-align: center; }
  .word-list { grid-template-columns: 1fr; }
  .about:has(.mascot) { grid-template-columns: 1fr; }
  .mascot { max-width: 220px; margin: 0 auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
