/* Arhangel panel stylesheet: the CSS API.
   A working tool for people who run game servers: compact controls, quiet surfaces, information first.

   How it is built (full reference: docs/CSS-API.md)
   - Everything here sits in cascade layers, from general to specific:
       arh.tokens      design tokens: colours, fonts, sizes, motion (custom properties on :root)
       arh.base        element defaults
       arh.primitives  the reusable parts every screen is made of: icon, button, field, input, tabs,
                       card (block), badge, table, notice, chart, code, modal, toast, menu
       arh.layout      page frame: top bar, side menu, server sub-navigation, page grids
       arh.components  composed parts of particular screens: server list, console, files, editor, nodes…
       arh.responsive  touch, tablet and phone adaptations
       arh.motion      animations (off with Admin -> Settings -> Appearance -> Animations, or the
                       system's "reduce motion")
       arh.utilities   single-purpose helpers (.u-*), they win over everything above
   - Rules outside any layer win over every layer. That is where Admin -> Settings -> Appearance ->
     Custom CSS (served as /custom.css) and plugin styles go: they overlay the panel's styles rather
     than replace them, and need no !important.
   - Primitives read their own variables (--btn-bg, --tab-h, --card-pad…) that fall back to the global
     tokens. Change a token to restyle the whole panel, a component variable to restyle one kind of
     element, or set it on a container to restyle that part only:  .console { --console-h: 640px; } */

@layer arh.tokens, arh.base, arh.primitives, arh.layout, arh.components, arh.responsive, arh.motion, arh.utilities;

/* ===================================================================================== tokens */
@layer arh.tokens {
  :root {
    /* fonts */
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
    --fs: 13px;            /* body text */
    --fs-sm: 12px;         /* labels, hints, table heads */
    --fs-xs: 11.5px;       /* badges, captions */
    --fs-code: 12.5px;
    --fs-h1: 17px; --fs-h2: 15px; --fs-h3: 13.5px;
    --lh: 1.45;
    --fw-medium: 500; --fw-strong: 600;
    /* geometry */
    --radius: 6px;
    --r-sm: calc(var(--radius) * .66);
    --ctl: 30px;           /* control height */
    --ctl-s: 26px;         /* small control */
    --pad: 12px;           /* block padding */
    --gap: 12px;           /* space between blocks */
    /* colour: accent and states */
    --accent: #4a7fd4;     /* steel cobalt; Appearance -> Accent colour */
    --accent-2: #3a69b5;   /* hover / pressed */
    --accent-fg: #fff;
    --ok: #3f9d5d; --warn: #c98a1b; --err: #d24b4b; --relay: #3b7fe0;
    /* colour: surfaces (light theme) */
    --bg: #eef0f2; --chrome: #f8f9fa; --surface: #fff; --surface-2: #f4f5f7; --raise: #e9ecef;
    --border: #d9dde2; --border-2: #c6ccd3; --text: #1f252c; --muted: #66707c;
    --term-bg: #1b1f24; --term-text: #d6dbe1; --term-line: #2c323a;
    --scrim: rgba(10, 14, 20, .55);
    --shadow-1: 0 8px 24px rgba(0, 0, 0, .25);
    --shadow-2: 0 12px 40px rgba(0, 0, 0, .35);
    --focus: 0 0 0 2px color-mix(in srgb, var(--accent) 55%, transparent);
    /* motion */
    --motion-fast: .12s; --motion: .2s; --motion-slow: .45s;
    --ease: cubic-bezier(.2, .7, .3, 1);
    /* names of 0.8 and older, kept for plugins */
    --nc: var(--accent); --nc-2: var(--accent-2); --nc-fg: var(--accent-fg);
  }
  [data-theme=dark] {
    --bg: #1d2127; --chrome: #181b20; --surface: #252a31; --surface-2: #2b3038; --raise: #323842;
    --border: #353c46; --border-2: #444c57; --text: #e4e8ec; --muted: #909aa6;
    --ok: #4cae6a; --warn: #d9a03a; --err: #e05a5a; --relay: #4c8ff0;
    --term-bg: #16191d; --term-text: #d6dbe1; --term-line: #2a2f36;
  }
  [data-density=comfortable] { --ctl: 36px; --ctl-s: 30px; --pad: 16px; --gap: 16px; --fs: 14px; }
  [data-font=inter] { --font: Inter, "Inter Variable", system-ui, sans-serif; }
  [data-font=mono] { --font: var(--mono); }
  @media (pointer: coarse) { :root { --ctl: 36px; --ctl-s: 32px; } }
  @media (max-width: 600px) { :root, [data-density] { --gap: 8px; } }
}

/* ======================================================================================= base */
@layer arh.base {
  *, *::before, *::after { box-sizing: border-box; }
  html, body { margin: 0; height: 100%; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body { background: var(--bg); color: var(--text); font: var(--fs)/var(--lh) var(--font); font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
  a { color: var(--accent); text-decoration: none; }
  a:hover { text-decoration: underline; }
  :focus-visible { outline: none; box-shadow: var(--focus); }
  h1, h2, h3 { margin: 0; font-weight: var(--fw-strong); letter-spacing: -.005em; }
  h1 { font-size: var(--fs-h1); } h2 { font-size: var(--fs-h2); } h3 { font-size: var(--fs-h3); }
  p { margin: 0 0 8px; }
  small, .muted { color: var(--muted); }
  small { font-size: var(--fs-sm); }
  code, .mono, pre { font-family: var(--mono); }
  code { font-size: var(--fs-sm); background: var(--surface-2); border: 1px solid var(--border); padding: 0 5px; border-radius: var(--r-sm); overflow-wrap: anywhere; }
  [hidden] { display: none !important; }
  details summary { cursor: pointer; color: var(--muted); font-size: var(--fs-code); margin: 8px 0 6px; }
  details summary:hover { color: var(--text); }
  button:disabled { cursor: not-allowed; }
  body.ed-open, body.sheet-open { overflow: hidden; }
  .boot, .loading, .empty { padding: 28px; text-align: center; color: var(--muted); }
  .loading { display: flex; gap: 10px; align-items: center; justify-content: center; }
  span.ok { color: var(--ok); } span.err { color: var(--err); }
}

/* ================================================================================= primitives */
@layer arh.primitives {
  /* ---- icon: 24×24 stroke SVG from Arhangel.icon(name, size); data-icon carries the name ---- */
  .ico { flex: none; vertical-align: middle; stroke-width: var(--icon-stroke, 1.8); color: var(--icon-color, currentColor); }

  /* ---- button ---- */
  .btn { --btn-h: var(--ctl); --btn-px: 12px; --btn-fs: var(--fs); --btn-radius: var(--r-sm);
    --btn-bg: var(--surface); --btn-fg: var(--text); --btn-border: var(--border-2);
    --btn-bg-hover: var(--surface-2); --btn-fg-hover: var(--btn-fg); --btn-border-hover: var(--muted);
    display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: var(--btn-h); padding: 0 var(--btn-px); border-radius: var(--btn-radius);
    border: 1px solid var(--btn-border); background: var(--btn-bg); color: var(--btn-fg); font: var(--fw-medium) var(--btn-fs) var(--font); white-space: nowrap; cursor: pointer; }
  .btn:hover { background: var(--btn-bg-hover); border-color: var(--btn-border-hover); color: var(--btn-fg-hover); text-decoration: none; }
  .btn:active:not(:disabled) { transform: translateY(1px); }
  .btn:disabled { opacity: .5; cursor: not-allowed; }
  .btn.small { --btn-h: var(--ctl-s); --btn-px: 9px; --btn-fs: var(--fs-sm); }
  .btn.ghost { --btn-bg: transparent; --btn-border: transparent; --btn-bg-hover: var(--raise); --btn-border-hover: transparent; }
  .btn.primary { --btn-bg: var(--accent); --btn-border: var(--accent); --btn-fg: var(--accent-fg); --btn-bg-hover: var(--accent-2); --btn-border-hover: var(--accent-2); }
  .btn.success { --btn-bg: var(--ok); --btn-border: var(--ok); --btn-fg: #fff; --btn-bg-hover: color-mix(in srgb, var(--ok) 85%, black); --btn-border-hover: var(--btn-bg-hover); }
  .btn.danger { --btn-bg: transparent; --btn-border: color-mix(in srgb, var(--err) 60%, var(--border)); --btn-fg: var(--err);
    --btn-bg-hover: var(--err); --btn-border-hover: var(--err); --btn-fg-hover: #fff; }
  /* square icon-only button */
  .icon-btn { --btn-h: var(--ctl); width: var(--btn-h); height: var(--btn-h); display: grid; place-items: center; border: 0; border-radius: var(--r-sm);
    background: none; color: var(--muted); cursor: pointer; font: inherit; }
  .icon-btn:hover, .icon-btn.active { background: var(--raise); color: var(--text); text-decoration: none; }

  /* ---- input ---- */
  .input, select.input, textarea.input { --input-h: var(--ctl); width: 100%; min-width: 0; height: var(--input-h); padding: 0 var(--input-px, 9px);
    background: var(--input-bg, var(--surface)); color: var(--input-fg, var(--text)); border: 1px solid var(--input-border, var(--border-2));
    border-radius: var(--input-radius, var(--r-sm)); font: var(--fs) var(--font); }
  [data-theme=dark] :is(.input, select.input, textarea.input) { --input-bg: var(--bg); }
  textarea.input { height: auto; padding: 7px 9px; font: var(--fs-code)/1.5 var(--mono); resize: vertical; }
  .input.mono { font-family: var(--mono); font-size: var(--fs-code); }
  .input:focus, select.input:focus, textarea.input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
  .input:disabled { opacity: .55; cursor: not-allowed; }
  input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--accent); margin: 0; }
  input[type=color] { width: 36px; height: var(--ctl); padding: 2px; border: 1px solid var(--border-2); border-radius: var(--r-sm); background: var(--surface); }
  input[type=range] { accent-color: var(--accent); flex: 1; }
  .lang-sel { height: var(--ctl-s); background: transparent; color: var(--muted); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 0 4px; font: var(--fs-sm) var(--font); cursor: pointer; }

  /* ---- field: label / control / hint (Arhangel.ui.field, ui.form) ---- */
  .form { display: grid; gap: 10px; }
  .form.cols { grid-template-columns: repeat(auto-fit, minmax(var(--field-min, 200px), 1fr)); gap: 10px 14px; }
  .form-f { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 4px; }
  .field { display: grid; gap: var(--field-gap, 4px); min-width: 0; align-content: start; }
  .field .lbl, .field-label { font-size: var(--field-label-fs, var(--fs-sm)); font-weight: var(--fw-medium); color: var(--field-label-fg, var(--muted)); overflow-wrap: anywhere; }
  .field-label code { margin-left: 6px; font-weight: 400; }
  .field small, .field-hint { font-size: var(--fs-sm); color: var(--field-hint-fg, var(--muted)); overflow-wrap: anywhere; }
  .field-hint { display: grid; gap: 2px; align-content: start; }
  .field-hint code { font-size: var(--fs-xs); }
  .field.check { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; cursor: pointer; }
  .field.check small { flex-basis: 100%; padding-left: 23px; }
  .field.full { grid-column: 1 / -1; }
  .hint { display: block; color: var(--muted); font-size: var(--fs-sm); margin: 4px 0 0; overflow-wrap: anywhere; }
  p.hint { margin: 0 0 var(--gap); }
  .lbl-row { font-size: var(--fs-sm); color: var(--muted); margin: 12px 0 6px; }
  .saved { display: block; min-height: 1.2em; margin-top: 4px; } .saved.ok { color: var(--ok); } .saved.err { color: var(--err); }
  /* forms in columns: label, control and hint of neighbouring fields line up, however long a label
     or hint is (subgrid shares the three row tracks; a field has exactly three parts) */
  @supports (grid-template-rows: subgrid) {
    .form.cols { row-gap: 0; align-items: start; }
    .form.cols > .field { grid-row: span 3; grid-template-rows: subgrid; row-gap: 0; align-content: start; margin-bottom: 12px; }
    .form.cols > .field > :is(.lbl, .field-label) { align-self: end; margin-bottom: 4px; }
    .form.cols > .field > :is(small, .field-hint) { margin-top: 4px; }
    .form.cols > .field.check { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 8px; align-items: center; }
    .form.cols > .field.check > input { grid-row: 2; grid-column: 1; }
    .form.cols > .field.check > span { grid-row: 2; grid-column: 2; }
    .form.cols > .field.check > small { grid-row: 3; grid-column: 1 / -1; padding-left: 23px; align-self: start; }
    .form.cols > .field > :is(.input, select, .combo) { align-self: center; }
  }

  /* ---- tabs: one primitive for every switcher; variants by container ----
     variables (set on .tabs, a variant or one .tab): --tab-h --tab-px --tab-gap --tab-radius --tab-fg --tab-fg-active
     --tab-bg-hover --tab-bg-active --tab-indicator --tab-indicator-size
     .tabs (pills) · .tabs.tabs-line (bookmarks: underlined) · .tabs.tabs-seg (segmented) · .tabs.tabs-side (vertical menu) */
  .tabs { display: flex; gap: 2px; margin-bottom: var(--gap); flex-wrap: wrap; }
  .tab { display: inline-flex; align-items: center; gap: var(--tab-gap, 6px); height: var(--tab-h, var(--ctl)); padding: 0 var(--tab-px, 12px); border: 0;
    border-radius: var(--tab-radius, var(--r-sm)); background: none; color: var(--tab-fg, var(--muted)); font: inherit; white-space: nowrap; cursor: pointer; }
  .tab:hover { color: var(--tab-fg-active, var(--text)); background: var(--tab-bg-hover, var(--raise)); text-decoration: none; }
  .tab.active { color: var(--tab-fg-active, var(--text)); background: var(--tab-bg-active, var(--raise)); }
  .tabs-line { --tab-radius: 0; --tab-bg-hover: transparent; --tab-bg-active: transparent; gap: 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--border); }
  .tabs-line .tab { border-bottom: var(--tab-indicator-size, 2px) solid transparent; margin-bottom: -1px; }
  .tabs-line .tab.active { border-bottom-color: var(--tab-indicator, var(--accent)); }
  .tabs-seg { --tab-bg-hover: var(--surface-2); --tab-radius: 0; display: inline-flex; gap: 0; border: 1px solid var(--border-2); border-radius: var(--r-sm); overflow: hidden; margin-bottom: 10px; flex-wrap: nowrap; }
  .tabs-seg .tab { background: var(--surface); }
  .tabs-seg .tab + .tab { border-left: 1px solid var(--border-2); }
  .tabs-seg .tab.active { background: var(--raise); font-weight: var(--fw-strong); }
  .tabs-side { --tab-px: 10px; --tab-gap: 9px; --tab-fg: var(--text); flex-direction: column; flex-wrap: nowrap; gap: 0; margin: 0; }
  .tabs-side .tab .ico { color: var(--muted); }
  .tabs-side .tab.active { background: var(--surface); box-shadow: inset 2px 0 0 var(--tab-indicator, var(--accent)), 0 0 0 1px var(--border); font-weight: var(--fw-strong); }
  .tabs-side .tab.active .ico { color: var(--tab-indicator, var(--accent)); }

  /* ---- card: the block every page is built from ---- */
  .card { background: var(--card-bg, var(--surface)); border: 1px solid var(--card-border, var(--border)); border-radius: var(--card-radius, var(--radius)); margin-bottom: var(--gap); min-width: 0; }
  .card-h { display: flex; align-items: center; gap: 8px; min-height: var(--card-head-h, 40px); padding: 0 var(--card-pad, var(--pad));
    border-bottom: 1px solid var(--card-border, var(--border)); background: var(--card-head-bg, transparent); border-radius: var(--card-radius, var(--radius)) var(--card-radius, var(--radius)) 0 0; }
  .card-b { padding: var(--card-pad, var(--pad)); }
  .card-b > :last-child { margin-bottom: 0; }
  .card-f { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 8px var(--card-pad, var(--pad)); border-top: 1px solid var(--card-border, var(--border));
    background: var(--card-foot-bg, var(--surface-2)); color: var(--muted); font-size: var(--fs-sm); border-radius: 0 0 var(--card-radius, var(--radius)) var(--card-radius, var(--radius)); }
  .card-f.right { justify-content: flex-end; }
  /* statistic tile */
  .stat { display: flex; gap: 10px; align-items: center; padding: 10px var(--pad); background: var(--card-bg, var(--surface)); border: 1px solid var(--card-border, var(--border)); border-radius: var(--card-radius, var(--radius)); min-width: 0; }
  .stat .ic { color: var(--muted); }
  .stat .v { font-size: var(--fs-h1); font-weight: var(--fw-strong); line-height: 1.1; }
  .stat .l { color: var(--muted); font-size: var(--fs-sm); }
  /* key / value rows */
  .kvr { display: flex; gap: 12px; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border); }
  .kvr:last-child { border-bottom: 0; }
  .kvl { color: var(--muted); flex: none; }
  .kvv { text-align: right; min-width: 0; overflow-wrap: anywhere; }
  .kvv.warn-text { color: var(--warn); font-weight: var(--fw-strong); }

  /* ---- notice: a message bar with a coloured edge ---- */
  .notice { --notice-edge: var(--border); display: flex; gap: 10px; align-items: center; padding: 8px var(--pad); border: 1px solid var(--border); border-left: 3px solid var(--notice-edge);
    border-radius: var(--radius); margin-bottom: var(--gap); background: var(--surface); min-width: 0; }
  .notice.warn { --notice-edge: var(--warn); } .notice.err { --notice-edge: var(--err); } .notice.info { --notice-edge: var(--accent); } .notice.ok { --notice-edge: var(--ok); }

  /* ---- badge, tag, dot, method ---- */
  .badge { --badge-bg: var(--raise); --badge-fg: var(--muted); display: inline-flex; align-items: center; height: var(--badge-h, 20px); padding: 0 7px; border-radius: var(--r-sm);
    font-size: var(--fs-xs); font-weight: var(--fw-strong); background: var(--badge-bg); color: var(--badge-fg); white-space: nowrap; }
  .badge.ok { --badge-fg: var(--ok); --badge-bg: color-mix(in srgb, var(--ok) 16%, transparent); }
  .badge.warn { --badge-fg: var(--warn); --badge-bg: color-mix(in srgb, var(--warn) 18%, transparent); }
  .badge.err { --badge-fg: var(--err); --badge-bg: color-mix(in srgb, var(--err) 16%, transparent); }
  .badge.info { --badge-fg: var(--accent); --badge-bg: color-mix(in srgb, var(--accent) 16%, transparent); }
  .tag { display: inline-block; margin-left: 6px; padding: 0 5px; border: 1px solid var(--border-2); border-radius: var(--r-sm); font-size: 11px; font-weight: var(--fw-medium); color: var(--muted); vertical-align: 1px; }
  .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
  .dot.running { background: var(--ok); }
  .dot.starting, .dot.stopping { background: var(--warn); }
  .state-pill { display: inline-flex; align-items: center; gap: 6px; text-transform: capitalize; }
  .method { display: inline-block; min-width: 54px; padding: 1px 6px; border-radius: var(--r-sm); font: 600 11px var(--mono); text-align: center; background: var(--raise); color: var(--muted); }
  .method.get { color: var(--ok); } .method.post { color: var(--accent); } .method.put, .method.patch { color: var(--warn); } .method.delete { color: var(--err); }

  /* ---- table ---- */
  .table-wrap { overflow-x: auto; }
  .card-b > .table-wrap:only-child { margin: calc(var(--card-pad, var(--pad)) * -1); }
  .table { width: 100%; border-collapse: collapse; }
  .table th { text-align: left; font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--muted); padding: 0 var(--pad); height: var(--table-head-h, 32px);
    border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--table-head-bg, var(--surface-2)); }
  .table td { padding: 6px var(--pad); height: var(--table-row-h, 38px); border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
  .table td.wrap { white-space: normal; }
  .table tr:last-child td { border-bottom: 0; }
  .table tr.click { cursor: pointer; }
  .table tr.click:hover td { background: var(--table-hover-bg, var(--surface-2)); }
  .table.compact td { height: auto; padding: 6px 8px; white-space: normal; }

  /* ---- charts: progress bar and sparkline ---- */
  .bar { height: var(--bar-h, 4px); border-radius: calc(var(--bar-h, 4px) / 2); background: var(--bar-bg, var(--raise)); overflow: hidden; margin-top: 4px; }
  .bar > i { display: block; width: var(--bar-value, 0%); height: 100%; background: var(--bar-fill, var(--accent)); transition: width .4s; }
  .spark { width: 100%; height: var(--chart-h, 56px); display: block; margin-top: 6px; }
  .spark-a { fill: var(--chart-fill, color-mix(in srgb, var(--accent) 14%, transparent)); }
  .spark-l { stroke: var(--chart-line, var(--accent)); stroke-width: var(--chart-stroke, 1.4); vector-effect: non-scaling-stroke; }

  /* ---- code ---- */
  pre.code, .pre.code { background: var(--term-bg); color: var(--term-text); padding: 10px 12px; border-radius: var(--r-sm); overflow: auto; font: 12px/1.5 var(--mono); white-space: pre-wrap; word-break: break-all; margin: 0; }
  pre.code.small { font-size: var(--fs-xs); }
  pre.code.wrap { white-space: pre-wrap; word-break: break-all; }
  pre.logs { max-height: 460px; }
  code.copy { cursor: copy; }
  /* an embedded code editor (egg scripts, custom CSS); the full-screen file editor is .ed-screen */
  .code-field { --editor-h: auto; position: relative; display: flex; flex-direction: column; min-height: 6em; height: var(--editor-h);
    border: 1px solid var(--border); border-radius: var(--r-sm); overflow: hidden; background: var(--editor-bg, var(--term-bg)); }
  .code-field .ed-host { flex: 1; min-height: 0; }
  .code-field textarea { border: 0; border-radius: 0; min-height: 100%; }

  /* ---- spinner ---- */
  .spin, .spinner { width: 14px; height: 14px; border: 2px solid var(--border-2); border-top-color: var(--spin-color, var(--accent)); border-radius: 50%; flex: none; }
  .spinner { --spin-color: var(--warn); width: 16px; height: 16px; margin-top: 1px; }

  /* ---- avatar ---- */
  .avatar { --av-size: 34px; display: inline-grid; place-items: center; width: var(--av-size); height: var(--av-size); font-size: calc(var(--av-size) * .42);
    border-radius: 50%; background: var(--raise); color: var(--text); font-weight: var(--fw-strong); overflow: hidden; flex: none; }
  .avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

  /* ---- menu (dropdown) and searchable picker ---- */
  .menu { position: absolute; right: 12px; top: 48px; min-width: 200px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px; z-index: 30; box-shadow: var(--shadow-1); }
  .menu a, .menu button { display: flex; width: 100%; gap: 8px; align-items: center; padding: 6px 10px; border-radius: var(--r-sm); color: var(--text); background: none; border: 0; font: inherit; text-align: left; cursor: pointer; }
  .menu a:hover, .menu button:hover { background: var(--surface-2); text-decoration: none; }
  .combo { position: relative; }
  .combo-list { position: absolute; z-index: 60; left: 0; right: 0; top: calc(100% + 2px); max-height: 260px; overflow: auto; margin: 0; padding: 4px; list-style: none;
    background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--r-sm); box-shadow: var(--shadow-1); }
  .combo-list li { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 5px 8px; border-radius: var(--r-sm); cursor: pointer; }
  .combo-list li small { color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; }
  .combo-list li.on, .combo-list li:hover { background: var(--raise); }
  .combo-list li.none { color: var(--muted); cursor: default; }

  /* ---- modal, toast ---- */
  .backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: var(--scrim); }
  .modal { --modal-w: 520px; width: 100%; max-width: var(--modal-w); max-height: 90vh; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border-2);
    border-radius: var(--radius); box-shadow: var(--shadow-2); }
  .modal.wide { --modal-w: 860px; }
  .modal-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 44px; padding: 0 8px 0 var(--pad); border-bottom: 1px solid var(--border); }
  .modal-b { padding: var(--pad); overflow: auto; }
  .modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 10px var(--pad); border-top: 1px solid var(--border); }
  #toasts { position: fixed; right: 14px; bottom: 14px; display: grid; gap: 6px; z-index: 80; }
  .toast { --toast-edge: var(--accent); display: flex; gap: 8px; align-items: center; max-width: 380px; padding: 8px 12px; background: var(--surface); border: 1px solid var(--border-2);
    border-left: 3px solid var(--toast-edge); border-radius: var(--radius); box-shadow: 0 6px 20px rgba(0, 0, 0, .25); }
  .toast.ok { --toast-edge: var(--ok); } .toast.err { --toast-edge: var(--err); }
  .toast.out { opacity: 0; transition: opacity .25s; }
}

/* ===================================================================================== layout */
@layer arh.layout {
  /* top bar */
  .hdr { --hdr-h: 44px; position: sticky; top: 0; z-index: 20; height: var(--hdr-h); display: flex; align-items: center; gap: 4px;
    padding: 0 max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
    background: var(--hdr-bg, var(--chrome)); border-bottom: 1px solid var(--border); }
  .logo { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 650; font-size: 14px; margin-right: 14px; white-space: nowrap; }
  .logo:hover { text-decoration: none; }
  .brand-img { display: block; }
  .hdr .brand-img { width: 22px; height: 22px; }
  [data-theme=light][data-brand=default] .hdr .brand-img { filter: invert(1) brightness(.25); } /* the built-in wing is white; uploaded logos are left alone */
  .apps { flex: 1; min-width: 0; height: 100%; margin: 0; border-bottom: 0; --tab-h: 100%; --tab-px: 10px; --tab-gap: 7px; }
  .hdr .icon-btn.av .avatar { box-shadow: 0 0 0 1px var(--border-2); }
  .hdr-r { display: flex; align-items: center; gap: 2px; }
  .hdr-slot { display: flex; align-items: center; gap: 4px; }
  .hdr-slot:empty { display: none; }

  /* page frame */
  .page { max-width: var(--page-w, 1360px); margin: 0 auto; padding: 16px 16px 48px; }
  .page-h { display: flex; align-items: center; gap: 8px; margin-bottom: var(--gap); flex-wrap: wrap; min-height: var(--ctl); }
  .page-h h1 small { font-size: var(--fs-sm); font-weight: 400; margin-left: 8px; font-family: var(--mono); }
  .crumbs-top { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: var(--fs-sm); margin-bottom: 6px; }
  .content-wrap { min-width: 0; }
  .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
  .row.nowrap { flex-wrap: nowrap; }
  .row.sp { justify-content: space-between; }
  .sp:empty { flex: 1; } /* spacer: h('div.sp') */

  /* admin: side menu + content */
  .layout { display: grid; grid-template-columns: var(--side-w, 208px) minmax(0, 1fr); gap: var(--gap); align-items: start; }
  .side { position: sticky; top: 60px; }
  .side-h { display: none; }
  .side .grp { padding: 12px 10px 4px; font-size: var(--fs-sm); color: var(--muted); }
  .side .grp:first-of-type { padding-top: 0; }

  /* server sub-navigation */
  .subnav { background: var(--surface); border-bottom: 1px solid var(--border); }
  .subnav-in { max-width: var(--page-w, 1360px); margin: 0 auto; padding: 0 16px; display: flex; align-items: stretch; gap: 16px; overflow-x: auto; scrollbar-width: none; }
  .subnav-name { display: flex; align-items: center; gap: 8px; font-weight: var(--fw-strong); white-space: nowrap; }
  .subnav .tabs { --tab-h: 40px; --tab-px: 10px; margin: 0; border-bottom: 0; }

  /* page grids. One spacing between blocks, horizontally and vertically: every container keeps --gap
     below it (the gap between grid cells is --gap too). */
  .grid { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); margin-bottom: var(--gap); }
  .grid > .card { margin-bottom: 0; }
  .grid.two { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
  .grid.stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
  .settings-layout { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); align-items: start; margin-bottom: var(--gap); }
  .settings-layout.wide-left { grid-template-columns: 2fr 1fr; }
  .settings-layout > .card { margin-bottom: 0; }
  .srv-layout { display: grid; grid-template-columns: 296px minmax(0, 1fr); gap: var(--gap); align-items: start; margin-bottom: var(--gap); }
  .srv-left { min-width: 0; }
  .srv-left .card, .srv-right .card { margin-bottom: var(--gap); }
  .node-about { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: var(--gap); align-items: start; }
  .node-about-l, .node-about-r { display: grid; gap: var(--gap); min-width: 0; }
  .node-about .card { margin-bottom: 0; }
  .lock-slot:not(:empty) { margin-bottom: var(--gap); }
  .content > :last-child, .card-b > .grid:last-child, .srv-right > :last-child, .settings-layout > div > :last-child { margin-bottom: 0; }
}

/* ================================================================================= components */
@layer arh.components {
  /* server list: rows with a state strip, like a rack LED */
  .srv-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
  .srv { --state: var(--border-2); display: grid; grid-template-columns: minmax(200px, 1fr) minmax(0, 2fr); align-items: center; gap: 4px 16px;
    min-height: 46px; padding: 6px var(--pad) 6px calc(var(--pad) + 4px); color: var(--text); border-bottom: 1px solid var(--border); box-shadow: inset 3px 0 0 var(--state); }
  .srv:last-child { border-bottom: 0; }
  .srv:hover { background: var(--surface-2); text-decoration: none; }
  .srv[data-state=running] { --state: var(--ok); }
  .srv[data-state=starting], .srv[data-state=stopping] { --state: var(--warn); }
  .srv[data-state=offline] { --state: var(--muted); }
  .srv[data-state=unreachable] { --state: var(--err); }
  .srv .top { display: flex; align-items: center; gap: 8px; min-width: 0; }
  .srv .top .dot { display: none; }
  .srv .nm { font-weight: var(--fw-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .srv .meta { display: grid; grid-template-columns: 170px minmax(90px, 1fr) minmax(90px, 1fr) 150px; gap: 12px; color: var(--muted); font-size: var(--fs-code); }
  .srv .meta > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .srv .meta > span:first-child { font-family: var(--mono); font-size: var(--fs-sm); color: var(--text); }
  .srv .meta > span:last-child { text-align: right; }

  /* server details column and power buttons */
  .d-title { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
  .d-title h3 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .d-title > span:last-child { color: var(--muted); font-size: var(--fs-sm); text-transform: capitalize; }
  .dr { padding: 7px 0; border-top: 1px solid var(--border); }
  .dl { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: var(--fs-sm); }
  .dv { margin-top: 2px; font-weight: var(--fw-strong); word-break: break-all; }
  /* power buttons share the row but never shrink below their label: a longer translation wraps */
  .power-col { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
  .power-col .btn { --btn-px: 10px; flex: 1 1 0; min-width: fit-content; }
  .power-col .btn.primary { --btn-bg: var(--surface); --btn-border: var(--border-2); --btn-fg: var(--text); --btn-bg-hover: var(--surface-2); --btn-border-hover: var(--muted); }

  /* console */
  .console { --state: var(--muted); --console-h: 460px; --console-bg: var(--term-bg); --console-fg: var(--term-text); --console-border: var(--term-line); --console-fs: 12.5px;
    display: flex; flex-direction: column; margin-bottom: var(--gap); background: var(--console-bg); border: 1px solid var(--console-border);
    border-radius: var(--radius); overflow: hidden; box-shadow: inset 3px 0 0 var(--state); }
  .console[data-state=running] { --state: var(--ok); }
  .console[data-state=starting], .console[data-state=stopping] { --state: var(--warn); }
  .console-out { height: var(--console-h); overflow: auto; padding: 10px 12px 10px 15px; font: var(--console-fs)/1.5 var(--mono); color: var(--console-fg); white-space: pre-wrap; word-break: break-all; }
  .console-out div { min-height: 1.5em; }
  .console-in { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--console-border); padding: 0 12px 0 15px; }
  .console-in span { color: var(--muted); font-family: var(--mono); }
  .console-in input { flex: 1; background: none; border: 0; color: var(--console-fg); font: 13px var(--mono); padding: 9px 0; outline: none; }
  /* the prompt line is part of the console: no focus ring, the caret is the focus */
  .console-in input:is(:focus, :focus-visible) { outline: none; box-shadow: none; }
  .ansi-1 { font-weight: 700; } .c30 { color: #6b7380; } .c31 { color: #ef6b73; } .c32 { color: #6cc788; } .c33 { color: #e3c26b; } .c34 { color: #6ea8f0; } .c35 { color: #c38ae0; } .c36 { color: #5cc4d3; } .c37 { color: #d6dbe1; }
  .c90 { color: #858e9a; } .c91 { color: #ff8a90; } .c92 { color: #8de0a4; } .c93 { color: #f2d98e; } .c94 { color: #98c3ff; } .c95 { color: #dcaaf0; } .c96 { color: #8ce0ec; } .c97 { color: #fff; }

  /* files */
  .crumbs { display: flex; gap: 2px; flex-wrap: wrap; align-items: center; padding: 0 0 8px; font: var(--fs-code) var(--mono); color: var(--muted); }
  .crumbs a { padding: 1px 4px; border-radius: var(--r-sm); }
  .crumbs a:hover { background: var(--raise); text-decoration: none; }
  .crumb-path { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; flex: 1; min-width: 0; min-height: 30px; cursor: text; }
  .crumb-sep { opacity: .6; }
  .crumb-edit { flex: none; }
  .crumb-input { flex: 1; min-width: 0; height: 30px; font: var(--fs-code) var(--mono); }
  .crumbs:has(.crumb-input) { gap: 6px; flex-wrap: nowrap; }
  .frow { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 4px 0 8px; border-top: 1px solid var(--border); }
  .frow:hover { background: var(--surface-2); }
  .frow .fn { flex: 1; min-width: 0; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
  .frow .ico:first-child { color: var(--muted); }
  .frow .fm { color: var(--muted); font-size: var(--fs-sm); width: 80px; text-align: right; }
  .frow .fd { color: var(--muted); font-size: var(--fs-sm); width: 170px; white-space: nowrap; }
  .frow .icon-btn { --btn-h: var(--ctl-s); }
  .frow.sel { background: color-mix(in srgb, var(--accent) 14%, transparent); }
  .frow { user-select: none; }
  .fchk { flex: none; width: 15px; height: 15px; margin: 0; cursor: pointer; accent-color: var(--accent); }
  .selbar { display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 4px 4px 4px 8px; border-top: 1px solid var(--border); background: var(--surface-2); flex-wrap: wrap; }
  .selbar[hidden] { display: none; }
  .sel-info { color: var(--muted); font-size: var(--fs-sm); }
  .sel-btns { flex-wrap: wrap; gap: 6px; }
  .menu.ctx { position: fixed; right: auto; top: 0; left: 0; min-width: 190px; z-index: 60; }
  .ctx-h { padding: 4px 10px 6px; color: var(--muted); font-size: var(--fs-xs); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
  .menu.ctx button.danger { color: var(--err); }
  .perm-table { width: auto; margin-bottom: 10px; }
  .perm-table td, .perm-table th { padding: 4px 14px 4px 0; border: 0; }
  .dropzone { position: relative; }
  .dropzone .drop-hint { display: none; }
  .dropzone.drag { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
  .dropzone.drag .drop-hint { position: absolute; inset: 0; display: flex; gap: 8px; align-items: center; justify-content: center; background: color-mix(in srgb, var(--surface) 88%, transparent);
    color: var(--text); font-weight: var(--fw-strong); border-radius: var(--radius); z-index: 2; }
  .upl { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px var(--pad); margin-bottom: var(--gap); }
  .upl-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: var(--fs-code); }

  /* sign-in */
  .auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
  .auth-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
  .auth-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; font-size: var(--fs-h1); font-weight: 650; color: var(--text); }
  .auth .form-f .btn { width: 100%; }
  .brand-tile { display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius); background: #1d2127; flex: none; }
  .brand-tile .brand-img, .brand-tile .brand-prev { width: 24px; height: 24px; }

  /* ACL scope picker */
  .scope-picker { display: grid; gap: 12px; }
  .scope-tbl { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
  .scope-h { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 7px 10px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
  .scope-h code { border: 0; background: none; padding: 0; color: var(--muted); font-size: var(--fs-xs); }
  .table.scopes tr { cursor: pointer; }
  .table.scopes tr:hover td { background: var(--surface-2); }
  .table.scopes td.cb { width: 28px; padding-right: 0; }
  .table.scopes td.scope-p { width: 38%; }
  .table.scopes td.scope-p code { border: 0; background: none; padding: 0; font-size: var(--fs-xs); color: var(--muted); word-break: break-all; }
  .table.scopes td.st { width: 64px; text-align: right; }
  .scope-t { font-weight: var(--fw-medium); }
  .scope-d { color: var(--muted); font-size: var(--fs-sm); }
  .scope-state { font-size: var(--fs-xs); color: var(--ok); }
  .table.scopes tr.implied .scope-t { color: var(--muted); }
  .table.scopes tr.locked { cursor: not-allowed; opacity: .5; }
  .scope-more textarea { margin-top: 2px; }
  .scope-hint { display: block; }

  /* appearance, database settings */
  .brand-list { display: grid; gap: 8px; margin: 14px 0 6px; }
  .brand-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px 0; border-top: 1px solid var(--border); }
  .brand-txt { display: grid; }
  .css-api { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 4px; }
  .css-api > summary { font-weight: var(--fw-medium); }
  .css-api .code-field { --editor-h: 360px; margin: 8px 0; resize: vertical; }
  .css-api-ref { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 2px 14px; margin: 8px 0; font-size: var(--fs-sm); }
  .css-api-ref button { display: flex; justify-content: space-between; gap: 8px; padding: 2px 4px; border: 0; border-radius: var(--r-sm); background: none; color: var(--text); font: var(--fs-xs) var(--mono); text-align: left; cursor: pointer; }
  .css-api-ref button:hover { background: var(--raise); }
  .css-api-ref button small { font-family: var(--font); }
  .grid-db { grid-template-columns: 2fr 1fr 1fr; gap: 10px 12px; }
  .grid-db .field:nth-child(4) { grid-column: 1; }
  .db-result { margin-top: 8px; font-size: var(--fs-code); word-break: break-word; }

  /* nodes grouped by country; the heart shows whether THIS browser reaches the node */
  .node-group { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: var(--gap); overflow: hidden; }
  .node-group-h { display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 var(--pad); background: var(--surface-2); border-bottom: 1px solid var(--border); }
  .node-group-h .flag { font-size: 16px; line-height: 1; }
  .node-group-h small { color: var(--muted); margin-left: auto; }
  .node-row { display: grid; grid-template-columns: 28px minmax(180px, 1.4fr) minmax(120px, 1fr) 90px 120px minmax(0, 150px) 110px; align-items: center; gap: 12px;
    min-height: 50px; padding: 6px var(--pad); color: var(--text); border-top: 1px solid var(--border); }
  .node-group-h + .node-row { border-top: 0; }
  .node-row:hover { background: var(--surface-2); text-decoration: none; }
  .node-row[data-state=down] :is(.node-main, .node-city, .node-num) { opacity: .55; }
  .node-main, .node-num { display: grid; min-width: 0; }
  .node-main small, .node-num small { color: var(--muted); font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .node-main small { font-family: var(--mono); }
  .node-city { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .node-ext { min-width: 0; }
  .ping { text-align: right; font-family: var(--mono); font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; }
  .node-row[data-state=up] .ping { color: var(--ok); }
  .node-row[data-state=down] .ping { color: var(--err); }
  .node-row[data-state=relay] .ping { color: var(--relay); }
  .node-cubes { margin: 0; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hb { display: grid; place-items: center; width: 24px; height: 24px; }
  .heart { width: 22px; height: 22px; overflow: visible; }
  .heart path { fill: var(--muted); transform-origin: 12px 13px; transition: fill .3s; }
  .heart .heart-pulse { fill: none; stroke: transparent; stroke-width: 1.5; }
  .hb[data-state=up] .heart path { fill: var(--ok); }
  .hb[data-state=up] .heart .heart-pulse { fill: none; stroke: var(--ok); }
  .hb[data-state=relay] .heart path { fill: var(--relay); }
  .hb[data-state=relay] .heart .heart-pulse { fill: none; stroke: var(--relay); }
  .hb[data-state=down] .heart path { fill: var(--err); }
  .hb[data-state=wait] .heart path { fill: var(--border-2); }

  /* node: SSH setup */
  .ssh-steps { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; }
  .ssh-steps li { display: flex; align-items: center; gap: 8px; }
  .ssh-steps li .mk { width: 18px; display: inline-flex; justify-content: center; flex: none; }
  .ssh-steps li.ok .mk { color: var(--ok); } .ssh-steps li.fail .mk { color: var(--err); }
  .ssh-steps li.fail > span:nth-child(2) { color: var(--err); font-weight: var(--fw-strong); }
  .ssh-steps small { margin-left: 4px; }
  .ssh-log { max-height: 320px; overflow: auto; font-size: var(--fs-xs); white-space: pre-wrap; word-break: break-all; margin: 8px 0 0; }
  .small-list { margin: 0 0 8px; padding-left: 18px; display: grid; gap: 4px; }

  /* API explorer */
  .api-routes td { height: 32px; padding-top: 3px; padding-bottom: 3px; }
  .api-routes td.m { width: 70px; }
  .api-routes td.p { font: var(--fs-code) var(--mono); white-space: normal; word-break: break-all; }
  .api-routes td.a { width: 120px; text-align: right; }
  .api-routes tr.closed td.p { color: var(--muted); }

  /* plugin slots */
  .plugin-slots { display: grid; gap: var(--gap); margin-bottom: var(--gap); }
  .plugin-slots:empty { display: none; }
  .plugin-error { padding: 8px var(--pad); border: 1px dashed var(--err); border-radius: var(--r-sm); color: var(--err); font-size: var(--fs-code); }
  .notice.eula a { font-weight: var(--fw-strong); }
  .notice.eula .btn { flex: none; }

  /* server lock banner */
  .notice.lock { align-items: flex-start; margin-bottom: 0; }
  .notice.lock .lock-text { display: grid; gap: 2px; min-width: 0; }
  .notice.lock .lock-text small { color: var(--muted); }
  .locked-page { display: grid; justify-items: center; gap: 8px; padding: 40px 16px; text-align: center; color: var(--muted); }
  .locked-page h3 { margin: 0; color: var(--text); }

  /* egg editor */
  .egg-body > div[hidden], .egg-body > .card[hidden] { display: none; }
  .img-row { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(0, 2.4fr) auto; gap: var(--gap); align-items: center; margin-bottom: var(--gap); }
  .img-row .row .btn:first-child svg { transform: rotate(-90deg); }
  .var-list { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); margin-bottom: var(--gap); }
  .var-list > .card { margin-bottom: 0; }
  .var-card .card-h code { color: var(--muted); font-size: var(--fs-sm); }
  .egg-save { position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: var(--gap); padding: 10px 0; background: linear-gradient(transparent, var(--bg) 40%); }

  /* full-screen file editor (CodeMirror 6 bundle in /editor/editor.js) */
  .ed-screen { --editor-bar-bg: var(--chrome); --editor-status-bg: #007acc; --editor-status-fg: #fff;
    position: fixed; inset: 0; z-index: 45; display: flex; flex-direction: column; background: var(--editor-bg, var(--term-bg)); color: var(--editor-fg, #d4d4d4); }
  .ed-bar { display: flex; align-items: center; gap: 6px; height: 44px; padding: 0 8px; background: var(--editor-bar-bg); color: var(--text); border-bottom: 1px solid var(--border); flex: none; }
  .ed-path { min-width: 0; flex: 0 1 auto; display: flex; align-items: center; overflow: hidden; white-space: nowrap; font-family: var(--mono); font-size: var(--fs-code); }
  .ed-path .muted { overflow: hidden; text-overflow: ellipsis; direction: rtl; min-width: 0; }
  .ed-path b { flex: none; }
  .ed-dirty { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); margin-left: 8px; flex: none; }
  .ed-bar .ed-lang { --input-h: var(--ctl-s); width: auto; max-width: 170px; flex: none; padding: 0 24px 0 8px; font-size: var(--fs-sm); }
  .ed-bar .ed-ver { max-width: 150px; }
  .ed-host { flex: 1; min-height: 0; }
  .ed-status { display: flex; align-items: center; gap: 14px; height: 24px; padding: 0 10px; background: var(--editor-status-bg); color: var(--editor-status-fg); font-size: var(--fs-sm); flex: none; white-space: nowrap; overflow: hidden; }
  .ed-probs { display: flex; gap: 10px; background: none; border: 0; color: inherit; font: inherit; padding: 0 4px; height: 100%; cursor: pointer; }
  .ed-probs:hover { background: rgba(255, 255, 255, .12); }
  .ed-probs span { display: inline-flex; align-items: center; gap: 3px; opacity: .85; }
  .ed-probs span.err, .ed-probs span.warn { opacity: 1; font-weight: var(--fw-strong); }
  .ed-schema { padding: 0 6px; border-radius: 3px; background: rgba(255, 255, 255, .16); }
  .ed-vimbtn { width: auto; padding: 0 8px; font-size: var(--fs-sm); }
  .ed-vimbtn[aria-pressed=true] { background: color-mix(in srgb, var(--ok) 22%, transparent); color: var(--ok); }
  .ed-vim { padding: 0 6px; border-radius: 3px; background: rgba(0, 0, 0, .25); font-weight: 700; letter-spacing: .05em; }

  /* phones: bottom tab bar, sheets, admin section button (hidden on wide screens) */
  .mtabs, .madmin { display: none; }
  .sheet-back { position: fixed; inset: 0; z-index: 70; background: var(--scrim); display: flex; align-items: flex-end; }
  .sheet { width: 100%; max-height: 85vh; overflow: auto; background: var(--surface); border-radius: 14px 14px 0 0; padding: 0 0 calc(10px + env(safe-area-inset-bottom)); box-shadow: 0 -8px 30px rgba(0, 0, 0, .35); }
  .sheet-h { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; height: 52px; padding: 0 8px 0 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
  .sheet-g { padding: 14px 16px 6px; font-size: var(--fs-sm); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
  .sheet-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; padding: 6px 12px; }
  .sheet-i { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 14px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); background: var(--surface-2); text-decoration: none !important; }
  .sheet-i.active { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }

  /* activity log: where an entry came from, and the client address(es) */
  .badge.src-panel, .badge.src-api { font-weight: var(--fw-strong); }
  .ip-cell { display: inline-flex; align-items: center; gap: 6px; }
  .ip-tag { font-size: var(--fs-xs); color: var(--muted); border: 1px dashed var(--border-2); border-radius: var(--r-sm); padding: 0 4px; cursor: help; }
  .ip-link { color: inherit; text-decoration: underline dotted; text-underline-offset: 3px; }
  .ip-link:hover { color: var(--accent); }
  .code-pre { max-height: 260px; overflow: auto; margin: 6px 0 0; padding: 10px; background: var(--term-bg); color: #d4d4d4; border-radius: var(--r-sm); font: var(--fs-code) var(--mono); }

  /* settings: node security */
  .cve-intro p { margin-top: 0; }
  .cve-state { display: grid; gap: 2px; white-space: normal; }

  /* settings: translations */
  .translations { margin-top: var(--gap); padding-top: var(--gap); border-top: 1px solid var(--border); }
  .translations h4 { margin: 0 0 4px; }

  /* admin overview: the panel's own log */
  .panel-log { margin: 0; height: 320px; overflow: auto; background: var(--console-bg, var(--term-bg)); color: var(--console-fg, #d4d4d4); padding: 10px 12px; border-radius: var(--r-sm); font: var(--fs-code) var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
  .panel-log .pl-t { color: #6e7681; }
  .panel-log-note { font-size: var(--fs-xs); }

  /* backups */
  .backup-name { display: inline-flex; align-items: center; gap: 6px; }
  .backup-name .ico { color: var(--warn); }
  .backup-run { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
  .backup-count { white-space: nowrap; }
  .backup-storage { display: grid; grid-template-columns: auto auto; column-gap: 6px; align-items: baseline; min-width: 180px; font-size: var(--fs-sm); }
  .backup-storage .bs-v { font-weight: var(--fw-strong); white-space: nowrap; }
  .backup-storage .bs-l { color: var(--muted); white-space: nowrap; }
  .backup-storage .bar { grid-column: 1 / -1; margin-top: 4px; }
  .backup-storage.full .bs-v { color: var(--err); }
  .backup-storage.full .bar > i { background: var(--err); }

  /* admin: node containers */
  .ct-name { display: flex; align-items: center; gap: 10px; white-space: normal; min-width: 220px; }
  .ct-name .dot { flex: none; }
  .ct-sub { font: var(--fs-xs) var(--mono); margin-top: 2px; overflow-wrap: anywhere; }
  .ct-name b { overflow-wrap: anywhere; }
  .ct-img { color: var(--text); }
  .ct-ports { font: var(--fs-xs) var(--mono); white-space: nowrap; }
  .ct-act { height: 28px; width: auto; padding: 0 26px 0 8px; font-size: var(--fs-xs); }
  .ct-usage { font-size: var(--fs-xs); white-space: nowrap; }
  .ct-actions { display: flex; flex-wrap: nowrap; justify-content: flex-end; gap: 2px; }
  .ct-logs { height: 60vh; }
  .ct-inspect { max-height: 65vh; }

  /* admin: transfer */
  .transfer-card .card-h h3 { display: inline-flex; align-items: center; gap: 8px; }
  .alloc-picks { display: flex; flex-wrap: wrap; gap: 6px; max-height: 132px; overflow: auto; }
  .check-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border: 1px solid var(--border); border-radius: 999px; font: var(--fs-xs) var(--mono); cursor: pointer; }
  .check-chip:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }

  /* sub-user rights: the "Advanced" section of the share dialog */
  .share-adv { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; }
  .share-adv > summary { cursor: pointer; display: flex; align-items: center; gap: 8px; font-weight: 600; list-style: none; }
  .share-adv > summary::-webkit-details-marker { display: none; }
  .share-adv[open] > summary { margin-bottom: 8px; }
  .share-adv > p { margin: 0 0 8px; font-size: 13px; }
  .perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; margin-top: 10px; }
  .perm-group { border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 10px 8px; margin: 0; min-width: 0; }
  .perm-group > legend { padding: 0 4px; font-weight: 600; font-size: 13px; }
  .perm { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: start; padding: 4px 0; font-size: 13px; cursor: pointer; }
  .perm > input { margin-top: 2px; }
  .perm > code { grid-column: 2; justify-self: start; font-size: 11px; color: var(--muted); background: none; border: 0; padding: 0; }
  .perm-off { opacity: .5; cursor: not-allowed; }

  /* server databases */
  .db-list { display: grid; gap: 12px; }
  .db-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
  .db-head > svg { color: var(--accent, currentColor); flex: none; }
  .db-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px 16px; }
  .db-grid > div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
  .db-grid small { color: var(--muted); font-size: 12px; }
  .db-grid code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .db-grid .secret { cursor: pointer; }
  .db-jdbc { margin-top: 10px; font-size: 13px; }
  .db-jdbc > summary { cursor: pointer; color: var(--muted); }
  .db-jdbc code { display: block; margin-top: 6px; word-break: break-all; }
}

/* ================================================================================= responsive */
@layer arh.responsive {
  @media (max-width: 1100px) {
    .srv .meta { grid-template-columns: 160px minmax(80px, 1fr) 140px; }
    .srv .meta > span:nth-child(3) { display: none; }
  }
  @media (max-width: 1000px) { .node-about { grid-template-columns: minmax(0, 1fr); } }
  /* tablets: buttons, then the console, then the details */
  @media (max-width: 900px) {
    .settings-layout, .settings-layout.wide-left { grid-template-columns: 1fr; }
    .srv { grid-template-columns: 1fr; }
    .srv .meta { grid-template-columns: auto auto 1fr; gap: 12px; }
    .srv .meta > span:nth-child(3) { display: none; }
    .srv-layout { display: flex; flex-direction: column; align-items: stretch; gap: var(--gap); }
    .srv-left, .srv-right { display: contents; }
    .srv-layout .power-col { order: 1; }
    .srv-layout .console { order: 2; margin: 0; }
    .srv-layout .srv-left > .card { order: 3; margin: 0; }
    .srv-layout .grid.two { order: 4; margin: 0; }
    .card-b.details { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); column-gap: 14px; }
    .card-b.details .d-title { grid-column: 1 / -1; }
  }
  /* admin: the side menu becomes one button that opens a sheet */
  @media (max-width: 860px) {
    .layout { grid-template-columns: 1fr; }
    .layout > .side { display: none; }
    .madmin { display: flex; align-items: center; gap: 8px; margin: 0 0 var(--gap); }
    .madmin-sec { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 12px; flex: 1 1 auto; min-width: 0; border: 1px solid var(--border); border-radius: var(--radius);
      background: var(--surface); color: var(--text); font: inherit; font-weight: var(--fw-strong); cursor: pointer; }
    .madmin-sec span { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .madmin-sec svg:last-child { transform: rotate(90deg); color: var(--muted); }
    .madmin-back { display: flex; align-items: center; height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); white-space: nowrap; }
    .crumbs-top { display: none; }
  }
  @media (max-width: 760px) {
    .node-row { grid-template-columns: 28px minmax(0, 1fr) auto; }
    .node-row :is(.node-city, .node-num, .node-ext) { display: none; }
    /* server: tabs move to a bottom bar */
    .subnav .tabs, .subnav .sp { display: none; }
    .subnav-in { padding: 0 12px; }
    .subnav-name { height: 44px; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; }
    .mtabs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
      padding-bottom: env(safe-area-inset-bottom); background: var(--chrome); border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgba(0, 0, 0, .18); }
    .mtab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: 56px; padding: 0 4px; border: 0; background: none;
      color: var(--muted); font: inherit; font-size: 11px; text-decoration: none !important; cursor: pointer; min-width: 0; }
    .mtab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .mtab.active { color: var(--accent); }
    .page.has-mtabs { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
    body:has(.mtabs) #toasts { bottom: calc(66px + env(safe-area-inset-bottom)); }
    /* bookmarks wrap instead of scrolling sideways */
    .tabs-line:not(.apps) { flex-wrap: wrap; overflow: visible; gap: 0 2px; }
    .tabs-line:not(.apps) .tab { --tab-px: 10px; }
    /* tables become cards: one row = one card, each cell labelled */
    .table-wrap { overflow: visible; border: 0; background: none; }
    .table-wrap .table thead { display: none; }
    .table-wrap :is(.table, .table tbody, .table tr, .table td) { display: block; width: 100%; }
    .table-wrap .table tr { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; padding: 4px 12px; background: var(--surface); }
    .table-wrap .table td { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 36px; padding: 4px 0; border: 0; text-align: right; word-break: break-word; }
    .table-wrap .table td + td { border-top: 1px solid var(--border); }
    .table-wrap .table td::before { content: attr(data-label); color: var(--muted); font-size: var(--fs-sm); text-align: left; flex: none; }
    .table-wrap .table td:empty { display: none; }
    /* one column for everything except the two small console graphs */
    .grid.two { grid-template-columns: minmax(0, 1fr); }
    .srv-layout .grid.two { grid-template-columns: 1fr 1fr; }
    .node-cubes .stat { flex-direction: column; align-items: flex-start; gap: 4px; padding: 10px; }
    .page-h { flex-wrap: wrap; gap: 8px; }
    .page-h h1 { flex: 1 1 100%; }
    .card-f.right, .form-f { justify-content: stretch; }
    .card-f.right .btn, .form-f .btn { flex: 1 1 auto; }
  }
  @media (max-width: 700px) {
    .ed-bar .btn span { display: none; }
    .ed-bar .btn { --btn-px: 8px; }
    .ed-status > span:nth-last-child(-n+3) { display: none; }
  }
  @media (max-width: 600px) {
    body { font-size: 14px; }
    .page { padding: 12px 10px calc(40px + env(safe-area-inset-bottom)); }
    .logo-txt { display: none; }
    .logo { margin-right: 4px; }
    .apps .tab span { display: none; }
    .apps .tab { --tab-px: 9px; }
    .hdr .icon-btn { --btn-h: 34px; }
    .lang-sel { font-size: var(--fs-xs); }
    .subnav-in { flex-wrap: wrap; gap: 0; padding: 0 10px; overflow: visible; }
    .subnav-name { flex: 0 0 100%; height: 34px; overflow: hidden; text-overflow: ellipsis; }
    .srv-layout .power-col { flex-wrap: nowrap; }
    .srv-layout .power-col .btn { min-width: 0; --btn-h: 40px; }
    .console { --console-h: 50vh; --console-fs: 12px; }
    .console-out { min-height: 240px; }
    .console-in input { font-size: 16px; }
    .card-b.details { grid-template-columns: 1fr 1fr; }
    .grid.two, .grid, .grid.stats { grid-template-columns: 1fr 1fr; }
    .grid:not(.stats):not(.two) { grid-template-columns: 1fr; }
    .srv .meta { grid-template-columns: 1fr auto; }
    .srv .meta > span:nth-child(2) { display: none; }
    .frow { flex-wrap: wrap; height: auto; padding: 6px 4px 6px 8px; gap: 0 8px; }
    .frow .fn { flex: 1 1 calc(100% - 30px); }
    .frow .fm { order: 3; flex: 1; width: auto; text-align: left; padding-left: 26px; }
    .frow .fd { display: none; }
    .frow .icon-btn { order: 4; --btn-h: 34px; }
    .crumbs { flex-wrap: nowrap; }
    .crumb-path { flex-wrap: nowrap; overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
    .form.cols, .grid-db { grid-template-columns: 1fr; }
    .grid-db .field:nth-child(4) { grid-column: auto; }
    .kvr { flex-wrap: wrap; gap: 0 12px; } .kvv { text-align: left; }
    .table.scopes td.scope-p { display: none; }
    .img-row, .var-list { grid-template-columns: 1fr; }
    .egg-save { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
    .backdrop { place-items: end center; padding: 0; }
    .modal { --modal-w: none; border-radius: var(--radius) var(--radius) 0 0; max-height: 92vh; padding-bottom: env(safe-area-inset-bottom); }
    .modal-f .btn { flex: 1; }
    #toasts { left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); }
    .toast { max-width: none; }
  }
  /* touch: every control at least 40-44 px tall, inputs at 16 px (smaller text makes iOS zoom in) */
  @media (pointer: coarse) {
    html { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
    :is(input, select, textarea, .input, .lang-sel) { font-size: 16px; }
    .btn { min-height: 40px; } .btn.small { min-height: 36px; }
    .icon-btn { min-width: 40px; min-height: 40px; }
    .tabs-line .tab { min-height: 44px; }
    .crumbs a, .crumbs-top a { display: inline-block; padding: 8px 2px; }
    a.fn { display: flex; align-items: center; min-height: 40px; }
    .field.check { min-height: 40px; }
    .field.check input[type=checkbox] { width: 20px; height: 20px; }
    :is(.btn, .icon-btn, .mtab, .sheet-i, .node-row, .srv):active { opacity: .65; }
    .logo { padding: 9px 4px; margin: -9px 0; }
    .table td a { display: inline-block; padding: 9px 0; }
  }
  @media (hover: none) { /* no sticky hover backgrounds after a tap */
    :is(.node-row, .srv, .combo-list li):hover { background: inherit; }
  }
}

/* ===================================================================================== motion
   On unless Admin -> Settings -> Appearance -> Animations is off (html[data-motion=off]) or the
   system asks for reduced motion. Icons move a little when their button is hovered or focused, each
   in its own way; the icon of the active bookmark draws itself once. */
@layer arh.motion {
  @keyframes arh-fade { from { opacity: 0; } }
  @keyframes arh-sheet-up { from { transform: translateY(30px); opacity: .4; } to { transform: none; opacity: 1; } }
  @keyframes arh-spin { to { transform: rotate(360deg); } }
  @keyframes arh-beat { 0%, 100% { transform: scale(1); } 14% { transform: scale(1.18); } 28% { transform: scale(1); } 42% { transform: scale(1.1); } 56% { transform: scale(1); } }
  @keyframes arh-echo { 0% { transform: scale(1); opacity: .7; } 70%, 100% { transform: scale(1.7); opacity: 0; } }
  @keyframes arh-faint { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
  @keyframes arh-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
  @keyframes arh-turn { to { transform: rotate(-360deg); } }
  @keyframes arh-wiggle { 0%, 100% { transform: rotate(0); } 30% { transform: rotate(-9deg); } 60% { transform: rotate(7deg); } }
  @keyframes arh-nudge-r { 50% { transform: translateX(2px); } }
  @keyframes arh-out { 0%, 100% { transform: none; } 45% { transform: translate(2.5px, -2.5px); } 70% { transform: translate(-.5px, .5px); } }
  @keyframes arh-nudge-u { 50% { transform: translateY(-2px); } }
  @keyframes arh-nudge-d { 50% { transform: translateY(2px); } }
  @keyframes arh-pop { 50% { transform: scale(1.18); } }
  @keyframes arh-flicker { 0%, 100% { opacity: 1; } 40% { opacity: .35; } 60% { opacity: 1; } 75% { opacity: .6; } }

  /* the panel's own moving parts (also turned off by the setting: they are decoration too) */
  :root:not([data-motion=off]) {
    .spin, .spinner { animation: arh-spin .8s linear infinite; }
    .backdrop, .sheet-back { animation: arh-fade var(--motion-fast) ease both; }
    .sheet { animation: arh-sheet-up .18s ease-out both; }
    .hb[data-state=up] .heart path:not(.heart-pulse) { animation: arh-beat 1.1s ease-in-out infinite; }
    .hb[data-state=up] .heart .heart-pulse { animation: arh-echo 1.1s ease-out infinite; }
    .hb[data-state=relay] .heart path:not(.heart-pulse) { animation: arh-beat 1.4s ease-in-out infinite; }
    .hb[data-state=relay] .heart .heart-pulse { animation: arh-echo 1.4s ease-out infinite; }
    .hb[data-state=down] .heart path:not(.heart-pulse) { animation: arh-faint 2.4s ease-in-out infinite; }
    .hb[data-state=wait] .heart path { animation: arh-faint 1.2s ease-in-out infinite; }

    /* icons: transforms around their own centre */
    .ico[data-icon=external] > * { transform-box: view-box; }
    .ico { transform-box: fill-box; transform-origin: center; transition: transform var(--motion) var(--ease); }
    :is(button, a, .tab, summary):is(:hover, :focus-visible) > .ico {
      &[data-icon=refresh], &[data-icon=restart] { animation: arh-turn var(--motion-slow) var(--ease); }
      &[data-icon=settings], &[data-icon=sun] { transform: rotate(60deg); }
      &[data-icon=plus], &[data-icon=x] { transform: rotate(90deg); }
      &[data-icon=trash], &[data-icon=edit], &[data-icon=key], &[data-icon=moon] { animation: arh-wiggle var(--motion-slow) var(--ease); }
      &[data-icon=download] { animation: arh-nudge-d var(--motion-slow) var(--ease); }
      &[data-icon=upload], &[data-icon=server], &[data-icon=egg], &[data-icon=folder], &[data-icon=box] { animation: arh-nudge-u var(--motion-slow) var(--ease); }
      &[data-icon=play], &[data-icon=chevron], &[data-icon=logout], &[data-icon=terminal] { animation: arh-nudge-r var(--motion-slow) var(--ease); }
      &[data-icon=stop], &[data-icon=check], &[data-icon=save], &[data-icon=copy], &[data-icon=user], &[data-icon=users], &[data-icon=shield] { animation: arh-pop var(--motion-slow) var(--ease); }
      &[data-icon=bolt], &[data-icon=alert] { animation: arh-flicker .5s linear; }
      &[data-icon=search], &[data-icon=globe], &[data-icon=node] { transform: rotate(-12deg) scale(1.06); }
      &[data-icon=archive] { animation: arh-nudge-d var(--motion-slow) var(--ease); }
      &[data-icon=lock], &[data-icon=unlock] { animation: arh-wiggle var(--motion-slow) var(--ease); }
      &[data-icon=transfer] { animation: arh-nudge-r var(--motion-slow) var(--ease); }
      /* external: the arrow leaves the box and comes back */
      &[data-icon=external] > :nth-child(-n+2) { animation: arh-out var(--motion-slow) var(--ease); }
    }
    /* the active bookmark's icon draws its strokes once */
    .tab.active > .ico > * { stroke-dasharray: 1; animation: arh-draw .6s var(--ease) both; }
    .btn, .tab, .icon-btn, .input, .bar > i { transition: background-color var(--motion-fast), border-color var(--motion-fast), color var(--motion-fast), box-shadow var(--motion-fast); }
  }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  }
}

/* ================================================================================== utilities */
@layer arh.utilities {
  .u-block { display: block; }
  .u-hidden { display: none; }
  .u-w-full { width: 100%; }
  .u-mt-0 { margin-top: 0; } .u-mt-1 { margin-top: 4px; } .u-mt-2 { margin-top: 8px; } .u-mt-3 { margin-top: 12px; } .u-mt-gap { margin-top: var(--gap); }
  .u-mb-0 { margin-bottom: 0; } .u-mb-2 { margin-bottom: 8px; } .u-mb-3 { margin-bottom: 18px; }
  .u-ml-2 { margin-left: 10px; }
  .u-m-0 { margin: 0; } .u-my-2 { margin: 10px 0; }
  .u-muted { color: var(--muted); }
  .u-right { text-align: right; }
  .u-mono { font-family: var(--mono); }
  .u-wrap { overflow-wrap: anywhere; }
  .u-nowrap { white-space: nowrap; }
  .u-max-320 { max-width: 320px; }
  .u-w-90 { width: 90px; }
}

/* ===================================================== third-party: CodeMirror (outside the layers)
   CodeMirror inserts its own styles at run time, outside any layer; these few rules must stay outside
   too to win over them. The editor's colours come from --editor-* variables (see the bundle's theme). */
:is(.ed-host, .code-field) .cm-editor { height: 100%; background-color: var(--editor-bg, var(--term-bg)); color: var(--editor-fg, #d4d4d4); font-size: var(--editor-fs, 13px); }
:is(.ed-host, .code-field) .cm-editor .cm-gutters { background-color: var(--editor-bg, var(--term-bg)); color: var(--editor-gutter-fg, #6e7681); }
:is(.ed-host, .code-field) .cm-editor .cm-activeLine { background-color: var(--editor-active-line, rgba(255, 255, 255, .04)); }
:is(.ed-host, .code-field) .cm-editor :is(.cm-selectionBackground, .cm-content ::selection) { background-color: var(--editor-selection, #264f78) !important; }
.ed-host .cm-editor.cm-focused { outline: none; }
.ed-host .cm-vim-panel { background: #1e1e1e; color: #ccc; font-family: var(--mono); padding: 2px 8px; }
.ed-host .cm-vim-panel input { background: transparent; color: #fff; border: 0; outline: none; font: inherit; }
.ed-host .cm-fat-cursor { background: rgba(174, 175, 173, .6) !important; color: #000 !important; }
@media (pointer: coarse) { .ed-host .cm-panel input { font-size: 16px; } }
@media (max-width: 700px) {
  .ed-host .cm-editor { font-size: 13px; }
  .ed-host .cm-content { font-size: 16px; } /* no zoom-on-focus in iOS Safari */
}
