:root {
  --bg: #f6f5f0;
  --surface: #ffffff;
  --surface-2: #fbfaf7;
  --ink: #1c2220;
  --muted: #646d69;
  --line: #e2dfd5;
  --line-soft: #efede6;
  --past: #f3f2ee;
  --accent: #1d6a85;
  --accent-ink: #ffffff;
  --accent-soft: rgba(29, 106, 133, 0.13);
  --approved: #2e7a57;
  --approved-bg: #dcefe4;
  --approved-ink: #163d2b;
  --approved-btn-ink: #ffffff;
  --req: #8b908d;
  --req-bg: #e9e8e2;
  --req-ink: #383d3b;
  --warn: #b5402b;
  --warn-soft: #fbe9e4;
  --now: #d1462e;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 10px 28px rgba(0, 0, 0, 0.1);
  --row: 24px;
  --gutter: 52px;
  --r: 10px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --sheet-h: 48vh;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111513;
    --surface: #191e1c;
    --surface-2: #151a18;
    --ink: #e6eae7;
    --muted: #9aa39f;
    --line: #2d3431;
    --line-soft: #222927;
    --past: #171c1a;
    --accent: #62b4d1;
    --accent-ink: #0a1a20;
    --accent-soft: rgba(98, 180, 209, 0.16);
    --approved: #5cc28f;
    --approved-bg: #1c3a2b;
    --approved-ink: #d5f1e1;
    --approved-btn-ink: #0c1e15;
    --req: #7f8884;
    --req-bg: #262c29;
    --req-ink: #d3d8d5;
    --warn: #ff8b74;
    --warn-soft: #3b211b;
    --now: #ff6a50;
    --shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--sans); }
.muted { color: var(--muted); }

/* ---------- header ---------- */
.top {
  max-width: 1280px; margin: 0 auto; padding: 28px 20px 14px;
  display: flex; gap: 20px; justify-content: space-between; align-items: flex-end; flex-wrap: wrap;
}
.eyebrow { margin: 0 0 4px; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
h1 { font-family: var(--serif); font-weight: 600; font-size: 32px; line-height: 1.1; margin: 0 0 6px; letter-spacing: -0.01em; }
.lede { margin: 0; color: var(--muted); max-width: 58ch; }
.notice {
  margin: 6px 0 8px; max-width: 58ch; padding: 9px 12px; color: var(--ink);
  background: var(--accent-soft); border-left: 3px solid var(--accent); border-radius: 6px;
}
.banner {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 10px 14px; min-width: 280px; max-width: 440px; font-size: 14px;
}
.b-line { display: flex; gap: 8px; align-items: baseline; }
.b-line + .b-line { margin-top: 4px; }
.b-label { flex: 0 0 38px; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.b-label.live { color: var(--now); font-weight: 700; }

.adminbar { max-width: 1280px; margin: 0 auto 10px; padding: 0 20px; }
.adminbar > div { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); padding: 8px 12px; font-size: 14px; }
.adminbar a { color: var(--accent); }
.adminbar .bad { border-color: var(--warn); color: var(--warn); }

.legend { max-width: 1280px; margin: 0 auto 10px; padding: 0 20px; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; gap: 6px; align-items: center; }
.sw { width: 16px; height: 10px; border-radius: 2px; display: inline-block; border: 1px solid var(--line); }
.sw-approved { background: var(--approved-bg); border-color: var(--approved); border-left-width: 3px; }
.sw-requested { background: repeating-linear-gradient(135deg, var(--req-bg) 0 3px, var(--surface) 3px 6px); border: 1px dashed var(--req); }
.sw-overlap { background: var(--surface); border: 2px solid var(--warn); }
.sw-now { height: 0; border: 0; border-top: 2px solid var(--now); border-radius: 0; }

/* ---------- layout ---------- */
.layout {
  max-width: 1280px; margin: 0 auto; padding: 0 20px 48px;
  display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start;
}
.tabs { display: none; }

/* ---------- board ---------- */
.board {
  display: grid; grid-template-columns: var(--gutter) repeat(var(--days, 3), minmax(0, 1fr));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  overflow: clip; user-select: none; -webkit-user-select: none;
}
.day { border-left: 1px solid var(--line); min-width: 0; }
.day-head {
  position: sticky; top: 0; z-index: 6; height: 46px;
  display: flex; align-items: baseline; gap: 7px; padding: 13px 10px 0;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.day-head .dow { font-family: var(--serif); font-size: 18px; font-weight: 600; }
.day-head .md { color: var(--muted); font-size: 13px; }
.day.today .day-head .dow::after { content: " · today"; font-family: var(--sans); font-size: 12px; font-weight: 500; color: var(--now); }
.day-body, .gutter-body { position: relative; }

.slot { height: var(--row); border-top: 1px solid var(--line-soft); }
.slot.hour { border-top-color: var(--line); }
.slot.past { background: repeating-linear-gradient(135deg, var(--past) 0 5px, var(--surface-2) 5px 10px); }
.slot:not(.off) { cursor: pointer; touch-action: pan-y; }
@media (hover: hover) { .slot:not(.off):hover { background: var(--accent-soft); } }

.glabel {
  height: var(--row); font-size: 11px; color: var(--muted); text-align: right; padding-right: 8px;
  transform: translateY(-8px); font-variant-numeric: tabular-nums; white-space: nowrap;
}

.layer { position: absolute; inset: 0; pointer-events: none; }
.blk, .ghost { position: absolute; left: 4px; right: 4px; pointer-events: auto; border-radius: 6px; overflow: hidden; }
.blk {
  display: flex; flex-direction: column; justify-content: flex-start;
  padding: 2px 7px; border: 1px solid; font: inherit; font-size: 12px; line-height: 16px;
  text-align: left; cursor: pointer; color: inherit; z-index: 2;
}
.blk.approved { background: var(--approved-bg); border-color: var(--approved); border-left-width: 4px; color: var(--approved-ink); }
.blk.requested {
  background: repeating-linear-gradient(135deg, var(--req-bg) 0 6px, var(--surface) 6px 12px);
  border-color: var(--req); border-style: dashed; color: var(--req-ink);
}
.blk.declined { background: var(--surface-2); border-color: var(--line); color: var(--muted); opacity: 0.8; }
.blk.declined .blk-pond { text-decoration: line-through; }
.blk.overlap { box-shadow: 0 0 0 2px var(--warn); z-index: 3; }
.blk.cont-top { border-top-left-radius: 0; border-top-right-radius: 0; border-top-style: dotted; }
.blk.cont-bot { border-bottom-left-radius: 0; border-bottom-right-radius: 0; border-bottom-style: dotted; }
.blk:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.blk-top { display: flex; gap: 6px; justify-content: space-between; align-items: baseline; min-width: 0; }
.blk-pond { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.blk-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0.85; }
.blk.tiny { justify-content: center; padding-top: 0; padding-bottom: 0; }
.blk.tiny .blk-sub { display: none; }
.chip { flex: none; font-size: 10px; line-height: 16px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; opacity: 0.85; }
.chip.approved { color: var(--approved); }
.chip.requested { color: var(--muted); }
.chip.declined { color: var(--warn); }

.ghost {
  background: var(--accent-soft); border: 2px solid var(--accent); color: var(--ink);
  z-index: 4; cursor: grab; touch-action: none; padding: 1px 7px;
  font-size: 12px; line-height: 18px; font-weight: 650; box-shadow: var(--shadow);
}
.ghost:active { cursor: grabbing; }
.ghost.overlap { border-color: var(--warn); background: var(--warn-soft); }
.ghost.cont-top { border-top-style: dotted; border-top-left-radius: 0; border-top-right-radius: 0; }
.ghost.cont-bot { border-bottom-style: dotted; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.ghost-label { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ghost-handle {
  position: absolute; left: 0; right: 0; bottom: 0; height: 16px; cursor: ns-resize;
  display: grid; place-items: center;
}
.ghost-handle::before { content: ""; width: 30px; height: 4px; border-radius: 2px; background: var(--accent); }

.now-line { position: absolute; left: 0; right: 0; height: 0; border-top: 2px solid var(--now); z-index: 5; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -1px; top: -5px; width: 8px; height: 8px; border-radius: 50%; background: var(--now); }

/* ---------- panel ---------- */
.panel {
  position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 16px 18px;
}
.view h2 { font-family: var(--serif); font-size: 21px; margin: 0 0 8px; font-weight: 600; line-height: 1.2; }
.view h3 { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 18px 0 8px; font-weight: 600; }
.view-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.x { border: 0; background: transparent; font-size: 24px; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; margin: -2px -4px 0 0; }
.when { font-weight: 600; margin: 0 0 2px; font-variant-numeric: tabular-nums; }
.status-line { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.steps { padding-left: 18px; margin: 0 0 14px; color: var(--muted); font-size: 14px; }
.steps li { margin: 4px 0; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 0; }
.opt { font-size: 12px; opacity: 0.85; }
input, select, textarea {
  display: block; width: 100%; margin-top: 4px; font: inherit; font-size: 16px; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.grid2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 10px; }
fieldset.gate { border: 0; padding: 0; margin: 12px 0 0; }
legend { font-size: 13px; color: var(--muted); padding: 0; }
.radio { display: flex; gap: 8px; align-items: center; color: var(--ink); font-size: 15px; margin: 6px 0 0; cursor: pointer; }
.radio input { width: auto; margin: 0; accent-color: var(--accent); }
.gate.invalid legend { color: var(--warn); }
.gate[disabled] .radio { cursor: default; }
/* Locked choice: draw it as clearly selected instead of the browser's faint disabled grey. */
.gate[disabled] .radio input {
  appearance: none; flex: 0 0 auto; width: 16px; height: 16px; padding: 0; border-radius: 50%;
  border: 2px solid var(--accent); background: radial-gradient(circle, var(--accent) 0 3.5px, transparent 4px);
}
.btn {
  font: inherit; font-size: 14px; font-weight: 600; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); padding: 9px 14px; border-radius: 6px; cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.approve { background: var(--approved); color: var(--approved-btn-ink); border-color: var(--approved); }
.btn.danger { color: var(--warn); }
.btn.sm { font-size: 12px; padding: 4px 9px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: default; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.admin-actions { padding-top: 12px; border-top: 1px solid var(--line); }
.warn { background: var(--warn-soft); color: var(--warn); border-radius: 6px; padding: 8px 10px; font-size: 13px; margin: 10px 0 0; }
.error { color: var(--warn); font-size: 13px; margin: 10px 0 0; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }

.rows { list-style: none; padding: 0; margin: 0; }
.row {
  width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 0 8px; text-align: left;
  font: inherit; color: inherit; background: none; border: 0; border-top: 1px solid var(--line-soft);
  padding: 8px 2px; cursor: pointer;
}
.rows li:first-child .row { border-top: 0; }
.row-main { font-weight: 600; }
.row-sub { grid-column: 1; font-size: 13px; color: var(--muted); }
.row .chip { grid-row: 1 / span 2; grid-column: 2; align-self: center; }

.facts { margin: 10px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

/* admin */
.admin { border-top: 1px solid var(--line); margin-top: 18px; }
.admin h3 { margin-top: 14px; }
.admin-summary { margin: 0; font-size: 14px; }
.warnings { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 6px; }
.warnings li { font-size: 13px; padding: 6px 9px; border-radius: 6px; background: var(--warn-soft); color: var(--warn); }
.warnings li.ok { background: var(--approved-bg); color: var(--approved-ink); }
.acards { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 8px; }
.acard { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.acard.approved { border-left: 4px solid var(--approved); }
.acard.requested { border-left: 4px dashed var(--req); }
.acard.declined { opacity: 0.65; }
.acard-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.acard-pond { font-weight: 650; font-size: 14px; }
.acard-meta { color: var(--muted); margin-top: 2px; }
.acard-meta a { color: var(--accent); }
.acard .actions { margin-top: 8px; gap: 6px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 8px; font-size: 14px;
  box-shadow: var(--shadow); max-width: calc(100vw - 32px);
}
.toast.err { background: var(--warn); color: #fff; }

/* ---------- phones ---------- */
@media (max-width: 899px) {
  .top { padding: 18px 16px 10px; gap: 12px; }
  h1 { font-size: 25px; }
  .lede { font-size: 14px; }
  .banner { max-width: none; width: 100%; min-width: 0; }
  .top-text { width: 100%; }
  /* "Request a fill" moved under the intro text by app.js */
  .top-text .request-card {
    margin-top: 12px; background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--r); padding: 14px 16px 16px;
  }
  .legend, .adminbar { padding: 0 16px; }
  .layout { grid-template-columns: minmax(0, 1fr); padding: 0 16px 28px; gap: 12px; }
  .panel { position: static; max-height: none; order: -1; }
  .panel.sheet {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; max-height: var(--sheet-h); z-index: 40;
    border-radius: 16px 16px 0 0; border-bottom: 0; box-shadow: var(--shadow);
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
  }
  body.sheet-open { padding-bottom: var(--sheet-h); }
  body.sheet-open .toast { bottom: calc(var(--sheet-h) + 12px); }
  .tabs {
    display: flex; position: sticky; top: 0; z-index: 20; gap: 6px; padding: 8px 16px;
    background: var(--bg); border-bottom: 1px solid var(--line); overflow-x: auto;
  }
  .tab {
    flex: 1 0 auto; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
    border-radius: 999px; padding: 7px 14px; font: inherit; font-size: 14px; font-weight: 600;
    display: flex; gap: 6px; align-items: baseline; justify-content: center; cursor: pointer;
  }
  .tab-md { font-weight: 400; opacity: 0.7; font-size: 12px; }
  .tab.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
  .board { grid-template-columns: var(--gutter) minmax(0, 1fr); }
  .day:not(.active) { display: none; }
  .day-head, .gutter-head { display: none; }
}
