/* Page-level styles: top bar, sign-in, home, task page, settings, the work-page frame, guide text.
   Class names, so task plugins know what they can lean on:
     .wk            work-page frame made by views/work_shell.js
       .wk-head       slim title row (back button, title, badges)
       .wk-top        sticky box under the top bar: the playback bar (+ optional timeline)
       .wk-panes      two columns on wide screens, one column under 900 px
         .wk-pane       one column; .wk-pane.sticky keeps it in view while the other one scrolls
       .wk-submit     bottom bar that stays on screen; .wk-submit-inner is its content row
     .guide         explanation text (kv tables, quotes, red/blue/orange line words)
     .mk-on .mk-stop .mk-eot    colored words for the red / blue / orange line
     .c-host .c-caller          host / caller colored words
     .hl            yellow "listen here" word
   Colors come from tokens.css only. */

/* ---------- top bar ---------- */
html.work { --topbar-h: 48px; --sticky-top: 48px; }
.topbar { gap: 8px; padding: 4px 14px; }
.topbar .brand { color: var(--text); text-decoration: none; font-size: 1.05rem; white-space: nowrap; }
.tb-crumb { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--text-2); font-size: .92em; }
.tb-crumb a { color: var(--text-2); text-decoration: none; white-space: nowrap; }
.tb-crumb a:hover { color: var(--text); text-decoration: underline; }
.tb-crumb .sep { opacity: .5; }
.tb-crumb .cur { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-sync { display: inline-flex; align-items: center; gap: 7px; min-width: 0; font-size: .88em; color: var(--text-2); white-space: nowrap; }
.tb-sync .dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); }
.tb-sync[data-s="saving"] .dot { background: var(--warn); }
.tb-sync[data-s="offline"] .dot, .tb-sync[data-s="error"] .dot { background: var(--err); }
.tb-sync[data-s="offline"], .tb-sync[data-s="error"] { color: var(--err); }
.tb-sync .txt { overflow: hidden; text-overflow: ellipsis; max-width: 30em; }
.topbar .btn.small { min-height: 40px; }
html.work .topbar .btn.small { min-height: 36px; }
@media (pointer: coarse) { .topbar .btn.small { min-height: 48px; } }
@media (max-width: 900px) {   /* the offline / error sentence is never cut: it wraps onto two lines */
  .tb-sync[data-s="offline"], .tb-sync[data-s="error"] { flex: 1 1 0; white-space: normal; }
  .tb-sync[data-s="offline"] .txt, .tb-sync[data-s="error"] .txt { max-width: none; overflow: visible; text-overflow: clip; line-height: 1.25; }
}
@media (max-width: 900px) {
  .tb-crumb { display: none; }
  .tb-sync .txt { max-width: 11em; font-size: .92em; }
  .topbar { padding: 4px 10px; gap: 4px; }
  .topbar .btn.small { padding: .2em .55em; }
}
@media (max-width: 560px) {
  .tb-sync:not([data-s="offline"]):not([data-s="error"]) .txt { display: none; }
  .topbar:has(.tb-sync[data-s="offline"]) .brand, .topbar:has(.tb-sync[data-s="error"]) .brand { display: none; }   /* room for the sentence */
  .topbar .brand { font-size: .98rem; }
}

/* ---------- forms shared by sign-in and settings ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label, .field > .lab { font-weight: 600; }
.field .hint { font-size: .9em; color: var(--text-2); }
.form-err { min-height: 1.6em; margin: 4px 0 10px; color: var(--err); font-weight: 550; }
.form-ok { color: var(--ok); font-weight: 550; }

/* ---------- sign-in and invitation ---------- */
.auth { min-height: calc(100vh - var(--topbar-h)); display: grid; place-items: start center; padding: 6vh 16px 40px; }
.auth-card { width: min(420px, 100%); padding: 28px 28px 24px; }
.auth-card h1 { font-size: 1.45rem; margin-bottom: .3em; }
.auth-card .lead { color: var(--text-2); margin-bottom: 1.2em; }
.auth-card .btn.primary { width: 100%; min-height: 54px; font-size: 1.08em; margin-top: 4px; }
.auth-foot { margin-top: 16px; font-size: .9em; color: var(--text-2); }

/* ---------- home ---------- */
.hero { padding: 28px 0 8px; }
.hero h1 { font-size: 1.75rem; margin-bottom: .25em; }
.hero p.sub { font-size: 1.15rem; color: var(--text-2); margin-bottom: 1.1em; }
.hero-go { min-width: 12em; min-height: 64px; padding: .5em 2em; font-size: 1.3rem; border-radius: 14px; }
.hero-note { margin-top: 14px; color: var(--text-2); }
.home-list { margin-top: 28px; display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
.home-list > .card + .card { margin-top: 0; }
.proj-card { display: flex; flex-direction: column; gap: 10px; }
.proj-card h3 { margin: 0; }
.proj-card .meta { color: var(--text-2); font-size: .92em; }
.proj-card .acts { display: flex; flex-wrap: wrap; gap: 10px; margin-top: auto; }
.pc-prog { display: flex; align-items: center; gap: 12px; }
.pc-prog .progress { flex: 1 1 auto; width: auto; }
.pc-prog .num { color: var(--text-2); font-size: .92em; white-space: nowrap; }
@media (max-width: 900px) {
  .hero { padding-top: 16px; }
  .hero h1 { font-size: 1.45rem; }
  .hero-go { width: 100%; }
}

/* ---------- project page ---------- */
.proj-head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.proj-head h1 { margin: 0 0 .15em; }
.proj-head .progress-line { display: flex; align-items: center; gap: 12px; flex: 1 1 280px; min-width: 240px; }
.proj-head .progress { flex: 1 1 auto; width: auto; height: 12px; }
.stage { margin-top: 16px; padding: 0; overflow: hidden; }
.stage + .stage { margin-top: 16px; }
.stage-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 18px; }
.stage-head h2 { margin: 0; font-size: 1.12rem; }
.stage-head .sub { color: var(--text-2); font-size: .92em; }
.stage.locked { opacity: .78; }
.stage.locked .stage-head h2 { color: var(--text-2); }
.stage-gate { margin: 0 18px 14px; padding: 12px 14px; background: var(--primary-soft); border-radius: var(--radius-s); display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.stage-gate p { margin: 0; flex: 1 1 18em; }
.stage-lock { margin: 0 18px 14px; color: var(--text-2); }
/* shared item pool (题库): the claim card and the folded earlier batches */
.pool-card { margin-top: 16px; padding: 16px 18px; }
.pool-card h2 { margin: 0 0 8px; font-size: 1.12rem; }
.pool-card .stage-gate { margin: 0; }
.pool-empty { margin: 0 0 10px; font-size: 1.05rem; }
.pool-held { margin: 0 0 12px; font-size: .92em; }
.pool-num { font-size: 1rem; }
.pool-old { margin-top: 16px; }
.pool-old > summary { cursor: pointer; padding: 8px 4px; color: var(--text-2); }
.pool-old[open] > summary { margin-bottom: 4px; }
@media (max-width: 900px) { .pool-card { padding: 14px; } }
.item-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.item-list li { border-top: 1px solid var(--line); }
.item-list li:first-child { border-top: 0; }
.item-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 8px 18px; background: transparent; border: 0; text-align: left; text-decoration: none; color: inherit; }
a.item-row:hover, button.item-row:hover { background: var(--surface-2); }
.item-row .name { flex: none; font-weight: 600; min-width: 4.5em; }
.item-row .sum { flex: 1 1 auto; min-width: 0; color: var(--text-2); font-size: .92em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-row .go { flex: none; margin-left: auto; color: var(--primary); font-weight: 600; font-size: .92em; }
.st-dot { flex: none; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line-2); background: transparent; }
.st-dot.doing { border-color: var(--warn); background: linear-gradient(90deg, var(--warn) 50%, transparent 50%); }
.st-dot.done { border-color: var(--ok); background: var(--ok); }
.st-dot.skipped { border-color: var(--text-2); background: var(--surface-2); }
.item-row.next { background: var(--primary-soft); }
.item-row.next .go { text-decoration: underline; }
@media (max-width: 900px) {
  .item-row { padding: 8px 14px; min-height: 56px; }
  .item-row .sum { display: none; }
  .stage-head, .stage-gate, .stage-lock { padding-left: 14px; padding-right: 14px; margin-left: 0; margin-right: 0; }
  .stage-gate { margin: 0 14px 14px; }
}

/* ---------- settings ---------- */
.set-sec { margin-top: 16px; }
.set-sec h2 { font-size: 1.1rem; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 8px 0; }
.set-row + .set-row { border-top: 1px solid var(--line); }
.set-row .lab { font-weight: 600; }
.set-row .hint { color: var(--text-2); font-size: .9em; display: block; font-weight: 400; }
.set-row input[type="number"] { width: 6.5em; }
.switch { display: inline-flex; align-items: center; gap: 10px; min-height: var(--tap); }
.switch input { width: 1.5em; height: 1.5em; }
.set-form { max-width: 420px; }

/* ---------- work-page frame ---------- */
.wk { max-width: 1480px; margin: 0 auto; padding: 0 20px; display: flex; flex-direction: column; min-height: calc(100vh - var(--topbar-h)); }
.wk-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 0 0; min-height: 44px; }
.wk-head .back { min-height: 40px; padding: 0 .8em; }
.wk-head h1 { margin: 0; font-size: 1.05rem; font-weight: 650; }
.wk-head .crumb { color: var(--text-2); font-size: .92em; }
.wk-head .badges { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.wk-head .status { margin-left: auto; color: var(--text-2); font-size: .92em; font-variant-numeric: tabular-nums; }
.wk-top { position: sticky; top: var(--sticky-top); z-index: 20; background: var(--bg); }
.wk-top .transport { position: static; padding: 6px 0; }
.wk-top .tp-bar { padding: 5px 8px; gap: 6px; }
.wk-top .tp-bar .btn { min-height: 40px; padding: .15em .8em; }
.wk-tl { padding-bottom: 6px; }
.wk-panes { flex: 1 1 auto; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 18px; align-items: start; padding-bottom: 12px; }
.wk-panes.single { grid-template-columns: minmax(0, 1fr); }
.wk-pane { min-width: 0; }
.wk-pane.sticky { position: sticky; top: calc(var(--sticky-top) + 72px); }
.wk-submit { position: sticky; bottom: 0; z-index: 25; margin: 0 -20px; padding: 10px 20px calc(10px + env(safe-area-inset-bottom, 0px)); background: var(--surface); border-top: 1px solid var(--line); box-shadow: var(--shadow-up); }
.wk-submit:empty { display: none; }
.wk-submit-inner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; max-width: 1480px; margin: 0 auto; }
.wk-submit .btn.primary { min-width: 9em; min-height: 52px; font-size: 1.05em; }
@media (pointer: coarse) { .wk-top .tp-bar .btn { min-height: 56px; } }
@media (max-width: 900px) {   /* phone: the sticky playback area must not eat the screen */
  .wk-top .tp-bar { gap: 6px; padding: 4px 6px; }
  .wk-top .tp-bar .btn { min-height: 48px; padding: .1em .65em; }
  .wk-top .tp-play { min-width: 0; flex: 1 1 7em; }
  .wk-top .tp-lab { display: none; }
}
@media (max-width: 900px) and (max-height: 720px) {   /* short phone: the pinned bar leaves room for a question and two answers */
  .wk-top .transport { padding: 3px 0; }
  .wk-top .tp-bar { gap: 4px; padding: 3px 6px; }
  .wk-top .tp-bar .btn { min-height: 40px; }
  .wk-submit { padding-top: 6px; padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px)); }
  .wk-submit .btn.primary { min-height: 44px; }
}
@media (max-width: 900px) {
  .wk { padding: 0 12px; }
  .wk-panes { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .wk-pane.sticky { position: static; }
  .wk-submit { margin: 0 -12px; padding-left: 12px; padding-right: 12px; }
  .wk-head h1 { font-size: 1rem; }
}

/* ---------- guide text ---------- */
.modal-wide { width: min(860px, 100%); }
.guide-modal h2.guide-title { margin: 0 2em .6em 0; }
.guide { line-height: 1.75; }
.guide h1 { font-size: 1.35rem; margin-top: 0; }
.guide h2 { font-size: 1.1rem; margin-top: 1.6em; padding-top: .8em; border-top: 1px solid var(--line); }
.guide h2:first-of-type { border-top: 0; }
.guide h3 { font-size: 1rem; margin-top: 1.2em; }
.guide ul, .guide ol { margin: 0 0 .8em; padding-left: 1.4em; }
.guide li { margin-bottom: .25em; }
.guide code { font: .9em var(--mono); padding: .05em .35em; background: var(--surface-2); border-radius: 4px; }
.guide blockquote { margin: .5em 0 1em; padding: .4em 1em; border-left: 4px solid var(--line-2); background: var(--surface-2); color: var(--text-2); border-radius: 0 var(--radius-s) var(--radius-s) 0; }
.guide table.kv { width: 100%; border-collapse: collapse; margin: .4em 0 1em; }
.guide table.kv td { padding: .5em .7em; vertical-align: top; border-top: 1px solid var(--line); }
.guide table.kv tr:first-child td { border-top: 0; }
.guide table.kv td:first-child { width: 11em; white-space: nowrap; background: var(--surface-2); }
.guide table.keys td:first-child { width: 9em; }
.guide .kbd { margin-left: 0; margin-right: .15em; }
.mk-on, .mk-stop, .mk-eot { font-weight: 700; }
.mk-on { color: var(--mark-on); }
.mk-stop { color: var(--mark-stop); }
.mk-eot { color: var(--mark-eot); }
.c-host { color: var(--speaker-host); }
.c-caller { color: var(--speaker-caller); }
b.c-host, b.c-caller { font-weight: 700; }
.hl { background: var(--hl); color: var(--hl-ink); padding: 0 .3em; border-radius: 3px; }
@media (max-width: 900px) {
  .guide table.kv td:first-child { white-space: normal; width: 6.5em; }
}

/* ---------- loading and empty states ---------- */
.empty { padding: 48px 16px; text-align: center; color: var(--text-2); }
.loading-line { padding: 56px 16px; text-align: center; color: var(--text-2); }

.tb-user { color: var(--text-2); font-size: .9em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 9em; }
@media (max-width: 700px) { .tb-user { display: none; } }
.view-holder { display: contents; }
