:root {
  color-scheme: light;
  --bg: #f6f7f2;
  --surface: #ffffff;
  --surface-2: #eef0e8;
  --ink: #152019;
  --muted: #69746d;
  --line: #dfe4db;
  --accent: #a9ed85;
  --accent-strong: #315d28;
  --accent-ink: #173411;
  --danger: #a23d3d;
  --shadow: 0 18px 50px rgba(32, 48, 37, 0.08);
  --radius: 24px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d100e;
  --surface: #161b18;
  --surface-2: #202720;
  --ink: #f3f6ef;
  --muted: #9da99f;
  --line: #2c342e;
  --accent: #99dd79;
  --accent-strong: #b7f09d;
  --accent-ink: #10200d;
  --danger: #ff9d9d;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
html { background: var(--bg); scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); min-height: 100vh; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

.app-shell { min-height: 100vh; padding-bottom: calc(92px + env(safe-area-inset-bottom)); }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; width: min(100% - 32px, 720px); height: 76px; margin: auto; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(18px); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-size: .95rem; font-weight: 750; text-decoration: none; letter-spacing: -.02em; }
.brand-mark { display: grid; place-items: center; width: 31px; height: 31px; border-radius: 10px; background: var(--ink); color: var(--bg); font-size: .9rem; }
.top-actions { display: flex; gap: 8px; }
.icon-button { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); cursor: pointer; font-size: 1.05rem; }
.icon-button:hover { border-color: var(--muted); transform: translateY(-1px); }

main { width: min(100% - 32px, 720px); margin: 0 auto; outline: none; }
.view { animation: enter .24s ease both; }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } }
.today-heading { padding: 30px 2px 22px; }
.eyebrow { color: var(--accent-strong); font-weight: 750; font-size: .86rem; letter-spacing: .08em; text-transform: uppercase; margin: 0 0 12px; }
.heading-row { display: flex; align-items: end; justify-content: space-between; gap: 16px; }
h1 { font-size: clamp(2rem, 8vw, 3.7rem); line-height: .96; letter-spacing: -.065em; margin: 0; max-width: 560px; }
.heading-row p { color: var(--muted); margin: 13px 0 0; font-size: 1rem; }
.day-pill { display: none; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); padding: 9px 13px; font-size: .82rem; white-space: nowrap; }
.word-stack { display: grid; gap: 12px; }
.word-card { position: relative; display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: center; min-height: 158px; padding: 25px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); transition: transform .2s ease, border-color .2s ease; }
.word-card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent-strong) 40%, var(--line)); }
.word-card::after { content: ""; position: absolute; right: -45px; top: -55px; width: 120px; height: 120px; background: var(--accent); border-radius: 50%; opacity: .12; }
.word-number { display: inline-block; color: var(--muted); font-size: .72rem; font-weight: 750; letter-spacing: .14em; margin-bottom: 18px; }
.word-card h2 { margin: 0; font-size: clamp(1.75rem, 7vw, 2.6rem); line-height: 1; letter-spacing: -.045em; text-transform: lowercase; }
.word-card p { margin: 9px 0 0; color: var(--muted); font-size: .95rem; }
.reveal-button { position: relative; z-index: 1; border: 0; border-radius: 15px; background: var(--surface-2); padding: 13px 16px; font-weight: 720; cursor: pointer; white-space: nowrap; }
.reveal-button:hover { background: var(--accent); color: var(--accent-ink); }
.daily-finish { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 26px 0; padding: 18px; color: var(--muted); }
.daily-finish span { display: grid; place-items: center; width: 25px; height: 25px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: .75rem; font-weight: 900; }
.daily-finish p { margin: 0; }

.bottom-nav { position: fixed; z-index: 30; bottom: max(12px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; width: min(calc(100% - 24px), 430px); padding: 7px; border: 1px solid color-mix(in srgb, var(--line) 82%, transparent); border-radius: 22px; background: color-mix(in srgb, var(--surface) 92%, transparent); box-shadow: 0 14px 40px rgba(18, 28, 21, .16); backdrop-filter: blur(20px); }
.nav-item { display: flex; align-items: center; justify-content: center; gap: 7px; height: 55px; border-radius: 16px; color: var(--muted); font-size: .84rem; font-weight: 700; text-decoration: none; }
.nav-item.active { background: var(--ink); color: var(--bg); }
.nav-icon { font-weight: 800; font-size: 1rem; }
.nav-add .nav-icon { font-size: 1.35rem; line-height: 0; }
.toast-root { position: fixed; z-index: 100; left: 50%; bottom: 100px; transform: translateX(-50%); width: min(calc(100% - 32px), 390px); pointer-events: none; }

.page-heading { padding: 34px 2px 26px; }
.page-heading > p:last-child { margin: 16px 0 0; color: var(--muted); font-size: 1rem; }
.page-heading h1 { max-width: 680px; }
.page-heading h1 span { color: var(--muted); font-size: .36em; vertical-align: top; letter-spacing: 0; }
.add-card { display: grid; gap: 12px; padding: 21px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.add-card > label, .word-form label { color: var(--muted); font-size: .82rem; font-weight: 720; }
textarea, input, select { width: 100%; border: 1px solid var(--line); border-radius: 14px; outline: none; background: var(--bg); color: var(--ink); padding: 13px 14px; font-size: 1rem; }
textarea:focus, input:focus, select:focus { border-color: var(--accent-strong); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.add-card textarea { min-height: 250px; resize: vertical; border: 0; border-radius: 16px; background: var(--surface-2); padding: 18px; line-height: 1.6; font-size: 1.1rem; }
.add-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 4px; }
.add-footer > span { color: var(--muted); font-size: .86rem; }
.primary-button, .secondary-button { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; border: 0; border-radius: 14px; padding: 0 19px; background: var(--ink); color: var(--bg); text-decoration: none; font-weight: 760; cursor: pointer; }
.primary-button:hover { transform: translateY(-1px); }
.primary-button:disabled, .secondary-button:disabled { opacity: .42; cursor: not-allowed; transform: none; }
.secondary-button { border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); }
.full { width: 100%; }
.quiet-note { display: flex; gap: 12px; align-items: start; max-width: 500px; margin: 19px auto; color: var(--muted); line-height: 1.55; font-size: .9rem; }
.quiet-note span { color: var(--accent-strong); }
.quiet-note p { margin: 0; }

.library-heading { display: flex; justify-content: space-between; }
.library-tools { position: sticky; z-index: 10; top: 76px; padding: 6px 0 16px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(16px); }
.search-box { display: flex; align-items: center; gap: 9px; height: 53px; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); padding: 0 15px; }
.search-box > span { color: var(--muted); font-size: 1.25rem; }
.search-box input { border: 0; background: transparent; padding: 0; box-shadow: none; }
.filter-row { display: flex; gap: 7px; margin-top: 10px; overflow-x: auto; scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
.filter-button { border: 1px solid var(--line); border-radius: 999px; background: transparent; padding: 8px 13px; color: var(--muted); font-size: .82rem; font-weight: 700; cursor: pointer; }
.filter-button.active { border-color: var(--ink); background: var(--ink); color: var(--bg); }
.word-list { display: grid; gap: 8px; padding-bottom: 24px; }
.library-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; min-height: 81px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); padding: 15px 17px; text-align: left; cursor: pointer; }
.library-row:hover { border-color: var(--accent-strong); transform: translateY(-1px); }
.library-row > div:first-child { min-width: 0; }
.library-row strong { display: block; margin-bottom: 5px; font-size: 1.14rem; letter-spacing: -.025em; }
.library-row > div:first-child span { display: block; overflow: hidden; color: var(--muted); font-size: .84rem; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { display: flex; align-items: center; gap: 7px; flex-shrink: 0; color: var(--muted); font-size: .76rem; text-transform: capitalize; }
.row-meta b { margin-left: 4px; font-size: 1.35rem; font-weight: 400; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #8f9a92; }
.status-dot.new { background: #4f88d8; }
.status-dot.learning { background: #e7a840; }
.status-dot.familiar { background: #6fbe5b; }

.word-card.revealed { display: block; min-height: 0; }
.word-card.revealed::after { background: var(--accent); opacity: .16; }
.meaning-panel { animation: enter .25s ease both; margin-top: 20px; }
.meaning-panel .definition { margin: 0; color: var(--ink); font-size: 1.02rem; line-height: 1.5; }
.meaning-panel .translation { margin-top: 10px; color: var(--accent-strong); font-weight: 720; }
.example { margin-top: 20px; padding-top: 17px; border-top: 1px solid var(--line); }
.example > span { color: var(--muted); font-size: .7rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.example p { margin-top: 7px; color: var(--ink); font-style: italic; line-height: 1.48; }
.used-button { width: 100%; margin-top: 20px; border: 1px solid color-mix(in srgb, var(--accent-strong) 28%, var(--line)); border-radius: 14px; background: color-mix(in srgb, var(--accent) 18%, var(--surface)); padding: 13px; color: var(--accent-strong); font-weight: 760; cursor: pointer; }
.used-button.done { opacity: .7; cursor: default; }

.empty-state { grid-column: 1 / -1; display: grid; place-items: center; min-height: 330px; padding: 38px 22px; border: 1px dashed var(--line); border-radius: var(--radius); text-align: center; }
.empty-state.compact { min-height: 260px; }
.empty-state .empty-glyph { display: grid; place-items: center; width: 58px; height: 58px; margin-bottom: 16px; border-radius: 18px; background: var(--surface-2); font-weight: 850; }
.empty-state h2 { margin: 0; letter-spacing: -.03em; }
.empty-state p { max-width: 330px; margin: 8px 0 20px; color: var(--muted); }

.locked { overflow: hidden; }
.overlay { position: fixed; z-index: 80; inset: 0; display: flex; justify-content: flex-end; }
.backdrop { position: absolute; inset: 0; width: 100%; border: 0; background: rgba(7, 12, 9, .48); backdrop-filter: blur(4px); }
.sheet { position: relative; width: min(100%, 530px); height: 100%; overflow-y: auto; overscroll-behavior: contain; padding: 26px 22px calc(40px + env(safe-area-inset-bottom)); background: var(--bg); box-shadow: -20px 0 70px rgba(0,0,0,.18); transform: translateX(100%); transition: transform .25s ease; }
.sheet.open { transform: translateX(0); }
.sheet-head { display: flex; align-items: start; justify-content: space-between; gap: 16px; margin-bottom: 27px; }
.sheet-head h2 { margin: 6px 0 0; font-size: 2.5rem; line-height: 1; letter-spacing: -.055em; }
.status-label { color: var(--accent-strong); font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.close-button { display: grid; place-items: center; width: 43px; height: 43px; flex: none; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); font-size: 1.55rem; cursor: pointer; }
.word-form { display: grid; gap: 14px; padding: 19px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); }
.word-form label { display: grid; gap: 7px; }
.word-form textarea { resize: vertical; }
.field-grid { display: grid; grid-template-columns: 1fr .7fr; gap: 10px; }
.detail-section, .settings-group { margin-top: 18px; padding: 20px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); }
.detail-section h3, .settings-group h3 { margin: 0 0 16px; font-size: .78rem; letter-spacing: .1em; text-transform: uppercase; }
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 15px; }
.stats-grid > div { padding: 13px; border-radius: 14px; background: var(--surface-2); }
.stats-grid span { display: block; margin-bottom: 5px; color: var(--muted); font-size: .7rem; }
.stats-grid strong { font-size: .94rem; }
.history { margin-top: 18px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); overflow: hidden; }
.history summary { display: flex; justify-content: space-between; padding: 19px 20px; font-weight: 760; cursor: pointer; list-style: none; }
.history summary span { color: var(--muted); }
.history > div { padding: 0 20px 14px; }
.history-row { display: flex; justify-content: space-between; gap: 15px; padding: 12px 0; border-top: 1px solid var(--line); font-size: .84rem; }
.history-row time { color: var(--muted); white-space: nowrap; }
.delete-button { width: 100%; margin-top: 18px; border: 0; background: transparent; padding: 14px; color: var(--danger); font-weight: 720; cursor: pointer; }

.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; padding: 5px; border-radius: 14px; background: var(--surface-2); }
.segmented button { border: 0; border-radius: 10px; background: transparent; padding: 10px; color: var(--muted); font-weight: 700; cursor: pointer; }
.segmented button.active { background: var(--surface); color: var(--ink); box-shadow: 0 4px 12px rgba(0,0,0,.06); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; cursor: pointer; }
.toggle-row strong, .toggle-row span { display: block; }
.toggle-row span { max-width: 310px; margin-top: 4px; color: var(--muted); font-size: .82rem; line-height: 1.4; }
.toggle-row input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-row i { position: relative; width: 49px; height: 29px; flex: none; border-radius: 999px; background: var(--surface-2); transition: background .2s ease; }
.toggle-row i::after { content: ''; position: absolute; left: 4px; top: 4px; width: 21px; height: 21px; border-radius: 50%; background: var(--surface); box-shadow: 0 2px 6px rgba(0,0,0,.17); transition: transform .2s ease; }
.toggle-row input:checked + i { background: var(--accent-strong); }
.toggle-row input:checked + i::after { transform: translateX(20px); }
.time-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 16px; color: var(--muted); font-size: .84rem; }
.time-row input { width: 125px; }
.capability-note { margin-top: 14px; padding: 13px; border-radius: 14px; background: var(--surface-2); }
.capability-note strong { font-size: .8rem; }
.capability-note p, .install-group p { margin: 5px 0 0; color: var(--muted); font-size: .78rem; line-height: 1.45; }
.install-group .secondary-button { margin-top: 14px; }

.toast { margin-top: 8px; padding: 14px 17px; border: 1px solid var(--line); border-radius: 14px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); transition: .2s ease; font-size: .9rem; font-weight: 680; text-align: center; }
.toast.show { opacity: 1; transform: translateY(0); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

@media (min-width: 650px) {
  .topbar { height: 92px; }
  .today-heading { padding-top: 48px; }
  .day-pill { display: block; }
  .word-stack { grid-template-columns: repeat(3, 1fr); }
  .word-card { min-height: 285px; padding: 26px; grid-template-columns: 1fr; align-content: space-between; }
  .word-card h2 { font-size: 2.15rem; overflow-wrap: anywhere; }
  .reveal-button { width: 100%; }
  .word-card.revealed { min-height: 365px; }
  .library-tools { top: 91px; }
  .word-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 420px) {
  .word-card { grid-template-columns: 1fr; min-height: 185px; }
  .reveal-button { width: 100%; }
  .brand span:last-child { display: none; }
  .page-heading h1 { font-size: 2.2rem; }
  .add-footer { align-items: stretch; flex-direction: column; }
  .add-footer .primary-button { width: 100%; }
  .field-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
