/* Actives Rota - porcelain and plum, one colour per night type. */
:root {
  --bg: #f6f1ec; --card: #fffdfa; --ink: #2d2230; --muted: #75697a; --line: #e7ddd4; --soft: #f1e9e2;
  --plum: #6c3d74; --plum-ink: #fff8fb; --focus: #a35bb0;
  --nx: #d9773d; --nx-bg: #fbe9dc; --nr: #6f55c8; --nr-bg: #ebe6fb; --nc: #3f907b; --nc-bg: #e0f1ea; --am: #c9971c; --am-bg: #fbf2d8;
  --warn: #b5501f; --warn-bg: #fdeee4; --ok: #2f7d5f; --ok-bg: #e4f3ec; --bad: #b42d3c; --bad-bg: #fbe5e8;
  --f-ret: #6f55c8; --f-acid: #d9773d; --f-bpo: #c4453f; --f-vitc: #e2a013; --f-cu: #a8643a; --f-aza: #c25a86; --f-nia: #2f8f9a; --f-spf: #c9971c; --f-bar: #8a9a7b; --f-none: #b9adb3;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b171e; --card: #241f28; --ink: #f2eaf0; --muted: #a99daf; --line: #3a3240; --soft: #2d2732;
    --plum: #c58ccf; --plum-ink: #1b171e; --focus: #d9a6e1;
    --nx-bg: #3d2a1f; --nr-bg: #2c2645; --nc-bg: #1f3530; --am-bg: #3a321b; --nx: #f0985f; --nr: #9d88ef; --nc: #6cc2a8; --am: #e6bb4a;
    --warn: #f0a170; --warn-bg: #3d2a1f; --ok: #7fd1ae; --ok-bg: #1f3530; --bad: #f28a96; --bad-bg: #42222a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1b171e; --card: #241f28; --ink: #f2eaf0; --muted: #a99daf; --line: #3a3240; --soft: #2d2732;
  --plum: #c58ccf; --plum-ink: #1b171e; --focus: #d9a6e1;
  --nx-bg: #3d2a1f; --nr-bg: #2c2645; --nc-bg: #1f3530; --am-bg: #3a321b; --nx: #f0985f; --nr: #9d88ef; --nc: #6cc2a8; --am: #e6bb4a;
  --warn: #f0a170; --warn-bg: #3d2a1f; --ok: #7fd1ae; --ok-bg: #1f3530; --bad: #f28a96; --bad-bg: #42222a;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); }
a { color: var(--plum); }
code { font-family: var(--mono); font-size: 0.88em; background: var(--soft); padding: 1px 5px; border-radius: 5px; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 13px; }
button, select, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.bar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 18px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.back { font-size: 13px; text-decoration: none; color: var(--muted); white-space: nowrap; }
.brand { display: flex; align-items: center; gap: 9px; font-family: var(--serif); font-size: 19px; }
.logo { display: inline-flex; gap: 2px; align-items: flex-end; height: 20px; }
.logo i { display: block; width: 6px; border-radius: 3px; }
.logo i:nth-child(1) { height: 12px; background: var(--nx); } .logo i:nth-child(2) { height: 20px; background: var(--nr); } .logo i:nth-child(3) { height: 15px; background: var(--nc); }
.session { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.credits { font-size: 13px; color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); cursor: pointer; text-decoration: none; color: var(--ink); font-size: 14px; }
.pill:hover:not(:disabled) { border-color: var(--plum); }
.pill.solid { background: var(--plum); color: var(--plum-ink); border-color: var(--plum); }
.pill.tiny { padding: 3px 10px; font-size: 12.5px; }
.pill:disabled { opacity: 0.5; cursor: default; }

main { max-width: 1120px; margin: 0 auto; padding: 8px 18px 40px; }
.hero { padding: 26px 0 10px; max-width: 780px; }
.kicker { margin: 0; text-transform: uppercase; letter-spacing: 0.14em; font-size: 12px; color: var(--plum); font-weight: 600; }
h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(32px, 6vw, 52px); line-height: 1.05; margin: 8px 0 12px; letter-spacing: -0.01em; }
.lede { font-size: 16.5px; margin: 0 0 16px; color: var(--ink); opacity: 0.92; }
.samples { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.chip { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); cursor: pointer; font-size: 13.5px; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip.red { border-style: dashed; }
.chip.red.on { background: var(--bad); border-color: var(--bad); color: #fff; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 18px 20px; margin: 16px 0; }
h2 { font-family: var(--serif); font-weight: 600; font-size: 22px; margin: 0 0 12px; display: flex; align-items: center; gap: 10px; }
h3 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 16px 0 6px; }
.num { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--soft); font-family: var(--sans); font-size: 14px; color: var(--plum); font-weight: 700; }
.field-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 8px 0; }
.field-row.check { gap: 8px; }
.lab { font-size: 13px; font-weight: 600; color: var(--muted); min-width: 92px; display: inline-block; }
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.segbtn { border: 0; background: transparent; padding: 6px 12px; cursor: pointer; font-size: 14px; border-right: 1px solid var(--line); }
.segbtn:last-child { border-right: 0; }
.segbtn.on { background: var(--plum); color: var(--plum-ink); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
select, input[type="text"], input[type="number"] { padding: 6px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); max-width: 100%; }
textarea { width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); resize: vertical; }
#shelfText { font-family: var(--mono); font-size: 13px; line-height: 1.55; }
.drop { position: relative; }
.drop.over textarea { border-color: var(--plum); background: var(--soft); }
.filebtn { margin-top: 8px; position: relative; overflow: hidden; }
.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.notes { list-style: none; padding: 0; margin: 8px 0 0; font-size: 13px; }
.notes li.warn { color: var(--warn); } .notes li.ok { color: var(--ok); }

.tablewrap { overflow-x: auto; margin-top: 10px; }
table.shelf { width: 100%; border-collapse: collapse; font-size: 14px; }
table.shelf th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); border-bottom: 1px solid var(--line); padding: 6px 8px; }
table.shelf td { border-bottom: 1px solid var(--line); padding: 8px; vertical-align: top; }
table.shelf tr.paused td { opacity: 0.55; }
table.shelf tr.lit td { background: var(--soft); }
.pid { display: inline-block; font-family: var(--mono); font-size: 11.5px; color: var(--muted); margin-right: 6px; }
.rnote { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.fams { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.fam { font-size: 11.5px; padding: 1px 7px; border-radius: 6px; color: #fff; font-weight: 600; }
.fam.f-ret { background: var(--f-ret); } .fam.f-acid { background: var(--f-acid); } .fam.f-bpo { background: var(--f-bpo); } .fam.f-vitc { background: var(--f-vitc); color: #2d2230; }
.fam.f-cu { background: var(--f-cu); } .fam.f-aza { background: var(--f-aza); } .fam.f-nia { background: var(--f-nia); } .fam.f-spf { background: var(--f-spf); color: #2d2230; }
.fam.f-bar { background: var(--f-bar); } .fam.f-none { background: transparent; color: var(--muted); border: 1px dashed var(--line); font-weight: 400; } .fam.f-frag { background: transparent; color: var(--warn); border: 1px solid var(--warn); }
.tag.rx { font-size: 11px; margin-left: 6px; color: var(--bad); border: 1px solid var(--bad); border-radius: 6px; padding: 0 5px; }

/* The week */
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; margin: 6px 0 10px; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.legend .lx::before { background: var(--nx); } .legend .lr::before { background: var(--nr); } .legend .lc::before { background: var(--nc); } .legend .la::before { background: var(--am); }
.grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.day { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.day.lit .dname { color: var(--plum); }
.dname { font-family: var(--serif); font-size: 17px; text-align: center; font-weight: 600; }
.sess { border-radius: 14px; padding: 7px; display: flex; flex-direction: column; gap: 5px; min-height: 120px; border: 1px solid transparent; }
.sess.s-am { background: var(--am-bg); }
.sess.n-x { background: var(--nx-bg); } .sess.n-r { background: var(--nr-bg); } .sess.n-c { background: var(--nc-bg); }
.sess.lit { border-color: var(--plum); box-shadow: 0 0 0 2px var(--plum) inset; }
.shead { display: flex; align-items: center; gap: 6px; }
.sun { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--am); color: #2d2230; font-size: 10.5px; font-weight: 700; }
.night { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; border: 0; color: #fff; font-weight: 800; cursor: pointer; font-size: 14px; }
button.night:hover { filter: brightness(1.1); transform: translateY(-1px); }
.night.n-x { background: var(--nx); } .night.n-r { background: var(--nr); } .night.n-c { background: var(--nc); }
span.night { width: 22px; height: 22px; font-size: 12px; cursor: default; vertical-align: middle; }
.sname { font-size: 11.5px; color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 3px; }
.layer { position: relative; display: flex; align-items: center; gap: 5px; background: var(--card); border-radius: 7px; padding: 3px 6px 3px 9px; font-size: 12px; line-height: 1.25; border-left: 4px solid var(--f-none); cursor: pointer; min-width: 0; }
.layer b { font-family: var(--mono); font-size: 10.5px; color: var(--muted); font-weight: 600; }
.layer .lname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.layer.lit { outline: 2px solid var(--plum); }
.layer.f-ret { border-left-color: var(--f-ret); } .layer.f-acid { border-left-color: var(--f-acid); } .layer.f-bpo { border-left-color: var(--f-bpo); } .layer.f-vitc { border-left-color: var(--f-vitc); }
.layer.f-cu { border-left-color: var(--f-cu); } .layer.f-aza { border-left-color: var(--f-aza); } .layer.f-nia { border-left-color: var(--f-nia); } .layer.f-spf { border-left-color: var(--f-spf); } .layer.f-bar { border-left-color: var(--f-bar); }
.cmark { font-style: normal; font-size: 10px; font-weight: 700; padding: 0 4px; border-radius: 5px; color: #fff; }
.cmark.lv-high { background: var(--bad); } .cmark.lv-medium { background: var(--warn); } .cmark.lv-low { background: var(--muted); }
.stack .none, .grid > .none { font-size: 12px; color: var(--muted); font-style: italic; }
.twocol { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.clist, .flist { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; }
.clist li, .flist li { padding: 7px 10px; border-radius: 10px; background: var(--soft); cursor: pointer; }
.clist li.ok, .flist li.ok { background: var(--ok-bg); color: var(--ok); cursor: default; }
.clist li.lit, .flist li.lit { box-shadow: 0 0 0 2px var(--plum) inset; }
.clist .cid { font-family: var(--mono); font-weight: 700; margin-right: 6px; }
.clist .lvl { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; padding: 0 6px; border-radius: 5px; color: #fff; }
.clist li.lv-high .lvl { background: var(--bad); } .clist li.lv-medium .lvl { background: var(--warn); } .clist li.lv-low .lvl { background: var(--muted); }
.clist .cells { display: block; font-size: 11.5px; color: var(--muted); font-family: var(--mono); margin-top: 2px; }
.flist li.warn { background: var(--warn-bg); color: var(--warn); }
.exports { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
#weekLine .lit { background: var(--soft); border-radius: 6px; }

/* Ask */
.lanes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.lane { text-align: left; border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: 12px 14px; cursor: pointer; display: flex; flex-direction: column; gap: 3px; }
.lane b { font-family: var(--serif); font-size: 17px; }
.lane span { font-size: 13px; color: var(--muted); }
.lane.on { border-color: var(--plum); box-shadow: 0 0 0 2px var(--plum) inset; }
.reaction { border: 1px dashed var(--line); border-radius: 14px; padding: 12px; margin-bottom: 12px; display: flex; flex-direction: column; gap: 6px; }
.redflag { background: var(--bad-bg); color: var(--bad); border-radius: 10px; padding: 9px 12px; font-size: 14px; margin: 4px 0; }
.cands .candlist { list-style: none; padding: 0; margin: 4px 0 0; font-size: 13.5px; }
.cands .candlist li { padding: 3px 0; }
.meter { font-size: 14px; margin: 10px 0 6px; }
.warnline { color: var(--warn); }
.gate { font-size: 14px; background: var(--soft); border-radius: 10px; padding: 9px 12px; }
.go { margin-top: 10px; width: 100%; padding: 13px 18px; border-radius: 14px; border: 0; background: var(--plum); color: var(--plum-ink); font-size: 16px; font-weight: 600; cursor: pointer; }
.go:disabled { opacity: 0.5; cursor: default; }

.progress .steps { list-style: none; padding: 0; margin: 6px 0; font-size: 14px; }
.step { color: var(--muted); } .step.done { color: var(--ok); } .step.active { color: var(--ink); font-weight: 600; }
.step-ic { display: inline-block; width: 14px; font-family: var(--mono); }
.raw { white-space: pre-wrap; font-family: var(--mono); font-size: 12px; max-height: 320px; overflow: auto; }
.partial { background: var(--warn-bg); color: var(--warn); border-radius: 12px; padding: 10px 14px; }

/* Results */
.rhead { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.rhead h2 { margin: 0; }
.stamp { font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; padding: 4px 10px; border-radius: 8px; border: 2px solid currentColor; }
.stamp.v-ready, .stamp.v-adjust { color: var(--ok); } .stamp.v-rebuild, .stamp.v-pause_actives { color: var(--warn); } .stamp.v-see_clinician { color: var(--bad); }
.summary { font-size: 15.5px; }
.calls { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.callrow { border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; }
.chead { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.verdict { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; padding: 2px 8px; border-radius: 6px; background: var(--soft); }
.pv-keep { background: var(--ok-bg); color: var(--ok); } .pv-move { background: var(--nr-bg); color: var(--nr); } .pv-pause { background: var(--warn-bg); color: var(--warn); } .pv-patch_test { background: var(--am-bg); color: var(--am); }
.lk-likely { background: var(--bad-bg); color: var(--bad); } .lk-possible { background: var(--warn-bg); color: var(--warn); } .lk-unlikely { background: var(--ok-bg); color: var(--ok); }
.arrow { font-size: 13px; color: var(--plum); font-weight: 600; }
.why { margin: 6px 0 0; font-size: 14px; }
.cites { display: inline-flex; flex-wrap: wrap; gap: 4px; vertical-align: middle; }
.cite { font-family: var(--mono); font-size: 11px; padding: 1px 6px; border-radius: 6px; border: 1px solid var(--line); background: var(--soft); cursor: pointer; }
.cite.bad { border-color: var(--bad); color: var(--bad); text-decoration: line-through; cursor: default; }
.cite.pausechip { font-family: var(--sans); font-size: 13px; padding: 3px 9px; margin: 0 6px 6px 0; background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
.lines, .plain, .plan, .redlist { padding-left: 20px; margin: 0; font-size: 14px; }
.lines li, .plain li, .plan li, .redlist li { margin: 4px 0; }
.redlist li { color: var(--bad); }
.none { color: var(--muted); font-style: italic; }
.handoff { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.recon { list-style: none; padding: 0; margin: 0; font-size: 14px; display: flex; flex-direction: column; gap: 4px; }
.recon li { padding: 6px 10px; border-radius: 8px; }
.recon li.ok { background: var(--ok-bg); color: var(--ok); } .recon li.warn { background: var(--warn-bg); color: var(--warn); } .recon li.info { background: var(--soft); }
.hlist { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 6px; }
.hrow { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.hinfo { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 50; width: min(92vw, 460px); }
.toast { padding: 10px 14px; border-radius: 12px; background: var(--ink); color: var(--bg); font-size: 14px; transition: opacity 0.5s; }
.toast.err { background: var(--bad); color: #fff; } .toast a { color: inherit; font-weight: 700; }
.toast.gone { opacity: 0; }
.foot { max-width: 1120px; margin: 0 auto; padding: 10px 18px 40px; font-size: 13px; color: var(--muted); }
.sheet { display: none; }

/* Docs pages */
.doc { max-width: 860px; }
.statebox { border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; background: var(--card); }
.tokenrow { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.tokenbox { font-family: var(--mono); font-size: 13px; padding: 10px 12px; border-radius: 10px; background: var(--soft); word-break: break-all; flex: 1; }
.mono { font-family: var(--mono); }
.doc pre { background: var(--soft); border-radius: 12px; padding: 12px 14px; overflow-x: auto; font-size: 12.5px; }
.codegroup { margin: 10px 0 16px; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.tab { padding: 4px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); cursor: pointer; font-size: 12.5px; }
.tab.active { background: var(--plum); color: var(--plum-ink); border-color: var(--plum); }
.doc table { border-collapse: collapse; width: 100%; font-size: 14px; display: block; overflow-x: auto; }
.doc th, .doc td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }

/* Phones: the week becomes a list of day rows, AM beside PM. */
@media (max-width: 860px) {
  .grid { grid-template-columns: 1fr; gap: 10px; }
  .day { display: grid; grid-template-columns: 36px minmax(0, 1fr) minmax(0, 1fr); gap: 6px; align-items: stretch; }
  .dname { writing-mode: vertical-rl; transform: rotate(180deg); text-align: center; font-size: 16px; align-self: center; }
  .sess { min-height: 0; }
  .twocol { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  main { padding: 6px 12px 32px; }
  .bar { padding: 8px 12px; gap: 8px; }
  .back { display: none; }
  .card { padding: 14px; border-radius: 16px; }
  .lanes { grid-template-columns: 1fr; }
  .lab { min-width: 0; width: 100%; }
  table.shelf thead { display: none; }
  table.shelf, table.shelf tbody, table.shelf tr, table.shelf td { display: block; width: 100%; }
  table.shelf tr { border-bottom: 1px solid var(--line); padding: 8px 0; }
  table.shelf td { border: 0; padding: 3px 0; }
  table.shelf td:nth-child(2)::before { content: "Layer: "; color: var(--muted); }
  table.shelf td:nth-child(5)::before { content: "New "; color: var(--muted); }
  .segbtn { padding: 6px 10px; font-size: 13.5px; }
}
@media print {
  body * { visibility: hidden; }
  .sheet, .sheet * { visibility: visible; }
  .sheet { display: block; position: absolute; inset: 0; padding: 20px; color: #000; background: #fff; font: 13px/1.4 var(--sans); }
  .sheet table { width: 100%; border-collapse: collapse; }
  .sheet th, .sheet td { border: 1px solid #999; padding: 6px; text-align: left; vertical-align: top; }
}
