/* Shared usability layer. Scoped rules also cover components that inject their own styles. */
:root {
  --ink: #202c35;
  --muted: #616d77;
  --paper: #f6f7f9;
  --cream: #edf2f1;
  --white: #ffffff;
  --line: #dce2e6;
  --brand: #21665c;
  --accent: #e5eed6;
  --orange: #a24e2d;
  --radius: 16px;
}
body { font-size: 15px; line-height: 1.5; }
body button, body input, body select, body textarea { border-radius: 8px; }
body button { touch-action: manipulation; }
body button:disabled { cursor: not-allowed; opacity: .55; }
body :focus-visible { outline: 3px solid #428b80; outline-offset: 3px; }
body input:focus-visible, body textarea:focus-visible { outline-offset: 1px; }
body h1, body h2, body h3 { font-family: var(--sans); font-weight: 700; letter-spacing: -.035em; }
body h1, body .hero h1, body .subpage-head h1 { font-size: clamp(28px, 3.4vw, 42px); line-height: 1.18; }
body h2 { font-size: 22px; }
body .app-shell { grid-template-columns: 220px minmax(0, 1fr); }
body .sidebar { width: 220px; padding: 30px 18px 24px; background: var(--white); }
body .brand { font-size: 22px; gap: 12px; padding: 0 12px; }
body .brand-mark { border-radius: 12px; width: 38px; height: 38px; color: white; font-size: 12px; }
body .main-nav { margin-top: 48px; gap: 8px; }
body .nav-item { min-height: 48px; border-radius: 10px; font-size: 14px; font-weight: 600; color: var(--muted); }
body .nav-item.active { color: var(--brand); background: #e9f2ef; }
body .nav-item:hover { background: #f0f4f3; color: var(--brand); }
body .nav-icon { width: 22px; font-size: 22px; }
body .streak-card { border-radius: 12px; border: 0; background: var(--paper); margin-bottom: 20px; }
body .profile { min-height: 48px; gap: 8px; }
body .profile b { font-size: 12px; }
body .profile small { font-size: 11px; line-height: 1.4; }
body .avatar { background: var(--cream); color: var(--brand); width: 36px; height: 36px; }
body .topbar { height: 76px; padding-inline: 40px; border: 0; }
.topbar-label { color: var(--muted); font-size: 13px; }
.mobile-brand { display: none; }
body .top-actions { gap: 12px; }
body .topbar .import-trigger { background: white; border: 1px solid var(--line); padding: 10px 16px; }
body .import-trigger { font: 600 13px var(--sans); letter-spacing: 0; text-transform: none; min-height: 44px; }
body .page { max-width: 1200px; padding: 24px 40px 64px; }
.eyebrow { color: var(--brand); font-size: 11px; font-weight: 700; letter-spacing: .13em; margin: 0 0 12px; }
.page-description { color: var(--muted); margin: 12px 0 0; font-size: 15px; }
body .hero { min-height: 116px; gap: 24px; }
body .due-ring { width: 100px; height: 100px; }
body .due-ring strong { font: 600 28px var(--sans); }
body .due-ring span { font: 11px var(--sans); text-transform: none; }
body .ring-progress { stroke: var(--brand); }
body .today-row { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 24px; margin-top: 28px; }
body .featured-lesson, body .chat-card { border-radius: var(--radius); box-shadow: none; overflow: hidden; min-width: 0; }
body .featured-lesson { min-height: 0; border-color: #d5e2dd; }
body .lesson-content, body .chat-card-body { padding: 28px; }
body .lesson-content h3 { font-size: 26px; line-height: 1.3; }
body .lesson-content > p, body .chat-card-body > p { font-size: 14px; line-height: 1.75; }
body .chat-card { background: #edf3f0; border-color: transparent; }
body .chat-card-body h3 { font-size: 23px; line-height: 1.3; }
body .chat-card-kind, body .lesson-meta, body .freshness { font: 600 11px var(--sans); letter-spacing: .03em; }
body .lesson-meta { flex-wrap: wrap; gap: 12px; }
body .topic-pill { border-radius: 5px; font: 600 11px var(--sans); letter-spacing: 0; }
body .chat-card-figure span { font: 12px var(--sans); text-transform: none; letter-spacing: 0; }
body .chat-card-body .primary-button { margin-top: 24px; }
body .start-steps { gap: 20px; margin-top: 24px; }
body .start-steps li { grid-template-columns: 1fr; gap: 6px; padding-top: 20px; }
body .start-steps li::before { display: none; }
body .start-steps b { font-size: 15px; }
body .start-steps span { font-size: 13px; }
body .start-steps > li > button:not(.primary-button) { min-height: 44px; font: 600 13px var(--sans); letter-spacing: 0; text-transform: none; background: white; }
body .primary-button { min-height: 46px; padding: 12px 18px; font: 600 14px var(--sans); line-height: 1.4; letter-spacing: 0; gap: 18px; border-radius: 9px; }
body .primary-button:hover { background: #194f47; }
body .lesson-content .primary-button { margin-top: 20px; }
.progress-link { width: 100%; margin-top: 24px; padding: 18px 0; display: flex; gap: 16px; align-items: center; background: transparent; border: 0; color: var(--brand); font-size: 13px; font-weight: 600; text-align: left; }
.progress-link > span:first-child { margin-right: auto; color: var(--muted); font-weight: 400; }
body .subpage-head { gap: 20px; margin-bottom: 28px; align-items: center; }
body .subpage-head p:last-child { font-size: 14px; margin-bottom: 0; }
body .card-toolbar { flex-wrap: wrap; gap: 16px; align-items: center; }
body .search { flex: 1 1 280px; width: auto; min-height: 46px; padding: 0 14px; border: 1px solid var(--line); background: white; border-radius: 9px; }
body .search input { font-size: 14px; min-width: 0; }
body .filter-group { order: 3; flex-basis: 100%; gap: 8px; }
body .filter { min-height: 42px; padding: 8px 14px; font: 500 13px var(--sans); white-space: nowrap; background: white; }
body .card-sort { font: 12px var(--sans); text-transform: none; letter-spacing: 0; }
body .card-sort select { font: 13px var(--sans); min-height: 44px; background: white; }
body .cards-table { border: 1px solid var(--line); background: white; border-radius: 12px; overflow: hidden; }
body .card-row { font-size: 13px; gap: 12px; grid-template-columns: 26px minmax(0,1.15fr) minmax(0,1.4fr) minmax(0,.7fr) 52px minmax(70px,.6fr) 88px; }
body .card-row > * { min-width: 0; overflow-wrap: anywhere; }
body .card-row.header { font: 11px var(--sans); background: #f0f3f5; }
body .card-row strong { font-size: 18px; }
body .row-actions { gap: 4px; }
body .row-icon { width: 40px; min-height: 40px; opacity: 1; font-size: 18px; }
body .status, body .recall, body .deck-tag { font-size: 11px; }
body .table-empty { padding: 40px 24px; border: 0; }
body .table-empty p { font-size: 14px; }
body .table-empty-actions button:not(.primary-button) { font: 600 13px var(--sans); text-transform: none; letter-spacing: 0; }
body .deck-bar, body .deck-actions, body .bulk-bar { flex-wrap: wrap; }
body .deck-bar button, body .deck-actions button, body .deck-select-bulk button, body .deck-manage, body .kind-switch button { min-height: 42px; font: 500 12px var(--sans); }
body .deck-detail, body .deck-select { border-radius: 12px; }
body .deck-detail p, body .deck-select-head p, body .deck-select-name { font-size: 13px; }
body .deck-detail b, body .deck-select-head b { font-size: 14px; }
body .deck-field input { min-width: 0; }
body .today-words { border-radius: 9px; overflow: hidden; }
body .today-words > summary { min-height: 44px; font: 500 12px var(--sans); text-transform: none; letter-spacing: 0; flex-wrap: wrap; }
body .today-words td { font-size: 13px; }
body .today-words th, body .tw-front small, body .tw-state span { font-size: 11px; }
body .tw-drop button { min-width: 40px; min-height: 44px; }
body .today-words-foot { flex-wrap: wrap; font-size: 12px; }
body .today-words-foot button { min-height: 40px; font-size: 11px; }
body .course-deck select { min-height: 44px; font: 13px var(--sans); max-width: 100%; }
body .modal-card { border-radius: 18px; background: white; max-height: calc(100dvh - 32px); padding: 32px; }
body .modal-card h2 { font-size: 28px; padding-right: 26px; }
body .modal-close { min-width: 44px; min-height: 44px; top: 10px; right: 10px; }
body .modal-card p, body .drop-zone strong { font-size: 14px; }
body .drop-zone { border-radius: 10px; background: var(--paper); padding: 20px; text-align: center; }
body .drop-zone span, body .deck-hint, body .privacy-note, body .deck-field > span, body .paste-divider span { font: 12px/1.6 var(--sans); }
body .file-button { padding: 10px 16px; font: 600 14px var(--sans); }
body .modal-card textarea, body .modal-card input { font-size: 16px; }
body .toast { border-radius: 12px; font-size: 14px; max-width: calc(100vw - 32px); }
/* Progress has a stable, explicit order independent of script mounting order. */
body #progress-view section { padding: 24px; margin: 0 0 24px; border: 1px solid var(--line); border-radius: var(--radius); background: white; min-width: 0; }
body #progress-view .activity-head, body #progress-view .profile-head { gap: 12px; flex-wrap: wrap; }
body #progress-view h2 { font: 700 21px var(--sans); letter-spacing: -.025em; }
body #progress-view .section-number { display: none; }
body #progress-view .activity-stat span, body #progress-view .kpi span, body #progress-view .activity-note, body #progress-view .profile-head > span { font: 12px/1.5 var(--sans); letter-spacing: 0; text-transform: none; }
body #progress-view .activity-stats { flex-wrap: wrap; gap: 24px; }
body #progress-view .activity-stat b, body #progress-view .kpi b { font: 600 28px var(--sans); }
body #progress-view .rg-toggle, body #progress-view .rhythm-table-toggle, body #progress-view .status-table-toggle { min-height: 44px; font-size: 12px; }
body #progress-view .rg-table { max-width: 100%; overflow: auto; }
body #library-view .pack-card, body #library-view .pack-detail { border-radius: 12px; background: white; }
body #library-view .pack-card { padding: 22px; }
body #library-view .pack-kind, body #library-view .pack-flag, body #library-view .pack-chip small, body #library-view .pack-preview th { font: 11px/1.5 var(--sans); letter-spacing: .03em; }
body #library-view .pack-card p, body #library-view .pack-hint, body #library-view .pack-source p { font-size: 13px; }
body #library-view .pack-close { min-width: 44px; min-height: 44px; }
body #chat-view .chat-empty, body #chat-view .chat-bank, body #chat-view .chat-composer, body #chat-view .chat-bubble { border-radius: 12px; }
body #chat-view .chat-empty p { font-size: 14px; }
body #chat-view .chat-acts button, body #chat-view .chat-chip, body #chat-view .chat-mic { min-height: 44px; }
body #chat-view .chat-topic input, body #chat-view .chat-search input, body #chat-view textarea { font-size: 16px; }
body #chat-view .chat-acts button, body #chat-view .chat-send-row > span { font-size: 12px; }
@media (max-width: 1100px) {
  body .today-row { grid-template-columns: 1fr; }
  body .card-row { grid-template-columns: 26px minmax(0,1fr) minmax(0,1fr) 52px 80px 88px; }
  body .card-row > :nth-child(4) { display: none; }
}
@media (min-width: 761px) and (max-width: 980px) {
  body .app-shell { grid-template-columns: 88px minmax(0,1fr); }
  body .sidebar { width: 88px; padding-inline: 10px; }
  body .brand { padding: 0; }
  body .nav-item { flex-direction: column; gap: 3px; padding: 9px 2px; font-size: 10px; }
  body .nav-item span:last-child { display: block; }
  body .page { padding-inline: 28px; }
  body .topbar { padding-inline: 28px; }
}
@media (max-width: 760px) {
  body .app-shell { display: block; }
  body main { display: block; }
  body .sidebar { inset: auto 0 0; width: 100%; height: auto; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); transform: none; border: 0; border-top: 1px solid var(--line); box-shadow: 0 -4px 20px #202c3508; z-index: 20; }
  body .sidebar > .brand, body .sidebar .streak-card { display: none; }
  /* One equal column per nav item, however many there are. */
  body .main-nav { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0,1fr); gap: 2px; margin: 0; }
  body .sidebar .nav-item { padding: 7px 2px; flex-direction: column; justify-content: center; gap: 4px; border-radius: 8px; min-height: 54px; font-size: 10px; line-height: 1.2; }
  body .sidebar .nav-item span:last-child { display: block; white-space: nowrap; }
  body .sidebar .sidebar-bottom { position: fixed; top: 15px; right: 16px; margin: 0; }
  body .sidebar .profile { display: flex; width: 44px; min-height: 44px; justify-content: center; }
  body .sidebar .profile > span:not(.avatar) { display: none; }
  body .topbar { height: 74px; padding: 0 72px 0 20px; }
  .topbar-label { display: none; }
  .mobile-brand { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 700; text-decoration: none; }
  body .mobile-brand .brand-mark { width: 32px; height: 32px; border-radius: 10px; font-size: 10px; }
  body .topbar .import-trigger { padding: 8px 10px; font-size: 12px; }
  body .page { padding: 20px 20px calc(104px + env(safe-area-inset-bottom)); }
  body .hero { align-items: center; gap: 16px; min-height: 100px; }
  body .hero h1 { font-size: 28px; }
  .eyebrow { font-size: 10px; margin-bottom: 10px; }
  .page-description { font-size: 13px; margin-top: 10px; }
  body .due-ring { width: 76px; height: 76px; }
  body .due-ring strong { font-size: 23px; }
  body .due-ring span { font-size: 10px; }
  body .today-row { grid-template-columns: 1fr; margin-top: 24px; gap: 18px; }
  body .lesson-content, body .chat-card-body { padding: 22px; }
  body .lesson-content h3 { font-size: 23px; }
  body .lesson-content .primary-button, body .chat-card-body .primary-button { width: 100%; min-width: 0; }
  .progress-link { flex-wrap: wrap; gap: 8px; }
  .progress-link > span:first-child { flex-basis: 100%; }
  body .subpage-head { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 24px; }
  body .subpage-head .primary-button { margin-top: 0; }
  body .card-toolbar { display: flex; gap: 12px; }
  body .search { flex-basis: 100%; margin: 0; }
  body .search input, body select { font-size: 16px; }
  body .filter-group { order: 0; overflow-x: auto; padding-bottom: 4px; }
  body .card-sort { margin: 0; width: 100%; justify-content: space-between; }
  body .card-sort select { font-size: 14px; max-width: 80%; }
  body .card-row { grid-template-columns: 24px minmax(0,1fr) auto; gap: 8px 12px; padding: 16px 12px; }
  body .card-row.header { display: none; }
  body .card-row > :nth-child(1) { grid-column: 1; grid-row: 1; }
  body .card-row > :nth-child(2) { grid-column: 2; grid-row: 1; }
  body .card-row > :nth-child(3) { grid-column: 2 / -1; grid-row: 2; }
  body .card-row > :nth-child(5) { grid-column: 2; grid-row: 3; }
  body .card-row > :nth-child(6) { grid-column: 2 / -1; grid-row: 4; justify-self: start; }
  body .card-row > :nth-child(7) { grid-column: 3; grid-row: 1; }
  body .card-row.confirming { display: flex; flex-wrap: wrap; }
  body .deck-select-list { grid-template-columns: 1fr; }
  body .deck-select-row, body .deck-detail.compact { flex-wrap: wrap; }
  body .deck-select-meta { text-align: left; }
  body .today-words th, body .today-words td { padding-inline: 8px; }
  body .tw-front { white-space: normal; overflow-wrap: anywhere; }
  body .tw-state .tw-both { display: none; }
  body .modal { padding: 12px; }
  body .modal-card { padding: 26px 20px; }
  body .toast { bottom: calc(86px + env(safe-area-inset-bottom)); right: 16px; }
  body #progress-view section { padding: 20px 16px; }
  body #progress-view .activity-stats { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 20px; }
  body #progress-view .profile-body { grid-template-columns: 1fr; }
  body #library-view .pack-row { grid-template-columns: 1fr; }
  body #library-view .pack-facts { flex-wrap: wrap; }
  body #chat-view .chat-send-row { flex-wrap: wrap; gap: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  body *, body *::before, body *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
body .account-row { min-height: 44px; }
body .account-row b { font-size: 12px; }
body .account-row small { font-size: 11px; }
body .acct-panel { border: 1px solid var(--line); border-radius: 12px; }
body .acct-panel button { min-height: 44px; font-size: 12px; }
body .course-close { min-width: 44px; min-height: 44px; }
body .course-lede, body .how-to li { font-size: 14px; }
body .course-steps small { font-size: 11px; }
body .dock-primary, body .dock-secondary, body .course-primary, body .course-ghost { min-height: 46px; font: 600 14px var(--sans); letter-spacing: 0; text-transform: none; }
body .dock-hint { font: 12px/1.5 var(--sans); letter-spacing: 0; text-transform: none; }
body .course-stage { padding-bottom: calc(var(--dock-height, 150px) + 28px); }
body .course-stage input:not([type=checkbox]), body .course-stage select, body .course-stage textarea { font-size: 16px; min-height: 44px; }
body .plan-chips button, body .plan-pack button, body .grades button { min-height: 44px; font-size: 12px; }
body .plan-scale span, body .plan-summary, body .how-to h3 { font-size: 12px; letter-spacing: 0; }
body .plan-table th { font-size: 11px; background: var(--cream); }
body .plan-table td { font-size: 13px; }
body .plan-table-wrap, body .how-to { border-radius: 10px; }
body .how-to { background: var(--cream); }
@media (min-width: 761px) and (max-width: 980px) {
  body .account-row { display: flex; justify-content: center; }
  body .account-row > span:not(.avatar) { display: none; }
}
@media (max-width: 760px) {
  body .account-row { display: flex; justify-content: center; width: 44px; }
  body .account-row > span:not(.avatar) { display: none; }
  body .acct-panel { top: 68px; bottom: auto; right: 16px; left: auto; max-width: calc(100vw - 32px); }
  body .course-head { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  body .course-steps { gap: 4px; }
  body .course-steps i { width: 16px; }
  body .course-tools { flex-wrap: wrap; }
  body .course-tools .tool-button { min-height: 44px; font-size: 11px; }
  body .course-dock { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  body .dock-row { flex-wrap: wrap; }
  body .dock-row .dock-secondary { width: 100%; }
}
@media (max-width: 360px) {
  body .topbar { padding-left: 12px; padding-right: 62px; }
  body .mobile-brand { font-size: 16px; gap: 6px; }
  body .topbar .import-trigger { font-size: 11px; padding-inline: 8px; }
  body .page { padding-inline: 16px; }
  body .hero { gap: 8px; }
  body .hero h1 { font-size: 25px; }
}
body .nav-icon { display: inline-flex; align-items: center; justify-content: center; height: 22px; flex: none; }
body .nav-icon svg { width: 21px; height: 21px; }
/* Status messages contain no controls and must never intercept navigation taps. */
body .toast { pointer-events: none; }
body .tool-button { min-height: 44px; font: 500 12px var(--sans); letter-spacing: 0; }
body .connection-help > div { border-radius: 16px; max-height: calc(100dvh - 40px); overflow-y: auto; }
body .connection-help p { font-size: 14px; }
@media (max-width: 760px) {
  body .topbar { height: auto; min-height: 124px; padding: 16px 20px 12px; flex-wrap: wrap; gap: 14px; }
  body .mobile-brand { min-height: 32px; }
  body .top-actions { flex-basis: 100%; margin: 0; gap: 6px; }
  body .top-actions .study-tools { display: contents; }
  body .top-actions .tool-button, body .topbar .import-trigger { flex: 1; min-width: 0; padding: 8px 6px; font-size: 11px; white-space: normal; text-align: center; }
}
