/* Palette: the validated reference instance, values unchanged. */
:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --plane: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;
  --series-1-soft: #cde2fb;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --ghost: rgba(11, 11, 11, 0.04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --plane: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-1-soft: #184f95;
    --ghost: rgba(255, 255, 255, 0.06);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #1a1a19;
  --plane: #0d0d0d;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5;
  --series-1-soft: #184f95;
  --ghost: rgba(255, 255, 255, 0.06);
}

/* Fonts ship with the app (OFL-licensed, Latin subset, one variable file
   each) so it looks the same offline and on every OS, and so the CSP can
   keep font-src to 'self'. DM Sans runs the interface; Lora is for reading:
   chat answers and quoted file text. */
@font-face {
  font-family: "DM Sans"; src: url("dm-sans.woff2") format("woff2");
  font-weight: 100 1000; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Lora"; src: url("lora.woff2") format("woff2");
  font-weight: 400 700; font-style: normal; font-display: swap;
}
:root {
  --font-ui: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-read: "Lora", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

/* A rule that sets `display` otherwise beats the `hidden` attribute, which
   silently leaves "hidden" elements on screen. Settle it once. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--plane);
  color: var(--text-primary);
  font: 14px/1.5 var(--font-ui);
}

/* ---------------------------------------------------------- shell */

.shell {
  display: grid; min-height: 100vh;
  grid-template-columns: 208px minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  grid-template-areas: "top top" "side main";
}
.wrap { grid-area: main; max-width: 1180px; width: 100%; margin: 0 auto; padding: 24px 24px 64px; }

.topbar {
  grid-area: top; position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  height: 56px; padding: 0 16px 0 20px;
  background: var(--surface-1); border-bottom: 1px solid var(--border);
}
.topbar .brand { flex: 0 1 auto; min-width: 0; display: flex; align-items: baseline; gap: 12px; }
.topbar .brand h1 { font-size: 17px; flex: 0 0 auto; }
.topbar .brand p { margin: 0; font-size: 12px; color: var(--text-muted); }
.topbar .spacer { flex: 1 1 auto; }
.topbar button.primary { padding: 6px 14px; }

.sidebar {
  grid-area: side; position: sticky; top: 56px; height: calc(100vh - 56px);
  padding: 16px 12px; background: var(--surface-1);
  border-right: 1px solid var(--border);
}

.sidenav { display: flex; flex-direction: column; gap: 2px; }
.sidenav .tab {
  display: flex; align-items: center; gap: 10px; width: 100%;
  border: none; background: none; text-align: left;
  padding: 8px 10px; color: var(--text-secondary);
}
.sidenav .tab svg { flex: 0 0 auto; }
.sidenav .tab:hover { background: var(--ghost); color: var(--text-primary); }
.sidenav .tab[aria-selected="true"] {
  background: var(--ghost); color: var(--text-primary); font-weight: 550;
  box-shadow: inset 3px 0 0 var(--series-1);
}

@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "side" "main"; }
  /* One row on a phone: the site line, Force and the status words go;
     the status dot stays, and all of it is still on the Sync tab. */
  .topbar { padding: 0 12px 0 16px; gap: 8px; }
  .topbar .brand p, .topbar .check, #net-text { display: none; }
  .topbar .pill { padding: 6px; }
  .sidebar {
    position: sticky; top: 0; z-index: 4; height: auto; padding: 6px 16px;
    border-right: none; border-bottom: 1px solid var(--border);
  }
  .sidenav { flex-direction: row; overflow-x: auto; }
  .sidenav .tab { width: auto; white-space: nowrap; }
  .sidenav .tab[aria-selected="true"] { box-shadow: inset 0 -2px 0 var(--series-1); }
  .wrap { padding: 16px 16px 48px; }
}

/* ---------------------------------------------------------- header */

header.top {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  margin-bottom: 20px;
}
.brand { min-width: 0; flex: 1 1 auto; }
.brand h1 { margin: 0; font-size: 19px; font-weight: 650; letter-spacing: -0.01em; }
.brand p {
  margin: 2px 0 0; color: var(--text-secondary); font-size: 13px;
  /* The data directory can be a long path - keep it on one line. */
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.spacer { flex: 0 0 auto; }

button {
  font: inherit; cursor: pointer; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-1);
  color: var(--text-primary); padding: 8px 14px;
}
button:hover:not(:disabled) { background: var(--ghost); }
button:disabled { opacity: 0.55; cursor: default; }
button.primary {
  background: var(--series-1); border-color: transparent; color: #fff; font-weight: 550;
}
button.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--series-1); }
.icon-btn { padding: 7px 9px; line-height: 0; display: inline-flex; align-items: center; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--text-secondary);
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.pill.ok .dot { background: var(--good); }
.pill.run .dot { background: var(--series-1); animation: pulse 1.2s ease-in-out infinite; }
.pill.err .dot { background: var(--critical); }
@keyframes pulse { 50% { opacity: 0.35; } }

/* ------------------------------------------------------- stat tiles */

.tiles {
  display: grid; gap: 12px; margin-bottom: 16px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}
.tile {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 16px;
}
.tile .label {
  font-size: 12px; color: var(--text-secondary); text-transform: uppercase;
  letter-spacing: 0.04em; margin-bottom: 6px;
}
.tile .value { font-size: 27px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.tile .sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ------------------------------------------------------------ cards */

.card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 10px; margin-bottom: 16px; overflow: hidden;
}
.card > h2 {
  margin: 0; padding: 12px 16px; font-size: 14px; font-weight: 600;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.card > h2 .count { color: var(--text-muted); font-weight: 400; }
.card .body { padding: 14px 16px; }

.banner {
  border-radius: 10px; padding: 12px 16px; margin-bottom: 16px;
  border: 1px solid var(--border); background: var(--surface-1);
  display: flex; gap: 10px; align-items: flex-start;
}
.banner .mark { font-weight: 700; }
.banner.warn { border-left: 3px solid var(--warning); }
.banner.err  { border-left: 3px solid var(--critical); }
.banner code {
  background: var(--ghost); padding: 1px 5px; border-radius: 4px; font-size: 12px;
}

/* --------------------------------------------------------- progress */

.progress-track {
  height: 6px; border-radius: 3px; background: var(--grid); overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: 3px; background: var(--series-1);
  width: 0%; transition: width 0.3s ease;
}
.progress-meta {
  display: flex; justify-content: space-between; gap: 12px;
  font-size: 12px; color: var(--text-secondary); margin-top: 8px;
}
.progress-meta .now {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 auto;
}
.log {
  margin-top: 12px; max-height: 190px; overflow-y: auto;
  font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
  border-top: 1px solid var(--border); padding-top: 10px;
}
.log div { display: flex; gap: 8px; }
.log .lv { flex: 0 0 auto; width: 12px; font-weight: 700; }
.log .ok .lv { color: var(--good); }
.log .warn .lv { color: var(--serious); }
.log .error .lv { color: var(--critical); }
.log .info .lv { color: var(--text-muted); }
.log .msg { color: var(--text-secondary); word-break: break-word; }

/* ----------------------------------------------------------- charts */

.chart-row { display: flex; align-items: center; gap: 10px; padding: 3px 0; }
.chart-row .name {
  flex: 0 0 34%; font-size: 13px; color: var(--text-secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chart-row .bar-track { flex: 1 1 auto; height: 14px; position: relative; }
.chart-row .bar {
  height: 14px; background: var(--series-1);
  border-radius: 0 4px 4px 0; min-width: 2px;
}
.chart-row .val {
  flex: 0 0 auto; font-size: 12px; color: var(--text-secondary);
  font-variant-numeric: tabular-nums; min-width: 72px; text-align: right;
}
.chart-row:hover .name, .chart-row:hover .val { color: var(--text-primary); }

/* ------------------------------------------------------------ split */

.split { display: grid; gap: 16px; grid-template-columns: 300px 1fr; align-items: start; }
.split.charts { grid-template-columns: 1fr 1fr; }
@media (max-width: 860px) {
  .split, .split.charts { grid-template-columns: 1fr; }
}

.course-list { list-style: none; margin: 0; padding: 6px; max-height: 620px; overflow-y: auto; }
.course-list li { margin: 0; }
.course-list button {
  width: 100%; text-align: left; border: none; background: none;
  border-radius: 7px; padding: 8px 10px; display: block;
}
.course-list button.active { background: var(--series-1); color: #fff; }
.course-list button.active .meta { color: rgba(255, 255, 255, 0.82); }
.course-list .nm {
  font-size: 13px; display: block; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.course-list .meta { font-size: 11px; color: var(--text-muted); }

/* ----------------------------------------------------------- search */

.searchbar { display: flex; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
input[type="search"] {
  flex: 1 1 auto; font: inherit; padding: 8px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--plane); color: var(--text-primary);
}
input[type="search"]:focus { outline: 2px solid var(--series-1); outline-offset: -1px; }

/* ------------------------------------------------------------ table */

table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; font-weight: 550; font-size: 12px; color: var(--text-secondary);
  padding: 8px 16px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface-1);
}
tbody td { padding: 8px 16px; border-bottom: 1px solid var(--grid); vertical-align: top; }
tbody tr:hover { background: var(--ghost); }
tbody tr:last-child td { border-bottom: none; }
td.num { font-variant-numeric: tabular-nums; color: var(--text-secondary); white-space: nowrap; }
td .path { font-size: 11px; color: var(--text-muted); }
td a { color: var(--series-1); text-decoration: none; font-weight: 500; }
td a:hover { text-decoration: underline; }
.tag {
  display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 4px;
  border: 1px solid var(--border); color: var(--text-secondary);
}
.tag.missing { border-color: var(--critical); color: var(--critical); }

.empty { padding: 36px 16px; text-align: center; color: var(--text-muted); }

/* Scrolls in both directions: on a narrow screen the right-hand columns
   would otherwise be clipped with no way to reach them. */
.table-scroll { max-height: 620px; overflow: auto; }
.table-scroll table { min-width: 560px; }
.foot { padding: 10px 16px; font-size: 12px; color: var(--text-muted); border-top: 1px solid var(--border); }

.check {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text-secondary); cursor: pointer;
}
.check input { accent-color: var(--series-1); cursor: pointer; }

/* ------------------------------------------------------ settings form */

.field { margin-bottom: 14px; }
.field > label {
  display: block; font-size: 13px; font-weight: 550;
  margin-bottom: 5px; color: var(--text-primary);
}
.field input[type="text"], .field input[type="url"], .field input[type="password"] {
  width: 100%; font: inherit; padding: 9px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--plane);
  color: var(--text-primary);
}
.field input:focus { outline: 2px solid var(--series-1); outline-offset: -1px; }
.field input:disabled { opacity: 0.6; cursor: not-allowed; }

.hint { display: block; font-size: 12px; color: var(--text-muted); margin-top: 5px; }
.hint code { background: var(--ghost); padding: 1px 5px; border-radius: 4px; }
p.hint { margin: 0 0 16px; max-width: 62ch; }

.row2 { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
@media (max-width: 620px) { .row2 { grid-template-columns: 1fr; } }

.advanced { margin: 4px 0 16px; }
.advanced summary {
  cursor: pointer; font-size: 13px; color: var(--text-secondary);
  padding: 6px 0; user-select: none;
}
.advanced summary:hover { color: var(--text-primary); }
.advanced[open] summary { margin-bottom: 10px; }

.actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
/* A class rather than a style attribute: the CSP forbids inline styles,
   which is what keeps a downloaded bundle from smuggling one in. */
.actions.spaced { margin-top: 12px; }
.actions .spacer { flex: 1 1 auto; }

.result {
  border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; font-size: 13px;
  border: 1px solid var(--border); background: var(--plane);
  display: flex; gap: 9px; align-items: flex-start;
}
.result .mark { font-weight: 700; flex: 0 0 auto; }
.result.ok { border-left: 3px solid var(--good); }
.result.ok .mark { color: var(--good); }
.result.bad { border-left: 3px solid var(--critical); }
.result.bad .mark { color: var(--critical); }
.result.busy { border-left: 3px solid var(--series-1); }

.locked-note {
  font-size: 12px; color: var(--serious); margin-top: 5px; display: block;
}

/* -------------------------------------------------------------- chat */

.chatpanel {
  display: flex; flex-direction: column; gap: 12px;
  height: calc(100vh - 56px - 48px); max-width: 780px; margin: 0 auto;
}
.chatpanel[hidden] { display: none; }
.chatlog { flex: 1 1 auto; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px 2px; }
.chat-empty { margin: auto 0; text-align: center; }
.chat-empty .hint { max-width: 46ch; margin: 0 auto; font: 15px/1.55 var(--font-read); }
.chat-empty h2 { margin: 0 0 6px; font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.chat-suggest { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 16px; }
.chat-suggest button {
  border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px;
  background: var(--surface-1); color: var(--text-secondary); font-size: 13px;
}
.bubble {
  max-width: 85%; padding: 10px 14px; border-radius: 12px;
  font: 15px/1.6 var(--font-read);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.bubble.user { align-self: flex-end; background: var(--series-1); color: #fff; }
.bubble.assistant {
  align-self: flex-start; background: var(--surface-1); border: 1px solid var(--border);
}
.bubble.pending { color: var(--text-muted); }
.bubble.note { color: var(--text-secondary); background: var(--ghost); border-style: dashed; }
.bubble.note.bad { color: var(--critical); }
.chatbox {
  display: flex; gap: 8px; align-items: flex-end;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 12px; padding: 8px;
}
.chatbox textarea {
  flex: 1 1 auto; resize: none; border: none; outline: none; background: none;
  color: var(--text-primary); font: 15px/1.5 var(--font-read); padding: 6px 8px; max-height: 160px;
}
@media (max-width: 760px) { .chatpanel { height: calc(100vh - 220px); min-height: 360px; } }

.card > h2 .spacer { flex: 1 1 auto; }

/* ------------------------------------------------------- view toggle */

.viewtoggle { display: inline-flex; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; }
.viewtoggle button {
  border: none; border-radius: 0; background: none; font-size: 12px;
  padding: 4px 10px; color: var(--text-secondary); font-weight: 400;
}
.viewtoggle button + button { border-left: 1px solid var(--border); }
.viewtoggle button.active { background: var(--series-1); color: #fff; font-weight: 550; }
.viewtoggle button:hover:not(.active) { background: var(--ghost); }

/* --------------------------------------------------------- file grid */

.grid-scroll { max-height: 620px; overflow-y: auto; padding: 14px 16px; }
.filegrid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}
.filecard {
  display: flex; flex-direction: column; gap: 6px;
  border: 1px solid var(--border); border-radius: 9px; padding: 12px;
  background: var(--plane); text-decoration: none; color: inherit;
  min-width: 0;
}
.filecard:hover { border-color: var(--series-1); background: var(--ghost); }
.filecard .ext {
  align-self: flex-start; font-size: 10px; font-weight: 700; letter-spacing: 0.06em;
  padding: 3px 7px; border-radius: 4px;
  background: var(--series-1-soft); color: var(--series-1);
}
.filecard .fname {
  font-size: 13px; font-weight: 500; color: var(--series-1);
  overflow-wrap: anywhere; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.filecard .fmeta {
  font-size: 11px; color: var(--text-muted); margin-top: auto;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ------------------------------------------------------------ toasts */

.toasts {
  position: fixed; right: 16px; bottom: 16px; z-index: 50;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
}
.toast {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface-1); color: var(--text-primary);
  border: 1px solid var(--border); border-left: 3px solid var(--series-1);
  border-radius: 9px; padding: 11px 14px; font-size: 13px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14);
  animation: toastin 0.18s ease-out;
  max-width: min(400px, calc(100vw - 32px));
}
.toast.bad { border-left-color: var(--critical); }
.toast .msg { flex: 1 1 auto; }
.toast button { padding: 4px 10px; font-size: 12px; }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }


/* ---------------------------------------------------------- deadlines */

button.linkish {
  border: none; background: none; padding: 2px 4px;
  color: var(--series-1); font-size: 13px; font-weight: 500;
}
button.linkish:hover { background: var(--ghost); }

.duelist { list-style: none; margin: 0; padding: 0; }
.duelist li {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 16px; border-bottom: 1px solid var(--grid);
}
.duelist li:last-child { border-bottom: none; }
.duelist li:hover { background: var(--ghost); }

.duelist .when {
  flex: 0 0 168px; font-size: 13px; font-variant-numeric: tabular-nums;
  color: var(--text-secondary); white-space: nowrap;
}
.duelist .when .rel { display: block; font-size: 11px; color: var(--text-muted); }
.duelist li.overdue .when .rel { color: var(--critical); font-weight: 600; }
.duelist li.soon .when .rel { color: var(--serious); font-weight: 600; }

.duelist .what { flex: 1 1 auto; min-width: 0; }
.duelist .what .nm {
  font-size: 13px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.duelist .what .crs { font-size: 11px; color: var(--text-muted); }

/* Status never rides on colour alone - each carries its own word. */
.state {
  flex: 0 0 auto; font-size: 11px; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--text-secondary);
  display: inline-flex; align-items: center; gap: 5px;
}
.state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.state.done   { color: var(--good); }
.state.todo   { color: var(--serious); }
.state.graded { color: var(--series-1); }

.duelist .go {
  flex: 0 0 auto; font-size: 12px; color: var(--series-1);
  text-decoration: none; padding: 5px 10px; border-radius: 7px;
  border: 1px solid var(--border); white-space: nowrap;
}
.duelist .go:hover { background: var(--ghost); }

@media (max-width: 620px) {
  .duelist li { flex-wrap: wrap; }
  .duelist .when { flex-basis: 100%; }
  .duelist .what { flex-basis: 100%; }
}


/* ------------------------------------------------- full-text results */

.hits-scroll { max-height: 620px; overflow-y: auto; }
.hits { list-style: none; margin: 0; padding: 0; }
.hits li { padding: 11px 16px; border-bottom: 1px solid var(--grid); }
.hits li:last-child { border-bottom: none; }
.hits li:hover { background: var(--ghost); }

.hits .head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.hits .head a { color: var(--series-1); text-decoration: none; font-weight: 500; font-size: 13px; }
.hits .head a:hover { text-decoration: underline; }
.hits .page {
  font-size: 11px; color: var(--text-secondary);
  border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px;
  font-variant-numeric: tabular-nums;
}
.hits .crs { font-size: 11px; color: var(--text-muted); }
.hits .snip {
  font: 13px/1.55 var(--font-read); color: var(--text-secondary); margin-top: 5px;
  overflow-wrap: anywhere;
}
.hits .snip mark {
  background: var(--series-1-soft); color: var(--text-primary);
  padding: 0 2px; border-radius: 3px;
}


/* ------------------------------------------------- selection + chat */

th.pick, td.pick { width: 34px; padding-right: 0; }
td.pick input, th.pick input { cursor: pointer; accent-color: var(--series-1); }

.filecard { position: relative; }
.filecard .pickbox {
  position: absolute; top: 8px; right: 8px;
  accent-color: var(--series-1); cursor: pointer;
}
.filecard.picked { border-color: var(--series-1); background: var(--ghost); }

.selbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 11px 16px; border-top: 1px solid var(--border);
  background: var(--plane);
}
.selbar .spacer { flex: 1 1 auto; }
.selcount { font-size: 13px; font-weight: 550; }
.chatopen { display: inline-flex; }
.chatopen button { border-radius: 8px 0 0 8px; }
.chatopen select {
  font: inherit; font-size: 13px; border: 1px solid var(--border);
  border-left: none; border-radius: 0 8px 8px 0; padding: 8px 8px;
  background: var(--surface-1); color: var(--text-primary); cursor: pointer;
}

.hint select {
  font: inherit; font-size: 12px; padding: 1px 4px; border-radius: 5px;
  border: 1px solid var(--border); background: var(--plane);
  color: var(--text-primary);
}

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 13px; }
.kv dt, .kv .k { color: var(--text-secondary); }
.kv .v { color: var(--text-primary); font-variant-numeric: tabular-nums; }

#lang-select {
  font: inherit; font-size: 13px; padding: 7px 8px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-1);
  color: var(--text-primary); cursor: pointer;
}

.diagbox {
  margin: 14px 0 0; padding: 12px 14px; max-height: 320px; overflow: auto;
  background: var(--plane); border: 1px solid var(--border); border-radius: 8px;
  font: 11px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--text-secondary); white-space: pre-wrap; overflow-wrap: anywhere;
}

.codebox {
  margin-top: 14px; padding: 14px 16px; border-radius: 9px;
  background: var(--plane); border: 1px solid var(--border);
  border-left: 3px solid var(--good);
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  font-size: 13px; color: var(--text-secondary);
}
.codebox strong {
  font: 700 26px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.14em; color: var(--text-primary);
  user-select: all;
}

/* The chat fills the viewport, so drop the page's usual bottom padding. */
.wrap:has(> .chatpanel:not([hidden])) { padding-bottom: 24px; }

/* ============================================================ Meteoro */

.grow { flex: 1 1 auto; }
.topbar .brand img { flex: 0 0 auto; border-radius: 6px; align-self: center; }
.topbar .brand { align-items: center; gap: 10px; }

.pill.off .dot { background: var(--warning); }
.pill.warn .dot { background: var(--warning); }

button.danger { color: var(--critical); }
button.danger:hover:not(:disabled) { background: var(--ghost); border-color: var(--critical); }

.tag.away { border-style: dashed; color: var(--text-muted); }
.filecard.away { opacity: 0.72; }
.course-list .group {
  padding: 12px 10px 4px; font-size: 11px; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--text-muted); font-weight: 600;
}

details.history { border-top: 1px solid var(--border); }
details.history > summary {
  cursor: pointer; padding: 10px 16px; font-size: 13px; color: var(--text-secondary);
  list-style-position: inside;
}
details.history > summary:hover { color: var(--text-primary); }
details.history .table-scroll { max-height: 340px; }
#connector-panels .log { max-height: 240px; margin-top: 10px; }
#connector-panels .progress-track { margin-top: 12px; }
#connector-panels .kv { margin-bottom: 4px; }
#offline-info { margin-top: 12px; }
#version-line { text-align: right; padding: 4px 2px; }

/* ------------------------------------------------- connected platforms */

.connlist, .kindlist { list-style: none; margin: 0; padding: 6px; }
.connlist li, .kindlist li { margin: 0; }
.connempty { padding: 14px 10px; color: var(--text-muted); font-size: 13px; }
.connitem {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left;
  border: 1px solid transparent; background: none; padding: 10px; border-radius: 9px;
}
.connitem:hover:not(:disabled) { background: var(--ghost); }
.connitem.active { border-color: var(--series-1); background: var(--ghost); }
.connitem .avatar {
  flex: 0 0 auto; width: 36px; height: 36px; border-radius: 9px;
  display: grid; place-items: center; font-weight: 650; font-size: 16px;
  background: var(--series-1-soft); color: var(--series-1);
}
.connitem .avatar.plus { background: var(--ghost); color: var(--text-secondary); }
.connitem .words { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.connitem .nm { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.connitem .sub {
  font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
.connitem .pill { flex: 0 0 auto; }
.add-btn { width: 30px; height: 30px; justify-content: center; padding: 0; border-radius: 8px; }
.addmenu { border-top: 1px solid var(--border); padding: 12px 10px 4px; }
.addmenu .hint { margin: 0 6px 6px; }

/* --------------------------------------------------------- sign in */

.authpage {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 24px 16px; gap: 16px;
}
.authcard {
  width: 100%; max-width: 420px; background: var(--surface-1);
  border: 1px solid var(--border); border-radius: 14px; padding: 24px;
}
.authbrand { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.authbrand img { border-radius: 10px; }
.authbrand h1 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -0.01em; }
.authbrand p { margin: 2px 0 0; color: var(--text-secondary); font: 14px/1.4 var(--font-read); }
.authtabs { display: flex; margin-bottom: 12px; }
.authtabs button { flex: 1 1 0; }
#auth-intro { margin: 0 0 14px; font-size: 13px; color: var(--text-secondary); }
#auth-form .field { margin-bottom: 12px; }
#auth-result { margin: 4px 0 12px; }
#auth-form .actions { display: flex; align-items: center; gap: 10px; }
#auth-form .actions .spacer { flex: 1 1 auto; }
.authfoot { max-width: 420px; text-align: center; color: var(--text-secondary); font: 15px/1.55 var(--font-read); }

/* ---------------------------------------------------------- viewer */

.viewer {
  position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column;
  background: var(--plane);
}
.viewer-bar {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: var(--surface-1); border-bottom: 1px solid var(--border);
}
.viewer-bar strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-bar .spacer { flex: 1 1 auto; }
.viewer-bar .icon-btn { font-size: 20px; line-height: 1; padding: 4px 11px; }
.viewer-body { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; }
.viewer-body iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.viewer-body img, .viewer-body video { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-body audio { width: min(560px, 90%); }

/* ------------------------------------------------------ Google sign-in */

.author {
  display: flex; align-items: center; gap: 10px; margin: 16px 0 12px;
  color: var(--text-muted); font-size: 12px;
}
.author::before, .author::after { content: ""; flex: 1 1 auto; height: 1px; background: var(--border); }
.google-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 10px 14px; font-weight: 550;
}
.signins { margin: 4px 0 16px; }
.signin-row {
  display: flex; align-items: center; gap: 14px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 9px; font-size: 13px;
}
.signin-row .k { font-weight: 600; }
.signin-row .v { flex: 1 1 auto; color: var(--text-secondary); overflow-wrap: anywhere; }
#gadmin-info { margin-bottom: 14px; overflow-wrap: anywhere; }

/* ------------------------------------------------------------ passkeys */

.authbtns { display: flex; flex-direction: column; gap: 10px; margin: 4px 0 4px; }
.passkey-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 11px 14px; font-size: 15px;
}
#auth-form .actions { margin-top: 4px; }
#auth-submit { width: 100%; }
.authlang { display: flex; justify-content: flex-end; margin-top: 14px; }
.passkeys { margin-bottom: 14px; display: flex; flex-direction: column; gap: 8px; }
.passkeys-head { display: flex; align-items: center; gap: 10px; }
.passkeys .hint { margin: 0; }
.peoplelist { list-style: none; margin: 0; padding: 10px 16px; display: flex; flex-direction: column; gap: 8px; }
.signin-row .k { margin-right: 6px; }
#recovery-box .codebox strong, #invite-box strong {
  font: 600 14px/1.5 var(--font-ui); letter-spacing: 0; overflow-wrap: anywhere;
}
