:root {
  color-scheme: light;
  --ink: #272d23;
  --muted: #5d6355;
  --paper: #f6f3e9;
  --card: #fffdf7;
  --line: #dedbcf;
  --olive: #283d30;
  --gold: #e9b96c;
  font-family: "Avenir Next", Avenir, system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, textarea { font: inherit; }
button { cursor: pointer; color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid #856338; outline-offset: 3px; }
[hidden] { display: none !important; }
main { max-width: 680px; margin: auto; padding: max(12px, env(safe-area-inset-top)) 20px max(26px, env(safe-area-inset-bottom)); }
.masthead, .card-head, .dialog-head, .form-actions, footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.masthead { margin-bottom: 12px; min-height: 54px; }
.brand { display: flex; align-items: center; gap: 9px; font-size: .94rem; font-weight: 650; white-space: nowrap; }
.mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; background: var(--olive); color: var(--gold); font: 1.3rem Georgia, serif; }
.quiet { background: none; border: 0; padding: 0 3px; min-height: 44px; font-size: .85rem; font-weight: 650; }
.quiet:hover { text-decoration: underline; }
.hero { overflow: hidden; position: relative; isolation: isolate; display: grid; align-content: center; min-height: 216px; border-radius: 23px; padding: clamp(22px, 6vw, 42px); background: #1b3023; color: #fffbeb; }
.hero::after { content: ""; position: absolute; z-index: -1; inset: 0; background: linear-gradient(90deg, #16291feb 0%, #16291fdc 26%, #16291f56 57%, transparent 90%); }
.hero-art { position: absolute; z-index: -2; width: 100%; height: 100%; object-fit: cover; object-position: 78% 48%; inset: 0; }
.hero p { max-width: 22ch; margin: 13px 0 0; color: #f6eedb; font-size: .83rem; line-height: 1.4; }
h1, h2 { font: normal 2rem/1.05 Georgia, "Times New Roman", serif; margin: 0; letter-spacing: -.045em; }
h1 { font-size: clamp(2.65rem, 10vw, 4.9rem); line-height: .96; }
h1 em { color: var(--gold); }
@media (min-width: 520px) {
  .hero { min-height: 278px; }
  .hero p { max-width: 34ch; }
}
nav { display: flex; gap: 7px; margin: 17px 0 13px; padding: 4px; border: 1px solid var(--line); border-radius: 14px; background: #eeebdf; }
nav button { flex: 1; min-height: 44px; border: 0; border-radius: 10px; background: transparent; font-size: .88rem; font-weight: 650; }
nav button[aria-pressed="true"] { background: var(--card); box-shadow: 0 1px 3px #272d2320; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 19px; margin-bottom: 12px; box-shadow: 0 5px 13px #282f2108; overflow-wrap: anywhere; }
.card-head { align-items: flex-start; }
h2 { font-size: clamp(1.8rem, 7vw, 2.45rem); }
.phonetic, .context { color: var(--muted); font-size: 15px; margin: 5px 0 0; }
.actions { display: flex; flex-shrink: 0; align-items: center; gap: 6px; }
.listen { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; border: 1px solid #d4dace; background: #edf0e7; color: #263d30; }
.meaning { margin: 12px 0; font-size: 1.125rem; line-height: 1.55; }
.exchange { padding: 10px 13px 2px; border-radius: 10px; background: #f5f1e5; }
.context { margin: 1px 0 8px; font-weight: 650; }
blockquote { margin: 0; font-size: 1.125rem; line-height: 1.52; }
blockquote p { margin: 0 0 5px; }
.hear-example { color: #354a39; }
footer { justify-content: center; border-top: 1px solid var(--line); margin-top: 20px; color: var(--muted); flex-wrap: wrap; }
.primary, .choice { border-radius: 10px; min-height: 44px; padding: 10px 15px; font-weight: 650; border: 1px solid var(--olive); background: var(--olive); color: #fffdf7; }
.choice { background: var(--card); color: var(--olive); border-color: var(--line); text-align: left; }
.choice.correct { border-color: #628171; background: #e5efe4; opacity: 1; }
.choice.incorrect { border-color: #a66d47; background: #f5e9df; opacity: 1; }
.choices { display: grid; gap: 8px; margin: 14px 0; }
.feedback { min-height: 1.5em; line-height: 1.5; }
dialog { width: min(440px, calc(100% - 32px)); max-height: 90%; overflow: auto; border: 1px solid var(--line); border-radius: 20px; padding: 21px; color: var(--ink); background: var(--card); }
dialog::backdrop { background: #1b291c85; }
label { display: grid; gap: 6px; font-size: .9rem; font-weight: 650; margin: 14px 0; }
input, textarea { border: 1px solid #bdbeb1; border-radius: 8px; background: #fff; padding: 9px; width: 100%; font-size: 1rem; }
.form-actions { justify-content: flex-end; }
#notice, #form-error { line-height: 1.4; color: #774023; }
#notice { padding: 9px 12px; background: #f5e9df; border-radius: 8px; font-size: .9rem; }

.recall-prompt { background: #f4efe2; border: 1px solid #ebe4d6; border-radius: 11px; padding: 13px; margin: 14px 0; }
.recall-prompt p { margin: 0 0 5px; font-size: 1.125rem; line-height: 1.55; }
.recall-prompt p:last-child { margin-bottom: 0; }
.recall-banner { display: block; width: 100%; height: clamp(105px, 24vw, 150px); object-fit: cover; object-position: 65% 53%; border-radius: 11px; margin-bottom: 17px; }

main:has(#feed-controls:not([hidden])) { padding-bottom: calc(126px + env(safe-area-inset-bottom)); }
#feed-controls {
  position: fixed;
  z-index: 1;
  inset: auto 0 0;
  background: var(--paper);
  border-top: 1px solid var(--line);
  padding: 8px max(20px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(20px, env(safe-area-inset-left));
}
.feed-bar-inner { max-width: 640px; margin: auto; }
#next-word { width: 100%; min-height: 54px; }
.feed-meta { display: flex; justify-content: space-between; align-items: center; color: var(--muted); }
#back-word { text-decoration: underline; }
#back-word:disabled { opacity: .45; cursor: default; }
#word-count { font-size: .8rem; margin: 0; }
footer details { width: 100%; }
footer summary { min-height: 44px; padding: 13px 3px; cursor: pointer; font-size: .9rem; font-weight: 650; }
#my-words { padding: 0; margin: 0; list-style: none; }
#my-words li { display: flex; justify-content: space-between; align-items: center; gap: 12px; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.my-actions { display: flex; flex-wrap: wrap; gap: 4px 17px; }
.personal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0 10px; }

.spoken-word {
  position: relative;
  top: 0;
  transition: color 100ms ease-out, text-shadow 260ms ease-out, top 260ms ease-out;
}
.spoken-word.is-spoken {
  color: #805018;
  text-shadow: 0 0 .5em #e9b96c99;
  top: -.08em;
  transition-duration: 100ms, 160ms, 160ms;
}
.headword { display: inline-block; transform-origin: left center; }
.headword.conversation-emphasis {
  transition: color 200ms ease-in-out, text-shadow 200ms ease-in-out, transform 200ms ease-in-out;
}
.headword.conversation-emphasis.is-spoken { top: 0; transform: scale(1.06); }
@media (prefers-reduced-motion: reduce) {
  .headword.conversation-emphasis, .headword.conversation-emphasis.is-spoken { transition: none; transform: none; }
  .spoken-word, .spoken-word.is-spoken { transition: none; text-shadow: none; top: 0; }
}
