/* KBSME Quick Fix — shared styles.
   Palette: clinic navy + teal, one warm accent (brick) for primary actions, on a paper-warm wash. */
:root {
  --navy: #102f4a;
  --navy-2: #1c4965;
  --teal: #087f79;
  --teal-wash: #e6f4f1;
  --brick: #c4502f;        /* primary action; 4.9:1 on white */
  --brick-wash: #fbefe9;
  --ink: #172b3a;
  --muted: #5b6c78;        /* 5.4:1 on white */
  --line: #dbe4e6;
  --paper: #f3f1eb;
  --white: #fff;

  --font-display: 'Bricolage Grotesque', 'IBM Plex Sans', system-ui, sans-serif;
  --font-body: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;

  --step--1: 0.8125rem;   /* 13 */
  --step-0: 0.9375rem;    /* 15 */
  --step-1: 1.125rem;     /* 18 */
  --step-2: clamp(1.4rem, 1.1rem + 1.4vw, 1.9rem);
  --step-3: clamp(2rem, 1.4rem + 3vw, 3.4rem);
  --radius: 14px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; } }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 var(--step-0)/1.6 var(--font-body); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .5; cursor: not-allowed; }
:where(a, button, input, textarea, select, summary):focus-visible { outline: 3px solid #f0a35e; outline-offset: 2px; }
a { color: var(--teal); }
h1, h2, h3 { font-family: var(--font-display); font-weight: 650; letter-spacing: -0.02em; color: var(--navy); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ─── shell & header ─── */
.shell { max-width: 1180px; margin: 0 auto; padding: 20px 16px 64px; }
@media (min-width: 821px) { .shell { padding: 28px 28px 80px; } }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px 18px; flex-wrap: wrap; margin-bottom: 20px; }
.brand { display: flex; gap: 12px; align-items: center; text-decoration: none; color: inherit; }
.logo { width: 42px; height: 42px; flex: 0 0 42px; background: var(--navy); color: #fff; display: grid; place-items: center; border-radius: 10px; font: 700 16px/1 var(--font-display); letter-spacing: -0.04em; }
.brand strong { display: block; font: 650 1rem/1.2 var(--font-display); color: var(--navy); }
.brand small { display: block; color: var(--muted); font-size: 12px; }
.account { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: var(--step--1); color: var(--muted); }
.account .who { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ─── hero: the session formula is the thesis ─── */
.hero { background: var(--navy); color: #fff; border-radius: 20px; padding: 26px 22px; display: grid; gap: 22px; }
@media (min-width: 821px) { .hero { grid-template-columns: minmax(0, 1.6fr) minmax(220px, 1fr); padding: 36px 40px; align-items: end; } }
.eyebrow { color: #8fe0d3; letter-spacing: .12em; text-transform: uppercase; font-size: 11px; font-weight: 600; }
.hero h1 { color: #fff; font-size: var(--step-3); line-height: 1.02; letter-spacing: -0.035em; margin: 10px 0 14px; max-width: 14ch; }
.hero p { color: #d4e1e8; margin: 0; max-width: 54ch; }
.hero .fine { margin-top: 14px; font-size: var(--step--1); color: #a9bfcb; }
.formula { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid rgba(255,255,255,.18); }
@media (min-width: 821px) { .formula { grid-template-columns: 1fr; border-top: 0; border-left: 1px solid rgba(255,255,255,.18); padding-left: 24px; } }
.formula div { padding: 12px 8px 0 0; }
@media (min-width: 821px) { .formula div { padding: 6px 0; display: flex; align-items: baseline; gap: 14px; } }
.formula b { font: 700 clamp(2rem, 1.5rem + 2.5vw, 3.2rem)/1 var(--font-display); color: #fff; letter-spacing: -0.04em; display: block; min-width: 1.2ch; }
.formula span { font-size: 12px; color: #c4d4dc; line-height: 1.35; display: block; }

/* ─── layout ─── */
.main-layout { display: grid; gap: 18px; margin-top: 18px; align-items: start; }
@media (min-width: 821px) { .main-layout { grid-template-columns: 240px minmax(0, 1fr); } }
.side { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px; display: flex; overflow-x: auto; gap: 2px; }
@media (min-width: 821px) { .side { position: sticky; top: 16px; padding: 14px; display: block; } }
.side-title { display: none; padding: 4px 8px 12px; font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .09em; text-transform: uppercase; }
.side-bottom { display: none; }
@media (min-width: 821px) { .side-title, .side-bottom { display: block; } }
.side-bottom { border-top: 1px solid var(--line); margin-top: 14px; padding: 14px 8px 2px; font-size: 12px; color: var(--muted); }
.step-tab { border: 0; background: transparent; flex: 1; min-width: 56px; min-height: 48px; padding: 8px 6px; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; border-radius: 10px; color: var(--muted); }
@media (min-width: 821px) { .step-tab { width: 100%; flex-direction: row; gap: 11px; padding: 11px 10px; text-align: left; } }
.step-tab .n { display: grid; place-items: center; width: 26px; height: 26px; flex: 0 0 26px; background: #eef2f3; border-radius: 50%; font-size: 12px; font-weight: 700; }
.step-tab b { font-size: 11px; font-weight: 600; line-height: 1.2; }
@media (min-width: 821px) { .step-tab b { font-size: 13.5px; } }
.step-tab.active { background: var(--teal-wash); color: #0d5a54; }
.step-tab.active .n { background: var(--teal); color: #fff; }
.step-tab.done .n { background: var(--navy); color: #fff; }

.workspace { min-width: 0; }
.progress { display: flex; align-items: center; gap: 12px; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 12px; }
.progress strong { font-size: 12px; color: var(--navy); }
.progress small { color: var(--muted); font-size: 11.5px; }
.bar { height: 6px; background: #e6eced; border-radius: 30px; overflow: hidden; flex: 1; min-width: 60px; }
.bar-in { height: 100%; width: 20%; background: var(--teal); border-radius: 30px; transition: width .25s; }

.card { background: var(--white); border: 1px solid var(--line); border-radius: 18px; padding: 22px 16px; }
@media (min-width: 821px) { .card { padding: 34px 38px; min-height: 520px; } }
.panel { display: none; }
.panel.active { display: block; }
.kicker { color: var(--teal); font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; }
.card h2 { font-size: var(--step-2); line-height: 1.12; margin: 8px 0 10px; }
.card h3 { font-size: var(--step-1); margin: 26px 0 10px; letter-spacing: -0.01em; }
.intro { color: var(--muted); max-width: 64ch; margin: 0 0 22px; }

/* ─── forms ─── */
.form-grid { display: grid; gap: 16px; }
@media (min-width: 640px) { .form-grid { grid-template-columns: 1fr 1fr; } }
.field { min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field label, .field-label { font-weight: 600; font-size: 13px; color: #29465a; display: block; margin-bottom: 6px; }
.required { color: var(--brick); }
.field input, .field textarea, .field select, .track-note { width: 100%; min-height: 46px; border: 1px solid #c9d7db; background: #fcfdfd; padding: 11px 13px; border-radius: 10px; }
.field textarea { min-height: 110px; resize: vertical; line-height: 1.55; }
.hint { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
.choice-grid { display: grid; gap: 10px; margin: 6px 0; }
@media (min-width: 640px) { .choice-grid { grid-template-columns: 1fr 1fr; } }
.choice { display: block; cursor: pointer; position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; }
.choice-body { display: block; border: 1px solid var(--line); background: #fff; padding: 14px; border-radius: 12px; height: 100%; min-height: 80px; }
.choice input:checked + .choice-body { border-color: var(--teal); box-shadow: inset 0 0 0 1px var(--teal); background: var(--teal-wash); }
.choice input:focus-visible + .choice-body { outline: 3px solid #f0a35e; outline-offset: 2px; }
.choice strong { display: block; color: var(--navy); font-size: 14px; font-weight: 600; }
.choice small { display: block; color: var(--muted); font-size: 12px; line-height: 1.45; margin-top: 3px; }

.tip { border-left: 3px solid #e3a77f; background: #fdf6ef; color: #6d3f26; padding: 11px 14px; border-radius: 0 10px 10px 0; font-size: 13px; margin: 16px 0; }
.tip.good { border-color: #6dbb9f; background: #eff9f4; color: #1f5d4a; }
.tip.neutral { border-color: #a9c0cb; background: #f3f7f9; color: #3f5a68; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.upload { border: 2px dashed #b3cbd1; border-radius: 12px; background: #f8fbfb; padding: 18px; margin: 14px 0; text-align: center; }
.upload strong { display: block; color: var(--navy); font-size: 14px; }
.upload p { margin: 4px 0; font-size: 12.5px; color: var(--muted); }
.upload input { max-width: 100%; margin-top: 10px; font-size: 13px; }
.preview { margin: 12px auto 0; max-width: 260px; max-height: 170px; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; display: none; }
.divider { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
.subtle { font-size: 13px; color: var(--muted); }
.status { font-size: 11.5px; font-weight: 600; color: #1c685b; background: #e3f4ee; display: inline-flex; padding: 4px 9px; border-radius: 6px; }
.status.warn { color: #87472a; background: #fbede3; }

.diagnosis { background: #f5faf9; border: 1px solid #cfe5df; border-radius: 14px; padding: 18px; margin-top: 16px; }
.diagnosis .big { font: 650 var(--step-1)/1.3 var(--font-display); color: var(--navy); }
.two-col { display: grid; gap: 14px; }
@media (min-width: 640px) { .two-col { grid-template-columns: 1fr 1fr; } }
.surface { border: 1px solid var(--line); border-radius: 12px; padding: 15px; background: #fff; }
.surface h4 { font-size: 11.5px; color: var(--teal); text-transform: uppercase; letter-spacing: .06em; margin: 0 0 8px; font-weight: 600; }
.surface p { white-space: pre-wrap; margin: 0; font-size: 13.5px; }
.surface ul { padding-left: 18px; margin: 0; font-size: 13.5px; }
.surface li { margin: 4px 0; }
.surface.programme { margin-top: 16px; border-left: 3px solid var(--line); }
.surface.programme[data-status="ready"] { border-left-color: var(--teal); }
.surface.programme[data-status="pending"] { border-left-color: #e3a77f; }
.surface.programme .opt { font-size: var(--step--1); color: var(--muted); margin-top: 6px; }
.editor { min-height: 180px !important; font-size: 15px; line-height: 1.7 !important; }
textarea.grow { resize: none; overflow: hidden; }
.placeholder-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 8px; }
.placeholder-count { font-size: 13.5px; font-weight: 600; color: #8a3423; background: #fdeee8; border-radius: 999px; padding: 4px 12px; }
.placeholder-count.done { color: #1d6b4f; background: #e6f4ee; }
.placeholder-count:empty { display: none; }
.summary-box { margin-top: 18px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.summary-box > summary { cursor: pointer; padding: 14px 18px; min-height: 44px; font: 600 15px/1.3 var(--font-display); color: var(--navy); list-style-position: inside; }
.summary-box[open] > summary { border-bottom: 1px solid var(--line); }
.summary-box .report { border: 0; margin: 0; border-radius: 0 0 14px 14px; }
.take-home .btn { flex: 1 1 200px; }
.field-error { margin: 8px 0 0; }

.costtable { display: grid; grid-template-columns: 1fr 120px; gap: 9px 14px; align-items: center; }
@media (min-width: 640px) { .costtable { grid-template-columns: 1fr 150px; } }
.costtable label { font-size: 13px; color: #375368; font-weight: 500; }
.costtable input { min-height: 44px; padding: 8px 11px; border-radius: 9px; border: 1px solid #c9d7db; width: 100%; }
.resultbox { margin: 14px 0; padding: 14px 16px; color: #fff; border-radius: 12px; background: var(--navy); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.resultbox b { font: 650 1.35rem/1.1 var(--font-display); text-align: right; }
.resultbox small { font-size: 11.5px; opacity: .85; }
.check-label { display: flex; align-items: flex-start; gap: 10px; font-size: 13.5px; color: #385368; margin: 12px 0; cursor: pointer; }
.check-label input { margin-top: 4px; width: 18px; height: 18px; flex: 0 0 18px; accent-color: var(--teal); }

/* ─── tracker & report ─── */
.tracker { display: grid; gap: 10px; }
.task { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 8px 12px; border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: #fff; }
.task.done { background: #f0f9f5; border-color: #c6e4d9; }
.day { font: 650 13px/1.3 var(--font-display); color: var(--teal); padding-top: 10px; }
.task-head, .task .proof, .task .track-note { grid-column: 2; }
.task-head { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.task-head strong { font-size: 14px; color: var(--navy); font-weight: 600; flex: 1 1 180px; }
/* Task title and proof read as text but stay editable; they grow with their content and never clip. */
.task .task-title, .task .task-proof { display: block; width: 100%; min-height: 44px; resize: none; overflow: hidden; border: 1px solid transparent; border-radius: 8px; background: transparent; }
.task .task-title { flex: 1 1 180px; font: 600 14px/1.45 var(--font-body); color: var(--navy); padding: 10px 8px; margin: 0 0 0 -8px; width: calc(100% + 8px); }
.task .proof { display: block; font-size: 12px; color: var(--muted); }
.task .proof > span { display: block; margin-bottom: 2px; }
.task .task-proof { font: 13px/1.45 var(--font-body); color: var(--ink); padding: 10px 8px; margin-left: -8px; width: calc(100% + 8px); }
.task .task-title:hover, .task .task-proof:hover { border-color: var(--line); }
.task .task-title:focus-visible, .task .task-proof:focus-visible { border-color: #c9d7db; background: #fcfdfd; }
.task .track-note { min-height: 44px; padding: 10px; font-size: 13px; line-height: 1.45; border: 1px solid #c9d7db; border-radius: 9px; resize: none; overflow: hidden; }
.task select { border: 1px solid #c9d7db; border-radius: 8px; background: #fff; padding: 8px 10px; font-size: 13px; min-height: 44px; }
@media (max-width: 639px) {
  /* "Hari N" becomes a small label above the task, so the task gets the full width. */
  .task { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .task-head, .task .proof, .task .track-note { grid-column: 1; }
  .day { padding-top: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
  .task-head select { width: 100%; }
}
.track-progress { height: 8px; border-radius: 20px; background: #e2eaeb; overflow: hidden; }
.track-progress > div { height: 100%; background: var(--teal); transition: width .2s; }
.track-meta { display: flex; justify-content: space-between; color: var(--navy); font-size: 13px; font-weight: 600; margin: 8px 0; }
.metrics-grid { display: grid; gap: 12px; }
@media (min-width: 640px) { .metrics-grid { grid-template-columns: repeat(3, 1fr); } }
.report { border: 1px solid var(--line); border-radius: 14px; background: #fff; padding: 6px 18px; margin-top: 14px; }
.report-row { padding: 12px 0; border-bottom: 1px solid var(--line); }
.report-row:last-child { border-bottom: 0; }
.report-row b { color: var(--navy); font-size: 12.5px; }
.report-row p { margin: 4px 0 0; white-space: pre-wrap; font-size: 13.5px; }
.lesson { font-size: 13px; color: var(--muted); margin: 2px 0 10px; }

/* ─── buttons & messages ─── */
.footer-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.btn { border: 1px solid transparent; border-radius: 10px; padding: 11px 18px; min-height: 46px; font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn.primary { background: var(--brick); color: #fff; }
.btn.navy { background: var(--navy); color: #fff; }
.btn.secondary { color: var(--navy); background: #e9eff0; }
.btn.outline { border-color: #c9d7db; background: #fff; color: var(--navy); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 13px; }
.btn:hover:not(:disabled) { filter: brightness(.95); }
.link-btn { background: none; border: 0; padding: 6px 2px; color: var(--muted); text-decoration: underline; font-size: 13px; min-height: 36px; }
.link-btn.danger { color: #a3412c; }
.demo-bar { margin-bottom: 12px; padding: 4px 12px; border: 1px dashed var(--line, #c9c2b4); border-radius: 8px; }
.spacer { flex: 1; }
.message { border-radius: 10px; padding: 11px 14px; font-size: 13.5px; background: #eef5f9; color: #2e5468; margin: 12px 0; display: none; }
.message.show { display: block; }
.message.error { background: #fdeee8; color: #8a3423; }
.small-print { font-size: 12px; color: var(--muted); margin: 14px 0 0; }

/* ─── sign-in & gates ─── */
.gate { max-width: 520px; margin: 28px auto 0; background: var(--white); border: 1px solid var(--line); border-radius: 18px; padding: 26px 20px; }
@media (min-width: 640px) { .gate { padding: 34px 36px; } }
.gate h2 { font-size: var(--step-2); margin: 6px 0 10px; line-height: 1.15; }
.gate p { color: var(--muted); }
.gate .btn { width: 100%; margin-top: 14px; }
.notice-box { max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: 13.5px; background: #fafbfb; }
.notice-box ul { padding-left: 18px; margin: 6px 0; }

#print-area { display: none; }
@media print {
  body { background: #fff; color: #101e2c; }
  .shell { display: none !important; }
  #print-area { display: block !important; padding: 18px 24px; font: 12px/1.5 Arial, sans-serif; }
  #print-area h1 { font-size: 24px; color: var(--navy); }
  #print-area h2 { margin-top: 24px; color: var(--teal); font-size: 16px; }
  #print-area .pr-item { margin: 10px 0; border-top: 1px solid #cfdfe3; padding-top: 10px; white-space: pre-wrap; }
  #print-area .pr-sub { font-size: 11px; color: #526776; }
  #print-area table { width: 100%; border-collapse: collapse; }
  #print-area td, #print-area th { border: 1px solid #d4e0e4; padding: 7px; text-align: left; }
  #print-area tr { break-inside: avoid; }
  #print-area .pr-quick { white-space: pre-wrap; border: 1px solid #cfdfe3; padding: 12px; border-radius: 8px; }
}

/* ─── prose pages ─── */
.prose { max-width: 720px; margin: 0 auto; background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 26px 20px; }
@media (min-width: 640px) { .prose { padding: 40px 48px; } }
.prose h1 { font-size: var(--step-2); margin-top: 0; }
.prose h2 { font-size: var(--step-1); margin-top: 28px; }
.prose .draft { background: #fdf6ef; border-left: 3px solid #e3a77f; padding: 10px 14px; font-size: 13.5px; color: #6d3f26; }

/* Once a participant is working, the hero shrinks on phones so the form starts above the fold. */
@media (max-width: 820px) {
  /* 16px stops iPhone Safari from zooming into a field on focus. */
  input, select, textarea, .editor, .task .task-title, .task .task-proof, .task .track-note, .task select, .upload input { font-size: 16px !important; }
  body.in-app .hero { padding: 18px 20px; gap: 0; }
  body.in-app .hero h1 { font-size: 1.6rem; margin-bottom: 0; max-width: none; }
  body.in-app .hero p, body.in-app .formula { display: none; }
}
