:root {
  color-scheme: light;
  --ink: #17332c;
  --muted: #60726c;
  --paper: #f7f3e9;
  --card: #fffdf7;
  --accent: #c65d3b;
  --accent-dark: #984128;
  --line: #d8d6ca;
  --success: #28654e;
  --error: #8b2f2f;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 90% 0%, rgb(198 93 59 / 14%), transparent 28rem),
    var(--paper);
}

main {
  width: min(100% - 2rem, 42rem);
  margin: 0 auto;
  padding: max(2rem, env(safe-area-inset-top)) 0 max(3rem, env(safe-area-inset-bottom));
}

.intro { margin: 1rem 0 2rem; }
.app-bar { display: flex; align-items: flex-start; justify-content: flex-start; gap: 1rem; }
.app-bar .eyebrow { margin: .75rem 0 0; }
.app-menu { position: relative; flex: 0 0 auto; }
.menu-toggle {
  display: grid;
  width: 44px;
  min-height: 44px;
  padding: 10px;
  place-content: center;
  gap: 4px;
  border: 1px solid rgb(23 51 44 / 18%);
  border-radius: .75rem;
  color: var(--ink);
  background: rgb(255 253 247 / 82%);
}
.menu-toggle:hover { color: white; }
.menu-toggle span { display: block; width: 20px; border-top: 2px solid currentcolor; }
.menu-panel {
  position: absolute;
  z-index: 10;
  top: calc(100% + .45rem);
  left: 0;
  display: grid;
  min-width: 11rem;
  padding: .85rem 1rem;
  border: 1px solid rgb(23 51 44 / 14%);
  border-radius: .8rem;
  background: var(--card);
  box-shadow: 0 .75rem 2rem rgb(35 42 36 / 15%);
}
.menu-panel[hidden] { display: none; }
.menu-item { min-height: 44px; padding: .55rem .7rem; text-align: left; }
.menu-item[aria-current="page"] { background: var(--accent-dark); }
.menu-separator { margin: .65rem 0; border-top: 1px solid var(--line); }
.menu-label { color: var(--muted); font-size: .72rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.menu-version { margin-top: .2rem; font-variant-numeric: tabular-nums; font-weight: 750; }
.eyebrow, .result-label { font-size: .78rem; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.eyebrow { color: var(--accent-dark); }
h1 { max-width: 11ch; margin: .4rem 0 .75rem; font-family: Georgia, serif; font-size: clamp(2.55rem, 12vw, 4.6rem); line-height: .98; letter-spacing: -.045em; }
.lede { max-width: 35rem; margin: 0; color: var(--muted); font-size: 1.06rem; line-height: 1.55; }

.capture-panel, .result, .audio-panel {
  padding: 1.25rem;
  border: 1px solid rgb(23 51 44 / 12%);
  border-radius: 1.25rem;
  background: var(--card);
  box-shadow: 0 1rem 3rem rgb(35 42 36 / 8%);
}

label { display: block; margin-bottom: .5rem; font-size: .9rem; font-weight: 700; }
textarea, input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: .75rem;
  color: var(--ink);
  background: white;
  font: inherit;
}
textarea { min-height: 8rem; padding: 1rem; resize: vertical; line-height: 1.5; }
input { padding: .75rem; }
select { min-height: 44px; padding: .75rem; }
textarea:focus, input:focus, select:focus, button:focus-visible, summary:focus-visible { outline: 3px solid rgb(198 93 59 / 28%); outline-offset: 2px; }

button {
  width: 100%;
  min-height: 3.25rem;
  border: 0;
  border-radius: .8rem;
  color: white;
  background: var(--accent);
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}
button:hover { background: var(--accent-dark); }
button:disabled { cursor: wait; opacity: .6; }
.audio-panel { margin-top: 1rem; }
.audio-panel h2 { margin: .35rem 0; font-family: Georgia, serif; font-size: 1.8rem; }
.audio-panel > p:not(.eyebrow, .status) { color: var(--muted); line-height: 1.5; }
.audio-actions { display: flex; gap: .65rem; }
.audio-actions button { flex: 1; }
button.secondary { color: var(--accent-dark); border: 1px solid var(--accent); background: transparent; }
button.secondary:hover { color: white; background: var(--accent-dark); }
.voice-actions { display: flex; gap: .65rem; }
.voice-actions button { flex: 1; }
.capture-hint { margin: .7rem 0 0; color: var(--muted); font-size: .9rem; line-height: 1.45; }
.capture-divider { display: flex; align-items: center; gap: .75rem; margin: 1rem 0; color: var(--muted); font-size: .8rem; font-weight: 700; text-transform: uppercase; }
.capture-divider::before, .capture-divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
#capture-form button { margin-top: .75rem; }

.status { margin-top: 1rem; padding: .85rem 1rem; border-radius: .75rem; background: #edf0e9; line-height: 1.45; }
.status.error { color: var(--error); background: #f8e9e6; }
.status.success { color: var(--success); background: #e5f1eb; }
.home-intro { margin-bottom: 2rem; }
.cards-view { padding-bottom: 1rem; }
.cards-mode { display: flex; gap: .65rem; min-width: 0; margin: 1.25rem 0 0; padding: 0; border: 0; }
.cards-mode button { flex: 1; min-height: 44px; }
.cards-status { margin-bottom: 1rem; }
.cards-list { display: grid; gap: .85rem; margin: 0; padding: 0; list-style: none; }
.cards-list-item { min-width: 0; }
.study-card, .edit-list-card {
  overflow: hidden;
  border: 1px solid rgb(23 51 44 / 14%);
  border-radius: 1rem;
  color: var(--ink);
  background: var(--card);
  box-shadow: 0 .5rem 1.5rem rgb(35 42 36 / 7%);
}
.study-card-prompt, .edit-list-card {
  display: grid;
  width: 100%;
  min-height: 7rem;
  padding: 1rem;
  gap: .5rem;
  color: var(--ink);
  background: var(--card);
  text-align: left;
}
.study-card-prompt:hover, .edit-list-card:hover { color: var(--ink); background: #fff; }
.cards-prompt-label { color: var(--accent-dark); font-size: .72rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.cards-meaning { overflow-wrap: anywhere; font-family: Georgia, serif; font-size: 1.35rem; line-height: 1.25; }
.cards-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; margin: .25rem 0 0; color: var(--muted); font-size: .78rem; font-weight: 600; }
.cards-review-badge { display: inline-flex; padding: .22rem .5rem; border-radius: 999px; color: var(--ink); background: #e7ebe5; }
.cards-review-badge.due { color: #6d2b20; background: #f8dfd8; }
.cards-review-badge.new { color: #174e3d; background: #dcefe6; }
.cards-review-badge.unavailable { color: var(--muted); background: #ecebe6; }
.study-card-answer { padding: 1rem; border-top: 1px solid var(--line); background: #fff; }
.study-card-answer[hidden] { display: none; }
.cards-answer-text { margin: .3rem 0; font-family: Tahoma, Arial, sans-serif; font-size: clamp(2rem, 10vw, 3.4rem); font-weight: 600; line-height: 1.35; }
.cards-answer-transliteration { margin: 0; color: var(--accent-dark); font-size: 1.05rem; }
.cards-rating-guidance { margin: 1rem 0 .55rem; color: var(--muted); font-size: .9rem; }
.cards-ratings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
.cards-ratings button { min-height: 44px; padding: .55rem; }
.edit-list-persian { overflow-wrap: anywhere; font-family: Tahoma, Arial, sans-serif; font-size: 1.65rem; line-height: 1.4; text-align: right; }
#cards-load-more { margin-top: 1rem; }
.result { margin-top: 1rem; background: var(--ink); color: white; }
.result-label { display: flex; align-items: center; justify-content: space-between; color: #d5e1dc; }
.register { padding: .25rem .5rem; border: 1px solid rgb(255 255 255 / 25%); border-radius: 2rem; font-size: .66rem; }
.result-actions { display: flex; gap: .65rem; margin-top: .85rem; }
.result-actions button { flex: 1; min-height: 44px; padding: .55rem .9rem; }
.edit-card { color: white; border-color: rgb(255 255 255 / 55%); }
.persian { margin: 2rem 0 .5rem; font-family: Tahoma, Arial, sans-serif; font-size: clamp(2.5rem, 14vw, 5rem); font-weight: 600; line-height: 1.35; }
.tagging-actions { display: flex; justify-content: flex-start; margin: .5rem 0; }
.tagging-actions button { width: auto; min-height: 44px; padding: .55rem .9rem; color: white; border-color: rgb(255 255 255 / 55%); }
.tagging-tools { margin: .75rem 0; padding: .9rem; border: 1px solid rgb(255 255 255 / 25%); border-radius: .8rem; background: rgb(255 255 255 / 5%); }
.tagging-tools h3 { margin: 0; color: white; font-size: 1rem; }
.tagging-help, .tagging-status { color: #d5e1dc; line-height: 1.4; }
.word-parts-toggle { display: flex; align-items: center; gap: .55rem; color: #d5e1dc; font-weight: 600; }
.word-parts-toggle input { width: 24px; height: 24px; margin: 0; }
.target-token { display: inline; width: auto; min-height: 44px; margin: .08rem; padding: .15rem .22rem; border: 1px solid transparent; border-radius: .35rem; color: inherit; background: transparent; font: inherit; font-weight: inherit; line-height: inherit; }
.target-token:hover, .target-token:focus-visible, .target-token.selected { color: var(--ink); background: #fff; }
.target-mark { text-decoration-line: underline; text-decoration-thickness: .12em; text-underline-offset: .16em; }
.target-mark[data-status="can_use"] { text-decoration-color: #a9cbbf; }
.target-mark[data-status="recognize_only"] { text-decoration-color: #f4c76e; }
.target-mark[data-status="new"] { text-decoration-color: #8eced0; }
.target-mark[data-status="can_use"]::after { content: " ✓"; color: #a9cbbf; font-size: .34em; vertical-align: super; }
.target-mark[data-status="recognize_only"]::after { content: " ◉"; color: #f4c76e; font-size: .34em; vertical-align: super; }
.target-mark[data-status="new"]::after { content: " ＋"; color: #8eced0; font-size: .34em; vertical-align: super; }
.selected-target { margin: .65rem 0; font-size: 1.35rem; }
.phrase-actions, .target-status-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .55rem; }
.phrase-actions button, .target-status-actions button { flex: 1 1 8rem; min-height: 44px; padding: .5rem .65rem; }
.target-status-actions button[data-target-status="can_use"] { background: #668d80; }
.target-status-actions button[data-target-status="recognize_only"] { color: #312914; background: #f4c76e; }
.target-status-actions button[data-target-status="new"] { color: #12383a; background: #8eced0; }
.word-parts { margin-top: .65rem; padding: .65rem; border-radius: .55rem; color: var(--ink); background: #fff; font-size: .9rem; }
.word-part-candidate { width: auto; min-height: 44px; margin: .2rem; padding: .45rem .65rem; }
.transliteration { margin: 0; color: #f1b8a5; font-size: 1.2rem; }
dl { margin: 2rem 0 0; padding-top: 1rem; border-top: 1px solid rgb(255 255 255 / 18%); }
dt { color: #aebeb8; font-size: .75rem; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; }
dd { margin: .35rem 0 0; font-size: 1.05rem; }
.card-enrichment { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid rgb(255 255 255 / 18%); }
.card-enrichment h3 { margin: 1rem 0 .3rem; color: #d5e1dc; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; }
.card-enrichment p { margin: .25rem 0; line-height: 1.5; }
.audio-notes { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid rgb(255 255 255 / 18%); }
.audio-notes h3 { color: white; }
.audio-note-warning, .audio-note-consent { color: #d5e1dc; line-height: 1.45; }
.audio-note-mode { display: block; margin-bottom: .35rem; color: #d5e1dc; font-weight: 700; }
#audio-note-actor, .audio-note-trusted-fields input, .audio-note-trusted-fields select { width: 100%; color: var(--ink); background: white; }
.audio-note-trusted-fields { min-width: 0; margin: 1rem 0; padding: 1rem; border: 1px solid rgb(255 255 255 / 25%); border-radius: .75rem; }
.audio-note-trusted-fields legend { padding: 0 .35rem; font-weight: 750; }
.audio-note-trusted-fields > label:not(.audio-note-consent) { display: block; margin: .75rem 0 .35rem; color: #d5e1dc; }
.audio-note-consent { display: flex; gap: .65rem; align-items: flex-start; font-weight: 500; }
.audio-note-trusted-fields .audio-note-consent { margin-top: 1rem; }
.audio-note-consent input { width: 24px; min-width: 24px; height: 24px; margin: 0; }
.audio-note-actions { display: flex; flex-wrap: wrap; gap: .55rem; }
.audio-note-actions button { flex: 1 1 8rem; min-height: 44px; }
#audio-note-review { width: 100%; min-height: 44px; }
.audio-note-list { padding: 0; list-style: none; }
.audio-note-list li { padding: .75rem 0; border-top: 1px solid rgb(255 255 255 / 18%); }
.audio-note-provenance { margin: -.25rem 0 .5rem; color: #f1b8a5; font-size: .88rem; }
.audio-note-list button { width: auto; min-height: 44px; margin: .25rem .4rem .25rem 0; padding: .5rem .8rem; }
.audio-note-export { min-width: 0; margin: 1rem 0 0; padding: 1rem; border: 1px solid rgb(255 255 255 / 28%); border-radius: .75rem; }
.audio-note-export legend { padding: 0 .35rem; font-weight: 750; }
.audio-note-export-warning { color: #d5e1dc; line-height: 1.45; }
.audio-note-export-actions { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: .85rem; }
.audio-note-export-actions button { flex: 1 1 10rem; min-height: 44px; }
.audio-note-export .audio-note-processing-status { overflow-wrap: anywhere; }
.audio-note-export dialog { width: min(32rem, calc(100% - 2rem)); max-height: calc(100dvh - 2rem); padding: 1.25rem; border: 0; border-radius: .85rem; color: var(--ink); background: white; overflow: auto; }
.audio-note-export dialog::backdrop { background: rgb(21 41 35 / 72%); }
.audio-note-export dialog h4 { margin: 0 0 .65rem; font-size: 1.15rem; }
.audio-note-export dialog p { line-height: 1.45; }
.audio-note-export dialog .audio-note-consent { color: var(--ink); }
.audio-note-processing { min-width: 0; margin-top: .75rem; padding: .85rem; border: 1px solid rgb(255 255 255 / 22%); border-radius: .75rem; background: rgb(255 255 255 / 5%); overflow-wrap: anywhere; }
.audio-note-processing h4 { margin: 0 0 .35rem; color: #fff; }
.audio-note-processing-status { margin: .35rem 0 .65rem; color: #d5e1dc; line-height: 1.45; }
.audio-note-processing-status.error { color: #ffd5cc; }
.audio-note-processing-consent { min-width: 0; margin: 0; padding: .85rem; border: 1px solid rgb(255 255 255 / 28%); border-radius: .65rem; }
.audio-note-processing-consent legend { padding: 0 .35rem; font-weight: 750; }
.audio-note-processing-consent .audio-note-consent { margin-top: .85rem; }
.audio-note-processing-actions { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: .75rem; }
.audio-note-processing-actions button, .audio-note-processing > button, .audio-note-transcription > button { flex: 1 1 9rem; min-height: 44px; }
.audio-note-transcription + .audio-note-transcription { margin-top: .85rem; padding-top: .85rem; border-top: 1px solid rgb(255 255 255 / 18%); }
.audio-note-transcript-text { margin: .5rem 0; padding: .65rem; border-radius: .55rem; color: var(--ink); background: #fff; white-space: pre-wrap; }
.audio-note-transcript-text.corrected { border: 2px solid #f1b8a5; }
.audio-note-transcript-label { margin: .65rem 0 .25rem; color: #d5e1dc; font-size: .88rem; font-weight: 700; }
.audio-note-correction-provenance { margin: .65rem 0 .25rem; color: #f1b8a5; font-size: .88rem; }
.audio-note-transcript-correction label { display: block; margin-bottom: .35rem; color: #fff; font-weight: 700; }
.audio-note-transcript-correction textarea { width: 100%; min-height: 6rem; color: var(--ink); background: #fff; resize: vertical; }
.example-target { font-family: Tahoma, Arial, sans-serif; font-size: 1.35rem; }
#retry-enrichment { margin-top: .75rem; color: white; border-color: rgb(255 255 255 / 55%); }
.card-audio-row { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem; margin-top: .75rem; }
.card-audio-row button { width: auto; min-height: 44px; padding: .6rem .9rem; }
.card-audio-row span { color: #d5e1dc; font-size: .85rem; }
.correction-form { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid rgb(255 255 255 / 18%); }
.correction-form h3 { margin-top: 0; }
.correction-form label { margin-top: .85rem; }
.correction-form textarea { min-height: 5rem; }
.correction-form input, .correction-form textarea, .correction-form select { color: var(--ink); background: white; }
.correction-form [aria-invalid="true"] { border: 2px solid var(--error); }
.correction-errors { margin-top: .75rem; padding: .75rem; border-radius: .65rem; color: #fff; background: var(--error); line-height: 1.4; }
.correction-errors ul { margin: .25rem 0 0; padding-left: 1.2rem; }
.correction-actions { display: flex; gap: .65rem; margin-top: 1rem; }
.correction-actions button { flex: 1; min-height: 44px; }
.offline-note { padding: .85rem 1rem; border: 1px solid #d1b161; border-radius: .75rem; background: #fff4d6; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@media (min-width: 40rem) {
  main { padding-top: 4rem; }
  .capture-panel, .result, .audio-panel { padding: 1.75rem; }
  .cards-ratings { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: no-preference) {
  .result:not([hidden]) { animation: reveal .28s ease-out; }
  @keyframes reveal { from { opacity: 0; transform: translateY(.5rem); } }
}
