@import url("./tokens.css");

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 16px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; }
button, .button { cursor: pointer; border: 0; border-radius: 10px; padding: 10px 16px; background: var(--green); color: white; min-height: 44px; font-weight: 500; }
button:hover { filter: brightness(.95); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.secondary { background: transparent; color: var(--green); }
button.secondary:hover { background: var(--wash); filter: none; }
button.danger { background: transparent; color: #9b3626; }
button.danger:hover { background: #fff0ed; }
button.small { padding: 8px 12px; font-size: 14px; }
a { color: var(--green); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 28px; border-bottom: 1px solid var(--line); background: var(--paper); }
.brand { display: flex; gap: 10px; align-items: center; color: var(--green); font-weight: 800; font-size: 22px; letter-spacing: .04em; }
.brand img { width: 36px; height: 36px; }
.brand small { font-size: 12px; color: var(--muted); letter-spacing: .12em; display: block; }
nav { display: flex; gap: 5px; }
nav button { background: transparent; color: var(--muted); font-weight: 500; padding: 10px 16px; }
nav button.active { background: transparent; color: var(--green); box-shadow: inset 0 -2px var(--green); border-radius: 0; }
main { max-width: 1120px; margin: auto; padding: 30px 24px 100px; }
h1 { font-size: clamp(26px, 4vw, 38px); letter-spacing: -.03em; line-height: 1.25; margin: 0 0 12px; }
h2 { font-size: 22px; margin: 0 0 16px; }
h3 { font-size: 18px; margin: 0 0 8px; }
p { margin: 8px 0 16px; }
.muted { color: var(--muted); }
.eyebrow { color: var(--green); font-size: 12px; font-weight: 700; letter-spacing: .15em; margin-bottom: 12px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 24px; margin-top: 26px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 24px; box-shadow: none; }
.card + .card { margin-top: 18px; }
.grid .card + .card { margin-top: 0; }
.course-card { display: flex; flex-direction: column; gap: 16px; border-top: 1px solid var(--line); }
.course-card > button { align-self: flex-start; background: transparent; color: var(--green); padding-left: 0; }
.course-card > button:hover { background: var(--wash); }
.course-card h3 { flex: 1; overflow-wrap: anywhere; }
.badge { font-size: 12px; padding: 2px 0; border-radius: 0; color: var(--muted); background: transparent; }
.badge.warning { background: transparent; color: #855710; }
.empty { text-align: center; padding: 65px 24px; border: 1px dashed #bdccc6; border-radius: 20px; margin-top: 30px; }
.empty img { width: 68px; margin-bottom: 16px; }
.intro { max-width: 720px; }
label { display: block; font-weight: 500; font-size: 14px; margin: 20px 0 8px; }
input:not([type=checkbox]), textarea, select { width: 100%; border: 1px solid #cbd6d0; border-radius: 10px; background: white; padding: 12px; color: var(--ink); }
textarea { min-height: 160px; resize: vertical; font-family: ui-monospace, monospace; font-size: 14px; line-height: 1.6; }
.checkbox { display: flex; align-items: flex-start; gap: 10px; font-weight: 400; }
.checkbox input { width: 20px; height: 20px; margin-top: 3px; flex-shrink: 0; accent-color: var(--green); }
.help { font-size: 14px; color: var(--muted); margin-top: 6px; }
.notice { border-left: 2px solid var(--gold); padding: 8px 12px; background: transparent; border-radius: 0; font-size: 13px; margin: 16px 0; }
.error { color: #a73325; white-space: pre-wrap; overflow-wrap: anywhere; }
.success { color: var(--green); }
.login { max-width: 440px; margin: 8vh auto; }
.login .brand { margin-bottom: 34px; }
.tabs { display: flex; gap: 12px; margin: 22px 0; flex-wrap: wrap; }
.tabs button { background: transparent; color: var(--muted); border-radius: 0; }
.tabs button.active { background: transparent; color: var(--green); box-shadow: inset 0 -2px var(--green); }
.stack { display: grid; gap: 14px; }
.learning { padding-top: 20px; }
.learning-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 24px; align-items: start; margin-top: 18px; }
.video-column { position: sticky; top: 20px; }
.video-frame { background: #112d29; border-radius: 14px; overflow: hidden; width: 100%; aspect-ratio: 16/9; min-height: 200px; }
.video-frame iframe, .video-frame > div { width: 100%; height: 100%; border: 0; display: block; }
.player-status { font-size: 13px; color: var(--muted); margin: 9px 0; }
.learning-controls { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.learning-controls button { flex: 1; min-width: 72px; padding: 10px 8px; }
.sentence { font-size: 24px; line-height: 1.7; font-weight: 500; overflow-wrap: anywhere; margin: 20px 0; }
.word { padding: 0 2px; min-height: 0; border-radius: 3px; font: inherit; color: var(--green); background: #e5f0e8; border-bottom: 2px solid #8eaf9e; }
.translation { padding-top: 14px; border-top: 1px solid var(--line); color: #4c615b; font-size: 18px; }
.vocab-list { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0; }
.notes { padding-left: 20px; color: var(--muted); }
.timeline { max-height: 290px; overflow-y: auto; padding-top: 12px; border-top: 1px solid var(--line); margin-top: 18px; }
.timeline button { width: 100%; text-align: left; padding: 10px; background: transparent; color: var(--ink); font-weight: 400; border-radius: 8px; margin-bottom: 4px; }
.timeline button.active { background: var(--wash); }
.timeline time { color: var(--muted); font-size: 12px; margin-right: 12px; }
.sheet-backdrop { position: fixed; inset: 0; background: #0d292d66; display: flex; align-items: center; justify-content: center; z-index: 30; padding: 24px; }
.sheet { background: var(--paper); border-radius: 22px; max-width: 520px; width: 100%; max-height: 85dvh; overflow-y: auto; padding: 28px; box-shadow: 0 25px 80px #102c2940; }
.sheet h2 { font-size: 30px; }
.sheet .example { background: var(--wash); padding: 16px; border-radius: 12px; margin: 18px 0; }
.sheet .row { justify-content: flex-end; margin-top: 24px; }
.sheet .row button { flex: 0 1 auto; }
.word-detail h2 { font-size: 28px; overflow-wrap: anywhere; }
.word-detail .example { background: transparent; padding: 20px 0; border-top: 1px solid var(--line); border-radius: 0; margin: 24px 0 0; }
.word-detail .row { margin-top: 16px; }
.word-detail .row { justify-content: flex-end; gap: 12px; }
.word-detail .row button { flex: 0 1 auto; }
.word-heading { display: flex; align-items: flex-start; gap: 16px; }
.word-heading h2 { flex: 1; margin: 6px 0 0; font-family: Georgia, "Times New Roman", serif; font-weight: 400; font-size: 30px; line-height: 1.25; }
.word-heading .icon-control { flex-shrink: 0; color: var(--muted); }
.word-pronunciation { display: flex; align-items: center; gap: 8px; margin: 4px 0 20px; font-size: 14px; }
.word-meaning { font-size: 17px; line-height: 1.8; margin: 0; }
.example-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.example-heading .eyebrow { margin: 0; font-size: 11px; color: var(--muted); letter-spacing: .08em; }
.word-detail .example p[lang] { font-family: Georgia, "Times New Roman", serif; font-size: 21px; line-height: 1.65; margin: 8px 0 12px; }
.word-detail .example .muted { font-size: 14px; line-height: 1.75; margin: 0; }
.word-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); padding-top: 12px; margin-top: 4px; }
.word-footer .help { margin: 0; font-size: 12px; text-align: center; }
.word-footer .icon-control { flex-shrink: 0; }
.icon-control.is-saved { color: var(--green); background: var(--wash); }
.icon-control.is-saved svg { fill: #dcebe2; }
.hidden { display: none !important; }
.lesson-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.lesson-toolbar h1 { flex: 1; min-width: 0; font-size: 18px; margin: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.lesson-toolbar button { flex-shrink: 0; }
.study-column { min-width: 0; width: 100%; }
.study-scroll { min-width: 0; width: 100%; }
.sentence-card, .course-tools, .inline-detail { width: 100%; min-width: 0; }
.word-detail { min-width: 0; overflow-wrap: anywhere; }
.word-detail .row button { min-width: 0; }
.learning-modes { margin: 0 0 10px; gap: 4px; }
.learning-modes button { min-height: 44px; padding: 8px 16px; font-size: 14px; }
.learning-controls { flex-wrap: nowrap; margin: 6px 0 0; gap: 4px; }
.learning-controls button { min-width: 0; min-height: 44px; padding: 8px 5px; font-size: 14px; }
.learning-controls select { flex: 0 0 68px; width: 68px; padding: 8px 4px; min-height: 44px; font-size: 14px; }
.icon-control { display: inline-flex; justify-content: center; align-items: center; background: transparent; color: var(--green); border-radius: 50%; padding: 10px; min-width: 44px; min-height: 44px; }
.icon-control svg { width: 22px; height: 22px; flex-shrink: 0; }
.icon-control:hover { background: var(--wash); filter: none; }
.learning-controls { display: grid; grid-template-columns: minmax(48px, 1fr) minmax(48px, 1fr) 56px minmax(48px, 1fr) minmax(48px, 1fr); align-items: center; padding: 5px 0; gap: 6px; border: 0; background: transparent; }
.learning-controls .icon-control { width: 48px; height: 48px; justify-self: center; border-radius: 50%; }
.learning-controls .primary-control { width: 56px; height: 56px; background: var(--green); color: white; box-shadow: 0 5px 14px #163f3926, inset 0 1px 0 #ffffff26; }
.learning-controls .icon-control:active { background: var(--wash); }
.learning-controls .primary-control:active { background: #0d302b; }
.learning-controls .primary-control svg { width: 25px; height: 25px; }
.learning-controls .primary-control:hover { background: #20564d; }
.learning-controls .icon-control:first-child { color: var(--muted); }
.learning-controls .is-active:first-child { color: var(--green); background: #dcebe2; box-shadow: inset 0 0 0 1px #9fbfaf; }
.learning-controls select { justify-self: center; width: 58px; max-width: 100%; border: 0; background: var(--wash); border-radius: 16px; text-align: center; font-weight: 600; font-size: 13px; min-height: 48px; }
.learning-modes { background: transparent; padding: 0; border-bottom: 1px solid var(--line); border-radius: 0; gap: 12px; }
.learning-modes button { background: transparent; color: var(--muted); border-radius: 0; }
.learning-modes button.active { background: transparent; color: var(--green); box-shadow: inset 0 -2px var(--green); }
.sentence-card { padding: 16px; }
.sentence-card .sentence { font-size: 23px; line-height: 1.65; margin: 16px 0; font-weight: 400; }
.sentence-card > .sentence:not([lang]) { font-size: 24px; font-weight: 500; letter-spacing: .02em; margin: 20px 0 12px; }
.sentence-card > .muted { font-size: 14px; line-height: 1.7; }
.sentence-card > button { min-height: 44px; padding: 10px 14px; font-size: 14px; }
.sentence-card textarea { max-width: 100%; }
.sentence-card .sentence[lang] { font-family: Georgia, "Times New Roman", serif; }
.sentence-card { touch-action: pan-y pinch-zoom; }
.sentence-card .word { background: transparent; border-bottom: 1px solid #8eaf9e; border-radius: 0; padding: 0; }
.sentence-card .translation { font-size: 16px; margin-bottom: 8px; padding-top: 10px; }
.sentence-card time { font-size: 13px; }
.sentence-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sentence-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; min-width: 0; }
.sentence-actions { display: flex; align-items: center; flex-shrink: 0; }
.translation-toggle { min-width: 44px; padding: 8px; font-size: 14px; }
.translation-toggle[aria-pressed="true"] { color: var(--green); box-shadow: inset 0 -1px var(--green); border-radius: 0; }
.sentence-pair + .sentence-pair { margin-top: 24px; }
.sentence-card .sentence-pair .sentence { margin-bottom: 8px; }
.sentence-card .translation.sentence-translation { border: 0; padding: 0; margin: 0; font-size: 16px; line-height: 1.85; overflow-wrap: anywhere; }
.reading-expanded .learning-grid { display: block; height: calc(100dvh - 170px); overflow-y: auto; overscroll-behavior-y: contain; position: relative; }
.reading-expanded .video-column { display: contents; }
.reading-expanded .learning-controls { position: sticky; top: 0; z-index: 2; background: var(--paper); margin: 0; }
.reading-expanded .study-column { display: block; min-height: calc(100dvh - 240px); }
.reading-expanded .study-scroll { overflow: visible; }
.reading-expanded .sentence-card { max-width: 760px; margin-inline: auto; }
.sentence-notes { margin: 12px 0 0; font-size: 14px; }
.sentence-notes summary { color: var(--muted); }
.course-tools { padding: 16px 4px 24px; background: transparent; border-bottom: 1px solid var(--line); border-radius: 0; margin-bottom: 16px; }
.course-tools h2 { font-size: 16px; overflow-wrap: anywhere; }
.course-tools .row { font-size: 14px; }
.course-tools button { min-height: 44px; padding: 8px 10px; font-size: 14px; }
.study-extra { margin: 12px 0; font-size: 14px; }
.study-extra > summary { padding: 8px 4px; min-height: 40px; color: var(--muted); }
.sentence-card .badge, .sentence-card time { font-variant-numeric: tabular-nums; }
.sentence-card .badge { background: transparent; padding: 0; color: var(--muted); letter-spacing: .04em; }
#notification { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 100; max-width: min(90vw, 650px); padding: 0; }
#notification.visible { padding: 12px 18px; border-radius: 12px; background: #173f39; color: white; box-shadow: 0 4px 24px #0002; }
#notification.failure { background: #8b3028; white-space: pre-wrap; }
.import-preview { padding: 14px; background: var(--wash); border-radius: 12px; margin: 16px 0; }
.jobs { margin-top: 30px; }
.job { padding: 16px 0; border-top: 1px solid var(--line); }
.footer { margin-top: 32px; color: var(--muted); font-size: 13px; }
details { margin: 16px 0; }
summary { cursor: pointer; font-weight: 600; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; }
@media (max-width: 760px) {
  header { padding: 14px 18px; }
  header nav { position: fixed; bottom: 0; left: 0; right: 0; background: var(--paper); border-top: 1px solid var(--line); z-index: 20; justify-content: space-around; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); }
  header nav button { flex: 1; font-size: 14px; padding: 8px 4px; }
  main { padding: 24px 16px 110px; }
  .card { padding: 20px; }
  .learning-grid { grid-template-columns: 1fr; gap: 16px; }
  .video-column { position: static; }
  .sentence { font-size: 22px; }
  .sheet-backdrop { align-items: flex-end; padding: 0; }
  .sheet { border-radius: 24px 24px 0 0; padding: 24px 22px calc(24px + env(safe-area-inset-bottom)); max-width: none; }
  .learning > .row { gap: 6px; }
  .learning h1 { font-size: 24px; }
  .video-frame { border-radius: 12px; }
  .learning-shell { height: 100dvh; overflow: hidden; }
  .learning-shell > header { display: none; }
  .learning-shell main.learning { height: 100%; min-height: 560px; padding: 8px 12px max(8px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; }
  .learning-shell .lesson-toolbar { margin-bottom: 8px; gap: 6px; flex-shrink: 0; }
  .learning-shell .lesson-toolbar h1 { font-size: 14px; }
  .learning-shell .lesson-toolbar button { min-height: 44px; padding: 8px; }
  .learning-shell .learning-grid { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; margin-top: 0; }
  .learning-shell .video-column { flex-shrink: 0; min-width: 0; width: 100%; }
  .learning-shell .video-frame { min-height: 200px; min-width: 0; max-width: 100%; }
  .learning-shell .player-status { font-size: 12px; margin: 4px 0; line-height: 1.4; }
  .learning-shell .study-column { display: flex; flex-direction: column; flex: 1; min-height: 0; width: 100%; }
  .learning-shell .learning-modes { flex-shrink: 0; margin-bottom: 8px; }
  .learning-shell .learning-modes button { flex: 1; }
  .learning-shell .study-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior-y: contain; padding-bottom: 12px; }
  .learning-shell .sentence-card { padding: 14px; }
  .learning-shell .word-detail h2 { font-size: 22px; }
  .learning-shell .word-detail .example { padding: 16px 0; margin: 20px 0 0; }
  .learning-shell .word-detail button { font-size: 14px; min-height: 44px; padding: 8px 10px; }
  .learning-shell ~ #notification { bottom: max(12px, env(safe-area-inset-bottom)); }
  .learning-shell .reading-expanded .learning-grid { display: block; height: auto; overflow-y: auto; position: relative; }
  .learning-shell .reading-expanded .video-column { display: contents; }
  .learning-shell .reading-expanded .study-column { display: block; min-height: calc(100dvh - 134px); }
  .learning-shell .reading-expanded .study-scroll { overflow: visible; }
}
@media (max-width: 760px) and (max-height: 559px) {
  .learning-shell { height: auto; overflow: visible; }
  .learning-shell main.learning { height: auto; min-height: 0; }
  .learning-shell .study-scroll { overflow: visible; }
  .learning-shell main.reading-expanded { height: 100dvh; }
  .learning-shell .reading-expanded .learning-grid { min-height: 0; }
}
@media (prefers-reduced-motion: no-preference) {
  button { transition: background .15s, filter .15s; }
}
