/* Tokens and rules from design/schedule.html. Khmer sets the type:
   16px base, 1.85 line-height, no letter-spacing, no uppercase. */

:root {
  --brand: #2674a8;
  --brand-dark: #1f5f8b;
  --brand-soft: #eaf3f9;
  --on-brand: #ffffff;
  --ink: #17212b;
  --muted: #5a6b7b;
  --line: #dce4ea;
  --page: #f3f6f8;
  --surface: #ffffff;
  --surface-2: #fbfcfd;
  --input-border: #7d93a6;
  --ok: #1f6b4d;
  --ok-bg: #e7f4ee;
  --ok-border: #c8e5d8;
  --danger: #a3281f;
  --danger-border: #e9cfcc;
  --error-bg: #fdecea;
  --error-border: #f3c6c1;
  --warn-bg: #fff8e8;
  --warn-border: #f0d9a8;
  --warn: #8a5300;
  --radius: 12px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --brand: #5aa9d6;
  --brand-dark: #8cc7e8;
  --brand-soft: #1a2a35;
  --on-brand: #08141c;
  --ink: #e8eef4;
  --muted: #a3b4c2;
  --line: #2a3742;
  --page: #0e1418;
  --surface: #151e25;
  --surface-2: #1b262e;
  --input-border: #5a7183;
  --ok: #7fd0a9;
  --ok-bg: #12301f;
  --ok-border: #245c3d;
  --danger: #f0a19a;
  --danger-border: #5e2b27;
  --error-bg: #2a1614;
  --error-border: #5e2b27;
  --warn-bg: #2a2314;
  --warn-border: #5c4a1f;
  --warn: #e6c07a;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Noto Sans Khmer", "Noto Sans", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.85;
  letter-spacing: normal;
  color: var(--ink);
  background:
    radial-gradient(1100px 460px at 82% -12%, rgba(38, 116, 168, 0.08), transparent 62%),
    var(--page);
  transition: background-color 200ms ease;
}
:root[data-theme="dark"] body {
  background:
    radial-gradient(1100px 460px at 82% -12%, rgba(90, 169, 214, 0.09), transparent 62%),
    var(--page);
}

h1 { font-size: 24px; line-height: 1.45; margin: 0 0 6px; }
h2 { font-size: 18px; line-height: 1.5; margin: 0 0 8px; }
p { margin: 0 0 10px; }
a { color: var(--brand-dark); }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; }

:focus-visible { outline: 2px solid var(--brand-dark); outline-offset: 2px; border-radius: 6px; }

.muted { color: var(--muted); }
.center { text-align: center; }
.block { display: block; }
.pad { padding: 48px 16px; }
.empty-state {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 28px 8px;
}
.empty-art {
  width: 190px;
  flex: none;
  color: var(--brand);
  opacity: 0.35;
  --art-accent: var(--brand);
}
.empty-state p { margin: 0; max-width: 420px; }

@keyframes app-rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.page { animation: app-rise 0.3s ease-out backwards; }
.grow { flex: 1; min-width: 0; }

/* ── auth ─────────────────────────────────────────────── */
.auth {
  display: grid;
  grid-template-columns: minmax(320px, 44%) minmax(0, 1fr);
  min-height: 100vh;
  margin: 0;
  padding: 0;
  max-width: none;
  background: var(--page);
}

.auth-brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  padding: clamp(32px, 6vw, 72px);
  color: #fff;
  background:
    radial-gradient(circle at 82% 12%, rgba(255, 255, 255, 0.14), transparent 40%),
    linear-gradient(158deg, #2674a8 0%, #1f5f8b 55%, #17496b 100%);
}
.auth-lockup { display: flex; align-items: center; gap: 14px; }
.auth-lockup h1 {
  margin: 0;
  font-size: clamp(26px, 3vw, 34px);
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: #fff;
}
.auth-region {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  color: #fff;
}
.auth-mark {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  font-size: 17px;
  color: #fff;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.28);
}
.auth-tagline {
  max-width: 30ch;
  margin: 0;
  font-size: clamp(16px, 1.6vw, 19px);
  line-height: 1.65;
  color: #fff;
}
.auth-art {
  width: min(100%, 360px);
  height: auto;
  margin: 4px 0 0;
  color: #fff;
  --art-accent: #b9e2f7;
}
.art-accent { fill: var(--art-accent, #b9e2f7); }
.auth-foot {
  margin: 10px 0 0;
  font-size: 13px;
  color: #fff;
}

@keyframes auth-rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes auth-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}

.auth-brand > * { animation: auth-rise 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.auth-brand > :nth-child(1) { animation-delay: 0.05s; }
.auth-brand > :nth-child(2) { animation-delay: 0.12s; }
.auth-brand > :nth-child(3) { animation-delay: 0.2s; }
.auth-brand > :nth-child(4) { animation-delay: 0.28s; }
.auth-brand > .auth-art {
  animation:
    auth-rise 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) 0.2s both,
    auth-float 7s ease-in-out 1.6s infinite;
}
.auth-tools { animation: auth-rise 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) 0.08s both; }
.auth-content > * { animation: auth-rise 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) 0.16s both; }
.auth-content > :nth-child(2) { animation-delay: 0.22s; }
.auth-content > :nth-child(3) { animation-delay: 0.28s; }

@media (prefers-reduced-motion: reduce) {
  .auth-brand > *,
  .auth-brand > .auth-art,
  .auth-tools,
  .auth-content > *,
  .page {
    animation: none !important;
    opacity: 1;
    transform: none;
  }
}

.auth-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 18px 24px 48px;
}
.auth-tools {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}
.auth-content {
  width: 100%;
  max-width: 400px;
  margin: auto;
  padding: 20px 0;
}
.auth-content .card {
  border: 0;
  padding: 28px;
  box-shadow: 0 1px 2px rgba(16, 40, 58, 0.06), 0 18px 44px rgba(16, 40, 58, 0.09);
}
.auth-lead {
  margin: -2px 0 18px;
  font-size: 14px;
  color: var(--muted);
}
.auth-content > .center,
.auth-content > .muted.center { margin: 14px 0 0; font-size: 14px; }
.auth-content form.card .btn { margin-top: 8px; }

[data-theme="dark"] .auth-content .card {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 18px 44px rgba(0, 0, 0, 0.35);
}
[data-theme="dark"] .auth-brand {
  background:
    radial-gradient(circle at 82% 12%, rgba(90, 169, 214, 0.16), transparent 40%),
    linear-gradient(158deg, #1b3a4d 0%, #142a38 55%, #101f29 100%);
}

@media (max-height: 740px) and (min-width: 761px) {
  .auth-art { display: none; }
}

@media (max-width: 760px) {
  .auth { grid-template-columns: 1fr; }
  .auth-brand {
    justify-content: flex-start;
    gap: 10px;
    padding: 26px 20px 24px;
  }
  .auth-lockup h1 { font-size: 24px; }
  .auth-tagline { max-width: none; font-size: 15px; line-height: 1.55; }
  .auth-foot { display: none; }
  .auth-art { display: none; }
  .auth-panel { padding: 4px 16px 40px; }
  .auth-tools { padding: 8px 0 14px; }
  .auth-content { margin: 0 auto; padding: 0; }
  .account-art { display: none; }
}

@media (max-width: 700px) {
  .empty-state { padding: 20px 4px; }
  .empty-art { display: none; }
}

.mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--brand);
  color: var(--on-brand);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 15px;
  flex: none;
}
.mark.small { width: 32px; height: 32px; font-size: 13px; border-radius: 8px; }

/* ── surfaces ─────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(16, 40, 58, 0.04), 0 10px 28px rgba(16, 40, 58, 0.05);
}
.card > *:last-child { margin-bottom: 0; }
[data-theme="dark"] .card {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.22), 0 12px 30px rgba(0, 0, 0, 0.16);
}

.plain { margin: 0; padding-left: 20px; }
.plain li { margin-bottom: 4px; }

/* ── account ─────────────────────────────────────────── */
.account-profile {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}
.account-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-dark);
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 700;
  flex: none;
}
.account-identity { min-width: 0; }
.account-identity h1 { margin: 0; font-size: 22px; }
.account-identity p { margin: 0; font-size: 14px; overflow-wrap: anywhere; }
.account-eyebrow { display: block; font-size: 13px; color: var(--muted); }
.account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.account-card { position: relative; overflow: hidden; }
.account-art {
  position: absolute;
  top: 16px;
  right: 14px;
  width: min(300px, 34%);
  color: var(--brand);
  opacity: 0.16;
  pointer-events: none;
  --art-accent: var(--brand);
}
[data-theme="dark"] .account-art { opacity: 0.22; }
.account-password .account-form { max-width: 420px; }
.account-contact .account-form { max-width: 420px; }
.account-create form { max-width: 420px; }
.chip.chip-brand {
  background: var(--brand-soft);
  color: var(--brand-dark);
  border-color: var(--brand-soft);
}

/* ── forms ────────────────────────────────────────────── */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 14.5px; color: var(--muted); margin-bottom: 2px; }

input {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--input-border);
  border-radius: 8px;
}
input:focus { border-color: var(--brand); }

select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--input-border);
  border-radius: 8px;
}
select { padding-right: 32px; }
select:focus,
textarea:focus { border-color: var(--brand); }

input[type="file"] {
  padding: 8px 10px;
  background: var(--surface-2);
  border-style: dashed;
}
input[type="file"]::file-selector-button {
  margin-right: 10px;
  padding: 6px 12px;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
}
input[type="file"]::file-selector-button:hover { background: var(--brand-soft); }

.hint { display: block; font-size: 13.5px; color: var(--muted); margin-top: 2px; }

.error {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--danger);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14.5px;
  margin: 0 0 12px;
}
.ok {
  background: var(--ok-bg);
  border: 1px solid var(--ok-border);
  color: var(--ok);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14.5px;
  margin: 0 0 12px;
}

/* ── buttons ──────────────────────────────────────────── */
.btn {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 9px;
  border: 1px solid var(--input-border);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 150ms ease, border-color 150ms ease;
}
.btn:hover { border-color: var(--input-border); background: var(--surface-2); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); font-weight: 700; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: var(--on-brand); }
.btn-quiet { border-color: var(--line); background: transparent; }
.btn-quiet:hover { background: var(--brand-soft); border-color: var(--line); }
.btn-danger { color: var(--danger); border-color: var(--danger-border); }
.btn-danger:hover { background: var(--error-bg); border-color: var(--danger-border); }
.btn-small { min-height: 40px; padding: 0 12px; font-size: 14px; }

/* The one stateful control: aria-pressed reads correctly to a screen reader. */
.btn[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-dark); }

form .btn { width: 100%; }
.card form .btn { margin-top: 4px; }

/* ── app shell ────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}
.shell-main { min-width: 0; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 14px;
  overflow-y: auto;
  background:
    linear-gradient(180deg, var(--brand-soft) 0, transparent 210px),
    var(--surface);
  border-right: 1px solid var(--line);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 10px;
  border-bottom: 1px solid var(--line);
}
.sidebar-brand b { display: block; font-size: 15px; line-height: 1.35; }
.sidebar-brand .muted { font-size: 12px; }

.side-nav,
.side-planned,
.sidebar-foot { display: flex; flex-direction: column; gap: 2px; }
.side-planned { border-top: 1px solid var(--line); padding-top: 12px; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; }

.side-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  text-align: left;
  cursor: pointer;
}
.side-link:hover { background: var(--brand-soft); }
.side-link.active {
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--brand);
}
.side-link.planned { min-height: 34px; color: var(--muted); font-size: 14px; cursor: default; }
.side-link.planned:hover { background: transparent; }
.side-link .chip { font-size: 11px; }
.nav-group { display: flex; flex-direction: column; gap: 1px; }
.nav-group-head { display: flex; align-items: center; gap: 2px; }
.nav-group-head > .side-link { flex: 1; width: auto; min-width: 0; }
.nav-toggle {
  display: grid;
  place-items: center;
  width: 34px;
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.nav-toggle:hover { background: var(--brand-soft); color: var(--brand-dark); }
.nav-chevron {
  width: 7px;
  height: 7px;
  margin-top: -3px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform 150ms ease;
}
.nav-chevron.open { margin-top: 3px; transform: rotate(-135deg); }
.nav-sub {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 1px 0 6px 18px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
}
.nav-sub.collapsed { display: none; }
.nav-sub .side-link { min-height: 36px; font-size: 14px; }
.nav-sub .side-link.active { box-shadow: none; }
.side-link .count {
  background: var(--danger);
  color: #fff;
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 12px;
  font-weight: 700;
}
.side-tools { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 0 6px; }
.side-heading {
  margin: 0 0 4px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.shell-bar { display: none; }

.page { max-width: 880px; margin: 0 auto; padding: 0 16px 64px; }

.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 22px 0 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}
.topbar h1 { font-size: 26px; line-height: 1.3; letter-spacing: -0.015em; margin: 0; }
.topbar b { font-size: 15px; line-height: 1.4; }
.topbar .muted { font-size: 13px; }
.topbar-nav,
.topbar-tools { display: flex; align-items: center; gap: 2px; }
.topbar-tools { padding-left: 8px; border-left: 1px solid var(--line); }
.topbar .btn { min-height: 38px; }
.topbar .btn-quiet { min-height: 36px; }

@media (max-width: 860px) {
  .app-shell { display: block; }
  .shell-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 8px 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
  }
  .shell-bar b { font-size: 14px; white-space: nowrap; }
  .shell-bar .btn { white-space: nowrap; }
  .shell-bar .mark { width: 30px; height: 30px; font-size: 12px; }
  .sidebar { display: none; }
  .sidebar.open {
    display: flex;
    position: fixed;
    inset: 56px 0 0;
    height: auto;
    z-index: 30;
    border-right: 0;
    border-top: 1px solid var(--line);
  }
  .sidebar .side-tools { display: none; }
}

@media (max-width: 480px) {
  .shell-bar .mark { display: none; }
}

/* ── bug reports ──────────────────────────────────────── */
.report-meta {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}
.report-meta .field { flex: 1; min-width: 190px; }
.report-origin {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 14px;
}
.report-label { font-size: 14.5px; color: var(--muted); }
.report-row { padding: 16px 0; border-top: 1px solid var(--line); }
.report-row:first-of-type { border-top: 0; padding-top: 4px; }
.report-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.report-who { display: flex; flex-direction: column; min-width: 0; }
.report-tags { display: flex; gap: 6px; flex-wrap: wrap; align-items: flex-start; }
.report-body {
  margin: 10px 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.report-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.inline-name {
  width: 100%;
  max-width: 320px;
  min-height: 40px;
  margin-bottom: 4px;
}

/* ── coordinator contacts ─────────────────────────────── */
.contact-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}
.contact-row:first-of-type { border-top: 0; padding-top: 4px; }
.contact-who { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.contact-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ── rows (approvals) ─────────────────────────────────── */
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.row:first-of-type { border-top: 0; }
.row-main { flex: 1; min-width: 220px; display: flex; flex-direction: column; }
.row-main b { font-size: 15px; overflow-wrap: anywhere; }
.row-main .muted { font-size: 13.5px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── one-time password ────────────────────────────────── */
.pw-box {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
}
.pw-box h2 { font-size: 16px; margin-bottom: 6px; }
.pw {
  display: block;
  font-size: 20px;
  letter-spacing: .04em;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px dashed var(--warn-border);
  border-radius: 8px;
  margin: 6px 0 10px;
  overflow-wrap: anywhere;
}

@media (prefers-reduced-motion: reduce) {
  body, .btn { transition: none; }
}

/* ── schedule ─────────────────────────────────────────── */
.page.wide { max-width: 1080px; }

.month-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.month-switch { display: flex; align-items: center; gap: 2px; }
.month-switch h1 { font-size: 22px; margin: 0; min-width: 0; padding: 0 8px; }
.btn-step {
  min-height: 38px;
  width: 38px;
  padding: 0;
  font-size: 17px;
  color: var(--muted);
  border-color: var(--line);
  background: transparent;
}
.btn-step:hover { color: var(--ink); background: var(--brand-soft); border-color: var(--line); }
.date-input { width: auto; min-height: 40px; padding: 0 10px; }

.sheet {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(23, 33, 43, .05);
}
:root[data-theme="dark"] .sheet { box-shadow: none; }

.wk {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) minmax(150px, 210px);
  grid-template-areas:
    "date title speaker"
    "date slots slots";
  gap: 2px 18px;
  padding: 12px 16px 10px;
  border-top: 1px solid var(--line);
}
.date { grid-area: date; }
.title { grid-area: title; min-width: 0; }
.slots { grid-area: slots; min-width: 0; }
.speaker { grid-area: speaker; }
.wk:first-child { border-top: 0; }
.wk:hover { background: var(--surface-2); }

.date b { display: block; font-size: 17px; line-height: 1.5; }
.date span { font-size: 12.5px; color: var(--muted); }

.talk { display: contents; }
.title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.title strong { font-weight: 700; font-size: 16.5px; line-height: 1.55; }
.num { color: var(--muted); font-size: 13.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.slots {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 14px;
  margin-top: 1px;
  font-size: 14.5px;
}
.slots .time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 14px; }
.slot { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.slot .label { font-size: 13px; color: var(--muted); white-space: nowrap; }

/* A slot select reads as text until pointed at, so the row stays a schedule
   and not a form. Hover and focus bring the control back. */
.slot select {
  min-height: 30px;
  padding: 0 20px 0 4px;
  font-size: 14.5px;
  border-color: transparent;
  background-color: transparent;
  border-radius: 6px;
  max-width: 170px;
  field-sizing: content;
}
.slot select:hover { background-color: var(--surface); border-color: var(--line); }
.slot select:focus { background-color: var(--surface); border-color: var(--brand); }

.speaker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
  text-align: right;
}
.speaker select {
  min-height: 32px;
  padding: 0 22px 0 6px;
  font-size: 14.5px;
  max-width: 100%;
  border-color: transparent;
  background-color: transparent;
  field-sizing: content;
}
.speaker select:hover { background-color: var(--surface); border-color: var(--line); }
.speaker select:focus { background-color: var(--surface); border-color: var(--brand); }
.speaker .muted { font-size: 12.5px; white-space: nowrap; }
.hosp { flex-basis: 100%; font-size: 12.5px; color: var(--muted); }

.title-select {
  min-height: 32px;
  padding: 0 22px 0 0;
  font-weight: 700;
  font-size: 16.5px;
  line-height: 1.55;
  border-color: transparent;
  background-color: transparent;
  border-radius: 6px;
  max-width: 100%;
  field-sizing: content;
}
.title-select:hover { border-color: var(--line); background-color: var(--surface); }
.title-select:focus { border-color: var(--brand); background-color: var(--surface); }

.wk-more { margin-left: auto; }
.wk-more summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  list-style: none;
}
.wk-more summary::-webkit-details-marker { display: none; }
.wk-more summary::after { content: "▾"; margin-left: 5px; font-size: 10px; }
.wk-more[open] summary::after { content: "▴"; }
.wk-more summary:hover { color: var(--ink); border-color: var(--line); background: var(--surface); }
.wk-more[open] { flex-basis: 100%; margin-left: 0; margin-top: 2px; }
.wk-more[open] summary { color: var(--ink); }
.more-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px 16px;
  align-items: start;
  margin-top: 8px;
  padding: 12px 0 2px;
  border-top: 1px solid var(--line);
}
.more-grid .slot {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
}
.more-grid .slot .label { line-height: 1.5; }
.more-grid select {
  width: 100%;
  max-width: none;
  border-color: var(--line);
  background-color: var(--surface);
}
.more-grid input { width: 100%; min-width: 0; min-height: 38px; }
/* display:contents lets the three fields flow as grid cells; hidden wins. */
.more-extra { display: contents; }
.more-extra[hidden] { display: none; }
.more-grid .btn { grid-column: 1 / -1; justify-self: end; align-self: end; }
.more-grid .btn.more-toggle { justify-self: start; }
.more-toggle-row {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.more-toggle-row .hint { margin: 0; font-size: 13px; }

@media (max-width: 720px) {
  .topbar .grow { flex-basis: 100%; }
  .topbar-tools { margin-left: auto; padding-left: 0; border-left: 0; }
  .wk {
    grid-template-columns: 52px minmax(0, 1fr);
    grid-template-areas:
      "date title"
      "date slots"
      "date speaker";
    gap: 2px 12px;
    padding: 12px;
  }
  .speaker { justify-content: flex-start; text-align: left; }
  .speaker select { max-width: 100%; }
  .slot select { max-width: none; }
  .more-grid input { min-width: 0; width: 100%; }
}

/* ── inline add forms (brothers, talks) ───────────────── */
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.inline-form input { width: auto; min-width: 180px; min-height: 40px; }
.inline-form .number-input { width: 90px; min-width: 90px; }
.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  min-height: 40px;
}
.check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-width: 0;
  min-height: 0;
  padding: 0;
  margin: 0;
}
.inline-form .btn { width: auto; }
/* The add-brother form mirrors the person rows: name, Reader, Speaker, then
   the submit on its own line. A grid keeps the button from squeezing them. */
.inline-form.stack {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  align-items: center;
}
.inline-form.stack input:not([type="checkbox"]) {
  flex: 1 1 140px;
  width: auto;
  min-width: 0;
}
.inline-form.stack .btn { flex: none; }
@media (max-width: 560px) {
  /* No room beside the flags: the name takes its own line. */
  .inline-form.stack input:not([type="checkbox"]) { flex-basis: 100%; }
  .inline-form.stack .btn { margin-left: auto; }
}

details.card { padding: 12px 20px; }
details.card summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 16px;
  list-style: none;
  display: flex;
  align-items: center;
  min-height: 34px;
}
details.card summary::-webkit-details-marker { display: none; }
/* Chevron at the far edge: one affordance for every collapsible panel. */
details.card summary::after {
  content: "";
  width: 7px;
  height: 7px;
  margin-left: auto;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 150ms ease;
}
details.card[open] summary::after { transform: rotate(45deg); }
details.card summary:hover { color: var(--brand-dark); }
details[open].card summary { margin-bottom: 10px; }
/* A nested collapsible inside a panel reads as a footer action. */
details.card details > summary {
  border-top: 1px solid var(--line);
  margin-top: 10px;
  padding-top: 10px;
}

/* ── editable lists (brothers, talk catalog) ──────────── */
.rows { list-style: none; margin: 12px 0 0; padding: 0; }
.person-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.person-row .name-input { flex: 1 1 220px; width: auto; min-width: 0; min-height: 38px; }
.person-row .number-input { width: 80px; min-width: 80px; min-height: 38px; }

/* Read-only until Edit: the row is a name and its roles, not a form. */
.person-name {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.person-tags { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.person-actions { display: flex; flex-wrap: wrap; gap: 8px; flex-basis: 100%; }
.person-edit { display: none; }
.person-row.editing .person-edit { display: contents; }
.person-row.editing .person-name,
.person-row.editing .person-tags { display: none; }

/* ── undo ─────────────────────────────────────────────── */
.manage-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
  margin-top: 16px;
}
.manage-grid > .card,
.manage-grid > details.card { margin-bottom: 0; }
.manage-grid > .manage-wide { grid-column: 1 / -1; }
@media (max-width: 860px) {
  .manage-grid { grid-template-columns: 1fr; }
}

.undo {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 14.5px;
}
.undo .btn { width: auto; }

/* ── requests ─────────────────────────────────────────── */
/* Ask form: a grid so the three picks line up and the long fields
   (talk, message) get the full width. */
.request-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 16px;
}
.request-form .field { margin-bottom: 0; min-width: 0; }
.request-form .field > span { margin-bottom: 4px; }
.request-form select {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--input-border);
  border-radius: 8px;
}
.request-form select:focus { border-color: var(--brand); }
.request-form .form-wide { grid-column: 1 / -1; }
.request-form .form-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
}
.request-form .btn { width: auto; }
@media (max-width: 720px) {
  .request-form { grid-template-columns: 1fr; }
}

.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tab {
  min-height: 42px;
  padding: 0 14px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.tab[aria-selected="true"] {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand-dark);
  font-weight: 700;
}
.tab .count {
  background: var(--brand);
  color: var(--on-brand);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 12.5px;
  font-weight: 700;
}

.req {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 10px;
}
.req-main { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: 4px; }
.req-title b { font-size: 16.5px; }
.req-main .meta { font-size: 13px; color: var(--muted); }
.req-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
/* The thread is the card's footer, not another item in the side column. */
.req > .thread-wrap {
  flex-basis: 100%;
  margin-top: 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
/* A bordered summary reads as a button, not as body text. */
.req > .thread-wrap > summary {
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}
.req > .thread-wrap > summary::-webkit-details-marker { display: none; }
.req > .thread-wrap > summary::after {
  content: "";
  width: 6px;
  height: 6px;
  margin-left: 2px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 150ms ease;
}
.req > .thread-wrap[open] > summary::after { transform: rotate(45deg); }
.req > .thread-wrap > summary:hover {
  border-color: var(--brand);
  color: var(--brand-dark);
  background: var(--brand-soft);
}

/* One replace confirmation, styled like the rest of the app. */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgb(12 22 30 / 45%);
}
.modal {
  width: min(440px, 100%);
  padding: 20px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 18px 50px rgb(0 0 0 / 25%);
}
.modal h2 { margin: 0 0 6px; font-size: 17px; }
.modal p { margin: 0 0 16px; color: var(--muted); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }
.modal-actions .btn { width: auto; }

.chip {
  display: inline-flex;
  align-items: center;
  font-size: 12.5px;
  line-height: 1;
  padding: 5px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-weight: 700;
}
.chip-ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-border); }
.chip-warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-border); }
.chip-muted { background: var(--surface-2); color: var(--muted); }

/* ── request thread ───────────────────────────────────── */
.req-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.req-side .row-hint { font-size: 12.5px; }
.thread-wrap { margin-top: 6px; }
.thread-wrap summary {
  cursor: pointer;
  font-size: 13.5px;
  color: var(--muted);
  min-height: 32px;
  display: inline-flex;
  align-items: center;
}
.thread {
  margin-top: 8px;
  border-left: 3px solid var(--line);
  padding-left: 12px;
}
.msg { margin-bottom: 10px; }
.msg-head { font-size: 13px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; }
.msg-head b { color: var(--ink); font-size: 14px; }
.msg-body { margin: 0 0 2px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .row-actions { margin-top: 2px; }
.thread-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.thread-form input { flex: 1; min-width: 200px; min-height: 38px; }

.topbar .count {
  background: var(--danger);
  color: #fff;
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 12px;
  font-weight: 700;
  margin-left: 6px;
}
/* Approved speakers waiting for us: good news, not an alarm. */
.topbar .count-ok { background: var(--ok); color: var(--surface); }

/* ── attachments ──────────────────────────────────────── */
.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.thumb {
  max-width: 220px;
  max-height: 160px;
  border-radius: 8px;
  border: 1px solid var(--line);
  display: block;
}
.attach {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  font-size: 14px;
  text-decoration: none;
}
.attach-label { position: relative; overflow: hidden; max-width: 200px; }
.attach-label .file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: 0;
  opacity: 0;
  clip: rect(0 0 0 0);
  overflow: hidden;
}
.attach-label:focus-within { outline: 2px solid var(--brand-dark); outline-offset: 2px; }

.thread-form .btn { width: auto; }
.thread-wrap { flex-basis: 100%; }

/* ── board sheet (screen preview + print) ─────────────── */
.print-screen { padding: 0 16px 40px; }
.print-screen > .topbar { max-width: 210mm; margin: 0 auto 16px; }
.print-controls {
  max-width: 210mm;
  margin: 0 auto 14px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.print-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.print-row .grow { flex: 1; }
.range-label { font-weight: 700; min-width: 140px; text-align: center; }
.inline-check { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; }
.inline-check select {
  min-height: 38px;
  padding: 0 8px;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--input-border);
  border-radius: 8px;
}
.inline-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
  padding: 0;
  margin: 0;
  accent-color: var(--brand);
}
.print-options { padding-top: 2px; }

.sheet-page {
  width: 210mm;
  min-height: 297mm;
  margin: 0 auto;
  padding: 12mm 14mm;
  background: #fff;
  color: #111;
  border: 1px solid #e3e8ec;
  box-shadow: 0 10px 34px rgba(0, 0, 0, .12);
  font-size: 14.5px;
  line-height: 1.7;
}
.sheet-head {
  display: flex;
  justify-content: flex-end;
  min-height: 6mm;
}
.sheet-congregation { font-size: 12px; color: #555; }
.month-band {
  background: #2674a8;
  color: #fff;
  font-weight: 700;
  font-size: 17px;
  text-align: center;
  padding: 4px 10px;
  margin: 4mm 0 2mm;
  break-after: avoid;
}
.prow {
  display: grid;
  grid-template-columns: 18mm minmax(0, 1fr) auto;
  column-gap: 4mm;
  padding: 2.5mm 3mm;
  border-bottom: 1px solid #e2e2e2;
  break-inside: avoid;
}
.prow:last-child { border-bottom: 0; }
.pday { font-weight: 700; }
.ptalk { min-width: 0; }
.ptalk strong { font-weight: 700; }
.pnum { margin-left: 4px; color: #444; }
.pspeaker { text-align: right; font-weight: 700; white-space: nowrap; }
.pcong { display: block; font-weight: 400; font-size: 12.5px; color: #444; }
.pline2 {
  grid-column: 2 / 4;
  display: flex;
  gap: 3mm;
  flex-wrap: wrap;
  align-items: baseline;
  color: #222;
  font-size: 14px;
}
.ptime { min-width: 14mm; }
.phosp {
  margin-left: auto;
  color: #444;
  font-size: 12.5px;
  font-weight: 400;
  white-space: nowrap;
}
.sheet-empty { color: #666; padding: 10mm 0; }

@media print {
  @page { size: A4; margin: 12mm 14mm; }
  body { background: #fff; }
  .app-shell { display: block; }
  .no-print, .topbar, .print-controls { display: none !important; }
  .sheet-page {
    width: auto;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
  }
  .month-band { background: #2674a8 !important; color: #fff !important; print-color-adjust: exact; }
}

/* Activity grows with use; a fixed height keeps the page and its screenshot stable. */
.activity-list { height: 320px; overflow-y: auto; }

/* Years of archives stay bounded; the card scrolls instead of growing. */
.archive-head { padding-bottom: 6px; }
.archive-list { max-height: 320px; overflow-y: auto; }

.import-box {
  width: 100%;
  min-height: 90px;
  padding: 8px 10px;
  font: inherit;
  font-size: 15px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--input-border);
  border-radius: 8px;
  margin: 6px 0;
}

/* ── import preview ───────────────────────────────────── */
.preview-table { overflow-x: auto; margin: 8px 0; }
.preview-table table { border-collapse: collapse; font-size: 14px; }
.preview-table th, .preview-table td {
  border: 1px solid var(--line);
  padding: 4px 8px;
  text-align: left;
  white-space: nowrap;
}
.preview-table th { background: var(--surface-2); }

.slot .label { white-space: nowrap; }

@media print {
  .month-band.page-break { break-before: page; }
}
