/* Daydan dashboard prototype. Builds on ../assets/tokens.css (colours, type, spacing, motion).
   Mobile first (~390px). At >=1024px a right-side rail replaces the bottom tab bar. */

:root {
  --r-card: 16px;
  --rail: 256px;
  --tabbar: 64px;
  --topbar: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.4, 0.64, 1);
}

html { scroll-behavior: smooth; }
body { min-height: 100vh; min-height: 100dvh; background: var(--paper); overflow-x: hidden; }
body.is-locked { overflow: hidden; }
h1, h2, h3, h4, p { margin: 0; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { cursor: not-allowed; }
input, textarea { border: 0; background: none; }
[hidden] { display: none !important; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.en { font-family: "IBM Plex Sans Arabic", system-ui, sans-serif; }
.ic { flex: none; }
.mir { transform: scaleX(-1); }
.muted { color: var(--ink-3); }
.small { font-size: var(--fs-xs); }
.skip { position: absolute; inset-inline-start: 8px; top: -60px; z-index: 100; background: var(--navy); color: var(--white); padding: 8px 16px; border-radius: var(--r-sm); }
.skip:focus { top: 8px; }

/* ---------- App shell ---------- */
.shell { min-height: 100vh; min-height: 100dvh; }
.topbar { position: sticky; top: 0; z-index: 20; height: var(--topbar); display: flex; align-items: center; justify-content: space-between; padding: 0 var(--s4); background: rgba(251, 252, 254, 0.92); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid transparent; transition: border-color var(--t-fast); }
.topbar.is-scrolled { border-bottom-color: var(--line); }
.brand { display: inline-flex; flex-direction: column; align-items: center; gap: 5px; text-decoration: none; }
.brand .logo { font-size: 26px; }
.brand-bar { display: block; width: 62%; height: 3px; border-radius: 3px; background: var(--sky); }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--mist); color: var(--navy); font-weight: 700; font-size: var(--fs-sm); text-decoration: none; transition: background var(--t-fast); }
.avatar:hover { background: var(--line); }

.main { padding: var(--s5) var(--s4) calc(var(--tabbar) + var(--safe-b) + var(--s7)); max-width: 720px; margin: 0 auto; }

.tabbar { position: fixed; inset-inline: 0; bottom: 0; z-index: 30; height: calc(var(--tabbar) + var(--safe-b)); padding-bottom: var(--safe-b); display: grid; grid-template-columns: repeat(5, 1fr); background: var(--white); border-top: 1px solid var(--line); }
.tab { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--ink-3); font-size: 11px; font-weight: 600; text-decoration: none; transition: color var(--t-fast); min-height: 44px; }
.tab .ic { transition: transform var(--t-med) var(--ease-spring); }
.tab[aria-current="page"] { color: var(--navy); }
.tab[aria-current="page"] .ic { transform: translateY(-1px); }
.tab-ind { position: absolute; top: -1px; height: 3px; width: calc(100% / 5); inset-inline-start: 0; display: flex; justify-content: center; pointer-events: none; transition: transform var(--t-med) var(--ease); }
.tab-ind::before { content: ""; width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: var(--sky); }

.rail { display: none; }

@media (min-width: 1024px) {
  .topbar, .tabbar { display: none; }
  .rail { display: flex; flex-direction: column; position: fixed; inset-block: 0; inset-inline-start: 0; width: var(--rail); padding: var(--s6) var(--s4) var(--s5); background: var(--white); border-inline-end: 1px solid var(--line); z-index: 20; }
  .rail .brand { align-self: flex-start; margin: 0 var(--s3) var(--s7); }
  .rail .brand .logo { font-size: 34px; }
  .rail-nav { display: flex; flex-direction: column; gap: 2px; }
  .rail-link { position: relative; display: flex; align-items: center; gap: var(--s3); min-height: 44px; padding: 0 var(--s3); border-radius: var(--r-md); color: var(--ink-2); text-decoration: none; font-weight: 500; transition: background var(--t-fast), color var(--t-fast); }
  .rail-link:hover { background: var(--mist-2); color: var(--navy); }
  .rail-link[aria-current="page"] { background: var(--mist); color: var(--navy); font-weight: 600; }
  .rail-link[aria-current="page"]::before { content: ""; position: absolute; inset-inline-start: -16px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--navy); }
  .rail-foot { margin-top: auto; display: flex; align-items: center; gap: var(--s3); padding: var(--s3); border-top: 1px solid var(--line); padding-top: var(--s4); }
  .rail-foot .who { min-width: 0; line-height: 1.4; }
  .rail-foot .who b { display: block; font-size: var(--fs-sm); }
  .rail-foot .who span { font-size: var(--fs-xs); color: var(--ink-3); }
  .main { margin-inline-start: var(--rail); max-width: none; padding: var(--s7) var(--s7) var(--s8); }
  .main > .view { max-width: 960px; margin-inline: auto; }
}

/* ---------- View transitions ---------- */
.view { animation: view-in var(--t-med) var(--ease-out) backwards; }
@keyframes view-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Page header ---------- */
.page-head { margin-bottom: var(--s5); }
.page-head .eyebrow { font-size: var(--fs-xs); color: var(--ink-3); font-weight: 600; margin-bottom: var(--s1); }
.page-title { font-size: var(--fs-xl); font-weight: 700; line-height: var(--lh-tight); color: var(--ink); }
.page-title::after { content: ""; display: block; width: 32px; height: 3px; border-radius: 3px; background: var(--sky); margin-top: var(--s3); }
.page-sub { margin-top: var(--s3); color: var(--ink-2); font-size: var(--fs-sm); max-width: 56ch; }
@media (min-width: 1024px) { .page-title { font-size: var(--fs-2xl); } }

.back { display: inline-flex; align-items: center; gap: var(--s2); min-height: 44px; margin-inline-start: -8px; padding: 0 8px; color: var(--ink-2); text-decoration: none; font-size: var(--fs-sm); font-weight: 600; border-radius: var(--r-sm); }
.back:hover { color: var(--navy); background: var(--mist-2); }

.section { margin-top: var(--s6); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s3); }
.section-title { font-size: var(--fs-md); font-weight: 700; color: var(--ink); }
.section-note { font-size: var(--fs-xs); color: var(--ink-3); }

/* ---------- Cards and rows ---------- */
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow-1); }
.card-pad { padding: var(--s4); }
@media (min-width: 640px) { .card-pad { padding: var(--s5); } }
.card + .card { margin-top: var(--s3); }
.card-title { font-weight: 700; font-size: var(--fs-md); }
.card-sub { font-size: var(--fs-sm); color: var(--ink-3); }

.rows { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: var(--s3); min-height: 56px; padding: var(--s3) var(--s4); border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row-main { flex: 1; min-width: 0; line-height: 1.5; }
.row-main > b { display: block; font-weight: 600; font-size: var(--fs-sm); }
.row-main > span { display: block; font-size: var(--fs-xs); color: var(--ink-3); }
.row-end { display: flex; align-items: center; gap: var(--s2); flex: none; }
button.row, a.row { width: 100%; text-align: start; color: inherit; text-decoration: none; transition: background var(--t-fast); }
button.row:hover, a.row:hover { background: var(--mist-2); }

.ibox { width: 40px; height: 40px; flex: none; border-radius: var(--r-md); display: grid; place-items: center; background: var(--mist); color: var(--navy); }
.ibox.sm { width: 32px; height: 32px; border-radius: 10px; }

/* ---------- Buttons ---------- */
.btn { white-space: nowrap; }
.btn .ic { margin-inline: -2px; }
.btn-block { width: 100%; }
.btn-lg { min-height: 52px; font-size: var(--fs-md); }
.btn-sm { min-height: 36px; padding: 0 var(--s4); font-size: var(--fs-sm); }
.btn-soft { background: var(--mist); color: var(--navy); }
.btn-soft:hover { background: var(--line); }
.btn-danger { background: transparent; color: var(--danger); border-color: #e9c3c3; }
.btn-danger:hover { background: var(--danger-bg); }
.btn-danger-solid { background: var(--danger); color: var(--white); }
.btn-danger-solid:hover { background: #8c2424; }
.btn:disabled, .btn[aria-disabled="true"] { background: var(--mist-2); color: var(--ink-3); border-color: var(--line); transform: none; }
.btn-text { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 var(--s2); color: var(--navy-2); font-weight: 600; font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn-text:hover { color: var(--navy); background: var(--mist-2); }
.iconbtn { width: 40px; height: 40px; border-radius: 50%; display: inline-grid; place-items: center; color: var(--ink-3); transition: background var(--t-fast), color var(--t-fast); }
.iconbtn:hover { background: var(--mist-2); color: var(--navy); }
.iconbtn:disabled { opacity: 0.35; background: none; }
.iconbtn.danger:hover { background: var(--danger-bg); color: var(--danger); }
.btn.is-busy { pointer-events: none; }
.spin { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-inline-end-color: transparent; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Form controls ---------- */
.field { display: block; }
.field + .field { margin-top: var(--s4); }
.label { display: block; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); margin-bottom: var(--s2); }
.hint { font-size: var(--fs-xs); color: var(--ink-3); margin-top: var(--s2); }
.input { width: 100%; min-height: 48px; padding: 0 var(--s4); border: 1px solid var(--line-2); border-radius: var(--r-md); background: var(--white); font-size: var(--fs-md); transition: border-color var(--t-fast), box-shadow var(--t-fast); }
.input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(55, 138, 221, 0.18); }
textarea.input { padding: var(--s3) var(--s4); min-height: 120px; resize: vertical; line-height: 1.8; }
.input-group { display: flex; align-items: stretch; border: 1px solid var(--line-2); border-radius: var(--r-md); background: var(--white); overflow: hidden; transition: border-color var(--t-fast), box-shadow var(--t-fast); }
.input-group:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(55, 138, 221, 0.18); }
.input-group .affix { display: grid; place-items: center; padding: 0 var(--s4); background: var(--mist-2); color: var(--ink-2); font-weight: 600; border-inline-end: 1px solid var(--line); }
.input-group .input { border: 0; box-shadow: none; border-radius: 0; }

/* Switch */
.switch { position: relative; width: 46px; height: 28px; flex: none; border-radius: 999px; background: var(--line-2); transition: background var(--t-med) var(--ease); }
.switch::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--white); box-shadow: 0 1px 3px rgba(11, 31, 51, 0.25); transition: transform var(--t-med) var(--ease-spring); }
[aria-checked="true"] > .switch { background: var(--navy); }
[aria-checked="true"] > .switch::after { transform: translateX(-18px); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); min-height: 56px; width: 100%; text-align: start; }
.switch-row .row-main > b { font-size: var(--fs-md); font-weight: 600; }

/* Toggle pill (compact switch with label, used on answers) */
.tpill { white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px 0 12px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--white); color: var(--ink-2); font-size: var(--fs-sm); font-weight: 600; transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast), transform var(--t-fast) var(--ease); }
.tpill:hover { border-color: var(--navy-2); }
.tpill:active { transform: scale(0.97); }
.tpill .tick { width: 18px; height: 18px; border-radius: 6px; border: 1.5px solid var(--line-2); display: grid; place-items: center; transition: background var(--t-fast), border-color var(--t-fast); }
.tpill .tick svg { opacity: 0; transform: scale(0.5); transition: opacity var(--t-fast), transform var(--t-med) var(--ease-spring); }
.tpill[aria-pressed="true"] .tick svg { opacity: 1; transform: none; }
.tpill.alert[aria-pressed="true"] { background: var(--attn-bg); border-color: #ecd2a8; color: var(--attn); }
.tpill.alert[aria-pressed="true"] .tick { background: var(--attn); border-color: var(--attn); color: var(--white); }
.tpill.coord[aria-pressed="true"] { background: var(--mist); border-color: var(--sky); color: var(--navy); }
.tpill.coord[aria-pressed="true"] .tick { background: var(--navy); border-color: var(--navy); color: var(--white); }

/* Chips (radio / multi) */
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chips.nowrap { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; margin-inline: -4px; padding-inline: 4px; }
.chips.nowrap::-webkit-scrollbar { display: none; }
button.chip { min-height: 40px; padding: 0 16px; font-weight: 500; white-space: nowrap; transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast), transform var(--t-fast) var(--ease), box-shadow var(--t-fast); }
button.chip:hover { border-color: var(--navy-2); color: var(--navy); }
button.chip:active { transform: scale(0.96); }
button.chip.is-on, button.chip[aria-checked="true"], button.chip[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: var(--white); box-shadow: 0 2px 8px -2px rgba(12, 68, 124, 0.4); }
button.chip:disabled { opacity: 0.45; border-style: dashed; }
button.chip.sm { min-height: 34px; padding: 0 12px; font-size: var(--fs-xs); }

/* Segmented control with a sliding thumb */
.seg { position: relative; display: grid; grid-auto-columns: 1fr; grid-auto-flow: column; padding: 4px; border-radius: 999px; background: var(--mist); isolation: isolate; }
.seg-thumb { position: absolute; top: 4px; bottom: 4px; inset-inline-start: 4px; width: calc((100% - 8px) / var(--n)); border-radius: 999px; background: var(--white); box-shadow: var(--shadow-1), 0 0 0 1px var(--line); transform: translateX(calc(-100% * var(--i))); transition: transform var(--t-med) var(--ease); z-index: -1; }
.seg button { min-height: 40px; padding: 0 var(--s3); border-radius: 999px; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-3); transition: color var(--t-fast); }
.seg button[aria-checked="true"] { color: var(--navy); }

/* Stepper */
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line-2); border-radius: 999px; background: var(--white); }
.stepper button { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; color: var(--navy); transition: background var(--t-fast); }
.stepper button:hover { background: var(--mist-2); }
.stepper button:disabled { color: var(--line-2); background: none; }
.stepper output { min-width: 44px; text-align: center; font-weight: 700; font-size: var(--fs-lg); font-variant-numeric: tabular-nums; }
.stepper.sm button { width: 36px; height: 36px; }
.stepper.sm output { min-width: 28px; font-size: var(--fs-md); }
.bump { animation: bump var(--t-med) var(--ease-spring); }
@keyframes bump { 40% { transform: scale(1.18); } }

/* Calm inline notes */
.note { display: flex; gap: var(--s2); align-items: flex-start; padding: 10px 12px; border-radius: var(--r-md); font-size: var(--fs-xs); line-height: 1.7; background: var(--mist-2); color: var(--ink-2); border: 1px solid var(--line); }
.note .ic { margin-top: 1px; color: var(--navy-2); }
.note b { font-weight: 600; color: var(--ink); }
.note-attn { background: var(--attn-bg); border-color: #efdcbc; color: #6e430d; }
.note-attn .ic { color: var(--attn); }
.note-danger { background: var(--danger-bg); border-color: #f0cccc; color: #7a2222; }
.note-danger .ic { color: var(--danger); }
.note-ok { background: var(--ok-bg); border-color: #c3e4d8; color: #0c5543; }
.note-ok .ic { color: var(--ok); }
.note + .note { margin-top: var(--s2); }
.note-in { animation: note-in var(--t-med) var(--ease-out); }
@keyframes note-in { from { opacity: 0; transform: translateY(-4px); } }

/* Status dots */
.dot { position: relative; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; display: inline-block; }
.dot.attn { background: #c98a2b; }
.dot.off { background: var(--line-2); }
.dot.live::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: inherit; animation: pulse 2.4s var(--ease-out) infinite; }
@keyframes pulse { 0% { transform: scale(1); opacity: 0.55; } 70%, 100% { transform: scale(3); opacity: 0; } }

.tag { white-space: nowrap; }
.tag .dot { width: 6px; height: 6px; }

/* ---------- Home ---------- */
.status-strip { display: grid; grid-template-columns: 1fr; gap: 0; }
.status-item { display: flex; align-items: center; gap: var(--s3); min-height: 56px; padding: var(--s3) var(--s4); border-top: 1px solid var(--line); text-decoration: none; color: inherit; transition: background var(--t-fast); }
.status-item:first-child { border-top: 0; }
.status-item:hover { background: var(--mist-2); }
.status-item .row-main > b { font-size: var(--fs-sm); }
@media (min-width: 760px) {
  .status-strip { grid-template-columns: repeat(3, 1fr); }
  .status-item { border-top: 0; border-inline-start: 1px solid var(--line); }
  .status-item:first-child { border-inline-start: 0; }
}

.stats { display: grid; grid-template-columns: repeat(3, 1fr); }
.stat { padding: var(--s4) var(--s3); text-align: center; border-inline-start: 1px solid var(--line); }
.stat:first-child { border-inline-start: 0; }
.stat-n { font-size: 34px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--ink); }
.stat-l { font-size: var(--fs-xs); color: var(--ink-3); margin-top: var(--s1); line-height: 1.5; }
.stat.attn .stat-n { color: var(--attn); }
@media (min-width: 640px) { .stat-n { font-size: 42px; } .stat { padding: var(--s5) var(--s4); } }
.stats-foot { display: flex; gap: var(--s2); align-items: flex-start; padding: var(--s3) var(--s4); border-top: 1px solid var(--line); background: var(--mist-2); border-radius: 0 0 var(--r-card) var(--r-card); font-size: var(--fs-xs); color: var(--ink-2); line-height: 1.7; }

.actions { display: grid; gap: var(--s3); grid-template-columns: 1fr; }
@media (min-width: 640px) { .actions { grid-template-columns: repeat(3, 1fr); } }
.action { display: flex; align-items: center; gap: var(--s3); padding: var(--s4); min-height: 72px; text-align: start; border-radius: var(--r-card); border: 1px solid var(--line); background: var(--white); box-shadow: var(--shadow-1); color: inherit; text-decoration: none; transition: transform var(--t-fast) var(--ease), box-shadow var(--t-med) var(--ease), border-color var(--t-fast); }
.action:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--line-2); }
.action:active { transform: translateY(0); }
.action .row-main > b { display: block; font-weight: 700; font-size: var(--fs-md); line-height: 1.4; }
.action .row-main > span { display: block; font-size: var(--fs-xs); color: var(--ink-3); line-height: 1.5; margin-top: 2px; }
.action .row-main { flex: 1; }
.action.primary { background: var(--navy); border-color: var(--navy); color: var(--white); }
.action.primary .row-main > span { color: #c8dcf2; }
.action.primary .ibox { background: rgba(255, 255, 255, 0.12); color: var(--white); }
.action.primary:hover { background: var(--navy-2); }
.action .end { color: var(--ink-3); }
.action.primary .end { color: var(--sky); }
@media (min-width: 640px) { .action { flex-direction: column; align-items: flex-start; min-height: 150px; } .action .end { display: none; } }

.proto-mini { display: flex; align-items: center; gap: var(--s3); }

/* ---------- Protocols list ---------- */
.plist { display: grid; gap: var(--s3); }
@media (min-width: 760px) { .plist { grid-template-columns: repeat(2, 1fr); } }
.pcard { display: flex; flex-direction: column; gap: var(--s3); padding: var(--s4); border-radius: var(--r-card); background: var(--white); border: 1px solid var(--line); box-shadow: var(--shadow-1); text-decoration: none; color: inherit; transition: box-shadow var(--t-med) var(--ease), border-color var(--t-fast), transform var(--t-fast) var(--ease); }
a.pcard:hover { box-shadow: var(--shadow-2); border-color: var(--line-2); transform: translateY(-1px); }
.pcard-head { display: flex; align-items: flex-start; gap: var(--s3); }
.pcard-head .row-main > b { font-size: var(--fs-md); font-weight: 700; }
.pcard-head .row-main > span { font-size: var(--fs-xs); }
.pcard-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); flex-wrap: wrap; }
.pcard-meta { display: flex; flex-wrap: wrap; gap: 6px var(--s3); font-size: var(--fs-xs); color: var(--ink-3); }
.pcard-meta span { display: inline-flex; align-items: center; gap: 4px; }
.pcard .strip { display: flex; gap: 3px; align-items: center; height: 18px; }
.strip i { display: block; height: 6px; flex: 1; border-radius: 3px; background: var(--mist); }
.strip i.on { background: var(--sky); }
.strip i.pre { background: var(--line-2); }
.lib .pcard { background: var(--mist-2); box-shadow: none; }
.lib .pcard.is-added { opacity: 0.72; }
.pcard .btns { display: flex; gap: var(--s2); }
.added-flag { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--ok); font-weight: 600; min-height: 36px; }
.fly { animation: fly var(--t-slow) var(--ease-out) both; }
@keyframes fly { 0% { box-shadow: 0 0 0 0 rgba(55, 138, 221, 0.5); } 40% { box-shadow: 0 0 0 6px rgba(55, 138, 221, 0.18); } 100% { box-shadow: var(--shadow-1); } }
.scratch { display: flex; align-items: center; justify-content: center; gap: var(--s2); width: 100%; min-height: 64px; border-radius: var(--r-card); border: 1.5px dashed var(--line-2); color: var(--navy-2); font-weight: 600; transition: background var(--t-fast), border-color var(--t-fast); }
.scratch:hover { background: var(--mist-2); border-color: var(--navy-2); }

/* ---------- Protocol editor ---------- */
.ed-grid { display: block; }
.ed-side { display: none; }
@media (min-width: 1024px) {
  .ed-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: var(--s6); align-items: start; }
  .ed-side { display: block; position: sticky; top: var(--s6); }
  .pv-open-m { display: none !important; }
}
.ed-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); }
.ed-title { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.meta-line { display: flex; align-items: flex-start; gap: var(--s2); margin-top: var(--s4); padding: 10px 12px; border-radius: var(--r-md); background: var(--white); border: 1px solid var(--line); font-size: var(--fs-xs); color: var(--ink-2); line-height: 1.7; }
.meta-line .ic { color: var(--navy-2); margin-top: 1px; }

/* Timeline */
.tl { position: relative; list-style: none; margin: 0; padding: 0; }
.tl::before { content: ""; position: absolute; inset-block: 22px 22px; inset-inline-start: 19px; width: 2px; background: var(--line); border-radius: 2px; }
.tp { position: relative; padding-inline-start: 44px; margin-bottom: var(--s2); }
.tp-node { position: absolute; inset-inline-start: 13px; top: 20px; width: 14px; height: 14px; border-radius: 50%; background: var(--white); border: 2px solid var(--sky); transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-med) var(--ease-spring); z-index: 1; }
.tp.is-open .tp-node { background: var(--navy); border-color: var(--navy); transform: scale(1.15); }
.tp.is-pre .tp-node { border-color: var(--line-2); }
.tp-card { border-radius: var(--r-card); background: var(--white); border: 1px solid var(--line); box-shadow: var(--shadow-1); transition: border-color var(--t-fast), box-shadow var(--t-med) var(--ease); }
.tp.is-open .tp-card { border-color: var(--line-2); box-shadow: var(--shadow-2); }
.tp-head { display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: 56px; padding: var(--s3) var(--s4); text-align: start; border-radius: var(--r-card); }
.tp-head:hover { background: var(--mist-2); }
.tp.is-open .tp-head { border-radius: var(--r-card) var(--r-card) 0 0; }
.tp-when { flex: 1; min-width: 0; line-height: 1.45; }
.tp-when > b { display: block; font-weight: 700; font-size: var(--fs-md); }
.tp-when > span { display: flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--ink-3); flex-wrap: wrap; }
.tp-kinds { display: flex; gap: 4px; color: var(--navy-2); }
.tp-kinds .ic { width: 16px; height: 16px; }
.tp-chev { color: var(--ink-3); transition: transform var(--t-med) var(--ease); }
.tp.is-open .tp-chev { transform: rotate(180deg); }
.tp-body { padding: 0 var(--s4) var(--s4); border-top: 1px solid var(--line); }
.tp-body-in { animation: body-in var(--t-med) var(--ease-out); }
@keyframes body-in { from { opacity: 0; transform: translateY(-6px); } }
.tp-tools { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); padding: var(--s3) 0 var(--s2); flex-wrap: wrap; }
.surgery { position: relative; display: flex; align-items: center; gap: var(--s2); padding-inline-start: 44px; margin: var(--s3) 0 var(--s4); }
.surgery-node { position: absolute; inset-inline-start: 9px; top: 50%; width: 22px; height: 22px; margin-top: -11px; border-radius: 6px; background: var(--navy); color: var(--white); display: grid; place-items: center; transform: rotate(45deg); z-index: 1; }
.surgery-node .ic { transform: rotate(-45deg); }
.surgery-label { font-size: var(--fs-xs); font-weight: 700; color: var(--navy); background: var(--mist); padding: 4px 12px; border-radius: 999px; }
.surgery-line { flex: 1; height: 1px; background: var(--line-2); }
.add-tp { display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: 52px; padding-inline-start: 44px; position: relative; color: var(--navy-2); font-weight: 600; }
.add-tp .plus { position: absolute; inset-inline-start: 6px; width: 28px; height: 28px; border-radius: 50%; border: 1.5px dashed var(--navy-2); display: grid; place-items: center; background: var(--paper); transition: background var(--t-fast), transform var(--t-med) var(--ease-spring); }
.add-tp:hover .plus { background: var(--mist); transform: rotate(90deg); }
.add-tp .txt { border-radius: var(--r-md); padding: 8px 12px; transition: background var(--t-fast); }
.add-tp:hover .txt { background: var(--mist-2); }

/* Message card */
.msg { margin-top: var(--s3); border: 1px solid var(--line); border-radius: 14px; background: var(--white); }
.msg-head { display: flex; align-items: center; gap: var(--s2); padding: 10px 12px 0; flex-wrap: wrap; }
.msg-kind { display: flex; align-items: center; gap: var(--s2); font-weight: 700; font-size: var(--fs-sm); flex: 1 1 auto; white-space: nowrap; }
.msg-head .send-tag { order: 3; margin-inline-start: 40px; }
.msg-tools { order: 2; }
.msg-order { font-size: var(--fs-xs); color: var(--ink-3); font-weight: 600; font-variant-numeric: tabular-nums; }
.msg-tools { display: flex; align-items: center; }
.msg-body { padding: var(--s3); }
.send-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; color: var(--ink-3); padding: 2px 8px; border-radius: 999px; background: var(--mist-2); border: 1px solid var(--line); white-space: nowrap; }
.send-tag.tpl { color: var(--navy); background: var(--mist); border-color: #cfe1f5; }

/* Fill-in frame: the fixed template text around the surgeon's sentence */
.frame { padding: var(--s3); border-radius: 12px; background: var(--mist-2); border: 1px solid var(--line); font-size: var(--fs-sm); line-height: 1.9; }
.frame .fixed { color: var(--ink-3); }
.frame .fixed + .fill, .frame .fill + .fixed { margin-top: 4px; }
.fill { position: relative; display: block; }
.fill input { width: 100%; min-height: 44px; padding: 8px 12px; border-radius: 10px; background: var(--white); border: 1.5px dashed var(--sky); color: var(--ink); font-size: var(--fs-md); font-weight: 500; transition: border-color var(--t-fast), box-shadow var(--t-fast); }
.fill input::placeholder { color: #9aabbf; font-weight: 400; }
.fill input:focus { outline: none; border-style: solid; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(55, 138, 221, 0.16); }
.fill .count { display: block; margin-top: 4px; text-align: left; font-size: 11px; line-height: 1.4; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.fill .count.warn { color: var(--attn); font-weight: 600; }
.frame-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--s2); }
.frame-btns span { padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--white); color: var(--navy); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.checks { margin-top: var(--s2); }
.checks:empty { display: none; }

/* Answers outline */
.answers { margin-top: var(--s3); display: grid; gap: var(--s3); }
.answers-title { display: flex; align-items: center; justify-content: space-between; font-size: var(--fs-xs); color: var(--ink-3); font-weight: 600; }
.ans { position: relative; padding-inline-start: var(--s4); border-inline-start: 2px solid var(--line); }
.ans-head { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; margin-bottom: var(--s2); }
.ans-label { display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px; border-radius: 999px; background: var(--navy); color: var(--white); font-size: var(--fs-sm); font-weight: 600; font-variant-numeric: tabular-nums; }
.ans-label.soft { background: var(--mist); color: var(--navy); }
.ans-label-input { min-height: 36px; width: 150px; padding: 0 12px; border-radius: 999px; border: 1.5px dashed var(--sky); background: var(--white); font-weight: 600; font-size: var(--fs-sm); color: var(--navy); }
.ans-label-input:focus { outline: none; border-style: solid; border-color: var(--blue); }
.ans-toggles { display: flex; gap: var(--s2); flex-wrap: wrap; }
.ans-then { margin-top: var(--s2); }
.ans-then .lbl { font-size: var(--fs-xs); color: var(--ink-3); font-weight: 600; margin-bottom: 6px; display: block; }
.ans-extra { margin-top: var(--s2); }
.ans-extra .fill input { font-size: var(--fs-sm); }
.nest { margin-top: var(--s3); padding: var(--s3); border-radius: 12px; background: var(--paper); border: 1px solid var(--line); }
.nest-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); font-size: var(--fs-xs); color: var(--ink-3); font-weight: 600; margin-bottom: var(--s2); }
.depth { display: inline-flex; align-items: center; gap: 6px; }
.depth i { width: 14px; height: 4px; border-radius: 2px; background: var(--line-2); }
.depth i.on { background: var(--navy-2); }
.rule-chips { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s3); }
.rchip { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding-inline: 4px 4px; padding-inline-start: 12px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--white); font-size: var(--fs-sm); font-weight: 600; color: var(--ink-3); transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast); }
.rchip.is-on { background: var(--attn-bg); border-color: #ecd2a8; color: var(--attn); }
.rchip .rchip-t { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; }
.rchip .stepper { border: 0; background: transparent; }
.rchip .stepper button { width: 32px; height: 32px; color: inherit; }
.rchip .stepper output { min-width: 22px; font-size: var(--fs-md); }
.rchip:not(.is-on) .stepper { opacity: 0.45; pointer-events: none; }

.add-msg { display: flex; align-items: center; justify-content: center; gap: var(--s2); width: 100%; min-height: 48px; margin-top: var(--s3); border-radius: 12px; border: 1.5px dashed var(--line-2); color: var(--navy-2); font-weight: 600; font-size: var(--fs-sm); transition: background var(--t-fast), border-color var(--t-fast); }
.add-msg:hover { background: var(--mist-2); border-color: var(--navy-2); }
.add-msg:disabled { color: var(--ink-3); border-color: var(--line); background: none; }
.empty { text-align: center; padding: var(--s5) var(--s4); color: var(--ink-3); font-size: var(--fs-sm); }
.empty .ibox { margin: 0 auto var(--s3); }
.empty b { display: block; color: var(--ink); font-weight: 600; margin-bottom: 2px; }

.redflags .frame textarea { width: 100%; min-height: 120px; resize: vertical; padding: 10px 12px; border-radius: 10px; background: var(--white); border: 1.5px dashed var(--sky); font-size: var(--fs-sm); line-height: 1.9; }
.redflags .frame textarea:focus { outline: none; border-style: solid; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(55, 138, 221, 0.16); }
.redflags.is-missing .card { border-color: #f0cccc; }

.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.checklist li { display: flex; gap: var(--s2); align-items: flex-start; font-size: var(--fs-sm); line-height: 1.6; }
.checklist .ok { color: var(--ok); }
.checklist .attn { color: var(--attn); }
.checklist .bad { color: var(--danger); }

.savebar { position: fixed; inset-inline: 0; bottom: calc(var(--tabbar) + var(--safe-b)); z-index: 25; padding: var(--s3) var(--s4); background: rgba(255, 255, 255, 0.96); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-top: 1px solid var(--line); display: flex; gap: var(--s2); align-items: center; animation: bar-in var(--t-med) var(--ease-out); }
.savebar .state { flex: 1; min-width: 0; font-size: var(--fs-xs); color: var(--ink-3); line-height: 1.4; display: flex; align-items: center; gap: 6px; }
.savebar .state .dot { background: var(--sky); }
.savebar .state.dirty .dot { background: #c98a2b; }
@keyframes bar-in { from { transform: translateY(100%); } }
@media (min-width: 1024px) { .savebar { inset-inline-start: var(--rail); bottom: 0; padding-inline: var(--s7); } .savebar .pv-open-m { display: none; } }
.ed-pad { height: 72px; }

.banner { display: flex; align-items: flex-start; gap: var(--s3); padding: var(--s3) var(--s4); border-radius: var(--r-card); background: var(--navy); color: var(--white); font-size: var(--fs-sm); line-height: 1.7; margin-bottom: var(--s4); animation: banner-in var(--t-slow) var(--ease-out); }
.banner .ic { color: var(--sky); margin-top: 3px; }
.banner span { color: #c8dcf2; display: block; font-size: var(--fs-xs); }
.banner .iconbtn { color: #c8dcf2; margin: -8px; }
.banner .iconbtn:hover { background: rgba(255, 255, 255, 0.1); color: var(--white); }
@keyframes banner-in { from { opacity: 0; transform: translateY(-10px) scale(0.98); } }

/* ---------- Patient preview (brand colours, not a messaging-app look) ---------- */
.phone { width: 100%; max-width: 360px; margin: 0 auto; border-radius: 32px; background: var(--ink); padding: 8px; box-shadow: var(--shadow-2); }
.phone-in { border-radius: 26px; overflow: hidden; background: var(--mist-2); display: flex; flex-direction: column; height: min(640px, calc(100vh - 150px)); min-height: 480px; }
.sheet .phone { box-shadow: none; }
.sheet .phone-in { height: calc(88vh - 150px); min-height: 420px; }
.pv-top { display: flex; align-items: center; gap: var(--s3); padding: 14px 14px 12px; background: var(--white); border-bottom: 1px solid var(--line); }
.pv-av { width: 38px; height: 38px; border-radius: 50%; background: var(--navy); display: grid; place-items: center; flex: none; position: relative; }
.pv-av .logo { color: var(--white); font-size: 13px; }
.pv-av::after { content: ""; position: absolute; bottom: 8px; width: 14px; height: 2px; border-radius: 2px; background: var(--sky); }
.pv-name { flex: 1; min-width: 0; line-height: 1.35; }
.pv-name b { display: flex; align-items: center; gap: 4px; font-size: var(--fs-sm); }
.pv-name b .ic { color: var(--blue); }
.pv-name span { font-size: 11px; color: var(--ink-3); }
.pv-days { display: flex; gap: 6px; padding: 8px 10px; background: var(--white); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.pv-days::-webkit-scrollbar { display: none; }
.pv-days button { flex: none; min-height: 32px; padding: 0 12px; border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--ink-3); border: 1px solid var(--line); background: var(--white); transition: background var(--t-fast), color var(--t-fast); }
.pv-days button[aria-pressed="true"] { background: var(--navy); color: var(--white); border-color: var(--navy); }
.chat { flex: 1; overflow-y: auto; padding: var(--s4) var(--s3); display: flex; flex-direction: column; gap: var(--s2); scroll-behavior: smooth; }
.chat .daychip { align-self: center; font-size: 11px; color: var(--ink-3); background: var(--white); border: 1px solid var(--line); padding: 2px 10px; border-radius: 999px; margin-bottom: var(--s2); }
.chat .bubble { white-space: pre-line; animation: bubble-in var(--t-med) var(--ease-spring) both; transform-origin: top right; }
.chat .bubble-out { transform-origin: top left; }
.chat .bubble p + p { margin-top: 6px; }
.chat .typing { animation: bubble-in var(--t-fast) var(--ease-out) both; }
@keyframes bubble-in { from { opacity: 0; transform: translateY(6px) scale(0.96); } }
.bubble .fx { color: var(--ink-2); }
.bubble .bubble-meta { text-align: left; }
.bubble-out .bubble-meta { color: #c8dcf2; }
.pv-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.pv-btns button { flex: 1 1 auto; min-height: 38px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--mist-2); color: var(--navy); font-size: var(--fs-xs); font-weight: 700; transition: background var(--t-fast), transform var(--t-fast) var(--ease), border-color var(--t-fast); }
.pv-btns button:hover:not(:disabled) { background: var(--mist); border-color: var(--sky); }
.pv-btns button:active:not(:disabled) { transform: scale(0.96); }
.pv-btns button:disabled { opacity: 0.45; cursor: default; }
.pv-btns button.picked { background: var(--navy); border-color: var(--navy); color: var(--white); opacity: 1; }
.pv-btns.pain { display: grid; grid-template-columns: repeat(5, 1fr); }
.pv-btns.pain button { min-height: 36px; padding: 0; font-variant-numeric: tabular-nums; }
.pv-note { align-self: center; display: inline-flex; align-items: center; gap: 6px; max-width: 92%; padding: 4px 12px; border-radius: 999px; font-size: 11px; font-weight: 600; line-height: 1.6; border: 1px dashed; animation: bubble-in var(--t-med) var(--ease-out) both; text-align: center; }
.pv-note.alert { color: var(--attn); border-color: #e0bd85; background: var(--attn-bg); }
.pv-note.coord { color: var(--navy); border-color: var(--sky); background: var(--mist); }
.pv-note.end { color: var(--ink-3); border-color: var(--line-2); background: var(--white); }
.pv-note.repeat { color: var(--navy-2); border-color: var(--sky); background: var(--white); }
.pv-photo { width: 180px; height: 128px; border-radius: 10px; background: repeating-linear-gradient(135deg, #dbe8f6 0 8px, #e8f1fb 8px 16px); display: grid; place-items: center; color: var(--navy-2); }
.pv-bottom { display: flex; align-items: center; gap: var(--s2); padding: 10px; background: var(--white); border-top: 1px solid var(--line); }
.pv-compose { flex: 1; min-height: 40px; border-radius: 999px; background: var(--mist-2); border: 1px solid var(--line); display: flex; align-items: center; padding: 0 14px; font-size: 12px; color: var(--ink-3); }
.pv-cam { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--mist); color: var(--ink-3); transition: background var(--t-fast), color var(--t-fast); }
.pv-cam.is-live { background: var(--navy); color: var(--white); animation: cam 1.6s var(--ease-out) infinite; }
@keyframes cam { 0% { box-shadow: 0 0 0 0 rgba(12, 68, 124, 0.4); } 80%, 100% { box-shadow: 0 0 0 10px rgba(12, 68, 124, 0); } }
.pv-controls { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); margin-bottom: var(--s3); }
.pv-legend { margin-top: var(--s3); font-size: 11px; color: var(--ink-3); text-align: center; line-height: 1.6; }
.pv-legend i { display: inline-block; width: 18px; height: 10px; border: 1px dashed #e0bd85; background: var(--attn-bg); border-radius: 999px; vertical-align: -1px; margin-inline-end: 4px; }

/* ---------- Sheets and dialogs ---------- */
.backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(11, 31, 51, 0.36); opacity: 0; transition: opacity var(--t-med) var(--ease); }
.backdrop.is-in { opacity: 1; }
.sheet { position: fixed; z-index: 61; inset-inline: 0; bottom: 0; max-height: 92vh; max-height: 92dvh; display: flex; flex-direction: column; background: var(--white); border-radius: 24px 24px 0 0; box-shadow: 0 -12px 40px -12px rgba(11, 31, 51, 0.3); transform: translateY(100%); transition: transform 420ms var(--ease-out); padding-bottom: var(--safe-b); }
.sheet.is-in { transform: none; }
.sheet-grip { width: 40px; height: 4px; border-radius: 4px; background: var(--line-2); margin: 10px auto 0; flex: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s3) var(--s4) var(--s2) var(--s2); padding-inline-start: var(--s5); flex: none; }
.sheet-title { font-size: var(--fs-lg); font-weight: 700; line-height: 1.4; }
.sheet-sub { font-size: var(--fs-xs); color: var(--ink-3); }
.sheet-body { padding: var(--s2) var(--s5) var(--s5); overflow-y: auto; overscroll-behavior: contain; }
.sheet-foot { flex: none; display: flex; gap: var(--s2); padding: var(--s3) var(--s5) var(--s4); border-top: 1px solid var(--line); background: var(--white); }
.sheet-foot .btn { flex: 1; }
@media (min-width: 720px) {
  .sheet { inset-inline: auto; left: 50%; bottom: auto; top: 50%; width: min(560px, calc(100vw - 48px)); max-height: 86vh; border-radius: 24px; transform: translate(-50%, calc(-50% + 24px)) scale(0.98); opacity: 0; transition: transform var(--t-med) var(--ease-out), opacity var(--t-med) var(--ease); }
  .sheet.is-in { transform: translate(-50%, -50%); opacity: 1; }
  .sheet-grip { display: none; }
  .sheet-head { padding-top: var(--s5); }
  .sheet.wide { width: min(440px, calc(100vw - 48px)); }
}
.sheet .group + .group { margin-top: var(--s5); }
.sheet .group-label { font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); margin-bottom: var(--s2); display: block; }
.picker-sum { text-align: center; padding: var(--s4); border-radius: var(--r-card); background: var(--mist-2); border: 1px solid var(--line); margin-bottom: var(--s5); }
.picker-sum b { display: block; font-size: var(--fs-xl); font-weight: 700; color: var(--navy); line-height: 1.4; }
.picker-sum span { font-size: var(--fs-xs); color: var(--ink-3); }
.picker-row { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }

.kinds { display: grid; gap: var(--s2); }
.kind { display: flex; align-items: flex-start; gap: var(--s3); padding: var(--s3); text-align: start; border-radius: 14px; border: 1px solid var(--line); background: var(--white); transition: border-color var(--t-fast), background var(--t-fast), transform var(--t-fast) var(--ease); }
.kind:hover:not(:disabled) { border-color: var(--navy-2); background: var(--mist-2); }
.kind:active:not(:disabled) { transform: scale(0.99); }
.kind:disabled { opacity: 0.55; }
.kind b { display: block; font-weight: 700; font-size: var(--fs-sm); }
.kind .row-main > span { display: block; font-size: var(--fs-xs); color: var(--ink-3); line-height: 1.6; }
.kind .eg { display: inline-flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.kind .eg i { font-style: normal; font-size: 10px; font-weight: 700; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--navy); background: var(--white); }

/* Toast */
#toast-root { position: fixed; z-index: 80; inset-inline: 0; bottom: calc(var(--tabbar) + var(--safe-b) + 16px); display: flex; justify-content: center; pointer-events: none; padding: 0 var(--s4); }
.toast { display: flex; align-items: center; gap: var(--s2); max-width: 440px; padding: 12px 16px; border-radius: 14px; background: var(--ink); color: var(--white); font-size: var(--fs-sm); box-shadow: var(--shadow-2); animation: toast-in var(--t-med) var(--ease-spring) both; pointer-events: auto; }
.toast .ic { color: var(--sky); }
.toast.out { animation: toast-out var(--t-fast) var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(0.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }
@media (min-width: 1024px) { #toast-root { bottom: 32px; padding-inline-start: var(--rail); } }

/* ---------- Auth and onboarding ---------- */
.bare { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.auth { flex: 1; display: grid; grid-template-columns: 1fr; }
.auth-main { display: flex; flex-direction: column; justify-content: center; padding: var(--s7) var(--s5); max-width: 440px; width: 100%; margin: 0 auto; }
.hero-logo { display: inline-flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: var(--s6); align-self: flex-start; }
.hero-logo .logo { font-size: 64px; }
.hero-logo .brand-bar { width: 0; height: 5px; animation: underline 900ms 250ms var(--ease-out) forwards; }
@keyframes underline { to { width: 70%; } }
.auth h1 { font-size: var(--fs-2xl); line-height: 1.35; font-weight: 700; }
.auth .lead { margin-top: var(--s3); color: var(--ink-2); }
.gbtn { display: flex; align-items: center; justify-content: center; gap: var(--s3); width: 100%; min-height: 52px; margin-top: var(--s6); border-radius: 999px; background: var(--white); border: 1px solid var(--line-2); font-weight: 600; font-size: var(--fs-md); color: var(--ink); box-shadow: var(--shadow-1); transition: border-color var(--t-fast), box-shadow var(--t-med) var(--ease), transform var(--t-fast); }
.gbtn:hover { border-color: var(--navy-2); box-shadow: var(--shadow-2); }
.gbtn:active { transform: translateY(1px); }
.gmark { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--mist); color: var(--navy); }
.fine { margin-top: var(--s4); font-size: var(--fs-xs); color: var(--ink-3); line-height: 1.7; text-align: center; }
.how { list-style: none; margin: var(--s6) 0 0; padding: 0; display: grid; gap: var(--s3); counter-reset: how; }
.how li { display: flex; gap: var(--s3); align-items: flex-start; font-size: var(--fs-sm); color: var(--ink-2); line-height: 1.7; }
.how li::before { counter-increment: how; content: counter(how); flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--mist); color: var(--navy); font-weight: 700; font-size: var(--fs-xs); display: grid; place-items: center; margin-top: 1px; }
.auth-art { display: none; }
@media (min-width: 1024px) {
  .auth { grid-template-columns: minmax(420px, 1fr) 1fr; }
  .auth-art { display: flex; flex-direction: column; justify-content: center; padding: var(--s8); background: var(--navy); color: var(--white); position: relative; overflow: hidden; }
  .auth-main { padding: var(--s8) var(--s7); }
}
.art-tl { position: relative; list-style: none; margin: 0; padding: 0; max-width: 400px; }
.art-tl::before { content: ""; position: absolute; inset-inline-start: 7px; top: 12px; bottom: 12px; width: 2px; background: rgba(133, 183, 235, 0.35); }
.art-tl li { position: relative; padding-inline-start: 36px; margin-bottom: var(--s5); opacity: 0; animation: art-in 700ms var(--ease-out) forwards; }
.art-tl li:nth-child(2) { animation-delay: 180ms; } .art-tl li:nth-child(3) { animation-delay: 360ms; } .art-tl li:nth-child(4) { animation-delay: 540ms; }
.art-tl li::before { content: ""; position: absolute; inset-inline-start: 0; top: 7px; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--sky); background: var(--navy); }
.art-tl li.hot::before { background: var(--sky); }
.art-tl b { display: block; font-size: var(--fs-md); }
.art-tl span { font-size: var(--fs-sm); color: #c8dcf2; }
.art-card { margin-top: 8px; padding: 10px 14px; border-radius: 12px; background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(133, 183, 235, 0.25); font-size: var(--fs-sm); color: #e8f1fb; }
@keyframes art-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.art-cap { margin-top: var(--s6); font-size: var(--fs-sm); color: #c8dcf2; max-width: 400px; }

.drive-tree { margin-top: var(--s5); padding: var(--s4); border-radius: var(--r-card); background: var(--white); border: 1px solid var(--line); box-shadow: var(--shadow-1); font-size: var(--fs-sm); }
.drive-tree .node { display: flex; align-items: center; gap: var(--s2); min-height: 36px; }
.drive-tree .node .ic { color: var(--navy-2); }
.drive-tree .lvl1 { padding-inline-start: var(--s5); position: relative; }
.drive-tree .lvl1::before { content: ""; position: absolute; inset-inline-start: 9px; top: 0; bottom: 50%; width: 10px; border-inline-start: 1.5px solid var(--line-2); border-bottom: 1.5px solid var(--line-2); border-end-start-radius: 6px; }
.drive-tree .own { margin-inline-start: auto; font-size: 11px; }
.ticks { list-style: none; margin: var(--s5) 0 0; padding: 0; display: grid; gap: var(--s2); }
.ticks li { display: flex; gap: var(--s2); align-items: flex-start; font-size: var(--fs-sm); color: var(--ink-2); line-height: 1.7; }
.ticks .ic { color: var(--ok); margin-top: 3px; }

.ob { flex: 1; display: flex; flex-direction: column; max-width: 560px; width: 100%; margin: 0 auto; padding: var(--s4) var(--s4) 0; }
.ob-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: 48px; }
.ob-top .brand .logo { font-size: 22px; }
.progress { display: flex; gap: 6px; margin: var(--s4) 0 var(--s2); }
.progress i { flex: 1; height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; position: relative; }
.progress i::after { content: ""; position: absolute; inset: 0; background: var(--navy); transform: scaleX(0); transform-origin: right; transition: transform 500ms var(--ease-out); }
.progress i.done::after { transform: scaleX(1); }
.progress-l { font-size: var(--fs-xs); color: var(--ink-3); font-weight: 600; }
.ob-body { flex: 1; padding: var(--s5) 0 var(--s6); }
.ob-body h1 { font-size: var(--fs-xl); font-weight: 700; line-height: 1.4; }
.ob-body .lead { margin-top: var(--s2); color: var(--ink-2); font-size: var(--fs-sm); }
.ob-body .content { margin-top: var(--s5); }
.ob-foot { position: sticky; bottom: 0; display: flex; gap: var(--s2); padding: var(--s3) 0 calc(var(--s4) + var(--safe-b)); background: linear-gradient(to top, var(--paper) 70%, rgba(251, 252, 254, 0)); }
.ob-foot .btn-primary { flex: 1; }
.ob-slide { animation: ob-in var(--t-med) var(--ease-out) backwards; }
@keyframes ob-in { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: none; } }
.ob-slide.back-dir { animation-name: ob-in-back; }
@keyframes ob-in-back { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
.preview-line { margin-top: var(--s4); padding: var(--s3) var(--s4); border-radius: var(--r-md); background: var(--mist-2); border: 1px solid var(--line); font-size: var(--fs-sm); color: var(--ink-2); }
.preview-line b { color: var(--navy); }

.verify { margin-top: var(--s5); padding: var(--s5); border-radius: var(--r-card); background: var(--white); border: 1px solid var(--line); box-shadow: var(--shadow-1); text-align: center; }
.verify .code { display: inline-flex; align-items: center; gap: var(--s2); margin: var(--s3) 0; padding: 8px 16px; border-radius: 12px; background: var(--mist); color: var(--navy); font-weight: 700; font-size: var(--fs-lg); }
.verify .wait { display: inline-flex; align-items: center; gap: var(--s2); font-size: var(--fs-sm); color: var(--ink-3); }
.verified { display: flex; align-items: center; gap: var(--s3); text-align: start; }
.verified .seal { width: 48px; height: 48px; border-radius: 50%; background: var(--ok-bg); color: var(--ok); display: grid; place-items: center; flex: none; animation: seal var(--t-slow) var(--ease-spring); }
@keyframes seal { from { transform: scale(0.4); opacity: 0; } }
.draw path { stroke-dasharray: 30; stroke-dashoffset: 30; animation: draw 500ms 150ms var(--ease-out) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

.center-card { padding: var(--s4); border-radius: var(--r-card); background: var(--white); border: 1px solid var(--line); box-shadow: var(--shadow-1); }
.center-card + .center-card { margin-top: var(--s3); }
.day-rows { display: grid; gap: var(--s2); margin-top: var(--s3); }
.day-row { display: flex; align-items: center; gap: var(--s3); padding: 6px 0; border-top: 1px dashed var(--line); animation: body-in var(--t-med) var(--ease-out); flex-wrap: wrap; }
.day-row:first-child { border-top: 0; }
.day-row .d { width: 64px; font-weight: 600; font-size: var(--fs-sm); flex: none; }

.lib-pick { display: grid; gap: var(--s2); }
.lib-pick .kind[aria-checked="true"] { border-color: var(--navy); background: var(--mist-2); box-shadow: 0 0 0 1px var(--navy); }
.radio-dot { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line-2); flex: none; display: grid; place-items: center; margin-top: 2px; transition: border-color var(--t-fast); }
.radio-dot::after { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--navy); transform: scale(0); transition: transform var(--t-med) var(--ease-spring); }
[aria-checked="true"] > .radio-dot { border-color: var(--navy); }
[aria-checked="true"] > .radio-dot::after { transform: scale(1); }

.finish { text-align: center; }
.finish .phone { max-width: 300px; margin-top: var(--s5); }
.finish .phone-in { height: 470px; min-height: 0; }

/* ---------- Centers ---------- */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: var(--s3); }
.week div { text-align: center; }
.week .wd { font-size: 11px; color: var(--ink-3); font-weight: 600; }
.week .slot { margin-top: 4px; min-height: 40px; border-radius: 8px; background: var(--mist-2); border: 1px dashed var(--line); display: flex; flex-direction: column; justify-content: center; gap: 2px; padding: 2px; }
.week .slot.on { background: var(--mist); border: 1px solid #cfe1f5; }
.week .slot i { font-style: normal; font-size: 10px; font-weight: 700; color: var(--navy); line-height: 1.3; }
.coord-list { margin-top: var(--s4); border-top: 1px solid var(--line); }
.coord { display: flex; align-items: center; gap: var(--s3); min-height: 56px; border-bottom: 1px solid var(--line); }
.coord:last-child { border-bottom: 0; }
.coord .avatar { width: 36px; height: 36px; font-size: var(--fs-xs); }
.flow { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; counter-reset: flow; }
.flow > li { position: relative; padding: 0 0 var(--s5); padding-inline-start: 44px; }
.flow > li::before { counter-increment: flow; content: counter(flow); position: absolute; inset-inline-start: 0; top: 0; width: 28px; height: 28px; border-radius: 50%; background: var(--navy); color: var(--white); font-weight: 700; font-size: var(--fs-xs); display: grid; place-items: center; z-index: 1; }
.flow > li::after { content: ""; position: absolute; inset-inline-start: 13px; top: 28px; bottom: 0; width: 2px; background: var(--line); }
.flow > li:last-child::after { display: none; }
.flow > li:last-child { padding-bottom: 0; }
.flow b { display: block; font-weight: 700; font-size: var(--fs-sm); line-height: 1.6; }
.flow p { font-size: var(--fs-xs); color: var(--ink-3); line-height: 1.7; margin-top: 2px; }
.mini-card { margin-top: var(--s2); padding: 10px 12px; border-radius: 12px; background: var(--mist-2); border: 1px solid var(--line); font-size: var(--fs-xs); line-height: 1.7; color: var(--ink-2); }
.mini-card .mini-btns { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.mini-card .mini-btns span { padding: 2px 10px; border-radius: 999px; background: var(--white); border: 1px solid var(--line-2); color: var(--navy); font-weight: 600; font-size: 11px; }
.center-grid { display: grid; gap: var(--s4); }
@media (min-width: 1024px) { .center-grid { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); align-items: start; } }

/* ---------- Connection ---------- */
.kv { display: grid; grid-template-columns: 1fr; }
.kv > div { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: 52px; padding: var(--s2) var(--s4); border-top: 1px solid var(--line); }
.kv > div:first-child { border-top: 0; }
.kv dt { font-size: var(--fs-sm); color: var(--ink-3); }
.kv dd { margin: 0; font-size: var(--fs-sm); font-weight: 600; display: flex; align-items: center; gap: 6px; text-align: end; }
.meter { display: inline-flex; gap: 3px; }
.meter i { width: 14px; height: 6px; border-radius: 3px; background: var(--line); }
.meter i.on { background: var(--ok); }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 44px; margin-top: var(--s3); direction: ltr; }
.bars i { flex: 1; border-radius: 2px 2px 0 0; background: var(--sky); opacity: 0.8; transform-origin: bottom; animation: grow 700ms var(--ease-out) both; }
.bars i.now { background: var(--navy); opacity: 1; }
@keyframes grow { from { transform: scaleY(0); } }
.pipe { display: grid; grid-template-columns: 1fr; gap: var(--s2); }
.pipe-node { display: flex; align-items: center; gap: var(--s3); padding: var(--s3); border-radius: 12px; background: var(--mist-2); border: 1px solid var(--line); font-size: var(--fs-sm); }
.pipe-node b { display: block; font-size: var(--fs-sm); }
.pipe-node span { font-size: var(--fs-xs); color: var(--ink-3); }
.pipe-link { display: flex; justify-content: center; color: var(--sky); height: 18px; position: relative; overflow: hidden; }
.pipe-link::before { content: ""; width: 2px; height: 100%; background: repeating-linear-gradient(to bottom, var(--sky) 0 4px, transparent 4px 8px); animation: flow 1s linear infinite; }
@keyframes flow { to { background-position: 0 8px; } }
@media (min-width: 1024px) {
  .pipe { grid-template-columns: 1fr 32px 1fr 32px 1fr 32px 1fr; align-items: center; }
  .pipe-node { flex-direction: column; text-align: center; min-height: 128px; justify-content: center; }
  .pipe-link { height: 2px; width: 100%; }
  .pipe-link::before { width: 100%; height: 2px; background: repeating-linear-gradient(to left, var(--sky) 0 4px, transparent 4px 8px); animation: flow-x 1s linear infinite; }
  @keyframes flow-x { to { background-position: -8px 0; } }
}
.tpl-group + .tpl-group { margin-top: var(--s4); }
.tpl-row { width: 100%; }
.tpl-row .row-main > b { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.code-name { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 11px; color: var(--ink-3); font-weight: 400; direction: ltr; unicode-bidi: isolate; }
.tpl-body { padding: 0 var(--s4) var(--s4); animation: body-in var(--t-med) var(--ease-out); }
.tpl-body .frame { font-size: var(--fs-xs); }
.var { display: inline-block; padding: 0 8px; border-radius: 6px; background: var(--white); border: 1px dashed var(--sky); color: var(--navy); font-weight: 600; }
.conn-grid { display: grid; gap: var(--s4); }
@media (min-width: 1024px) { .conn-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; } }

/* ---------- Settings ---------- */
.set-group { padding: var(--s2) var(--s4); }
.set-item { padding: var(--s4) 0; border-top: 1px solid var(--line); }
.set-item:first-child { border-top: 0; }
.set-item .label { margin-bottom: var(--s1); font-size: var(--fs-md); color: var(--ink); }
.set-item .hint { margin-top: 0; margin-bottom: var(--s3); }
.set-item .switch-row { min-height: 0; }
.set-sub { margin-top: var(--s3); padding: var(--s3); border-radius: 12px; background: var(--mist-2); border: 1px solid var(--line); animation: body-in var(--t-med) var(--ease-out); }
.hours { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.hours .to { color: var(--ink-3); font-size: var(--fs-sm); }
.set-grid { display: grid; gap: var(--s4); }
@media (min-width: 1024px) { .set-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-flow: dense; align-items: start; } .set-grid > .alerts { grid-column: 2; grid-row: 1 / span 2; } }
.set-grid > .card + .card { margin-top: 0; }
.hours-pair { display: inline-flex; align-items: center; gap: var(--s2); }
.hours-pair .muted { min-width: 20px; }

/* ---------- QR ---------- */
.qr-card { text-align: center; padding: var(--s5); border-radius: var(--r-card); border: 1px solid var(--line); background: var(--white); }
.qr-card .qr { width: 216px; height: 216px; margin: var(--s4) auto; display: block; }
.qr-card .logo { font-size: 28px; }
.qr-card .cap { font-size: var(--fs-md); font-weight: 600; line-height: 1.6; max-width: 280px; margin: 0 auto; }
.qr-card .center { font-size: var(--fs-sm); color: var(--ink-3); margin-top: var(--s2); }
.qr-card .code-name { font-size: var(--fs-xs); }
.qr-draw rect.m { animation: qr-in 500ms var(--ease-out) both; }
@keyframes qr-in { from { opacity: 0; } }

@media print {
  body * { visibility: hidden !important; }
  .qr-card, .qr-card * { visibility: visible !important; }
  .qr-card { position: fixed; inset: 0; border: 0; display: flex; flex-direction: column; justify-content: center; }
  .backdrop, .sheet { transform: none !important; box-shadow: none !important; background: none !important; }
}

.ways { display: grid; gap: var(--s3); }
.way { padding: var(--s4); border-radius: var(--r-card); border: 1px solid var(--line); background: var(--white); }
.way-head { display: flex; align-items: center; gap: var(--s3); }
.way-head b { font-weight: 700; }
.way-head .tag { margin-inline-start: auto; }
.way ol { margin: var(--s3) 0 0; padding-inline-start: 20px; font-size: var(--fs-sm); color: var(--ink-2); line-height: 1.8; }
.way ol li::marker { color: var(--navy-2); font-weight: 700; }

.grid-2 { display: grid; gap: var(--s4); }
@media (min-width: 1024px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; } }

/* ---------- Additions used by demo.js ---------- */
.view.still { animation: none; }
h1:focus, .main:focus { outline: none; }
.ed-tags { display: flex; gap: var(--s2); flex-wrap: wrap; margin-top: var(--s2); }
.ed-head .page-title::after { display: none; }
.nest .msg-body { padding: var(--s2) 0 0; }
.nest .nest { background: var(--white); }
.pv { width: 100%; }

.mini-tl { position: relative; height: 16px; margin: 2px 6px; }
.mini-tl::before { content: ""; position: absolute; inset-inline: 0; top: 7px; height: 2px; border-radius: 2px; background: var(--mist); }
.mini-tl i { position: absolute; top: 3px; width: 10px; height: 10px; margin-inline-start: -5px; border-radius: 50%; background: var(--white); border: 2px solid var(--sky); }
.mini-tl i.pre { border-color: var(--line-2); }
.mini-tl .op { position: absolute; top: 1px; width: 2px; height: 14px; margin-inline-start: -1px; border-radius: 2px; background: var(--navy); }
.lib .mini-tl::before { background: var(--line); }

@media (max-width: 639px) {
  .tl::before { inset-inline-start: 13px; }
  .tp { padding-inline-start: 32px; transition: padding var(--t-med) var(--ease); }
  .tp-node { inset-inline-start: 7px; }
  .surgery, .add-tp { padding-inline-start: 32px; }
  .surgery-node { inset-inline-start: 3px; }
  .add-tp .plus { inset-inline-start: 0; }
  .tp.is-open { padding-inline-start: 0; }
  .tp.is-open .tp-node { opacity: 0; }
  .tp-body { padding: 0 var(--s3) var(--s3); }
  .msg-body { padding: var(--s3) 10px; }
  .ans { padding-inline-start: var(--s3); }
  .savebar .state { display: none; }
  .savebar .btn { flex: 1; padding: 0 var(--s3); }
  .rchip { padding-inline-start: 10px; }
}
.surgery-node { border-radius: 5px; }

.bare > .view { flex: 1; display: flex; flex-direction: column; }
.row-main > .ltr, .verified .ltr { text-align: right; }
body:has(.bare) #toast-root { bottom: calc(var(--safe-b) + 100px); }

.rep-rows { display: grid; gap: var(--s2); margin: var(--s2) 0 var(--s3); font-size: var(--fs-sm); color: var(--ink-2); }
.rep-rows > div { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: 4px 4px 4px 0; }
.ans-head .tag { margin-inline-end: auto; }
body.is-locked #toast-root { bottom: auto; top: 16px; }
.set-group > .sr-only + .set-item { border-top: 0; }
.rail-foot .who span { display: block; text-align: right; }
@media (min-width: 1024px) { .ed-side .phone-in { height: calc(100vh - 250px); min-height: 440px; } }
