/* endoscopy v3: the calendar.
   Reader: an older, non-technical center manager opening a forwarded link alone.
   The opening screen is a plain month grid; everything else shows up only when clicked.
   Light only (the warm ground carries the mesindev match). Nothing moves unless she taps.
   Every action is a worded control at least 52px tall. No coloured left rules, anywhere.
   Ember is spent once: the mark for a block that has booked cases and no CRNA. */

:root {
  color-scheme: light;
  --sev-1: var(--sev-kosong);  --sev-1-text: var(--sev-kosong-text);
  --tap: 52px;
  --r-control: 5px;   /* buttons, cells, slots */
  --r-panel: 8px;     /* revealed day, editors */
  --r-case: 4px;      /* case boxes in the day grid */
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.5;
}
a { color: inherit; }
p { margin: 0; }
button { font: inherit; color: inherit; }

.wrap { max-width: 1120px; margin-inline: auto; padding-inline: 20px; }
/* A short view (the phone week) never pulls the footer into the first screen. */
.app { min-height: calc(100svh - 61px); }

/* ---- Top ---- */
.top { border-bottom: 1px solid var(--border); }
.top__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; }
.lockup { display: inline-flex; align-items: baseline; gap: 3px; color: var(--ink); text-decoration: none; padding-block: 8px; }
.lockup__word { font-family: var(--font-mark); font-size: 24px; letter-spacing: -0.03em; line-height: 1; }
.lockup__cursor { display: block; width: 9px; height: 3px; background: var(--accent); }
.demo-tag { font-size: 15px; color: var(--muted); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 10px 18px;
  font-weight: 700; text-decoration: none; text-align: center; line-height: 1.2;
  border-radius: var(--r-control); border: 1px solid transparent; cursor: pointer;
}
button:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn--primary { background: var(--ink); color: var(--paper); }
.btn--secondary { background: var(--surface); color: var(--ink); border-color: var(--border-strong); }
.btn--quiet { background: transparent; color: var(--ink-2); text-decoration: underline; text-underline-offset: 4px; font-weight: 600; padding-inline: 10px; }
.btn--nav { background: var(--surface); border-color: var(--border-strong); font-weight: 600; padding-inline: 12px; white-space: nowrap; }
.btn--option { background: var(--surface); color: var(--ink); border-color: var(--border-strong); font-weight: 600; padding-inline: 14px; }
.btn--option.is-on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.opt__note { font-weight: 400; }
@media (hover: hover) {
  .btn--primary:hover { background: var(--ink-2); }
  .btn--secondary:hover, .btn--nav:hover, .btn--option:not(.is-on):hover { border-color: var(--n-500); }
  .cell:not(.cell--pad):hover, .slot:hover, .case:hover, .band:hover { border-color: var(--n-500); }
  .wk__day:hover .wk__dayname { text-decoration-thickness: 2px; }
}

/* ---- The bar: previous / title / next, and the Month | Week switch ---- */
.bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; padding-block: 18px 16px; }
.bar__nav { display: flex; align-items: center; gap: 8px; flex: 1 1 100%; min-width: 0; }
.bar__title { flex: 1; min-width: 0; margin: 0; text-align: center; font-size: 20px; line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; }
.t-long { display: none; }
.seg { display: flex; flex: 1 1 100%; padding: 3px; gap: 3px; background: var(--n-100); border: 1px solid var(--border-strong); border-radius: var(--r-panel); }
.seg__btn { flex: 1; min-height: var(--tap); padding: 8px 20px; border: 0; border-radius: var(--r-control); background: transparent; font-weight: 700; color: var(--ink-2); cursor: pointer; }
.seg__btn[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

@media (min-width: 720px) {
  .wrap { padding-inline: 32px; }
  .bar { padding-block: 20px 16px; }
  .bar__nav { flex: 0 1 auto; gap: 12px; }
  .bar__title { flex: 0 1 auto; font-size: 30px; min-width: 12ch; }
  .seg { flex: 0 0 auto; }
  .t-long { display: inline; }
  .t-short { display: none; }
}

/* ---- Month: the opening screen ---- */
.month { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.month__wd { padding: 0 4px 2px; font-size: 14px; font-weight: 600; color: var(--muted); }
.wd-long { display: none; }
.cell {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  min-height: 84px; padding: 6px 6px 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-control);
  text-align: left; cursor: pointer;
}
.cell--pad { background: transparent; border-color: transparent; cursor: default; }
.cell--past { background: var(--surface-2); color: var(--muted); }
.cell__n { font-size: 15px; font-weight: 700; line-height: 1.2; }
.cell--today .cell__n {
  display: inline-grid; place-items: center; min-width: 26px; height: 26px; margin: -3px 0 0 -3px;
  padding-inline: 4px; border-radius: 999px; background: var(--ink); color: var(--paper);
}
.cell__count { order: 2; margin-top: auto; font-size: 18px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.cell__count b { font-weight: 700; }
.cell__unit { display: none; }
.cell__mark { position: absolute; top: 9px; right: 7px; display: flex; align-items: center; gap: 6px; color: var(--sev-1-text); font-size: 14px; font-weight: 700; line-height: 1.2; }
.cell__markword { display: none; }
.cell__mark { order: 1; }
.cell.is-sel { border-color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }
.dot { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--sev-1); }
.key { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 15px; color: var(--ink); }

@media (min-width: 720px) {
  .month { gap: 6px; }
  .wd-long { display: inline; }
  .wd-short { display: none; }
  .cell { min-height: 104px; padding: 10px 12px; gap: 4px; }
  .cell__n { font-size: 17px; }
  .cell__count { font-size: 20px; }
  .cell__unit { display: inline; font-size: 16px; font-weight: 400; color: var(--ink-2); }
  .cell--past .cell__unit { color: var(--muted); }
  .cell__mark { position: static; }
  .cell__markword { display: inline; }
  .key { display: none; }
}

/* ---- A day revealed under its week row ---- */
.reveal {
  position: relative; grid-column: 1 / -1;
  padding: 16px 14px 18px; margin-block: 8px 6px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-panel);
  box-shadow: var(--elev-2);
}
/* The notch points at the day she tapped. Two stacked triangles, no borders. */
.reveal--month::before, .reveal--month::after {
  content: ""; position: absolute; left: calc((var(--col) + 0.5) * 20% - 10px);
  width: 20px; height: 10px; clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
.reveal--month::before { top: -10px; background: var(--border-strong); }
.reveal--month::after { top: -9px; background: var(--surface); }
.reveal__head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 10px 16px; }
.reveal__title { margin: 0; font-size: 21px; line-height: 1.25; font-weight: 700; }
.reveal__meta { margin-top: 2px; color: var(--ink-2); font-size: 16px; }
.reveal__acts { display: flex; flex-wrap: wrap; gap: 8px; }
.rooms { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }
.room, .edit-host { order: var(--o); }
.room__h { margin: 0; font-size: 15px; font-weight: 700; color: var(--ink-2); }
/* ---- Week, phone: one row per day, the day reveal opens under its row ---- */
.wkrows { display: grid; gap: 6px; }
.wkrow {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: var(--tap); padding: 8px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-control); text-align: left; cursor: pointer;
}
.wkrow--past { background: var(--surface-2); color: var(--muted); }
.wkrow.is-sel { border-color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }
.wkrow__d { font-weight: 700; white-space: nowrap; }
.wkrow__today { font-weight: 400; color: var(--muted); }
.wkrow__mark { display: flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 700; color: var(--sev-1-text); white-space: nowrap; }
.wkrow__n { margin-left: auto; font-variant-numeric: tabular-nums; white-space: nowrap; }
.wkrows .reveal { margin-block: 2px 8px; box-shadow: var(--elev-1); }

@media (min-width: 900px) {
  .reveal { padding: 20px 22px 22px; }
  .rooms { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px 14px; }
  .room--staff { grid-column: 1 / -1; }
  .room--staff .slot { max-width: 560px; }
  .edit-host { grid-column: 1 / -1; order: 9; }
  .edit-host--staff { order: 11; }
}

/* ---- Slots: one room, one half day ---- */
.slot {
  position: relative; display: flex; flex-direction: column; align-items: flex-start;
  width: 100%; min-height: var(--tap); margin-top: 6px; padding: 8px 12px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-control);
  font-size: 16px; line-height: 1.3; text-align: left; cursor: pointer;
}
.rooms .slot, .day-list .slot { padding-left: 50px; }
.rooms .slot--staff { padding-left: 12px; }
.slot__half { position: absolute; left: 12px; top: 9px; font-size: 14px; font-weight: 700; color: var(--muted); }
.slot__doc { font-weight: 700; }
.slot__crna { color: var(--ink-2); }
.slot__crna.is-warm, .band__crna.is-warm { color: var(--sev-1-text); font-weight: 700; }
.slot__n { color: var(--muted); font-size: 15px; }
.slot__open { color: var(--muted); font-weight: 600; }
.slot--open { background: transparent; border-style: dashed; }
.slot--past:not(.slot--open) { background: var(--surface-2); }
.slot.is-on { border-color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }

/* ---- Editors ---- */
.editor { padding: 14px 14px 16px; background: var(--n-50); border: 1px solid var(--border-strong); border-radius: var(--r-panel); }
.inline-edit { margin-top: 6px; }
.editor__h { font-size: 19px; line-height: 1.3; font-weight: 700; }
.editor__fact { margin-top: 2px; font-size: 16px; color: var(--ink-2); }
.undo {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2px 12px;
  margin-top: 10px; padding: 2px 4px 2px 14px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-control);
  font-size: 16px; font-weight: 600;
}
.bar + .undo { margin: 0 0 14px; }
.field { margin-top: 14px; }
.field__label { margin-bottom: 6px; font-size: 15px; font-weight: 700; color: var(--ink-2); }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opts + .opts { margin-top: 8px; }
.editor__acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
@media (min-width: 900px) { .editor { padding: 18px 20px 20px; } }

/* ---- Week, wide: rooms by weekday. Norm cells are bare text on the page ground (no tile, no border);
   Open is dashed; No CRNA is warm; the tapped cell keeps its ring. Columns hold by alignment and gap. ---- */
.wk { display: grid; grid-template-columns: 112px repeat(5, minmax(0, 1fr)); column-gap: 6px; row-gap: 2px; }
.wk__day {
  display: flex; flex-direction: column; justify-content: center; align-items: flex-start; min-height: var(--tap); padding: 2px 10px;
  background: transparent; border: 0; border-radius: var(--r-control); text-align: left; cursor: pointer;
}
.wk__dayname { font-size: 17px; line-height: 1.2; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.wk__day.is-today .wk__dayname { text-decoration-thickness: 3px; }
.wk__daycount { margin-top: 3px; font-size: 14px; line-height: 1.3; color: var(--muted); }
.wk__rule { grid-column: 1 / -1; height: 1px; margin-block: 3px; background: var(--border); }
.wkl { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-height: var(--tap); padding-right: 8px; font-size: 15px; color: var(--ink-2); }
.wkl b { color: var(--ink); }
.wkl--staff { flex-direction: column; align-items: flex-start; justify-content: center; gap: 0; line-height: 1.2; }
.wkl--staff span { font-size: 13px; color: var(--muted); }
.wkc {
  display: flex; flex-direction: column; justify-content: center; align-items: flex-start; min-width: 0; width: 100%;
  min-height: var(--tap); padding: 4px 10px;
  background: transparent; border: 1px solid transparent; border-radius: var(--r-control);
  font-size: 15px; line-height: 1.25; font-weight: 400; text-align: left; cursor: pointer;
}
.wkc__doc { color: var(--ink); }
.wkc__crna { color: var(--ink-2); }
.wkc__crna.is-warm { color: var(--sev-1-text); font-weight: 700; }
.wkc--open { background: transparent; border: 1px dashed var(--n-400); }
.wkc__open { color: var(--muted); font-weight: 600; }
.wkc--past .wkc__doc, .wkc--past .wkc__crna { color: var(--muted); }
.wkc--staff { font-variant-numeric: tabular-nums; }
.wkc.is-on { border-color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }
@media (hover: hover) { .wkc:not(.is-on):hover { border-color: var(--n-500); } }
.wk__edit { grid-column: 1 / -1; margin-block: 8px; }

/* ---- Day, wide: rooms side by side, time down ---- */
.dhead { display: grid; grid-template-columns: 64px repeat(4, minmax(0, 1fr)); column-gap: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.dhead__room { font-size: 15px; color: var(--ink-2); }
.dhead__room b { margin-right: 6px; font-size: 18px; color: var(--ink); }
.dgrid {
  position: relative; display: grid; grid-template-columns: 64px repeat(4, minmax(0, 1fr)); column-gap: 8px; margin-top: 8px;
  background: repeating-linear-gradient(to bottom, var(--border) 0 1px, transparent 1px 104px);
}
.dtimes { position: relative; }
.dtimes span { position: absolute; left: 0; padding-top: 2px; font-size: 13px; color: var(--muted); }
.dcol { position: relative; }
.dblock { position: absolute; left: 0; right: 0; background: var(--n-100); border-radius: var(--r-control); }
.band {
  position: absolute; left: 0; right: 0; height: var(--tap); display: flex; flex-direction: column; justify-content: center;
  padding: 2px 10px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-control);
  font-size: 14px; line-height: 1.2; text-align: left; cursor: pointer; overflow: hidden;
}
.band__doc { font-weight: 700; }
.band__crna { color: var(--ink-2); }
.band--open { background: transparent; border-style: dashed; color: var(--muted); }
.band.is-on { border-color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }
/* The editor docks beside the grid while open: it covers no case and no band. */
.dwrap.has-dock { display: grid; grid-template-columns: minmax(0, 1fr) 340px; column-gap: 16px; align-items: start; }
.dwrap.has-dock .dhead, .dwrap.has-dock .dgrid { grid-template-columns: 52px repeat(4, minmax(0, 1fr)); column-gap: 6px; }
.dwrap.has-dock .dhead__room { font-size: 14px; }
.dwrap.has-dock .editor { padding: 16px 16px 18px; }
.dmain { min-width: 0; }
.dock { position: sticky; top: 16px; overflow-y: auto; overscroll-behavior: contain; border-radius: var(--r-panel); }
.dock .editor { background: var(--surface); box-shadow: var(--elev-1); }

/* ---- Cases ---- */
.case {
  display: grid; grid-template-columns: 5.4em minmax(0, 1fr); column-gap: 8px; align-items: baseline;
  width: 100%; min-height: var(--tap); margin-top: 4px; padding: 8px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-case);
  font-size: 16px; line-height: 1.3; text-align: left; cursor: pointer;
}
.case > span:not(.case__time) { grid-column: 2; }
.case__time { grid-row: 1 / span 4; font-weight: 700; font-variant-numeric: tabular-nums; }
.case__name { font-weight: 600; }
.case__proc { color: var(--ink-2); }
.case__mark { font-weight: 700; }
.case.is-cancelled { background: transparent; border-style: dashed; }
.case.is-cancelled .case__name { text-decoration: line-through; color: var(--muted); }
.case.is-on { border-color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }
.case--abs {
  position: absolute; left: 4px; right: 4px; min-height: 0; margin: 0; padding: 2px 8px;
  display: flex; flex-wrap: wrap; align-content: flex-start; column-gap: 6px;
  font-size: 14px; line-height: 1.3; border-color: var(--border-strong);
}
.case--abs .case__mark::before { content: "· "; font-weight: 400; }
.case--short .case__proc { display: none; }
.day-list { display: grid; gap: 28px; }
.droom__h { margin: 0; font-size: 21px; font-weight: 700; }
.droom__h span { font-size: 16px; font-weight: 400; color: var(--muted); margin-left: 4px; }
.day-list .slot { margin-top: 12px; background: var(--n-100); }
.day-list .slot--open { background: transparent; }

/* ---- Foot ---- */
.foot { display: grid; gap: 8px; justify-items: start; margin-top: 80px; padding-block: 20px 48px; border-top: 1px solid var(--border); }
.intro { font-size: 17px; color: var(--ink-2); }
.intro__link { display: inline-block; padding-block: 12px; color: var(--ink); font-weight: 700; text-underline-offset: 3px; }
.foot__note { font-size: 16px; color: var(--muted); }
.foot .btn--quiet { margin-left: -10px; }
