:root { --ink:#14232b; --muted:#647680; --line:#dbe3e7; --bg:#f3f6f7; --card:#fff; --brand:#0f766e; --brand-ink:#fff; --danger:#b42318; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
h1, h2, h3 { margin: 0; text-wrap: balance; }
a { color: inherit; text-decoration: none; }
input, select, button { font: inherit; color: inherit; }
input, select { border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; background: #fff; min-width: 0; }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.muted { color: var(--muted); font-size: 13px; }
.pad { padding: 12px; }
.grow { flex: 1; }
.row { display: flex; align-items: center; gap: 8px; }
.error { color: var(--danger); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #b8c6cc; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.btn.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: inherit; }
.btn.danger { color: var(--danger); }
.btn.small { padding: 3px 8px; font-size: 12px; }
.btn.block { width: 100%; margin-top: 8px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 50; }
.toast.bad { background: var(--danger); }

.auth { max-width: 380px; margin: 9vh auto; padding: 28px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; display: flex; flex-direction: column; gap: 14px; }
.auth input { width: 100%; padding: 10px 12px; }
.tv .auth input { font-size: 28px; letter-spacing: .3em; text-align: center; }
.link { color: var(--brand); text-align: center; }

.shell { display: grid; grid-template: "top top" auto "side main" 1fr / 220px 1fr; height: 100%; }
.top { grid-area: top; display: flex; align-items: center; gap: 12px; padding: 10px 18px; background: var(--ink); color: #fff; }
.brand { font-weight: 800; letter-spacing: .02em; font-size: 17px; }
.ws, .who { opacity: .75; font-size: 13px; }
.side { grid-area: side; background: var(--card); border-right: 1px solid var(--line); padding: 14px 10px; overflow: auto; display: flex; flex-direction: column; gap: 2px; }
.nav { padding: 8px 10px; border-radius: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav:hover { background: var(--bg); }
.nav.active { background: #e3f1ef; color: var(--brand); font-weight: 600; }
.side-label, .panel-label { margin: 16px 0 4px; padding: 0 10px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.panel-label { padding: 0; }
.main { grid-area: main; overflow: auto; padding: 20px 24px 40px; min-width: 0; }
.page-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h2 { flex: 1; }
.title-input { font-size: 20px; font-weight: 700; border-color: transparent; background: transparent; width: 260px; }
.title-input:hover { border-color: var(--line); }
.status { font-size: 12px; color: var(--brand); }
.status.dirty { color: #a15c07; }
.code { font: 600 14px ui-monospace, Menlo, Consolas, monospace; background: var(--ink); color: #fff; padding: 3px 8px; border-radius: 6px; letter-spacing: .08em; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.stats b { display: block; font-size: 28px; font-variant-numeric: tabular-nums; }
.stats small, .board-card small { color: var(--muted); letter-spacing: .06em; font-size: 11px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.board-card { display: flex; flex-direction: column; gap: 6px; }
.card-title { font-size: 17px; font-weight: 700; }
.card-title:hover { color: var(--brand); }
.form-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; }
.form-row h3 { width: 100%; font-size: 15px; }

.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 6px 8px; border-bottom: 1px solid #eef2f4; }
.table.edit input { width: 100%; }
.table.edit input[type=number] { max-width: 90px; font-variant-numeric: tabular-nums; }
.photo { width: 34px; height: 34px; border-radius: 8px; border: 1px dashed var(--line); background: var(--bg); cursor: pointer; padding: 0; overflow: hidden; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }

.editor { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 18px; align-items: start; }
.editor.one { grid-template-columns: minmax(0, 1fr); }
.editor > .card { overflow-x: auto; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px 14px 16px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; font-size: 13px; }
.field small { color: var(--muted); }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; margin-top: 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; cursor: pointer; }
.toggle input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand); }
.toggle input[type=color] { width: 40px; height: 26px; padding: 0; border: 1px solid var(--line); }

.cal-edit { display: grid; grid-template-columns: repeat(7, minmax(92px, 1fr)); gap: 6px; margin-top: 12px; }
.cal-edit .dow { font-size: 12px; color: var(--muted); text-align: center; }
.day { border: 1px solid var(--line); border-radius: 8px; padding: 6px; display: flex; flex-direction: column; gap: 4px; min-height: 96px; }
.day.closed { background: var(--bg); color: var(--muted); }
.day label { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 12px; }
.day input { width: 58px; padding: 3px 5px; text-align: right; }

.stage { aspect-ratio: 16 / 9; width: 100%; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; box-shadow: 0 8px 28px rgba(20, 35, 43, .12); }
body.tv { background: #0c1318; }
#tv { height: 100%; }

/* ------------------------------------------------ the board itself (sized in container units so it scales to any screen) */
.rb { container-type: size; height: 100%; width: 100%; background: var(--rb-bg); color: var(--rb-ink); display: flex; flex-direction: column; gap: 1.6cqh; padding: 2.4cqh 1.6cqw; overflow: hidden; }
.rb-head { display: flex; align-items: center; gap: 1.4cqw; background: var(--rb-header); color: var(--rb-header-ink); border-radius: var(--rb-radius); padding: 1.8cqh 1.6cqw; }
.rb-logo { height: 8cqh; max-width: 14cqw; object-fit: contain; background: #fff; border-radius: calc(var(--rb-radius) * .6); padding: .5cqh; }
.rb-titles { flex: 1; min-width: 0; }
.rb-kicker { font-size: 1.9cqh; letter-spacing: .22em; text-transform: uppercase; opacity: .8; }
.rb-title { font-size: 4.6cqh; font-weight: 800; line-height: 1.1; }
.rb-chips { display: flex; gap: .8cqw; }
.rb-chip { background: var(--rb-surface); color: var(--rb-ink); border-radius: 99px; padding: .9cqh 1.2cqw; font-size: 2cqh; display: flex; gap: .6cqw; align-items: baseline; white-space: nowrap; }
.rb-chip span { text-transform: uppercase; letter-spacing: .06em; font-size: 1.5cqh; opacity: .7; }
.rb-chip b { font-variant-numeric: tabular-nums; }

.rb-rows { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: .8cqh; --row: calc((100cqh - 24cqh) / (var(--n) + 1.2)); }
.rb-row { flex: 1; min-height: 0; display: flex; align-items: center; gap: 1cqw; background: var(--rb-surface); border-radius: var(--rb-radius); padding: 0 1.2cqw; font-size: min(calc(var(--row) * .42), 3.4cqh); border: .25cqh solid transparent; }
.rb-row.rb-top1 { flex: 2.2; font-size: min(calc(var(--row) * .8), 5.4cqh); }
.rb-glow .rb-top { border-color: var(--rb-accent); }
.rb-glow .rb-top1 { box-shadow: 0 0 2.4cqh color-mix(in srgb, var(--rb-accent) 45%, transparent); }
.rb-rank { width: 2.2em; text-align: center; font-weight: 800; opacity: .75; font-variant-numeric: tabular-nums; }
.rb-avatar { height: 78%; aspect-ratio: 1; border-radius: calc(var(--rb-radius) * .6); object-fit: cover; flex: none; }
.rb-initials { display: grid; place-items: center; background: color-mix(in srgb, var(--rb-accent) 18%, var(--rb-surface)); font-size: .7em; font-weight: 700; }
.rb-name { width: 22cqw; font-weight: 700; text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rb-bar { flex: 1; height: 38%; min-height: .8cqh; background: color-mix(in srgb, var(--rb-ink) 9%, transparent); border-radius: 99px; overflow: hidden; }
.rb-bar i { display: block; height: 100%; background: var(--rb-accent); border-radius: 99px; transition: width .6s ease; }
.rb-extra { font-size: .62em; opacity: .8; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rb-goal { border: .15cqh solid color-mix(in srgb, var(--rb-ink) 25%, transparent); border-radius: 99px; padding: .1em .7em; }
.rb-value { min-width: 3.4em; text-align: right; line-height: 1; }
.rb-value b { display: block; font-variant-numeric: tabular-nums; }
.rb-value small { font-size: .42em; text-transform: uppercase; letter-spacing: .1em; opacity: .65; }
.rb-empty { margin: auto; font-size: 3cqh; opacity: .6; }

.rb-cal-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 1cqh; }
.rb-cal { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(7, 1fr); grid-template-rows: auto repeat(var(--weeks), 1fr); gap: 1cqh .8cqw; }
.rb-dow { text-align: center; font-size: 2.2cqh; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; opacity: .6; background: var(--rb-surface); border-radius: var(--rb-radius); padding: .5cqh 0; }
.rb-day { position: relative; background: var(--rb-surface); border-radius: var(--rb-radius); display: grid; place-items: center; min-height: 0; border: .25cqh solid color-mix(in srgb, var(--rb-ink) 12%, transparent); }
.rb-day b { font-size: 5.2cqh; font-variant-numeric: tabular-nums; }
.rb-date { position: absolute; top: .6cqh; right: .8cqw; font-size: 1.8cqh; opacity: .7; }
.rb-day-foot { position: absolute; bottom: .5cqh; left: 0; right: 0; display: flex; justify-content: center; gap: 1cqw; font-size: 1.6cqh; opacity: .75; }
.rb-blank { background: transparent; border-color: transparent; }
.rb-hit { background: color-mix(in srgb, #1f9d55 22%, var(--rb-surface)); border-color: #1f9d55; }
.rb-miss { background: color-mix(in srgb, #d64545 20%, var(--rb-surface)); border-color: #d64545; }
.rb-future { opacity: .78; }
.rb-today { outline: .5cqh solid var(--rb-accent); outline-offset: .2cqh; opacity: 1; }
.rb-closed { background: color-mix(in srgb, var(--rb-accent) 16%, var(--rb-surface)); border-color: color-mix(in srgb, var(--rb-accent) 50%, transparent); }
.rb-closed em { font-style: normal; font-size: 2.2cqh; letter-spacing: .14em; text-transform: uppercase; opacity: .7; }
.rb-cal-foot { background: var(--rb-surface); border-radius: var(--rb-radius); padding: .7cqh 1.2cqw; font-size: 1.8cqh; white-space: pre; }

.rb-ticker { background: var(--rb-header); color: var(--rb-header-ink); border-radius: var(--rb-radius); overflow: hidden; white-space: nowrap; font-size: 2.6cqh; padding: .8cqh 0; }
.rb-ticker span { display: inline-block; padding-left: 100%; animation: rb-scroll 28s linear infinite; }
@keyframes rb-scroll { to { transform: translateX(-100%); } }
@media (prefers-reduced-motion: reduce) { .rb-ticker span { animation: none; padding-left: 1.2cqw; } .rb-bar i { transition: none; } }

@media (max-width: 900px) {
  .shell { grid-template: "top" auto "side" auto "main" 1fr / 1fr; }
  .side { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .side-label { display: none; }
  .editor { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: 1fr; }
}
