/* Lexicon — English vocabulary app
   Design: warm paper, serif words, two-button review. */

:root {
  color-scheme: light dark;
  --bg: #f6f2ea;
  --bg-2: #ece5d9;
  --surface: #fffdf9;
  --surface-2: #faf6ef;
  --ink: #211d18;
  --ink-2: #574e42;
  --muted: #6f6557;
  --line: #e2d8c9;
  --line-strong: #cfc2ae;
  --green: #2f6b4f;
  --green-soft: #e6f0e9;
  --red: #a8462f;
  --red-soft: #f8e7e0;
  --amber: #b07d2a;
  --shadow: 0 1px 2px rgba(48, 36, 22, 0.04), 0 10px 34px rgba(48, 36, 22, 0.07);
  --shadow-sm: 0 1px 2px rgba(48, 36, 22, 0.05);
  --radius: 26px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131110;
    --bg-2: #1b1815;
    --surface: #1d1917;
    --surface-2: #221e1a;
    --ink: #f4eee4;
    --ink-2: #cdc3b4;
    --muted: #988d7d;
    --line: #2f2923;
    --line-strong: #413930;
    --green: #8cc9a9;
    --green-soft: #1d2f26;
    --red: #e08a70;
    --red-soft: #33211c;
    --amber: #d9a94f;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 34px rgba(0, 0, 0, 0.35);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
  border-radius: 10px;
}

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.wrap {
  width: min(100% - 2rem, 940px);
  margin-inline: auto;
}
.wrap.narrow { width: min(100% - 2rem, 640px); }

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 62px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: 0;
  padding: 4px;
  margin-left: -4px;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-size: 17px;
}
.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: var(--ink);
  color: var(--bg);
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
  flex: none;
}
.brand small {
  display: block;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: -2px;
}

.profile-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px 5px 6px;
  font-size: 13.5px;
  font-weight: 550;
  color: var(--ink-2);
}
.avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  flex: none;
  letter-spacing: 0;
}

/* ---------- generic ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 14px;
  border: 1px solid transparent;
  padding: 11px 18px;
  font-weight: 600;
  font-size: 15px;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  background: var(--surface);
  color: var(--ink);
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:active { transform: scale(0.985); }
.btn.primary { background: var(--ink); color: var(--bg); }
.btn.primary:hover { background: color-mix(in srgb, var(--ink) 88%, var(--bg)); }
.btn.ghost { border-color: var(--line); background: transparent; }
.btn.ghost:hover { background: var(--surface); }
.btn.subtle { background: var(--bg-2); }
.btn.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 28%, var(--line)); background: transparent; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.label {
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.muted { color: var(--muted); }
.center { text-align: center; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 550;
  color: var(--ink-2);
}
.chip[aria-pressed="true"] {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--bg-2);
  color: var(--ink-2);
}

/* ---------- dashboard ---------- */

.main { flex: 1; padding: 26px 0 56px; }

.greeting { margin-bottom: 18px; }
.greeting h1 {
  font-family: var(--serif);
  font-size: clamp(1.7rem, 5vw, 2.2rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.greeting p { color: var(--muted); font-size: 14.5px; margin-top: 4px; }

.hero {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px;
}
.hero-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; }
.due-num {
  font-family: var(--serif);
  font-size: clamp(3.2rem, 15vw, 4.6rem);
  font-weight: 600;
  line-height: 0.95;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.due-sub { color: var(--muted); font-size: 14px; margin-top: 8px; }
.hero-actions { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }

.progress {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.bar {
  display: flex;
  height: 9px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--bg-2);
  margin: 10px 0 12px;
}
.bar > span { display: block; height: 100%; transition: width 0.5s ease; }
.seg-known { background: var(--green); }
.seg-learn { background: var(--amber); }
.seg-new { background: var(--line-strong); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--muted); }
.legend b { color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 600; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 14px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 13px 14px;
  box-shadow: var(--shadow-sm);
}
.stat b { display: block; font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.stat span { font-size: 11.5px; color: var(--muted); }

.section { margin-top: 30px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }

.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.action {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.action:hover { border-color: var(--line-strong); }
.action b { font-size: 15px; font-weight: 600; }
.action span { font-size: 12.5px; color: var(--muted); }

/* ---------- review ---------- */

.review-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: min(100% - 2rem, 720px);
  margin-inline: auto;
  padding: 14px 0 24px;
}

.review-top {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px 0 18px;
}
.quit {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  display: grid;
  place-items: center;
  color: var(--ink-2);
  flex: none;
}
.review-progress { flex: 1; }
.review-progress .bar { margin: 0; height: 6px; }
.seg-done { background: var(--ink); }
.review-count { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 8px 0 18px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 30px;
  box-shadow: var(--shadow);
  padding: clamp(26px, 6vw, 44px);
  min-height: 248px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  animation: card-in 0.32s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(10px) scale(0.995); }
  to { opacity: 1; transform: none; }
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.card-meta .sep { opacity: 0.5; }

.word {
  font-family: var(--serif);
  font-size: clamp(3rem, 14vw, 5.2rem);
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: -0.025em;
  text-align: center;
  overflow-wrap: anywhere;
  hyphens: auto;
}
.word.w10 { font-size: clamp(2.3rem, 10vw, 4rem); }
.word.w14 { font-size: clamp(1.9rem, 8vw, 3.2rem); }

.word-hint {
  text-align: center;
  color: var(--muted);
  font-size: 15px;
  margin-top: 10px;
  font-style: italic;
}

.reveal {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  animation: rise 0.38s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.definition {
  font-family: var(--serif);
  font-size: clamp(1.15rem, 4.2vw, 1.4rem);
  line-height: 1.45;
  letter-spacing: -0.005em;
}
.examples {
  margin-top: 18px;
  display: grid;
  gap: 10px;
}
.examples li {
  position: relative;
  padding-left: 16px;
  color: var(--ink-2);
  font-size: 14.5px;
  line-height: 1.5;
}
.examples li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.6em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--line-strong);
}
.examples li em { font-style: normal; font-weight: 600; color: var(--ink); }

.grades {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 20px;
}
.grade {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 10px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  font-weight: 600;
  font-size: 13.5px;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}
.grade:active { transform: scale(0.97); }
.grade svg { width: 30px; height: 30px; }
.grade.again { color: var(--red); border-color: color-mix(in srgb, var(--red) 26%, var(--line)); }
.grade.again:hover { background: var(--red-soft); }
.grade.good { color: var(--green); border-color: color-mix(in srgb, var(--green) 30%, var(--line)); background: var(--green-soft); }
.grade.good:hover { border-color: var(--green); }
.grade kbd {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 5px;
  background: var(--bg);
}

.next-row { margin-top: 20px; display: grid; gap: 10px; }
.hint-keys {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin-top: 14px;
}

/* ---------- browse ---------- */

.searchbar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 14px;
  box-shadow: var(--shadow-sm);
}
.searchbar svg { color: var(--muted); flex: none; }
.searchbar input {
  border: 0;
  background: transparent;
  padding: 13px 0;
  width: 100%;
  font-size: 15px;
}
.searchbar input:focus { outline: none; }
.filters {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 4px;
  margin: 12px 0 16px;
  scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }
.filters .chip { flex: none; }

.list-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  margin: 10px 2px 2px;
}
.list-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.word-list { display: grid; gap: 8px; }
.word-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.word-row summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  cursor: pointer;
  list-style: none;
}
.word-row summary::-webkit-details-marker { display: none; }
.word-row summary::after {
  content: "+";
  margin-left: auto;
  color: var(--muted);
  font-size: 18px;
  font-weight: 400;
  line-height: 1;
}
.word-row[open] summary::after { content: "–"; }
.word-row .w { font-weight: 600; font-size: 15.5px; }
.word-row .meta { color: var(--muted); font-size: 12px; }
.status { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.status.known { background: var(--green); }
.status.learning { background: var(--amber); }
.status.new { background: var(--line-strong); }
.word-body { padding: 0 16px 16px; border-top: 1px solid var(--line); }
.word-body .definition { font-size: 15px; margin-top: 12px; font-family: var(--sans); line-height: 1.5; }
.word-body .examples { margin-top: 10px; }
.word-body .examples li { font-size: 13.5px; }

.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}

.load-more { margin-top: 14px; }

/* ---------- settings ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
  padding: 18px;
  margin-bottom: 12px;
}
.panel h2 {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0.02em;
  margin-bottom: 4px;
}
.panel .desc { color: var(--muted); font-size: 13px; margin-bottom: 14px; }

.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field input, .field select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px 12px;
  font-size: 15px;
}
.row { display: flex; gap: 10px; flex-wrap: wrap; }

.goal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.goal {
  text-align: left;
  border: 1.5px solid var(--line);
  background: var(--surface);
  border-radius: 16px;
  padding: 14px;
  display: grid;
  gap: 4px;
}
.goal[aria-pressed="true"] { border-color: var(--ink); background: var(--surface-2); box-shadow: 0 0 0 1px var(--ink); }
.goal b { font-size: 14.5px; }
.goal span { font-size: 12.5px; color: var(--muted); }
.goal .n { font-family: var(--serif); font-size: 20px; letter-spacing: -0.01em; }

/* ---------- welcome ---------- */

.welcome {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 40px 0;
}
.welcome-card {
  width: min(100% - 2rem, 520px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(24px, 6vw, 38px);
}
.welcome h1 {
  font-family: var(--serif);
  font-size: clamp(2rem, 8vw, 2.7rem);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.025em;
  margin-bottom: 8px;
}
.welcome .lead { color: var(--muted); font-size: 15px; margin-bottom: 24px; }

/* ---------- dialogs ---------- */

dialog {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 22px;
  padding: 22px;
  width: min(100% - 2rem, 420px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
}
dialog::backdrop { background: rgba(20, 16, 12, 0.45); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
dialog h2 { font-size: 18px; font-weight: 650; margin-bottom: 4px; }
dialog .desc { color: var(--muted); font-size: 13.5px; margin-bottom: 16px; }
.profile-list { display: grid; gap: 8px; margin-bottom: 14px; }
.profile-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 12px;
  padding: 9px 12px;
}
.profile-item[aria-current="true"] { border-color: var(--ink); }
.profile-item .nm { font-weight: 600; font-size: 14px; }
.profile-item .gl { font-size: 12px; color: var(--muted); }

/* ---------- misc ---------- */

.loading {
  flex: 1;
  display: grid;
  place-items: center;
  color: var(--muted);
  gap: 12px;
}
.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--ink-2);
  animation: spin 0.8s linear infinite;
  margin-inline: auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.session-summary {
  text-align: center;
  padding: 24px 0;
  min-height: 62vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.session-summary .big {
  font-family: var(--serif);
  font-size: clamp(2.2rem, 9vw, 3.2rem);
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}
.summary-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 24px 0;
}

.footer-note {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 28px 0 10px;
}
.footer-note a { text-decoration: underline; text-underline-offset: 2px; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 560px) {
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .action-grid { grid-template-columns: 1fr; }
  .hero-top { flex-direction: column; align-items: stretch; }
  .hero-actions { flex-direction: row; }
  .hero-actions .btn { flex: 1; }
  .goal-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
