/* Pulsed Schedule — category-standard calendar UI (Google Calendar / Outlook bar) */
:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f8f9fa;
  --hover: #f1f3f4;
  --line: #dadce0;
  --line-soft: #eceff1;
  --ink: #1f1f1f;
  --ink-2: #3c4043;
  --muted: #5f6368;
  --blue: #1a73e8;
  --blue-ink: #185abc;
  --blue-soft: #e8f0fe;
  --blue-soft-2: #d2e3fc;
  --red: #d93025;
  --red-soft: #fce8e6;
  --amber-ink: #7a4f01;
  --amber-soft: #fef7e0;
  --shadow-1: 0 1px 2px rgba(60, 64, 67, .3), 0 1px 3px 1px rgba(60, 64, 67, .15);
  --shadow-2: 0 1px 3px rgba(60, 64, 67, .3), 0 4px 8px 3px rgba(60, 64, 67, .15);
  --shadow-3: 0 8px 24px rgba(60, 64, 67, .22), 0 2px 6px rgba(60, 64, 67, .18);
  --radius: 8px;
  --appbar-h: 56px;
  --weekbar-h: 60px;
  --sidebar-w: 248px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1e1f22; --surface: #1e1f22; --surface-2: #26272b; --hover: #2c2d31; --line: #3c4043; --line-soft: #2e3034;
    --ink: #e8eaed; --ink-2: #dadce0; --muted: #9aa0a6;
    --blue: #8ab4f8; --blue-ink: #aecbfa; --blue-soft: #28354a; --blue-soft-2: #2d3f5e;
    --red: #f28b82; --red-soft: #3c2a29;
    --amber-ink: #fdd663; --amber-soft: #3d3419;
    --shadow-1: 0 1px 2px rgba(0,0,0,.5), 0 1px 3px 1px rgba(0,0,0,.3);
    --shadow-2: 0 1px 3px rgba(0,0,0,.5), 0 4px 8px 3px rgba(0,0,0,.35);
    --shadow-3: 0 8px 24px rgba(0,0,0,.55), 0 2px 6px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font); font-size: 14px; line-height: 1.43; color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  padding-top: var(--appbar-h);
  /* room for the fixed week bar (plus the iPhone home-indicator area) so the end of the calendar can scroll into view */
  padding-bottom: calc(var(--weekbar-h) + env(safe-area-inset-bottom));
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 500; }
p { margin: 0; }
::selection { background: var(--blue-soft-2); color: var(--ink); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--line); border: 3px solid transparent; background-clip: padding-box; border-radius: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
input { caret-color: var(--blue); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }
[hidden] { display: none !important; }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon.small { width: 16px; height: 16px; }
.tabular { font-variant-numeric: tabular-nums; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 16px;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 500; letter-spacing: .01em; cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background-color .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.btn:hover { background: var(--hover); }
.btn:active { background: var(--line-soft); }
.btn .icon { width: 18px; height: 18px; margin-left: -4px; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-ink); border-color: var(--blue-ink); box-shadow: var(--shadow-1); }
.btn.primary .icon { stroke-width: 2; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger:hover { filter: brightness(.94); }
.btn.danger-ghost { color: var(--red); border-color: transparent; background: transparent; }
.btn.danger-ghost:hover { background: var(--red-soft); }
.btn.small { height: 30px; padding: 0 12px; font-size: 13px; }
.btn.text { border-color: transparent; background: transparent; color: var(--blue); }
.btn.text:hover { background: var(--blue-soft); }
.btn:disabled, .icon-btn:disabled { opacity: .38; cursor: default; box-shadow: none; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 0; background: transparent; color: var(--muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; transition: background-color .12s ease;
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn:active { background: var(--line-soft); }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=date], input[type=time], input[type=number], input:not([type]), select, textarea {
  height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); min-width: 0;
  transition: border-color .12s ease, box-shadow .12s ease;
}
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
::placeholder { color: var(--muted); opacity: 1; }
textarea { height: auto; padding: 8px 12px; resize: vertical; line-height: 1.4; }
select { appearance: none; -webkit-appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235f6368' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 18px; }
input[type=color] { width: 40px; height: 36px; padding: 3px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); cursor: pointer; }
input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
input[type=color]::-webkit-color-swatch { border: 0; border-radius: 5px; }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; margin: 0; accent-color: var(--blue); cursor: pointer; }
.check, .radio { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; min-height: 32px; }

/* ---------- app bar ---------- */
.appbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--appbar-h); z-index: 30;
  display: flex; align-items: center; gap: 12px; padding: 0 16px 0 12px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; margin-right: 8px; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--blue); color: #fff; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.brand-mark .icon { width: 22px; height: 22px; stroke-width: 2; }
.brand-name { font-size: 20px; font-weight: 500; letter-spacing: -.01em; white-space: nowrap; }
.viewswitch { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: var(--radius); }
.seg { height: 28px; padding: 0 14px; border: 0; border-radius: 5px; background: transparent; color: var(--ink-2); font-weight: 500; cursor: pointer; transition: background-color .12s ease; }
.seg:hover { background: var(--hover); }
.seg.active { background: var(--blue-soft); color: var(--blue-ink); }
.searchbox { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: var(--radius); background: var(--hover); color: var(--muted); flex: 1; min-width: 0; max-width: 480px; margin-left: 12px; transition: background-color .12s ease, box-shadow .12s ease; }
.searchbox:focus-within { background: var(--surface); box-shadow: 0 0 0 1px var(--blue); color: var(--ink); }
.searchbox input { height: 100%; flex: 1; min-width: 0; width: 100%; border: 0; background: transparent; padding: 0; box-shadow: none !important; }
.searchbox input::-webkit-search-cancel-button { -webkit-appearance: none; }
.appbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
body.logged-out .auth-only { display: none !important; }
body.logged-in .guest-only { display: none !important; }
.mobile-only { display: none !important; }
.count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--blue); color: #fff; font-size: 11px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
.menu { position: relative; }
.menu-btn { padding-left: 6px; padding-right: 10px; gap: 8px; }
.menu-btn .icon { margin: 0; }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--blue-soft); color: var(--blue-ink); font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; letter-spacing: .02em; }
.menu-list { display: none; position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-2); min-width: 280px; padding: 8px 0; z-index: 40; }
.menu.open .menu-list { display: block; animation: pop .12s ease-out; }
.menu-list button { display: flex; align-items: center; gap: 14px; width: 100%; height: 40px; text-align: left; padding: 0 16px; border: 0; background: transparent; color: var(--ink); cursor: pointer; }
.menu-list button:hover { background: var(--hover); }
.menu-list button .icon { color: var(--muted); }
.menu-list hr { border: 0; border-top: 1px solid var(--line); margin: 8px 0; }

/* ---------- shell / sidebar ---------- */
.shell { display: flex; min-height: calc(100vh - var(--appbar-h) - var(--weekbar-h)); }
.sidebar {
  flex: none; width: var(--sidebar-w); padding: 16px 12px 24px 16px; border-right: 1px solid var(--line);
  position: sticky; top: var(--appbar-h); height: calc(100vh - var(--appbar-h) - var(--weekbar-h)); overflow-y: auto;
}
.side-title { display: flex; align-items: center; justify-content: space-between; height: 32px; margin: 8px 0 2px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.side-title .btn.text { height: 28px; padding: 0 8px; font-size: 12px; }
.prog-list { display: flex; flex-direction: column; margin: 0 -8px 12px; }
.prog-row { position: relative; display: flex; align-items: center; min-height: 32px; padding: 0; border-radius: 6px; user-select: none; -webkit-user-select: none; }
.prog-label { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; min-height: 32px; padding: 3px 8px; cursor: pointer; }
.prog-row:hover { background: var(--hover); }
.prog-row input { appearance: none; -webkit-appearance: none; width: 18px; height: 18px; margin: 0; border-radius: 4px; border: 2px solid var(--pc); background: transparent; flex: none; cursor: pointer; position: relative; transition: background-color .1s ease; }
.prog-row input:checked { background: var(--pc); }
.prog-row input:checked::after { content: ""; position: absolute; inset: 0; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center/13px no-repeat; }
.prog-row input.dark-check:checked::after { filter: invert(1); }
.prog-row input:focus-visible { outline-offset: 1px; }
.prog-row span { flex: 1; min-width: 0; font-size: 13.5px; line-height: 1.2; overflow-wrap: anywhere; }
.prog-row .only { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); opacity: 0; font-size: 12px; color: var(--muted); padding: 2px 6px; border-radius: 4px; border: 0; background: var(--surface); cursor: pointer; }
.prog-row:hover .only, .prog-row:focus-within .only { opacity: 1; }
.prog-row .only:hover { background: var(--line-soft); color: var(--ink); }
.side-field { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 14px; }
.side-field select { width: 100%; }
.side-note { font-size: 12px; color: var(--muted); line-height: 1.4; margin-top: 16px; }
.side-links { display: flex; flex-direction: column; gap: 2px; margin: 12px -8px 0; }
.side-links button { display: flex; align-items: center; gap: 12px; height: 36px; padding: 0 8px; border: 0; background: transparent; color: var(--ink-2); border-radius: 6px; cursor: pointer; text-align: left; }
.side-links button:hover { background: var(--hover); }
.side-links .icon { color: var(--muted); width: 18px; height: 18px; }

/* ---------- main ---------- */
.view { flex: 1; min-width: 0; padding: 0; }
.empty-state { max-width: 440px; margin: 64px auto; text-align: center; padding: 0 24px; }
.empty-state h2 { font-size: 22px; margin-bottom: 8px; }
.empty-state p { color: var(--muted); margin: 0 0 20px; }
.empty { padding: 20px; }

/* ---------- lesson chip (shared) ---------- */
.lesson {
  position: absolute; border-radius: 6px; padding: 3px 8px; overflow: hidden; cursor: pointer; user-select: none; -webkit-user-select: none;
  font-size: 12px; line-height: 1.3; box-shadow: inset 0 0 0 1px rgba(255,255,255,.35);
  transition: box-shadow .12s ease, opacity .15s ease, filter .12s ease; touch-action: manipulation;
}
.lesson:hover { box-shadow: var(--shadow-1), inset 0 0 0 1px rgba(255,255,255,.35); z-index: 3; }
.lesson:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.lesson-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 16px; }
.lesson-meta { opacity: .9; font-size: 11px; line-height: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; gap: 6px; }
.grid .lesson-meta > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.lesson.dim { opacity: .28; }
.lesson.conflict { box-shadow: inset 0 0 0 2px var(--red), 0 0 0 1px var(--surface); }
.lesson-flags { position: absolute; top: 3px; right: 4px; display: flex; gap: 2px; }
.lesson-flags .icon { width: 14px; height: 14px; stroke-width: 2; filter: drop-shadow(0 0 1px rgba(0,0,0,.3)); }
.lesson.dragging { opacity: .35; }
.lesson.resizing { z-index: 4; }
.ghost, .ghost-move { position: absolute; z-index: 5; pointer-events: none; }
.ghost { background: var(--blue-soft); border: 2px dashed var(--blue); border-radius: 6px; color: var(--blue-ink); font-size: 11px; font-weight: 500; padding: 4px 6px; }
.ghost-move { opacity: .85; box-shadow: var(--shadow-2) !important; }
.handle { position: absolute; z-index: 2; }
.handle-e { top: 0; right: 0; width: 8px; height: 100%; cursor: ew-resize; }
.handle-s { left: 0; bottom: 0; height: 8px; width: 100%; cursor: ns-resize; }
.handle:hover { background: rgba(0,0,0,.14); }

/* while dragging nothing may be selected (Safari selects text under a pointer drag) */
body.is-dragging, body.is-dragging * { user-select: none !important; -webkit-user-select: none !important; cursor: grabbing; }
.lane-area, .daycol, .rowlabel, .slot, .timelabel, .daycol-head { -webkit-user-select: none; user-select: none; }

/* ---------- calendar view ---------- */
.cal { display: flex; flex-direction: column; }
.cal-head { display: flex; position: sticky; top: var(--appbar-h); z-index: 3; background: var(--surface); border-bottom: 1px solid var(--line); }
.timecol-spacer, .timecol { flex: none; width: 56px; }
.timecol-spacer { border-right: 1px solid var(--line); }
.daycol-head { flex: 1; padding: 10px 6px 8px; text-align: center; min-width: 0; border-left: 1px solid var(--line); }
.daycol-head:first-of-type { border-left: 0; }
.dc-name { font-size: 11px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.dc-date { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; font-size: 22px; font-weight: 400; margin-top: 2px; color: var(--ink); }
.daycol-head.today .dc-name { color: var(--blue); }
.daycol-head.today .dc-date { background: var(--blue); color: #fff; font-weight: 500; }
.dc-count { min-height: 16px; font-size: 11px; color: var(--muted); }
.cal-body { display: flex; position: relative; }
.timecol { position: relative; border-right: 1px solid var(--line); }
.timelabel { position: absolute; right: 8px; transform: translateY(-50%); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.daycol {
  flex: 1; position: relative; border-left: 1px solid var(--line); min-width: 0; cursor: crosshair;
  background-image: linear-gradient(to bottom, var(--line) 1px, transparent 1px);
  background-size: 100% var(--hourh);
  background-position: 0 var(--hourofs);
}
.daycol:first-of-type { border-left: 0; }
body.logged-out .daycol { cursor: default; }
.daycol .lesson-meta { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: var(--lines, 1); overflow: hidden; white-space: normal; line-height: 14px; }
.daycol .lesson-meta span { display: block; overflow: visible; }
.daycol .lesson.narrow { padding: 3px 5px; }
.daycol .lesson.narrow .lesson-meta { display: none; }
.daycol .lesson.narrow .lesson-flags { display: none; }
.now-line-h { position: absolute; left: 0; right: 0; height: 2px; background: var(--red); z-index: 4; pointer-events: none; }
.now-line-h::before { content: ''; position: absolute; left: -6px; top: -5px; width: 12px; height: 12px; border-radius: 50%; background: var(--red); }

/* ---------- rooms view ---------- */
.rooms { display: flex; flex-direction: column; }
.day { border-bottom: 8px solid var(--surface-2); }
.day-head { display: flex; align-items: center; gap: 12px; height: 48px; padding: 0 16px; border-bottom: 1px solid var(--line); position: sticky; top: var(--appbar-h); background: var(--surface); z-index: 4; }
.day-head h2 { font-size: 15px; font-weight: 500; }
.day.today .day-head h2 { color: var(--blue-ink); }
.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 10px; background: var(--hover); color: var(--muted); font-size: 11px; font-weight: 500; }
.today-badge { background: var(--blue-soft); color: var(--blue-ink); }
.grid { overflow-x: auto; position: relative; }
.row { display: flex; min-width: max-content; border-bottom: 1px solid var(--line-soft); }
.row:last-child { border-bottom: 0; }
.row.archived .rowlabel { opacity: .6; font-style: italic; }
.rowlabel {
  flex: none; width: var(--labelw); padding: 4px 12px; font-size: 13px; overflow-wrap: break-word; position: sticky; left: 0; z-index: 2;
  background: var(--surface); border-right: 1px solid var(--line); display: flex; align-items: center; overflow: hidden; line-height: 1.25;
}
/* long space names: at most 2 lines so every row keeps the same height (full name in the tooltip) */
.rowlabel-text { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.timerow { background: var(--surface); border-bottom: 1px solid var(--line); }
.slots { display: flex; height: 28px; }
.slot { flex: none; width: var(--slotw); border-left: 1px solid transparent; position: relative; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.slot.hour { border-left-color: var(--line); }
.slot span { position: absolute; left: 4px; top: 6px; white-space: nowrap; }
.slot.half span { font-size: 10px; opacity: .7; }
.lane-area {
  position: relative; flex: 1; min-width: calc(var(--slotw) * 36);
  background-image: linear-gradient(to right, var(--line) 1px, transparent 1px);
  background-size: var(--hourw) 100%;
  background-position: var(--hourofs) 0;
  cursor: crosshair;
}
body.logged-out .lane-area { cursor: default; }
.now-line-v { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--red); z-index: 4; pointer-events: none; }
.now-line-v::before { content: ''; position: absolute; top: 0; left: -5px; width: 12px; height: 12px; border-radius: 50%; background: var(--red); }

/* ---------- day tabs (phone) ---------- */
.daytabs { display: flex; gap: 4px; padding: 8px 8px 0; position: sticky; top: var(--appbar-h); background: var(--surface); z-index: 5; border-bottom: 1px solid var(--line); }
.daytab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px 8px; border: 0; background: transparent; cursor: pointer; border-radius: 8px 8px 0 0; color: var(--muted); }
.daytab .dt-name { font-size: 11px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; }
.daytab .dt-date { width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 15px; color: var(--ink); }
.daytab.active .dt-name { color: var(--blue); }
.daytab.active .dt-date { background: var(--blue); color: #fff; font-weight: 500; }
.daytab.is-today:not(.active) .dt-date { color: var(--blue); font-weight: 500; box-shadow: inset 0 0 0 1px var(--blue); }

/* ---------- week bar (bottom) ---------- */
.weekbar {
  position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--weekbar-h) + env(safe-area-inset-bottom)); z-index: 30;
  display: flex; align-items: center; gap: 12px; padding: 0 16px 0 12px; padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
.weekbar-nav { display: flex; align-items: center; gap: 2px; flex: none; }
.weekbar-nav .btn { margin: 0 4px; }
.weektabs { flex: 1; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 4px 10px; scroll-snap-type: x mandatory; -webkit-mask-image: linear-gradient(to right, transparent, #000 10px, #000 calc(100% - 10px), transparent); mask-image: linear-gradient(to right, transparent, #000 10px, #000 calc(100% - 10px), transparent); }
.weektabs::-webkit-scrollbar { display: none; }
.weektab {
  flex: none; display: flex; flex-direction: column; align-items: flex-start; min-width: 104px; padding: 4px 12px; border-radius: var(--radius);
  border: 1px solid transparent; background: transparent; cursor: pointer; line-height: 1.25; color: var(--ink-2); transition: background-color .12s ease; scroll-snap-align: start;
}
.weektab:hover { background: var(--hover); }
.weektab.current { border-color: var(--line); }
.weektab.active { background: var(--blue-soft); color: var(--blue-ink); border-color: transparent; }
.wt-num { font-weight: 500; font-size: 13px; }
.wt-range { font-size: 11px; color: var(--muted); white-space: nowrap; }
.weektab.active .wt-range { color: var(--blue-ink); opacity: .85; }
.weekpick-wrap { position: relative; flex: none; }
.weekpick { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border: 0; background: transparent; font: inherit; cursor: pointer; border-radius: var(--radius); font-weight: 500; color: var(--ink-2); }
.weekpick:hover, .weekpick[aria-expanded=true] { background: var(--hover); }
.weekpick .icon { color: var(--muted); }
/* week picker popover: opens upwards from the bottom bar */
.weekpop { position: absolute; right: 0; bottom: calc(100% + 10px); width: 296px; padding: 8px 8px 10px; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-3); z-index: 40; animation: pop .12s ease-out; }
.weekpop[hidden] { display: none; }
.wp-head { display: flex; align-items: center; justify-content: space-between; padding: 0 0 6px; }
.wp-title { font-weight: 500; }
.wp-row { display: grid; grid-template-columns: 34px repeat(7, 1fr); align-items: center; width: 100%; height: 34px; border: 0; background: transparent; font: inherit; color: var(--ink-2); border-radius: var(--radius); cursor: pointer; padding: 0; }
.wp-row:not(.wp-labels):hover { background: var(--hover); }
.wp-row.current { box-shadow: inset 0 0 0 1px var(--line); }
.wp-row.selected { background: var(--blue-soft); color: var(--blue-ink); box-shadow: none; }
.wp-labels { height: 26px; cursor: default; font-size: 11px; color: var(--muted); }
.wp-wk { font-size: 11px; color: var(--muted); text-align: center; }
.wp-day { text-align: center; font-size: 13px; }
.wp-day.out { color: var(--muted); opacity: .6; }
.wp-day.today { font-weight: 700; color: var(--blue); }

/* ---------- modals ---------- */
.overlay { position: fixed; inset: 0; background: rgba(32, 33, 36, .5); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal { background: var(--surface); border-radius: 12px; width: 100%; max-width: 560px; max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px); display: flex; flex-direction: column; box-shadow: var(--shadow-3); animation: pop .14s ease-out; }
.modal.wide { max-width: 840px; }
@keyframes pop { from { transform: translateY(6px) scale(.985); opacity: 0; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 12px 12px 24px; }
.modal-head-actions { display: flex; align-items: center; gap: 8px; }
.modal-head h3 { font-size: 20px; font-weight: 500; letter-spacing: -.01em; }
.modal-body { padding: 4px 24px 20px; overflow: auto; }
.modal-foot { display: flex; gap: 8px; align-items: center; padding: 12px 24px 20px; }
.form-grid { display: grid; gap: 14px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: grid; gap: 6px; }
.field-label { font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: .02em; }
.field select, .field input:not([type=checkbox]):not([type=radio]), .field textarea { width: 100%; }
.hint { font-size: 12px; color: var(--muted); line-height: 1.4; }
.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.repeat-box { margin-top: 6px; padding: 12px; background: var(--surface-2); border-radius: var(--radius); display: grid; gap: 8px; }
.form-error { color: var(--red); font-size: 13px; background: var(--red-soft); padding: 10px 12px; border-radius: var(--radius); }
.info { background: var(--blue-soft); color: var(--blue-ink); padding: 10px 12px; border-radius: var(--radius); font-size: 13px; }
.help-list { display: grid; gap: 4px; padding-left: 18px; margin: 0; }
.help-list strong { color: var(--ink-2); font-weight: 500; }
.warn-box { background: var(--amber-soft); color: var(--amber-ink); padding: 10px 12px; border-radius: var(--radius); font-size: 13px; }
.temp-pw { display: flex; gap: 8px; align-items: center; }
.temp-pw code { flex: 1; font: 500 20px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .06em; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); user-select: all; }
.stack { display: grid; gap: 10px; }
.stack h4 { margin-top: 12px; font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.details { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; }
.details dt { color: var(--muted); font-size: 12px; padding-top: 2px; }
.details dd { margin: 0; white-space: pre-wrap; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px 0 10px; border-radius: 16px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2); cursor: pointer; font-size: 13px; font-weight: 500; transition: background-color .12s ease, border-color .12s ease;
}
.chip:hover { background: var(--hover); }
.chip.on { background: var(--blue-soft); border-color: transparent; color: var(--blue-ink); }
.chip .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--dot, currentColor); flex: none; }
.chip.on .dot { box-shadow: 0 0 0 2px var(--surface); }
.chip.colored.on { color: var(--chip-ink); background: var(--dot); }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; }
.swatch.big { width: 24px; height: 24px; border-radius: 6px; flex: none; }
.legend-item { display: inline-flex; align-items: center; gap: 8px; }

/* subscribe */
.sub-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.sub-label { font-weight: 500; font-size: 13px; }
.sub-row select { width: 100%; }
.sub-actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
.outlook-callout { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.outlook-callout .btn { flex: none; }
.outlook-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 20px; }
.outlook-step p { display: flex; align-items: baseline; gap: 10px; margin: 0; line-height: 1.5; }
.outlook-step .step-num { flex: none; display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--blue-soft); color: var(--blue-ink); font-size: 12px; font-weight: 600; }
.outlook-step img { display: block; width: 100%; height: auto; margin-top: 10px; border: 1px solid var(--line); border-radius: var(--radius); }
@media (max-width: 600px) { .outlook-callout { flex-direction: column; align-items: flex-start; } }

/* manage */
.manage { display: grid; gap: 16px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { height: 44px; padding: 0 14px; border: 0; background: transparent; cursor: pointer; color: var(--muted); font-weight: 500; box-shadow: inset 0 -3px 0 transparent; margin-bottom: -1px; white-space: nowrap; border-radius: 6px 6px 0 0; }
.tab:hover { background: var(--hover); color: var(--ink); }
.tab.active { color: var(--blue-ink); box-shadow: inset 0 -3px 0 var(--blue); }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-form input:not([type=color]):not([type=checkbox]) { flex: 1; min-width: 140px; }
.list { display: grid; gap: 2px; }
.list-row { display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 6px 8px 6px 12px; border-radius: var(--radius); }
.list-row:hover { background: var(--surface-2); }
.list-row.archived { opacity: .55; }
.list-row strong { font-weight: 500; }

/* toast */
#toast { position: fixed; left: 24px; bottom: calc(var(--weekbar-h) + 16px); transform: translateY(12px); background: #323232; color: #fff; padding: 12px 16px; border-radius: 6px; box-shadow: var(--shadow-2); opacity: 0; transition: .18s ease; z-index: 100; max-width: min(92vw, 560px); font-size: 14px; pointer-events: none; }
#toast.show { opacity: 1; transform: translateY(0); }
#toast.ok { background: #1e3a2a; }
#toast.error { background: var(--red); }
#toast.warn { background: #5d3f00; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  :root { --sidebar-w: 232px; }
  .rowlabel { font-size: 12px; padding: 4px 8px; }
  .searchbox { max-width: 280px; }
}
@media (max-width: 900px) {
  .brand-name { display: none; }
  .btn span:not(.count) { display: none; }
  .btn .icon { margin: 0; }
  .btn.guest-only { padding: 0 12px; }
  .btn.guest-only span { display: inline; }
  .menu-btn #user-name { display: none; }
}
@media (max-width: 720px) {
  :root { --appbar-h: 56px; --weekbar-h: 64px; }
  .appbar { gap: 8px; padding: 0 8px; }
  .brand { margin-right: 0; }
  .searchbox { height: 36px; padding: 0 10px; }
  .appbar-actions { gap: 6px; }
  .appbar-actions .btn { padding: 0 10px; }
  .viewswitch { display: none; }
  .mobile-dayline { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px 6px; font-size: 14px; font-weight: 500; }
  .searchbox { margin-left: 0; max-width: none; }
  .mobile-only { display: inline-flex !important; }
  .sidebar { display: none; }
  .shell { display: block; }
  .row-2 { grid-template-columns: 1fr; }
  .modal { max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); border-radius: 12px 12px 8px 8px; }
  .overlay { padding: 8px; padding-top: max(8px, env(safe-area-inset-top)); padding-bottom: max(8px, env(safe-area-inset-bottom)); align-items: flex-end; }
  .weekbar { gap: 6px; padding: 0 8px; padding-bottom: env(safe-area-inset-bottom); }
  .weekbar-nav .btn { padding: 0 12px; margin: 0 2px; }
  .weekpick .weeklabel-text { display: none; }
  .weekpick { width: 40px; padding: 0; justify-content: center; }
  .weekpop { right: -4px; }
  .weektab { min-width: 92px; padding: 3px 10px; }
  .timecol-spacer, .timecol { width: 48px; }
  .timelabel { right: 6px; }
  .cal-head { top: calc(var(--appbar-h) + 63px); }
  #toast { left: 12px; right: 12px; max-width: none; }
}

/* ---------- print ---------- */
@media print {
  .appbar, .weekbar, .sidebar, #toast, .handle, .now-line-v, .now-line-h, .daytabs { display: none !important; }
  body { padding: 0; background: #fff; color: #000; }
  .shell { display: block; min-height: 0; }
  .day { break-inside: avoid; border-bottom: 1px solid #999; }
  .day-head, .timerow, .cal-head { position: static; }
  .grid { overflow: visible; }
  .lesson { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .lesson.dim { opacity: .3; }
}
