/* magi web interface. No inline styles: the Content-Security-Policy allows only this file. */
:root {
  --bg: #f5f6f8; --fg: #1c2230; --muted: #5d6676; --card: #fff; --line: #d9dde4;
  --accent: #6d3fc0; --error: #b42318; --ok: #2e7d32; --warn: #b26a00; --crit: #c62828;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #13151a; --fg: #e6e8ec; --muted: #9aa3b2; --card: #1c2027; --line: #333944;
          --accent: #b392f0; --error: #ff8a80; --ok: #66bb6a; --warn: #ffb74d; --crit: #ef5350; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--fg); }
a { color: var(--accent); }
.top { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.5rem; padding: .7rem 1.25rem;
       background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-weight: 600; color: var(--fg); text-decoration: none; display: inline-flex; align-items: center; gap: .5rem; }
.brand img { display: block; border-radius: 6px; }
.brand span { display: flex; flex-direction: column; line-height: 1.15; }
.brand small { color: var(--muted); font-weight: 400; font-size: .75em; margin: 0; }
nav { display: flex; flex-wrap: wrap; gap: .25rem 1rem; flex: 1; }
nav a { text-decoration: none; padding: .15rem 0; border-bottom: 2px solid transparent; }
nav a.active { border-bottom-color: var(--accent); }
.signout { display: flex; align-items: center; gap: .75rem; margin-left: auto; }
.who { color: var(--muted); font-size: .9em; text-decoration: none; }
main { max-width: 76rem; margin: 1.5rem auto; padding: 0 1.25rem; }
footer { text-align: center; color: var(--muted); font-size: .8em; padding: 1rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 1.25rem 1.5rem; }
.card + .card, .card + .editor, .editor + .card { margin-top: 1.25rem; }
.narrow { max-width: 28rem; margin: 4rem auto; }
h1 { font-size: 1.35rem; margin: 0 0 .75rem; }
h1 small { font-size: .6em; font-weight: 400; }
h2 { font-size: 1.05rem; margin: 1rem 0 .6rem; }
h2:first-child { margin-top: 0; }
label { display: block; font-weight: 500; margin-bottom: .25rem; }
input[type=text], input[type=password], input[type=url], input[type=number], select, textarea {
  width: 100%; padding: .45rem .55rem; border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg); color: var(--fg); font: inherit; margin: .15rem 0 .6rem; }
textarea.code, pre.code, input.token { font: .88em ui-monospace, SFMono-Regular, Menlo, monospace; }
pre.code { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: .75rem; overflow-x: auto; }
small, .hint { color: var(--muted); font-size: .88em; }
small { display: block; margin: -.4rem 0 .6rem; }
.small { font-size: .85em; }
button, a.button { padding: .45rem .9rem; border: 1px solid var(--accent); border-radius: 6px; background: var(--accent);
  color: #fff; font: inherit; cursor: pointer; text-decoration: none; display: inline-block; }
button.secondary { background: transparent; color: var(--accent); }
button.danger { background: var(--error); border-color: var(--error); }
button.link { background: none; border: none; color: var(--accent); padding: 0; }
button.icon { padding: .1rem .45rem; background: transparent; color: var(--fg); border-color: var(--line); }
button.icon.danger { color: var(--error); }
button:disabled { opacity: .35; cursor: default; }
button.small { padding: .25rem .6rem; font-size: .9em; }
.default-action { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.error { color: var(--error); }
.notice { padding: .5rem .75rem; border-radius: 6px; background: color-mix(in srgb, var(--accent) 12%, transparent); }
.crumbs { margin: 0 0 .25rem; font-size: .9em; }
table { width: 100%; border-collapse: collapse; font-size: .93em; }
th, td { text-align: left; padding: .45rem .55rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; }
table.compact td { padding: .25rem .5rem; vertical-align: middle; }
tr.failed td { background: color-mix(in srgb, var(--error) 7%, transparent); }
tr.pending td { background: color-mix(in srgb, var(--warn) 9%, transparent); }
td.detail { max-width: 30rem; word-break: break-word; }
.nowrap { white-space: nowrap; }
.badge { display: inline-block; padding: .02rem .5rem; border-radius: 999px; font-size: .8em; background: color-mix(in srgb, var(--fg) 9%, transparent); }
.badge.shared { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.badge.off, .badge.warn { background: color-mix(in srgb, var(--warn) 22%, transparent); }
code.code { font-size: 1.05em; letter-spacing: .12em; font-weight: 600; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0 0 1rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: .75rem; }
.stat { display: flex; flex-direction: column; padding: .75rem 1rem; border: 1px solid var(--line); border-radius: 8px; color: var(--fg); text-decoration: none; }
a.stat:hover { border-color: var(--accent); }
.stat .figure { font-size: 1.6rem; font-weight: 600; }
.stat span:last-child { color: var(--muted); font-size: .9em; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: .75rem; }
.choice { display: flex; flex-direction: column; gap: .2rem; padding: .75rem 1rem; border: 1px solid var(--line); border-radius: 8px; color: var(--fg); text-decoration: none; }
.choice:hover { border-color: var(--accent); }
.choice span { color: var(--muted); font-size: .9em; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 0 1.25rem; }
.grid .wide { grid-column: 1 / -1; }
.checks { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; align-items: center; margin-bottom: .6rem; }
.checks small { flex-basis: 100%; margin: 0; }
label.check { display: inline-flex; align-items: center; gap: .4rem; font-weight: 400; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-top: .5rem; }
form.inline { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
form.inline label { flex: 1 1 12rem; }
form.inline input, form.inline select { margin-bottom: 0; }
.row-form { display: grid; grid-template-columns: 1.4fr 1fr .8fr .8fr 1.4fr 1fr auto; gap: .5rem; align-items: center; }
.row-form input, .row-form select { margin: 0; }
.row-form.head { color: var(--muted); font-weight: 500; font-size: .93em; padding: 0 .55rem .4rem; border-bottom: 1px solid var(--line); }
.device { padding: .55rem; border-bottom: 1px solid var(--line); }
.device.pending { background: color-mix(in srgb, var(--warn) 9%, transparent); }
table + small { margin-top: .4rem; }
details.danger-zone { margin-top: .75rem; }
details.danger-zone summary { color: var(--muted); font-size: .9em; cursor: pointer; }
details.danger-zone form { margin-top: .5rem; }
details.inline { display: inline-block; margin-top: .25rem; }
.secret-once { border: 1px solid var(--warn); border-radius: 8px; padding: .75rem 1rem; margin-bottom: 1rem;
  background: color-mix(in srgb, var(--warn) 8%, transparent); }
input.position { width: 4.5rem; margin: 0; }
/* Board editor */
.editor { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.editor > .card { margin-top: 0; }
.editor .preview { position: sticky; top: 1rem; }
@media (max-width: 70rem) { .editor { grid-template-columns: 1fr; } .editor .preview { position: static; } }
fieldset.section { border: 1px solid var(--line); border-radius: 8px; padding: .5rem 1rem 1rem; margin: 1rem 0; position: relative; }
fieldset.section legend { font-weight: 600; padding: 0 .4rem; }
.section-tools { position: absolute; top: -.2rem; right: .75rem; display: flex; gap: .3rem; }
.tile-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0 .6rem; padding: .6rem 0; border-top: 1px dashed var(--line); align-items: end; }
.tile-row .w1 { grid-column: span 1; } .tile-row .w2 { grid-column: span 2; } .tile-row .w3 { grid-column: span 3; }
.tile-row label { font-size: .85em; }
.tile-row label.check { margin-bottom: .7rem; }
.tile-tools { display: flex; gap: .3rem; justify-content: flex-end; grid-column: span 3; margin-bottom: .6rem; }
/* Preview: the board roughly as the Apple TV shows it, scaled to the frame. */
.tv-frame { container-type: inline-size; }
.tv { aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; padding: 3cqw 3.5cqw;
  color: #fff; background: radial-gradient(circle at 20% 10%, #41506b, #1b2130 60%, #0d1018); font-size: 1.6cqw; }
.tv-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 1.6cqw; }
.tv-title { font-size: 3.2cqw; font-weight: 700; }
.tv-updated { opacity: .7; }
.tv-section { text-transform: uppercase; letter-spacing: .08em; opacity: .7; font-size: 1.3cqw; margin: 1.4cqw 0 .8cqw; }
.tv-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.2cqw; }
.tv-tile { background: rgba(255,255,255,.1); border-radius: 1.2cqw; padding: 1.2cqw 1.4cqw; display: flex; flex-direction: column; gap: .3cqw;
  border-left: .45cqw solid transparent; }
.tv-label { opacity: .85; display: flex; align-items: center; gap: .6cqw; }
.tv-value { font-size: 2.6cqw; font-weight: 700; }
.tv-detail { opacity: .65; font-size: 1.2cqw; }
/* Trend (magi#59): good green, bad orange, neutral gray. */
.tv-trend { font-size: 1.2cqw; font-weight: 600; opacity: .8; } .tv-table .tv-trend { display: block; font-size: 1cqw; }
.trend-ok { color: #34c759; } .trend-warn { color: #ff9f0a; } .trend-none { color: #c7c7cc; }
.tv-list { background: rgba(255,255,255,.08); border-radius: 1.2cqw; padding: .6cqw 1.4cqw; }
.tv-row { padding: .6cqw 0; display: flex; align-items: center; gap: .8cqw; }
.tv-row + .tv-row { border-top: 1px solid rgba(255,255,255,.1); }
/* Up to three lines, like the app (magi#37). */
.tv-text { background: rgba(255,255,255,.08); border-radius: 1.2cqw; padding: 1cqw 1.4cqw; font-size: 2.2cqw; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
/* Pie (magi#55): rings side by side, the total in the middle, the legend beside. */
.tv-pies { display: flex; gap: 2cqw; }
.tv-pie { flex: 1; background: rgba(255,255,255,.08); border-radius: 1.2cqw; padding: 1cqw 1.4cqw; }
.tv-pie-title { font-weight: 600; margin-bottom: .6cqw; }
.tv-pie-body { display: flex; align-items: center; gap: 1.4cqw; }
.tv-pie-body svg { width: 12cqw; height: 12cqw; flex: none; }
.tv-pie-body path { stroke: none; }
.tv-pie-total { fill: #fff; font-size: 14px; font-weight: 700; text-anchor: middle; dominant-baseline: central; }
.tv-pie-legend { display: grid; gap: .4cqw; font-size: 1.3cqw; }
.tv-pie-legend b { font-variant-numeric: tabular-nums; }
/* Chosen colours of chart series and pie slices (magi#56), as the app shows them. */
.k-green { stroke: #34c759; fill: #34c759; } .k-orange { stroke: #ff9f0a; fill: #ff9f0a; } .k-blue { stroke: #0a84ff; fill: #0a84ff; }
.k-yellow { stroke: #ffd60a; fill: #ffd60a; } .k-brown { stroke: #ac8e68; fill: #ac8e68; } .k-purple { stroke: #bf5af2; fill: #bf5af2; }
.k-red { stroke: #ff453a; fill: #ff453a; } .k-gray { stroke: #8e8e93; fill: #8e8e93; }
.swatch.k-green { background: #34c759; } .swatch.k-orange { background: #ff9f0a; } .swatch.k-blue { background: #0a84ff; }
.swatch.k-yellow { background: #ffd60a; } .swatch.k-brown { background: #ac8e68; } .swatch.k-purple { background: #bf5af2; }
.swatch.k-red { background: #ff453a; } .swatch.k-gray { background: #8e8e93; }
.rest { fill: #8a8f98; } .swatch.rest { background: #8a8f98; }
/* Table (magi#53): values right-aligned under their column, the state as a dot after the value. */
.tv-table { width: 100%; border-collapse: collapse; background: rgba(255,255,255,.08); border-radius: 1.2cqw; overflow: hidden; }
.tv-table th, .tv-table td { padding: .6cqw 1.4cqw; text-align: right; white-space: nowrap; }
.tv-table thead th { font-weight: 400; opacity: .65; font-size: 1.3cqw; }
.tv-table tbody th { text-align: left; font-weight: 400; opacity: .85; width: 100%; }
.tv-table td { font-size: 2.2cqw; font-weight: 700; font-variant-numeric: tabular-nums; }
.tv-table td .dot { margin-left: .6cqw; vertical-align: middle; }
.tv-table tbody tr + tr { border-top: 1px solid rgba(255,255,255,.1); }
h3.sub { font-size: .95em; margin: .8rem 0 0; }
.dot { width: 1cqw; height: 1cqw; border-radius: 50%; display: inline-block; background: transparent; flex: none; }
.state-ok .dot { background: #4caf50; } .state-warn .dot { background: #ffb300; } .state-crit .dot { background: #f44336; }
.state-ok.tv-tile { border-left-color: #4caf50; } .state-warn.tv-tile { border-left-color: #ffb300; } .state-crit.tv-tile { border-left-color: #f44336; }
fieldset.settings { border: 1px solid var(--line); border-radius: 8px; padding: .5rem 1rem .25rem; margin: 0 0 1rem; }
fieldset.settings legend { font-weight: 600; padding: 0 .4rem; }
small.key { opacity: .7; }
.presence-row { grid-template-columns: 1.4fr .8fr 1.2fr 1fr .9fr auto; }
.type-row { display: grid; grid-template-columns: 4rem 1fr 1fr 1fr .8fr 4.5rem auto auto auto; gap: .5rem; align-items: end;
  padding: .6rem 0; border-bottom: 1px solid var(--line); }
.type-row label { font-size: .85em; margin: 0; }
.type-row input, .type-row select { margin-bottom: 0; }
.type-row label.check { margin-bottom: .5rem; }
/* Announcement preview: the glass band in the lower third, as the app shows it. */
.announce-preview { display: flex; align-items: flex-end; background: radial-gradient(circle at 30% 20%, #6b8f71, #2c3d4f 60%, #12161f); }
.announce { width: 100%; padding: 2.4cqw 3cqw; border-radius: 1.6cqw; background: rgba(255,255,255,.18);
  backdrop-filter: blur(12px); font-size: 3.4cqw; font-weight: 600; display: flex; gap: 1.6cqw; align-items: center; }
.announce.urgent { border-left: .8cqw solid #f44336; }
.announce-icon { font-size: 3.8cqw; }
.media-list { display: grid; gap: 1rem; }
.media-item { display: grid; grid-template-columns: 220px 1fr; gap: .4rem 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.media-item img, .media-item video { width: 220px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; background: var(--bg); grid-row: span 2; }
.media-item.inactive img, .media-item.inactive video { opacity: .45; }
.media-form { display: grid; grid-template-columns: 1.2fr 2fr .7fr 1.1fr 1.1fr auto; gap: .5rem; align-items: end; }
.media-form label { font-size: .85em; margin: 0; }
.media-form input { margin-bottom: 0; }
.media-tools { display: flex; gap: .4rem; align-items: center; }
.media-tools .hint { margin-right: auto; }

/* Charts in the board preview (magi#13): inline SVG, colours by class (CSP forbids inline styles). */
.tv-chart { background: rgba(255,255,255,.08); border-radius: 1.2cqw; padding: 1cqw 1.4cqw; }
.tv-chart svg { width: 100%; height: 14cqw; display: block; overflow: visible; }
.tv-chart .series { fill: none; stroke-width: 2.5; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.tv-chart .area { stroke: none; opacity: .9; }
.tv-chart .rule-warn, .tv-chart .rule-crit { stroke-width: 1; stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; }
.tv-chart .rule-warn { stroke: #ffb300; } .tv-chart .rule-crit { stroke: #f44336; }
.tv-legend { display: flex; flex-wrap: wrap; gap: .4cqw 1.6cqw; margin-top: .6cqw; align-items: center; }
.tv-legend .swatch { display: inline-block; width: 1.2cqw; height: .4cqw; border-radius: .2cqw; margin-right: .5cqw; vertical-align: middle; }
.s0 { stroke: #4fc3f7; fill: #4fc3f7; } .s1 { stroke: #ffd54f; fill: #ffd54f; } .s2 { stroke: #81c784; fill: #81c784; }
.s3 { stroke: #f06292; fill: #f06292; } .s4 { stroke: #ba68c8; fill: #ba68c8; } .s5 { stroke: #ff8a65; fill: #ff8a65; }
.tv-chart .series.s0, .tv-chart .series.s1, .tv-chart .series.s2, .tv-chart .series.s3, .tv-chart .series.s4, .tv-chart .series.s5 { fill: none; }
.swatch.s0 { background: #4fc3f7; } .swatch.s1 { background: #ffd54f; } .swatch.s2 { background: #81c784; }
.swatch.s3 { background: #f06292; } .swatch.s4 { background: #ba68c8; } .swatch.s5 { background: #ff8a65; }

/* List items with symbol and coloured labels (magi#30), colours as in the app. */
.tv-row .sym { display: inline-block; width: 1.6cqw; height: 1.6cqw; border-radius: .4cqw; flex: none; }
.tv-row .chips { display: inline-flex; gap: .4cqw; flex-wrap: wrap; }
.tv-row .chip { font-size: 1cqw; font-weight: 600; padding: .1cqw .6cqw; border-radius: 1cqw; }
.sym.c-green { background: #34c759; } .sym.c-orange { background: #ff9f0a; } .sym.c-blue { background: #0a84ff; }
.sym.c-yellow { background: #ffd60a; } .sym.c-brown { background: #ac8e68; } .sym.c-purple { background: #bf5af2; }
.sym.c-red { background: #ff453a; } .sym.c-gray { background: #8e8e93; }
.chip.c-green { color: #34c759; background: rgba(52,199,89,.18); } .chip.c-orange { color: #ff9f0a; background: rgba(255,159,10,.18); }
.chip.c-blue { color: #64b5ff; background: rgba(10,132,255,.2); } .chip.c-yellow { color: #ffd60a; background: rgba(255,214,10,.18); }
.chip.c-brown { color: #c8a77e; background: rgba(172,142,104,.22); } .chip.c-purple { color: #da8fff; background: rgba(191,90,242,.2); }
.chip.c-red { color: #ff6961; background: rgba(255,69,58,.2); } .chip.c-gray { color: #c7c7cc; background: rgba(142,142,147,.22); }
/* Devices page (#32): new devices, channels with their devices */
.card.attention { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 6%, var(--card)); }
.channel-card header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem; }
.channel-card h2 { margin: 0; }
.row-form.short { grid-template-columns: 1.6fr 1fr 1.4fr 1fr auto; }
.row-form > * { min-width: 0; }
.row-form code { overflow-wrap: anywhere; }
.row-form .name-cell { display: flex; align-items: center; gap: .4rem; }
.row-form .name-cell input { flex: 1; min-width: 0; width: auto; }
.dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; background: var(--line); vertical-align: middle; }
.dot.on { background: var(--ok); }
@media (max-width: 48rem) {
  .row-form, .row-form.short { grid-template-columns: 1fr 1fr; }
  .row-form.head { display: none; }
}

/* Avatars and the self-service of a person (magi#44). */
.avatar { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; flex: none; }
.avatar-row, .me-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.me-head h1 { margin: 0; }
