/* duwp VPS panel — "Graphite": dark, compact, precise, one violet accent */
:root {
  --bg: #0b0b0d;
  --sidebar: #0f0f12;
  --surface: #131317;
  --inset: #0f0f12;
  --console: #09090b;
  --border: #1f1f24;
  --border-hi: #2c2c33;
  --divider: #18181c;
  --hover: #18181c;
  --selected: #1c1c22;
  --text: #e6e6ea;
  --text-2: #c9c9d1;
  --muted: #8a8a96;
  --faint: #6b6b76;
  --accent: #8b7cff;
  --accent-hi: #a497ff;
  --accent-ink: #0b0b0d;
  --accent-soft: #1a1830;
  --accent-line: #34306b;
  --text-strong: #f2f2f5;
  --nav-text: #a1a1ad;
  --field-border: #24242a;
  --topbar-bg: rgba(11, 11, 13, .88);
  --scroll: #2e3037;
  --scroll-hi: #3a3a42;
  --warn-bg: #1c150a;
  --warn-line: #3d2c12;
  --shadow: rgba(0, 0, 0, .55);
  --ok: #3ecf8e;
  --ok-text: #6fe0ad;
  --ok-bg: #0f1a15;
  --ok-line: #1f3a2d;
  --warn: #f5a524;
  --bad: #ff8a95;
  --bad-bg: #1a1012;
  --bad-line: #3a1d22;
  --radius: 8px;
  --radius-lg: 10px;
  --display: Inter, system-ui, sans-serif;
  --body: Inter, system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --sidebar-w: 240px;
  --topbar-h: 48px;
  color-scheme: dark;
}

/* Light theme: same layout, zinc/stone neutrals, a deeper violet for contrast.
   Consoles stay dark (see .console-card / .logs-body). */
:root[data-theme="light"] {
  --bg: #fafafa;
  --sidebar: #f4f4f5;
  --surface: #ffffff;
  --inset: #f7f7f8;
  --border: #e4e4e7;
  --border-hi: #d4d4d8;
  --divider: #ececef;
  --hover: #ececef;
  --selected: #e7e7eb;
  --text: #18181b;
  --text-2: #3f3f46;
  --muted: #5f5f6b;
  --faint: #8a8a96;
  --accent: #6d5dfc;
  --accent-hi: #5b4be8;
  --accent-ink: #ffffff;
  --accent-soft: #efedff;
  --accent-line: #c9c2ff;
  --text-strong: #09090b;
  --nav-text: #52525b;
  --field-border: #d4d4d8;
  --topbar-bg: rgba(250, 250, 250, .88);
  --scroll: #d4d4d8;
  --scroll-hi: #a1a1aa;
  --ok: #16a34a;
  --ok-text: #15803d;
  --ok-bg: #ecfdf3;
  --ok-line: #bbf7d0;
  --warn: #b45309;
  --warn-bg: #fff7e6;
  --warn-line: #fcd9a0;
  --bad: #c62a3a;
  --bad-bg: #fff1f2;
  --bad-line: #fecdd3;
  --shadow: rgba(24, 24, 27, .14);
  color-scheme: light;
}
/* Terminal areas keep their dark look in both themes. */
.console-card, .logs-body {
  --text: #e6e6ea; --text-2: #c9c9d1; --muted: #8a8a96; --faint: #6b6b76;
  --border: #1f1f24; --divider: #1c1c21; --accent-hi: #a497ff;
  color: var(--text);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 13px/1.5 var(--body); font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; font-family: var(--display); font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 14px; }
h2 { font-size: 15px; }
a { color: var(--accent-hi); }
a:hover { color: var(--text); }
code { font-family: var(--mono); color: var(--accent-hi); font-size: .9em; }
.sub, .hint, .meta { color: var(--muted); font-size: 12px; }
.hint, .meta { margin: 6px 0 0; }
.mono { font-family: var(--mono); }
[hidden], .hidden { display: none !important; }

/* ---------------------------------------------------------- scrollbar -- */
* { scrollbar-width: thin; scrollbar-color: var(--scroll) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--scroll-hi); border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-corner { background: transparent; }

/* ------------------------------------------------------------- layout -- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 30;
  display: flex; flex-direction: column; gap: 14px; padding: 12px 10px;
  background: var(--sidebar); border-right: 1px solid var(--border); overflow-y: auto;
}
.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }

.brand { display: flex; align-items: center; gap: 8px; padding: 6px 8px; }
.brand strong { font-family: var(--display); font-size: 13px; font-weight: 600; color: var(--text-strong); }
.brand-mark {
  width: 22px; height: 22px; border-radius: 6px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--accent-ink); font-family: var(--display); font-weight: 700; font-size: 12px;
}

.server-chip {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.server-chip-text { display: grid; min-width: 0; }
.server-chip-name { font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--faint); }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }

.nav { display: grid; gap: 1px; }
.nav a {
  display: flex; align-items: center; gap: 10px; height: 30px; padding: 0 8px; border-radius: 6px;
  color: var(--nav-text); text-decoration: none; font-weight: 500;
}
.nav svg, .icon-link svg, .btn.icon svg {
  width: 16px; height: 16px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.nav a:hover { background: var(--hover); color: var(--text-strong); }
.nav a.active { background: var(--selected); color: var(--text-strong); }
.nav a.active svg { color: var(--accent-hi); }
.nav-label { margin: 12px 8px 4px; font-size: 11px; font-weight: 600; color: var(--muted); }

.viewer {
  margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 10px 8px 2px;
  border-top: 1px solid var(--border);
}
.viewer img, .viewer-avatar { width: 26px; height: 26px; border-radius: 50%; }
.viewer-text { display: grid; min-width: 0; flex: 1; }
.viewer-text > span:first-child { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-link { display: inline-flex; padding: 6px; border-radius: 6px; color: var(--muted); }
.icon-link:hover { color: var(--text-strong); background: var(--hover); }

.topbar {
  position: sticky; top: 0; z-index: 10; height: var(--topbar-h);
  display: flex; align-items: center; gap: 10px; padding: 0 20px;
  background: var(--topbar-bg); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.topbar .sub { margin-left: auto; }
#menu-toggle { display: none; }

.page { padding: 20px; display: grid; gap: 16px; align-content: start; }
.empty { color: var(--muted); margin: 0; }
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); z-index: 25; }

/* ----------------------------------------------------- dashboard hero -- */
.hero {
  display: grid; gap: 18px; padding: 18px 20px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.hero-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap; }
.hero-title { display: grid; gap: 10px; min-width: 0; }
.hero-name { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.hero-name h2 { font-size: 20px; font-weight: 600; line-height: 1.2; letter-spacing: -0.02em; color: var(--text-strong); }
.badge {
  font-size: 11.5px; font-weight: 500; padding: 2px 9px; border-radius: 999px;
  color: var(--ok-text); background: var(--ok-bg); border: 1px solid var(--ok-line);
}
.badge::before { content: "● "; }
.badge.bad { color: var(--bad); background: var(--bad-bg); border-color: var(--bad-line); }
.badge.warn { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-line); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font-size: 12px; color: var(--text-2); padding: 2px 8px; border-radius: 999px;
  background: var(--inset); border: 1px solid var(--border); text-decoration: none;
}
.chip-link:hover { color: var(--text-strong); border-color: var(--border-hi); }
button.chip { cursor: pointer; font-family: var(--mono); }
button.chip:hover { color: var(--text-strong); border-color: var(--border-hi); }
.hero-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.tile { display: grid; gap: 6px; padding: 12px 14px; background: var(--inset); align-content: start; }
.tile-label { font-size: 12px; font-weight: 500; color: var(--muted); }
.tile-value { font-family: var(--mono); font-size: 18px; font-weight: 500; line-height: 1.2; font-variant-numeric: tabular-nums; color: var(--text-strong); }
.tile-value small { font-size: 12px; color: var(--muted); font-weight: 400; }
.tile-sub { font-size: 12px; color: var(--muted); }
.bar { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--text-2); border-radius: 2px; transition: width .4s; }
.bar i.hot { background: var(--bad); }

/* ------------------------------------------------ dashboard lower row -- */
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.dash-grid.single { grid-template-columns: minmax(0, 1fr); }
.console-card {
  display: flex; flex-direction: column; min-height: 360px; max-height: 520px;
  background: var(--console); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden;
}
.console-head { display: flex; justify-content: space-between; align-items: center; height: 40px; padding: 0 14px; border-bottom: 1px solid var(--divider); }
.console-title { font-family: var(--display); font-weight: 600; font-size: 13px; }
.console-head a { font-size: 12px; font-weight: 500; text-decoration: none; }
.console-body {
  flex: 1; margin: 0; padding: 12px 14px; overflow: auto;
  font: 12px/1.7 var(--mono); color: #a1a1ad; white-space: pre-wrap; word-break: break-word;
}
.console-foot { padding: 9px 14px; border-top: 1px solid var(--divider); font-size: 12px; color: var(--muted); }

.side-col { display: grid; gap: 10px; align-content: start; }
.side-title { font-size: 12px; font-weight: 600; color: var(--muted); padding: 0 2px; }
.service-rows { display: grid; gap: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.service-rows:empty { display: none; }
.service-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border-bottom: 1px solid var(--divider);
}
.service-row:last-child { border-bottom: 0; }
.service-row:hover { background: var(--hover); }
.service-row-text { display: grid; flex: 1; min-width: 0; }
.service-row-name { font-weight: 500; font-size: 13px; }
.service-row-meta { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.service-row-actions { display: flex; gap: 6px; }
.server-line { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 14px; padding: 8px 4px; font-size: 13px; color: var(--muted); }
.server-line b { color: var(--text-2); font-weight: 600; }

/* ------------------------------------------------------------ buttons -- */
.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 28px; padding: 0 10px; border-radius: 6px; border: 1px solid var(--field-border);
  background: var(--surface); color: var(--text); font: 500 12.5px/1 var(--body); cursor: pointer; text-decoration: none;
  transition: background .12s, border-color .12s;
}
.btn:hover { border-color: var(--border-hi); background: var(--hover); color: var(--text-strong); }
.btn:disabled { cursor: not-allowed; opacity: .55; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hi); border-color: var(--accent-hi); color: var(--accent-ink); }
.btn.primary { font-weight: 600; }
.btn.danger { background: var(--bad-bg); border-color: var(--bad-line); color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.big { height: 34px; padding: 0 14px; border-radius: 7px; font: 600 13px/1 var(--display); }
.btn.big:disabled { background: var(--inset); border-color: var(--border); color: var(--faint); opacity: 1; }
.btn.small { height: 24px; padding: 0 8px; font-size: 12px; border-radius: 5px; }
.btn.icon { width: 28px; padding: 0; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .nav a:focus-visible, .chip-link:focus-visible, .icon-link:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}

/* ------------------------------------------------------ panels, lists -- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.panel > .panel-head { margin-bottom: 12px; }
.panel > .panel-head + .hint { margin-top: -6px; }
.panel-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.list { list-style: none; margin: 12px 0 8px; padding: 0; display: grid; gap: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.list li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 12px; background: var(--inset); border-bottom: 1px solid var(--divider); font-size: 13px; }
.list li:last-child { border-bottom: 0; }
.list li .muted { color: var(--muted); }

input[type=search], input[type=text], input[type=password],  select, .field input:not([type=checkbox]), .field textarea {
  background: var(--inset); border: 1px solid var(--field-border); color: var(--text);
  border-radius: 6px; height: 30px; padding: 0 10px; font: 13px var(--body);
}
.field textarea { height: auto; padding: 8px 10px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent-line); outline: none; box-shadow: 0 0 0 3px rgba(139, 124, 255, .15); }
.check { color: var(--muted); font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
input[type=checkbox] { accent-color: var(--accent); }

/* --------------------------------------------------------------- logs -- */
.logs-page { height: calc(100vh - var(--topbar-h)); grid-template-rows: auto 1fr; }
.logs-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.logs-toolbar select { min-width: 210px; }
.logs-toolbar input[type=search] { width: 240px; }
.logs-body {
  margin: 0; min-height: 0; overflow: auto; padding: 12px 14px;
  background: var(--console); border: 1px solid var(--border); border-radius: var(--radius-lg);
  font: 12px/1.7 var(--mono); color: #a1a1ad; white-space: pre-wrap; word-break: break-word;
}

/* -------------------------------------------------------------- files -- */
.conn { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 14px 0; font-size: 13.5px; }
.conn dt { color: var(--muted); }
.conn dd { margin: 0; font-family: var(--mono); word-break: break-all; }
.notice { margin: 0 0 12px; padding: 9px 12px; border-radius: var(--radius); font-size: 12.5px; background: var(--accent-soft); border: 1px solid var(--accent-line); color: var(--text-2); }
.key-form { display: grid; gap: 10px; max-width: 760px; }
.field { display: grid; gap: 6px; color: var(--muted); font-size: 12.5px; }
.field input:not([type=checkbox]), .field textarea { width: 100%; font: 13px/1.45 var(--body); }
.field textarea { resize: vertical; word-break: break-all; }
.howto { margin-top: 14px; font-size: 13.5px; }
.howto summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.howto ol { margin: 10px 0 0; padding-left: 20px; display: grid; gap: 7px; }

/* ------------------------------------------------------ users/activity -- */
.dialog.wide { width: min(720px, calc(100vw - 24px)); }
.field-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.preset { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.preset button {
  background: var(--inset); border: 1px solid var(--border); color: var(--text-2); cursor: pointer;
  border-radius: 8px; padding: 3px 9px; font: 600 12px var(--body);
}
.preset button:hover { border-color: var(--accent); color: var(--accent-hi); }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.perm {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 8px 8px 12px;
  background: var(--inset); border: 1px solid var(--border); border-radius: 10px; color: var(--text); font-size: 13px; font-weight: 600;
}
.perm:has(select:not(.off)) { border-color: var(--accent-line); }
.perm select { padding: 5px 8px; }
.perm select.off { color: var(--muted); }
.files-fields { display: grid; gap: 14px; }
.table-wrap { overflow-x: auto; margin-top: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 7px 10px; white-space: nowrap; }
td { padding: 8px 10px; border-top: 1px solid var(--divider); }
tbody tr:hover td { background: var(--hover); }
td.muted { color: var(--muted); white-space: normal; }
.user-list { display: grid; gap: 8px; margin-top: 14px; }
.user-row {
  display: grid; grid-template-columns: auto minmax(120px, 200px) 1fr auto; align-items: center; gap: 14px;
  width: 100%; padding: 9px 12px; text-align: left; cursor: pointer; font: inherit; color: var(--text);
  background: var(--inset); border: 1px solid var(--border); border-radius: var(--radius);
  transition: border-color .15s, background .15s;
}
.user-row:hover, .user-row:focus-visible { border-color: var(--border-hi); background: var(--hover); outline: none; }
.avatar {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--selected); border: 1px solid var(--border-hi); color: var(--text-2); font: 600 12px var(--display, var(--body));
}
.user-name { font-weight: 500; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.access { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.ac {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--surface); border: 1px solid var(--border); color: var(--text-2);
}
.ac::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.ac.lvl-logs::before { background: #5e9bff; }
.ac.lvl-control::before { background: var(--accent); }
.ac.files::before { background: #cdb3e8; }
.ac.none { border-style: dashed; color: var(--muted); }
.ac.none::before { display: none; }
.user-edit { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.user-row:hover .user-edit { color: var(--accent-hi); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; color: var(--muted); font-size: 12px; }
.legend .ac { background: none; border: 0; padding: 0; color: var(--muted); font-weight: 500; }
.push-left { margin-right: auto; }
@media (max-width: 720px) {
  .user-row { grid-template-columns: auto 1fr auto; }
  .user-row .access { grid-column: 1 / -1; }
}
.row-actions { display: flex; gap: 6px; }
.activity-table td:first-child { white-space: nowrap; color: var(--muted); font-family: var(--mono); font-size: 12px; }
.activity-table td:nth-child(2) { white-space: nowrap; }
.tag { padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 500; background: var(--inset); border: 1px solid var(--border); color: var(--muted); }
.tag.auth { color: #8fb8ff; }
.tag.action { color: var(--accent-hi); }
.tag.users { color: #cdb3e8; }
#activity-filter { width: 200px; }

/* ------------------------------------------------------------- dialog -- */
.dialog {
  width: min(580px, calc(100vw - 24px)); background: var(--surface); color: var(--text);
  border: 1px solid var(--border-hi); border-radius: 12px; padding: 18px;
  box-shadow: 0 24px 60px var(--shadow);
}
.dialog::backdrop { background: rgba(5, 5, 7, .7); backdrop-filter: blur(2px); }
.dialog form { display: grid; gap: 14px; }
#sftp-fields { display: grid; gap: 14px; }
.field-label { color: var(--text-2); font-weight: 600; font-size: 13px; }
.folder-all { margin-top: 2px; display: grid; gap: 6px; }
.folder.covered-item { opacity: .45; pointer-events: none; }
.folder-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px;
  max-height: 230px; overflow: auto; padding: 2px 2px 4px;
}
.folder-grid.covered { opacity: .45; pointer-events: none; }
.folder {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px; cursor: pointer;
  background: var(--inset); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font-size: 13px; font-weight: 600;
}
.folder:hover { border-color: var(--accent-line); }
.folder:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-hi); }
.folder input { margin: 0; flex: none; }
.folder span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-everything { font-weight: 700; }
.folder-empty { color: var(--muted); font-size: 13px; padding: 6px 2px; }
.pass-form { display: grid; gap: 10px; max-width: 620px; margin-top: 6px; padding-top: 16px; border-top: 1px solid var(--divider); }
.form-title { font-size: 15px; }
.pass-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 640px) { .pass-fields { grid-template-columns: minmax(0, 1fr); } }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

.toast {
  position: fixed; right: 18px; bottom: 18px; z-index: 50; max-width: 420px;
  background: var(--surface); border: 1px solid var(--border-hi);
  padding: 10px 14px; border-radius: var(--radius-lg); white-space: pre-wrap; font-size: 13px;
  box-shadow: 0 12px 32px var(--shadow);
}
.toast.error { border-color: var(--bad-line); color: var(--bad); }

/* -------------------------------------------------------------- login -- */
.login-page { min-height: 100vh; display: grid; place-items: center; }
.login-box {
  width: min(360px, calc(100vw - 32px)); padding: 28px; text-align: center; display: grid; gap: 12px; justify-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.login-box .brand-mark { width: 40px; height: 40px; border-radius: 10px; font-size: 20px; }
.login-box h1 { font-size: 18px; }
.login-error { margin: 0; padding: 9px 12px; border-radius: 10px; font-size: 13px; background: var(--bad-bg); border: 1px solid var(--bad-line); color: var(--bad); }
.btn.discord { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); height: 36px; padding: 0 16px; font: 600 13px var(--display); border-radius: 7px; }
.btn.discord:hover { background: var(--accent-hi); border-color: var(--accent-hi); color: var(--accent-ink); }

/* ------------------------------------------------------------- mobile -- */
@media (max-width: 1100px) {
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0, 0, 0, .6); }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  #menu-toggle { display: inline-flex; }
  .page { padding: 14px; }
  .topbar { padding: 0 12px; }
  .topbar .sub { display: none; }
  .hero { padding: 20px; }
  .hero-name h2 { font-size: 24px; }
  .logs-toolbar input[type=search] { width: 140px; }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar, .bar i { transition: none; }
}

/* ------------------------------------------------------- console lines -- */
.log-line { display: flex; gap: 12px; padding: 0 4px; border-radius: 4px; }
.log-line:hover { background: rgba(255, 255, 255, .03); }
.log-ts { flex: none; color: var(--faint); user-select: none; font-variant-numeric: tabular-nums; }
.log-msg { min-width: 0; white-space: pre-wrap; word-break: break-word; }
.sev-warn { color: #e6c15a; }
.sev-error { color: #f0786a; }

/* ------------------------------------------------- server (VPS) card -- */
.server-card {
  display: grid; gap: 12px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.server-card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.server-card-title { font-family: var(--display); font-weight: 600; font-size: 13px; }
.meters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.meter { display: grid; gap: 6px; align-content: start; }
.meter-label { font-size: 12px; font-weight: 500; color: var(--muted); }
.meter-value { font: 500 13px var(--mono); font-variant-numeric: tabular-nums; color: var(--text-strong); }
.meter-sub { font-size: 12px; color: var(--muted); }
.meter .bar { height: 5px; }

/* ------------------------------------------------------- more menu -- */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 330px;
  display: grid; gap: 2px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 14px 34px var(--shadow);
}
.menu-list button {
  display: grid; gap: 2px; text-align: left; padding: 9px 11px; border: none; border-radius: 9px;
  background: transparent; color: var(--text); font: 13px/1.35 var(--body); cursor: pointer;
}
.menu-list button:hover, .menu-list button:focus-visible { background: var(--hover); }
.menu-list button b { font-weight: 700; }
.menu-list button span { color: var(--muted); font-size: 12px; }

/* ------------------------------------------------- SFTP app chooser -- */
.app-dialog { display: grid; gap: 16px; }
.app-dialog section { display: grid; gap: 12px; }
.app-dialog h2 { font-size: 18px; }
.app-options { display: grid; gap: 8px; }
.app-option {
  display: grid; gap: 3px; text-align: left; padding: 14px 16px; cursor: pointer;
  background: var(--inset); border: 1px solid var(--border); border-radius: 12px; color: var(--text); font: 14px/1.35 var(--body);
}
.app-option:hover, .app-option:focus-visible { border-color: var(--border-hi); background: var(--hover); }
.app-option b { font: 600 16px var(--display); }
.app-option span { color: var(--muted); font-size: 13px; }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 8px; font-size: 14px; }
.app-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.field input[readonly] { color: var(--muted); cursor: default; }

/* ------------------------------------------------------------- loader -- */
.loader {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px;
  background: var(--bg);
  animation: loader-in .25s ease .35s both;  /* short loads never flash it */
}
.loader.now { animation-delay: 0s; }
.loader.leaving { opacity: 0; transition: opacity .25s ease; pointer-events: none; }
.loader[hidden] { display: none; }
@keyframes loader-in { from { opacity: 0; } to { opacity: 1; } }
.loader-card { display: grid; justify-items: center; gap: 10px; text-align: center; max-width: 360px; }
.loader-mark { position: relative; width: 84px; height: 84px; display: grid; place-items: center; margin-bottom: 6px; }
.loader-mark img { border-radius: 12px; }
.loader-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--accent);
  animation: loader-spin 1s linear infinite;
}
@keyframes loader-spin { to { transform: rotate(360deg); } }
.loader-card h2 { margin: 0; font: 600 16px var(--display); }
.loader-card p { margin: 0; color: var(--muted); font-size: 13.5px; min-height: 2.6em; }
.loader-bar { width: 180px; height: 3px; border-radius: 3px; background: var(--border); overflow: hidden; }
.loader-bar span {
  display: block; width: 40%; height: 100%; border-radius: 3px; background: var(--accent);
  animation: loader-slide 1.3s ease-in-out infinite;
}
@keyframes loader-slide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
@media (prefers-reduced-motion: reduce) {
  .loader-ring, .loader-bar span { animation-duration: 3s; }
}

/* --------------------------------------------------------------- todo -- */
/* Page fills the screen: statuses share the width equally, the bin sits at the bottom. */
.todo-page {
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 14px;
  height: calc(100vh - var(--topbar-h)); min-height: 460px;
}
.todo-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.todo-head .hint { margin: 0; }
.board { display: flex; gap: 14px; overflow-x: auto; min-height: 0; padding-bottom: 2px; }
.todo-col {
  --c: #8e8a82;
  flex: 1 1 0; min-width: 210px; display: flex; flex-direction: column; min-height: 0;
  background: color-mix(in srgb, var(--c) 2.5%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--c) 10%, var(--border));
  border-top: 2px solid color-mix(in srgb, var(--c) 55%, var(--border));
  border-radius: var(--radius); transition: border-color .15s, background .15s;
}
.todo-col.over { background: color-mix(in srgb, var(--c) 7%, var(--surface)); border-color: color-mix(in srgb, var(--c) 45%, var(--border)); }
.todo-col-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 8px 14px; }
.todo-col-head h3 { margin: 0; font: 600 13px var(--display); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.todo-count {
  font-size: 12px; font-weight: 700; border-radius: 999px; padding: 0 8px;
  color: color-mix(in srgb, var(--c) 55%, var(--muted)); background: color-mix(in srgb, var(--c) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 20%, var(--border));
}
/* status tools only take room while hovering, so the name gets the full width */
.todo-tools { display: none; gap: 2px; flex: none; }
.todo-col:hover .todo-tools, .todo-tools:focus-within { display: flex; }
@media (hover: none) { .todo-tools { display: flex; } }
.todo-tool {
  background: none; border: 0; color: var(--muted); cursor: pointer; width: 26px; height: 26px; border-radius: 7px;
  display: grid; place-items: center; font: 600 13px var(--body);
}
.todo-tool:hover { background: var(--inset); color: var(--accent-hi); }
.todo-tool.danger:hover { color: var(--bad); }
.todo-tool:disabled { opacity: .3; pointer-events: none; }
.todo-list { display: flex; flex-direction: column; gap: 8px; padding: 4px 10px 10px; overflow-y: auto; min-height: 44px; flex: 1; }
.todo-card {
  background: var(--inset); border: 1px solid var(--border); border-radius: var(--radius); padding: 9px 11px; cursor: pointer;
  display: flex; align-items: baseline; gap: 10px; transition: border-color .15s;
}
.todo-card[draggable=true] { cursor: grab; }
.todo-card:hover, .todo-card:focus-visible { border-color: color-mix(in srgb, var(--c, var(--accent)) 55%, var(--border)); outline: none; }
.todo-card.dragging { opacity: .35; }
.todo-card-title { font-weight: 500; font-size: 13px; word-break: break-word; flex: 1; min-width: 0; }
/* categories: Modelling / Handling / Overige */
.cat-modelling { --cat: #9b6bd6; }
.cat-handling { --cat: #4a90d9; }
.cat-overige { --cat: #8e8a82; }
.cat-tag {
  flex: none; align-self: center; font-size: 10.5px; font-weight: 700; letter-spacing: .02em; padding: 1px 7px; border-radius: 999px;
  color: color-mix(in srgb, var(--cat) 70%, var(--text)); background: color-mix(in srgb, var(--cat) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--cat) 30%, transparent);
}
.cat-choice { display: flex; gap: 6px; }
.cat {
  flex: 1; padding: 6px 8px; border-radius: 9px; cursor: pointer; font: 600 12.5px var(--body);
  background: var(--inset); color: var(--muted); border: 1px solid var(--border);
}
.cat:hover { color: var(--text); border-color: color-mix(in srgb, var(--cat) 50%, var(--border)); }
.cat[aria-checked=true] {
  color: color-mix(in srgb, var(--cat) 60%, #fff); border-color: var(--cat); background: color-mix(in srgb, var(--cat) 16%, var(--inset));
}
.todo-note-flag {
  flex: none; align-self: center; width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center;
  background: var(--text); color: var(--bg); font: 800 11px/1 var(--body);
}
.todo-card-who { flex: none; max-width: 45%; color: var(--faint); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.todo-card-desc {
  color: var(--text-2); font-size: 12.5px; white-space: pre-line; word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.todo-card-meta { color: var(--faint); font-size: 11.5px; }
.todo-ph { border: 1.5px dashed var(--c, var(--accent)); border-radius: 11px; background: color-mix(in srgb, var(--c, var(--accent)) 10%, transparent); flex: none; }
.todo-empty { color: var(--faint); font-size: 12.5px; text-align: center; padding: 10px 6px; margin: 0; }
.todo-add {
  margin: 0 10px 10px; background: none; border: 1px dashed var(--border); color: var(--muted); border-radius: 10px;
  padding: 8px; cursor: pointer; font: 600 13px var(--body); text-align: left;
}
.todo-add:hover { border-color: var(--c); color: var(--text); }
.todo-composer { display: grid; gap: 8px; margin: 0 10px 10px; }
.todo-composer input, .todo-composer textarea {
  width: 100%; resize: vertical; background: var(--inset); color: var(--text);
  border: 1px solid var(--c); border-radius: 10px; padding: 8px 10px; font: 13px/1.45 var(--body);
}
.todo-composer textarea { min-height: 72px; }
.todo-composer div { display: flex; gap: 6px; }

/* Bottom row: bin (red), Doorgevoerd (purple), logs button */
.todo-bottom { display: flex; gap: 14px; align-items: stretch; min-width: 0; }
#todo-bin { flex: 2 1 0; min-width: 0; display: flex; }
#todo-done { flex: 1 1 0; min-width: 0; display: flex; }
#todo-bin > .todo-col, #todo-done > .todo-col { flex: 1; }
.todo-log-btn { flex: none; display: inline-flex; align-items: center; gap: 7px; }
.todo-log-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }
.todo-col.done {
  --c: #9b6bd6;
  flex-direction: row; align-items: center; gap: 10px; min-width: 0; padding: 6px 12px;
  border: 1.5px dashed rgba(155, 107, 214, .55); background: rgba(155, 107, 214, .08);
}
.todo-col.done.over { border-color: #9b6bd6; border-style: solid; background: rgba(155, 107, 214, .18); }
.todo-col.done .todo-col-head { padding: 0; flex: none; }
.todo-col.done .todo-col-head h3 { color: #c3a6ea; display: flex; align-items: center; gap: 7px; flex: none; }
.todo-col.done .todo-col-head svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.todo-col.done .todo-list { flex-direction: row; align-items: center; padding: 0; min-height: 34px; overflow: hidden; }
.todo-col.done .todo-empty { flex: 1; color: #b99be0; padding: 0; }
.todo-col.done .todo-ph { width: 90px; height: 30px !important; }

/* Bin: low red strip at the bottom */
.todo-col.bin {
  --c: #f44336;
  flex-direction: row; align-items: center; gap: 10px; min-width: 0; padding: 6px 12px;
  border: 1.5px dashed rgba(244, 67, 54, .55); background: rgba(244, 67, 54, .07);
}
.todo-col.bin.over { border-color: #f44336; border-style: solid; background: rgba(244, 67, 54, .16); }
.todo-col.bin .todo-col-head { padding: 0; flex: none; }
.todo-col.bin .todo-col-head h3 { color: #f0a093; display: flex; align-items: center; gap: 7px; flex: none; }
.todo-col.bin .todo-col-head svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.todo-col.bin .todo-list { flex-direction: row; align-items: center; gap: 6px; padding: 0; min-height: 34px; overflow-x: auto; overflow-y: hidden; }
.todo-col.bin .todo-card { flex: none; max-width: 220px; padding: 5px 10px; opacity: .8; }
.todo-col.bin .todo-card-title { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.todo-col.bin .todo-card-desc, .todo-col.bin .todo-card-meta { display: none; }
.todo-col.bin .todo-ph { width: 120px; height: 30px !important; }
.todo-col.bin .todo-empty { flex: 1; color: #e88f82; padding: 0; }
.todo-col.bin .todo-tools { display: flex; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer; background: var(--c);
  border: 2px solid transparent; box-shadow: inset 0 0 0 2px var(--surface);
}
.swatch[aria-checked=true] { border-color: var(--text); }
.swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.dialog.small { width: min(420px, calc(100vw - 24px)); }
#todo-card-dialog { width: min(640px, calc(100vw - 24px)); }
.note-count { color: var(--muted); font-weight: 500; }
.notes { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 240px; overflow-y: auto; }
.note { background: var(--inset); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; }
.note-head { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.note-head b { color: var(--text-2); }
.note p { margin: 4px 0 0; color: var(--text); font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.note-del { margin-left: auto; background: none; border: 0; color: var(--faint); cursor: pointer; border-radius: 6px; padding: 2px 6px; }
.note-del:hover { color: var(--bad); background: var(--surface); }
.note-empty { color: var(--faint); font-size: 12.5px; }
.note-add { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.note-add-actions { display: grid; gap: 6px; }
.note-add-actions label.btn { cursor: pointer; text-align: center; }
.note-add .note-files { grid-column: 1 / -1; }
.note-add .note-files:empty { display: none; }
.note-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.note-file {
  display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px; border-radius: 8px; font-size: 12.5px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2); text-decoration: none;
}
a.note-file:hover { border-color: var(--accent); color: var(--accent-hi); }
.note-file span { color: var(--faint); font-weight: 500; font-size: 11.5px; }
.note-file-x { background: none; border: 0; color: var(--faint); cursor: pointer; padding: 0 2px; }
.note-file-x:hover { color: var(--bad); }
.note-add textarea { resize: vertical; }
.field textarea:disabled, .field input:disabled, .field select:disabled { opacity: .75; }
.tag.todo { color: #a6d9b4; }
/* To-Do logs */
.dialog.wide#todo-log-dialog { width: min(860px, calc(100vw - 24px)); }
.log-dialog { display: grid; gap: 12px; }
.log-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.log-head h2 { margin: 0; }
.log-kinds { display: flex; flex-wrap: wrap; gap: 6px; }
.log-kind {
  --k: var(--muted); background: var(--inset); border: 1px solid var(--border); color: var(--muted);
  border-radius: 999px; padding: 3px 10px; font: 600 12px var(--body); cursor: pointer;
}
.log-kind[aria-pressed=true] { color: var(--text); border-color: var(--k); background: color-mix(in srgb, var(--k) 14%, var(--inset)); }
.log-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: min(60vh, 560px); overflow-y: auto; }
.log-item { background: var(--inset); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; }
.log-row { display: flex; align-items: baseline; gap: 10px; font-size: 13px; }
.log-time { flex: none; color: var(--faint); font: 12px var(--mono); min-width: 110px; }
.log-tag {
  --k: var(--muted); flex: none; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px;
  color: color-mix(in srgb, var(--k) 70%, var(--text)); background: color-mix(in srgb, var(--k) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--k) 30%, transparent);
}
.log-text { min-width: 0; word-break: break-word; color: var(--text-2); }
.log-text b { color: var(--text); }
.k-added { --k: #4caf6a; } .k-edited { --k: #f5a524; } .k-moved { --k: #4a90d9; } .k-note { --k: #3fb1a8; }
.k-bin { --k: #e0564a; } .k-removed { --k: #f44336; } .k-done { --k: #9b6bd6; } .k-status { --k: #8e8a82; }
.log-card { margin-top: 8px; padding-left: 120px; display: grid; gap: 6px; }
.log-card summary { cursor: pointer; color: #c3a6ea; font-size: 12.5px; font-weight: 600; }
.log-card-desc { margin: 4px 0 0; white-space: pre-wrap; font-size: 13px; }
.log-card-meta { margin: 0; color: var(--faint); font-size: 12px; }

@media (max-width: 720px) {
  .todo-bottom { flex-wrap: wrap; }
  #todo-bin, #todo-done { flex-basis: 100%; }
  .log-card { padding-left: 0; }
  .log-row { flex-wrap: wrap; }
}
@media (max-width: 720px) {
  .todo-page { height: auto; min-height: calc(100vh - var(--topbar-h)); }
  .board { min-height: 60vh; }
  .todo-col { flex: 0 0 82vw; }
}

/* ------------------------------------------------------- language switch -- */
.lang-switch { display: inline-flex; flex: none; padding: 2px; border-radius: 9px; background: var(--inset); border: 1px solid var(--border); }
.lang-switch button {
  background: none; border: 0; color: var(--muted); cursor: pointer; padding: 3px 9px; border-radius: 7px;
  font: 700 11.5px var(--body); letter-spacing: .04em;
}
.lang-switch button:hover { color: var(--text); }
.lang-switch button[aria-pressed=true] { background: var(--selected); color: var(--text-strong); box-shadow: inset 0 0 0 1px var(--border-hi); }
.login-lang { position: fixed; top: 16px; right: 16px; }
.side-lang {
  margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 12px; color: var(--muted); font-size: 12.5px; font-weight: 600;
}
.side-lang + .viewer { margin-top: -12px; }

/* .meta paste pop-up */
.code-input { font: 12px/1.5 var(--mono) !important; white-space: pre; overflow-wrap: normal; overflow-x: auto; resize: vertical; tab-size: 2; }
.link-like { color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.link-like:hover { color: var(--accent-hi); }
#todo-meta-size.too-big { color: var(--bad); font-weight: 700; }

.todo-tool.todo-dl { width: auto; padding: 0 8px; font-size: 11.5px; border: 1px solid var(--border); color: var(--text-2); }
.todo-tool.todo-dl:hover { border-color: var(--accent); }

/* in-panel confirmation */
.dialog.ask { width: min(440px, calc(100vw - 24px)); }
.dialog.ask p { margin: 0 0 18px; white-space: pre-line; font-size: 14px; line-height: 1.5; }

/* Minecraft page */
.mc-command { display: flex; align-items: center; gap: 8px; }
.mc-command input { flex: 1; min-width: 0; font: inherit; font-family: var(--mono, ui-monospace, monospace); font-size: 13px; }
.mc-prompt { color: var(--muted); font-family: var(--mono, ui-monospace, monospace); }
.mc-add { display: flex; gap: 8px; margin-top: 12px; }
.mc-add input { flex: 1; min-width: 0; font: inherit; }
.mc-names { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.mc-names li { display: flex; align-items: center; gap: 10px; min-height: 32px; font-size: 14px; }
.mc-names li.muted { font-size: 13px; }
.mc-names li.muted { color: var(--muted); }
.mc-initial { width: 24px; height: 24px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 5px; background: var(--border); font-size: 12px; font-weight: 700; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mc-names .mc-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* ------------------------------------------------- sidebar: top, prefs -- */
.side-top { display: flex; align-items: center; gap: 4px; }
.side-top .server-chip { flex: 1; min-width: 0; text-decoration: none; color: var(--text); }
.server-chip:hover { border-color: var(--border-hi); }
.server-chip-meta { font: 11px var(--mono); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fold-btn { flex: none; background: none; border: 0; cursor: pointer; }
.nav-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-dot { width: 6px; height: 6px; }
.nav-dot:not(.ok):not(.warn):not(.bad) { display: none; }
.nav a.parent-active { color: var(--text-strong); }
.nav-sub { display: grid; gap: 1px; margin: 1px 0 3px 16px; padding-left: 8px; border-left: 1px solid var(--border); }
.nav-sub a { height: 28px; font-size: 12.5px; }
.nav-sub svg { width: 15px; height: 15px; }
.side-prefs { margin-top: auto; display: grid; gap: 2px; }
.side-pref {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 4px 8px; color: var(--muted); font-size: 12px; font-weight: 500;
}
.side-pref .lang-switch button { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; }
.side-pref .lang-switch svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.side-prefs + .viewer { margin-top: 0; }

/* ------------------------------------------------------ topbar crumbs -- */
.crumbs { display: flex; align-items: center; gap: 8px; min-width: 0; }
.crumbs a { color: var(--muted); text-decoration: none; font-size: 14px; }
.crumbs a:hover { color: var(--text-strong); }
.crumb-sep { color: var(--faint); }
#page-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* --------------------------------------------------- folded menu (desktop) -- */
@media (min-width: 861px) {
  .sidebar, .main { transition: width .18s ease, margin-left .18s ease; }
  .menu-folded .sidebar { width: 56px; padding: 12px 8px; overflow-x: hidden; }
  .menu-folded .main { margin-left: 56px; }
  .menu-folded .side-top { flex-direction: column; gap: 6px; }
  .menu-folded .side-top .server-chip { flex: none; width: 40px; height: 34px; padding: 0; justify-content: center; }
  .menu-folded .server-chip-text,
  .menu-folded .nav-text,
  .menu-folded .nav-label,
  .menu-folded .side-prefs,
  .menu-folded .viewer-text { display: none; }
  .menu-folded .nav a { justify-content: center; padding: 0; position: relative; }
  .menu-folded .nav-sub { margin: 1px 0 3px; padding: 0; border-left: 0; }
  .menu-folded .nav-dot { position: absolute; top: 6px; right: 7px; }
  .menu-folded .viewer { flex-direction: column; padding: 8px 0 0; }
  .menu-folded .fold-btn svg { transform: scaleX(-1); }
}
@media (max-width: 860px) {
  .fold-btn { display: none; }
}

/* ---------------------------------------------------------- dashboard -- */
.tiles.tiles-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tile-value.tile-text { font: 500 13px/1.4 var(--body); color: var(--text-strong); }
.usage-table td { vertical-align: middle; }
.usage-table td .dot { display: inline-block; vertical-align: middle; margin-right: 2px; }
.usage-table td.mono { font-family: var(--mono); font-size: 12.5px; }
.usage-name { color: var(--text-strong); text-decoration: none; font-weight: 500; }
.usage-name:hover { color: var(--accent-hi); }

/* -------------------------------------------------- service console -- */
.console-card.console-tall { min-height: 420px; max-height: calc(100vh - 330px); }
.console-head .sub { margin-left: auto; margin-right: 12px; }

/* --------------------------------------------------------------- games -- */
.game-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.game-card {
  display: grid; gap: 12px; padding: 16px 18px; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  transition: border-color .12s, background .12s;
}
.game-card:hover { border-color: var(--border-hi); background: var(--hover); color: var(--text); }
.game-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.game-card-name { font-weight: 600; font-size: 15px; color: var(--text-strong); }
.game-card-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding-top: 12px; border-top: 1px solid var(--divider); }
.game-card-stats > div { display: grid; gap: 4px; }
.game-card-value { font: 500 14px var(--mono); color: var(--text-strong); }

@media (max-width: 1100px) { .tiles.tiles-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* --------------------------------------------- foldable menu groups -- */
.nav-group { position: relative; display: grid; }
.nav-group > a { padding-right: 30px; }
.nav-caret {
  position: absolute; right: 3px; top: 50%; transform: translateY(-50%);
  width: 24px; height: 24px; display: grid; place-items: center; padding: 0;
  background: none; border: 0; border-radius: 5px; color: var(--muted); cursor: pointer;
}
.nav-caret:hover { background: var(--selected); color: var(--text-strong); }
.nav-caret svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
.nav-caret[aria-expanded="true"] svg { transform: rotate(90deg); }
.nav-sub.closed { display: none; }
@media (min-width: 861px) {
  .menu-folded .nav-caret { display: none; }
  .menu-folded .nav-group > a { padding-right: 0; }
}
@media (prefers-reduced-motion: reduce) { .nav-caret svg { transition: none; } }

/* ------------------------------------------------------- page tabs -- */
.page-tabs { display: flex; gap: 2px; padding: 0 20px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.page-tabs a {
  padding: 10px 10px 9px; border-bottom: 2px solid transparent; margin-bottom: -1px;
  color: var(--muted); text-decoration: none; font-weight: 500; white-space: nowrap;
}
.page-tabs a:hover { color: var(--text-strong); }
.page-tabs a.active { color: var(--text-strong); border-bottom-color: var(--accent); }
@media (max-width: 860px) { .page-tabs { padding: 0 14px; } }

/* ----------------------------------------------------------- charts -- */
.charts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.chart { display: grid; gap: 6px; padding: 12px 14px 8px; background: var(--inset); border: 1px solid var(--border); border-radius: var(--radius); min-width: 0; }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.chart-title { font-size: 12px; font-weight: 500; color: var(--muted); }
.chart-value { font: 500 15px var(--mono); color: var(--text-strong); font-variant-numeric: tabular-nums; }
.chart-plot { position: relative; min-height: 120px; }
.chart-plot .empty { padding: 40px 0; text-align: center; font-size: 12px; }
.chart-svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.chart-area { fill: var(--accent); opacity: .12; }
.chart-grid { stroke: var(--divider); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-base { stroke: var(--border-hi); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-axis { fill: var(--muted); font: 10px var(--mono); }
.chart-cross { stroke: var(--faint); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.chart-dot { fill: var(--accent); stroke: var(--inset); stroke-width: 2; }
.chart-tip {
  position: absolute; top: -6px; transform: translate(-50%, -100%); pointer-events: none; white-space: nowrap;
  display: grid; justify-items: center; gap: 1px; padding: 4px 8px; border-radius: 6px; font-size: 11px;
  background: var(--surface); border: 1px solid var(--border-hi); box-shadow: 0 6px 18px var(--shadow); color: var(--muted);
}
.chart-tip b { font: 600 12px var(--mono); color: var(--text-strong); }
@media (max-width: 1100px) { .charts { grid-template-columns: minmax(0, 1fr); } }

/* ---------------------------------------------------------- updates -- */
.repo-list li { align-items: center; }
.repo-name { display: grid; gap: 2px; min-width: 160px; }
.repo-name .muted { font-size: 12px; }
.repo-commit { display: flex; align-items: baseline; gap: 10px; min-width: 0; justify-content: flex-end; text-align: right; }
.repo-commit .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.repo-pending { color: var(--warn); font-size: 12.5px; }
.console-card + .console-card, .panel + .console-card { margin-top: 0; }

/* ------------------------------------------------- users and avatars -- */
.avatar-icon { display: inline-grid; place-items: center; color: var(--accent); background: var(--accent-soft); border-color: var(--accent-line); }
.avatar-icon svg { width: 60%; height: 60%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
img.avatar { object-fit: cover; }
.viewer .avatar-icon { width: 26px; height: 26px; border-radius: 50%; flex: none; border: 1px solid var(--accent-line); }
.user-who { display: grid; min-width: 0; }
.user-kind { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg { display: inline-flex; padding: 2px; gap: 2px; border-radius: 8px; background: var(--inset); border: 1px solid var(--border); justify-self: start; }
.seg label { position: relative; display: inline-flex; align-items: center; padding: 5px 12px; border-radius: 6px; cursor: pointer; color: var(--muted); font-weight: 500; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--selected); color: var(--text-strong); box-shadow: inset 0 0 0 1px var(--border-hi); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }
.seg label:has(input:disabled) { cursor: default; }

/* ------------------------------------------------------------ login -- */
.login-or { display: flex; align-items: center; gap: 10px; width: 100%; color: var(--faint); font-size: 12px; }
.login-or::before, .login-or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.login-form { display: grid; gap: 10px; width: 100%; text-align: left; }
.login-form input { width: 100%; }
.login-form .btn { height: 34px; justify-self: stretch; }
/* To-Do under the FiveM tabs: the tab row takes 41px of the screen. */
.page-tabs:not([hidden]) ~ .todo-page { height: calc(100vh - var(--topbar-h) - 41px); }
.pass-fields > .hint { grid-column: 1 / -1; margin: 0; }

/* ------------------------------------------------- School (panel page) -- */
.school-import { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-top: 10px; }
.school-import .field { min-width: 220px; }
.school-import input[type=file] { height: auto; padding: 5px 8px; }
.school-import-result { margin-top: 12px; padding: 10px 12px; border-radius: var(--radius); font-size: 12.5px; display: grid; gap: 3px;
  background: var(--ok-bg); border: 1px solid var(--ok-line); color: var(--text-2); }
.school-import-result.has-errors { background: var(--warn-bg); border-color: var(--warn-line); }
.school-questions td.clip { max-width: 420px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.school-questions tr.clickable { cursor: pointer; }
.school-questions tr.clickable:focus-visible td { outline: 2px solid var(--accent); outline-offset: -2px; }
#school-q-search { width: 220px; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions .btn + .btn { margin-left: 4px; }

/* ------------------------------------------------- School (practice site) -- */
.school-mark { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-line); }
.school-mark svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.login-box .school-mark { width: 44px; height: 44px; border-radius: 12px; }
.login-box .school-mark svg { width: 24px; height: 24px; }
.school-body { min-height: 100vh; }
.school-top {
  position: sticky; top: 0; z-index: 10; height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 max(16px, calc((100% - 880px) / 2)); background: var(--topbar-bg); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.school-brand { display: flex; align-items: center; gap: 10px; color: var(--text-strong); text-decoration: none; font-weight: 600; font-size: 15px; }
.school-brand:hover { color: var(--text-strong); }
.school-top-right { display: flex; align-items: center; gap: 8px; }
.school-top-right .lang-switch svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.school-top-right .lang-switch button { display: inline-flex; align-items: center; justify-content: center; min-width: 28px; }
.school-user { color: var(--muted); font-size: 12.5px; margin-left: 4px; }
.school-main { max-width: 880px; margin: 0 auto; padding: 24px 16px 60px; display: grid; gap: 16px; }
.school-head h1 { font-size: 22px; letter-spacing: -0.02em; }
.school-head .sub { margin: 4px 0 0; }
.subject-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.subject-card { display: grid; gap: 10px; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.subject-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.subject-card h2 { font-size: 16px; color: var(--text-strong); }
.subject-stats { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.subject-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.school-back { color: var(--muted); text-decoration: none; font-size: 13px; }
.school-back:hover { color: var(--text-strong); }
.school-setup { display: grid; gap: 14px; }
.school-setup h1 { font-size: 20px; }
.setup-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.setup-fields select { width: 100%; }
.school-setup > .btn.big { justify-self: start; }
.quiz-card { display: grid; gap: 14px; padding: 20px; }
.quiz-card > .bar { margin: -4px 0 2px; }
.quiz-top { display: flex; align-items: center; gap: 10px; }
.quiz-top .btn { margin-left: auto; }
.quiz-question { margin: 0; font-size: 17px; line-height: 1.5; color: var(--text-strong); white-space: pre-line; }
.quiz-choices { display: grid; gap: 8px; }
.quiz-choice {
  display: flex; align-items: flex-start; gap: 12px; width: 100%; padding: 12px 14px; text-align: left; cursor: pointer;
  background: var(--inset); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font: 14px/1.45 var(--body);
  transition: border-color .12s, background .12s;
}
.quiz-choice:hover:not(:disabled) { border-color: var(--border-hi); background: var(--hover); }
.quiz-choice:disabled { cursor: default; }
.quiz-key { flex: none; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 6px; background: var(--selected); font: 600 12px var(--mono); color: var(--text-2); }
.quiz-choice.right { border-color: var(--ok); background: var(--ok-bg); }
.quiz-choice.right .quiz-key { background: var(--ok); color: #fff; }
.quiz-choice.wrong { border-color: var(--bad); background: var(--bad-bg); }
.quiz-choice.wrong .quiz-key { background: var(--bad); color: #fff; }
.quiz-own { width: 100%; resize: vertical; background: var(--inset); border: 1px solid var(--field-border); border-radius: var(--radius); color: var(--text); padding: 10px 12px; font: 14px/1.5 var(--body); }
.quiz-card > .btn { justify-self: start; }
.quiz-after { display: grid; gap: 10px; }
.quiz-after:empty { display: none; }
.quiz-after > .btn { justify-self: start; }
.quiz-verdict { margin: 0; font-weight: 600; }
.quiz-verdict.ok { color: var(--ok-text); }
.quiz-verdict.bad { color: var(--bad); }
.quiz-explain { margin: 0; padding: 10px 12px; border-radius: var(--radius); background: var(--accent-soft); border: 1px solid var(--accent-line); color: var(--text-2); white-space: pre-line; }
.quiz-model { display: grid; gap: 4px; padding: 10px 12px; border-radius: var(--radius); background: var(--inset); border: 1px solid var(--border); }
.quiz-model p { margin: 0; white-space: pre-line; color: var(--text-strong); }
.quiz-judge { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.school-result { display: grid; gap: 14px; }
.school-result h1 { font-size: 22px; }
@media (max-width: 640px) {
  .setup-fields { grid-template-columns: minmax(0, 1fr); }
  .school-user, .school-top-right .lang-switch:first-child { display: none; }
}
.ac.school::before { background: #3ecf8e; }
.school-pick { max-height: 180px; }
.school-pick .folder-empty { grid-column: 1 / -1; }
.school-import-names { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; margin-top: 12px; }
.school-import-name .sub { font-size: 11.5px; }
.school-import-result b { color: var(--text-strong); margin-top: 4px; }

/* School: subject page and ratings */
.school-subjects tr.clickable { cursor: pointer; }
.school-subjects tr.clickable:focus-visible td { outline: 2px solid var(--accent); outline-offset: -2px; }
.rated-down, .rate-down { color: var(--bad); }
.rate-up { color: var(--ok-text); }
.rating-cell { white-space: nowrap; font: 12px var(--mono); }
.rating-cell span + span { margin-left: 8px; }
.subject-title { display: grid; gap: 2px; }
.question-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.question-filters input[type=search] { flex: 1 1 220px; }
#school-subject-view { display: grid; gap: 12px; }
#school-subject-view[hidden], #school-list-view[hidden] { display: none; }
#school-list-view { display: grid; gap: 16px; }
.quiz-rate { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.rate-btn {
  width: 32px; height: 32px; display: grid; place-items: center; padding: 0; cursor: pointer;
  background: var(--inset); border: 1px solid var(--border); border-radius: 8px; color: var(--muted);
}
.rate-btn:hover { color: var(--text-strong); border-color: var(--border-hi); }
.rate-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.rate-btn.on { color: var(--ok-text); border-color: var(--ok-line); background: var(--ok-bg); }
.rate-btn.on.bad { color: var(--bad); border-color: var(--bad-line); background: var(--bad-bg); }
.rate-why { display: flex; flex-wrap: wrap; gap: 6px; flex-basis: 100%; }

/* School: prompt template, pictures */
.school-prompt { margin-top: 14px; }
.school-prompt[open] { display: grid; gap: 10px; }
.prompt-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.prompt-fields .prompt-extra { grid-column: 1 / -1; }
.prompt-fields input { width: 100%; }
#prompt-text { width: 100%; background: var(--inset); color: var(--text-2); border: 1px solid var(--field-border); border-radius: var(--radius); padding: 10px 12px; }
.image-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; margin-top: 10px; }
.image-item { display: flex; align-items: center; gap: 10px; padding: 6px 8px; background: var(--inset); border: 1px solid var(--border); border-radius: var(--radius); }
.image-item img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; background: var(--surface); flex: none; }
.image-text { display: grid; min-width: 0; flex: 1; }
.image-name { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-strong); }
.school-missing { background: var(--warn-bg); border-color: var(--warn-line); }
.img-tag { display: inline-block; padding: 0 5px; border-radius: 4px; font: 600 10px var(--mono); text-transform: uppercase; color: var(--accent-hi); background: var(--accent-soft); border: 1px solid var(--accent-line); vertical-align: 1px; }
.sq-preview { max-width: 100%; max-height: 220px; border-radius: var(--radius); border: 1px solid var(--border); justify-self: start; }
.quiz-image { display: block; justify-self: start; max-width: 100%; }
.quiz-image img { display: block; max-width: 100%; max-height: 420px; border-radius: var(--radius); border: 1px solid var(--border); background: #fff; }
@media (max-width: 640px) { .prompt-fields { grid-template-columns: minmax(0, 1fr); } }
#prompt-text { white-space: pre-wrap !important; overflow-wrap: anywhere; }

/* Tentamens: full width, count badge, three-step setup */
.school-top { padding: 0 clamp(16px, 3vw, 40px); }
.school-main { max-width: none; padding: 24px clamp(16px, 3vw, 40px) 60px; }
.quiz-card, .school-result { width: 100%; max-width: 1100px; justify-self: center; }
.subject-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.count-badge { flex: none; display: inline-flex; align-items: baseline; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: 12px; white-space: nowrap; border: 1px solid; }
.count-badge b { font: 600 13px var(--mono); }
.count-badge.lots { color: var(--ok-text); background: var(--ok-bg); border-color: var(--ok-line); }
.count-badge.some { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-line); }
.count-badge.few { color: var(--bad); background: var(--bad-bg); border-color: var(--bad-line); }
.school-setup { gap: 22px; padding: 22px 24px; }
.setup-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.setup-head h1 { font-size: 22px; letter-spacing: -0.02em; }
.setup-head .sub { margin: 4px 0 0; }
.setup-step { display: grid; gap: 12px; transition: opacity .15s; }
.setup-step.locked { opacity: .4; pointer-events: none; }
.setup-step-head { display: flex; align-items: center; gap: 10px; }
.setup-step-head h2 { font-size: 15px; flex: 1; }
.step-no { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent-hi); border: 1px solid var(--accent-line); font: 600 12px var(--mono); }
.toggle {
  cursor: pointer; text-align: left; color: var(--text); font: 13px/1.35 var(--body);
  background: var(--inset); border: 1px solid var(--border); border-radius: var(--radius);
  transition: border-color .12s, background .12s, color .12s;
}
.toggle:hover:not(:disabled) { border-color: var(--border-hi); background: var(--hover); }
.toggle[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.toggle:disabled { cursor: not-allowed; opacity: .45; }
.chapter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.toggle.chapter { display: grid; gap: 2px; padding: 10px 12px; }
.chapter-no:empty { display: none; }
.chapter-no { font: 600 11px var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.toggle[aria-pressed="true"] .chapter-no { color: var(--accent-hi); }
.chapter-name { font-weight: 500; color: var(--text-strong); }
.chapter-meta { font-size: 11.5px; color: var(--muted); }
.toggle-row { display: flex; flex-wrap: wrap; gap: 8px; }
.toggle.amount { min-width: 64px; height: 40px; padding: 0 16px; text-align: center; font: 600 15px var(--mono); }
.mode-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.toggle.mode { display: grid; gap: 3px; padding: 12px 14px; }
.mode-label { font-weight: 600; color: var(--text-strong); font-size: 14px; }
.mode-sub { font-size: 12px; color: var(--muted); }
.mode-avail { font: 11.5px var(--mono); color: var(--accent-hi); min-height: 1em; }
.setup-start { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding-top: 4px; border-top: 1px solid var(--divider); padding-top: 18px; }
@media (max-width: 760px) { .mode-grid { grid-template-columns: minmax(0, 1fr); } }
/* Question count: a plain rounded square, only the background tinted by the amount. */
.count-badge { display: inline-block; padding: 4px 8px; border: 0; border-radius: 6px; font: 500 12px var(--body); color: var(--text-2); }
.count-badge b { font: 600 12px var(--body); color: var(--text-strong); }
.count-badge.lots { color: var(--text-2); background: rgba(62, 207, 142, .16); }
.count-badge.some { color: var(--text-2); background: rgba(245, 165, 36, .18); }
.count-badge.few { color: var(--text-2); background: rgba(240, 82, 96, .16); }
.count-badge b { margin-right: 4px; }
.quiz-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.quiz-actions .quiz-rate { margin-left: auto; }
.quiz-actions .rate-why { justify-content: flex-end; }

/* Tentamens as an app: install button, iPhone hint, phone layout, notch-safe spacing */
#install-app svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
#install-app { gap: 6px; }
.install-hint {
  display: flex; align-items: center; gap: 10px; margin: 12px clamp(16px, 3vw, 40px) 0; padding: 10px 12px;
  border-radius: var(--radius); background: var(--accent-soft); border: 1px solid var(--accent-line); color: var(--text-2); font-size: 13px;
}
.install-hint span { flex: 1; }
.install-hint[hidden] { display: none; }
.standalone .school-top { padding-top: env(safe-area-inset-top); height: calc(52px + env(safe-area-inset-top)); }
.school-main { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }
@media (max-width: 640px) {
  .school-top { gap: 8px; }
  .school-top-right { gap: 6px; }
  .school-top-right .lang-switch:nth-of-type(2), .school-user { display: none; }
  #install-app span { display: none; }
  #install-app { width: 32px; padding: 0; }
  .school-main { padding-top: 16px; gap: 12px; }
  .school-head h1, .setup-head h1 { font-size: 19px; }
  .subject-grid { grid-template-columns: minmax(0, 1fr); }
  .school-setup { padding: 16px; gap: 18px; }
  .setup-head { flex-direction: column; gap: 8px; }
  .chapter-grid { grid-template-columns: minmax(0, 1fr); }
  .toggle.chapter { padding: 12px 14px; }
  .toggle-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .toggle.amount { min-width: 0; height: 46px; padding: 0; }
  .toggle.mode { padding: 14px; }
  .setup-start .btn.big { width: 100%; height: 46px; }
  .quiz-card { padding: 16px; gap: 12px; }
  .quiz-question { font-size: 16px; }
  .quiz-choice { padding: 14px; min-height: 52px; font-size: 15px; }
  .quiz-actions { flex-direction: column; align-items: stretch; }
  .quiz-actions > .btn { height: 46px; }
  .quiz-actions .quiz-rate { margin-left: 0; justify-content: space-between; }
  .rate-btn { width: 40px; height: 40px; }
  .quiz-judge .btn { flex: 1; height: 44px; }
  .quiz-card > .btn { width: 100%; height: 46px; }
  .subject-actions .btn { flex: 1; height: 42px; }
}
.quiz-top .chip { min-width: 0; max-width: 60%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quiz-top .sub { white-space: nowrap; }
@media (max-width: 640px) {
  .quiz-actions .quiz-rate { justify-content: flex-start; gap: 8px; }
  .quiz-actions .quiz-rate > .sub { flex: 1; }
}
.school-main > *, .quiz-card > *, .quiz-top { min-width: 0; }
.quiz-top .chip { flex: 0 1 auto; }

/* Tentamens on phones: setup and quiz fit (almost) on one screen */
@media (max-width: 640px) {
  .school-main { padding-top: 10px; gap: 8px; }
  .school-setup { padding: 14px; gap: 14px; }
  .setup-head { flex-direction: row; align-items: center; gap: 10px; }
  .setup-head h1 { font-size: 17px; line-height: 1.25; }
  .setup-head .sub { display: none; }
  .setup-step { gap: 8px; }
  .setup-step-head h2 { font-size: 14px; }
  /* phones: chapters as short H1, H2, ... tiles (titles only on larger screens) */
  .chapter-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
  .toggle.chapter { display: grid; place-items: center; padding: 0; height: 44px; min-height: 0; }
  .chapter-no, .chapter-no:empty { display: block; font-size: 0; letter-spacing: 0; }
  .chapter-no::before { content: "H" attr(data-n); font: 600 13.5px var(--body); }
  .chapter-name, .chapter-meta { display: none; }
  .toggle.amount { height: 40px; }
  .mode-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .toggle.mode { padding: 9px 6px; justify-items: center; align-content: center; text-align: center; gap: 2px; }
  .mode-label { font-size: 12.5px; line-height: 1.25; }
  .mode-sub { display: none; }
  .mode-avail { font-size: 10.5px; }
  .setup-start { padding-top: 12px; gap: 6px; }
  .setup-start .btn.big { height: 44px; }

  .quiz-card { padding: 14px; gap: 10px; }
  .quiz-question { font-size: 15.5px; }
  .quiz-choices { gap: 6px; }
  .quiz-choice { padding: 10px 12px; min-height: 0; font-size: 14.5px; }
  .quiz-after { gap: 8px; }
  .quiz-explain { font-size: 13.5px; padding: 8px 10px; }
  /* "Next question" + thumbs: one bar that stays at the bottom of the screen */
  .quiz-actions {
    position: sticky; bottom: calc(8px + env(safe-area-inset-bottom)); z-index: 2;
    flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px;
    margin: 0 -6px; padding: 6px; border-radius: var(--radius-lg);
    background: var(--surface); border: 1px solid var(--border-hi); box-shadow: 0 6px 24px var(--shadow);
  }
  .quiz-actions > .btn { flex: 1; height: 44px; }
  .quiz-actions .quiz-rate { display: contents; }
  .quiz-actions .quiz-rate > .sub { display: none; }
  .quiz-actions .rate-btn { width: 44px; height: 44px; }
  .quiz-actions .rate-why { flex-basis: 100%; justify-content: flex-start; }
}

/* Tentamens quiz on phones: the question card fills the screen, the page never scrolls */
@media (max-width: 640px) {
  html.quiz-mode, html.quiz-mode body { height: 100%; overflow: hidden; overscroll-behavior: none; }
  .quiz-mode .school-body { min-height: 0; height: 100dvh; display: flex; flex-direction: column; }
  .quiz-mode .install-hint { display: none; }
  .quiz-mode .school-main { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
  .quiz-mode .quiz-card { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain; }
  .quiz-mode .quiz-card > * { flex-shrink: 0; }
  .quiz-mode .quiz-after { flex: 1 0 auto; display: flex; flex-direction: column; }
  .quiz-mode .quiz-after:empty { display: none; }
  .quiz-mode .quiz-actions { margin-top: auto; bottom: 0; }
  .quiz-mode .quiz-image img { max-height: 26dvh; }
  .quiz-card.tight .quiz-choice:not(.right):not(.wrong) { display: none; }
}

/* Tentamens results: score, counts, per chapter, every question with a tick or cross */
.school-result { gap: 12px; }
.result-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; }
.result-score { display: flex; align-items: baseline; gap: 6px; }
.result-score b { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; color: var(--text-strong); }
.result-score span { color: var(--muted); font-size: 14px; }
.result-pct { font: 600 14px var(--mono); color: var(--text-2); }
.result-counts { display: flex; gap: 6px; margin-left: auto; align-self: center; }
.result-pill { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; border: 1px solid; }
.result-pill.ok { color: var(--ok-text); background: var(--ok-bg); border-color: var(--ok-line); }
.result-pill.bad { color: var(--bad); background: var(--bad-bg); border-color: var(--bad-line); }
.result-pill svg, .result-mark svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.result-title { font-size: 14px; margin: 6px 0 0; color: var(--text-strong); }
.result-chapters { margin: 0; }
.result-chapters li { align-items: center; }
.result-chapter { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-chapters .ok { color: var(--ok-text); }
.result-chapters .bad { color: var(--bad); }
.result-questions { display: grid; gap: 6px; }
.result-q { border: 1px solid var(--border); border-left: 3px solid; border-radius: var(--radius); background: var(--inset); }
.result-q.ok { border-left-color: var(--ok); }
.result-q.bad { border-left-color: var(--bad); }
.result-q summary { display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; cursor: pointer; list-style: none; }
.result-q summary::-webkit-details-marker { display: none; }
.result-mark { flex: 0 0 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; margin-top: -1px; }
.result-q.ok .result-mark { color: var(--ok-text); background: var(--ok-bg); border: 1px solid var(--ok-line); }
.result-q.bad .result-mark { color: var(--bad); background: var(--bad-bg); border: 1px solid var(--bad-line); }
.result-no { flex: 0 0 auto; font: 600 12.5px var(--mono); color: var(--muted); padding-top: 2px; }
.result-text { flex: 1; min-width: 0; font-size: 13.5px; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.result-q[open] .result-text { display: block; -webkit-line-clamp: none; }
.result-body { display: grid; gap: 8px; padding: 0 12px 12px 42px; }
.result-line { margin: 0; display: grid; gap: 2px; font-size: 13.5px; overflow-wrap: anywhere; }
.result-line.ok > span:last-child { color: var(--ok-text); }
.result-line.bad > span:last-child { color: var(--bad); }
.result-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 6px; }
@media (max-width: 640px) {
  .school-result { padding: 14px; }
  .result-counts { margin-left: 0; width: 100%; }
  .result-body { padding-left: 12px; }
  .result-actions { flex-direction: column; }
  .result-actions .btn { width: 100%; height: 44px; white-space: normal; }
}

/* Tentamens: highlight colours (dark first, then light theme) */
:root[data-accent="blue"] { --accent: #4f9dff; --accent-hi: #74b3ff; --accent-soft: #0f1a2b; --accent-line: #1f3a63; }
:root[data-accent="teal"] { --accent: #2dd4bf; --accent-hi: #5eead4; --accent-soft: #0d1f1d; --accent-line: #1b4a45; }
:root[data-accent="orange"] { --accent: #f59e3d; --accent-hi: #f8b566; --accent-soft: #22180c; --accent-line: #4d3518; }
:root[data-accent="pink"] { --accent: #f472b6; --accent-hi: #f79acb; --accent-soft: #241320; --accent-line: #4f2342; }
:root[data-theme="light"][data-accent="blue"] { --accent: #2563eb; --accent-hi: #1d4ed8; --accent-soft: #eaf2ff; --accent-line: #bfd6ff; }
:root[data-theme="light"][data-accent="teal"] { --accent: #0d9488; --accent-hi: #0f766e; --accent-soft: #e6f7f5; --accent-line: #a7e3dc; }
:root[data-theme="light"][data-accent="orange"] { --accent: #d9730d; --accent-hi: #b85f08; --accent-soft: #fff3e6; --accent-line: #fbd3a6; }
:root[data-theme="light"][data-accent="pink"] { --accent: #db2777; --accent-hi: #be185d; --accent-soft: #fdeef6; --accent-line: #f9c2dd; }

/* Tentamens: settings button and dialog */
#school-settings { border: 0; background: none; cursor: pointer; }
#school-settings svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
/* Phones and tablets: log out lives in the settings */
@media (hover: none), (pointer: coarse) { #school-logout { display: none; } }
.school-settings { display: grid; gap: 18px; padding: 18px; }
.school-settings:not([open]) { display: none; }
.settings-head { display: flex; align-items: center; justify-content: space-between; }
.settings-head h2 { font-size: 17px; }
.settings-head .icon-link { border: 0; background: none; cursor: pointer; }
.settings-head svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.settings-group { display: grid; gap: 10px; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch {
  width: 36px; height: 36px; border-radius: 50%; cursor: pointer; padding: 0;
  background: var(--swatch); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border-hi);
}
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--text-strong); }
.settings-switch { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--inset); cursor: pointer; }
.settings-switch-text { display: grid; gap: 2px; }
.settings-switch-label { color: var(--text-strong); font-weight: 600; font-size: 13.5px; }
.settings-switch .sub { font-size: 12px; }
.settings-switch input {
  appearance: none; -webkit-appearance: none; flex: 0 0 auto; width: 40px; height: 22px; margin: 0; border-radius: 999px;
  background: var(--border-hi); position: relative; cursor: pointer; transition: background .15s;
}
.settings-switch input::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; transition: transform .15s;
}
.settings-switch input:checked { background: var(--accent); }
.settings-switch input:checked::after { transform: translateX(18px); background: var(--accent-ink); }
.settings-switch input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.settings-foot { display: flex; justify-content: space-between; gap: 8px; }
.settings-foot .btn.primary { margin-left: auto; }
.settings-foot a.btn { text-decoration: none; display: inline-flex; align-items: center; }

/* Answer picked while right/wrong is hidden */
.quiz-choice.picked { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.quiz-choice.picked:disabled { opacity: 1; }

/* Confetti */
.confetti-layer { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti-layer i { position: absolute; width: 7px; height: 11px; border-radius: 2px; }
.settings-note { margin: 0; font-size: 12px; }

/* Tentamens: more highlight colours. Neutral ones turn dark in the light theme
   (white on a white page would vanish). */
:root[data-accent="green"] { --accent: #4ade80; --accent-hi: #86efac; --accent-soft: #0f1f15; --accent-line: #1f4a2e; }
:root[data-accent="yellow"] { --accent: #facc15; --accent-hi: #fde047; --accent-soft: #221d0a; --accent-line: #4d4214; }
:root[data-accent="red"] { --accent: #f46b6b; --accent-hi: #f79090; --accent-soft: #241213; --accent-line: #522426; }
:root[data-accent="grey"] { --accent: #9b9ba6; --accent-hi: #b4b4bd; --accent-soft: #1c1c21; --accent-line: #34343c; }
:root[data-accent="lightgrey"] { --accent: #c9c9d1; --accent-hi: #dcdce2; --accent-soft: #1e1e23; --accent-line: #3a3a42; }
:root[data-accent="white"] { --accent: #f2f2f5; --accent-hi: #ffffff; --accent-soft: #222227; --accent-line: #44444c; }
:root[data-theme="light"][data-accent="green"] { --accent: #16a34a; --accent-hi: #15803d; --accent-soft: #eafaf0; --accent-line: #b4e8c6; }
:root[data-theme="light"][data-accent="yellow"] { --accent: #ca8a04; --accent-hi: #a16207; --accent-soft: #fef9e3; --accent-line: #f5e08f; }
:root[data-theme="light"][data-accent="red"] { --accent: #dc2626; --accent-hi: #b91c1c; --accent-soft: #fdeeee; --accent-line: #f8c4c4; }
:root[data-theme="light"][data-accent="grey"] { --accent: #71717a; --accent-hi: #52525b; --accent-soft: #f0f0f2; --accent-line: #d4d4d8; }
:root[data-theme="light"][data-accent="lightgrey"] { --accent: #52525b; --accent-hi: #3f3f46; --accent-soft: #ececef; --accent-line: #c9c9cf; }
:root[data-theme="light"][data-accent="white"] { --accent: #18181b; --accent-hi: #000000; --accent-soft: #e9e9ec; --accent-line: #bdbdc3; }
