@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=DM+Sans:wght@400;500;600;700&family=Playfair+Display:ital,wght@0,600;1,600;1,700&display=swap');

:root {
  color-scheme: light;
  --ink: #202422;
  --muted: #707873;
  --line: #dedfd7;
  --paper: #f5f4ee;
  --white: #fffefa;
  --lime: #d4f36a;
  --lime-dark: #a9ce37;
  --coral: #ef7962;
  --blue: #8299db;
  --green: #397d59;
  --red: #bd4938;
  --mono: 'DM Mono', Consolas, monospace;
  --sans: 'DM Sans', 'Segoe UI', sans-serif;
  --serif: 'Playfair Display', Georgia, serif;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--paper); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, a, summary { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }

.topbar { height: 76px; display: flex; align-items: center; gap: 60px; padding: 0 max(5vw, calc((100vw - 1240px) / 2)); border-bottom: 1px solid var(--line); background: rgba(255,254,250,.82); }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 19px; letter-spacing: 0; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 31px; height: 31px; background: var(--ink); color: var(--lime); font-family: var(--serif); font-size: 19px; }
.brand-dot { color: var(--coral); }
.main-nav { display: flex; align-self: stretch; align-items: center; gap: 30px; }
.main-nav a { height: 100%; display: grid; place-items: center; color: var(--muted); font-size: 13px; border-bottom: 2px solid transparent; }
.main-nav a.active { color: var(--ink); border-color: var(--ink); }
.user-tools { margin-left: auto; display: flex; align-items: center; gap: 20px; }
.user-name { font-size: 13px; font-weight: 600; }
.user-tools form { margin: 0; }
.quiet-button { padding: 8px 0; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; }
.page-shell { max-width: 1240px; width: calc(100% - 64px); margin: 0 auto; padding: 52px 0 90px; }
.flash-stack { display: grid; gap: 8px; margin-bottom: 22px; }
.flash { padding: 12px 15px; border-left: 3px solid var(--blue); background: var(--white); font-size: 13px; }
.flash.error { border-color: var(--coral); }
.flash.success { border-color: var(--green); }

.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 34px; }
.eyebrow { margin: 0 0 11px; font: 500 10px/1.4 var(--mono); letter-spacing: 0; color: var(--muted); }
h1, h2, h3, p { letter-spacing: 0; }
.page-heading h1 { margin: 0; font-size: clamp(30px, 4vw, 44px); line-height: 1.12; font-weight: 600; }
.subheading { margin: 9px 0 0; color: var(--muted); font-size: 14px; }
.button { min-height: 44px; display: inline-flex; justify-content: center; align-items: center; gap: 16px; border: 1px solid transparent; padding: 0 18px; font-weight: 600; font-size: 12px; cursor: pointer; transition: transform .16s ease, background .16s ease; }
.button:hover { transform: translateY(-2px); }
.button:disabled { opacity: .55; cursor: wait; transform: none; }
.button-primary { background: var(--lime); color: var(--ink); }
.button-primary:hover { background: var(--lime-dark); }
.button-dark { background: var(--ink); color: var(--white); }
.button-outline { border-color: var(--ink); background: transparent; color: var(--ink); }
.button-wide { width: 100%; }
.button-minimal { min-height: 42px; padding: 0 6px; color: var(--ink); }

.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 58px; }
.stat-panel { min-height: 150px; padding: 20px 23px; display: flex; flex-direction: column; align-items: flex-start; }
.stat-lime { background: var(--lime); }
.stat-paper { background: #e6e7df; }
.stat-ink { background: var(--ink); color: var(--white); }
.stat-label { font: 500 10px var(--mono); }
.stat-panel strong { margin-top: 10px; font-size: 43px; line-height: 1; font-weight: 600; }
.stat-panel strong small { margin-left: 2px; font-size: 19px; }
.stat-note { margin-top: auto; padding-top: 10px; font-size: 11px; opacity: .72; }
.practice-section, .tracker-section { margin-top: 0; }
.section-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; padding-bottom: 17px; border-bottom: 1px solid var(--line); }
.section-title h2 { margin: 0; font-size: 24px; font-weight: 600; }
.section-title .eyebrow { margin-bottom: 7px; }
.section-index { font: 11px var(--mono); color: var(--muted); }
.subject-grid { display: grid; margin-bottom: 56px; }
.subject-row { display: grid; grid-template-columns: 68px minmax(180px, 1fr) auto; align-items: center; gap: 18px; padding: 22px 0; border-bottom: 1px solid var(--line); }
.subject-code { width: 54px; aspect-ratio: 1; display: grid; place-items: center; background: var(--blue); color: #121b38; font: 500 13px var(--mono); }
.subject-spanish .subject-code { background: var(--coral); color: #3c1711; }
.subject-copy h3 { margin: 0 0 4px; font-size: 17px; }
.subject-copy p { margin: 0; color: var(--muted); font-size: 12px; }
.subject-actions { display: flex; align-items: center; gap: 14px; }
.subject-actions .button { min-height: 40px; }
.tracker-section { margin-top: 0; }
.text-link { font-size: 12px; font-weight: 600; }
.tracker-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 36px; padding-top: 22px; }
.tracker-column h3 { display: flex; align-items: center; gap: 9px; margin: 0 0 12px; font-size: 13px; }
.tracker-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--coral); }
.tracker-dot.strong { background: #71ad7d; }
.tracker-word { display: grid; grid-template-columns: minmax(0,1fr) 130px; align-items: center; gap: 15px; min-height: 56px; border-top: 1px solid var(--line); }
.tracker-word > div:first-child { display: grid; gap: 3px; }
.tracker-word strong { font-size: 13px; }
.tracker-word span { color: var(--muted); font-size: 11px; }
.progress-wrap { display: grid; grid-template-columns: 34px 1fr; gap: 8px; align-items: center; }
.progress-wrap > span { font: 10px var(--mono); text-align: right; }
.progress-track { height: 4px; background: #dedfd7; }
.progress-track i { display: block; height: 100%; background: var(--coral); }
.tracker-column:last-child .progress-track i { background: #71ad7d; }
.empty-tracker { display: flex; align-items: center; gap: 14px; padding: 24px 0; color: var(--muted); font-size: 13px; }
.empty-tracker p { margin: 0; }
.empty-symbol { display: grid; place-items: center; width: 38px; height: 38px; background: var(--lime); color: var(--ink); font-size: 20px; }

.auth-shell { min-height: calc(100vh - 76px); display: flex; align-items: center; }
.auth-layout { width: 100%; min-height: 540px; display: grid; grid-template-columns: 1.05fr .95fr; background: var(--white); }
.auth-story { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: center; padding: clamp(34px, 7vw, 88px); background: var(--lime); }
.auth-story::after { content: ''; position: absolute; width: 340px; height: 340px; right: -110px; bottom: -140px; border: 1px solid rgba(32,36,34,.22); border-radius: 50%; box-shadow: 0 0 0 28px rgba(32,36,34,.04), 0 0 0 58px rgba(32,36,34,.035); }
.auth-story .eyebrow { color: #4b5e1c; }
.auth-story h1 { margin: 0; font-size: clamp(48px, 6vw, 78px); line-height: .98; font-weight: 600; }
.auth-story h1 em { font-family: var(--serif); font-weight: 600; }
.auth-copy { max-width: 350px; margin: 25px 0 0; font-size: 14px; line-height: 1.7; }
.language-stamp { display: flex; gap: 8px; margin-top: 48px; }
.language-stamp span { display: grid; place-items: center; width: 39px; height: 39px; border: 1px solid rgba(32,36,34,.45); font: 11px var(--mono); }
.auth-form-wrap { align-self: center; width: min(100%, 430px); padding: 52px clamp(28px, 7vw, 80px); }
.auth-form-wrap h2 { margin: 0 0 27px; font-size: 28px; }
.stack-form { display: grid; gap: 17px; }
.stack-form label, .edit-form label { display: grid; gap: 7px; font-size: 12px; font-weight: 600; }
.stack-form input, .stack-form select, .stack-form textarea, .edit-form input, .edit-form select { width: 100%; min-width: 0; min-height: 45px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 0; background: var(--white); color: var(--ink); font-size: 13px; }
.stack-form textarea { resize: vertical; }
.stack-form input::placeholder, .stack-form textarea::placeholder { color: #a1a59e; }
.field-hint { margin: -9px 0 0; color: var(--muted); font-size: 11px; }
.auth-switch { margin: 23px 0 0; color: var(--muted); font-size: 12px; }
.auth-switch a { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; font-weight: 600; }

.vocab-heading { align-items: center; }
.word-count { font: 28px var(--mono); white-space: nowrap; }
.word-count small { font: 11px var(--sans); color: var(--muted); }
.vocab-layout { display: grid; grid-template-columns: 320px minmax(0,1fr); gap: 52px; align-items: start; }
.entry-panel { padding: 21px; background: #e8e9e1; }
.entry-panel h2 { margin: 0 0 21px; font-size: 19px; }
.entry-panel .stack-form { gap: 14px; }
.optional { display: inline; color: var(--muted); font-size: 10px; font-weight: 400; }
.list-toolbar { display: flex; justify-content: space-between; align-items: center; min-height: 57px; border-bottom: 1px solid var(--ink); }
.list-toolbar h2 { margin: 0; font-size: 17px; }
.list-toolbar span { color: var(--muted); font-size: 11px; }
.list-toolbar b { padding: 0 5px; font-weight: 400; }
.word-item { display: grid; grid-template-columns: 44px minmax(0,1fr) 38px; align-items: center; gap: 14px; min-height: 82px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.word-language { display: grid; place-items: center; width: 35px; height: 35px; background: var(--blue); font: 10px var(--mono); }
.word-item:nth-child(even) .word-language { background: #f1a08e; }
.word-pair { display: grid; gap: 3px; min-width: 0; }
.word-pair strong { font-size: 14px; }
.word-pair > span { color: var(--muted); font-size: 12px; }
.word-pair small { overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.word-actions { position: relative; justify-self: end; }
.word-actions summary { width: 32px; height: 32px; display: grid; place-items: center; list-style: none; cursor: pointer; font-size: 20px; }
.word-actions summary::-webkit-details-marker { display: none; }
.action-menu { position: absolute; z-index: 4; top: 37px; right: 0; width: min(320px, calc(100vw - 42px)); padding: 17px; background: var(--white); border: 1px solid var(--line); box-shadow: 0 12px 28px rgba(32,36,34,.12); }
.edit-form { display: grid; gap: 10px; }
.edit-form label { font-size: 11px; }
.edit-form input, .edit-form select { min-height: 38px; padding: 8px; }
.action-menu form + form { margin-top: 10px; }
.delete-button { padding: 9px 0; border: 0; background: transparent; color: var(--red); cursor: pointer; font-size: 11px; }
.empty-list { padding: 55px 20px; text-align: center; border-bottom: 1px solid var(--line); }
.empty-list .empty-symbol { margin: 0 auto 15px; }
.empty-list h3 { margin: 0 0 7px; font-size: 17px; }
.empty-list p { max-width: 330px; margin: 0 auto; color: var(--muted); font-size: 12px; line-height: 1.6; }

.quiz-shell { max-width: 900px; }
.quiz-topline { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); padding-bottom: 17px; }
.back-link { font-size: 12px; font-weight: 600; }
.quiz-subject, .session-count { font: 11px var(--mono); color: var(--muted); }
.quiz-subject i { padding: 0 5px; color: var(--coral); font-style: normal; }
.quiz-settings { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 17px 0; border-bottom: 1px solid var(--line); }
.quiz-settings form { display: flex; align-items: center; gap: 12px; }
.quiz-settings label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; }
.quiz-settings select { min-height: 36px; padding: 6px 26px 6px 9px; border: 1px solid var(--line); background: var(--white); font-size: 11px; }
.quiz-settings .button { min-height: 36px; padding: 0 12px; font-size: 11px; }
.quiz-board { margin: 36px auto 0; max-width: 720px; }
.quiz-progress { display: grid; grid-template-columns: 100px 1fr 140px; align-items: center; gap: 13px; font: 10px var(--mono); color: var(--muted); }
.quiz-progress > :last-child { text-align: right; }
.quiz-progress-line { display: block; height: 2px; background: var(--line); }
.quiz-progress-line i { display: block; width: 0; height: 100%; background: var(--coral); }
.question-area { padding: 74px 0 38px; text-align: center; }
.question-area .eyebrow { color: #73796e; }
.question-area h1 { max-width: 100%; margin: 0; overflow-wrap: anywhere; font: 600 clamp(31px, 5vw, 48px)/1.2 var(--serif); }
.question-hint { margin: 13px 0 0; color: var(--muted); font-size: 12px; }
.answer-area { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.choice-option { display: grid; grid-template-columns: 28px minmax(0,1fr); align-items: center; gap: 11px; min-height: 74px; padding: 13px; border: 1px solid var(--line); background: var(--white); color: var(--ink); text-align: left; cursor: pointer; }
.choice-option:hover { border-color: var(--ink); }
.choice-option > span { display: grid; place-items: center; width: 25px; height: 25px; background: #e9e9e1; font: 11px var(--mono); }
.choice-option b { font-size: 13px; overflow-wrap: anywhere; }
.choice-option.is-answer { border-color: var(--green); background: #edf4e9; }
.choice-option.is-mistake { border-color: var(--red); background: #f9ece8; }
.typing-form { grid-column: 1 / -1; display: flex; gap: 10px; max-width: 540px; width: 100%; margin: 0 auto; }
.typing-form input { flex: 1; min-width: 0; min-height: 54px; padding: 0 15px; border: 1px solid var(--line); background: var(--white); font-size: 15px; }
.result-area { margin-top: 17px; padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; gap: 15px; font-size: 12px; }
.result-area[hidden] { display: none; }
.result-area.is-correct { background: #e6f0e5; }
.result-area.is-wrong { background: #fae8e2; }
.result-area strong { font-size: 13px; }
.result-area span { color: #58605a; text-align: right; }
.quiz-controls { display: flex; justify-content: space-between; align-items: center; margin-top: 25px; }
.quiz-controls .button { min-width: 180px; }
.quiz-controls a { color: var(--muted); font-size: 11px; text-decoration: underline; text-underline-offset: 3px; }
.quiz-empty { max-width: 540px; margin: 100px auto; text-align: center; }
.quiz-empty .empty-symbol { margin: 0 auto 17px; }
.quiz-empty h1 { margin: 0; font: 600 32px var(--serif); }
.quiz-empty p { margin: 12px 0 25px; color: var(--muted); font-size: 13px; }

@media (max-width: 760px) {
  .topbar { height: 64px; gap: 23px; padding: 0 20px; }
  .main-nav { gap: 17px; }
  .main-nav a { font-size: 11px; }
  .user-tools { gap: 10px; }
  .user-name { display: none; }
  .page-shell { width: calc(100% - 40px); padding: 34px 0 65px; }
  .auth-shell { min-height: calc(100vh - 64px); }
  .auth-layout { grid-template-columns: 1fr; }
  .auth-story { min-height: 320px; padding: 36px; }
  .auth-story h1 { font-size: 54px; }
  .auth-copy { max-width: 320px; margin-top: 15px; font-size: 12px; }
  .language-stamp { margin-top: 22px; }
  .auth-form-wrap { margin: auto; padding: 38px 32px; }
  .stats-grid { gap: 7px; margin-bottom: 43px; }
  .stat-panel { min-height: 126px; padding: 14px; }
  .stat-panel strong { font-size: 34px; }
  .stat-label { font-size: 9px; }
  .stat-note { font-size: 9px; }
  .subject-row { grid-template-columns: 48px minmax(0,1fr); gap: 12px; }
  .subject-code { width: 44px; }
  .subject-actions { grid-column: 2; justify-content: flex-start; flex-wrap: wrap; gap: 7px; }
  .subject-actions .button { min-height: 36px; padding: 0 10px; font-size: 10px; }
  .tracker-grid { grid-template-columns: 1fr; gap: 25px; }
  .vocab-layout { grid-template-columns: 1fr; gap: 32px; }
  .entry-panel { padding: 20px; }
  .word-count { font-size: 22px; }
  .quiz-settings { align-items: flex-start; flex-direction: column; }
  .quiz-settings form { width: 100%; flex-wrap: wrap; }
  .quiz-settings label { flex: 1; justify-content: space-between; }
  .quiz-settings select { min-width: 110px; }
  .quiz-board { margin-top: 26px; }
  .question-area { padding: 50px 0 28px; }
  .answer-area { grid-template-columns: 1fr; }
  .choice-option { min-height: 57px; }
}

@media (max-width: 440px) {
  .topbar { gap: 13px; padding: 0 13px; }
  .brand { gap: 7px; font-size: 16px; }
  .brand-mark { width: 27px; height: 27px; }
  .main-nav { gap: 11px; }
  .main-nav a { font-size: 10px; }
  .quiet-button { font-size: 10px; }
  .page-shell { width: calc(100% - 28px); }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .dashboard-heading .button { align-self: flex-start; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-panel:last-child { grid-column: 1 / -1; min-height: 105px; }
  .section-title h2 { font-size: 20px; }
  .tracker-word { grid-template-columns: minmax(0,1fr) 104px; gap: 8px; }
  .list-toolbar { align-items: flex-start; flex-direction: column; justify-content: center; gap: 4px; padding: 10px 0; }
  .quiz-subject { font-size: 9px; }
  .quiz-progress { grid-template-columns: 72px 1fr 96px; gap: 7px; font-size: 8px; }
  .result-area { align-items: flex-start; flex-direction: column; gap: 6px; }
  .result-area span { text-align: left; }
  .quiz-controls { align-items: flex-start; flex-direction: column; gap: 15px; }
}
