/* Layout: sticky top bar + tab strip; the schedule is an agenda column (start side, RTL) beside the day panel,
   stacking into one column under 960px. Track colours carry meaning everywhere a section appears. */
:root {
  --bg: #f3f6f5;
  --surface: #ffffff;
  --surface-2: #edf2f0;
  --surface-3: #e1e8e5;
  --line: #d6dfdb;
  --line-strong: #b4c2bd;
  --ink: #14211e;
  --ink-2: #41514c;
  --ink-3: #6b7a75;
  --accent: #0b6b5d;
  --accent-strong: #075247;
  --accent-soft: #d9eee8;
  --on-accent: #ffffff;
  --live: #cc2f2f;
  --live-soft: #fbe2df;
  --warn: #8f5a00;
  --warn-soft: #faeed5;
  --danger: #b3261e;
  --danger-soft: #fbe5e3;
  --ok: #24733f;
  --t0: #2e6bb0; --t1: #b0532a; --t2: #6c4da6; --t3: #2a8452;
  --t4: #a57a17; --t5: #b8416f; --t6: #2b8796; --t7: #66707d;
  --t-none: #9aa6a2;
  --on-track: #ffffff;
  --shadow: 0 1px 2px rgb(16 32 28 / .06), 0 10px 28px -16px rgb(16 32 28 / .22);
  --radius: 12px;
  --radius-sm: 7px;
  --font-display: "Reem Kufi", "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --font-body: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, "Noto Sans Arabic", system-ui, sans-serif;
  --font-data: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1513; --surface: #141d1b; --surface-2: #1a2522; --surface-3: #22302c;
    --line: #29372f; --line-strong: #3d4f48;
    --ink: #e3ebe8; --ink-2: #b0beb9; --ink-3: #83928d;
    --accent: #45b9a3; --accent-strong: #66d0bb; --accent-soft: #163a33; --on-accent: #06211c;
    --live: #ff6a61; --live-soft: #3d1b19; --warn: #e8b04c; --warn-soft: #3a2c12;
    --danger: #ff7b72; --danger-soft: #3d1b19; --ok: #6fd08f;
    --t0: #6ea5e6; --t1: #e58c5f; --t2: #a98ae2; --t3: #5ec38b;
    --t4: #dbb04f; --t5: #e47fab; --t6: #5fc0cd; --t7: #9ca6b3;
    --t-none: #66746f; --on-track: #0b1311;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 12px 30px -16px rgb(0 0 0 / .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1513; --surface: #141d1b; --surface-2: #1a2522; --surface-3: #22302c;
  --line: #29372f; --line-strong: #3d4f48;
  --ink: #e3ebe8; --ink-2: #b0beb9; --ink-3: #83928d;
  --accent: #45b9a3; --accent-strong: #66d0bb; --accent-soft: #163a33; --on-accent: #06211c;
  --live: #ff6a61; --live-soft: #3d1b19; --warn: #e8b04c; --warn-soft: #3a2c12;
  --danger: #ff7b72; --danger-soft: #3d1b19; --ok: #6fd08f;
  --t0: #6ea5e6; --t1: #e58c5f; --t2: #a98ae2; --t3: #5ec38b;
  --t4: #dbb04f; --t5: #e47fab; --t6: #5fc0cd; --t7: #9ca6b3;
  --t-none: #66746f; --on-track: #0b1311;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 12px 30px -16px rgb(0 0 0 / .6);
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-underline-offset: 3px; }
h1, h2, h3 { margin: 0; text-wrap: balance; line-height: 1.3; }
h2 { font-size: 1.12rem; font-weight: 700; }
h3 { font-size: .98rem; font-weight: 600; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--ink-3); }
.meta { color: var(--ink-3); font-size: .84rem; }
.spacer { flex: 1 1 auto; }
.mono { font-family: var(--font-data); font-variant-numeric: tabular-nums; font-size: .92em; unicode-bidi: isolate; direction: ltr; }
.trange { display: inline-flex; gap: .3em; align-items: baseline; white-space: nowrap; }
.trange .dash { color: var(--ink-3); }
.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hint-line { color: var(--ink-3); font-size: .86rem; }
.eyebrow { color: var(--ink-3); font-size: .78rem; font-weight: 600; letter-spacing: .02em; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 38px; padding: 0 .9rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
  font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--line-strong); }
.btn-sm { min-height: 32px; padding: 0 .7rem; font-size: .88rem; }
.btn-sm .ic { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--line); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--surface); }
.btn-danger:hover { filter: brightness(1.08); }
.btn-quiet-danger { color: var(--danger); }
.btn-quiet-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn:disabled { opacity: .3; cursor: default; background: transparent; }
.linkish { border: 0; padding: 0; background: none; color: var(--accent); cursor: pointer; text-align: start; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- chips & pills ---------- */
.chip {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .1rem .55rem; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line);
  color: var(--ink-2); font-size: .8rem; font-weight: 500; white-space: nowrap; text-decoration: none;
}
.chip .ic { width: 13px; height: 13px; }
.chip-sm { font-size: .74rem; padding: 0 .45rem; }
.chip-link:hover { border-color: var(--accent); color: var(--accent); }
.chip-warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.chip-accent { background: var(--accent-soft); border-color: transparent; color: var(--accent-strong); }
.tchip {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: 0 .5rem; border-radius: 999px; font-size: .76rem; font-weight: 500; white-space: nowrap;
  background: color-mix(in srgb, var(--tc) 14%, transparent); color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--tc) 40%, transparent);
}
.tchip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--tc); }
.track-chips { display: flex; flex-wrap: wrap; gap: .3rem; }

.pill {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .05rem .5rem; border-radius: 999px;
  font-size: .72rem; font-weight: 600; letter-spacing: .01em; white-space: nowrap;
}
.pill-live { background: var(--live); color: var(--surface); }
.pill-upcoming { background: var(--accent-soft); color: var(--accent-strong); }
.pill-ended { background: var(--surface-3); color: var(--ink-3); }
.pill-draft { background: var(--warn-soft); color: var(--warn); }
.pill-cancelled { background: var(--surface-3); color: var(--ink-3); text-decoration: line-through; }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar-row, .tabs {
  max-width: 1320px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.topbar-row { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem .75rem; padding-block: .6rem; }
.brand { display: inline-flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--ink); }
.brand-mark { width: 30px; height: 30px; }
.brand-mark .bm-a { fill: var(--t0); }
.brand-mark .bm-b { fill: var(--accent); }
.brand-mark .bm-c { fill: var(--t1); }
.brand-mark .bm-live { fill: var(--live); }
.brand-name { font-family: var(--font-display); font-size: 1.3rem; font-weight: 700; letter-spacing: 0; }
.brand-tag { font-size: .7rem; color: var(--ink-3); border: 1px solid var(--line); border-radius: 999px; padding: 0 .45rem; }
.program-picker select {
  max-width: min(360px, 70vw); min-height: 36px; padding: 0 .7rem 0 2rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2);
  font-weight: 600;
}
.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-pop {
  position: absolute; inset-inline-end: 0; top: calc(100% + 6px); z-index: 30;
  min-width: 270px; padding: .35rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  display: grid;
}
.menu-pop button {
  border: 0; background: none; text-align: start; padding: .5rem .7rem; border-radius: var(--radius-sm); cursor: pointer;
}
.menu-pop button:hover:not(:disabled) { background: var(--surface-2); }
.menu-pop button:disabled { opacity: .45; cursor: default; }
.menu-pop button.danger { color: var(--danger); }
.menu-pop hr { border: 0; border-top: 1px solid var(--line); margin: .3rem 0; }
.tabs { display: flex; gap: .25rem; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: 0; background: none; cursor: pointer; white-space: nowrap;
  padding: .55rem .8rem .65rem; color: var(--ink-2); font-weight: 500;
  border-bottom: 2.5px solid transparent;
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--ink); font-weight: 700; border-bottom-color: var(--accent); }

/* ---------- page ---------- */
.page {
  max-width: 1320px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 20px calc(48px + env(safe-area-inset-bottom, 0px));
  display: grid; gap: 18px;
}
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; display: grid; gap: 12px; align-content: start; min-width: 0;
}
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.block-head { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem .6rem; }
.page-head h2 { font-size: 1.25rem; }
.empty {
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius); padding: 18px;
  color: var(--ink-2); background: var(--surface-2); font-size: .92rem;
}
.empty-tall { min-height: 240px; display: grid; place-items: center; text-align: center; }
.empty-sm { color: var(--ink-3); font-size: .86rem; }
.callout {
  border-radius: var(--radius-sm); padding: 10px 12px; font-size: .88rem;
  background: var(--accent-soft); color: var(--ink);
}
.welcome { max-width: 640px; justify-self: center; padding: 28px; gap: 14px; }
.welcome h2 { font-family: var(--font-display); font-size: 1.6rem; }

/* ---------- summary strip ---------- */
.summary { display: grid; grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr)); gap: 12px; }
.sum-card {
  display: grid; gap: 2px; align-content: start; text-align: start; min-width: 0;
  padding: 14px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
}
button.sum-card { cursor: pointer; font: inherit; color: inherit; }
button.sum-card:hover { border-color: var(--line-strong); }
.sum-label { color: var(--ink-3); font-size: .78rem; font-weight: 600; }
.sum-title { font-family: var(--font-display); font-size: 1.25rem; font-weight: 600; line-height: 1.35; }
.sum-num { font-family: var(--font-display); font-size: 1.55rem; font-weight: 600; line-height: 1.25; }
.sum-sub { color: var(--ink-2); font-size: .84rem; }
.sum-next { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); background: linear-gradient(to left, var(--accent-soft), var(--surface) 70%); }
.sum-next.is-live { border-color: var(--live); background: linear-gradient(to left, var(--live-soft), var(--surface) 70%); }
.sum-card.is-warn .sum-num { color: var(--warn); }
.sum-card.is-ok .sum-num { color: var(--ok); }

.alerts {
  border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent); background: var(--warn-soft);
  border-radius: var(--radius); padding: 12px 16px; display: grid; gap: 6px;
}
.alerts h2 { display: flex; align-items: center; gap: .4rem; font-size: .95rem; color: var(--warn); }
.alerts ul { display: grid; gap: 4px; padding-inline-start: 1.6rem; list-style: disc; }
.alerts .linkish { color: var(--ink); }

/* ---------- schedule layout ---------- */
.schedule { display: grid; grid-template-columns: minmax(300px, 390px) minmax(0, 1fr); gap: 18px; align-items: start; }
.agenda { display: grid; gap: 14px; min-width: 0; }
.agenda-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.agenda-head h2 { font-family: var(--font-display); font-size: 1.2rem; font-weight: 600; }
.week { display: grid; gap: 8px; }
.week-label { display: flex; align-items: center; gap: .5rem; font-size: .8rem; font-weight: 600; color: var(--ink-3); }
.week-now { color: var(--accent-strong); background: var(--accent-soft); border-radius: 999px; padding: 0 .5rem; }
.daylist { display: grid; gap: 8px; }

.dayrow {
  width: 100%; display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 12px;
  padding: 12px; text-align: start; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  transition: border-color .15s, box-shadow .15s;
}
.dayrow:hover { border-color: var(--line-strong); }
.dayrow.is-selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.dayrow.st-ended .dr-title, .dayrow.st-cancelled .dr-title { color: var(--ink-2); }
.dayrow.st-live { border-color: var(--live); }
.dr-date {
  display: grid; justify-items: center; align-content: start; gap: 0;
  padding: 6px 0; border-radius: var(--radius-sm); background: var(--surface-2);
}
.dr-dow { font-size: .7rem; color: var(--ink-3); font-weight: 600; }
.dr-num { font-family: var(--font-display); font-size: 1.6rem; font-weight: 600; line-height: 1.15; font-variant-numeric: tabular-nums; }
.dr-mon { font-size: .72rem; color: var(--ink-2); }
.dr-main { display: grid; gap: 4px; min-width: 0; }
.dr-top { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.dr-n { font-size: .74rem; color: var(--ink-3); font-weight: 600; }
.dr-warn { display: inline-flex; align-items: center; gap: 2px; color: var(--warn); font-size: .76rem; font-weight: 600; }
.dr-warn .ic { width: 14px; height: 14px; }
.dr-title { font-weight: 600; line-height: 1.4; }
.dr-meta { display: flex; align-items: center; flex-wrap: wrap; gap: .3rem; color: var(--ink-2); font-size: .82rem; }
.dr-meta .sep { color: var(--ink-3); }
.dr-meta .chip { font-size: .7rem; padding: 0 .4rem; }

/* section bars: solid = topic, striped = activity, hatched grey = break; colour = track */
.minibar, .tl-segs { display: flex; gap: 2px; overflow: hidden; }
.minibar { height: 8px; border-radius: 4px; margin-top: 4px; }
.minibar.is-empty { background: repeating-linear-gradient(-45deg, var(--surface-3) 0 4px, transparent 4px 8px); }
.seg { flex-basis: 0; min-width: 0; position: relative; background: var(--tc, var(--t-none)); }
.seg-activity {
  background: repeating-linear-gradient(-45deg, var(--tc) 0 5px, color-mix(in srgb, var(--tc) 62%, var(--surface)) 5px 9px);
}
.seg-break { background: repeating-linear-gradient(-45deg, var(--line-strong) 0 2px, var(--surface-2) 2px 6px); }

/* ---------- day panel ---------- */
.daypanel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; display: grid; gap: 18px; min-width: 0; scroll-margin-top: 110px;
}
.dp-head { display: grid; gap: 8px; }
.dp-eyebrow { display: flex; align-items: center; gap: .5rem; color: var(--ink-3); font-size: .82rem; font-weight: 600; }
.dp-title { font-family: var(--font-display); font-size: clamp(1.4rem, 1.1rem + 1vw, 1.9rem); font-weight: 600; }
.dp-when { display: flex; flex-wrap: wrap; gap: .25rem 1rem; color: var(--ink-2); }
.dp-desc { color: var(--ink-2); max-width: 65ch; }
.streams { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.dp-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: 4px; }

.issues {
  display: grid; gap: 4px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--warn-soft); color: var(--ink); font-size: .88rem;
}
.issues li { display: flex; gap: .45rem; align-items: flex-start; }
.issues .ic { color: var(--warn); width: 16px; height: 16px; margin-top: 3px; }
.issue-inline { display: flex; gap: .4rem; align-items: center; color: var(--warn); font-size: .84rem; }
.issue-inline .ic { width: 16px; height: 16px; }

.dp-block { display: grid; gap: 12px; align-content: start; min-width: 0; }
.dp-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 22px; padding-top: 18px; border-top: 1px solid var(--line); }

/* big timeline */
.tl { display: grid; gap: 6px; }
.tl-bar { position: relative; height: 46px; margin-top: 14px; }
.tl-segs { height: 100%; gap: 3px; border-radius: 8px; }
.tl-segs .seg { display: flex; align-items: center; overflow: hidden; }
.seg-label {
  padding-inline: 8px; color: var(--on-track); font-size: .78rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.seg-activity .seg-label { text-shadow: 0 0 3px var(--tc), 0 0 6px var(--tc); }
.tl-now {
  position: absolute; top: -6px; bottom: -6px; width: 2px; margin-inline-start: -1px;
  background: var(--live); border-radius: 2px; pointer-events: none;
}
.tl-now span {
  position: absolute; top: -18px; inset-inline-start: 50%; transform: translateX(50%);
  background: var(--live); color: var(--surface); font-size: .66rem; font-weight: 700;
  padding: 0 .35rem; border-radius: 4px; white-space: nowrap;
}
.tl-ticks { position: relative; height: 18px; color: var(--ink-3); font-family: var(--font-data); font-size: .74rem; font-variant-numeric: tabular-nums; }
.tl-ticks .tick { position: absolute; top: 0; transform: translateX(50%); }
.tl-ticks .tick:first-child { transform: none; }
.tl-ticks .tick-end { inset-inline-end: 0; transform: none; }
.tl-legend { display: flex; flex-wrap: wrap; gap: .3rem 1rem; color: var(--ink-2); font-size: .78rem; }
.tl-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.lg { display: inline-block; width: 18px; height: 10px; border-radius: 2px; }
.lg-topic { background: var(--ink-2); }
.lg-activity { background: repeating-linear-gradient(-45deg, var(--ink-2) 0 3px, var(--surface-3) 3px 6px); }
.lg-break { background: repeating-linear-gradient(-45deg, var(--line-strong) 0 2px, var(--surface-2) 2px 5px); border: 1px solid var(--line); }

/* section rows */
.sections { display: grid; gap: 6px; }
.sec {
  display: grid; align-items: center; gap: 10px;
  grid-template-columns: 18px 52px 4px minmax(0, 1fr) auto auto;
  grid-template-areas: "grip time swatch body dur actions";
  padding: 8px 6px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--line);
}
.sec-grip { grid-area: grip; color: var(--ink-3); cursor: grab; display: grid; place-items: center; }
.sec-grip .ic { width: 16px; height: 16px; stroke-width: 3; }
.sec-time { grid-area: time; display: grid; line-height: 1.35; font-size: .9rem; }
.sec-time .muted { font-size: .8rem; }
.sec-body { grid-area: body; display: grid; gap: 1px; min-width: 0; }
.sec-kind { color: var(--ink-3); font-size: .78rem; display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; }
.sec-track { color: var(--ink); font-weight: 600; }
.sec-main { font-weight: 600; line-height: 1.4; }
.sec-sub { color: var(--ink-2); font-size: .82rem; }
.sec-dur { grid-area: dur; font-family: var(--font-data); font-size: .82rem; color: var(--ink-2); white-space: nowrap; }
.sec-actions { grid-area: actions; display: flex; gap: 0; }
.sec-actions .icon-btn { width: 30px; height: 30px; }
.sec-actions .ic { width: 16px; height: 16px; }
.sec-swatch { grid-area: swatch; align-self: stretch; border-radius: 2px; background: var(--tc); }
.sec-activity .sec-swatch { background: repeating-linear-gradient(-45deg, var(--tc) 0 3px, transparent 3px 6px); }
.sec-break { background: var(--surface-2); }
.sec-break .sec-main { font-weight: 500; color: var(--ink-2); }
.sec.is-live { border-color: var(--live); box-shadow: 0 0 0 1px var(--live); }
.sec.is-dragging { opacity: .45; }
.sec.drop-before { box-shadow: 0 -3px 0 0 var(--accent); }
.sec.drop-after { box-shadow: 0 3px 0 0 var(--accent); }

/* notes */
.note-form { display: grid; gap: 8px; }
.note-form textarea, .note-row select, .note-row input {
  width: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2); padding: .5rem .65rem; resize: vertical;
}
.note-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; gap: 6px; }
.note-row select, .note-row input { min-height: 32px; padding-block: .25rem; font-size: .88rem; }
.notes { display: grid; gap: 8px; }
.notes li {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px;
  padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2);
}
.notes p { grid-column: 1; }
.notes .meta { grid-column: 1; display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.notes .icon-btn { grid-column: 2; grid-row: 1 / span 2; align-self: start; }

/* exams */
.exam-list { display: grid; gap: 8px; }
.exam {
  display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 12px; align-items: start;
  padding: 10px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface);
}
.exam-date { display: grid; justify-items: center; padding: 4px 0; border-radius: var(--radius-sm); background: var(--surface-2); }
.exam-body { display: grid; gap: 4px; min-width: 0; }
.exam-body .meta { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.row-actions { display: flex; align-items: center; gap: 0; }

/* ratings */
.stars { display: inline-flex; gap: 1px; color: var(--line-strong); }
.stars .ic { width: 15px; height: 15px; }
.star.on { fill: var(--t4); stroke: var(--t4); }
.rating-sum { display: flex; align-items: center; gap: .6rem; }
.rating-sum strong { font-size: 1.5rem; font-family: var(--font-display); }
.ratings { display: grid; gap: 6px; }
.ratings li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 8px; align-items: center; font-size: .88rem; }
.r-text { color: var(--ink-2); }

/* attachments */
.att-list { display: grid; gap: 8px; }
.att-list li { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: start; }
.att-kind {
  display: inline-block; font-size: .7rem; font-weight: 600; color: var(--ink-2);
  border: 1px solid var(--line); border-radius: 4px; padding: 0 .35rem; white-space: nowrap;
}
.att-body { display: grid; gap: 4px; min-width: 0; }
.att-links { display: flex; flex-wrap: wrap; gap: .3rem; }

/* ---------- structure ---------- */
.program-card { grid-template-columns: minmax(0, 1fr) auto; align-items: start; }
.pc-main { display: grid; gap: 6px; min-width: 0; }
.pc-title { font-family: var(--font-display); font-size: 1.6rem; font-weight: 600; }
.pc-meta { color: var(--ink-2); font-size: .9rem; }
.pc-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.ent-list { display: grid; gap: 8px; }
.ent {
  display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 12px; align-items: start;
  padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--line);
}
.ent .swatch { align-self: stretch; border-radius: 3px; background: var(--tc); }
.ent-body { display: grid; gap: 2px; min-width: 0; }
.ent-body .muted { font-size: .86rem; }
.swatch-sm { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--tc); margin-inline-end: .35rem; }
.topic-list { display: grid; gap: 10px; }
.topic { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; display: grid; gap: 8px; }
.topic-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: start; }
.act-list { display: grid; gap: 4px; padding-inline-start: 10px; border-inline-start: 2px solid var(--line); }
.act-list li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: center; font-size: .9rem; }
.act-empty { font-size: .86rem; justify-self: start; }
.kind { font-size: .7rem; font-weight: 600; padding: 0 .4rem; border-radius: 4px; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; }
.kind-questions { background: var(--accent-soft); color: var(--accent-strong); }
.kind-discussion { background: color-mix(in srgb, var(--t2) 16%, transparent); color: var(--ink); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.matrix, .list-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.matrix th, .matrix td, .list-table th, .list-table td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: start; white-space: nowrap; }
.matrix thead th, .list-table thead th { background: var(--surface-2); font-size: .8rem; color: var(--ink-2); font-weight: 600; }
.matrix tbody th { font-weight: 600; }
.matrix td { font-family: var(--font-data); font-variant-numeric: tabular-nums; font-size: .82rem; border-inline-start: 1px solid var(--line); }
.matrix .cv-empty { color: var(--ink-3); text-align: center; }
.matrix .cv-total { background: var(--surface-2); font-weight: 500; }
.matrix tfoot th, .matrix tfoot td { border-bottom: 0; background: var(--surface-2); }
.list-table tbody tr:last-child td { border-bottom: 0; }
.list-table td { white-space: normal; }

/* ---------- lecturers ---------- */
.lec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 14px; }
.lec { gap: 10px; }
.lec-head { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-strong); font-family: var(--font-display); font-size: 1.1rem; font-weight: 700;
}
.lec-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; }
.lec-stats div { background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 10px; min-width: 0; }
.lec-stats dt { font-size: .74rem; color: var(--ink-3); font-weight: 600; }
.lec-stats dd { margin: 0; font-size: .9rem; }

/* ---------- modal ---------- */
.modal {
  width: min(600px, calc(100vw - 24px)); max-height: calc(100vh - 32px);
  padding: 0; border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
}
.modal::backdrop { background: rgb(8 16 14 / .45); }
.mform { display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; max-height: calc(100vh - 34px); }
.mform-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 6px; }
.mform-head h2 { font-family: var(--font-display); font-size: 1.3rem; font-weight: 600; }
.mform-head .muted { font-size: .86rem; }
.mform-body { overflow-y: auto; padding: 10px 20px 16px; display: flex; flex-wrap: wrap; gap: 14px 12px; align-content: start; }
.mform-error { margin: 0 20px 10px; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--danger-soft); color: var(--danger); font-size: .9rem; }
.mform-foot { display: flex; align-items: center; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 14px 14px; }
.field { display: grid; gap: 5px; flex: 1 1 100%; min-width: 0; margin: 0; padding: 0; border: 0; }
.field.half { flex: 1 1 calc(50% - 6px); min-width: 180px; }
.field > label, .field > legend { font-size: .84rem; font-weight: 600; color: var(--ink-2); padding: 0; margin-bottom: 5px; }
.field > label { margin-bottom: 0; }
.req { color: var(--danger); }
.field input:not([type=radio]):not([type=checkbox]), .field select, .field textarea {
  width: 100%; min-height: 40px; padding: .45rem .7rem;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface);
}
.field textarea { resize: vertical; line-height: 1.6; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.hint { font-size: .8rem; color: var(--ink-3); }
.hint:empty { display: none; }
.field-html { flex: 1 1 100%; }
.field-html p + p { margin-top: 8px; }
.when-preview { padding: 8px 12px; border-radius: var(--radius-sm); background: var(--accent-soft); font-size: .9rem; }
.segmented { display: inline-flex; flex-wrap: wrap; gap: 0; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; width: fit-content; max-width: 100%; }
.segopt { position: relative; cursor: pointer; }
.segopt input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.segopt span { display: block; padding: .4rem .95rem; font-weight: 500; border-inline-start: 1px solid var(--line); }
.segopt:first-child span { border-inline-start: 0; }
.segopt input:checked + span { background: var(--accent); color: var(--on-accent); }
.segopt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -3px; }
.chip-group { font-size: .76rem; color: var(--ink-3); font-weight: 600; margin-top: 4px; }
.chip-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.pick { position: relative; cursor: pointer; }
.pick input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.pick span {
  display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .7rem; border-radius: 999px;
  border: 1px solid var(--line-strong); font-size: .86rem;
}
.pick[style] span::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--tc); }
.pick input:checked + span { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); font-weight: 600; }
.pick input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.sw { position: relative; width: 32px; height: 32px; border-radius: 50%; background: var(--tc); cursor: pointer; }
.sw input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.sw:has(input:checked) { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--tc); }
.sw:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 5px; }
.star-picker { display: flex; gap: 4px; }
.star-picker label { position: relative; cursor: pointer; color: var(--line-strong); }
.star-picker input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.star-picker .ic { width: 30px; height: 30px; }
.star-picker label.on .ic { fill: var(--t4); stroke: var(--t4); }
.star-picker label:has(input:focus-visible) { outline: 2px solid var(--accent); border-radius: 4px; }
.minutes { display: flex; align-items: center; gap: 8px; }
.minutes input { max-width: 120px; }
.presets { display: flex; flex-wrap: wrap; gap: 5px; }
.preset {
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px;
  padding: .1rem .6rem; font-size: .8rem; cursor: pointer;
}
.preset:hover { border-color: var(--line-strong); }
.preset.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.stream-rows { display: grid; gap: 6px; margin-bottom: 6px; }
.stream-row { display: grid; grid-template-columns: minmax(110px, 150px) minmax(0, 1fr) auto; gap: 6px; align-items: center; }
.stream-row select, .stream-row input { min-height: 38px !important; }

/* ---------- toast ---------- */
.toast {
  position: fixed; z-index: 50; inset-inline-start: 50%; transform: translateX(50%);
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: 14px; max-width: calc(100vw - 32px);
  padding: 10px 16px; border-radius: 10px;
  background: var(--ink); color: var(--bg); box-shadow: var(--shadow); font-size: .92rem;
}
.toast-btn { border: 0; background: none; color: var(--accent-soft); font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .summary .sum-next { grid-column: 1 / -1; }
}
@media (max-width: 960px) {
  .schedule, .two-col, .dp-grid { grid-template-columns: minmax(0, 1fr); }
  .program-card { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 620px) {
  body { font-size: 14.5px; }
  .summary { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .summary .sum-card:last-child { grid-column: 1 / -1; }
  .brand-tag { display: none; }
  .program-picker { order: 5; flex: 1 1 100%; }
  .program-picker select { max-width: 100%; width: 100%; }
  .daypanel, .panel { padding: 14px; }
  .sec {
    grid-template-columns: 4px 50px minmax(0, 1fr) auto;
    grid-template-areas: "swatch time body dur" "swatch actions actions actions";
    row-gap: 4px;
  }
  .sec-grip { display: none; }
  .sec-actions { justify-content: flex-end; }
  .note-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .note-row .btn { grid-column: 1 / -1; }
  .ratings li { grid-template-columns: auto minmax(0, 1fr) auto; }
  .ratings .meta { display: none; }
  .stream-row { grid-template-columns: minmax(0, 1fr) auto; }
  .stream-row input { grid-column: 1 / -1; grid-row: 2; }
  .lec-stats { grid-template-columns: minmax(0, 1fr); }
  .mform-body { padding-inline: 16px; }
  .mform-head, .mform-foot { padding-inline: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
