/* Sonaria dashboard: the game's dark song-select palette. Sidebar + content on a laptop; a top bar on a phone. */
:root {
  --bg: #0D0E14;
  --panel: #13151D;
  --card: #161821;
  --control: #1A1D28;
  --line: #262938;
  --line-strong: #2E3242;
  --text: #F2F3F7;
  --text-2: #C9CDD9;
  --muted: #A3A9BC;
  --accent: #7FE3FF;
  --ink: #14151C;
  --gold: #FFD23F;
  --danger: #FF6B81;
  --ok: #6BF2A2;
  --d0: #6BF2A2;
  --d1: #5EC8FF;
  --d2: #FFB35C;
  --d3: #FF7A95;
  --head: "Chakra Petch", "Arial Narrow", system-ui, sans-serif;
  --body: "Outfit", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 12px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 14px/1.45 var(--body); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--head); margin: 0; letter-spacing: .02em; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-family: var(--head); font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.boot { padding: 48px 24px; color: var(--muted); text-align: center; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 22px;
  padding: 20px 14px; background: var(--panel); border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--card); border: 1px solid var(--line-strong); display: grid; place-items: center; flex: none; }
.brand-mark i { display: block; width: 14px; height: 3px; border-radius: 2px; background: var(--accent); box-shadow: 0 -6px 0 -0.5px var(--gold); }
.brand b { font: 700 16px var(--head); letter-spacing: .14em; }
.brand span { display: block; font: 600 10px var(--head); letter-spacing: .18em; color: var(--muted); text-transform: uppercase; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--text-2);
  font: 600 12px var(--head); letter-spacing: .12em; text-transform: uppercase; text-decoration: none; white-space: nowrap;
}
.nav a:hover { background: var(--control); }
.nav a[aria-current="page"] { background: var(--accent); color: var(--ink); }
.me { margin-top: auto; padding: 12px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.me b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
main { min-width: 0; padding: 26px 30px 56px; }

/* ---------- hiding the sidebar ---------- */
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0; border-radius: 10px; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); color: var(--text-2);
}
.icon-btn:hover { border-color: var(--muted); color: var(--text); }
.side-toggle { position: fixed; z-index: 30; top: 18px; left: calc(224px - 14px - 34px); }
.layout.side-hidden { grid-template-columns: minmax(0, 1fr); }
.layout.side-hidden .sidebar { display: none; }
.layout.side-hidden .side-toggle { left: 14px; }
.layout.side-hidden main { padding-left: 64px; }
.layout.side-hidden main.editor-view { padding-left: 58px; }
main.editor-view:fullscreen, main.editor-max { padding-left: 12px !important; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 20px; margin-bottom: 18px; }
.page-head h1 { font-size: 24px; }
.page-head p { margin: 2px 0 0; color: var(--muted); }
.page-head .actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.crumb { display: inline-block; margin-bottom: 8px; font: 600 11px var(--head); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

@media (max-width: 1100px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 800px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .sidebar {
    position: sticky; z-index: 20; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; align-content: flex-start; gap: 8px 12px;
    padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--line);
  }
  .brand span { display: none; }
  /* on a phone the bar is at the top: the button sits at its right end, and hiding the bar frees the whole screen */
  .side-toggle { top: 10px; left: auto; right: 16px; }
  .layout.side-hidden .side-toggle { left: auto; right: 12px; }
  .layout.side-hidden main, .layout.side-hidden main.editor-view { padding-left: 16px; padding-top: 52px; }
  .sidebar .me { margin-right: 44px; }
  .brand { flex: 1; }
  /* the pages get a row of their own under the brand, so every one is in view on a phone */
  .nav { order: 3; flex: 1 0 100%; flex-direction: row; overflow-x: auto; min-width: 0; scrollbar-width: none; }
  .nav a { padding: 8px 10px; }
  .me { margin: 0; padding: 0; background: none; border: 0; flex-direction: row; align-items: center; }
  .me .who { display: none; }
  main { padding: 18px 16px 48px; }
}

/* ---------- cards, tiles ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.card-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 12px; margin-bottom: 12px; }
.card-head h2 { font-size: 13px; letter-spacing: .14em; text-transform: uppercase; }
.card-head p { margin: 0; color: var(--muted); font-size: 12px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile .label { font: 600 11px var(--head); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.tile .value { font: 700 26px var(--head); font-variant-numeric: tabular-nums; margin: 4px 0 2px; }
.tile .sub { font-size: 12px; color: var(--muted); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
  font: 600 10px var(--head); letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
}
td { padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.right, th.right { text-align: right; }
td.wrap { white-space: normal; min-width: 160px; }
tbody tr:hover { background: rgba(255, 255, 255, .02); }
.cell-name b { font-weight: 600; }
.cell-name span { display: block; color: var(--muted); font-size: 12px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: nowrap; }

/* ---------- chips, badges ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; white-space: nowrap;
  font: 700 10px var(--head); letter-spacing: .1em; text-transform: uppercase; color: var(--ink); background: var(--muted);
}
.chip.d0 { background: var(--d0); } .chip.d1 { background: var(--d1); } .chip.d2 { background: var(--d2); } .chip.d3 { background: var(--d3); }
.chip.ghost { background: transparent; color: var(--muted); border: 1px dashed var(--line-strong); }
.badge {
  display: inline-block; padding: 1px 7px; border-radius: 6px; white-space: nowrap;
  font: 600 10px var(--head); letter-spacing: .12em; text-transform: uppercase; border: 1px solid var(--line-strong); color: var(--text-2);
}
.badge.on { color: var(--ok); border-color: rgba(107, 242, 162, .4); }
.badge.off { color: var(--muted); }
.badge.danger { color: var(--danger); border-color: rgba(255, 107, 129, .45); }
.badge.admin { color: var(--gold); border-color: rgba(255, 210, 63, .45); }
.badge.charter { color: var(--accent); border-color: rgba(127, 227, 255, .45); }
.clear { font: 700 11px var(--head); letter-spacing: .08em; color: var(--text-2); }
.clear.c2 { color: var(--accent); }
.clear.c3 { color: var(--gold); }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 34px; padding: 6px 14px;
  border-radius: 10px; border: 1px solid var(--line-strong); background: var(--control); color: var(--text); cursor: pointer;
  font: 600 12px var(--head); letter-spacing: .1em; text-transform: uppercase; white-space: nowrap; text-decoration: none;
}
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); border-color: rgba(255, 107, 129, .45); }
.btn.danger.solid { background: var(--danger); color: var(--ink); border-color: var(--danger); }
.btn.small { min-height: 28px; padding: 3px 10px; font-size: 11px; border-radius: 8px; }
.btn.link { background: none; border-color: transparent; color: var(--accent); padding-left: 6px; padding-right: 6px; }
label.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
label.field > span { font: 600 10px var(--head); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
label.field small { color: var(--muted); font-size: 12px; }
.input, select.input {
  width: 100%; min-height: 36px; padding: 7px 11px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--control); color: var(--text);
}
.input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(127, 227, 255, .18); }
.input:disabled { color: var(--muted); }
.input.level { width: 66px; min-height: 30px; padding: 4px 8px; text-align: center; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.form-foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 14px; }
.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.toolbar .input { width: auto; flex: 1 1 200px; max-width: 320px; }
.toolbar select.input { flex: 0 1 180px; }
.switch {
  display: inline-flex; align-items: center; gap: 10px; padding: 6px 12px 6px 6px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--control); font: 600 11px var(--head); letter-spacing: .12em; text-transform: uppercase;
}
.switch i { width: 34px; height: 20px; border-radius: 999px; background: var(--line-strong); position: relative; transition: background .15s; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--text-2); transition: transform .15s; }
.switch[aria-pressed="true"] i { background: var(--accent); }
.switch[aria-pressed="true"] i::after { transform: translateX(14px); background: var(--ink); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; color: var(--muted); font-size: 12px; }
.pager div { display: flex; gap: 6px; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tabs .chip { cursor: pointer; border: 0; opacity: .45; }
.tabs .chip[aria-pressed="true"] { opacity: 1; }
.filter-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 12px; border-radius: 999px; background: var(--control); border: 1px solid var(--line-strong); font-size: 12px; }

/* ---------- states ---------- */
.state { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 36px 16px; color: var(--muted); text-align: center; }
.state.inline { padding: 18px 8px; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-text { color: var(--danger); font-size: 13px; min-height: 1em; margin: 8px 0 0; }

/* ---------- sign in ---------- */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.signin .card { width: min(380px, 100%); padding: 26px 24px; display: flex; flex-direction: column; gap: 14px; }
.signin h1 { font-size: 22px; }
.signin p { margin: 0; color: var(--muted); }
.signin .btn { width: 100%; min-height: 40px; }
.notice { padding: 10px 12px; border-radius: 10px; background: rgba(255, 107, 129, .1); border: 1px solid rgba(255, 107, 129, .35); color: #ffc2cc; font-size: 13px; }

/* ---------- overview ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font: 600 10px var(--head); }
.chart .bar { fill: var(--accent); }
.chart .day:hover .bar { fill: var(--gold); }
.chart .hit { fill: transparent; }
.meter { height: 10px; border-radius: 999px; background: var(--control); border: 1px solid var(--line); overflow: hidden; margin: 8px 0 6px; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.meter i.warn { background: var(--d2); }
.meter i.full { background: var(--danger); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; }
.subhead { margin: 16px 0 0; font: 600 10px var(--head); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }

/* ---------- songs ---------- */
.song-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.song-card {
  display: flex; gap: 12px; padding: 12px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line);
  color: var(--text); text-decoration: none; min-width: 0;
}
.song-card:hover { border-color: var(--accent); text-decoration: none; background: #1C2030; }
.song-card .info { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.song-card .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.song-card .by { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.song-card .chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: auto; }
.jacket { width: 72px; height: 72px; border-radius: 10px; flex: none; object-fit: cover; background: var(--control); display: grid; place-items: center; overflow: hidden; }
.jacket.big { width: 96px; height: 96px; }
.jacket.huge { width: 168px; height: 168px; border-radius: 12px; }
.jacket.placeholder { color: rgba(20, 21, 28, .55); font: 700 28px var(--head); }
.jacket.big.placeholder { font-size: 36px; }
.jacket.huge.placeholder { font-size: 56px; }
.song-head { display: flex; gap: 16px; align-items: center; min-width: 0; }
.song-head .titles { min-width: 0; }
.song-head h1 { font-size: 24px; overflow-wrap: anywhere; }
.song-head p { margin: 2px 0 0; color: var(--muted); overflow-wrap: anywhere; }
.song-head p.pron { margin: 0; color: var(--text-2); }
.media-row { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.media-row .grow { flex: 1 1 220px; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.media-block + .media-block { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.media-block h3 { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
audio { width: 100%; height: 36px; }
progress { width: 100%; height: 8px; accent-color: var(--accent); }
.danger-zone { border-color: rgba(255, 107, 129, .35); }
.danger-zone .card-head h2 { color: var(--danger); }
.danger-zone p { margin: 0 0 12px; color: var(--muted); }

/* ---------- dialogs ---------- */
dialog.modal { padding: 0; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--panel); color: var(--text); width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 48px); }
dialog.modal.wide { width: min(720px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: rgba(5, 6, 10, .72); }
.modal-box { display: flex; flex-direction: column; gap: 14px; padding: 20px; }
.modal-box h2 { font-size: 18px; }
.modal-box > p { margin: 0; color: var(--text-2); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 100; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 10px; background: var(--card); border: 1px solid var(--line-strong);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45); transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { border-color: rgba(127, 227, 255, .5); }
.toast.error { border-color: rgba(255, 107, 129, .6); color: #ffc2cc; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation-duration: 0s !important; }
  .spinner { animation: none; border-top-color: var(--line-strong); }
}

/* ---------- studio: roles, the songs master table, the editor, announcements, classes ---------- */
.badge.superadmin { color: #FF9FD0; border-color: rgba(255, 159, 208, .5); }
.card.flush { padding: 0; overflow: hidden; }
.card.flush .table-wrap { margin: 0; padding: 0; }
table.master th, table.master td { padding-top: 8px; padding-bottom: 8px; }
table.master td:first-child, table.master th:first-child { padding-left: 16px; }
th .sort { all: unset; cursor: pointer; }
th .sort:hover, th .sort[aria-sort] { color: var(--text); }
th .sort[aria-sort="ascending"]::after { content: " ▲"; font-size: 9px; }
th .sort[aria-sort="descending"]::after { content: " ▼"; font-size: 9px; }
th .sort:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.song-cell { display: flex; align-items: center; gap: 10px; color: var(--text); min-width: 200px; }
.song-cell:hover b { color: var(--accent); }
.jacket.small { width: 40px; height: 40px; border-radius: 7px; font-size: 16px; }
.chart-cell { white-space: nowrap; }
.chart-cell .chart-link { display: inline-flex; flex-direction: column; gap: 2px; color: var(--text); vertical-align: middle; }
.chart-cell .chart-link:hover .chip { filter: brightness(1.12); }
.chart-cell .danger-text { color: var(--danger); vertical-align: middle; min-height: 24px; }
.chart-cell.empty .ghost-btn { border-style: dashed; color: var(--muted); }
.chart-cell.empty .ghost-btn:hover { color: var(--text); }

/* the editor, full size in the studio */
main.editor-view { padding: 10px 12px 12px; display: flex; flex-direction: column; height: 100vh; }
.editor-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-bottom: 8px; min-height: 36px; }
.editor-head .spacer { flex: 1; }
.full-btn { display: inline-flex; align-items: center; gap: 6px; }
/* full screen: the browser's, or (where there is none) filling the window */
main.editor-view:fullscreen { background: var(--bg); height: 100vh; width: 100vw; }
main.editor-view:-webkit-full-screen { background: var(--bg); height: 100vh; width: 100vw; }
main.editor-max { position: fixed; inset: 0; z-index: 60; background: var(--bg); height: 100dvh; padding: max(10px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)); }
main.editor-max #editor-frame, main.editor-view:fullscreen #editor-frame { min-height: 0; }
html.no-scroll { overflow: hidden; }
.editor-head .crumb { margin: 0; }
#editor-frame { flex: 1 1 auto; width: 100%; min-height: 520px; border: 1px solid var(--line); border-radius: var(--radius); background: #0c0e16; }
@media (max-width: 800px) { main.editor-view { height: auto; } #editor-frame { height: 80vh; } }

/* announcements */
.ann-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); gap: 16px; }
.ann-card .card-head h2 { font-size: 12px; }
.ann-preview { background: var(--panel); border: 1px solid var(--line-strong); border-radius: 12px; overflow: hidden; }
.ann-preview img, .ann-noimg { display: block; width: 100%; aspect-ratio: 2 / 1; object-fit: cover; background: var(--control); }
.ann-noimg { display: grid; place-items: center; color: var(--muted); font: 600 12px var(--head); letter-spacing: .14em; text-transform: uppercase; }
.ann-text { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; }
.ann-text b { font: 700 16px var(--head); letter-spacing: .04em; }
.ann-text p { margin: 0; color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; }
textarea.input { resize: vertical; min-height: 96px; font: inherit; }

/* classes */
details.class-card > summary { cursor: pointer; list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font: 600 15px var(--head); }
details.class-card > summary::-webkit-details-marker { display: none; }
details.class-card > summary::before { content: "▸"; color: var(--muted); margin-right: 6px; transition: transform .15s; }
details.class-card[open] > summary::before { transform: rotate(90deg); }
details.class-card[open] > summary { margin-bottom: 14px; }
.class-songs { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.class-song { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.class-song select.input { width: auto; flex: 1 1 160px; min-width: 0; }
.class-song .num { width: 22px; }
