/* Instruct. Two themes: the studio's colors (default) and black, switched with the
   header toggle (html[data-theme="dark"]). Every color below comes from these tokens. */
:root {
  /* Studio brand: defaults; each studio's brand.css (built from studios/<id>/studio.json) overrides these */
  --brand-green: #34604F;
  --brand-gold: #DAAB6B;
  --brand-cream: #F1ECE3;

  --bg: var(--brand-cream);
  --surface: #ffffff;
  --surface-2: #fbf9f5;
  --field: #ffffff;
  --ink: #26352f;
  --heading: var(--brand-green);
  --muted: #5f6b65;
  --line: #e3dccf;
  --accent: var(--brand-green);      /* links, outlines, selected */
  --btn-bg: var(--brand-green);      /* solid buttons */
  --btn-ink: #ffffff;
  --accent-soft: #e3ece7;
  --gold-soft: #f7ecdb;
  --gold-ink: #7a4a14;
  --subs-bg: #fffdf8;
  --zero-row: #fdf8ef;
  --warn: #8a5a1f;
  --warn-soft: var(--gold-soft);
  --danger: #a33b3b;
  --danger-soft: #fbeeee;
  --danger-pill: #f6dcdc;
  --danger-line: #efc4c4;
  --toast-bg: var(--brand-green);
  --radius: 14px;

  --font-body: Arial, "Helvetica Neue", Helvetica, sans-serif;
  /* Gotham is a licensed font; Montserrat (Google Fonts) stands in where Gotham isn't available */
  --font-heading: "Gotham Medium", "Gotham", "Montserrat", Arial, sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --surface: #0f0f0f;
  --surface-2: #171717;
  --field: #111111;
  --ink: #ffffff;
  --heading: #ffffff;
  --muted: #b3b3b3;
  --line: #2b2b2b;
  --accent: #9ccbb3;                 /* light sage: readable on black */
  --btn-bg: var(--brand-green);
  --btn-ink: #ffffff;
  --accent-soft: #1d2a24;
  --gold-soft: #2e2415;
  --gold-ink: #f0cc96;
  --subs-bg: #15110a;
  --zero-row: #161208;
  --warn: #e9c38c;
  --warn-soft: #2e2415;
  --danger: #ff9b9b;
  --danger-soft: #2a1212;
  --danger-pill: #3a1818;
  --danger-line: #5a2626;
  --toast-bg: #34604F;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font-body);
}
h1, h2, h3 { font-family: var(--font-heading); font-weight: 500; margin: 0 0 .5rem; color: var(--heading); letter-spacing: .01em; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .75rem 16px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: .9rem; line-height: 1.2; min-width: 0; }
.brand-logo { display: block; height: 48px; width: auto; }
.brand-logo.logo-dark { display: none; }
html[data-theme="dark"] .brand-logo.logo-light { display: none; }
html[data-theme="dark"] .brand-logo.logo-dark { display: block; }
.brand-sub {
  font-family: var(--font-heading); font-weight: 500;
  font-size: .8rem; color: var(--heading); letter-spacing: .1em; text-transform: uppercase;
  padding-left: .9rem; border-left: 2px solid var(--brand-gold);
}
.top-actions { display: flex; align-items: center; gap: .9rem; }
.help-link { color: var(--accent); font-weight: 600; font-size: .9rem; text-decoration: none; }
.help-link:hover { text-decoration: underline; }
.theme-toggle {
  font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; white-space: nowrap;
  background: transparent; color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: .3rem .75rem;
}
.theme-toggle:hover { border-color: var(--accent); }
.help-link:focus-visible, .theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 999px; }
.who { display: flex; align-items: center; gap: .75rem; font-size: .9rem; }
.who span { max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.container { max-width: 960px; margin: 0 auto; padding: 1.25rem 16px 4rem; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.25rem; margin-bottom: 1rem;
}
.hero { text-align: center; padding: 2.5rem 1.25rem; }
.hero p { max-width: 34rem; margin: .5rem auto 1.5rem; }
.actions { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; }

.btn {
  font: inherit; font-weight: 600; border-radius: 999px; padding: .55rem 1.2rem; cursor: pointer;
  border: 1px solid var(--btn-bg); background: var(--btn-bg); color: var(--btn-ink);
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
a.btn { text-decoration: none; display: inline-block; }
.btn-outline { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn-quiet { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-sm { padding: .3rem .85rem; font-size: .85rem; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tab {
  font: inherit; background: none; border: none; padding: .6rem .9rem; cursor: pointer; color: var(--muted);
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab[aria-selected="true"] { color: var(--heading); border-bottom-color: var(--brand-gold); font-weight: 600; }
.badge {
  display: inline-block; min-width: 1.3rem; padding: 0 .35rem; border-radius: 999px; font-size: .75rem;
  background: var(--brand-gold); color: #26352f; font-weight: 600; text-align: center; margin-left: .3rem;
}

.rangebar { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.rangebar .label { font-weight: 600; }

.day { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: .75rem; overflow: hidden; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; padding: .7rem 1rem; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.day-head .date { font-family: var(--font-heading); font-weight: 500; color: var(--heading); }
.day-body { padding: .6rem 1rem .8rem; }
.day.past { opacity: .55; }
.day.today { border-color: var(--brand-gold); }
.day.today .day-head { background: var(--gold-soft); }

.class-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .5rem 0; border-bottom: 1px dashed var(--line); }
.class-row:last-child { border-bottom: none; }
.class-info { min-width: 0; }
.class-time { font-weight: 600; }
.class-meta { font-size: .85rem; color: var(--muted); }
.class-row.cancelled .class-time, .class-row.cancelled .class-name { text-decoration: line-through; color: var(--muted); }

.pill { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; background: var(--accent-soft); color: var(--accent); margin: .15rem .25rem .15rem 0; }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-plain { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }
.pill-gold { background: var(--gold-soft); color: var(--gold-ink); border: 1px solid var(--brand-gold); font-weight: 600; }

.available-list { margin-top: .3rem; }
.subs-card { border-color: var(--brand-gold); background: var(--subs-bg); }
.subs-card h2 { font-size: 1.1rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin-top: .5rem; }
.field { display: flex; flex-direction: column; gap: .25rem; }
input[type="date"], input[type="time"], textarea, select.assign-select {
  font: inherit; padding: .35rem .5rem; border: 1px solid var(--line); border-radius: 6px; background: var(--field); color: var(--ink);
}
select.assign-select { font-size: .85rem; border-radius: 8px; max-width: 100%; }
textarea { width: 100%; min-height: 3.2rem; resize: vertical; margin-top: .25rem; }
.timeoff-line { margin-top: .5rem; }
.roster-summary { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; margin-bottom: .4rem; }
.roster-count { font-weight: 600; }
table.roster td.spot { font-weight: 700; font-variant-numeric: tabular-nums; width: 4rem; }
table.roster td, table.roster th { padding: .4rem .5rem; }
.roster-inline { margin-top: .5rem; padding: .6rem .75rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.composer { margin-top: .6rem; padding: .7rem .8rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.composer textarea { min-height: 4.2rem; }
.msg-log { display: flex; flex-direction: column; gap: .4rem; margin: .4rem 0 .6rem; }
.msg-item { padding: .45rem .6rem; border-left: 3px solid var(--brand-gold); background: var(--surface); border-radius: 0 6px 6px 0; }
.spot-hero p { max-width: 62ch; }
.spot-status { margin-top: .6rem; }
.spot-grid { display: grid; gap: .9rem; }
.spot-label { font-weight: 600; font-size: .92rem; }
.spot-field textarea { min-height: 3.6rem; }
.chip-row { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .2rem; }
.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .7rem; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; background: var(--field); font-size: .9rem; }
.chip input { margin: 0; accent-color: var(--brand-green); }
.chip:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tot { display: grid; gap: .5rem; }
.tot-row { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
.tot-or { color: var(--muted); font-size: .85rem; font-style: italic; }
.spot-actions { margin-bottom: 1.5rem; }
.spot-text { white-space: pre-wrap; font: inherit; font-size: .9rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: .8rem 1rem; margin: .6rem 0; }
.media-list { margin-top: .4rem; }
.all-class { border-bottom: 1px dashed var(--line); }
.all-class:last-child { border-bottom: none; }
.all-class .class-row { border-bottom: none; }
.all-class.cancelled .class-time, .all-class.cancelled .class-name { text-decoration: line-through; color: var(--muted); }
.all-class .roster-inline { margin: 0 0 .6rem; }
/* Class plans / builder */
.plan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .75rem; }
.plan-card { text-align: left; font: inherit; color: inherit; cursor: pointer; margin: 0; }
.plan-card:hover { border-color: var(--accent); }
.plan-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .4rem; }
.plan-item { display: flex; gap: .9rem; padding: .6rem 0; border-bottom: 1px dashed var(--line); }
.plan-item:last-child { border-bottom: none; }
.plan-time { flex: 0 0 4.2rem; font-variant-numeric: tabular-nums; }
.plan-note { border-left: 3px solid var(--brand-gold); padding-left: .5rem; margin: .2rem 0; }
.pre { white-space: pre-wrap; }
.class-plan-link { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; padding: .45rem .7rem; margin-bottom: .5rem; border-radius: 10px; background: var(--accent-soft); }
.timeline { margin: .8rem 0 .2rem; }
.tl-bar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); margin-bottom: .3rem; }
.tl-seg { height: 100%; border-right: 1px solid var(--surface); }
.tl-gap { height: 100%; background: repeating-linear-gradient(45deg, transparent 0 4px, var(--line) 4px 6px); }
.tl-off { color: var(--warn); font-weight: 600; }
.tl-legend { display: flex; gap: .8rem; flex-wrap: wrap; }
.tl-dot { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; margin-right: .35rem; vertical-align: -.05rem; }
.tl-s0 { background: var(--brand-gold); } .tl-s1 { background: var(--brand-green); } .tl-s2 { background: #8fb3a3; } .tl-s3 { background: #b9763a; } .tl-s4 { background: #6d7f99; }
.tl-text0 { color: #b8843f; } .tl-text1 { color: var(--accent); } .tl-text2 { color: #6f9a86; } .tl-text3 { color: #b9763a; } .tl-text4 { color: #6d7f99; }
.cb-section-title { max-width: 14rem; font-weight: 600; padding: .25rem .5rem; }
.cb-item { display: grid; grid-template-columns: auto 2.6rem minmax(0, 1fr) 4.2rem auto; gap: .5rem; align-items: center; padding: .45rem 0; border-bottom: 1px dashed var(--line); }
.cb-item.dragging { opacity: .4; }
.cb-item.drop-target { box-shadow: inset 0 3px 0 var(--brand-gold); }
.cb-grip { cursor: grab; color: var(--muted); user-select: none; letter-spacing: -.2em; }
.cb-at { font-variant-numeric: tabular-nums; }
.cb-item-name { font-weight: 600; }
.cb-item .cb-note { margin-top: .25rem; padding: .25rem .5rem; font-size: .85rem; max-width: none; width: 100%; }
.cb-time { max-width: 4.2rem; text-align: center; font-variant-numeric: tabular-nums; padding: .3rem .4rem; }
.cb-item-btns { display: flex; gap: .2rem; }
.cb-item-btns .btn { padding: .25rem .5rem; }
.cb-add { margin-top: .5rem; }
.cb-add .assign-select { max-width: 100%; }
.cb-actions { position: sticky; bottom: 0; background: var(--bg); padding: .6rem 0; margin-bottom: 1.5rem; }
@media (max-width: 560px) {
  .cb-item { grid-template-columns: 2.4rem minmax(0, 1fr) 4rem; }
  .cb-grip { display: none; }
  .cb-item-btns { grid-column: 2 / -1; justify-content: flex-end; }
}
/* Teach mode: full screen over the app */
body.teaching { overflow: hidden; }
.teach { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: flex; flex-direction: column; padding: calc(env(safe-area-inset-top, 0px) + 1rem) 16px calc(env(safe-area-inset-bottom, 0px) + 1rem); overflow-y: auto; }
.teach-top { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.teach-progress { margin: .6rem 0 0; }
.teach-main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: .5rem; max-width: 760px; margin: 0 auto; width: 100%; }
.teach-section { font-family: var(--font-heading); text-transform: uppercase; letter-spacing: .12em; font-size: .9rem; }
.teach-name { font-family: var(--font-heading); color: var(--heading); font-size: clamp(1.8rem, 6vw, 3.2rem); line-height: 1.15; }
.teach-clock { font-size: clamp(4rem, 20vw, 9rem); font-variant-numeric: tabular-nums; font-weight: 700; line-height: 1; color: var(--ink); }
.teach-clock.ending { color: var(--warn); }
.teach-springs { font-weight: 600; font-size: 1.1rem; }
.teach-note { background: var(--gold-soft); color: var(--gold-ink); border-radius: 8px; padding: .4rem .8rem; }
.teach-cues { font-size: 1rem; max-width: 60ch; text-align: left; }
.teach-next { text-align: center; color: var(--muted); margin: .6rem 0; }
.teach-controls { display: flex; justify-content: center; gap: .6rem; }
.teach-controls .btn { min-width: 6.5rem; padding: .7rem 1rem; font-size: 1rem; }
.teach-play { min-width: 9rem !important; }
.teach-auto { margin: .8rem auto 0; }
/* Available hours (instructors) and Coverage (admins) */
.hours-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; margin-bottom: .8rem; }
.hours-title { font-family: var(--font-heading); color: var(--heading); font-size: 1.05rem; }
#hours-status { margin-left: auto; }
.hcheck { display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.hcheck input, .hours-slot input { width: 1.05rem; height: 1.05rem; accent-color: var(--brand-green); cursor: pointer; margin: 0; }
html[data-theme="dark"] .hcheck input, html[data-theme="dark"] .hours-slot input { accent-color: #9ccbb3; }
.hcheck.locked input, .hours-slot.locked input { cursor: not-allowed; }
.hours-table { border-collapse: collapse; width: 100%; font-size: .9rem; }
.hours-table th, .hours-table td { border-bottom: 1px solid var(--line); padding: .3rem .25rem; text-align: center; }
.hours-table thead th { font-weight: 600; vertical-align: bottom; }
.hours-table thead th.today { color: var(--accent); }
.hours-table tbody th { text-align: left; white-space: nowrap; font-weight: 500; }
.hours-table td.on { background: var(--accent-soft); }
.hours-grouprow th, .hours-grouprow td { background: var(--surface-2); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.hours-colall, .hours-rowall { display: inline-flex; align-items: center; gap: .3rem; cursor: pointer; }
.hours-colall { margin-top: .25rem; }
.hours-day-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .4rem; }
.hours-group { margin-top: .8rem; }
.hours-group-toggle { display: inline-flex; align-items: center; gap: .45rem; font-weight: 600; cursor: pointer; }
.hours-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .4rem; margin-top: .4rem; }
.hours-slot { display: flex; align-items: center; gap: .5rem; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 10px; background: var(--field); cursor: pointer; font-size: .9rem; }
.hours-slot.on { border-color: var(--accent); background: var(--accent-soft); }
.hours-slot.locked { opacity: .5; cursor: not-allowed; }
.hours-week-mobile { display: none; }
.hours-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: .25rem; margin-bottom: .6rem; }
.hours-chip { font: inherit; background: var(--field); border: 1px solid var(--line); border-radius: 10px; padding: .3rem 0; cursor: pointer; color: var(--ink); text-align: center; }
.hours-chip.active { border-color: var(--accent); background: var(--accent-soft); color: var(--heading); font-weight: 600; }
.hours-chip .dot { width: 6px; height: 6px; border-radius: 50%; margin: .15rem auto 0; background: transparent; }
.hours-chip .dot.on { background: var(--brand-gold); }
.hours-copy { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: -.25rem 0 1rem; }
.hours-month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .3rem; }
.hours-dow { text-align: center; padding-bottom: .2rem; }
.hours-cell { min-height: 5.2rem; border: 1px solid var(--line); border-radius: 10px; padding: .35rem .4rem; background: var(--field); cursor: pointer; display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.hours-cell:hover { border-color: var(--accent); }
.hours-cell.other { opacity: .45; }
.hours-cell.locked { background: var(--surface-2); cursor: default; }
.hours-cell.today { box-shadow: inset 0 0 0 2px var(--brand-gold); }
.hours-cell.has { background: var(--accent-soft); }
.hours-cell-head { display: flex; justify-content: space-between; align-items: center; gap: .2rem; }
.hours-num { font-weight: 600; }
.hours-sum { font-size: .75rem; line-height: 1.25; color: var(--ink); overflow-wrap: anywhere; }
.coverage td { padding: .15rem; }
.cov-cell { width: 100%; min-width: 2.2rem; font: inherit; font-weight: 600; border: 1px solid var(--line); border-radius: 6px; padding: .3rem 0; cursor: pointer;
  background: color-mix(in srgb, var(--brand-green) calc(var(--cov, 0) * 100%), var(--field)); color: var(--ink); }
.cov-cell:not(.zero) { color: #fff; }
.cov-cell.zero { color: var(--muted); background: var(--field); }
.cov-cell.active { outline: 2px solid var(--brand-gold); outline-offset: 1px; }
@media (max-width: 700px) {
  .hours-week-desktop { display: none; }
  .hours-week-mobile { display: block; }
  .hours-cell { min-height: 3.6rem; padding: .25rem; }
  .hours-cell .hours-colall { display: none; }
  .hours-sum { font-size: .65rem; }
  #hours-status { margin-left: 0; }
}
/* Exercise types */
.type-pill { background: var(--gold-soft); color: var(--gold-ink); font-size: .72rem; }
.type-chips { margin-top: .2rem; }
.cb-pickbar { position: sticky; top: 0; z-index: 3; padding: .7rem 1rem; }
@media (min-width: 900px) { .cb-pickbar { top: calc(env(safe-area-inset-top, 0px) + 80px); } }

/* Messages (chat) */
.chat-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 0; height: calc(100vh - 150px); min-height: 480px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.chat-layout.has-thread { grid-template-columns: 240px minmax(0, 1fr) 340px; }
.chat-side { border-right: 1px solid var(--line); background: var(--surface-2); overflow-y: auto; padding: .5rem 0; display: flex; flex-direction: column; }
.chat-side-head { display: flex; justify-content: space-between; align-items: center; padding: .6rem .8rem .3rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.chat-side-foot { margin-top: auto; padding: .8rem; font-size: .85rem; }
.chat-link { display: flex; align-items: center; gap: .45rem; width: 100%; font: inherit; text-align: left; background: none; border: none; color: var(--ink); padding: .35rem .8rem; cursor: pointer; border-radius: 0; }
.chat-link:hover { background: var(--accent-soft); }
.chat-link.active { background: var(--accent-soft); color: var(--heading); font-weight: 600; box-shadow: inset 3px 0 0 var(--brand-gold); }
.chat-link.unread .chat-link-name { font-weight: 700; color: var(--heading); }
.chat-link.muted-conv { opacity: .6; }
.chat-link .hash { width: 1.3rem; text-align: center; color: var(--muted); }
.chat-link-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { font: inherit; background: none; border: 1px solid transparent; border-radius: 8px; padding: .15rem .45rem; cursor: pointer; color: var(--ink); line-height: 1.2; }
.icon-btn:hover { background: var(--accent-soft); border-color: var(--line); }
.avatar { flex: 0 0 auto; width: 1.9rem; height: 1.9rem; border-radius: 8px; color: #fff; font-size: .75rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.chat-link .avatar { width: 1.35rem; height: 1.35rem; font-size: .6rem; border-radius: 6px; }
.chat-pane, .chat-thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-thread { border-left: 1px solid var(--line); }
.chat-head { display: flex; align-items: center; gap: .6rem; padding: .6rem .9rem; border-bottom: 1px solid var(--line); justify-content: space-between; }
.chat-title { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.chat-title strong { color: var(--heading); }
.chat-back { display: none; font-size: 1.3rem; }
.chat-msgs { flex: 1; overflow-y: auto; padding: .6rem .9rem; display: flex; flex-direction: column; gap: .15rem; }
.chat-empty, .chat-empty-msgs { margin: auto; text-align: center; padding: 2rem; }
.chat-day { text-align: center; margin: .7rem 0 .3rem; font-size: .75rem; color: var(--muted); position: relative; }
.chat-day span { background: var(--surface); padding: 0 .6rem; position: relative; z-index: 1; }
.chat-day::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid var(--line); }
.msg { display: flex; gap: .6rem; padding: .35rem .4rem; border-radius: 10px; position: relative; }
.msg:hover { background: var(--surface-2); }
.msg.mentions-me { background: var(--gold-soft); }
.msg.root { border-bottom: 1px solid var(--line); border-radius: 0; margin-bottom: .3rem; }
.msg-main { flex: 1; min-width: 0; }
.msg-meta { display: flex; gap: .5rem; align-items: baseline; }
.msg-meta strong { color: var(--heading); font-size: .92rem; }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.mention { background: var(--accent-soft); color: var(--accent); border-radius: 4px; padding: 0 .15rem; font-weight: 600; }
.mention.me { background: var(--gold-soft); color: var(--gold-ink); }
.msg-actions { position: absolute; top: -.6rem; right: .5rem; display: none; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .1rem; box-shadow: 0 2px 6px rgba(0,0,0,.08); }
.msg:hover .msg-actions, .msg:focus-within .msg-actions { display: flex; }
.msg-reacts, .msg-picker { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .25rem; }
.react { font: inherit; font-size: .85rem; background: var(--field); border: 1px solid var(--line); border-radius: 999px; padding: .05rem .5rem; cursor: pointer; color: var(--ink); }
.react.mine { border-color: var(--accent); background: var(--accent-soft); }
.msg-thread-link { font: inherit; font-size: .85rem; background: none; border: none; color: var(--accent); cursor: pointer; padding: .2rem 0; font-weight: 600; }
.msg-files { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .3rem; }
.chat-img-btn { padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface-2); cursor: zoom-in; }
.chat-img { display: block; max-width: 260px; max-height: 200px; min-width: 60px; min-height: 40px; object-fit: cover; }
.chat-file { font: inherit; display: inline-flex; gap: .45rem; align-items: center; background: var(--field); border: 1px solid var(--line); border-radius: 10px; padding: .4rem .6rem; cursor: pointer; color: var(--ink); max-width: 100%; }
.msg-edit textarea { width: 100%; font: inherit; }
.chat-compose { border-top: 1px solid var(--line); padding: .5rem .7rem .4rem; position: relative; }
.compose-row { display: flex; gap: .4rem; align-items: flex-end; }
.chat-input { flex: 1; font: inherit; resize: none; border: 1px solid var(--line); border-radius: 10px; padding: .5rem .6rem; background: var(--field); color: var(--ink); max-height: 160px; min-height: 2.4rem; }
.chat-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.compose-hint { margin-top: .2rem; }
.compose-files { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .3rem; }
.mention-pop { position: absolute; bottom: 100%; left: .7rem; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 4px 14px rgba(0,0,0,.12); padding: .25rem; min-width: 220px; z-index: 5; }
.mention-pop button { display: flex; align-items: center; gap: .5rem; width: 100%; font: inherit; background: none; border: none; padding: .35rem .5rem; border-radius: 6px; cursor: pointer; color: var(--ink); text-align: left; }
.mention-pop button:first-child, .mention-pop button:hover { background: var(--accent-soft); }
.mention-pop .avatar { width: 1.4rem; height: 1.4rem; font-size: .6rem; }
.chat-join { border-top: 1px solid var(--line); padding: .7rem .9rem; display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; }
.chat-dialog { padding: 1rem 1.2rem; overflow-y: auto; }
.people-pick { max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: .25rem; background: var(--field); }
.people-row { display: flex; align-items: center; gap: .5rem; padding: .3rem .4rem; border-radius: 6px; }
label.people-row { cursor: pointer; }
label.people-row:hover { background: var(--accent-soft); }
.people-row .avatar { width: 1.5rem; height: 1.5rem; font-size: .6rem; }
.tab .chat-badge { margin-left: .35rem; }
@media (max-width: 899px) {
  .chat-layout, .chat-layout.has-thread { grid-template-columns: minmax(0, 1fr); height: calc(100vh - 170px); }
  .chat-layout.has-open .chat-side { display: none; }
  .chat-layout:not(.has-open) .chat-pane { display: none; }
  .chat-layout.has-thread .chat-pane { display: none; }
  .chat-thread { border-left: none; }
  .chat-back { display: inline-block; }
  .msg-actions { display: flex; position: static; box-shadow: none; border: none; background: none; margin-left: auto; align-self: flex-start; }
  .msg-actions .icon-btn { padding: .1rem .3rem; opacity: .6; }
  .chat-img { max-width: 200px; }
}
.doc-filters { display: flex; flex-direction: column; gap: .6rem; margin-bottom: 1rem; }
.doc-search {
  font: inherit; padding: .5rem .75rem; border: 1px solid var(--line); border-radius: 999px; background: var(--field); color: var(--ink);
  max-width: 24rem; width: 100%;
}
.doc-row { align-items: flex-start; }
.doc-type {
  display: inline-block; font-size: .7rem; font-weight: 700; letter-spacing: .05em; padding: .05rem .4rem; border-radius: 4px;
  background: var(--accent-soft); color: var(--accent); vertical-align: 2px;
}
.doc-desc { font-size: .9rem; margin-top: .15rem; }
.doc-input { max-width: none; width: 100%; }
.phone-input, .code-input {
  font: inherit; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 8px; background: var(--field); color: var(--ink);
  max-width: 16rem;
}
.code-input { max-width: 8rem; letter-spacing: .2em; font-variant-numeric: tabular-nums; }
.consent { display: flex; gap: .5rem; align-items: flex-start; margin: .75rem 0 0; max-width: 60ch; }
.consent input { margin-top: .2rem; }
table.prefs td:nth-child(n+2), table.prefs th:nth-child(n+2) { text-align: center; width: 5rem; }

table.report td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.report th:nth-child(n+3):nth-child(-n+8) { text-align: right; }
table.report tr.zero td { color: var(--muted); background: var(--zero-row); }
table.report tr.totals td { border-top: 2px solid var(--line); font-weight: 600; }
.bar-cell { width: 22%; min-width: 80px; }
.bar { height: 10px; border-radius: 999px; background: var(--accent); min-width: 2px; }

.class-row.conflict {
  background: var(--danger-soft); border-left: 4px solid var(--danger); border-bottom-style: solid;
  padding-left: .6rem; margin: .25rem -.4rem; padding-right: .4rem; border-radius: 6px;
}
.pill-conflict { background: var(--danger-pill); color: var(--danger); font-weight: 600; }
.notice-conflict { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger-line); }
.notice-conflict .small { color: var(--ink); margin-top: .25rem; }

.assign-controls { margin-top: .45rem; }
.assignment { margin-bottom: .3rem; }
.assign-row { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }

.availability-summary { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; }

.editor { margin-top: .75rem; padding-top: .75rem; border-top: 1px solid var(--line); }
.editor label { font-size: .9rem; }
.window-row { display: flex; align-items: center; gap: .5rem; margin: .4rem 0; flex-wrap: wrap; }
.editor-actions { display: flex; gap: .5rem; margin-top: .75rem; flex-wrap: wrap; }

table.users { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.users th, table.users td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.users th { font-weight: 600; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.table-wrap { overflow-x: auto; }

.notice { padding: .75rem 1rem; border-radius: 8px; background: var(--warn-soft); color: var(--warn); margin-bottom: 1rem; }
.error { color: var(--danger); }

.toast {
  position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); max-width: calc(100% - 32px);
  background: var(--toast-bg); color: #fff; padding: .6rem 1.1rem; border-radius: 999px; font-size: .9rem; z-index: 20;
}
.toast.error-toast { background: #a33b3b; }

/* Section navigation: top row on phones (above), left sidebar on computers */
.tab-group { display: none; }
@media (min-width: 900px) {
  .container { max-width: 1200px; }
  .main-layout { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 28px; align-items: start; }
  .main-content { min-width: 0; }
  .main-layout .tabs {
    flex-direction: column; gap: .15rem; margin: 0; padding: .25rem .5rem .25rem 0;
    border-bottom: none; border-right: 1px solid var(--line); overflow: visible;
    position: sticky; top: calc(env(safe-area-inset-top, 0px) + 88px);
  }
  .main-layout .tab {
    text-align: left; white-space: normal; padding: .55rem .8rem; border-bottom: none;
    border-left: 3px solid transparent; border-radius: 0 8px 8px 0;
  }
  .main-layout .tab:hover { background: var(--surface-2); color: var(--ink); }
  .main-layout .tab[aria-selected="true"] { border-left-color: var(--brand-gold); background: var(--accent-soft); color: var(--heading); }
  .tab-group {
    display: block; margin: .9rem 0 .2rem .8rem; font-size: .7rem; font-weight: 600; letter-spacing: .1em;
    text-transform: uppercase; color: var(--muted);
  }
}

@media (max-width: 560px) {
  .class-row { flex-direction: column; align-items: flex-start; }
  .brand-sub { display: none; }
  .brand-logo { height: 40px; }
  .top-actions { gap: .6rem; }
  .who span { display: none; }
  .theme-toggle { padding: .25rem .6rem; }
}
