/* ============================================================
   Hillside Staff Schedule — styles
   Layout: one phone-width column (max 560px), sticky top bar,
   admin bottom tab bar, bottom sheets for editing.
   Color roles: Preschool = warm amber, Elementary = cool blue,
   Covering (cross-coverage) = plum, the only solid fill in the
   teacher view. Words and icons always accompany color.
   ============================================================ */
:root {
  --bg: #f5f4fb;
  --surface: #ffffff;
  --surface-2: #f0eff8;
  --surface-3: #e4e2f3;
  --fg: #1e1b3a;
  --fg-muted: #5f5c7a;
  --fg-faint: #6a6786;
  --line: #e7e5f2;
  --line-strong: #cfcce3;
  --control-border: #8f8ba9;
  --accent: #5b3df5;
  --accent-fg: #ffffff;
  --accent-soft: #ebe7fe;
  --accent-ink: #4328c9;
  --pre: #8a4b00;
  --pre-soft: #fff0d6;
  --pre-rail: #f59e0b;
  --el: #1d4ed8;
  --el-soft: #e3ecff;
  --el-rail: #3b82f6;
  --cross: #9d174d;
  --cross-soft: #fde7f1;
  --cross-rail: #ec4899;
  --cross-solid: #be185d;
  --cross-solid-fg: #ffffff;
  --warn: #92400e;
  --warn-soft: #fff4e0;
  --warn-rail: #f59e0b;
  --ok: #047857;
  --ok-soft: #dcf7ea;
  --draft: #5f5c7a;
  --draft-soft: #f0eff8;
  --focus: #5b3df5;
  --shadow: 0 16px 40px rgba(30, 27, 58, 0.16);
  --shadow-sm: 0 2px 10px rgba(30, 27, 58, 0.06);
  --scrim: rgba(30, 27, 58, 0.45);
  --font-display: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --radius: 16px;
  --radius-lg: 20px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14122a; --surface: #1e1b38; --surface-2: #28254a; --surface-3: #353160;
    --fg: #f1f0fa; --fg-muted: #b3b0cc; --fg-faint: #9b98b8; --line: #343157; --line-strong: #4b4876; --control-border: #7c799c;
    --accent: #a593ff; --accent-fg: #14122a; --accent-soft: #2b2457; --accent-ink: #c4b8ff;
    --pre: #ffd08a; --pre-soft: #3d2a0f; --pre-rail: #f5b14a;
    --el: #b4c8ff; --el-soft: #1c2a52; --el-rail: #6b98f0;
    --cross: #ffb3d4; --cross-soft: #42203a; --cross-rail: #f06ab0; --cross-solid: #8c1d55; --cross-solid-fg: #ffe3f0;
    --warn: #ffd08a; --warn-soft: #3d2e12; --warn-rail: #e0a23a;
    --ok: #6fe0b0; --ok-soft: #173a2c;
    --draft: #b3b0cc; --draft-soft: #28254a;
    --focus: #c4b8ff;
    --shadow: 0 16px 40px rgba(0, 0, 0, 0.5); --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.35);
    --scrim: rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #14122a; --surface: #1e1b38; --surface-2: #28254a; --surface-3: #353160;
    --fg: #f1f0fa; --fg-muted: #b3b0cc; --fg-faint: #9b98b8; --line: #343157; --line-strong: #4b4876; --control-border: #7c799c;
    --accent: #a593ff; --accent-fg: #14122a; --accent-soft: #2b2457; --accent-ink: #c4b8ff;
    --pre: #ffd08a; --pre-soft: #3d2a0f; --pre-rail: #f5b14a;
    --el: #b4c8ff; --el-soft: #1c2a52; --el-rail: #6b98f0;
    --cross: #ffb3d4; --cross-soft: #42203a; --cross-rail: #f06ab0; --cross-solid: #8c1d55; --cross-solid-fg: #ffe3f0;
    --warn: #ffd08a; --warn-soft: #3d2e12; --warn-rail: #e0a23a;
    --ok: #6fe0b0; --ok-soft: #173a2c;
    --draft: #b3b0cc; --draft-soft: #28254a;
    --focus: #c4b8ff;
    --shadow: 0 16px 40px rgba(0, 0, 0, 0.5); --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.35);
    --scrim: rgba(0, 0, 0, 0.6);
    color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100%;
  background: var(--bg); color: var(--fg);
  font-family: var(--font-body); font-size: 16px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; line-height: 1.2; text-wrap: balance; letter-spacing: -0.01em; }
p, blockquote, ul { margin: 0; }
ul { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-ink); }
svg { width: 1em; height: 1em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
h1[tabindex="-1"]:focus, h1[tabindex="-1"]:focus-visible { outline: none; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--fg-muted); }
.small { font-size: 15px; }
.warn-text { color: var(--warn); }
.ok-text { color: var(--ok); font-weight: 700; }
.cross-text { color: var(--cross); font-weight: 700; display: inline-flex; gap: 6px; align-items: flex-start; }
.cross-text svg { flex: none; margin-top: 3px; }
.details-summary { cursor: pointer; font-family: var(--font-display); font-weight: 700; min-height: 44px; display: flex; align-items: center; }
.details-summary::-webkit-details-marker { display: none; }
.details-summary::before { content: "\25B8"; margin-right: 8px; color: var(--fg-muted); transition: transform 120ms ease; }
details[open] > .details-summary::before { transform: rotate(90deg); }

.app { max-width: 560px; margin: 0 auto; padding-inline: 16px; padding-block: 0 112px; min-height: 100vh; }
.app.app-teacher { padding-bottom: 40px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-block: 12px 10px; margin-inline: -16px; padding-inline: 16px;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.topbar > * { min-width: 0; }
.topbar .brand { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-display); font-weight: 700; font-size: 15px; color: var(--fg); overflow-wrap: anywhere; }
.topbar .brand::before { content: ""; width: 26px; height: 26px; border-radius: 8px; background: var(--accent); flex: none; box-shadow: inset 0 -6px 0 rgba(255,255,255,0.22); }
.topbar .title { font-size: 20px; font-weight: 700; }
.topbar .actions { display: flex; gap: 8px; align-items: center; flex: none; }
.topbar .actions .btn { white-space: nowrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 20px; border-radius: 999px; border: 1px solid transparent;
  font-family: var(--font-display); font-weight: 600; font-size: 16px; line-height: 1.2;
  background: var(--surface-2); color: var(--fg); text-decoration: none; -webkit-tap-highlight-color: transparent;
  transition: transform 80ms ease, background 120ms ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: var(--accent-fg); box-shadow: 0 6px 16px rgba(91, 61, 245, 0.28); }
.btn-primary:hover { background: var(--accent-ink); }
.btn-outline { background: var(--surface); border-color: var(--line-strong); color: var(--accent-ink); }
.btn-ghost { background: transparent; color: var(--accent-ink); padding-inline: 12px; }
.btn-danger { background: var(--warn-soft); color: var(--warn); }
.btn-block { width: 100%; }
.btn-sm { min-height: 40px; padding: 6px 14px; font-size: 14px; border-radius: 999px; }
.btn-icon { min-width: 44px; min-height: 44px; padding-inline: 10px; }
.btn[disabled] { opacity: 0.6; cursor: default; transform: none; }
.btn svg { width: 18px; height: 18px; flex: none; }

/* ---------- Badges (one component, tint only) ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-height: 24px;
  padding: 3px 10px; border-radius: 999px;
  font-family: var(--font-display); font-size: 12.5px; font-weight: 600; line-height: 1.25;
  background: var(--surface-2); color: var(--fg-muted); white-space: normal; text-align: left; overflow-wrap: anywhere;
}
.badge svg { width: 15px; height: 15px; flex: none; }
.badge-pre { background: var(--pre-soft); color: var(--pre); }
.badge-el { background: var(--el-soft); color: var(--el); }
.badge-cross { background: var(--cross-soft); color: var(--cross); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-draft { background: var(--draft-soft); color: var(--draft); border: 1px dashed var(--line-strong); }
.badge-changed { background: var(--warn-soft); color: var(--warn); }

/* ---------- Sections ---------- */
.section { margin-top: 24px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.eyebrow { font-family: var(--font-display); font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-muted); }
.section-sub { font-size: 15px; color: var(--fg-muted); }

/* ---------- Teacher: greeting ---------- */
.greeting { margin-top: 8px; display: grid; gap: 2px; }
.greeting h1 { font-size: 28px; font-weight: 700; }
.greeting .date { font-size: 15px; color: var(--accent-ink); font-weight: 600; font-family: var(--font-display); }
.greeting .stamp { font-size: 14px; color: var(--fg-faint); margin-top: 4px; }
.summary-line { margin: 0 0 12px; font-size: 17px; line-height: 1.45; }

/* ---------- Teacher: TODAY card ---------- */
.today-list { display: grid; gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.card:not(.today-card) { border-color: transparent; }
.today-card { position: relative; padding: 0; }
.today-card.area-pre { box-shadow: inset 5px 0 0 var(--pre-rail), var(--shadow-sm); }
.today-card.area-el { box-shadow: inset 5px 0 0 var(--el-rail), var(--shadow-sm); }
.today-card.is-cross { box-shadow: inset 5px 0 0 var(--cross-rail), var(--shadow-sm); border-color: var(--cross-rail); }
.band {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-height: 40px;
  padding: 8px 18px 8px 22px; background: var(--surface-2); color: var(--fg-muted);
  font-family: var(--font-display); font-weight: 600; font-size: 14px;
}
.band svg { width: 18px; height: 18px; flex: none; }
.band-cross { background: var(--cross-solid); color: var(--cross-solid-fg); font-size: 16px; font-weight: 700; min-height: 46px; }
.band-cross svg { width: 22px; height: 22px; }
.band .badge { margin-left: auto; }
.today-card .body { padding: 16px 18px 18px 22px; display: grid; gap: 10px; }
.today-card .where { font-family: var(--font-display); font-weight: 700; font-size: 28px; line-height: 1.15; letter-spacing: -0.02em; }
.today-card .where-detail { font-size: 15px; color: var(--fg-muted); margin-top: -6px; }
.today-card .position { font-family: var(--font-display); font-weight: 600; font-size: 20px; line-height: 1.25; }
.covering-for { font-weight: 700; color: var(--fg-muted); font-size: 0.85em; }
.today-card .when { font-size: 17px; font-weight: 700; color: var(--fg); }
.today-card .when .sep { color: var(--fg-faint); }
.now { color: var(--ok); font-weight: 700; }
.with-you { font-size: 16px; line-height: 1.45; }
.wy-label { font-weight: 700; }
.after { font-size: 15px; line-height: 1.45; }
.today-card.is-done .body { color: var(--fg-muted); }
.today-card.is-done .where, .today-card.is-done .position { color: var(--fg-muted); }
.note {
  padding: 10px 14px; border-left: 3px solid var(--line-strong); background: var(--surface-2); border-radius: 0 12px 12px 0;
  font-size: 16px; line-height: 1.45;
}
.area-pre .note { border-left-color: var(--pre-rail); }
.area-el .note { border-left-color: var(--el-rail); }
.is-cross .note { border-left-color: var(--cross-rail); }
.note .note-label { display: block; font-family: var(--font-display); font-size: 13px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--fg-muted); margin-bottom: 2px; }
.contact-link {
  display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 12px; margin: 2px -12px 0;
  border-radius: 12px; color: var(--accent); font-weight: 700; text-decoration: none; font-size: 16px;
}
.contact-link svg { width: 20px; height: 20px; flex: none; }
.empty-today { padding: 20px 18px; display: grid; gap: 12px; }
.empty-today h3 { font-size: 22px; }
.next-up { display: grid; gap: 4px; padding: 14px 16px; border-radius: 12px; background: var(--surface-2); color: inherit; text-decoration: none; }
.next-up .label { font-family: var(--font-display); font-size: 13px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--fg-muted); }
.headsup {
  display: flex; gap: 12px; align-items: flex-start; margin-top: 16px; padding: 14px 16px; border-radius: var(--radius);
  background: var(--cross-soft); color: var(--fg); text-decoration: none; font-size: 16px; line-height: 1.45; min-height: 56px;
  border: 1px solid var(--cross-rail);
}
.headsup svg { width: 22px; height: 22px; flex: none; color: var(--cross); margin-top: 2px; }
.headsup strong { color: var(--cross); }
.contact-link { color: var(--accent-ink); }

/* ---------- Teacher: week list ---------- */
.day-group { margin-top: 14px; scroll-margin-top: 72px; }
.day-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  padding: 8px 2px 6px; font-family: var(--font-display); font-weight: 700; font-size: 16px; color: var(--fg);
}
.day-head .date { color: var(--fg-muted); font-weight: 700; font-size: 14px; }
.day-group.is-past .day-head, .day-group.is-past .row { color: var(--fg-muted); }
.day-group.is-flash .day-head { color: var(--accent); }
.day-empty { padding: 12px 14px; border-radius: 12px; border: 1px dashed var(--line-strong); color: var(--fg-muted); font-size: 15px; }
.rows { display: grid; gap: 8px; }
.row {
  position: relative; display: block; min-height: 56px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px 12px 18px; text-align: left; width: 100%; color: inherit;
}
.row.area-pre { box-shadow: inset 4px 0 0 var(--pre-rail); }
.row.area-el { box-shadow: inset 4px 0 0 var(--el-rail); }
.row.is-cross { box-shadow: inset 4px 0 0 var(--cross-rail); background: var(--cross-soft); border-color: var(--cross-rail); }
.row .row-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; justify-content: space-between; }
.row .row-time { font-weight: 700; font-size: 15px; color: var(--fg-muted); }
.row .row-main { font-size: 17px; line-height: 1.4; margin-top: 4px; }
.row .row-where { font-family: var(--font-display); font-weight: 700; }
.row .row-position { font-weight: 400; }
.row .row-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
details.row > summary { list-style: none; cursor: pointer; display: block; }
details.row > summary::-webkit-details-marker { display: none; }
details.row .row-more { display: block; margin-top: 6px; font-size: 14px; color: var(--accent); font-weight: 700; font-family: var(--font-display); }
details.row[open] .row-more { display: none; }
.row-detail { display: grid; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 15px; }
.earlier { margin-top: 18px; }
.week-switch { display: grid; gap: 8px; margin-top: 18px; }
.footer-help { margin-top: 28px; padding: 16px; border-radius: var(--radius); background: var(--surface-2); font-size: 15px; color: var(--fg-muted); }
.footer-help strong { color: var(--fg); }

/* ---------- Login ---------- */
.login { padding-top: 36px; display: grid; gap: 18px; }
.login .mark { width: 64px; height: 64px; border-radius: 18px; background: linear-gradient(135deg, var(--accent), #8b5cf6); color: #fff; display: grid; place-items: center; box-shadow: 0 10px 24px rgba(91, 61, 245, 0.3); }
.login .mark svg { width: 34px; height: 34px; }
.login h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.login .sub { font-size: 17px; color: var(--fg-muted); margin-top: 4px; }
.people { display: grid; gap: 8px; }
.person {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; min-height: 56px;
  padding: 10px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: inherit;
}
.person { border-color: transparent; box-shadow: var(--shadow-sm); }
.person.is-selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: 15px; background: var(--surface-2); color: var(--fg);
}
.avatar.pre { background: var(--pre-soft); color: var(--pre); }
.avatar.el { background: var(--el-soft); color: var(--el); }
.avatar.both { background: var(--accent-soft); color: var(--accent-ink); }
.person .p-name { font-family: var(--font-display); font-weight: 700; font-size: 17px; }
.person .p-sub { font-size: 14px; color: var(--fg-muted); }
.pin-box { display: grid; gap: 10px; padding: 18px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid transparent; box-shadow: var(--shadow-sm); }
.pin-input { font-size: 28px; letter-spacing: 0.5em; text-align: center; font-variant-numeric: tabular-nums; }
.demo-hint { font-size: 15px; color: var(--fg-muted); }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; }
.field > label, .field > .label { font-family: var(--font-display); font-weight: 700; font-size: 14px; color: var(--fg-muted); }
.input, .select, textarea.input {
  width: 100%; min-height: 48px; min-width: 0; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--control-border); background: var(--surface); color: var(--fg); font-size: 16px;
}
input[type="date"].input, input[type="time"].input { min-width: 0; width: 100%; -webkit-appearance: none; appearance: none; }
textarea.input { min-height: 88px; resize: vertical; line-height: 1.4; }
.select { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--fg-muted) 50%), linear-gradient(135deg, var(--fg-muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.field-row > * { min-width: 0; }
.hint { font-size: 14px; color: var(--fg-muted); line-height: 1.4; }
.hint:empty { display: none; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface-2); }
.seg label { position: relative; display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 6px 8px; border-radius: 10px; font-family: var(--font-display); font-weight: 700; font-size: 15px; text-align: center; color: var(--fg-muted); cursor: pointer; }
.seg label > span { display: inline-flex; align-items: center; gap: 6px; }
.seg label svg { width: 16px; height: 16px; }
.seg input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.seg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 6px; border-radius: 6px; }
.seg label.is-checked { background: var(--surface); color: var(--fg); box-shadow: var(--shadow-sm); }
.seg label.seg-pre.is-checked { color: var(--pre); }
.seg label.seg-el.is-checked { color: var(--el); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 40px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); font-family: var(--font-display); font-weight: 700; font-size: 14px; color: var(--fg); }
.chip.is-active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
.chip .muted { font-weight: 700; }
.errors { display: grid; gap: 6px; padding: 12px 14px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); font-size: 15px; }
.errors ul { margin: 0; padding-left: 18px; list-style: disc; }
.conflict-box { display: grid; gap: 6px; padding: 12px 14px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); font-size: 15px; border-left: 4px solid var(--warn-rail); }
.conflict-box + .conflict-box { margin-top: 8px; }
.conflict-box strong { font-family: var(--font-display); display: inline-flex; gap: 6px; align-items: center; }
.conflict-box.soft { background: var(--surface-2); color: var(--fg-muted); border-left-color: var(--line-strong); }
.conflict-box.soft span { display: inline-flex; gap: 6px; align-items: flex-start; }
.conflict-box.soft svg { flex: none; margin-top: 3px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 15px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.reassign { display: grid; gap: 8px; padding: 12px; border-radius: var(--radius); background: var(--surface-2); }
.reassign .person { min-height: 52px; }
.reassign .btn { justify-self: start; }

/* ---------- Bottom sheet / dialog ---------- */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 40; }
.scrim-top { z-index: 50; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  max-height: 92vh; max-height: 92dvh; overflow: auto; -webkit-overflow-scrolling: touch;
  background: var(--surface); border-radius: 22px 22px 0 0; box-shadow: var(--shadow);
  padding: 8px 16px calc(20px + env(safe-area-inset-bottom, 0px));
  max-width: 560px; margin: 0 auto;
}
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 4px auto 12px; }
.sheet h2 { font-size: 22px; }
.sheet .sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.sheet form { display: grid; gap: 16px; }
.sheet .sheet-actions { display: grid; gap: 10px; margin-top: 6px; }
.dialog {
  position: fixed; left: 16px; right: 16px; top: 50%; transform: translateY(-50%); z-index: 51;
  max-width: 420px; margin: 0 auto; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow);
  padding: 20px; display: grid; gap: 12px;
}
.dialog h2 { font-size: 20px; }
.dialog .dialog-actions { display: grid; gap: 8px; grid-template-columns: 1fr 1fr; margin-top: 4px; }
.preview-label { font-family: var(--font-display); font-weight: 700; font-size: 14px; color: var(--fg-muted); margin-bottom: 8px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom, 0px)); z-index: 60; pointer-events: none;
  max-width: 440px; margin: 0 auto; padding: 12px 16px; border-radius: 14px;
  background: var(--fg); color: var(--bg); font-weight: 700; text-align: center; box-shadow: var(--shadow);
  animation: toast-in 160ms ease-out;
}
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Admin: tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr); max-width: 560px; margin: 0 auto;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 6px 8px calc(8px + env(safe-area-inset-bottom, 0px));
}
.tab-brand { display: none; }
.tab-logout { display: none; }
.tab { display: grid; justify-items: center; gap: 2px; padding: 6px 4px; border-radius: 12px; border: 0; background: transparent; color: var(--fg-muted); font-family: var(--font-display); font-weight: 600; font-size: 12px; min-height: 52px; text-decoration: none; }
.tab svg { width: 24px; height: 24px; }
.tab.is-active { color: var(--accent-ink); background: var(--accent-soft); }
@media (min-width: 900px) {
  .app:not(.app-teacher) { max-width: 760px; margin-left: 240px; }
  .app.app-teacher { margin-left: 240px; }
  .tabbar { top: 0; bottom: 0; left: 0; right: auto; width: 200px; max-width: none; margin: 0; background: var(--surface);
    display: flex; flex-direction: column; gap: 4px; padding: 20px 12px; border-top: 0; border-right: 1px solid var(--line); }
  .tab-brand { display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-weight: 700; font-size: 16px; padding: 6px 10px 18px; color: var(--fg); }
  .tab-brand::before { content: ""; width: 24px; height: 24px; border-radius: 7px; background: var(--accent); flex: none; }
  .tab { grid-template-columns: 24px 1fr; justify-items: start; align-items: center; gap: 10px; padding: 10px 12px; min-height: 44px; font-size: 15px; }
  .tab-logout { display: grid; margin-top: auto; width: 100%; border: 0; background: transparent; cursor: pointer; font-family: var(--font-display); border-top: 1px solid var(--line); border-radius: 0; padding-top: 16px; }
  .tab-logout:hover { color: var(--accent-ink); }
  .app .topbar .brand { visibility: hidden; }
}

/* ---------- Admin: week builder ---------- */
.week-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.week-label { display: grid; justify-items: center; gap: 0; min-height: 48px; color: var(--fg); }
.week-label .label { font-family: var(--font-display); font-weight: 700; font-size: 17px; }
.week-label .section-sub { font-size: 13px; }
.week-label[disabled] { opacity: 1; }
.status-card { padding: 14px 16px; display: grid; gap: 10px; }
.status-card .status-line { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.status-card.all-good { box-shadow: inset 5px 0 0 var(--ok), var(--shadow-sm); }
.day-tabs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface-2); margin-top: 16px; }
.day-tab { display: grid; justify-items: center; gap: 0; min-height: 60px; padding: 6px 2px; border-radius: 12px; border: 0; background: transparent; color: var(--fg-muted); font-family: var(--font-display); font-weight: 600; font-size: 13px; }
.day-tab .d { font-size: 18px; color: var(--fg); line-height: 1.2; }
.day-tab.is-active { background: var(--surface); color: var(--fg); box-shadow: var(--shadow-sm); }
.day-tab.is-today .d { color: var(--accent-ink); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.day-tab .cnt { font-size: 12px; color: var(--fg-muted); font-weight: 700; display: inline-flex; align-items: center; gap: 3px; }
.day-tab .flag { color: var(--warn); display: inline-flex; }
.day-tab .flag svg { width: 13px; height: 13px; }
.day-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-top: 18px; }
.day-title h2 { font-size: 20px; }
.arow {
  display: grid; grid-template-columns: 42px 1fr; gap: 12px; align-items: start; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; color: inherit;
}
.arow.has-conflict { border-color: var(--warn-rail); box-shadow: inset 4px 0 0 var(--warn-rail); }
.arow .a-main { display: grid; gap: 4px; min-width: 0; }
.arow .a-name { font-family: var(--font-display); font-weight: 700; font-size: 17px; }
.arow .a-time { font-weight: 700; font-size: 15px; color: var(--fg-muted); }
.arow .a-what { font-size: 16px; }
.arow .a-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.arow .a-note { font-size: 14px; color: var(--fg-muted); font-style: italic; }
.arow .a-conflict { font-size: 14px; color: var(--warn); font-weight: 700; display: inline-flex; gap: 4px; align-items: center; }
.conflicts { display: grid; gap: 8px; }
.conflict-item { display: grid; gap: 4px; padding: 12px 14px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); border-left: 4px solid var(--warn-rail); font-size: 15px; }
.conflict-item strong { font-family: var(--font-display); display: inline-flex; gap: 6px; align-items: center; }
.conflict-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.add-bar { margin-top: 12px; }

/* ---------- Admin: board ---------- */
.board-area { margin-top: 18px; }
.board-loc { margin-top: 8px; padding: 12px 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.board-loc .l-name { font-family: var(--font-display); font-weight: 700; font-size: 16px; display: flex; justify-content: space-between; gap: 8px; }
.board-loc .l-detail { font-size: 13px; color: var(--fg-muted); }
.board-loc .l-people { display: grid; gap: 6px; margin-top: 8px; }
.board-person { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; font-size: 15px; text-align: left; background: none; border: 0; padding: 6px 0; color: inherit; min-height: 44px; border-radius: 8px; }
.board-person.has-conflict { box-shadow: inset 3px 0 0 var(--warn-rail); padding-left: 10px; }
.board-person .bp-name { font-weight: 700; }
.board-person .bp-pos { color: var(--fg-muted); font-size: 14px; grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.board-person .bp-time { color: var(--fg-muted); font-size: 14px; }
.board-add { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; margin-top: 6px; padding: 4px 10px; border-radius: 10px; border: 1px dashed var(--line-strong); background: transparent; color: var(--fg-muted); font-size: 14px; font-family: var(--font-display); font-weight: 700; }
.board-add svg { width: 16px; height: 16px; }

/* ---------- Admin: staff ---------- */
.staff-list { display: grid; gap: 8px; }
.staff-row { display: grid; grid-template-columns: 42px 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.staff-row.is-inactive { color: var(--fg-muted); }
.staff-row .s-name { font-family: var(--font-display); font-weight: 700; font-size: 17px; }
.staff-row .s-sub { font-size: 14px; color: var(--fg-muted); }
.staff-row .s-actions { display: grid; gap: 6px; }

/* ---------- Admin: menu ---------- */
.menu-card { padding: 16px; display: grid; gap: 12px; }
.menu-card h2 { font-size: 17px; }
.preview-banner { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; font-size: 14px; margin-top: 10px; }
.preview-banner svg { width: 20px; height: 20px; flex: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media (min-width: 600px) {
  .app { padding-inline: 20px; }
}

.demo-grid { display: grid; gap: 12px; margin-top: 12px; }
p.contact-link { color: var(--fg); }
.a-main, .s-sub, .row-main, .with-you, .note, .after { overflow-wrap: anywhere; }

/* ---------- Dashboard: tiles + team week grid ---------- */
.app.app-dash { max-width: 1100px; }
.tabbar-3 { grid-template-columns: repeat(3, 1fr); }
.tabbar-6 { grid-template-columns: repeat(6, 1fr); }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
.tile { display: grid; gap: 2px; padding: 14px 16px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); color: inherit; text-decoration: none; min-width: 0; }
.tile strong { font-family: var(--font-display); font-size: 18px; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.tile .muted { font-size: 13px; }
.tile-label { font-family: var(--font-display); font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-muted); }
.tile-cross { box-shadow: inset 4px 0 0 var(--cross-rail), var(--shadow-sm); }
.tile-cross strong { color: var(--cross); }
.grid-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.grid-nav { gap: 6px; }
.grid-nav .label { font-family: var(--font-display); font-weight: 700; font-size: 15px; padding-inline: 4px; }
.grid-wrap { overflow-x: auto; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); -webkit-overflow-scrolling: touch; }
.sgrid { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 640px; font-size: 13px; }
.sgrid th, .sgrid td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 8px; vertical-align: top; text-align: left; min-width: 112px; }
.sgrid th { font-family: var(--font-display); font-weight: 600; color: var(--fg-muted); background: var(--surface-2); white-space: nowrap; }
.sgrid th .sg-day { color: var(--fg); font-weight: 700; }
.sgrid th.is-today { background: var(--accent-soft); color: var(--accent-ink); }
.sgrid th.is-today .sg-day { color: var(--accent-ink); }
.sgrid td.is-today { background: color-mix(in srgb, var(--accent-soft) 35%, transparent); }
.sgrid .sg-person { position: sticky; left: 0; z-index: 2; background: var(--surface); min-width: 170px; max-width: 220px; border-right: 1px solid var(--line-strong); vertical-align: middle; }
.sgrid thead .sg-person, .sgrid tfoot .sg-person { background: var(--surface-2); }
.sg-pwrap { display: flex; align-items: center; gap: 10px; }
.sg-pwrap-col { flex-direction: column; align-items: flex-start; gap: 0; }
.sgrid .sg-person .avatar { width: 34px; height: 34px; font-size: 13px; }
.sgrid .sg-name { display: grid; gap: 1px; min-width: 0; }
.sgrid .sg-name strong { font-family: var(--font-display); font-weight: 600; font-size: 14px; color: var(--fg); overflow-wrap: anywhere; }
.sgrid tr.is-me td { background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface)); }
.sgrid tr.is-me .sg-person { background: var(--accent-soft); }
.sgrid tfoot td { background: var(--surface-2); border-bottom: 0; }
.sgrid tfoot td strong { display: block; font-family: var(--font-display); }
.shiftchip { display: grid; gap: 1px; width: 100%; text-align: left; padding: 6px 8px; margin-bottom: 6px; border-radius: 8px; border: 1px dashed; font: inherit; font-size: 12.5px; line-height: 1.3; color: inherit; cursor: default; }
button.shiftchip { cursor: pointer; }
.shiftchip:last-child { margin-bottom: 0; }
.shiftchip .sc-time { font-weight: 700; }
.shiftchip .sc-what { font-weight: 500; }
.shiftchip .sc-where { color: var(--fg-muted); }
.shiftchip .sc-state { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--warn); }
.sc-pre { background: var(--pre-soft); border-color: var(--pre-rail); color: var(--pre); }
.sc-el { background: var(--el-soft); border-color: var(--el-rail); color: var(--el); }
.sc-cross { background: var(--cross-soft); border-color: var(--cross-rail); color: var(--cross); }
.sc-pre .sc-where, .sc-el .sc-where, .sc-cross .sc-where { color: inherit; opacity: 0.8; }
.sg-add { width: 100%; min-height: 32px; border: 1px dashed var(--line-strong); border-radius: 8px; background: transparent; color: var(--fg-faint); opacity: 0; transition: opacity 120ms; }
.sgrid td:hover .sg-add, .sg-add:focus-visible { opacity: 1; }
.sg-add svg { width: 16px; height: 16px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.legend .shiftchip { width: auto; margin: 0; padding: 4px 10px; display: inline-flex; }
@media (min-width: 700px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 900px) {
  .app.app-dash { max-width: 1100px; margin-left: 240px; }
  .app.app-dash .topbar .brand { visibility: hidden; }
  .app.app-teacher.has-tabs { padding-bottom: 112px; }
}
@media (hover: none) { .sg-add { opacity: 0.6; } }

/* ---------- Sign-in page (storefront style) ---------- */
body:has(.login) { background: #fff; }
.app:has(.login) { max-width: 1100px; background: #fff; min-height: 100vh; }
.login { padding-top: 0; gap: 0; display: block; }
.login-top { display: flex; align-items: center; justify-content: center; padding: 18px 0 6px; border-bottom: 1px solid var(--line); margin-inline: -16px; padding-inline: 16px; }
.login-logo { height: 120px; width: auto; display: block; }
.login-h1 { font-size: 40px; font-weight: 700; letter-spacing: -0.02em; margin: 40px 0 28px; color: #1d1d1f; }
.login-cols { display: grid; grid-template-columns: 1fr; gap: 32px; }
.login-col h2 { font-size: 24px; font-weight: 600; color: #1d1d1f; margin-bottom: 18px; }
.login-form { display: grid; gap: 12px; }
.login-input, .select.login-input { min-height: 56px; font-size: 17px; border-radius: 12px; border: 1px solid #86868b; background: #fff; }
.login-input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); outline: none; }
.login-error { display: flex; gap: 6px; align-items: center; color: #e30000; font-size: 14px; }
.login-note { font-size: 15px; color: #1d1d1f; line-height: 1.45; }
.login-lead { font-size: 17px; line-height: 1.5; color: #1d1d1f; margin-bottom: 24px; }
.btn-login { min-height: 56px; font-size: 17px; border-radius: 12px; margin-top: 8px; }
.login-form .btn-ghost { justify-self: start; }
.login .errors { margin: 0 0 16px; }
.login-help { margin-top: 48px; padding-top: 20px; border-top: 1px solid var(--line); font-size: 17px; color: #1d1d1f; padding-bottom: 24px; }
@media (min-width: 760px) {
  .login-top { justify-content: flex-start; }
  .login-logo { height: 110px; }
  .login-cols { grid-template-columns: 1fr 1fr; gap: 56px; }
  .login-col + .login-col { border-left: 1px solid var(--line); padding-left: 56px; }
  .login-h1 { font-size: 48px; }
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body:has(.login), :root:not([data-theme="light"]) body:has(.login), :root:not([data-theme="light"]) .app:has(.login) { background: var(--surface); }
  :root:not([data-theme="light"]) .login-h1, :root:not([data-theme="light"]) .login-col h2, :root:not([data-theme="light"]) .login-note, :root:not([data-theme="light"]) .login-lead, :root:not([data-theme="light"]) .login-help { color: var(--fg); }
  :root:not([data-theme="light"]) .login-input, :root:not([data-theme="light"]) .select.login-input { background: var(--surface-2); border-color: var(--control-border); }
  :root:not([data-theme="light"]) .login-logo { background: #fff; border-radius: 12px; padding: 6px; }
}
:root[data-theme="dark"] body:has(.login), :root[data-theme="dark"] body:has(.login), :root[data-theme="dark"] .app:has(.login) { background: var(--surface); }
:root[data-theme="dark"] .login-h1, :root[data-theme="dark"] .login-col h2, :root[data-theme="dark"] .login-note, :root[data-theme="dark"] .login-lead, :root[data-theme="dark"] .login-help { color: var(--fg); }
:root[data-theme="dark"] .login-input, :root[data-theme="dark"] .select.login-input { background: var(--surface-2); border-color: var(--control-border); }
:root[data-theme="dark"] .login-logo { background: #fff; border-radius: 12px; padding: 6px; }

/* ---------- Bottom log-out ---------- */
.logout-foot { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); }
