/* Colours of Shadow's screens. theme.js sets every variable below from what the backend declared; this file only says WHERE each one is used, and holds no colour of its own
   beyond black and white (the plain screen before the first declaration).
   --bg / --text    the screen behind everything and the text on it (black/white, following the dark/light toggle)
   --m, --n         the mode colour (blue in dark, gold in light) and the navigation colour (brown)
   --on-*           black or white, whichever reads better on that colour
   --hi-m, --hi-n   the colour a thing that carries --m or --n uses for its highlights (its buttons): the other colour
   Inside any tab or card, --s is the colour it carries, --on the text on it, --hi the highlight and --on-hi the text on the highlight; everything inside reads those four. */
:root {
  --bg: #000000; --text: #ffffff;
  --m: #000000; --on-m: #ffffff; --hi-m: #ffffff; --on-hi-m: #000000;
  --n: #000000; --on-n: #ffffff; --hi-n: #ffffff; --on-hi-n: #000000;
  --ok: #ffffff; --warn: #ffffff; --danger: #ffffff; --processing: #ffffff; --cancelled: #ffffff;
  --on-ok: #000000; --on-warn: #000000; --on-danger: #000000; --on-processing: #000000; --on-cancelled: #000000;
  --s: var(--bg); --on: var(--text); --hi: var(--text); --on-hi: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, system-ui, sans-serif; background: var(--bg); color: var(--text); padding: 16px; padding-bottom: 80px; }
h1 { font-size: 1.1rem; letter-spacing: 0.05em; color: var(--text); margin: 0 0 4px 0; }
.subtitle { font-size: 0.8rem; margin-bottom: 20px; }
.welcome { font-size: 1.05rem; }
a { color: var(--on); text-decoration: underline; text-decoration-color: var(--hi); text-decoration-thickness: 2px; text-underline-offset: 2px; }

/* what carries the mode colour: every card, every tab, the top navigation */
.panel, .tab, .nav a, .veil > div { --s: var(--m); --on: var(--on-m); --hi: var(--hi-m); --on-hi: var(--on-hi-m); background: var(--s); color: var(--on); border: 1px solid var(--s); }
/* what is being navigated to carries the navigation colour: the tab shown, the page you are on, the card that is open, a card waiting for a decision (and what sits inside them) */
.tab.active, .nav a.on, .card.card-open, .card.card-forced, .card.card-open .panel, .card.card-forced .panel { --s: var(--n); --on: var(--on-n); --hi: var(--hi-n); --on-hi: var(--on-hi-n); }

.panel { border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.panel h2 { font-size: 0.9rem; margin: 0 0 12px 0; color: inherit; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
label { display: block; font-size: 0.75rem; margin: 10px 0 4px; }
input, select, textarea { width: 100%; padding: 10px; background: var(--bg); color: var(--text); border: 1px solid var(--hi); border-radius: 6px; font-size: 0.9rem; font-family: inherit; }
input::placeholder, textarea::placeholder { color: var(--text); font-style: italic; opacity: 1; }
input[type=checkbox], input[type=radio] { accent-color: var(--hi); }
input[type=color] { padding: 2px; height: 42px; cursor: pointer; }
button { margin-top: 14px; width: 100%; padding: 12px; background: var(--hi); color: var(--on-hi); border: 1px solid var(--hi); border-radius: 6px; font-weight: 600; font-size: 0.9rem; }
button.secondary { background: transparent; border: 1px solid var(--hi); color: var(--on); margin-top: 0; width: auto; padding: 6px 12px; font-size: 0.75rem; }
button.block-secondary { background: transparent; border: 1px solid var(--hi); color: var(--on); }
button.card-toggle { background: var(--hi); color: var(--on-hi); }
button.danger { background: var(--danger); color: var(--on-danger); border-color: var(--danger); }
button:disabled { opacity: .5; }
.status-line { font-size: 0.8rem; margin-top: 10px; word-break: break-word; }
.status-line:empty { display: none; }
.status-line.ok, .status-line.err { display: block; width: fit-content; max-width: 100%; padding: 3px 9px; border-radius: 6px; }
.status-line.ok { background: var(--ok); color: var(--on-ok); }
.status-line.err { background: var(--danger); color: var(--on-danger); }
.hidden { display: none !important; }
.health-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--hi); font-size: 0.82rem; }
.health-row:last-child { border-bottom: none; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 8px; background: var(--on); border: 1px solid var(--on); }
.dot.ok { background: var(--ok); } .dot.err { background: var(--danger); } .dot.warn { background: var(--warn); }
.health-detail { font-size: 0.72rem; margin-top: 2px; word-break: break-word; }
.light { display: inline-flex; align-items: center; font-size: 0.72rem; }
/* navigation, tabs, tables, status labels */
.nav { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.nav a { flex: 1; min-width: 90px; text-align: center; padding: 9px 6px; border-radius: 8px; text-decoration: none; font-size: .8rem; }
.nav a.on { font-weight: 600; }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 14px; padding-bottom: 4px; }
.tab { flex: 0 0 auto; width: auto; margin: 0; padding: 7px 12px; border-radius: 999px; font-size: .78rem; font-weight: 500; }
.tab.active { font-weight: 600; }
.page { display: none; } .page.active { display: block; }
textarea { min-height: 120px; font-family: ui-monospace, Menlo, monospace; font-size: .75rem; }
.btns { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.btns button { margin-top: 0; width: auto; padding: 8px 12px; font-size: .78rem; }
.item { border-bottom: 1px solid var(--hi); padding: 10px 0; font-size: .82rem; }
.item:last-child { border-bottom: none; }
.item .title { font-weight: 600; word-break: break-word; }
.meta { font-size: .76rem; margin: 2px 0 8px; word-break: break-word; }
.item .meta { font-size: .72rem; margin: 2px 0 0; word-break: break-word; }
/* a status is a filled label (the fill is the status colour, the text black or white) so it reads on any card; the ring keeps its edge on a card of a similar colour */
.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .68rem; border: 1px solid var(--on); margin-right: 4px; color: var(--on); background: transparent; }
.chip.pending, .chip.warn { background: var(--warn); color: var(--on-warn); }
.chip.processing { background: var(--processing); color: var(--on-processing); }
.chip.success { background: var(--ok); color: var(--on-ok); }
.chip.failed, .chip.error { background: var(--danger); color: var(--on-danger); }
.chip.cancelled { background: var(--cancelled); color: var(--on-cancelled); }
/* "Nothing to change" is information, not a status: plain text in the colour of what it sits on (ui.js chip() draws it so) */
.plain-state { display: inline-block; font-size: .72rem; margin-right: 6px; color: inherit; }
.bar, .slotbar { height: 8px; border-radius: 4px; background: var(--bg); border: 1px solid var(--hi); overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--processing); }
.slotbar > i { display: block; height: 100%; background: var(--hi); }
pre { background: var(--bg); color: var(--text); border: 1px solid var(--hi); border-radius: 6px; padding: 10px; overflow-x: auto; font-size: .7rem; white-space: pre-wrap; word-break: break-word; max-height: 360px; }
.check { display: flex; gap: 8px; align-items: flex-start; } .check input { width: auto; margin-top: 3px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 8px; margin-top: 6px; }
.grid4 { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 8px; margin-top: 6px; }
.blurred { filter: blur(7px); pointer-events: none; user-select: none; }
.veil { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 40; padding: 24px; text-align: center; }
.veil > div { border-radius: 12px; padding: 20px; max-width: 360px; }
/* Contain long text: nothing (ids, urls, hashes, long names) may spill out of the card it belongs to. */
html, body { max-width: 100%; overflow-x: hidden; }
.panel { overflow: hidden; }
.panel, .panel * { overflow-wrap: anywhere; }
.row, .health-row { flex-wrap: wrap; }
.row > *, .health-row > *, .item, .item > *, .grid2 > *, .grid3 > *, .grid4 > *, .btns > * { min-width: 0; max-width: 100%; }
.chip { max-width: 100%; white-space: normal; }
input, select, textarea, button { max-width: 100%; }
@media (max-width: 420px) { .grid2, .grid3, .grid4 { grid-template-columns: 1fr; } }
.panel.notice { border: 2px solid var(--danger); }
.notice-title { display: inline-block; background: var(--danger); color: var(--on-danger); font-weight: 600; font-size: 0.9rem; margin-bottom: 6px; padding: 2px 10px; border-radius: 6px; }
/* pending cards (pending.js): a short card right under the button or page that proposed the action; the card is open and carries the navigation colour, the frame says pending */
/* a request waiting for a decision is being navigated to: navigation colour, with the yellow of "pending" as its edge */
.pend-box { --s: var(--n); --on: var(--on-n); --hi: var(--hi-n); --on-hi: var(--on-hi-n); background: var(--s); color: var(--on); border: 2px solid var(--warn); border-radius: 10px; padding: 10px 12px; margin: 12px 0; }
.pend-box .item.pend { border-bottom: 1px solid var(--hi); }
.pend-sec { margin-top: 8px; }
.health-row > div:last-child { text-align: right; }
/* the danger zone: its own red section */
.panel.danger-zone { border: 2px solid var(--danger); }
.panel.danger-zone h2 { display: inline-block; background: var(--danger); color: var(--on-danger); padding: 2px 10px; border-radius: 6px; }
/* the step flow (flow.js): choices that read as one list */
.opt { display: block; width: 100%; text-align: left; margin-top: 8px; padding: 10px 12px; background: transparent; color: var(--on); border: 1px solid var(--hi); border-radius: 8px; font-weight: 500; font-size: .85rem; }
.opt.on { background: var(--hi); color: var(--on-hi); border-width: 2px; }
.opt .health-detail { font-weight: 400; }
.crumbs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.item.archived { opacity: .6; }
/* cards (cards.js): a closed card is its title and one button; an open card is at most 60% of the screen and scrolls inside itself */
.card-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-bar h2 { margin: 0; min-width: 0; }
.card-toggle { margin: 0; flex: 0 0 auto; }
.card.card-open > .card-bar { margin-bottom: 10px; }
.card.card-closed > .card-body { display: none; }
.card.card-open > .card-body { max-height: 60vh; max-height: 60dvh; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.card.card-forced > .card-bar .card-toggle { display: none; }
details summary { cursor: pointer; text-decoration: underline; text-decoration-color: var(--hi); }
/* the dark/light button on every page */
.theme-toggle { position: fixed; top: 8px; right: 8px; z-index: 50; width: auto; margin: 0; padding: 4px 10px; font-size: .72rem; border-radius: 999px; background: var(--m); color: var(--on-m); border: 1px solid var(--hi-m); }
body { padding-top: 44px; }
/* the Theme card (theme_card.js): three colours to choose from and a preview of both screens drawn with the same rules as the real ones */
.swatches { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.swatches label { margin: 0 0 4px; }
.preview { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.preview > div { --s: var(--bg); --on: var(--text); --hi: var(--text); --on-hi: var(--bg); background: var(--bg); color: var(--text); border: 1px solid var(--text); border-radius: 8px; padding: 8px; }
.preview .tabs { margin-bottom: 6px; padding-bottom: 0; overflow: hidden; }
.preview .tab { pointer-events: none; }
.preview .sample { border-radius: 8px; padding: 8px; margin-bottom: 6px; font-size: .72rem; background: var(--s); color: var(--on); border: 1px solid var(--s); }
.preview .sample.m { --s: var(--m); --on: var(--on-m); --hi: var(--hi-m); --on-hi: var(--on-hi-m); }
.preview .sample.n { --s: var(--n); --on: var(--on-n); --hi: var(--hi-n); --on-hi: var(--on-hi-n); }
.preview .sample b { display: block; margin-bottom: 4px; font-size: .75rem; }
.preview .sample button { margin-top: 6px; padding: 5px 8px; font-size: .7rem; width: auto; pointer-events: none; }
@media (max-width: 420px) { .swatches { grid-template-columns: 1fr; } .preview { grid-template-columns: 1fr; } }

