/* vmsd operator UI. Tokens, then components; nothing page-specific that a
   component cannot express. Type scale: 13 body, 12 meta, 15 card titles,
   20 page titles, 11 uppercase labels. */

:root {
  --bg: #f4f4f1; --panel: #ffffff; --ink: #17181c; --muted: #6a6d75;
  --rule: #e4e4df; --tint: #f0f0ec; --accent: #2a5bd7;
  --raised: #ffffff; /* a chip raised from a tray: lighter than what it sits on */
  --ok: #1d7a4b; --ok-bg: #e5f3eb; --warn: #8f5d00; --warn-bg: #fbf0d6; --bad: #b0262c; --bad-bg: #fbe7e7;
  --neutral: #4a4d55; --neutral-bg: #ebebe7;
  --amber: #f2b705; --bezel: #0d0d0f; --bezel-edge: #26272b;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  --radius: 10px;
  color-scheme: light dark; /* native controls (date picker, file input) follow the scheme */
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111215; --panel: #1a1b1f; --ink: #ececea; --muted: #a0a2a8;
    --rule: #2a2b31; --tint: #222328; --accent: #7aa2ff;
    --raised: #2c2d33;
    --ok: #5fcf97; --ok-bg: #173226; --warn: #f0c35a; --warn-bg: #3a2e12; --bad: #f2878b; --bad-bg: #3d1b1d;
    --neutral: #c4c6cc; --neutral-bg: #26272c;
    --bezel: #050506; --bezel-edge: #2e2f35; --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 13px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif; }
[x-cloak] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
code { font: 12px/1.4 ui-monospace, "SF Mono", Menlo, Consolas, monospace; background: var(--tint); padding: 1px 6px; border-radius: 4px; overflow-wrap: anywhere; }
.meta { color: var(--muted); font-size: 12px; }
.label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; margin: 0 0 8px; }

/* top bar */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 20px; padding: 10px 20px;
       background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--rule); }
.brand { font-weight: 700; font-size: 15px; text-decoration: none; }
.brand span { color: var(--amber); }
.ver { margin-left: auto; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ver + .conn { margin-left: 0; }
/* the nav's negative margin takes back the trays' 3px padding, so the bar
   keeps the height it had before the trays */
.nav { display: flex; gap: 10px; overflow-x: auto; margin-block: -3px; }
/* each of the nav's groups (signs' content, cameras, records and access)
   sits in a faint tray of its own: the ink at 5% over the bar, so it is as
   faint in the dark theme as in the light; a radius of the items' 6px plus
   the padding, so the items nest in it. flex: none keeps a tray whole when
   the nav scrolls on a narrow window. */
.navgroup { flex: none; display: flex; gap: 2px; padding: 3px; border-radius: 9px;
            background: color-mix(in srgb, var(--ink) 5%, transparent); }
.nav a { text-decoration: none; padding: 4px 10px; border-radius: 6px; color: var(--muted); white-space: nowrap; }
.nav a:hover { color: var(--ink); }
/* the current section is a raised chip in its tray */
.nav a.on { color: var(--ink); background: var(--raised); font-weight: 600;
            box-shadow: 0 0 0 1px var(--rule), 0 1px 2px rgba(0,0,0,.06); }
/* the focus ring hugs the link, inside the tray's padding, so the nav's
   scroll box never clips it */
.nav a:focus-visible { outline-offset: 0; }
@media (max-width: 640px) { .nav { gap: 6px; } }
.conn { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--bad); font-size: 12px; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }
.conn.lost .dot { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-bg); }
/* the user menu: a long name or e-mail address ends in an ellipsis rather
   than pushing the menu past a narrow screen's edge */
.usermenu { min-width: 0; max-width: 16em; }
.usermenu > summary { color: var(--muted); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.usermenu .popmenu { left: auto; right: 0; max-width: calc(100vw - 32px); }
.usermenu .popmenu > .meta { margin: 4px 10px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 640px) { .top { gap: 12px; padding: 10px 16px; } .usermenu { max-width: 7em; } }

.page { max-width: 1280px; margin: 0 auto; padding: 20px; }
@media (max-width: 640px) { .page { padding: 16px; } }
.pagehead { display: flex; align-items: baseline; gap: 12px; margin-bottom: 16px; }
.pagehead h1 { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.emptystate { padding: 60px 20px; text-align: center; color: var(--muted); }
.emptystate h2 { margin: 0 0 8px; font-size: 15px; color: var(--ink); }

/* badges and chips: one tone class each */
.badge, .chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; border-radius: 999px; white-space: nowrap; }
.badge { padding: 2px 9px; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip { padding: 1px 8px; font-weight: 500; }
.t-ok { color: var(--ok); background: var(--ok-bg); }
.t-warn { color: var(--warn); background: var(--warn-bg); }
.t-bad { color: var(--bad); background: var(--bad-bg); }
.t-neutral { color: var(--neutral); background: var(--neutral-bg); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; margin-bottom: 24px; }
@media (max-width: 400px) { .cards { grid-template-columns: minmax(0, 1fr); } }
.card { display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius);
        overflow: hidden; box-shadow: var(--shadow); text-decoration: none; min-width: 0; }
a.card:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--rule)); }
.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.card-head { display: flex; align-items: center; gap: 10px; }
.card-title { font-weight: 600; font-size: 15px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .chips { margin-top: 4px; }

/* sign face: previews are always on black, pixels kept sharp */
.bezel { background: var(--bezel); border-radius: var(--radius); padding: 14px; box-shadow: inset 0 0 0 1px var(--bezel-edge); }
.screen { aspect-ratio: var(--ar, 368/104); display: grid; place-items: center; background: #000; border-radius: 2px; overflow: hidden; }
/* Nearest-neighbour only where a picture is drawn at or above its native
   size; a picture drawn smaller is smoothed so its text stays legible. */
.screen img, img.thumb { image-rendering: pixelated; background: #000; }
.choice img.thumb { image-rendering: auto; }
.screen img { width: 100%; height: 100%; object-fit: contain; display: block; }
.screen .empty { color: #6a6d75; font-size: 12px; text-align: center; padding: 8px; }
.sign-card .bezel { border-radius: 0; padding: 12px; display: grid; place-items: center; }
/* Fixed preview height so wide and square signs line up in one row. */
.sign-card .screen { height: 110px; max-width: 100%; }
/* camera cards: the small copy edge to edge in a 16:9 box (another shape
   letterboxed, so the cards of a row line up), smoothed (a photo, scaled
   down); dimmed while the camera is disabled or not answering */
.camera-card .bezel { border-radius: 0; padding: 0; box-shadow: none; }
.camera-card .screen { border-radius: 0; aspect-ratio: 16 / 9; position: relative; }
/* the link fills the box exactly (a percentage height does not resolve in a
   box sized by aspect-ratio), so the picture inside is contained, not cropped */
.camera-card .screen > a { position: absolute; inset: 0; }
.camera-card .screen img { image-rendering: auto; }
/* Refresh, beside the badge, no taller than it */
.camera-card .card-head .btn { padding-top: 0; padding-bottom: 0; }
.screen img.dimmed { opacity: .4; filter: grayscale(1); }
/* the countdown to a camera's next fetch, after the frame's size and time:
   written by app.js (empty without it, and then no separator either), its
   digits of one width so it does not jitter as it ticks */
.countdown { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.countdown:not(:empty)::before { content: " · "; }
/* traffic light cards: the facts in two columns under the name, the alarms'
   marks in their tones; the facts faded, as a camera's picture is, while
   they are as last known (disabled, failing, not heard); Open at the foot,
   so the buttons of a row line up */
.light-card .card-body { flex: 1; }
.lightfacts { margin-top: 6px; gap: 2px 12px; }
.lightfacts.dimmed { opacity: .5; }
.lightfacts .alarms { display: flex; flex-wrap: wrap; gap: 2px 12px; }
.alarm { white-space: nowrap; }
.alarm .mark { font-weight: 600; }
.mark.a-ok { color: var(--ok); }
.mark.a-bad { color: var(--bad); }
.mark.a-neutral { color: var(--muted); }
.light-card .cardactions { margin-top: auto; padding-top: 6px; }
/* the traffic lights page's head: ↻ and Manage side by side; above the
   grid, the notice and the line of the last read with the countdown */
.headactions { display: flex; align-items: center; gap: 8px; }
.lightsline { margin: 0 0 10px; }
/* a camera test's picture, under its answer */
.probe > .probeshot { display: block; margin-top: 6px; max-width: 100%; height: auto; border-radius: 2px; background: #000; }

/* panels, columns, sections */
.panel { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); min-width: 0; }
.columns { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .columns { grid-template-columns: minmax(0, 1fr); } }
.maincol { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.section { margin-top: 16px; }
.sectionhead { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.pagehead .headlive { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.pagehead + .subhead { margin: -12px 0 16px; }
.pagehead .headlink { font-size: 12px; color: var(--muted); padding-top: 2px; padding-bottom: 2px; }
.field.invalid input { border-color: var(--bad); }
.narrow { max-width: 400px; margin-left: auto; margin-right: auto; }
.formtitle { margin: 0 0 14px; font-size: 20px; letter-spacing: -.01em; }
.caption { margin: 10px 0 0; }
.strip { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 10px; padding: 6px 10px; border-radius: 8px; font-weight: 600; }
.strip-text { flex: 1 1 0; min-width: 0; }
/* the upload's progress: a thin bar in the strip's tone under its text */
.strip-bar { flex: 1 0 100%; height: 3px; border-radius: 2px; background: color-mix(in srgb, currentColor 20%, transparent); overflow: hidden; }
.strip-bar > span { display: block; height: 100%; background: currentColor; transition: width .25s ease-out; }
details > summary { cursor: pointer; }
details.raw { margin-top: 10px; }
details.raw code { display: block; margin-top: 6px; padding: 8px 10px; }
details.panel > summary.label { margin: 0; }
details.panel[open] > summary.label { margin-bottom: 10px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 8px; }
.toolbar > * { max-width: 100%; }
.search { width: 220px; }
.newtemplate { gap: 8px; margin-bottom: 16px; }
.newtemplate input.size { width: 6em; }
.check { display: inline-flex; align-items: center; gap: 6px; }
.tablewrap { overflow-x: auto; }
.nowrap { white-space: nowrap; }
.actions { white-space: nowrap; text-align: right; }
.actions form { display: inline; }
.inlineform { display: inline-flex; align-items: center; gap: 6px; }
.actions .inlineform input[type="password"] { width: 170px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
fieldset.field > legend { padding: 0; margin-bottom: 4px; }
.notice.secret { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.notice.secret code { font-size: 13px; padding: 4px 8px; }
.fallback { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
img.thumb, span.thumb { display: block; background: #000; border-radius: 2px; }
.thumb.small { height: 32px; width: auto; max-width: 120px; object-fit: contain; image-rendering: auto; }
[hidden] { display: none !important; }
.screen > a { display: block; width: 100%; height: 100%; cursor: zoom-in; }

/* content chooser: radio tiles, each revealing its picker */
fieldset.plain { border: 0; margin: 0; padding: 0; min-width: 0; }
.notice { margin: 0 0 10px; padding: 6px 10px; border-radius: 8px; font-weight: 600; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tile { position: relative; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 8px;
        border: 1px solid var(--rule); border-radius: 8px; cursor: pointer; font-weight: 600; text-align: center; }
.tile input { position: absolute; opacity: 0; pointer-events: none; }
.tile:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); color: var(--accent); }
.tile:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.tile .now, .choice .now { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; color: var(--ok); background: var(--ok-bg);
             padding: 0 6px; border-radius: 999px; }
fieldset:disabled .tile, fieldset:disabled .choice { cursor: default; opacity: .6; }
fieldset:disabled .choice-pick { cursor: default; }
/* favourite star: a toggle button, filled amber when on */
.star { font-size: 16px; line-height: 1; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 6px; background: transparent;
        color: var(--muted); cursor: pointer; }
.star:hover:not(:disabled) { color: var(--amber); background: var(--tint); }
.star.on { color: var(--amber); }
.star:disabled { cursor: default; }
.actions .tipwrap:has(> .star) { vertical-align: middle; }
.picker { margin-top: 12px; }
.picker p { margin: 0; }
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.choice { position: relative; padding: 8px; border: 1px solid var(--rule); border-radius: 8px; min-width: 0; }
.choice-pick { display: flex; flex-direction: column; gap: 4px; cursor: pointer; min-width: 0; }
.choice .choice-meta { padding-right: 28px; }
.choice > .tipwrap { position: absolute; right: 4px; bottom: 4px; }
.choice .thumb { width: 100%; height: auto; object-fit: contain; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.choice:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.choice-label { font-weight: 600; overflow-wrap: anywhere; }
.choice-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
/* slots form: a row per text field, labelled by its name, then the draft preview */
.platerow { display: grid; grid-template-columns: 7em minmax(0, 1fr) auto auto; align-items: center; gap: 8px; padding: 4px 0; }
.platerow .marker { font-weight: 600; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.platerow input.plate { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.platerow input.plate.upper { text-transform: uppercase; }
.platerow input.plate::placeholder { text-transform: none; }
.platerow.invalid input.plate { border-color: var(--bad); }
.platerow .rowerror, .platerow .platehint { grid-column: 2 / -1; }
.platerow .platehint { margin: -4px 0 0; font-size: 12px; }
.platerow .rowerror[data-client]:empty { display: none; }
@media (max-width: 520px) { .platerow { grid-template-columns: 5em minmax(0, 1fr) auto; } .platerow input[type="datetime-local"] { grid-column: 2 / -1; } }
.plates .draft { margin-top: 12px; }
.plates .draft + .meta { margin: 8px 0 0; }
.formactions { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.formactions form { display: inline; }

/* stacked form: a drop zone for a file, a row of fields, progress */
.stack { display: flex; flex-direction: column; gap: 10px; }
.formrow { display: flex; flex-wrap: wrap; gap: 8px; }
.formrow .grow { flex: 1 1 220px; }
.drop { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 18px; border: 1px dashed var(--rule); border-radius: 8px; cursor: pointer; }
.drop.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.drop.has { border-style: solid; }
.drop input[type="file"] { max-width: 100%; }
progress { width: 100%; height: 6px; accent-color: var(--accent); }
/* a stored picture being read: a bar as wide as the Re-read button it
   replaces (with its 4px sides), so the nowrap actions column does not jump */
.rowprogress { width: 52px; margin: 0 4px; vertical-align: middle; }
.rowerror { margin: 0; color: var(--bad); font-size: 12px; font-weight: 600; }

/* sign administration: the manage table, the sign form in two columns,
   the connection test's answer */
.pagehead .pushright { margin-left: auto; align-self: center; }
.managesigns .signcell .meta { display: block; }
.managesigns .actions > * + * { margin-left: 4px; }
/* the sign order: a grip to drag (or arrow keys on it) before the name;
   the row dragged dimmed, a line where it lands. The grip is a span with
   the button role, since Firefox starts no drag from inside a <button>; a
   touch on it drags rather than scrolls. */
.signcell { display: flex; align-items: center; gap: 8px; }
.grip { flex: none; padding: 4px 8px 4px 4px; margin-left: -4px; border: 0; border-radius: 6px; background: transparent; color: var(--muted);
        cursor: grab; font-size: 16px; line-height: 20px; letter-spacing: -.12em; user-select: none; touch-action: none; }
.grip:hover { color: var(--ink); background: var(--tint); }
.managesigns tr.dragging { opacity: .45; }
.managesigns tr.dropbefore > td { box-shadow: inset 0 2px 0 var(--accent); }
.managesigns tr.dropafter > td { box-shadow: inset 0 -2px 0 var(--accent); }
@media (max-width: 640px) {
  .managesigns tr.dropbefore > td, .managesigns tr.dropafter > td { box-shadow: none; }
  .managesigns tr.dropbefore { box-shadow: inset 0 2px 0 var(--accent); }
  .managesigns tr.dropafter { box-shadow: inset 0 -2px 0 var(--accent); }
}
/* read out, not shown */
.sronly { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.signform { max-width: 720px; }
.signfonts { max-width: 720px; margin-top: 16px; }
.signfonts .sectionhead { align-items: center; margin-bottom: 8px; }
.signfonts .sectionhead .pushright { margin-left: auto; }
.fonttable .fontsample img { display: block; max-width: 100%; height: auto; image-rendering: pixelated; background: #000; padding: 3px; border-radius: 3px; box-sizing: content-box; }
.signform > .label { margin-top: 18px; }
.signform > .label:first-of-type { margin-top: 0; }
.formgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; align-items: start; }
@media (max-width: 560px) { .formgrid { grid-template-columns: minmax(0, 1fr); } }
.formgrid .enabledcheck { align-self: end; padding-bottom: 6px; }
.field .hint { font-size: 11px; }
input.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
input[readonly] { background: var(--tint); color: var(--muted); }
.probebar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }
.proberesult:not(:empty) { margin-top: 10px; }
.probe { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; border-radius: 8px; }
.probe > span { color: var(--ink); }
.probe > code { align-self: flex-start; margin-top: 2px; background: transparent; padding: 0; color: var(--ink); }

/* picture cards (images, templates): the picture on black over the body.
   Visible overflow, so a popover menu is not clipped. */
.card.media { overflow: visible; }
.media-box { display: grid; place-items: center; height: 150px; padding: 12px; background: var(--bezel); overflow: hidden;
             border-radius: var(--radius) var(--radius) 0 0; }
.media-box > a { display: contents; cursor: zoom-in; }
/* Cards draw a picture at most twice its native width and often smaller:
   smoothed, so text in it stays legible. */
.media-box img.thumb { width: 100%; height: auto; max-height: 126px; object-fit: contain; image-rendering: auto; }
.cardactions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.cardactions form { display: inline; }
.popover { position: relative; }
.popover > summary { list-style: none; display: inline-block; }
.popover > summary::-webkit-details-marker { display: none; }
.popover[open] > summary { border-color: var(--accent); color: var(--accent); }
.popmenu { position: absolute; z-index: 10; top: calc(100% + 4px); left: 0; min-width: 180px; max-height: 260px; overflow-y: auto;
           display: flex; flex-direction: column; padding: 4px; background: var(--panel); border: 1px solid var(--rule); border-radius: 8px;
           box-shadow: 0 6px 24px rgba(0,0,0,.15); }
.popmenu form { display: block; }
.popmenu .btn.text { display: block; width: 100%; text-align: left; padding: 6px 10px; border-radius: 6px; }
.popmenu .btn.text:hover:not(:disabled) { background: var(--tint); }

/* template editor, one column: the top bar, the canvas (the sign at its
   zoom, narrower on a narrow page), the toolbar, the properties, the region
   chips. html.js is set by app.js: .nojs shows without JavaScript, .jsonly
   with it. */
html.js .nojs, html:not(.js) .jsonly { display: none !important; }
.editorbar { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; margin-bottom: 12px; }
.editorsave { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; flex: 1 1 auto; }
.editorsave .tname { font-size: 15px; font-weight: 600; width: 280px; }
.editorsave .tid { width: 180px; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.editorsave .tid[readonly] { background: var(--tint); color: var(--muted); }
.editorsave .tsize { padding-top: 6px; white-space: nowrap; }
.editorbar .saveas .popmenu { left: auto; right: 0; gap: 8px; padding: 10px; min-width: 260px; max-height: none; }
.editorerrors { margin: 0 0 12px; padding: 8px 12px 8px 28px; border-radius: 8px; color: var(--bad); background: var(--bad-bg); font-weight: 600; }
.editorerrors li + li { margin-top: 2px; }
.editorerrors code { background: transparent; padding: 0; margin-right: 4px; cursor: pointer; }
.layoutjson { display: block; width: 100%; font: 12px/1.4 ui-monospace, "SF Mono", Menlo, Consolas, monospace; padding: 8px 10px;
              border: 1px solid var(--rule); border-radius: 8px; background: var(--panel); color: var(--ink); }
.editorbody { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.editorbody > .editorerrors { margin: 0; }
.dirtymark { margin-left: 4px; font-weight: 700; }
.canvaswrap { padding: 8px; background: var(--bezel); border-radius: var(--radius); box-shadow: inset 0 0 0 1px var(--bezel-edge); }
.canvas { position: relative; max-width: 100%; margin: 0 auto; background: #000; user-select: none; touch-action: none; }
.canvasimg { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; pointer-events: none; }
.region { position: absolute; outline: 1px solid rgba(255,255,255,.35); outline-offset: -1px; cursor: move; }
.region.label { outline: 1px dashed rgba(242,183,5,.6); }
.region:hover { outline-color: rgba(255,255,255,.85); }
.region.on { outline: 2px solid var(--accent); outline-offset: 0; background: color-mix(in srgb, var(--accent) 10%, transparent); z-index: 2; }
.region.label.on { outline-style: dashed; }
/* The sign draws it: a dotted teal box, the sign's own text. */
.region.sign { outline: 1px dotted rgba(64,214,190,.9); }
.region.sign:hover { outline-color: rgb(120,240,220); }
.region.sign.on { outline: 2px dotted #40d6be; background: rgba(64,214,190,.10); }
.region.bad { outline: 2px solid var(--bad); }
.regionname { position: absolute; left: 0; top: 0; max-width: 100%; padding: 0 4px; font-size: 10px; line-height: 14px; color: #fff;
              background: rgba(0,0,0,.75); border-radius: 0 0 3px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
              pointer-events: none; display: none; }
.region:hover .regionname, .region.on .regionname { display: block; }
.handle { position: absolute; width: 9px; height: 9px; margin: -5px 0 0 -5px; background: #fff; border: 1px solid var(--accent); border-radius: 2px; display: none; }
.region.on .handle { display: block; }
.h-nw { left: 0; top: 0; cursor: nwse-resize; }   .h-n { left: 50%; top: 0; cursor: ns-resize; }
.h-ne { left: 100%; top: 0; cursor: nesw-resize; } .h-e { left: 100%; top: 50%; cursor: ew-resize; }
.h-se { left: 100%; top: 100%; cursor: nwse-resize; } .h-s { left: 50%; top: 100%; cursor: ns-resize; }
.h-sw { left: 0; top: 100%; cursor: nesw-resize; } .h-w { left: 0; top: 50%; cursor: ew-resize; }
.edittools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.btn.tool { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px 0 8px; white-space: nowrap; font-size: 13px; }
.btn.tool svg { display: block; flex: none; }
.bgmenu > summary.btn.tool { list-style: none; }
.bgmenu > summary.btn.tool::-webkit-details-marker { display: none; }
.toolsep { width: 1px; height: 20px; margin: 0 4px; background: var(--rule); }
.bgmenu .bgpick { display: grid; grid-template-columns: repeat(2, 150px); gap: 6px; padding: 6px; max-height: 320px; }
.bgopt { display: grid; place-items: center; aspect-ratio: 368/104; padding: 2px; border: 1px solid var(--rule); border-radius: 6px; background: #000;
         color: #a0a2a8; font-size: 12px; font-weight: 600; cursor: pointer; overflow: hidden; }
.bgopt img { width: 100%; height: 100%; object-fit: contain; image-rendering: auto; }
.bgopt.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
@media (max-width: 520px) { .bgmenu .bgpick { grid-template-columns: repeat(2, 120px); } }
.props { padding: 10px 14px; }
.props > .meta { margin: 0; }
.proprows { display: flex; flex-direction: column; gap: 8px; }
.proprow { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 10px; }
.proprow .field { flex: 0 1 130px; }
.proprow .pid { flex-basis: 150px; }
.proprow .pname { flex-basis: 180px; }
.proprow .pgroup { flex-basis: 110px; }
.proprow .ptext { flex: 1 1 200px; }
.proprow .pnum { flex-basis: 76px; }
.proprow .pface { flex-basis: 190px; }
.proprow .psize { flex-basis: 170px; }
.proprow .pfont { flex: 1 1 260px; max-width: 420px; }
.proprow .pfonthead { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.proprow .pfonthead .hint { margin-left: auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.propkind { margin: 0; font-size: 12px; color: var(--muted); }
.proprow .pupper { padding-bottom: 6px; white-space: nowrap; }
@media (max-width: 520px) { .proprow .field { flex: 1 1 calc(50% - 5px); } .proprow .ptext, .proprow .psize { flex-basis: 100%; } }
.proprow input, .proprow select { width: 100%; }
.proprow input[readonly] { background: var(--tint); color: var(--muted); }
.proprow input[type="color"] { padding: 2px; height: 32px; }
.sizepick { display: flex; gap: 6px; }
.sizepick select { flex: 1 1 auto; }
.sizepick input { flex: 0 0 64px; width: 64px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; max-width: 300px; padding: 3px 10px 3px 8px; border: 1px solid var(--rule); border-radius: 999px;
        background: var(--panel); cursor: pointer; white-space: nowrap; }
.chip > span:last-child { overflow: hidden; text-overflow: ellipsis; }
.chip > span:not(:last-child) { display: inline-flex; color: var(--muted); }
.chip:hover { border-color: var(--accent); }
.chip.on { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--panel)); }
.chip.on > span:not(:last-child) { color: var(--accent); }
.chip.bad { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad); color: var(--bad); }
.chip > .chipkind { font-size: 11px; }
.chip.sign:not(.on):not(.bad) > span:not(:last-child) { color: #1f9c88; }

/* tables and definition lists */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--rule); }
.table td { padding: 6px 8px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
/* .reflow: on a phone each row is a block of its cells, the last one (the
   detail) on a line of its own, instead of a table to scroll sideways. */
@media (max-width: 640px) {
  .table.reflow thead { display: none; }
  .table.reflow tr { display: flex; flex-wrap: wrap; gap: 2px 12px; padding: 8px 0; border-bottom: 1px solid var(--rule); }
  .table.reflow td { padding: 0; border: 0; }
  .table.reflow td:empty { display: none; }
  .table.reflow td:first-child { color: var(--muted); }
  .table.reflow td:last-child { flex-basis: 100%; }
  /* the users table: a long address breaks rather than widening the row,
     and the row's buttons wrap */
  .users td.login { min-width: 0; overflow-wrap: anywhere; }
  .users td.actions { display: flex; flex-wrap: wrap; gap: 6px; white-space: normal; text-align: left; }
}
.dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; overflow-wrap: anywhere; }

/* buttons and fields */
.btn { font-weight: 600; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--rule); background: var(--panel); cursor: pointer; }
.btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn:disabled { color: var(--muted); cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--panel); }
.btn.primary:disabled { color: var(--panel); opacity: .45; }
.btn.primary:hover:not(:disabled) { color: var(--panel); filter: brightness(1.08); }
/* the ↻ icon button (refreshButton): square, the icon centred; it turns
   while a refresh waits or runs */
.btn.iconbtn { display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0; vertical-align: middle; }
.btn.iconbtn svg { display: block; }
.btn.iconbtn.busy svg { animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn.danger { color: var(--bad); }
.btn.danger:hover:not(:disabled) { border-color: var(--bad); color: var(--bad); }
.btn.danger:disabled { color: var(--muted); }
.btn.text { border-color: transparent; background: transparent; padding-left: 4px; padding-right: 4px; }
a.btn { display: inline-block; text-decoration: none; }
/* fields: every text-like input and select looks the same */
.field { display: flex; flex-direction: column; gap: 4px; }
input:not([type="checkbox"], [type="radio"], [type="file"]), select {
  padding: 5px 10px; border: 1px solid var(--rule); border-radius: 8px; background: var(--panel); min-width: 0; max-width: 100%; }

/* toast: the flash; livetoasts: the stack of live ones, newest at the
   bottom, clear of the flash (bottom right, above it on a phone) */
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 20; max-width: calc(100% - 32px); }
.toast, .livetoast { padding: 8px 14px; border-radius: 8px; font-weight: 600; box-shadow: 0 4px 16px rgba(0,0,0,.2); }
.livetoasts { position: fixed; right: 20px; bottom: 20px; z-index: 20; display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
              max-width: min(420px, calc(100% - 32px)); pointer-events: none; }
.livetoast { pointer-events: auto; cursor: default; overflow-wrap: anywhere; }
@media (max-width: 640px) { .livetoasts { left: 16px; right: 16px; bottom: 64px; max-width: none; align-items: stretch; } }

/* dialogs */
.dialog { border: 0; padding: 0; border-radius: var(--radius); background: var(--panel); color: var(--ink); box-shadow: 0 12px 40px rgba(0,0,0,.3); max-width: min(560px, calc(100% - 32px)); }
.dialog::backdrop { background: rgba(0,0,0,.6); }
.dialog form { padding: 18px 20px; margin: 0; }
.dialog-title { margin: 0 0 8px; font-size: 15px; }
.dialog p { margin: 0 0 16px; color: var(--muted); }
.dialog .actions { display: flex; justify-content: flex-end; gap: 8px; }
.lightbox { max-width: min(1200px, calc(100% - 32px)); background: #000; padding: 16px; cursor: zoom-out; }
.lightbox img { display: block; width: 100%; max-height: 80vh; object-fit: contain; image-rendering: pixelated; }

/* hints: #tip is the layout's popover="hint", placed by app.js under (or
   over) the element with data-tip; inverted, so it stands off the panels
   in both themes. The browser's popover box is undone (inset, margin,
   border, padding, colours, overflow); its display stays the browser's,
   but where popovers are unknown the element would show, empty. .tipped
   marks plain text with a hint; badges and chips only change the cursor,
   not inside a link (the overview's cards open the sign). A disabled
   control takes no pointer events, so its .tipwrap gets them. */
#tip { position: fixed; inset: auto; left: 0; top: 0; margin: 0; width: max-content; max-width: min(22rem, 100vw - 16px);
       padding: 4px 8px; border: 0; border-radius: 6px; color: var(--bg); background: var(--ink); overflow: visible;
       overflow-wrap: anywhere; font-size: 12px; line-height: 1.4; font-weight: 500; text-align: left;
       box-shadow: 0 6px 24px rgba(0,0,0,.15); pointer-events: none; }
@supports not selector(:popover-open) { #tip { display: none; } }
.tipped { text-decoration: underline dotted var(--muted); text-underline-offset: 3px; cursor: help; }
.badge[data-tip], .chip[data-tip] { cursor: help; }
a .badge[data-tip], a .chip[data-tip] { cursor: inherit; }
.tipwrap { display: inline-flex; }
.popmenu .tipwrap { display: block; }
.tipwrap > :disabled { pointer-events: none; }
/* iOS sends no click for a tap on plain text unless it looks clickable,
   and a tap is how a hint shows on touch. */
@media (hover: none) { [data-tip]:not([data-tip=""]) { cursor: pointer; } }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
