/* SPDX-License-Identifier: AGPL-3.0-or-later */
/* SuperWebManager — Liquid Glass × Material 3 Expressive.
   Glass for the floating functional layer (Apple); tonal color, expressive shapes
   and spring motion for content and controls (Material 3 Expressive).
   Two layers, as Apple defines them:
     • content layer  — opaque grouped surfaces (cards, lists, tables), never glass
     • functional layer — sidebar, toolbar, tab bar, sheets, menus, alerts: Liquid Glass
   Text/background pairs are checked against WCAG 4.5:1. */

/* ---------- tokens: light ---------- */
:root {
  --window: #f2f2f7;            /* iOS systemGroupedBackground */
  --surface: #ffffff;           /* secondarySystemGroupedBackground */
  --surface2: #f2f2f7;
  --surface3: #e5e5ea;
  --fill: rgba(118, 118, 128, 0.12);   /* iOS tertiary fill: inputs, secondary buttons */
  --fill-strong: rgba(118, 118, 128, 0.2);
  --separator: rgba(60, 60, 67, 0.13);
  --separator-strong: rgba(60, 60, 67, 0.22);
  --label: #000000;
  --label2: #6c6c70;            /* 5.2:1 on white */
  --label3: #8e8e93;            /* placeholders / decoration only */
  --accent: #0066cc;            /* text & links, 5.57:1 */
  --accent-fill: #0071e3;       /* filled buttons, white text 4.70:1 */
  --accent-fill-hover: #0077ed;
  --accent-soft: rgba(0, 113, 227, 0.12);
  --green: #1b7f37; --red: #c9252d; --orange: #b25000; --teal: #00739a;
  --green-soft: rgba(52, 199, 89, 0.11); --red-soft: rgba(255, 59, 48, 0.12); --orange-soft: rgba(255, 149, 0, 0.16); --teal-soft: rgba(48, 176, 199, 0.16);
  --focus: rgba(0, 113, 227, 0.5);

  /* Liquid Glass (regular variant) */
  --glass: rgba(255, 255, 255, 0.58);
  --glass-strong: rgba(250, 250, 252, 0.74);  /* large elements (sidebar) are more opaque */
  --glass-edge: rgba(255, 255, 255, 0.75);
  --glass-rim: rgba(0, 0, 0, 0.07);
  --glass-shadow: 0 10px 34px rgba(0, 0, 0, 0.10), 0 1px 3px rgba(0, 0, 0, 0.06);
  --glass-blur: blur(26px) saturate(1.7);
  --shine: linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 42%);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 30px 80px rgba(0, 0, 0, 0.22);
  --code-bg: #1c1c1e; --code-fg: #e5e5ea;
  --ambient-1: rgba(0, 122, 255, 0.20); --ambient-2: rgba(175, 82, 222, 0.16); --ambient-3: rgba(52, 199, 89, 0.10);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI Variable", "Segoe UI", system-ui, Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --r-xl: 26px;   /* sidebar, sheets */
  --r-lg: 22px;   /* cards, lists */
  --r-md: 14px;   /* inner platters, menus */
  --r-sm: 10px;   /* inputs */
  --spring: cubic-bezier(0.32, 0.72, 0, 1);
  --sidebar-w: 290px;
  color-scheme: light;
}

/* ---------- tokens: dark ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --window: #000000; --surface: #1c1c1e; --surface2: #2c2c2e; --surface3: #3a3a3c;
    --fill: rgba(118, 118, 128, 0.24); --fill-strong: rgba(118, 118, 128, 0.36);
    --separator: rgba(84, 84, 88, 0.55); --separator-strong: rgba(84, 84, 88, 0.8);
    --label: #ffffff; --label2: #a1a1a6; --label3: #6e6e73;
    --accent: #409cff; --accent-soft: rgba(10, 132, 255, 0.2);
    --green: #32d74b; --red: #ff6961; --orange: #ffb340; --teal: #5ac8f5;
    --green-soft: rgba(48, 209, 88, 0.18); --red-soft: rgba(255, 69, 58, 0.18); --orange-soft: rgba(255, 159, 10, 0.18); --teal-soft: rgba(100, 210, 255, 0.16);
    --focus: rgba(64, 156, 255, 0.6);
    --glass: rgba(36, 36, 40, 0.52); --glass-strong: rgba(28, 28, 31, 0.7);
    --glass-edge: rgba(255, 255, 255, 0.16); --glass-rim: rgba(255, 255, 255, 0.06);
    --glass-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.4);
    --shine: linear-gradient(180deg, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0) 45%);
    --shadow-sm: none; --shadow-lg: 0 30px 90px rgba(0, 0, 0, 0.7);
    --code-bg: #0c0c0e;
    --ambient-1: rgba(10, 132, 255, 0.26); --ambient-2: rgba(191, 90, 242, 0.20); --ambient-3: rgba(48, 209, 88, 0.10);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --window: #000000; --surface: #1c1c1e; --surface2: #2c2c2e; --surface3: #3a3a3c;
  --fill: rgba(118, 118, 128, 0.24); --fill-strong: rgba(118, 118, 128, 0.36);
  --separator: rgba(84, 84, 88, 0.55); --separator-strong: rgba(84, 84, 88, 0.8);
  --label: #ffffff; --label2: #a1a1a6; --label3: #6e6e73;
  --accent: #409cff; --accent-soft: rgba(10, 132, 255, 0.2);
  --green: #32d74b; --red: #ff6961; --orange: #ffb340; --teal: #5ac8f5;
  --green-soft: rgba(48, 209, 88, 0.18); --red-soft: rgba(255, 69, 58, 0.18); --orange-soft: rgba(255, 159, 10, 0.18); --teal-soft: rgba(100, 210, 255, 0.16);
  --focus: rgba(64, 156, 255, 0.6);
  --glass: rgba(36, 36, 40, 0.52); --glass-strong: rgba(28, 28, 31, 0.7);
  --glass-edge: rgba(255, 255, 255, 0.16); --glass-rim: rgba(255, 255, 255, 0.06);
  --glass-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.4);
  --shine: linear-gradient(180deg, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0) 45%);
  --shadow-sm: none; --shadow-lg: 0 30px 90px rgba(0, 0, 0, 0.7);
  --code-bg: #0c0c0e;
  --ambient-1: rgba(10, 132, 255, 0.26); --ambient-2: rgba(191, 90, 242, 0.20); --ambient-3: rgba(48, 209, 88, 0.10);
  color-scheme: dark;
}


/* ---------- M3 Expressive tokens ---------- */
:root {
  --primary-container: #d8e4ff; --on-primary-container: #0a2f6b;
  --tertiary: #7b3fb3; --tertiary-container: #f0dcff; --on-tertiary-container: #3a0b63;
  --tonal: #e4ecfd; --tonal-hover: #d6e2fb; --on-tonal: #0b4aa2;
  --container-low: #f7f8fc; --container-high: #eceef5;
  --outline: #74777f;
  --specular: rgba(255, 255, 255, 0.6);
  --heat-hot: #e8710a; --heat-crit: #d93025;
  --spring-bounce: cubic-bezier(0.34, 1.45, 0.5, 1);   /* M3 Expressive "fast spatial": a little overshoot */
  --spring-soft: cubic-bezier(0.2, 1.1, 0.3, 1);
  --r-lg: 26px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary-container: #173a74; --on-primary-container: #d8e4ff;
    --tertiary: #d7a8ff; --tertiary-container: #4a2470; --on-tertiary-container: #f0dcff;
    --tonal: rgba(64, 156, 255, 0.17); --tonal-hover: rgba(64, 156, 255, 0.26); --on-tonal: #b9d6ff;
    --container-low: #151518; --container-high: #26262b; --outline: #8e9099;
    --specular: rgba(255, 255, 255, 0.16); --heat-hot: #ffae4d; --heat-crit: #ff6b61;
  }
}
:root[data-theme="dark"] {
  --primary-container: #173a74; --on-primary-container: #d8e4ff;
  --tertiary: #d7a8ff; --tertiary-container: #4a2470; --on-tertiary-container: #f0dcff;
  --tonal: rgba(64, 156, 255, 0.17); --tonal-hover: rgba(64, 156, 255, 0.26); --on-tonal: #b9d6ff;
  --container-low: #151518; --container-high: #26262b; --outline: #8e9099;
  --specular: rgba(255, 255, 255, 0.16); --heat-hot: #ffae4d; --heat-crit: #ff6b61;
}

/* aliases used by page scripts and canvas drawing */
:root { --bg: var(--window); --bg2: var(--surface); --panel: var(--surface); --panel2: var(--surface2); --border: var(--separator-strong);
  --text: var(--label); --muted: var(--label2); --ok: var(--green); --bad: var(--red); --warn: var(--orange); --info: var(--teal); }

/* ---------- the glass recipe (functional layer only) ---------- */
.glass {
  background: radial-gradient(260px circle at var(--mx, -999px) var(--my, -999px), var(--specular), transparent 62%), var(--shine), var(--glass);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  box-shadow: inset 0 0.5px 0 var(--glass-edge), inset 0 0 0 0.5px var(--glass-rim), var(--glass-shadow);
}

/* ---------- base ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { background: var(--window); color: var(--label); font: 15px/1.42 var(--font); -webkit-font-smoothing: antialiased; letter-spacing: -0.005em; }
/* content-layer ambience: soft color the glass can refract */
body::before { content: ""; position: fixed; inset: -10%; z-index: -1; pointer-events: none;
  background: radial-gradient(40% 35% at 12% 8%, var(--ambient-1), transparent 70%),
              radial-gradient(35% 30% at 88% 4%, var(--ambient-2), transparent 70%),
              radial-gradient(40% 40% at 70% 100%, var(--ambient-3), transparent 70%); }
/* custom wallpaper (Panel Settings → Appearance) replaces the ambience; the window color laid over it keeps text legible */
html.has-wallpaper body::before { display: none; }
html.has-wallpaper body::after { content: ""; position: fixed; z-index: -1; pointer-events: none; inset: calc(var(--wallpaper-blur, 0px) * -2);
  background: linear-gradient(color-mix(in srgb, var(--window) var(--wallpaper-dim, 35%), transparent), color-mix(in srgb, var(--window) var(--wallpaper-dim, 35%), transparent)),
              var(--wallpaper) center / cover no-repeat;
  filter: blur(var(--wallpaper-blur, 0px)); }
.wallpaper-thumb { width: 120px; aspect-ratio: 16 / 10; flex: none; border-radius: var(--r-md, 12px); background: var(--fill) center / cover no-repeat; box-shadow: inset 0 0 0 1px var(--separator); display: grid; place-items: center; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a[role=button] { cursor: pointer; }
code, pre, .mono { font-family: var(--mono); font-size: 13px; }
h1 { font-size: 22px; line-height: 1.2; margin: 0; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 17px; margin: 0 0 12px; font-weight: 600; letter-spacing: -0.02em; }
h3 { font-size: 13px; margin: 0 0 8px; font-weight: 600; color: var(--label2); text-transform: none; }
svg.i { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
::selection { background: var(--accent-soft); }
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 10px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; }

/* ---------- layout: floating sidebar + floating toolbar ---------- */
.app { display: grid; grid-template-columns: calc(var(--sidebar-w) + 12px) 1fr; height: 100vh; transition: grid-template-columns .45s var(--spring); }
.app.sidebar-hidden { grid-template-columns: 0 1fr; }
.app.sidebar-hidden .sidebar { opacity: 0; transform: translateX(-24px); pointer-events: none; }
.sidebar { margin: 10px 0 10px 12px; border-radius: var(--r-xl); display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden; min-width: 0;
  background: radial-gradient(260px circle at var(--mx, -999px) var(--my, -999px), var(--specular), transparent 62%), var(--shine), var(--glass-strong); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  box-shadow: inset 0 0.5px 0 var(--glass-edge), inset 0 0 0 0.5px var(--glass-rim), var(--glass-shadow);
  transition: opacity .3s, transform .45s var(--spring); scrollbar-width: none; }
.sidebar::-webkit-scrollbar { display: none; }
.main { overflow-y: auto; display: flex; flex-direction: column; min-width: 0; position: relative; }

/* signature: the machine platter (vibrant fill, not glass — no glass on glass) */
.machine { display: block; margin: 12px 12px 4px; padding: 13px 14px 11px; border-radius: 18px; background: var(--fill); color: inherit; }
.machine:hover { text-decoration: none; background: var(--fill-strong); }
.machine .host { display: flex; align-items: center; gap: 8px; font: 600 14px/1.2 var(--font); letter-spacing: -0.01em; overflow: hidden; }
.machine .host span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.machine .os { color: var(--label2); font-size: 12px; margin: 3px 0 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.machine .pulse { display: grid; grid-template-columns: auto 1fr auto; gap: 5px 9px; align-items: center; font-size: 11.5px; color: var(--label2); font-weight: 500; }
.machine .pulse canvas { width: 100%; height: 20px; display: block; }
.machine .pulse b { font-variant-numeric: tabular-nums; color: var(--label); font-weight: 600; min-width: 34px; text-align: right; }
.machine .up { margin-top: 9px; font-size: 11.5px; color: var(--label2); font-variant-numeric: tabular-nums; }
.heartbeat { width: 9px; height: 9px; border-radius: 50%; background: #34c759; box-shadow: 0 0 0 3px rgba(52, 199, 89, .22), 0 0 10px rgba(52, 199, 89, .6); flex: none; animation: beat 2.2s ease-in-out infinite; }
.heartbeat.lost { background: #ff3b30; box-shadow: 0 0 0 3px rgba(255, 59, 48, .22); animation: none; }
@keyframes beat { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(.82); opacity: .6; } }

.nav { padding: 2px 10px 10px; flex: 1; }
.nav .sec { display: flex; align-items: center; width: 100%; gap: 5px; background: none; border: 0; font: 600 13px var(--font); color: var(--label2);
  padding: 14px 10px 5px; cursor: pointer; border-radius: 8px; text-align: left; letter-spacing: -0.01em; }
.nav .sec:hover { color: var(--label); }
.nav .sec svg.i { width: 12px; height: 12px; stroke-width: 2.6; transition: transform .3s var(--spring); order: 2; margin-left: auto; opacity: .7; }
.nav .sec[aria-expanded="false"] svg.i { transform: rotate(-90deg); }
.nav .group[hidden] { display: none; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 7px 10px; border-radius: 12px; color: var(--label); margin: 1px 0; font-size: 15px; min-height: 36px;
  transition: background .15s; }
.nav a:hover { background: var(--fill); text-decoration: none; }
.nav a svg.i { color: var(--accent); width: 19px; height: 19px; }
.nav a.active { background: var(--accent-fill); color: #fff; font-weight: 600; box-shadow: 0 4px 14px rgba(0, 113, 227, .3); }
.nav a.active svg.i { color: #fff; }
.side-foot { margin: 0 10px 10px; padding: 8px 8px 8px 12px; border-radius: 16px; background: var(--fill); display: flex; gap: 6px; align-items: center; color: var(--label2); font-size: 13px; }
.side-foot .grow { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--label); font-weight: 500; }

/* toolbar: transparent strip; controls float in glass capsules */
.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 22px 10px 18px; min-height: 64px; position: sticky; top: 0; z-index: 5; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.topbar .grow { flex: 1; }
/* scroll-edge effect: content blurs and fades where it meets the controls */
.topbar::before { content: ""; position: absolute; inset: 0 0 -18px 0; z-index: -1; pointer-events: none;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  -webkit-mask-image: linear-gradient(to bottom, #000 45%, transparent); mask-image: linear-gradient(to bottom, #000 45%, transparent);
  background: linear-gradient(to bottom, color-mix(in srgb, var(--window) 55%, transparent), transparent); opacity: 0; transition: opacity .25s; }
.main.scrolled .topbar::before { opacity: 1; }
/* once content scrolls under it, the toolbar becomes a glass bar so the title never collides with content */
.main.scrolled .topbar::before { inset: 0; -webkit-mask-image: none; mask-image: none;
  background: radial-gradient(260px circle at var(--mx, -999px) var(--my, -999px), var(--specular), transparent 62%), var(--shine), var(--glass-strong); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  box-shadow: inset 0 -0.5px 0 var(--separator); }
.topbar .compact-title { font: 600 17px var(--font); letter-spacing: -0.02em; opacity: 0; transform: translateY(6px); transition: opacity .25s, transform .35s var(--spring);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.main.scrolled .topbar .compact-title { opacity: 1; transform: none; }
.pill { display: inline-flex; align-items: center; gap: 2px; padding: 4px; border-radius: 999px; }
.pill .btn { background: transparent; box-shadow: none; }
.pill .btn:hover { background: var(--fill); }
.pill .btn.primary { background: var(--accent-fill); }
.pill:empty { display: none; }
#page-actions { flex-wrap: nowrap; }
.circle { width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; border: 0; color: var(--label); cursor: pointer; padding: 0; }
.circle:hover { filter: brightness(1.05); }
.circle:active { transform: scale(.94); }

.large-title { font: 700 34px/1.12 var(--font); letter-spacing: -0.025em; margin: 2px 0 18px; }
.content { padding: 0 24px 56px; flex: 1; min-width: 0; max-width: 1680px; width: 100%; }

/* ---------- content layer ---------- */
.card { background: var(--surface); border-radius: var(--r-lg); padding: 20px 22px; min-width: 0; box-shadow: var(--shadow-sm); }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.nowrap { flex-wrap: nowrap; }
.grow { flex: 1; }
.mt { margin-top: 18px; }
.mb { margin-bottom: 16px; }
.muted { color: var(--label2); }
.small { font-size: 13px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* buttons: capsules */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; background: var(--fill); color: var(--accent);
  padding: 7px 16px; min-height: 34px; border-radius: 999px; cursor: pointer; font: 600 14px var(--font); white-space: nowrap; letter-spacing: -0.01em;
  transition: background .15s, transform .2s var(--spring), filter .15s; }
.btn:hover { background: var(--fill-strong); text-decoration: none; }
.btn:active { transform: scale(0.95); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent-fill); color: #fff; box-shadow: 0 4px 14px rgba(0, 113, 227, .28); }
.btn.primary:hover { background: var(--accent-fill-hover); }
.btn.danger { color: var(--red); }
.btn.danger.solid { background: #c9252d; color: #fff; }
.btn.sm { padding: 4px 12px; min-height: 28px; font-size: 13px; }
.btn.ghost { background: transparent; color: var(--label2); }
.btn.ghost:hover { background: var(--fill); color: var(--label); }
.btn.icon-only { padding: 0; width: 34px; min-width: 34px; }
.btn.sm.icon-only { width: 28px; min-width: 28px; }
.btn svg.i { width: 16px; height: 16px; }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* inputs: filled, no borders */
input, select, textarea { font: 15px var(--font); color: var(--label); background: var(--fill); border: 0; border-radius: var(--r-sm); padding: 8px 12px; min-height: 36px;
  min-width: 0; transition: box-shadow .15s, background .15s; }
input::placeholder, textarea::placeholder { color: var(--label3); }
input:focus, select:focus, textarea:focus { background: var(--surface); box-shadow: 0 0 0 2px var(--accent-fill), 0 0 0 5px var(--accent-soft); }
select { cursor: pointer; appearance: none; -webkit-appearance: none; padding-right: 30px;
  background: var(--fill) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 10l4-4 4 4M8 14l4 4 4-4'/%3E%3C/svg%3E") no-repeat right 9px center / 14px; }
input[type=checkbox] { width: 20px; height: 20px; min-height: 0; padding: 0; accent-color: var(--accent-fill); margin: 0; background: none; box-shadow: none; }
input[type=range] { background: none; padding: 0; accent-color: var(--accent-fill); }
textarea { font-family: var(--mono); font-size: 13.5px; width: 100%; resize: vertical; tab-size: 4; line-height: 1.5; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--label2); margin-bottom: 16px; }
label.field input, label.field select, label.field textarea { color: var(--label); font-weight: 400; }
label.field > span.small { font-weight: 400; }

/* iOS switch for option toggles (label.check); table selection keeps checkboxes */
label.check { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; cursor: pointer; font-size: 15px; }
label.check input[type=checkbox] { appearance: none; -webkit-appearance: none; width: 44px; height: 26px; border-radius: 999px; background: var(--fill-strong);
  position: relative; cursor: pointer; flex: none; transition: background .25s; }
label.check input[type=checkbox]::after { content: ""; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .25), 0 0 0 0.5px rgba(0, 0, 0, .04); transition: transform .35s var(--spring), width .2s; }
label.check input[type=checkbox]:checked { background: #34c759; }
label.check input[type=checkbox]:checked::after { transform: translateX(18px); }
label.check input[type=checkbox]:active::after { width: 27px; }
label.check input[type=checkbox]:checked:active::after { transform: translateX(13px); }

.search { min-width: 260px; padding-left: 34px; border-radius: 999px;
  background: var(--fill) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 12px center / 16px; }

/* status capsules: color + shape */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600; line-height: 17px;
  background: var(--fill); color: var(--label2); white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid currentColor; box-sizing: border-box; flex: none; }
.badge.ok { color: var(--green); background: var(--green-soft); }
.badge.ok::before { background: currentColor; }
.badge.bad { color: var(--red); background: var(--red-soft); }
.badge.bad::before { border: 0; width: 8px; height: 8px; border-radius: 0; background: currentColor; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.badge.warn { color: var(--orange); background: var(--orange-soft); }
.badge.warn::before { border: 0; border-radius: 1px; width: 7px; height: 7px; background: currentColor; transform: rotate(45deg); }
.badge.info { color: var(--teal); background: var(--teal-soft); }
.badge.info::before { background: currentColor; opacity: .55; }
.badge.plain::before { display: none; }
.badge .spinner { width: 10px; height: 10px; border-width: 1.5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--label3); }
.dot.ok { background: var(--green); } .dot.bad { background: var(--red); } .dot.warn { background: var(--orange); }

/* segmented control: capsule track + floating thumb */
.tabs { display: inline-flex; gap: 2px; padding: 3px; margin-bottom: 20px; background: var(--fill); border-radius: 999px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { background: none; border: 0; color: var(--label); padding: 6px 16px; cursor: pointer; font: 500 14px var(--font); border-radius: 999px; white-space: nowrap;
  min-height: 30px; transition: background .25s var(--spring), box-shadow .25s; letter-spacing: -0.01em; }
.tabs button:hover:not(.active) { background: var(--fill); }
.tabs button.active { background: var(--surface); box-shadow: 0 3px 10px rgba(0, 0, 0, .12), 0 0 0 0.5px rgba(0, 0, 0, .04); font-weight: 600; }

/* lists & tables: inset grouped */
.table-wrap { overflow: auto; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th, td { text-align: left; padding: 10px 14px; vertical-align: middle; }
td { border-top: 0.5px solid var(--separator); }
tbody tr:first-child td { border-top: 0; }
th { font-size: 12.5px; color: var(--label2); font-weight: 600; background: var(--surface); position: sticky; top: 0; z-index: 1; user-select: none; white-space: nowrap;
  box-shadow: inset 0 -0.5px 0 var(--separator-strong); padding-top: 12px; }
th.sortable { cursor: pointer; }
th.sortable:hover { color: var(--label); }
th .sort { color: var(--accent); margin-left: 4px; font-size: 10px; }
th.mono, th.small { font-family: var(--font); font-size: 12.5px; }
tbody tr { transition: background .12s; }
tbody tr:hover td { background: var(--fill); }
tr.selected td { background: var(--accent-soft) !important; }
td.actions { text-align: right; white-space: nowrap; width: 1%; }
td.actions .btn-group { flex-wrap: nowrap; }
.table-foot { padding: 10px 14px; color: var(--label2); font-size: 12.5px; display: flex; gap: 10px; align-items: center; border-top: 0.5px solid var(--separator); }
.empty { text-align: center; color: var(--label2); padding: 48px 10px; }

pre.out { background: var(--code-bg); color: var(--code-fg); border-radius: var(--r-md); padding: 14px 16px; margin: 0; overflow: auto; max-height: 60vh;
  white-space: pre-wrap; word-break: break-all; line-height: 1.5; }

/* stats */
.stat { display: flex; flex-direction: column; gap: 6px; }
.stat .label { color: var(--label2); font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.stat .label svg.i { width: 16px; height: 16px; color: var(--accent); }
.stat .value { font: 700 32px/1.1 var(--font); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--label2); font-size: 13px; }
.bar { height: 6px; background: var(--fill); border-radius: 99px; overflow: hidden; }
.bar > div { height: 100%; background: var(--accent-fill); border-radius: 99px; transition: width .6s var(--spring); }
.bar.warn > div { background: #ff9500; } .bar.bad > div { background: #ff3b30; }
canvas.chart { width: 100%; height: 124px; display: block; }
.chart-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.chart-head h2 { margin: 0; }
.chart-sum { color: var(--label2); font-size: 13px; font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 22px; font-size: 14.5px; }
.kv > div:nth-child(odd) { color: var(--label2); }
.kv > div { min-width: 0; overflow-wrap: anywhere; }
.cores { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 9px; }
.cores .c { font-size: 12px; color: var(--label2); font-variant-numeric: tabular-nums; margin-bottom: 3px; }

/* ---------- functional layer: sheets, alerts, menus, toasts ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .22); display: flex; align-items: flex-start; justify-content: center; z-index: 50;
  padding: 7vh 16px; overflow-y: auto; animation: fade .25s ease-out; }
.modal { border-radius: var(--r-xl); width: 560px; max-width: 100%; display: flex; flex-direction: column;
  background: radial-gradient(260px circle at var(--mx, -999px) var(--my, -999px), var(--specular), transparent 62%), var(--shine), var(--glass-strong); -webkit-backdrop-filter: blur(40px) saturate(1.8); backdrop-filter: blur(40px) saturate(1.8);
  box-shadow: inset 0 0.5px 0 var(--glass-edge), inset 0 0 0 0.5px var(--glass-rim), var(--shadow-lg);
  animation: sheet .5s var(--spring); }
.modal.wide { width: 1000px; }
.modal.full { width: 1340px; }
.modal.alert { width: 300px; text-align: center; border-radius: 28px; animation: alertIn .4s var(--spring); }
.modal.alert .modal-head { justify-content: center; padding: 22px 20px 4px; }
.modal.alert .modal-head h2 { flex: none; font-size: 17px; }
.modal.alert .modal-head .btn { display: none; }
.modal.alert .modal-body { padding: 0 20px 18px; }
.modal.alert .modal-foot { border: 0; padding: 0 14px 14px; gap: 8px; }
.modal.alert .modal-foot .btn { flex: 1; min-width: 0; min-height: 44px; font-size: 16px; }
.modal-head { display: flex; align-items: center; padding: 18px 22px 12px; gap: 10px; }
.modal-head h2 { margin: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; font-size: 19px; font-weight: 700; }
.modal-head .btn.icon-only { background: var(--fill); color: var(--label2); border-radius: 50%; }
.modal-body { padding: 4px 22px 18px; min-width: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px 20px; }
.modal-foot .btn { min-width: 96px; min-height: 40px; font-size: 15px; }
.modal .card, .modal .table-wrap { background: var(--surface); }
@keyframes fade { from { opacity: 0; } }
@keyframes sheet { from { opacity: 0; transform: translateY(40px) scale(.97); } }
@keyframes alertIn { from { opacity: 0; transform: scale(1.12); } }

.menu { position: fixed; z-index: 90; min-width: 210px; max-width: 320px; padding: 6px; border-radius: 18px;
  background: radial-gradient(260px circle at var(--mx, -999px) var(--my, -999px), var(--specular), transparent 62%), var(--shine), var(--glass-strong); -webkit-backdrop-filter: blur(34px) saturate(1.8); backdrop-filter: blur(34px) saturate(1.8);
  box-shadow: inset 0 0.5px 0 var(--glass-edge), inset 0 0 0 0.5px var(--glass-rim), var(--shadow-lg);
  animation: pop .35s var(--spring); transform-origin: top right; }
.menu button { display: flex; width: 100%; align-items: center; gap: 8px; text-align: left; background: none; border: 0; padding: 9px 12px; border-radius: 12px;
  color: var(--label); font: 15px var(--font); cursor: pointer; min-height: 38px; }
.menu button:hover, .menu button:focus-visible { background: var(--fill-strong); outline: none; }
.menu button.danger { color: var(--red); }
.menu hr { border: 0; border-top: 0.5px solid var(--separator-strong); margin: 5px 10px; }
@keyframes pop { from { opacity: 0; transform: scale(.85); } }

#toasts { position: fixed; left: 50%; top: 14px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 100;
  max-width: min(460px, calc(100vw - 32px)); pointer-events: none; }
.toast { padding: 11px 18px 11px 44px; border-radius: 999px; animation: drop .5s var(--spring); white-space: pre-wrap; overflow-wrap: anywhere; position: relative;
  font-size: 14.5px; font-weight: 500; pointer-events: auto;
  background: radial-gradient(260px circle at var(--mx, -999px) var(--my, -999px), var(--specular), transparent 62%), var(--shine), var(--glass-strong); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  box-shadow: inset 0 0.5px 0 var(--glass-edge), inset 0 0 0 0.5px var(--glass-rim), var(--glass-shadow); }
.toast::before { content: "i"; position: absolute; left: 13px; top: 50%; margin-top: -11px; width: 22px; height: 22px; border-radius: 50%; background: var(--accent-fill); color: #fff;
  font: 700 13px/22px var(--font); text-align: center; }
.toast.ok::before { content: "✓"; background: #248a3d; }
.toast.bad::before { content: "!"; background: #d70015; }
.toast.bad { border-radius: 20px; }
@keyframes drop { from { opacity: 0; transform: translateY(-24px) scale(.9); } }

/* command palette (Spotlight-style) */
.palette { width: 600px; }
.palette .modal-head { display: none; }
.palette .modal-body { padding: 14px; }
.palette input { width: 100%; font-size: 20px; min-height: 48px; border-radius: 14px; background: var(--fill); }
.palette .results { margin-top: 8px; max-height: 50vh; overflow: auto; }
.palette .results a { display: flex; gap: 12px; align-items: center; padding: 9px 12px; border-radius: 12px; color: var(--label); font-size: 15px; }
.palette .results a svg.i { color: var(--accent); }
.palette .results a.sel { background: var(--accent-fill); color: #fff; text-decoration: none; }
.palette .results a.sel svg.i { color: #fff; }
.kbd { font: 11px var(--mono); padding: 2px 6px; border-radius: 6px; background: var(--fill); color: var(--label2); }

/* floating tab bar (phones) */
.tabbar { display: none; }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login { width: 380px; max-width: 100%; padding: 32px 28px 26px; border-radius: 30px;
  background: radial-gradient(260px circle at var(--mx, -999px) var(--my, -999px), var(--specular), transparent 62%), var(--shine), var(--glass-strong) !important; -webkit-backdrop-filter: blur(40px) saturate(1.8); backdrop-filter: blur(40px) saturate(1.8);
  box-shadow: inset 0 0.5px 0 var(--glass-edge), inset 0 0 0 0.5px var(--glass-rim), var(--shadow-lg) !important; }
.login .mark { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 24px; text-align: center; }
.login .mark img { width: 68px; height: 68px; border-radius: 17px; box-shadow: 0 10px 28px rgba(0, 113, 227, .35); }
.login .mark h1 { font-size: 24px; }
.login .mark div { color: var(--label2); font: 13px var(--mono); }
.login .btn.primary { width: 100%; min-height: 46px; font-size: 16px; margin-top: 4px; }
.err { color: var(--red); font-size: 13.5px; margin-bottom: 10px; min-height: 18px; }

/* files */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; font-size: 14px; font-weight: 500; }
.crumbs a { padding: 3px 8px; border-radius: 999px; color: var(--label); }
.crumbs a:hover { background: var(--fill); text-decoration: none; }
.fname { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; border-radius: 6px; }
.fname svg.i { color: var(--label2); }
.fname.dir svg.i { color: var(--accent); fill: var(--accent-soft); }
.fname:hover span:first-of-type { text-decoration: underline; }
.dropzone { outline: 2px dashed var(--accent); outline-offset: -6px; border-radius: var(--r-lg); }
.editor { height: 62vh; min-height: 300px; }

/* terminal */
.term-host { background: #0c0c0e; border-radius: var(--r-lg); padding: 12px; height: calc(100vh - 230px); min-height: 300px; }
.term-host .xterm { height: 100%; }

.spinner { width: 20px; height: 20px; border: 2.5px solid var(--fill-strong); border-top-color: var(--accent-fill); border-radius: 50%; animation: spin .8s linear infinite;
  display: inline-block; vertical-align: middle; flex: none; }
.loading { display: flex; gap: 10px; align-items: center; color: var(--label2); padding: 40px; justify-content: center; }
@keyframes spin { to { transform: rotate(360deg); } }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.menu-btn { display: none !important; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 800px) {
  body { font-size: 16px; }
  .app, .app.sidebar-hidden { grid-template-columns: 1fr; }
  /* the sidebar becomes a sheet opened from the tab bar's "All" button */
  .sidebar { position: fixed; inset: auto 8px 8px 8px; top: 8vh; margin: 0; width: auto; z-index: 60; transform: translateY(110%); opacity: 1 !important;
    pointer-events: auto !important; transition: transform .5s var(--spring); }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open .main::after { content: ""; position: fixed; inset: 0; background: rgba(0, 0, 0, .3); z-index: 55; animation: fade .3s; }
  .sidebar-toggle { display: none !important; }
  .g2 { grid-template-columns: minmax(0, 1fr); }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .g4 .stat .value { font-size: 24px; }
  .g4 .card { padding: 16px; }
  .content { padding: 0 16px 120px; }
  .topbar { padding: 8px 12px; min-height: 56px; }
  .large-title { font-size: 32px; }
  .search { min-width: 0; width: 100%; }
  .hide-sm { display: none !important; }
  .nav a { min-height: 44px; font-size: 17px; }
  .btn { min-height: 38px; }
  .btn.sm { min-height: 32px; }
  /* sheets rise from the bottom with a grabber */
  .modal-bg { padding: 0; align-items: flex-end; }
  .modal, .modal.wide, .modal.full { width: 100%; border-radius: 28px 28px 0 0; max-height: 94vh; overflow: auto; }
  .modal:not(.alert)::before { content: ""; display: block; width: 38px; height: 5px; border-radius: 3px; background: var(--fill-strong); margin: 8px auto 0; flex: none; }
  .modal-bg:has(.alert) { align-items: center; }
  .modal.alert { border-radius: 28px; width: 290px; }
  #toasts { top: auto; bottom: 96px; }
  /* floating glass tab bar */
  .tabbar { display: flex; position: fixed; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 45;
    padding: 5px; gap: 2px; border-radius: 999px; width: min(440px, calc(100vw - 24px)); justify-content: space-between; }
  .tabbar a, .tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px 5px; min-height: 52px;
    border-radius: 999px; color: var(--label); font: 600 10.5px var(--font); background: none; border: 0; cursor: pointer; text-decoration: none; }
  .tabbar svg.i { width: 23px; height: 23px; }
  .tabbar .on { color: var(--accent); background: var(--fill); }
}


/* =====================================================================
   M3 Expressive layer
   ===================================================================== */

/* living ambience behind the glass */
body::before { animation: drift 38s ease-in-out infinite alternate; }
@keyframes drift { 0% { transform: translate3d(0, 0, 0) scale(1); } 50% { transform: translate3d(2%, -2%, 0) scale(1.06); } 100% { transform: translate3d(-2%, 1.5%, 0) scale(1.02); } }

/* ripple state layer (motion.js) */
.btn, .nav a, .tabs button, .tabbar a, .tabbar button, .menu button, .circle, a.card, .machine, .palette .results a { position: relative; overflow: hidden; isolation: isolate; }
.machine { flex: none; } /* clipping for the ripple must not let the sidebar squash it */
.ripple { position: absolute; border-radius: 50%; background: currentColor; opacity: .16; transform: scale(0); pointer-events: none; z-index: -1;
  animation: ripple .6s cubic-bezier(.2, .7, .3, 1) forwards; }
@keyframes ripple { to { transform: scale(1); opacity: 0; } }

/* typography: emphasized display */
.large-title { font: 800 36px/1.08 var(--font); letter-spacing: -0.035em; animation: titleIn .7s var(--spring-bounce) both; }
@keyframes titleIn { from { opacity: 0; transform: translateY(12px); letter-spacing: -0.01em; } }
h2 { font-weight: 700; }

/* staggered entrance (motion.js adds .enter with --i) */
.enter { animation: rise .62s var(--spring-bounce) both; animation-delay: calc(var(--i, 0) * 38ms); }
@keyframes rise { from { opacity: 0; transform: translateY(20px) scale(.975); } }

/* buttons: tonal by default, and the shape morphs when pressed (full → squircle) */
.btn { background: var(--tonal); color: var(--on-tonal); font-weight: 650;
  transition: background .2s, border-radius .45s var(--spring-bounce), transform .45s var(--spring-bounce), box-shadow .25s, filter .15s; }
.btn:hover { background: var(--tonal-hover); }
.btn:active:not(:disabled) { border-radius: 12px; transform: scale(.96); }
.btn.sm:active:not(:disabled) { border-radius: 9px; }
.btn.primary { background: var(--accent-fill); color: #fff; }
.btn.primary:hover { box-shadow: 0 8px 22px rgba(0, 113, 227, .38); transform: translateY(-1px); }
.btn.primary:active:not(:disabled) { transform: scale(.96); }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.danger:hover { background: color-mix(in srgb, var(--red) 20%, transparent); }
.btn.danger.solid { background: #c9252d; color: #fff; }
.btn.ghost { background: transparent; color: var(--label2); }
.btn.ghost:hover { background: var(--fill); color: var(--label); }
.pill .btn { background: transparent; color: var(--accent); }
.pill .btn:hover { background: var(--fill); }
.pill .btn.primary { background: var(--accent-fill); color: #fff; }
.circle { transition: transform .45s var(--spring-bounce), border-radius .45s var(--spring-bounce); }
.circle:active { transform: scale(.9); border-radius: 14px; }

/* cards: larger radius, clickable ones lift */
.card { border-radius: var(--r-lg); }
a.card, .card.link { transition: transform .45s var(--spring-bounce), box-shadow .3s; }
a.card:hover, .card.link:hover { transform: translateY(-3px); box-shadow: 0 14px 34px rgba(0, 0, 0, .10); text-decoration: none; }
a.card:active { transform: scale(.985); }

/* hero stats: each metric gets its own tonal container */
.stat .value { font-weight: 800; letter-spacing: -0.04em; }
.stat .label svg.i { width: 28px; height: 28px; padding: 6px; border-radius: 10px; background: var(--tonal); color: var(--on-tonal); box-sizing: border-box; }
.g4 > .card.stat { position: relative; overflow: hidden; }
.g4 > .card.stat::after { content: ""; position: absolute; width: 170px; height: 170px; right: -70px; top: -84px; pointer-events: none; opacity: .5;
  background: var(--tint, var(--primary-container)); border-radius: 44% 56% 62% 38% / 48% 42% 58% 52%; transition: transform .8s var(--spring-soft); }
.g4 > .card.stat:hover::after { transform: rotate(35deg) scale(1.08); }
.g4 > .card.stat:nth-child(2) { --tint: var(--tertiary-container); }
.g4 > .card.stat:nth-child(2) .label svg.i { background: var(--tertiary-container); color: var(--on-tertiary-container); }
.g4 > .card.stat:nth-child(3) { --tint: var(--orange-soft); }
.g4 > .card.stat:nth-child(3) .label svg.i { background: var(--orange-soft); color: var(--orange); }
.g4 > .card.stat:nth-child(4) { --tint: var(--green-soft); }
.g4 > .card.stat:nth-child(4) .label svg.i { background: var(--green-soft); color: var(--green); }
.g4 > .card.stat > * { position: relative; z-index: 1; }

/* sidebar: sliding active-indicator pill (M3 navigation) */
.nav { position: relative; }
.nav .indicator { position: absolute; left: 10px; right: 10px; top: 0; height: 36px; border-radius: 999px; background: var(--accent-fill); z-index: 0; pointer-events: none;
  box-shadow: 0 6px 18px rgba(0, 113, 227, .32); transition: transform .55s var(--spring-bounce), height .35s var(--spring-bounce), opacity .2s; }
.nav .indicator.travel { animation: squashY .55s var(--spring-soft); }
@keyframes squashY { 35% { scale: .94 1.14; } }
.nav a { position: relative; z-index: 1; transition: background .15s, color .25s, padding .35s var(--spring-bounce); }
.nav a:hover { background: color-mix(in srgb, var(--accent-fill) 9%, transparent); }
.nav a.active, .nav a.active:hover { background: transparent; box-shadow: none; color: #fff; font-weight: 650; padding-left: 14px; }
.nav a.active svg.i { color: #fff; }

/* segmented tabs: a glass thumb that slides and stretches */
.tabs { position: relative; }
.tabs .indicator { position: absolute; left: 0; top: 3px; bottom: 3px; width: 60px; border-radius: 999px; background: var(--surface); z-index: 0; pointer-events: none;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .12), 0 0 0 0.5px rgba(0, 0, 0, .04); transition: transform .55s var(--spring-bounce), width .45s var(--spring-bounce), opacity .2s; }
.tabs .indicator.travel { animation: squashX .55s var(--spring-soft); }
@keyframes squashX { 35% { scale: 1.1 .9; } }
.tabs button { position: relative; z-index: 1; }
.tabs button.active { background: transparent; box-shadow: none; color: var(--accent); font-weight: 650; }
.tabs button:hover:not(.active) { background: transparent; color: var(--accent); }

/* inputs: M3 filled field with an active indicator line */
input:focus, select:focus, textarea:focus { box-shadow: inset 0 -2px 0 var(--accent-fill), 0 0 0 4px var(--accent-soft); }
input[type=checkbox]:focus { box-shadow: none; }

/* M3 switch: outlined track, the handle grows and gets a check when on */
label.check input[type=checkbox] { width: 52px; height: 32px; background: var(--container-high); box-shadow: inset 0 0 0 2px var(--outline); transition: background .25s, box-shadow .25s; }
label.check input[type=checkbox]::after { top: 8px; left: 8px; width: 16px; height: 16px; background: var(--outline); box-shadow: none;
  transition: transform .45s var(--spring-bounce), width .3s var(--spring-bounce), height .3s var(--spring-bounce), top .3s var(--spring-bounce), left .3s var(--spring-bounce), background .2s; }
label.check input[type=checkbox]:checked { background: var(--accent-fill); box-shadow: none; }
label.check input[type=checkbox]:checked::after { top: 4px; left: 4px; width: 24px; height: 24px; transform: translateX(20px); background: #fff center / 16px no-repeat
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230071e3' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E"); }
label.check input[type=checkbox]:active::after { width: 28px; height: 28px; top: 2px; left: 2px; }
label.check input[type=checkbox]:checked:active::after { transform: translateX(18px); }

/* M3 progress: active part, a gap, the track and a stop dot */
.bar { height: 8px; background: none; overflow: visible; position: relative; }
.bar::before { content: ""; position: absolute; top: 0; bottom: 0; right: 0; left: min(100%, calc(var(--p, 0%) + 5px)); border-radius: 99px; background: var(--primary-container); }
.bar::after { content: ""; position: absolute; right: 2px; top: 50%; width: 4px; height: 4px; margin-top: -2px; border-radius: 50%; background: var(--accent-fill); }
.bar > div { position: relative; z-index: 1; transition: width .8s var(--spring-bounce); }
.bar.warn::before { background: var(--orange-soft); } .bar.warn::after { background: #ff9500; }
.bar.bad::before { background: var(--red-soft); } .bar.bad::after { background: #ff3b30; }

/* M3 Expressive loading indicator: a shape that morphs as it turns */
.m3-loader { width: 40px; height: 40px; flex: none; background: var(--accent-fill); animation: morph 2.4s var(--spring-soft) infinite, turn 2.4s linear infinite; }
.loading { flex-direction: column; gap: 14px; font-weight: 500; }
@keyframes morph {
  0%, 100% { border-radius: 50%; scale: 1; }
  20% { border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%; scale: .9; }
  40% { border-radius: 22%; scale: .82; }
  60% { border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%; scale: .95; }
  80% { border-radius: 40% 60% 50% 50% / 50% 60% 40% 50%; scale: .88; }
}
@keyframes turn { to { rotate: 360deg; } }

/* tables: tinted state layer */
tbody tr:hover td { background: color-mix(in srgb, var(--accent-fill) 6%, transparent); }

/* functional layer gets springier */
.modal-bg { -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.modal { animation: sheet .6s var(--spring-bounce); }
.menu { animation: pop .42s var(--spring-bounce); }
.toast { animation: drop .6s var(--spring-bounce); }
.modal-foot .btn { min-height: 44px; }

/* machine card: CPU temperature */
.machine .temp-row { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 11.5px; color: var(--label2); font-weight: 500; }
.machine .temp-row svg.i { width: 13px; height: 13px; color: var(--label2); }
.machine .temp-row b { font-variant-numeric: tabular-nums; color: var(--label); font-weight: 600; }
.machine .temp-row[data-level="hot"] b, .machine .temp-row[data-level="hot"] svg.i { color: var(--heat-hot); }
.machine .temp-row[data-level="critical"] b, .machine .temp-row[data-level="critical"] svg.i { color: var(--heat-crit); animation: throb 1s ease-in-out infinite; }

/* ---------- overheating banner (every page) ---------- */
.heat-host { position: sticky; top: 64px; z-index: 4; padding: 0 24px; max-width: 1680px; width: 100%; }
.heat { display: flex; align-items: center; gap: 14px; padding: 12px 12px 12px 14px; margin-bottom: 14px; border-radius: 24px; position: relative; overflow: hidden;
  --heat: var(--heat-hot); animation: heatIn .7s var(--spring-bounce); }
.heat[data-level="critical"] { --heat: var(--heat-crit); }
.heat::before { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(100deg, color-mix(in srgb, var(--heat) 26%, transparent), color-mix(in srgb, var(--heat) 8%, transparent) 55%, color-mix(in srgb, var(--heat) 18%, transparent));
  background-size: 220% 100%; animation: haze 6s ease-in-out infinite alternate; }
.heat[data-level="critical"]::before { animation-duration: 2.2s; }
.heat b { font-size: 15px; color: var(--heat); }
.heat .small { color: var(--label); opacity: .85; margin-top: 1px; }
.heat-icon { width: 42px; height: 42px; flex: none; display: grid; place-items: center; border-radius: 14px; background: var(--heat); color: #fff;
  animation: throb 2s ease-in-out infinite; }
.heat[data-level="critical"] .heat-icon { animation-duration: .9s; border-radius: 50%; }
.heat-icon svg.i { width: 24px; height: 24px; stroke-width: 2.2; }
.heat-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: color-mix(in srgb, var(--heat, var(--accent)) 16%, transparent); color: var(--heat, var(--accent)); }
.heat.leaving { animation: heatOut .35s ease-in forwards; }
@keyframes heatIn { from { opacity: 0; transform: translateY(-16px) scale(.96); } }
@keyframes heatOut { to { opacity: 0; transform: translateY(-10px) scale(.97); } }
@keyframes haze { from { background-position: 0% 0; } to { background-position: 100% 0; } }
@keyframes throb { 50% { transform: scale(1.08); } }

@media (max-width: 800px) {
  .heat-host { padding: 0 12px; position: static; }
  .heat { flex-wrap: wrap; gap: 10px; padding: 10px 10px 10px 12px; }
  .heat .small { font-size: 13px; }
  .heat-chips { display: none; }
  .heat-icon { width: 36px; height: 36px; border-radius: 12px; }
  .heat > .row { width: 100%; justify-content: flex-end; }
  .large-title { font-size: 32px; }
  .tabbar { position: fixed; }
  .tabbar .indicator { position: absolute; left: 0; top: 5px; bottom: 5px; width: 60px; border-radius: 999px; background: var(--tonal); z-index: 0; pointer-events: none;
    transition: transform .55s var(--spring-bounce), width .45s var(--spring-bounce), opacity .2s; }
  .tabbar .indicator.travel { animation: squashX .55s var(--spring-soft); }
  .tabbar a, .tabbar button { z-index: 1; }
  .tabbar .on { background: transparent; color: var(--accent); }
}


/* ---------- Misc: tool browser ---------- */
.tool-layout { display: grid; grid-template-columns: minmax(250px, 310px) minmax(0, 1fr); gap: 18px; align-items: start; }
.tool-side { position: sticky; top: 76px; padding: 12px; max-height: calc(100vh - 96px); overflow-y: auto; scrollbar-width: thin; }
.tool-side .search { margin-bottom: 6px; }
.tool-group { font: 700 12px var(--font); letter-spacing: .04em; text-transform: uppercase; color: var(--label2); padding: 14px 10px 6px; }
.tool-item { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 18px; color: var(--label); margin: 1px 0;
  transition: background .2s, border-radius .45s var(--spring-bounce), transform .45s var(--spring-bounce); }
.tool-item:hover { background: color-mix(in srgb, var(--tool) 9%, transparent); text-decoration: none; }
.tool-item:active { transform: scale(.98); border-radius: 12px; }
.tool-item.active { background: color-mix(in srgb, var(--tool) 16%, transparent); }
.tool-item.active .tool-text b { color: var(--tool); }
.tool-ico { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 12px; color: #fff; background: var(--tool, var(--accent-fill));
  transition: border-radius .5s var(--spring-bounce), transform .5s var(--spring-bounce); }
.tool-item:hover .tool-ico, .tool-item.active .tool-ico { border-radius: 50%; }
.tool-item.active .tool-ico { transform: rotate(-8deg) scale(1.05); }
.tool-ico svg.i { width: 19px; height: 19px; }
.tool-ico.big { width: 52px; height: 52px; border-radius: 17px; }
.tool-ico.big svg.i { width: 26px; height: 26px; }
.tool-text { display: flex; flex-direction: column; min-width: 0; }
.tool-text b { font-size: 14.5px; font-weight: 600; transition: color .2s; }
.tool-text span { font-size: 12.5px; color: var(--label2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool-pane { min-height: 420px; padding: 22px 24px; }
.tool-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.tool-head h2 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.03em; }
.tool-head .tool-ico { animation: icoIn .7s var(--spring-bounce); }
.tool-back { display: none; }
.tool-body { animation: rise .5s var(--spring-bounce); }
@keyframes icoIn { from { transform: scale(.4) rotate(-40deg); border-radius: 50%; } }
.tool-empty { display: grid; place-items: center; text-align: center; padding: 60px 20px; }
.tool-empty .tool-ico { --tool: var(--accent-fill); margin-bottom: 12px; animation: morph 5s var(--spring-soft) infinite; }
.tool-section + .tool-section { margin-top: 24px; padding-top: 20px; border-top: 0.5px solid var(--separator); }
.chart-empty { height: 170px; display: flex; flex-direction: column; gap: 8px; align-items: center; justify-content: center; border-radius: 18px;
  background: var(--container-low); color: var(--label2); font-size: 13.5px; text-align: center; padding: 0 16px; }
.chart-empty svg.i { width: 26px; height: 26px; color: var(--tool); }
.tool-split { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 20px; align-items: start; }

.kv-list { display: flex; flex-direction: column; gap: 4px; }
.kv-row { display: flex; align-items: center; gap: 12px; padding: 8px 6px 8px 12px; border-radius: 14px; background: var(--container-low); min-width: 0; }
.kv-row > .muted { width: 128px; flex: none; font-size: 13px; }
.kv-row > b, .kv-row > .mono { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.kv-row.hl { background: var(--green-soft); }
.hash { font-size: 12.5px; word-break: break-all; }
.chip-btn { border: 0; background: var(--container-high); color: var(--label); font: 500 12.5px var(--font); padding: 5px 12px; border-radius: 10px; cursor: pointer;
  transition: border-radius .4s var(--spring-bounce), background .2s; }
.chip-btn:hover { background: var(--tonal); color: var(--on-tonal); border-radius: 999px; }
.result-card { padding: 14px 16px; border-radius: 18px; background: var(--fill); animation: rise .5s var(--spring-bounce); }
.result-card.ok { background: var(--green-soft); } .result-card.ok b { color: var(--green); }
.result-card.bad { background: var(--red-soft); } .result-card.bad b { color: var(--red); }
.result-card.warn { background: var(--orange-soft); } .result-card.warn b { color: var(--orange); }
.toggle-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 16px; }
.perm-grid { display: grid; grid-template-columns: 90px repeat(3, 70px); gap: 10px 8px; align-items: center; justify-items: center; }
.perm-grid > span:nth-child(4n+1) { justify-self: start; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
.stat-row > div { background: var(--container-low); border-radius: 16px; padding: 10px 14px; }
.stat-row b { font: 800 24px/1.2 var(--font); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.bench-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.bench-card { background: var(--container-low); border-radius: 22px; padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.bench-card svg.i { color: var(--tool); }
.bench-results { display: grid; gap: 8px; margin-top: 8px; animation: rise .5s var(--spring-bounce); }
.bench-value { font: 800 26px/1.1 var(--font); letter-spacing: -0.03em; color: var(--tool); }
.find-btn { width: 170px; height: 170px; border: 0; border-radius: 50%; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  background: var(--tool); color: #fff; font: 700 16px var(--font); box-shadow: 0 14px 40px color-mix(in srgb, var(--tool) 45%, transparent);
  transition: border-radius .6s var(--spring-bounce), transform .5s var(--spring-bounce); }
.find-btn svg.i { width: 40px; height: 40px; }
.find-btn:hover { border-radius: 38%; transform: rotate(-4deg); }
.find-btn:active { transform: scale(.94); }
.find-btn.pinging { animation: ping 1s ease-out infinite; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--tool) 55%, transparent); } 100% { box-shadow: 0 0 0 36px transparent; } }

@media (max-width: 1100px) { .tool-split { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 800px) {
  .tool-layout { grid-template-columns: minmax(0, 1fr); }
  .tool-side { position: static; max-height: none; }
  .tool-layout.detail .tool-side { display: none; }
  .tool-layout:not(.detail) .tool-pane { display: none; }
  .tool-head { flex-wrap: wrap; row-gap: 8px; }
  .tool-back { display: inline-flex; flex: 0 0 100%; justify-content: flex-start; margin: -6px 0 0 -10px; }
  .tool-pane { padding: 16px; }
  .kv-row > .muted { width: 96px; }
  .stat-row b { font-size: 20px; }
}


/* ---------- main navigation: Misc-style tiles ---------- */
.nav-search-wrap { padding: 4px 12px 0; }
.nav-search { width: 100%; min-width: 0; min-height: 34px; font-size: 14px; }
.nav a { gap: 11px; padding: 6px 9px; border-radius: 18px; min-height: 48px; color: var(--label);
  transition: background .2s, border-radius .45s var(--spring-bounce), transform .45s var(--spring-bounce); }
.nav a:hover { background: color-mix(in srgb, var(--tool) 9%, transparent); }
.nav a:active { transform: scale(.98); border-radius: 12px; }
.nav a .tool-ico { width: 34px; height: 34px; border-radius: 11px; background: var(--tool); }
.nav a .tool-ico svg.i { color: #fff; width: 18px; height: 18px; }
.nav a:hover .tool-ico { border-radius: 50%; }
.nav a .tool-text b { font-size: 14.5px; font-weight: 600; }
.nav a .tool-text span { font-size: 12px; }
.nav a.active, .nav a.active:hover { background: transparent; box-shadow: none; color: var(--label); padding-left: 9px; font-weight: 400; }
.nav a.active .tool-text b { color: var(--tool); }
.nav a.active .tool-ico { border-radius: 50%; transform: rotate(-8deg) scale(1.05); }
.nav a.active svg.i { color: #fff; }
.nav .indicator { background: color-mix(in srgb, var(--tool, var(--accent-fill)) 17%, transparent); box-shadow: none; border-radius: 18px; }
.nav a[hidden], .nav a[data-off], .nav .sec[hidden] { display: none; }
.nav .group.force-open[hidden] { display: block; }
.nav.searching .sec svg.i { visibility: hidden; }
.palette .results a { gap: 12px; padding: 7px 10px; border-radius: 16px; }
.palette .results a .tool-ico { width: 34px; height: 34px; border-radius: 11px; }
.palette .results a .tool-ico svg.i { color: #fff; width: 18px; height: 18px; }
.palette .results a.sel { background: color-mix(in srgb, var(--accent-fill) 14%, transparent); color: var(--label); }
.palette .results a.sel .tool-text b { color: var(--accent); }
.palette .results a.sel svg.i { color: #fff; }
@media (max-width: 800px) {
  .nav a { min-height: 54px; }
  .nav a .tool-text b { font-size: 16px; }
  .nav a .tool-text span { font-size: 13px; }
}


/* ---------- in-page tabs as a Misc-style side list ---------- */
.tabbed { display: grid; grid-template-columns: minmax(220px, 260px) minmax(0, 1fr); gap: 18px; align-items: start; }
.tabbed-content { min-width: 0; }
.tabbed-content.enter, .tabbed > .side-tabs.enter { animation: none; }
.tabs.side-tabs { display: flex; flex-direction: column; gap: 2px; padding: 10px; margin: 0; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-sm);
  position: sticky; top: 76px; overflow: visible; max-width: none; }
.side-tabs button { display: flex; align-items: center; gap: 11px; padding: 7px 9px; min-height: 50px; border-radius: 18px; text-align: left; font-weight: 400; color: var(--label);
  transition: background .2s, border-radius .45s var(--spring-bounce), transform .45s var(--spring-bounce); }
.side-tabs button:hover:not(.active) { background: color-mix(in srgb, var(--tool) 9%, transparent); color: var(--label); }
.side-tabs button:active { transform: scale(.98); border-radius: 12px; }
.side-tabs button.active { color: var(--label); font-weight: 400; }
.side-tabs button.active .tool-text b { color: var(--tool); }
.side-tabs button .tool-ico { width: 34px; height: 34px; border-radius: 11px; background: var(--tool); }
.side-tabs button .tool-ico svg.i { color: #fff; width: 18px; height: 18px; }
.side-tabs button:hover .tool-ico, .side-tabs button.active .tool-ico { border-radius: 50%; }
.side-tabs button.active .tool-ico { transform: rotate(-8deg) scale(1.05); }
.side-tabs .indicator { left: 10px; right: 10px; top: 0; bottom: auto; width: auto; background: color-mix(in srgb, var(--tool) 16%, transparent); box-shadow: none; border-radius: 18px;
  transition: transform .55s var(--spring-bounce), height .35s var(--spring-bounce), opacity .2s; }
.side-tabs .indicator.travel { animation: squashY .55s var(--spring-soft); }
.side-tabs .tool-text b { font-size: 14.5px; font-weight: 600; }
.side-tabs .tool-text span { font-size: 12px; }
@media (max-width: 1000px) {
  .tabbed { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  /* narrow screens: a scrolling row of tiles */
  .tabs.side-tabs { flex-direction: row; position: relative; top: auto; overflow-x: auto; scrollbar-width: none; padding: 8px; }
  .side-tabs button { flex: none; flex-direction: column; gap: 5px; min-height: 0; padding: 8px 12px; min-width: 84px; }
  .side-tabs button .tool-text { align-items: center; }
  .side-tabs button .tool-text b { font-size: 12.5px; white-space: nowrap; }
  .side-tabs button .tool-text span { display: none; }
  .side-tabs .indicator { left: 0; top: 8px; bottom: 8px; right: auto; height: auto !important; width: 60px; }
  .side-tabs .indicator.travel { animation: squashX .55s var(--spring-soft); }
}

.lang-switch { gap: 4px; font-size: 12px; letter-spacing: .04em; padding: 4px 9px; }
.lang-switch svg.i { width: 14px; height: 14px; }

.mod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.mod-card { background: var(--surface); border-radius: 20px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow-sm);
  transition: transform .45s var(--spring-bounce); }
.mod-card:hover { transform: translateY(-2px); }
.mod-title { font-weight: 700; color: var(--label); }
.mod-desc { color: var(--label2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- accessibility preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
@media (prefers-reduced-transparency: reduce) {
  .sidebar, .modal, .menu, .toast, .glass, .tabbar, .login, .heat { background: var(--surface) !important; -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
  .topbar::before { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--window); -webkit-mask-image: none; mask-image: none; }
  body::before { display: none; }
  .heat::before { animation: none; }
}
@media (prefers-contrast: more) {
  :root { --separator: rgba(128, 128, 128, .6); --separator-strong: rgba(128, 128, 128, .85); --label2: var(--label); --glass-rim: rgba(128, 128, 128, .9); --fill: rgba(118, 118, 128, .3); }
  .btn, input, select, textarea, .card, .table-wrap { box-shadow: inset 0 0 0 1.5px var(--separator-strong); }
}
