/* Radiology OS component styles.
   Shared colors, typography and spacing live in design-tokens.css.
   Study layout refinements live in study-design.css. */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button, a, label { touch-action: manipulation; }
a { color: var(--primary); }
@media (prefers-color-scheme: dark) { a { color: var(--lime); } }
h1, h2, h3, p { margin: 0; }
p { color: var(--muted); }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.hidden { display: none !important; }
.sr-only, input.sr-only {
  position: absolute !important; width: 1px !important; height: 1px !important;
  padding: 0 !important; margin: -1px !important; overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important; clip-path: inset(50%) !important; white-space: nowrap !important; border: 0 !important;
}

/* Fast card review uses the same contrast tokens in light and dark mode. */
.cards-dialog { width: min(680px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); border: 1px solid var(--line); border-radius: 20px; padding: 28px; background: var(--surface); color: var(--ink); overflow-y: auto; box-shadow: 0 24px 90px var(--shadow-deep); }
.cards-dialog::backdrop { background: var(--backdrop); backdrop-filter: blur(5px); }
.cards-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
#cards-content { padding: 24px 0 8px; }
#cards-prompt { font-size: clamp(21px, 3.5vw, 28px); line-height: 1.35; margin: 10px 0 28px; white-space: pre-wrap; }
#cards-answer { color: var(--ink); font-size: 19px; line-height: 1.6; padding: 20px 0; border-top: 1px solid var(--line); white-space: pre-wrap; }
#cards-context { margin: 0 0 20px; color: var(--muted); }
#cards-context p { margin-top: 12px; white-space: pre-wrap; }
.cards-links { display: flex; flex-wrap: wrap; gap: 16px; padding-top: 12px; }
#cards-reveal { width: 100%; }
.cards-shortcut { font-size: 12px; opacity: .75; margin-left: 12px; }
.cards-ratings { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.cards-ratings button { display: flex; flex-direction: column; justify-content: center; gap: 3px; padding: 13px 5px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--ink); min-height: 68px; }
.cards-ratings button:hover { border-color: var(--focus); }
.cards-ratings button span { font-size: 11px; color: var(--muted); }
.cards-ratings [data-card-rating="Good"] { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.cards-ratings [data-card-rating="Good"] span { color: var(--primary-ink); }
.cards-tools { display: flex; justify-content: space-between; margin: 18px 0; gap: 16px; }
#cards-empty { padding: 24px 0; }
#cards-empty p { margin: 12px 0 18px; }
.cards-settings { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 14px; }
.cards-settings label { display: flex; align-items: center; gap: 10px; margin: 15px 0 10px; }
.cards-settings p, .cards-settings button { margin-bottom: 12px; }
#cards-source-select { width: 100%; margin-bottom: 12px; background: var(--surface-2); color: var(--ink); padding: 10px; border: 1px solid var(--line); border-radius: 8px; }
#cards-home-status:empty { display: none; }
@media(max-width: 480px) { .cards-dialog { padding: 20px; } .cards-ratings { grid-template-columns: repeat(2, 1fr); } .cards-shortcut { display: none; } }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
main { padding: 28px 44px 40px; max-width: 1220px; width: 100%; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: var(--side); color: var(--side-ink);
  display: flex; flex-direction: column; gap: 32px;
  padding: 28px 18px 24px;
  border-right: 1px solid var(--side-line);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 6px; color: var(--side-ink); text-decoration: none; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 9px; background: var(--lime); color: var(--lime-ink);
  display: grid; place-items: center; font-size: 18px; font-weight: 600;
}
.brand-text { display: flex; flex-direction: column; }
.brand-text strong { font-size: 18px; font-weight: 600; letter-spacing: -0.4px; }
.brand-text small { font-family: var(--mono); font-size: 11px; color: var(--side-muted); }

.nav-list { display: flex; flex-direction: column; gap: 4px; }
.nav {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px;
  border: 0; border-radius: 8px; background: transparent; color: var(--muted);
  font-size: 14px; text-align: left; position: relative;
}
.nav:hover { background: var(--surface-2); }
.nav.active { background: var(--side-2); color: var(--ink); font-weight: 600; }
.nav.active::before { content: ''; position: absolute; left: 0; top: 13px; bottom: 13px; width: 3px; border-radius: 2px; background: var(--lime); }
.nav-label { flex-grow: 1; white-space: nowrap; }
.nav .short { display: none; }
.badge {
  min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px;
  background: var(--amber-badge); color: var(--amber-badge-ink);
  font-size: 12px; font-weight: 600; display: grid; place-items: center;
}
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.conn-dot.ready { background: var(--ok); }

.sidebar-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 12px; padding: 18px 8px 0; border-top: 1px solid var(--side-line); }
.side-label { font-family: var(--mono); font-size: 11px; letter-spacing: 0.6px; color: var(--muted); }
.side-links { display: flex; flex-direction: column; gap: 10px; }
.side-links a { color: var(--ink); font-size: 14px; text-decoration: none; }
.side-links a:hover { text-decoration: underline; text-underline-offset: 3px; }
.side-links.on-light { margin-top: 16px; }
.side-links.on-light a { color: var(--primary); }
@media (prefers-color-scheme: dark) { .side-links.on-light a { color: var(--lime); } }
.version { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ---------- Top bar ---------- */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 22px; }
.greeting { font-size: 26px; font-weight: 600; letter-spacing: -0.6px; line-height: 1.2; }
.top-sub { display: block; font-size: 14px; color: var(--muted); }
.status-pill {
  display: flex; align-items: center; gap: 8px; white-space: nowrap;
  font-size: 13px; color: var(--muted); background: var(--surface);
  border: 1px solid var(--line); border-radius: 20px; padding: 7px 14px;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.status-pill.ready .dot { background: var(--ok); }

/* ---------- Shared pieces ---------- */
.eyebrow { display: block; font-family: var(--mono); font-size: 12px; letter-spacing: 0.6px; color: var(--accent-text); }
.eyebrow.muted { color: var(--muted); }
.fine { font-size: 13px; line-height: 1.55; color: var(--muted); }
.quiet { font-size: 13px; color: var(--muted); }

.primary, .secondary, .quiet-button, .chip, .pending-button {
  min-height: 44px; border-radius: 9px; padding: 0 18px; font-size: 15px; font-weight: 600; white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
}
.primary { border: 0; background: var(--primary); color: var(--primary-ink); }
.primary:hover:not(:disabled) { background: var(--primary-hover); }
.primary.big { min-height: 50px; padding: 0 24px; font-size: 16px; border-radius: 10px; }
.primary.small { min-height: 38px; padding: 0 14px; font-size: 14px; }
.go { width: 26px; height: 26px; border-radius: 13px; background: var(--lime); color: var(--lime-ink); display: grid; place-items: center; font-size: 14px; }
@media (prefers-color-scheme: dark) { .go { background: transparent; width: auto; } }
.secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--line); font-weight: 400; }
.secondary:hover:not(:disabled) { border-color: var(--muted); }
.quiet-button { background: transparent; border: 0; color: var(--muted); font-weight: 400; text-decoration: underline; text-underline-offset: 3px; padding: 0 8px; }
.inline-button { border: 0; background: transparent; color: var(--primary); font-weight: 600; padding: 0; margin-left: 6px; text-decoration: underline; text-underline-offset: 3px; }
@media (prefers-color-scheme: dark) { .inline-button { color: var(--lime); } }

.notice {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 16px; margin-bottom: 18px; font-size: 14px; color: var(--muted);
}

.toast {
  position: sticky; top: 12px; z-index: 20; display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px; padding: 12px 12px 12px 16px; border-radius: 10px; font-size: 14px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: 0 6px 24px var(--shadow-color);
}
.toast span { flex-grow: 1; }
.toast.error { background: var(--amber-bg); border-color: var(--amber-line); color: var(--amber-ink); }
.toast-close { border: 0; background: transparent; font-size: 20px; line-height: 1; width: 32px; height: 32px; border-radius: 6px; color: inherit; }

/* ---------- Plan card ---------- */
.plan {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px 28px; display: flex; flex-direction: column; gap: 22px; box-shadow: var(--shadow);
  margin-bottom: 22px;
}
.plan-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; }
.plan-title { font-size: 30px; font-weight: 600; letter-spacing: -0.8px; line-height: 1.15; margin-top: 6px; }
.plan-sub { font-size: 14px; margin-top: 6px; }
.time-control { display: flex; align-items: center; gap: 10px; }
.time-control label { font-size: 14px; color: var(--muted); }
select, input:not([type=checkbox]):not([type=radio]), textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); color: var(--ink);
}
textarea { display: block; resize: vertical; line-height: 1.55; }
.time-control select { width: auto; padding: 0 12px; background: var(--surface); }

.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.step {
  border: 1px solid var(--line); border-radius: 10px; padding: 18px;
  display: flex; flex-direction: column; gap: 6px; background: var(--surface);
}
.step strong { font-size: 17px; font-weight: 600; }
.step > span { font-size: 14px; color: var(--muted); line-height: 1.5; }
.step-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.step-num { font-family: var(--mono); font-size: 12px; color: var(--accent-text); }
.step-time { font-size: 13px; color: var(--muted); }
.step.now { border: 1.5px solid var(--step-now-line); background: var(--step-now-bg); }
.step.now .step-num { color: var(--step-now-text); font-weight: 600; }
.step.now .step-time { font-size: 12px; font-weight: 600; color: var(--lime-ink); background: var(--lime); border-radius: 10px; padding: 1px 9px; }
.step.done { opacity: 0.6; }

.plan-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.or { font-size: 14px; color: var(--muted); margin-left: 6px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); border-radius: 22px; background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 400; padding: 0 16px; }
.chip:hover:not(:disabled) { border-color: var(--muted); }

/* Compact plan once a session is under way */
.plan.compact { padding: 14px 18px; gap: 12px; }
.plan.compact .plan-title { font-size: 18px; letter-spacing: -0.3px; margin-top: 2px; }
.plan.compact .plan-sub, .plan.compact .step > span, .plan.compact .step strong, .plan.compact .or, .plan.compact #today, .plan.compact .time-control { display: none; }
.plan.compact .steps { gap: 8px; }
.plan.compact .step { padding: 8px 12px; }
.plan.compact .plan-head { align-items: center; }

/* ---------- Conversation ---------- */
.study-columns { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 22px; align-items: start; }
.conversation-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 15px; padding: 16px 22px; border-bottom: 1px solid var(--line-soft); }
.panel-heading h2 { font-size: 16px; font-weight: 600; }
.messages { padding: 22px; min-height: 220px; max-height: 68vh; overflow: auto; display: flex; flex-direction: column; gap: 18px; }
.empty-chat { padding: 30px 8px; text-align: center; margin: auto 0; }
.empty-chat h3 { font-size: 18px; font-weight: 600; }
.empty-chat p { font-size: 14px; max-width: 340px; margin: 8px auto 0; }
.message { font-size: 15px; line-height: 1.65; overflow-wrap: anywhere; max-width: 680px; }
.message-label { font-family: var(--mono); font-size: 11px; letter-spacing: 0.6px; color: var(--accent-text); margin-bottom: 4px; }
.message p { color: var(--ink); white-space: pre-wrap; margin: 4px 0; }
.message h3 { font-size: 16px; font-weight: 600; margin: 12px 0 4px; }
.message pre { overflow: auto; background: var(--surface-2); border: 1px solid var(--line-soft); padding: 10px; font-size: 13px; border-radius: 8px; }
.message.user { align-self: flex-end; max-width: 560px; background: var(--user-bubble); color: var(--user-ink); border-radius: 12px 12px 4px 12px; padding: 12px 16px; }
.message.user .message-label { display: none; }
.message.user p { color: var(--user-ink); }
.message.user a { color: inherit; }
.message.system { align-self: center; font-size: 14px; color: var(--muted); }

.case-banner {
  margin: 14px 18px 0; padding: 12px 14px 12px 16px; border-radius: 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--side); color: var(--side-ink); font-size: 14px;
}
.case-banner .primary { background: var(--lime); color: var(--lime-ink); }

.composer { margin: 0 18px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); padding: 10px 12px; }
.composer textarea { border: 0; background: transparent; resize: none; min-height: 56px; padding: 4px; outline: none; }
.composer-bottom { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.composer-bottom .primary { margin-left: auto; min-height: 40px; }
.attach-button {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 14px; cursor: pointer; white-space: nowrap;
}
.attach-button svg { width: 16px; height: 16px; }

label { display: block; font-size: 15px; font-weight: 600; margin: 16px 0 6px; }
label.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 400; line-height: 1.5; margin: 14px 0; min-height: 28px; }
label.check.fine { font-size: 13px; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; flex-shrink: 0; accent-color: var(--primary); }

/* ---------- Right rail ---------- */
.learning-rail { display: flex; flex-direction: column; gap: 16px; }
.rail-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.rail-card h3 { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.rail-card > p { font-size: 14px; margin: 6px 0; }
.rail-card.subtle { background: transparent; box-shadow: none; }
.rail-big { display: block; font-size: 17px; font-weight: 600; margin: 8px 0 2px; }
.stat { display: flex; justify-content: space-between; align-items: baseline; font-size: 15px; margin-top: 12px; }
.stat strong { font-size: 17px; }
.rule { border-top: 1px solid var(--line-soft); padding-top: 12px; margin-top: 14px; }
.pending-card { background: var(--amber-bg); border-color: var(--amber-line); }
.pending-card .eyebrow { color: var(--amber-strong); }
.pending-card .rail-big { color: var(--ink); }
.pending-card p { color: var(--amber-ink); font-size: 14px; }
.pending-button { margin-top: 12px; border: 1px solid var(--amber-line); background: var(--surface); color: var(--amber-strong); font-size: 14px; min-height: 40px; padding: 0 14px; }
@media (prefers-color-scheme: dark) {
  .pending-card .rail-big { color: var(--warn); }
  .pending-button { background: var(--amber-badge); color: var(--amber-badge-ink); border: 0; }
}

/* ---------- Other tabs ---------- */
.tab { display: none; }
.tab.active { display: block; }
.page-title { padding: 18px 0 22px; }
.page-title h2 { font-size: 34px; font-weight: 600; letter-spacing: -1px; line-height: 1.15; margin: 8px 0 8px; }
.page-title p { font-size: 15px; max-width: 640px; }
.section-title { font-size: 18px; font-weight: 600; margin: 28px 0 12px; }
.two-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.setup-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 18px; }
.setup-grid > div { display: flex; flex-direction: column; gap: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.actions { display: flex; gap: 10px; margin-top: 18px; align-items: center; flex-wrap: wrap; }
.results { font-size: 12px; white-space: pre-wrap; color: var(--muted); margin: 14px 0 0; overflow-wrap: anywhere; font-family: var(--mono); }
.results:empty { display: none; }
.setup-steps { padding-left: 20px; margin: 12px 0 0; color: var(--muted); font-size: 14px; }
.setup-steps li { margin-bottom: 10px; }

.change-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 22px; margin-bottom: 16px; box-shadow: var(--shadow); }
.change-heading { display: flex; justify-content: space-between; gap: 15px; align-items: center; margin-bottom: 10px; }
.change-heading h3 { font-size: 17px; font-weight: 600; }
.change-card p { font-size: 14px; margin-bottom: 8px; }
.change-card details { margin: 12px 0; }
.change-card summary { font-size: 14px; color: var(--accent-text); cursor: pointer; min-height: 32px; }
.change-card pre { white-space: pre-wrap; font-size: 12px; overflow-wrap: anywhere; background: var(--surface-2); border: 1px solid var(--line-soft); padding: 12px; border-radius: 8px; max-height: 400px; overflow: auto; }
.tag { display: inline-block; padding: 3px 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; font-size: 12px; white-space: nowrap; }
.tag.pending { background: var(--amber-bg); border-color: var(--amber-line); color: var(--amber-strong); }
.tag.saved { color: var(--ok); }
#continue-after-writes { margin-top: 8px; }

footer { border-top: 1px solid var(--line); margin-top: 40px; padding: 20px 0 0; display: flex; gap: 20px; font-size: 12px; color: var(--muted); }
footer small { margin-left: auto; }

/* ---------- Case focus mode ---------- */
.case-focus { position: fixed; inset: 0; z-index: 50; background: var(--side); display: flex; flex-direction: column; overflow: auto; }
.case-top {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 40px 16px; color: var(--side-ink); border-bottom: 1px solid var(--side-line);
}
.case-tag { font-family: var(--mono); font-size: 13px; letter-spacing: 0.6px; color: var(--lime); }
  .case-back .short { display: none; }
.case-back { min-height: 40px; padding: 0 14px; border: 1px solid var(--field-line); border-radius: 8px; background: transparent; color: var(--ink); font-size: 14px; }
.case-body { flex-grow: 1; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
.case-info { padding: 48px 44px; color: var(--side-ink); display: flex; flex-direction: column; gap: 26px; }
.case-info h2 { font-size: 40px; font-weight: 600; letter-spacing: -1.2px; line-height: 1.1; }
.case-label { display: block; font-family: var(--mono); font-size: 12px; letter-spacing: 0.6px; color: var(--muted); margin-bottom: 6px; }
#clinical-context { font-size: 17px; line-height: 1.6; color: var(--ink); }
.case-link {
  display: flex; align-items: center; justify-content: space-between; min-height: 68px; padding: 0 22px;
  border-radius: 12px; background: var(--lime); color: var(--lime-ink) !important; font-size: 18px; font-weight: 600; text-decoration: none;
}
.case-link span:first-child { display: flex; align-items: center; gap: 12px; }
.case-link svg { width: 22px; height: 22px; }
.case-warn { font-size: 14px; line-height: 1.55; color: var(--muted); border: 1px solid var(--side-line); border-radius: 12px; padding: 14px 16px; }
.case-form { background: var(--bg); color: var(--ink); border-radius: 18px 0 0 0; padding: 40px 48px 48px; }
.case-form h3 { font-size: 22px; font-weight: 600; letter-spacing: -0.4px; margin-bottom: 4px; }
.case-form textarea { background: var(--surface); }
fieldset { border: 0; margin: 16px 0 0; padding: 0; min-width: 0; }
legend { font-size: 15px; font-weight: 600; padding: 0; margin-bottom: 8px; }
.opt { font-weight: 400; color: var(--muted); }
.segmented { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.segmented label { flex: 1 1 0; margin: 0; font-weight: 400; font-size: 14px; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: flex; align-items: center; justify-content: center; min-height: 40px; border-radius: 7px; cursor: pointer; text-align: center; padding: 0 6px; }
.segmented input:checked + span { background: var(--primary); color: var(--primary-ink); font-weight: 600; }
.segmented input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 1px; }
.case-actions { display: flex; align-items: center; justify-content: flex-start; flex-direction: row-reverse; gap: 14px; margin: 18px 0 8px; }
body.case-open { overflow: hidden; }

/* ---------- Responsive ---------- */
@media (max-width: 1150px) {
  main { padding: 24px 28px 40px; }
  .app { grid-template-columns: 210px minmax(0, 1fr); }
  .study-columns { grid-template-columns: minmax(0, 1fr) 250px; }
  .plan-head { flex-direction: column; align-items: flex-start; }
  .setup-grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .app { display: block; }
  main { padding: calc(14px + env(safe-area-inset-top, 0px)) 16px calc(96px + env(safe-area-inset-bottom, 0px)); }

  /* Sidebar becomes a bottom tab bar */
  .sidebar { position: static; height: auto; padding: 0; background: none; border: 0; display: block; }
  .brand, .sidebar-bottom { display: none; }
  .nav-list {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0;
    background: var(--surface); border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
  }
  .nav {
    flex-direction: column; justify-content: center; gap: 3px; min-height: 52px; padding: 0;
    color: var(--muted); font-size: 12px; text-align: center; border-radius: 8px;
  }
  .nav svg { width: 22px; height: 22px; }
  .nav:hover { background: transparent; }
  .nav.active { background: transparent; color: var(--primary); }
  .nav.active::before { display: none; }
  .nav .long { display: none; }
  .nav .short { display: inline; }
  .nav-label { flex-grow: 0; }
  .nav .badge { position: absolute; top: 2px; left: calc(50% + 6px); min-width: 18px; height: 18px; font-size: 11px; padding: 0 5px; }
  .nav .conn-dot { position: absolute; top: 8px; left: calc(50% + 10px); }
  @media (prefers-color-scheme: dark) {
    .nav-list { background: var(--bg); }
    .nav.active { color: var(--lime); }
  }

  .topbar { margin-bottom: 14px; }
  .greeting { font-size: 24px; }
  .status-pill { padding: 6px 10px; font-size: 12px; }

  .plan { padding: 6px 16px 16px; gap: 0; border-radius: 16px; }
  .plan-head { padding-top: 14px; gap: 10px; margin-bottom: 4px; }
  .plan-title { font-size: 20px; letter-spacing: -0.4px; }
  .plan-sub { display: none; }
  .time-control { width: 100%; }
  .time-control select { flex-grow: 1; }
  .steps { grid-template-columns: 1fr; gap: 0; margin: 6px 0 12px; }
  .step { border: 0; border-bottom: 1px solid var(--line-soft); border-radius: 0; padding: 12px 0; background: transparent; gap: 2px; }
  .step:last-child { border-bottom: 0; }
  .step > span { display: none; }
  .step.now { border: 0; border-bottom: 1px solid var(--line-soft); background: transparent; }
  .plan-actions { flex-direction: column; align-items: stretch; gap: 10px; }
  #today { width: 100%; min-height: 52px; font-size: 17px; border-radius: 12px; }
  .or { margin: 4px 0 0; }
  .chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chip { border-radius: 10px; padding: 0 10px; }
  .plan.compact { padding: 12px 14px; }
  .plan.compact .plan-head { align-items: flex-start; padding-top: 0; }
  .pending-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
  .pending-card .eyebrow, .pending-card p { display: none; }
  .pending-card .rail-big { margin: 0; font-size: 15px; flex-grow: 1; }
  .pending-card .pending-button { margin: 0; flex-shrink: 0; }
  .case-tag { font-size: 12px; }
  .case-back .long { display: none; }
  .case-back .short { display: inline; }
  .plan.compact .steps { display: none; }
  .plan.compact .chips { grid-template-columns: repeat(4, max-content); overflow-x: auto; display: flex; flex-wrap: nowrap; }

  .study-columns { grid-template-columns: 1fr; gap: 14px; }
  .learning-rail { order: -1; }
  .learning-rail .rail-card:not(.pending-card) { display: none; }
  .messages { max-height: none; padding: 16px 14px; }
  .composer { position: sticky; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); margin: 0 10px 10px; background: var(--surface-2); box-shadow: 0 8px 24px var(--shadow-color); }
  .two-cards, .setup-grid, .form-grid { grid-template-columns: 1fr; }
  .page-title h2 { font-size: 28px; }
  footer { display: none; }

  /* Case focus on phone */
  .case-top { padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; }
  .case-body { display: flex; flex-direction: column; }
  .case-info { padding: 18px 20px 22px; gap: 14px; }
  .case-info h2 { font-size: 26px; letter-spacing: -0.6px; }
  #clinical-context { font-size: 15px; }
  .case-link { min-height: 56px; font-size: 17px; }
  .case-warn { font-size: 13px; padding: 12px 14px; }
  .case-form { border-radius: 18px 18px 0 0; padding: 20px 18px calc(110px + env(safe-area-inset-bottom, 0px)); flex-grow: 1; }
  .case-actions {
    position: fixed; left: 0; right: 0; bottom: 0; margin: 0; z-index: 2;
    padding: 12px 18px calc(14px + env(safe-area-inset-bottom, 0px));
    background: var(--bg); border-top: 1px solid var(--line);
  }
  .case-actions .primary { flex-grow: 1; min-height: 52px; font-size: 17px; border-radius: 12px; }
}

@media (prefers-reduced-motion: no-preference) {
  .case-focus:not(.hidden) .case-form { animation: rise 0.28s ease-out; }
  @keyframes rise { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
}
@media (prefers-color-scheme: dark) { .case-form { background: var(--surface); } .case-form textarea, .segmented { background: var(--surface-2); } }

/* ======================================================
   Domain map (learner model)
   ====================================================== */


.s-unseen { background: transparent; border: 1.5px dashed var(--s-unseen-line); color: var(--s-unseen-ink); }
.s-building { background: var(--s-building); border: 1.5px solid var(--s-building-line); color: var(--s-building-ink); }
.s-practicing { background: var(--s-practicing); border: 1.5px solid var(--s-practicing-line); color: var(--s-practicing-ink); }
.s-functional { background: var(--s-functional); border: 1.5px solid var(--s-functional-line); color: var(--s-functional-ink); }
.s-transfer { background: var(--s-transfer); border: 1.5px solid var(--s-transfer); color: var(--s-transfer-ink); }
.s-stable { background: var(--s-stable); border: 1.5px solid var(--s-stable); color: var(--s-stable-ink); box-shadow: inset 0 0 0 2px var(--s-stable-ring); }

.neglect-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--neglect); flex-shrink: 0; }
.nav .nav-dot { position: static; }
.warn { color: var(--neglect-ink) !important; font-weight: 400; }

/* Header + filters */
.dm-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; }
.dm-header .page-title { padding-bottom: 18px; }
.dm-header .page-title h2 { margin-top: 0; }
.dm-filters { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); margin-bottom: 22px; flex-shrink: 0; }
.dm-filters button { min-height: 38px; padding: 0 14px; border: 0; border-radius: 7px; background: transparent; color: var(--ink); font-size: 14px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.dm-filters button[aria-selected="true"] { background: var(--primary); color: var(--primary-ink); font-weight: 600; }
.dm-neglect-pill { display: none; }

/* Summary */
.dm-summary { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow); margin-bottom: 22px; display: flex; flex-direction: column; gap: 16px; }
.dm-summary-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.dm-summary-head h3 { font-size: 17px; font-weight: 600; }
.dm-bar { display: flex; height: 18px; gap: 2px; border-radius: 6px; overflow: hidden; }
.dm-seg { border: 0 !important; box-shadow: none !important; }
.dm-seg.s-unseen { background: repeating-linear-gradient(135deg, var(--s-unseen-hatch) 0 4px, transparent 4px 8px); }
.dm-legend { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.dm-legend li { display: flex; flex-direction: column; gap: 3px; }
.dm-legend-head { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.dm-legend-sub { font-size: 13px; color: var(--muted); line-height: 1.4; }
.dm-swatch { width: 14px; height: 14px; border-radius: 4px; flex-shrink: 0; }

/* Domain rows */
.dm-columns { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.dm-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 22px; box-shadow: var(--shadow); }
.dm-row { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line-soft); align-items: start; }
.dm-row:last-child { border-bottom: 0; }
.dm-row-info { display: flex; flex-direction: column; gap: 2px; }
.dm-row-name { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.dm-row-touched { font-size: 13px; color: var(--muted); }
.dm-mini { display: none; }
.dm-tiles { display: flex; flex-wrap: wrap; gap: 6px; }
.dm-tile { min-height: 36px; padding: 0 12px; border-radius: 7px; font-size: 13px; font-weight: 400; white-space: nowrap; }
.dm-tile:hover { filter: brightness(0.97); }
.dm-tile.selected { outline: 2px solid var(--selected-ring); outline-offset: 2px; font-weight: 600; }
.dm-empty { padding: 20px 0; }

/* Detail panel */
.dm-detail { position: sticky; top: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.dm-detail-empty .dm-detail-body, .dm-detail-empty .dm-back { display: none; }
.dm-pick-hint { display: none; font-size: 14px; }
.dm-detail-empty .dm-pick-hint { display: block; }
.dm-detail-body { display: flex; flex-direction: column; gap: 16px; }
.dm-back { display: flex; align-items: center; gap: 4px; border: 0; background: transparent; padding: 0; min-height: 28px; color: var(--muted); font-size: 13px; pointer-events: none; }
.dm-back svg { display: none; }
#dm-d-name { font-size: 24px; font-weight: 600; letter-spacing: -0.5px; line-height: 1.2; margin-top: -8px; }
.dm-badge { align-self: flex-start; font-size: 13px; font-weight: 600; border-radius: 12px; padding: 2px 11px; margin-top: -8px; }
.dm-ladder { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.dm-ladder li { display: grid; grid-template-columns: 22px 1fr; gap: 12px; align-items: center; font-size: 14px; color: var(--muted); line-height: 1.4; }
.dm-rung { width: 14px; height: 14px; margin: 0 4px; border-radius: 50%; }
.dm-ladder li.done .dm-rung { background: var(--primary); border: 0; box-shadow: none; }
.dm-ladder li.todo .dm-rung { background: transparent; border: 1.5px solid var(--s-unseen-line); box-shadow: none; }
.dm-ladder li.now { color: var(--ink); font-weight: 600; }
.dm-ladder li.now .dm-rung { width: 22px; height: 22px; margin: 0; box-shadow: 0 0 0 3px var(--s-building); }
.dm-evidence-wrap { border-top: 1px solid var(--line-soft); padding-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.dm-evidence-wrap h4 { margin: 0; font-size: 15px; font-weight: 600; }
.dm-ev { display: grid; grid-template-columns: 64px 1fr; gap: 10px; font-size: 14px; line-height: 1.45; padding: 4px 0; }
.dm-ev-date { color: var(--muted); }
.dm-ev.miss .dm-ev-text::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--neglect); margin-right: 7px; vertical-align: 1px; }
.dm-next { background: var(--step-now-bg); border: 1px solid var(--s-building-line); border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; font-size: 14px; line-height: 1.5; }
.dm-next span { color: var(--muted); }
.dm-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.dm-actions a { font-size: 14px; }

/* Today: coverage pick + balance */
.step.coverage { border-color: var(--amber-line); background: var(--amber-bg); }
.step.coverage .step-num { color: var(--amber-strong); font-weight: 600; }
.step.coverage .step-desc { color: var(--amber-ink); }
.coverage-tag { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--amber-strong); margin-left: auto; margin-right: 8px; }
.coverage-queued { font-size: 14px; color: var(--muted); margin: -8px 0 0; }
.coverage-queued:empty, .plan.compact .coverage-queued { display: none; }

.balance { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow); margin-bottom: 22px; display: flex; flex-direction: column; gap: 14px; }
.balance-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.balance-head h2 { font-size: 17px; font-weight: 600; }
.balance-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(58px, 1fr)); gap: 8px; align-items: end; }
.bal-col { display: flex; flex-direction: column; gap: 6px; align-items: stretch; text-align: left; border: 0; background: transparent; padding: 4px; border-radius: 6px; color: var(--ink); }
.bal-col:hover { background: var(--surface-2); }
.bal-col.picked { outline: 2px solid var(--neglect); outline-offset: 2px; }
.bal-stack { display: flex; flex-direction: column-reverse; gap: 2px; }
.bal-stack span { height: 9px; border-radius: 2px; box-shadow: none !important; }
.bal-stack .s-unseen { border-width: 1px; }
.bal-name { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.bal-name .neglect-dot { width: 7px; height: 7px; }
.bal-age { font-size: 12px; color: var(--muted); white-space: nowrap; }
.plan.compact + .balance { display: none; }

@media (max-width: 1150px) {
  .dm-columns { grid-template-columns: minmax(0, 1fr) 290px; }
  .dm-row { grid-template-columns: 1fr; gap: 10px; }
  .dm-legend { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dm-header { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 860px) {
  .nav-list { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .nav .nav-dot { position: absolute; top: 8px; left: calc(50% + 10px); }

  .dm-header { flex-direction: row; align-items: center; justify-content: space-between; margin-bottom: 12px; }
  .dm-header .page-title { padding: 0; }
  .dm-header .page-title h2 { font-size: 26px; margin: 0; }
  .dm-header .page-title p, .dm-filters { display: none; }
  .dm-neglect-pill { display: flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border: 1px solid var(--amber-line); border-radius: 18px; background: var(--amber-bg); color: var(--amber-strong); font-size: 13px; font-weight: 600; }
  .dm-neglect-pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--neglect); }

  .dm-summary { padding: 0; border: 0; background: none; box-shadow: none; gap: 8px; margin-bottom: 14px; }
  .dm-summary-head h3 { display: none; }
  .dm-bar { height: 12px; border-radius: 4px; order: -1; }
  .dm-legend { display: none; }

  .dm-columns { display: block; }
  .dm-list { padding: 4px 16px; border-radius: 14px; }
  .dm-row { grid-template-columns: 1fr; gap: 10px; padding: 12px 0; }
  .dm-row-info { display: grid; grid-template-columns: 1fr 96px; grid-template-rows: auto auto; column-gap: 12px; align-items: center; }
  .dm-row-name { grid-column: 1; }
  .dm-row-touched { grid-column: 1; font-size: 12px; }
  .dm-mini { display: flex; gap: 2px; height: 10px; grid-column: 2; grid-row: 1 / span 2; }
  .dm-mini span { flex: 1; border-radius: 2px; box-shadow: none !important; }
  .dm-mini .s-unseen { border-width: 1px; }
  .dm-tile { min-height: 36px; }

  .dm-detail {
    position: fixed; inset: 0; z-index: 50; border: 0; border-radius: 0; box-shadow: none;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 20px calc(24px + env(safe-area-inset-bottom, 0px));
    overflow: auto; display: none; background: var(--bg);
  }
  .dm-detail.open { display: block; }
  .dm-back { pointer-events: auto; min-height: 44px; margin: 0 0 6px -8px; font-size: 15px; color: var(--muted); }
  .dm-back svg { display: block; width: 22px; height: 22px; color: var(--ink); }
  #dm-d-name { font-size: 28px; margin-top: 0; }
  .dm-badge { margin-top: -6px; }
  .dm-evidence-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
  .dm-actions { position: sticky; bottom: 0; padding: 12px 0 4px; background: var(--bg); flex-direction: column; align-items: stretch; }
  #dm-practice { min-height: 52px; font-size: 17px; border-radius: 12px; }

  .balance { padding: 16px; }
  .balance-head .fine { display: none; }
  .balance-grid { display: flex; overflow-x: auto; gap: 6px; padding-bottom: 4px; }
  .bal-col { flex: 0 0 60px; }
  .step.coverage { border: 0; border-bottom: 1px solid var(--line-soft); background: transparent; }
  .step.coverage .step-desc { display: block; font-size: 13px; }
  .coverage-tag { margin-right: 6px; }
}
@media (max-width: 860px) {
  .chips { grid-auto-flow: dense; }
  #swap-pick { grid-column: 1 / -1; }
}

/* ---------- v0.5 visual hierarchy + inviting input ---------- */


body { letter-spacing: -0.005em; }
main { max-width: 1280px; }
.plan {
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-3) 150%);
  border-color: color-mix(in srgb, var(--line) 70%, var(--accent-text));
}
.plan-title { max-width: 760px; }
.step { background: var(--surface-2); border-color: var(--line-soft); }
.step.now { background: var(--teal-soft); border-color: var(--accent-text); }
.step.preview-step { grid-column: 1 / -1; background: var(--surface-2); }
.dynamic-steps { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.chip { background: var(--surface-2); }
.chip:hover:not(:disabled) { background: var(--surface-3); border-color: var(--accent-text); }

.conversation-panel { background: var(--surface); overflow: hidden; }
.panel-heading { background: color-mix(in srgb, var(--surface) 80%, var(--teal-soft)); }
.messages { background: color-mix(in srgb, var(--bg) 48%, var(--surface)); }
.message.assistant {
  max-width: 760px;
  background: var(--assistant-bg);
  border-left: 3px solid var(--accent-text);
  border-radius: 4px 12px 12px 4px;
  padding: 12px 15px;
}
.message.assistant .message-label { color: var(--accent-text); }
.message.user { box-shadow: 0 8px 20px var(--shadow-color); }

.composer {
  position: relative;
  margin: 14px 18px 18px;
  padding: 14px 14px 12px;
  background: var(--composer-bg);
  border: 1.5px solid var(--composer-line);
  border-radius: 16px;
  box-shadow: 0 10px 30px var(--shadow-color);
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.composer:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--composer-glow), 0 14px 32px var(--shadow-color);
  transform: translateY(-1px);
}
.composer-prompt { display: flex; align-items: center; gap: 10px; margin: 0 2px 8px; }
.composer-prompt > span:last-child { display: flex; flex-direction: column; line-height: 1.25; }
.composer-prompt strong { font-size: 14px; color: var(--ink); }
.composer-prompt small { font-size: 12px; color: var(--muted); margin-top: 2px; }
.composer-spark {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  font-family: var(--mono); font-size: 11px; font-weight: 600; background: var(--lime); color: var(--lime-ink);
}
.composer textarea {
  min-height: 78px; max-height: 420px; padding: 6px 4px 10px; font-size: 16px;
  color: var(--ink); caret-color: var(--primary);
}
.composer textarea::placeholder { color: color-mix(in srgb, var(--muted) 78%, transparent); }
.composer-bottom { padding-top: 8px; border-top: 1px solid var(--line-soft); }
.dictate-button, .field-mic {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 9px; min-height: 40px; padding: 0 12px; font-size: 14px; font-weight: 600;
}
.dictate-button:hover, .field-mic:hover { border-color: var(--accent-text); background: var(--surface-3); }
.dictate-button.listening, .field-mic.listening {
  background: var(--amber-bg); border-color: var(--amber-line); color: var(--amber-strong);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--amber-line) 24%, transparent);
}
.mic-icon { font-size: 11px; line-height: 1; }
.send-button { min-width: 98px; }
.attach-button { background: transparent; }

.learning-rail .rail-card:nth-child(2n) { background: var(--surface-2); }
.rail-card { border-color: var(--line-soft); }

.case-focus { background: var(--surface-2); }
.case-form { background: var(--surface); }
.case-form textarea {
  min-height: 118px; max-height: 420px; background: var(--surface-2);
  border-color: var(--line); font-size: 16px; line-height: 1.6;
}
#impression { min-height: 84px; }
.case-field-head { display: flex; align-items: end; justify-content: space-between; gap: 10px; margin-top: 16px; }
.case-field-head label { margin: 0; }
.field-mic { min-height: 36px; padding: 0 10px; font-size: 13px; }
.case-warn { background: var(--surface-2); }
.case-tag { color: var(--lime); }
.segmented { background: var(--surface-2); }

.dm-summary, .dm-list, .dm-detail, .balance { border-color: var(--line-soft); }
.dm-detail { background: var(--surface); }

@media (max-width: 860px) {
  .composer { margin: 10px 12px 14px; border-radius: 15px; }
  .composer-bottom { flex-wrap: wrap; }
  .composer-bottom .send-button { margin-left: auto; }
  .dictate-button { order: 2; }
  .send-button { order: 3; }
  .message.assistant { max-width: 100%; }
  .case-field-head { align-items: center; }
  .case-form textarea { min-height: 132px; }
  #impression { min-height: 94px; }
}
.profile-steering {
  display: grid; grid-template-columns: minmax(220px,1.1fr) minmax(0,2fr) auto; gap: 18px; align-items: end;
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px;
}
.profile-steering-copy { display: flex; flex-direction: column; gap: 3px; }
.profile-steering-copy strong { font-size: 15px; line-height: 1.35; }
.profile-steering-copy small { color: var(--muted); font-size: 12px; }
.profile-steering-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 10px; }
.profile-steering-grid label { margin: 0; font-size: 12px; color: var(--muted); font-weight: 600; }
.profile-steering-grid select { margin-top: 4px; min-width: 0; width: 100%; font-size: 13px; background: var(--surface-2); }
@media (max-width: 1150px) { .profile-steering { grid-template-columns: 1fr; align-items: stretch; } }
@media (max-width: 860px) {
  .profile-steering { padding: 14px; gap: 12px; }
  .profile-steering-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .profile-steering .secondary { width: 100%; }
}


/* v0.5 polish: clearer visual hierarchy without visual noise */
.step:nth-child(2):not(.now) { background: var(--blue-soft); }
.step:nth-child(3):not(.now) { background: color-mix(in srgb, var(--amber-bg) 52%, var(--surface)); }
.learning-rail .rail-card:first-child:not(.pending-card) { background: var(--blue-soft); }
.learning-rail .rail-card.pending-card { background: var(--amber-bg); border-color: var(--amber-line); }
.composer {
  background: linear-gradient(145deg, var(--composer-bg) 0%, color-mix(in srgb, var(--teal-soft) 32%, var(--composer-bg)) 100%);
}
.composer-prompt strong { letter-spacing: -0.01em; }
.send-button { box-shadow: 0 5px 16px color-mix(in srgb, var(--primary) 22%, transparent); }
.send-button:hover:not(:disabled) { transform: translateY(-1px); }
.message.assistant h3 { color: var(--ink); }
.message.assistant strong { color: var(--ink); }
.case-form { box-shadow: -18px 0 50px var(--shadow-color); }

/* Explicit session lifecycle */
.session-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.session-controls .small {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
}
@media (max-width: 860px) {
  .panel-heading { align-items: flex-start; }
  .session-controls { gap: 8px; }
  .session-controls .quiet { display: none; }
}


/* v0.5 mobile usability patch */
@media (max-width: 860px) {
  /* Five actual destinations: Today, Profile, Record, Details, Setup. */
  .nav-list {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    padding-left: 2px;
    padding-right: 2px;
  }
  .nav {
    min-width: 0;
    font-size: 11px;
  }
  .nav svg { width: 21px; height: 21px; }

  /* Let the conversation own the viewport; the composer must not cover it. */
  .conversation-panel { overflow: visible; }
  .messages {
    padding: 14px 12px 10px;
    scroll-padding-bottom: 12px;
  }
  .composer {
    position: static;
    bottom: auto;
    margin: 0 10px 14px;
    padding: 10px 12px;
    border-radius: 14px;
    box-shadow: none;
    background: var(--composer-bg);
  }
  .composer-prompt {
    gap: 8px;
    margin: 0 0 4px;
  }
  .composer-prompt small { display: none; }
  .composer-spark {
    width: 24px;
    height: 24px;
    border-radius: 7px;
    font-size: 10px;
  }
  .composer textarea {
    min-height: 54px;
    max-height: 120px;
    padding: 5px 2px 8px;
    font-size: 16px;
    line-height: 1.45;
  }
  .composer-bottom {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 8px;
    align-items: center;
    padding-top: 8px;
    margin-top: 2px;
  }
  .attach-button,
  .dictate-button,
  .send-button {
    min-height: 38px;
    padding: 0 10px;
    font-size: 13px;
  }
  .attach-button {
    min-width: 0;
    justify-content: center;
  }
  .send-button { min-width: 82px; }
  #attachment-name {
    grid-column: 1 / -1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  #attachment-consent {
    margin: 8px 0 0;
    font-size: 12px;
  }

  /* Keep content clear of the fixed tab bar and iPhone safe area. */
  main {
    padding-bottom: calc(82px + env(safe-area-inset-bottom, 0px));
  }
}

.source-choice {
  margin: 0 18px 12px;
  padding: 17px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.source-choice-top, .source-choice-actions, .source-choice-links {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
}
.source-choice-top { justify-content: space-between; margin-bottom: 8px; }
.source-choice-eyebrow { font-size: 11px; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); }
.source-choice > strong { font-size: 17px; display: block; line-height: 1.35; }
.source-choice > .fine { margin: 9px 0 0; }
.source-choice-actions { margin-top: 14px; }
.source-choice-actions button { min-height: 42px; }
.source-choice-links { margin-top: 10px; font-size: 13px; }
.source-choice-links a { color: var(--accent-text); text-decoration: underline; text-underline-offset: 3px; }
@media (max-width: 860px) {
  .source-choice { margin: 0 10px 10px; padding: 15px; }
  .source-choice-actions { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
  .source-choice-actions button { width: 100%; padding: 10px 12px; }
  .source-choice-actions button:first-child:nth-last-child(3) { grid-column: 1 / -1; }
}

.resume-inline {
  margin: 0 18px 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--teal-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}
@media (max-width: 860px) {
  .resume-inline {
    margin: 0 10px 8px;
    padding: 9px 10px;
    font-size: 13px;
  }
  .resume-inline .small {
    min-height: 36px;
    padding: 0 10px;
    flex-shrink: 0;
  }
  #essay-inline {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  #essay-inline > span { grid-column: 1 / -1; }
  #essay-inline .small {
    min-width: 0;
    padding: 8px;
    white-space: normal;
  }
  .plan.compact .chips {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
    gap: 8px;
  }
  .plan.compact .chip {
    width: 100%;
    min-width: 0;
  }
}


/* Staged workflow UX: feedback must be read before advancing. */
.turn-next-action {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.turn-next-hint { color: var(--muted); font-size: .9rem; }
.turn-next-button { min-height: 46px; padding-inline: 18px; font-weight: 600; }
@media (max-width: 680px) {
  .turn-next-action { align-items: stretch; flex-direction: column; }
  .turn-next-button { width: 100%; }
}


.turn-event {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}


/* Board checkpoint — deterministic answer UI, generated once then cached. */
.board-answer-block {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.board-choice-grid {
  display: grid;
  gap: 9px;
}
.board-choice {
  width: 100%;
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: start;
  gap: 10px;
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.board-choice:hover,
.board-choice:focus-visible {
  border-color: var(--line);
  transform: translateY(-1px);
}
.board-choice-key {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  font-weight: 600;
  background: var(--line);
}
.board-choice-text { line-height: 1.35; padding-top: 4px; }
.board-note { margin: 10px 0 0; }


/* Keep errors visible above the case dialog. */
body.case-open .toast { position: fixed; left: 16px; right: 16px; top: 12px; z-index: 100; }
#commit-status { color: var(--ink); background: var(--surface-2); }

/* Focused study: one current task, with paired answers kept together. */
.focus-step-bar { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 12px 18px; margin-bottom: 20px; }
.focus-step-line { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; font-size: 14px; }
.focus-step-line > .quiet-button { margin-left: auto; }
.step-estimate { color: var(--muted); font-size: 13px; }
.focus-segments { display: flex; gap: 6px; margin-top: 9px; }
.focus-segments span { height: 3px; flex: 1; background: var(--line-soft); border-radius: 6px; }
.focus-segments .done { background: var(--primary); }
.focus-segments .current { background: var(--ok); }
.focused-session:not(.show-session-options) #plan,
.focused-session #balance { display: none; }
.focused-session .study-columns { display: block; }
.focused-session .learning-rail { display: none; }
.focused-session .conversation-panel { background: transparent; border: 0; box-shadow: none; overflow: visible; }
.focused-session .panel-heading { padding: 0 0 12px; border: 0; background: transparent; position: static; }
.focused-session .panel-heading > h2 { display: none; }
.focused-session .session-controls { width: 100%; justify-content: flex-end; }
.focused-session .session-controls #working { margin-right: auto; }
.focused-study { max-width: 860px; margin: 0 auto 26px; }
.drill-card { padding: 32px 38px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: 0 8px 30px var(--shadow-color); }
.drill-top { display: flex; justify-content: space-between; align-items: center; gap: 18px; }
.drill-dots { display: flex; gap: 7px; }
.drill-dots span { height: 7px; width: 7px; border-radius: 50%; background: var(--line); }
.drill-dots .done { background: var(--ok); }
.drill-dots .current { background: var(--primary); box-shadow: 0 0 0 3px var(--line-soft); }
.drill-card .drill-question { font-size: clamp(24px, 2.5vw, 32px); line-height: 1.35; font-weight: 400; letter-spacing: -.6px; margin: 28px 0; color: var(--ink); }
.drill-card label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.drill-card textarea { display: block; width: 100%; background: var(--surface-2); padding: 16px; min-height: 116px; border: 1px solid var(--line); border-radius: 12px; resize: vertical; line-height: 1.5; font-size: 17px; }
.drill-actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 18px; }
.drill-actions button { min-height: 48px; min-width: 140px; }
.drill-shortcuts { margin-top: 15px; font-size: 11px; color: var(--muted); }
.drill-source { display: inline-block; margin-top: 15px; font-size: 13px; text-underline-offset: 3px; }
.drill-help { border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; margin-top: 14px; background: var(--surface-2); }
.drill-help summary { cursor: pointer; font-size: 14px; color: var(--muted); }
.drill-help form { display: flex; gap: 10px; align-items: flex-end; margin-top: 12px; }
.drill-help textarea { flex: 1; min-width: 0; font-size: 16px; padding: 12px; }
.drill-help p { margin-top: 12px; color: var(--ink); }
.drill-feedback { padding: 20px; border: 1px solid var(--line-soft); border-radius: 12px; background: var(--surface-2); }
.drill-your-answer { color: var(--ink); font-size: 18px; margin: 4px 0 18px; white-space: pre-wrap; }
.drill-verdict { display: block; font-size: 17px; color: var(--accent-text); }
.drill-due { display: block; font-size: 13px; color: var(--muted); margin-top: 4px; }
.drill-explanation { margin-top: 14px; color: var(--ink); line-height: 1.6; }
.drill-reference { margin-top: 12px; font-size: 14px; }
.drill-next { display: block; width: 100%; min-height: 52px; margin-top: 24px; }
.answered-questions { max-width: 860px; margin: 0 auto 26px; }
.answered-questions > h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); padding: 0 2px 10px; }
.answer-row { background: var(--surface); padding: 16px 20px; border: 1px solid var(--line); border-bottom: 0; }
.answer-row:nth-child(2) { border-radius: 12px 12px 0 0; }
.answer-row:last-child { border-bottom: 1px solid var(--line); border-radius: 0 0 12px 12px; }
.answer-row:nth-child(2):last-child { border-radius: 12px; }
.answer-row-question { color: var(--ink); font-size: 14px; font-weight: 600; }
.answer-row-summary { display: flex; flex-wrap: wrap; gap: 5px 14px; font-size: 13px; margin-top: 5px; color: var(--muted); }
.answer-row-summary s { text-decoration-color: var(--warn); }
.answer-grade { color: var(--accent-text); }
.answer-due { margin-left: auto; font-size: 12px; }
.answer-reference { color: var(--ink); font-size: 13px; margin-top: 6px; }
.answer-row details { font-size: 13px; margin-top: 7px; }
.answer-row summary { color: var(--muted); cursor: pointer; }
.answer-row details p { margin-top: 7px; }
.conversation-history { min-width: 0; }
.conversation-history > summary { cursor: pointer; color: var(--muted); padding: 12px 18px; font-size: 13px; }
.focused-session .conversation-history { max-width: 860px; margin: 0 auto 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.focused-session .messages { min-height: 0; max-height: none; height: auto; overflow: visible; }
.drill-open #chat-form, .drill-open #essay-inline { display: none; }
.focused-session .composer { max-width: 860px; margin: 16px auto; width: 100%; }
.focused-session .resume-inline { max-width: 860px; margin: 0 auto 16px; }
.focused-session footer { margin-top: 26px; }
.drill-open #working { font-size: 13px; }
.viewer-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--muted); }
.viewer-toolbar a { color: var(--accent-text); }
.case-info { gap: 16px; padding: 24px; background: var(--surface); }
.viewer-note { color: var(--muted); font-size: 12px; }
.case-info .case-link { min-height: 48px; font-size: 15px; }
.case-info .case-warn { font-size: 12px; color: var(--muted); border-color: var(--line); }
.case-form { padding: 28px 36px; }
.case-form #clinical-context { color: var(--muted); font-size: 15px; line-height: 1.6; margin: 12px 0 20px; }
.case-form h2 { font-size: 28px; line-height: 1.25; letter-spacing: -.6px; margin-top: 10px; }
.case-form h3 { font-size: 16px; margin-top: 24px; }
.case-step-bar { border-bottom: 1px solid var(--line); padding-bottom: 14px; margin-bottom: 24px; color: var(--muted); font-size: 13px; }
.case-reminder { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: 14px; margin-bottom: 16px; }
.case-reminder summary { cursor: pointer; color: var(--accent-text); }
.case-reminder div { margin-top: 10px; }
.case-hint-text { border-left: 3px solid var(--ok); padding: 10px 16px; background: var(--surface); margin: 16px 0; font-size: 14px; }
.search-trace { padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 13px; overflow-wrap: anywhere; }
.search-trace > a { display: block; margin-top: 6px; }
.case-actions { flex-direction: row; flex-wrap: wrap; }
.case-actions .primary { margin-left: auto; }
@media (min-width: 861px) {
  .focused-session .app { grid-template-columns: 76px minmax(0, 1fr); }
  .focused-session .sidebar { padding: 24px 12px; align-items: center; }
  .focused-session .brand { padding: 0; }
  .focused-session .brand-text, .focused-session .sidebar-bottom, .focused-session .nav-label { display: none; }
  .focused-session .nav-list { width: 100%; gap: 12px; }
  .focused-session .nav { padding: 0; justify-content: center; min-height: 48px; }
  .focused-session .nav > .conn-dot, .focused-session .nav > .badge { position: absolute; top: 3px; right: 0; }
  .focused-session main { max-width: 1220px; margin: 0 auto; padding: 24px 48px 40px; }
  .focused-session .topbar { margin-bottom: 22px; }
  .focused-session .greeting { font-size: 21px; }
  .focused-session .top-sub { font-size: 11px; }
  .case-body { grid-template-columns: minmax(260px, .7fr) minmax(390px, 1.3fr); }
}
@media (max-width: 860px) {
  .focus-step-bar { padding: 12px; margin-bottom: 12px; }
  .focus-step-line { gap: 4px 10px; font-size: 12px; }
  .focus-step-line .step-estimate { font-size: 11px; }
  .focus-step-line > .quiet-button { font-size: 11px; min-height: 32px; padding: 0; }
  .focused-session main { padding-left: 12px; padding-right: 12px; }
  .focused-session .panel-heading { padding: 0 2px 10px; }
  .focused-session .session-controls .small { min-height: 32px; font-size: 11px; padding: 0 8px; }
  .focused-session .session-controls #working { display: block; font-size: 11px; }
  .focused-session .topbar { margin-bottom: 16px; }
  .focused-study { margin-bottom: 20px; }
  .drill-card { padding: 22px 18px 18px; border-radius: 16px; }
  .drill-card .drill-question { font-size: 24px; margin: 22px 0; }
  .drill-top .eyebrow { font-size: 11px; }
  .drill-card textarea { font-size: 16px; min-height: 108px; }
  .drill-actions button { min-width: 0; flex: 1; font-size: 14px; }
  .drill-shortcuts { display: none; }
  .drill-help { padding: 12px 14px; }
  .drill-help summary { font-size: 13px; }
  .drill-feedback { padding: 16px; }
  .drill-explanation { font-size: 15px; }
  .drill-next { position: sticky; bottom: calc(84px + env(safe-area-inset-bottom, 0px)); z-index: 2; box-shadow: 0 4px 16px var(--shadow-color); }
  .answer-row { padding: 14px; }
  .answer-due { width: 100%; margin-left: 0; }
  .focused-session .composer { position: static; width: 100%; margin: 12px 0; }
  .case-body { display: flex; flex-direction: column; }
  .case-info { padding: 14px; }
  .case-form { padding: 24px 18px calc(24px + env(safe-area-inset-bottom, 0px)); border-radius: 18px 18px 0 0; }
  .case-actions { gap: 10px; }
  .case-actions .primary { width: 100%; min-height: 52px; order: 3; }
}

.external-study-guide h2 { font-size: 25px; letter-spacing: -.5px; }
.external-study-guide p { color: var(--muted); font-size: 15px; margin-top: 14px; }
/* Optional scan teaching uses the same external viewer and keeps the read draft. */
.walkthrough-look { padding: 16px 18px; margin: 20px 0 24px; border: 1px solid var(--line); border-left: 4px solid var(--accent-text); border-radius: 12px; background: var(--teal-soft); }
.walkthrough-explanation { font-size: 1.05rem; line-height: 1.7; margin-bottom: 16px; }
.walkthrough-why { margin: 0 0 24px; }
#walkthrough-panel .walkthrough-section-title { color: var(--accent-text); font-size: .82rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; margin: 0 0 10px; }
.walkthrough-copy { max-width: 68ch; line-height: 1.7; overflow-wrap: anywhere; }
.walkthrough-copy p { margin: 0 0 14px; }
.walkthrough-copy > :last-child { margin-bottom: 0; }
.walkthrough-copy strong { color: var(--accent-text); background: var(--blue-soft); padding: .06em .16em; border-radius: 3px; font-weight: 600; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.walkthrough-points { margin: 0; padding-left: 1.25em; }
.walkthrough-points li { padding-left: .35em; margin-bottom: 14px; }
.walkthrough-points li::marker { color: var(--accent-text); }
.walkthrough-points li:last-child { margin-bottom: 0; }
.walkthrough-reporting { margin: 24px 0; padding: 20px; border: 1px solid var(--line); border-radius: 12px; }
.walkthrough-reporting > h3 { margin: 0 0 18px; font-size: 1.15rem; }
.walkthrough-report-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 24px; }
.walkthrough-report-choices h4 { margin: 0 0 8px; font-size: .92rem; color: var(--accent-text); }
.walkthrough-report-choices .walkthrough-copy { font-size: .95rem; }
.walkthrough-report-example, .walkthrough-report-references { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 18px; }
.walkthrough-reporting summary { cursor: pointer; color: var(--accent-text); font-weight: 600; }
.walkthrough-report-example pre { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; line-height: 1.65; background: var(--surface-2); color:var(--ink); border-radius: 8px; padding: 16px; }
.walkthrough-report-references a { display: block; font-size: .85rem; margin-top: 10px; }
@media (prefers-color-scheme: dark) {
  .walkthrough-look { background: var(--teal-soft); border-color: var(--line); border-left-color: var(--accent-text); }
  .walkthrough-look .walkthrough-copy, .walkthrough-look .walkthrough-copy p { color: var(--ink); }
  #walkthrough-panel .walkthrough-section-title,
  .walkthrough-report-choices h4, .walkthrough-reporting summary { color: var(--accent-text); }
  .walkthrough-copy strong { color: var(--lime); background: var(--teal-soft); }
  .walkthrough-points li::marker { color: var(--accent-text); }
  .walkthrough-reporting, .walkthrough-report-example, .walkthrough-report-references { border-color: var(--line); }
  .walkthrough-report-example pre { color: var(--ink); background: var(--surface-2); }
}
@media (max-width: 600px) { .walkthrough-report-choices { grid-template-columns: 1fr; } .walkthrough-reporting { padding: 16px; } }
.walkthrough-controls { display: flex; flex-wrap: wrap; gap: 10px; margin: 20px 0 12px; }
.walkthrough-question { display: grid; gap: 8px; margin-top: 20px; }
.walkthrough-question textarea { width: 100%; }
.walkthrough-question button { justify-self: start; }
.walkthrough-history { margin-top: 16px; }
.walkthrough-user { font-weight: 600; }
#walkthrough-panel > .primary { margin-top: 20px; }
@media (max-width: 600px) { .walkthrough-controls .primary { width: 100%; } }


/* Head-to-toe curriculum: focused location, not another dashboard. */
.curriculum-path {
  display: flex; justify-content: space-between; align-items: center; gap: 18px;
  padding: 17px 20px; margin-bottom: 16px;
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius);
}
.curriculum-path-main { flex: 1; min-width: 0; }
.curriculum-path-titleline { display: flex; align-items: baseline; flex-wrap: wrap; gap: 12px; }
.curriculum-path-titleline h2 { margin: 3px 0 0; line-height: 1.2; font-size: 20px; letter-spacing: -.02em; }
.curriculum-path-step { font-size: 12px; font-weight: 600; color: var(--muted); }
.curriculum-path-description { margin: 5px 0 0; font-size: 13px; line-height: 1.5; color: var(--muted); }
.curriculum-path .fine { margin: 5px 0 0; font-size: 12px; }
.curriculum-path-track { height: 5px; margin-top: 10px; background: var(--line-soft); border-radius: 10px; overflow: hidden; max-width: 360px; }
.curriculum-path-track span { display: block; height: 100%; background: var(--primary); border-radius: inherit; transition: width .15s ease; }
.curriculum-path-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.curriculum-path-actions button { min-height: 40px; white-space: nowrap; }
@media (max-width: 860px) {
  .curriculum-path { flex-direction: column; align-items: stretch; padding: 14px; }
  .curriculum-path-actions button { flex: 1; }
}


/* Step 3: compact, expandable evidence-based readiness recommendations. */
.readiness-panel { margin-top: 12px; border-top: 1px solid var(--line-soft); padding-top: 10px; }
.readiness-panel summary { display:flex; gap: 12px; justify-content: space-between; align-items:center; flex-wrap: wrap; font-size: 14px; font-weight: 600; cursor:pointer; }
.readiness-status { color: var(--accent-text); font-size:12px; font-weight: 600; }
.readiness-body { padding: 14px 0 0; max-width: 680px; }
.readiness-focus { display:flex; flex-direction:column; margin-bottom: 12px; }
.readiness-focus strong { font-size:14px; }
.readiness-skills { display:grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px 14px; margin: 10px 0 14px; }
.readiness-skill { padding: 8px 10px; border: 1px solid var(--line-soft); border-radius: 9px; background: var(--surface-2); }
.readiness-skill-head { display:flex; flex-wrap:wrap; align-items:baseline; justify-content:space-between; gap:5px; }
.readiness-skill strong { font-size: 12px; }
.readiness-skill p { margin: 3px 0 0; font-size: 11px; line-height:1.45; }
.readiness-recommendation { padding:10px 12px; border-left: 3px solid var(--primary); background:var(--surface-2); border-radius:6px; margin-bottom:12px; }
.readiness-recommendation strong,.readiness-links strong { font-size:12px; }
.readiness-recommendation p { font-size:13px; margin:3px 0 0; }
.readiness-evidence { display:flex; flex-direction:column; gap:3px; margin:5px 0 12px; }
.readiness-evidence-link { font-size:12px; line-height:1.45; overflow-wrap:anywhere; }
.readiness-actions { display:flex; flex-wrap:wrap; gap:8px; margin:8px 0 10px; }
.readiness-actions button { min-height:38px; }
.curriculum-coverage { padding:24px; margin:20px 0; border:1px solid var(--line-soft); background:var(--surface); border-radius:16px; }
.coverage-controls { display:flex; align-items:center; flex-wrap:wrap; gap:10px; margin:16px 0; }
.coverage-controls select { max-width:100%; }
.coverage-unit { border-top:1px solid var(--line-soft); padding:14px 12px; }
.coverage-unit.is-current { border-left:3px solid var(--primary); background:var(--surface-2); }
.coverage-unit summary { display:flex; align-items:center; justify-content:space-between; gap:12px; cursor:pointer; }
.coverage-state { font-size:12px; color:var(--muted); flex-shrink:0; }
.coverage-unit-body { padding:10px 0 0; }
.coverage-concepts { list-style:none; padding:0; margin:12px 0 18px; }
.coverage-concepts li { display:flex; justify-content:space-between; align-items:baseline; gap:16px; padding:9px 0; border-bottom:1px solid var(--line-soft); }
.coverage-concepts .needs-reinforcement .coverage-state { color:var(--error); }
@media(max-width:600px) { .curriculum-coverage { padding:16px; } .coverage-unit summary,.coverage-concepts li { align-items:flex-start; flex-direction:column; gap:4px; } }
@media (max-width: 650px) {
  .readiness-skills { grid-template-columns: 1fr; }
  .readiness-panel summary { align-items:start; }
}


/* Empty/loading assessment states should not resemble a failed competency test. */
.readiness-panel.readiness-unloaded .readiness-skills,
.readiness-panel.readiness-unloaded .readiness-recommendation,
.readiness-panel.readiness-unloaded .readiness-links { display: none; }
.readiness-panel.readiness-unloaded .readiness-focus { margin-bottom: 8px; }
.readiness-panel.readiness-unloaded .readiness-actions { margin-top: 10px; }
.readiness-panel.readiness-unloaded .readiness-status { color: var(--muted); }


/* Study home: one context-aware action, short progress, optional details.
   These selectors change presentation only; underlying study actions remain. */
.study-now {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  padding: 20px 24px; margin-bottom: 10px;
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}
.study-now-meta { width: 100%; display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:8px; }
.study-now-status { font-size:12px; font-weight: 600; color:var(--accent-text); }
.study-now-title { margin:0; font-size:25px; line-height:1.22; letter-spacing:-0.035em; }
.study-now-description { margin:0; color:var(--muted); font-size:14px; line-height:1.55; max-width:760px; }
.study-now-actions { display:flex; flex-wrap:wrap; align-items:center; gap:16px; margin-top:5px; }
.study-now-actions button { min-height:46px; }
.study-now-source { font-size:13px; text-decoration:underline; text-underline-offset:3px; }
.study-now-hint { margin:0; }
.study-now-hint:empty { display:none; }
.study-time { display:flex; align-items:center; gap:10px; margin-top:8px; }
.study-time label { margin:0; color:var(--muted); font-size:12px; }
.study-time select { padding:6px 10px; min-height:34px; font-size:13px; background:var(--surface-2); color:var(--ink); border:1px solid var(--line); }
.topbar-status { display:flex; flex-direction:column; align-items:flex-end; gap:4px; }
.save-status { border:0; background:transparent; color:var(--muted); font-size:12px; padding:3px 0; text-align:right; }
.save-status:hover { text-decoration:underline; text-underline-offset:3px; }
.save-status.needs-attention { color:var(--amber-strong); font-weight:600; }
.study-preferences, .session-details { border:1px solid var(--line); border-radius:var(--radius); background:var(--surface); margin-bottom:20px; }
.study-preferences > summary, .session-details > summary { padding:14px 18px; cursor:pointer; font-weight:600; }
.study-preferences .profile-steering { border:0; margin:0; border-top:1px solid var(--line); border-radius:0; box-shadow:none; }
.session-details { margin-top:22px; }
.session-record { padding:18px; border-top:1px solid var(--line); }
.session-record .two-cards { margin-top:0; }
#record-cards-open { margin-bottom:18px; }
.study-advanced {
  margin:0 0 14px; border:1px solid var(--line-soft);
  border-radius:12px; background:var(--surface);
}
.study-advanced > summary {
  cursor:pointer; padding:12px 20px; font-size:13px;
  color:var(--muted); font-weight: 600;
  list-style-position:inside;
}
.study-advanced[open] > summary { border-bottom:1px solid var(--line-soft); }
.study-advanced > .curriculum-path,
.study-advanced > .plan,
.study-advanced > .balance { margin:12px; }
.study-advanced .plan { box-shadow:none; }
.study-advanced .plan-actions .or { display:none; }
.study-advanced #today { display:none; }
.study-advanced .curriculum-path-actions { align-self: center; }
.study-hero-action #essay-inline,
.study-hero-action #resume-inline,
.study-hero-action .turn-next-button { display:none !important; }
@media (max-width:860px) {
 .study-now { padding:17px 16px; }
 .study-now-title { font-size:22px; }
 .study-now-actions { width:100%; flex-direction:column; align-items:stretch; gap:8px; }
 .study-now-actions button { width:100%; }
 .study-advanced > summary { padding:12px 14px; }
 .study-advanced > .curriculum-path,
 .study-advanced > .plan,
 .study-advanced > .balance { margin:9px; }
}

/* The active source is named in the study header. Don't repeat its title
   and reading assignment in the optional source tools below. */
.study-now-source-active #source-choice > strong,
.study-now-source-active #source-choice-focus { display: none; }
.study-now-source-active #source-choice { padding-block: 14px; }
.study-now-source-active #source-choice-actions { margin-top: 8px; }

/* UI cleanup: one source link and one source-options disclosure. */
.source-choice { padding: 0; border-color: var(--line-soft); }
.source-choice > details { padding: 0; }
.source-choice > details > summary {
  display: flex; flex-wrap: wrap; align-items: center;
  justify-content: space-between; gap: 10px; cursor: pointer;
  padding: 12px 16px; font-size: 13px; font-weight: 600;
  color: var(--muted); list-style-position: inside;
}
.source-choice > details[open] > summary { border-bottom: 1px solid var(--line-soft); }
.source-choice > details > strong,
.source-choice > details > p,
.source-choice > details > .source-choice-actions,
.source-choice > details > .source-choice-links { margin-left: 16px; margin-right: 16px; }
.source-choice > details > .source-choice-actions { padding-top: 6px; }
.source-choice > details > .source-choice-links { padding-bottom: 14px; }
.study-now-source-active #source-choice > details > strong,
.study-now-source-active #source-choice > details > p { display: none; }

/* Real-source image lesson within the existing study flow */
.image-lab{max-width:880px;margin:16px auto 22px;background:var(--surface);border:1px solid var(--line);border-radius:16px;padding:20px;scroll-margin-top:20px}
.image-lab-heading{display:flex;justify-content:space-between;align-items:center;gap:16px;margin-bottom:18px}
.image-lab-heading h2{font-size:22px;margin:4px 0}
.image-lab h3{font-size:18px;margin-bottom:6px}
.image-lab-viewport{display:flex;align-items:center;justify-content:center;overflow:hidden;height:min(65vh,520px);background:var(--surface-2);border-radius:10px}

/* Recall dashboard and quieter progress surfaces. */
.review-home { display:flex; align-items:center; justify-content:space-between; gap:20px; padding:20px 24px; margin:18px 0 24px; border:1px solid var(--line-soft); border-radius:var(--radius); background:var(--surface); }
.review-home p { margin:4px 0 0; }
.review-dashboard { border:1px solid var(--line); border-radius:20px; padding:30px; background:linear-gradient(125deg,var(--surface),var(--teal-soft)); }
.review-stats { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:24px; margin-bottom:26px; }
.review-stats > div { display:flex; flex-direction:column; border-right:1px solid var(--line); }
.review-stats > div:last-child { border:0; }
.review-stats strong { font-size:clamp(32px,5vw,48px); letter-spacing:-.05em; line-height:1.2; font-weight:600; }
.review-stats span { color:var(--muted); font-size:13px; margin-top:6px; }
.review-start-row { display:flex; align-items:center; gap:18px; flex-wrap:wrap; }
#review-sync { margin:18px 0 0; }
.review-filters { display:flex; gap:16px; align-items:end; flex-wrap:wrap; margin:24px 0 12px; }
.review-filters label { flex:1; min-width:140px; font-size:13px; color:var(--muted); }
.review-filters select, .review-filters input, .review-search input { display:block; width:100%; margin-top:6px; min-height:44px; padding:10px 12px; color:var(--ink); background:var(--surface); border:1px solid var(--line); border-radius:9px; }
.review-browse { margin-top:26px; border:1px solid var(--line-soft); border-radius:var(--radius); padding:20px 24px; background:var(--surface); }
.review-browse summary, .cards-settings summary { font-weight:600; cursor:pointer; }
.review-search { display:block; margin:20px 0; color:var(--muted); font-size:13px; }
.review-card-row { width:100%; display:flex; flex-direction:column; text-align:left; gap:6px; color:var(--ink); background:transparent; border:0; border-top:1px solid var(--line-soft); padding:18px 0; line-height:1.5; }
.review-card-row strong { font-size:15px; font-weight: 400; }
.review-card-row span { font-size:12px; color:var(--muted); }
.review-card-row:hover { color:var(--accent-text); }
#review-more { margin:14px 0 0; }
.card-interval { font-family:var(--mono); font-size:13px; margin-top:6px; }
#cards-ai-explanation { margin:10px 0 18px; white-space:pre-wrap; }
#card-edit-form label { display:block; margin-top:16px; color:var(--muted); font-size:13px; }
#card-edit-form textarea { display:block; width:100%; min-height:100px; background:var(--surface-2); color:var(--ink); border:1px solid var(--line); border-radius:9px; padding:12px; margin-top:6px; }
.dm-tile { display:flex; flex-direction:column; align-items:flex-start; gap:2px; padding:9px 12px; background:var(--surface-2); color:var(--ink); border:1px solid var(--line-soft); box-shadow:none; white-space:normal; text-align:left; }
.dm-tile-stage { font-size:10px; font-weight:400; color:var(--muted); }
.dm-tile.selected { background:var(--teal-soft); border-color:var(--accent-text); outline:0; }
.dm-key .dm-legend { margin-top:16px; }
.dm-ladder { padding-top:16px; }
.dm-detail summary, .dm-key summary { color:var(--muted); cursor:pointer; font-size:13px; }
@media(max-width:860px) {
  .review-home { padding:18px; align-items:flex-start; flex-direction:column; gap:14px; }
  .review-dashboard { padding:22px 18px; }
  .review-stats { gap:14px; }
  .review-stats span { font-size:12px; }
  .review-start-row { align-items:stretch; flex-direction:column; gap:10px; }
  .review-browse { padding:18px; }
  .dm-filters { display:flex; overflow-x:auto; max-width:100%; margin:0; flex-shrink:1; }
  .dm-header { flex-wrap:wrap; }
  .dm-key .dm-legend { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); }
  .dm-neglect-pill { display:none; }
}
.image-lab-viewport img{width:100%;height:100%;object-fit:contain;transform-origin:center;transition:transform .15s ease}
.image-lab-tools{display:flex;align-items:center;gap:8px;margin:10px 0}
.image-lab-tools button{min-width:38px}
.image-lab-credit{margin:0 0 14px}.image-lab-credit a{text-decoration:underline}
.image-lab-task{padding:16px;background:var(--surface-2);border:1px solid var(--line-soft);border-radius:12px}
.image-lab-task strong{display:block;margin-bottom:12px}
.image-lab textarea{width:100%;font-size:15px;padding:12px}
.image-lab-actions{display:flex;flex-wrap:wrap;gap:10px;margin-top:8px}
.image-lab-feedback{padding:12px;background:var(--surface);border-left:3px solid var(--primary);line-height:1.65;margin-top:10px}
#image-lab-next{margin-top:14px}
.image-lab-tutor{margin:14px 0;border:1px solid var(--line-soft);border-radius:10px;padding:12px}
.image-lab-tutor summary{cursor:pointer;color:var(--accent-text)}
.image-lab-tutor form{display:flex;flex-direction:column;align-items:flex-start;gap:10px;margin:14px 0}
#image-lab-tutor-reply{line-height:1.6}
@media(max-width:650px){.image-lab{padding:14px}.image-lab-viewport{height:350px}.image-lab-actions{flex-direction:column}.image-lab-actions button{width:100%}}

