:root {
  --surface: #eceff3;
  --panel: #ffffff;
  --panel-sunken: #f5f7f9;
  --ink: #16212b;
  --ink-soft: #33414e;
  --muted: #5c6c7a;
  --line: #d6dce3;
  --accent: #2c4bd8;
  --accent-soft: #e6eaff;
  --meter: #b4641a;
  --ok: #1c7a55;
  --warn: #a8342c;
  --radius: 6px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, monospace;
  --sans: ui-sans-serif, system-ui, "Segoe UI", Inter, Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- shell ---- */
.shell { display: flex; min-height: 100vh; }

.rail {
  width: 216px;
  flex: none;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand { font-weight: 640; font-size: 17px; letter-spacing: -0.01em; }
.brand span { display: block; font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 6px; }
.brand .brand-logo { display: block; color: inherit; }
.brand .brand-logo img { display: block; height: 30px; width: auto; max-width: 100%; }
.brand .by { display: block; font-size: 11.5px; font-weight: 500; color: var(--muted); letter-spacing: .01em; margin-top: 2px; }

.rail nav { display: flex; flex-direction: column; gap: 2px; }
.rail nav a {
  color: var(--ink);
  padding: 7px 10px;
  border-radius: var(--radius);
  font-size: 14.5px;
}
.rail nav a:hover { background: var(--panel-sunken); text-decoration: none; }
.rail nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 560; }
.rail .group { margin-top: 18px; font-size: 12.5px; color: var(--muted); padding: 0 10px 4px; }
.rail .foot { margin-top: auto; font-size: 12.5px; color: var(--muted); }

.content { flex: 1; padding: 28px 32px 64px; max-width: 1060px; }

h1 { font-size: 24px; letter-spacing: -0.015em; margin: 0 0 4px; font-weight: 640; }
h2 { font-size: 17px; margin: 28px 0 10px; font-weight: 600; }
h3 { font-size: 14.5px; margin: 0 0 8px; font-weight: 600; }
.lede { color: var(--muted); margin: 0 0 22px; max-width: 62ch; }

/* ---- panels ---- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.panel.tight { padding: 14px 16px; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.three { grid-template-columns: repeat(3, 1fr); }
.grid.four { grid-template-columns: repeat(4, 1fr); }

/* ---- the gauge: balance, burn rate, runway ---- */
.gauge { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; margin-bottom: 20px; }
.gauge .runway { font-size: 44px; line-height: 1.05; font-weight: 620; letter-spacing: -0.03em; }
.gauge .runway small { font-size: 17px; font-weight: 500; color: var(--muted); margin-left: 6px; letter-spacing: 0; }
.gauge .sub { color: var(--muted); margin-top: 4px; }
.track { height: 10px; background: var(--panel-sunken); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; margin: 18px 0 8px; }
.track i { display: block; height: 100%; background: var(--meter); }
.track i.low { background: var(--warn); }
.gauge .legend { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }

/* ---- tables ---- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 13px; padding: 0 12px 8px 0; border-bottom: 1px solid var(--line); }
td { padding: 10px 12px 10px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; padding-right: 0; }
.mono { font-family: var(--mono); font-size: 13px; }

/* ---- state dots ---- */
.state { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; }
.state::before { content: ""; width: 7px; height: 7px; border-radius: 99px; background: var(--muted); }
.state.running::before { background: var(--ok); }
.state.creating::before { background: var(--accent); }
.state.suspended::before, .state.error::before { background: var(--warn); }

/* ---- forms ---- */
label { display: block; font-size: 13.5px; margin-bottom: 5px; color: var(--ink); }
input[type=text], input[type=email], input[type=password], input[type=number],
select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}
textarea { min-height: 84px; resize: vertical; font-family: var(--mono); font-size: 13px; }
.field { margin-bottom: 14px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 150px; }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.check input { width: auto; }
.check label { margin: 0; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

input[type=range] { width: 100%; accent-color: var(--accent); }
.slider-head { display: flex; justify-content: space-between; align-items: baseline; }
.slider-head b { font-weight: 600; }
.slider-head span { color: var(--muted); font-size: 12.5px; }

button, .btn {
  font: inherit;
  font-size: 14px;
  font-weight: 540;
  padding: 8px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}
button:hover, .btn:hover { background: var(--panel-sunken); text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover, .btn.primary:hover { background: #2340c4; }
button.danger { color: var(--warn); border-color: #e7c7c4; }
button.danger:hover { background: #fbf0ef; }
button:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---- power controls: each action its own colour and weight ---- */
.power { display: inline-flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.power form { margin: 0; }
.pwr { display: inline-flex; align-items: center; gap: 6px; }
.pwr svg { flex: none; }
.pwr-start { background: var(--ok); border-color: var(--ok); color: #fff; }
.pwr-start:hover { background: #15603f; }
.pwr-restart { color: var(--accent); border-color: #c5cff5; }
.pwr-restart:hover { background: var(--accent-soft); }
.pwr-shutdown { color: var(--meter); border-color: #ecd3bb; background: #fdf7f1; }
.pwr-shutdown:hover { background: #f8eadc; }
.pwr-force { background: var(--warn); border-color: var(--warn); color: #fff; }
.pwr-force:hover { background: #8c2a23; }
.pwr:disabled { background: var(--panel); border-color: var(--line); color: var(--muted); opacity: .55; }
.pwr:disabled:hover { background: var(--panel); }
.power.compact .pwr { padding: 6px 10px; font-size: 13px; }
@media (max-width: 640px) { .power.compact .pwr span { display: none; } }

/* ---- option cards (templates, vGPU) ---- */
.options { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.option { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; background: var(--panel); }
.option:hover { border-color: #b9c3cd; }
.option input { position: absolute; opacity: 0; }
.option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.option:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.option b { display: block; font-weight: 600; }
.option .meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.option .price { font-size: 12.5px; color: var(--meter); margin-top: 6px; }

/* GPU offerings: a card with a quantity stepper instead of a radio */
.gpu-offer { cursor: default; }
.gpu-offer.picked { border-color: var(--accent); background: var(--accent-soft); }
.gpu-offer.off { opacity: .55; }
.stepper { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.stepper button { width: 32px; padding: 4px 0; font-size: 16px; line-height: 1; }
.option .stepper input { position: static; opacity: 1; width: 56px; text-align: center; padding: 5px 6px; }

/* ---- flashes ---- */
.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; border: 1px solid var(--line); background: var(--panel); font-size: 14px; }
.flash.error { border-color: #e7c7c4; background: #fbf0ef; color: #7d2a24; }
.flash.success { border-color: #bfe0d1; background: #eef8f3; color: #14563c; }

/* ---- misc ---- */
.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--panel-sunken); border: 1px solid var(--line); color: var(--muted); }
.pill.missing { background: #fbf0ef; border-color: #e7c7c4; color: var(--warn); }
.pill.vgpu { background: #fdf3e8; border-color: #efd9be; color: var(--meter); }
.empty { border: 1px dashed var(--line); border-radius: var(--radius); padding: 28px; text-align: center; color: var(--muted); background: var(--panel); }
.empty p { margin: 0 0 14px; }
.stat b { display: block; font-size: 22px; font-weight: 620; letter-spacing: -0.02em; }
.stat span { color: var(--muted); font-size: 13px; }
.bar { height: 6px; background: var(--panel-sunken); border-radius: 99px; overflow: hidden; margin-top: 6px; border: 1px solid var(--line); }
.bar i { display: block; height: 100%; background: var(--accent); }
.split { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.auth { max-width: 380px; margin: 10vh auto; }
.auth-logo { display: block; margin: 0 auto 18px; text-align: center; color: var(--ink); font-size: 22px; }
.auth-logo img { height: 40px; width: auto; }
.company { margin: 14px 0 0; font-size: 12px; color: var(--muted); }
.company img { height: 22px; width: auto; vertical-align: middle; opacity: .85; }
.auth .company { text-align: center; margin-top: 28px; }
.toml { background: var(--panel-sunken); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; font-family: var(--mono); font-size: 12.5px; overflow-x: auto; white-space: pre; }

/* ---- build progress ---- */
.build { border-color: #c8d2f6; }
.build-head { display: flex; justify-content: space-between; align-items: baseline; }
.build-head b { font-size: 22px; font-weight: 620; letter-spacing: -0.02em; color: var(--accent); }
.build-track { height: 12px; background: var(--panel-sunken); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; margin: 10px 0 6px; }
.build-track.small { height: 6px; margin: 6px 0 2px; max-width: 220px; }
.build-track i {
  display: block; height: 100%; background: var(--accent); border-radius: 99px;
  transition: width .6s ease;
  background-image: linear-gradient(90deg, rgba(255,255,255,0) 0, rgba(255,255,255,.35) 50%, rgba(255,255,255,0) 100%);
  background-size: 200px 100%; background-repeat: no-repeat;
  animation: build-sheen 1.6s linear infinite;
}
.build-track.failed i { background-color: var(--warn); animation: none; }
.build-track.done i { background-color: var(--ok); animation: none; }
@keyframes build-sheen { from { background-position: -200px 0; } to { background-position: calc(100% + 200px) 0; } }

/* ---- streaming and files ---- */
.stream-prep { max-width: 560px; }
.stream-prep.failed { border-color: #e7c7c4; }
.stream-prep.failed .js-title { color: var(--warn); }
.stream-prep [hidden], .stream-wrap[hidden] { display: none; }
.stream-wrap, .files-wrap { padding: 0; overflow: hidden; }
.stream-wrap iframe, .files-wrap iframe {
  display: block; width: 100%; border: 0; background: var(--surface);
  height: calc(100vh - 150px); min-height: 440px;
}
.stream-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.stream-card { display: flex; flex-direction: column; justify-content: space-between; gap: 14px; margin: 0; }
.stream-card b { font-weight: 600; }
.stream-card .btn, .stream-card button { align-self: flex-start; }
.stream-cta { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.stream-cta p { margin: 0; }
.btn.big, button.big { padding: 11px 20px; font-size: 15px; }
body.stream-solo { display: flex; align-items: center; justify-content: center; min-height: 100vh; margin: 0; padding: 16px; }
body.stream-solo .stream-prep { width: 100%; }

/* Enhanced display: the console on top, the stream connecting underneath
   (on screen, so the browser doesn't throttle it), swapped on its first frame. */
.stream-wrap.enhanced { position: relative; height: calc(100vh - 150px); min-height: 440px; background: #000; }
.stream-wrap.enhanced iframe { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; background: #000; }
.stream-wrap.enhanced #streamFrame { z-index: 1; }
.stream-wrap.enhanced #vncFrame { z-index: 2; }
/* The swap: the stream fades in ON TOP of the still-visible console, so
   there is never a moment with neither picture (a crossfade, not a cut). */
.stream-wrap.enhanced.ml-on #streamFrame { z-index: 3; animation: pb-stream-in .22s ease-out both; }
.stream-wrap.enhanced.ml-on #vncFrame { pointer-events: none; visibility: hidden; transition: visibility 0s .3s; }
@keyframes pb-stream-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .stream-wrap.enhanced.ml-on #streamFrame { animation-duration: .01s; } }
.stream-wrap.enhanced:fullscreen { height: 100%; }
.stream-wrap.enhanced.solo { position: fixed; inset: 0; height: auto; min-height: 0; margin: 0; border: 0; border-radius: 0; }
.stream-pill {
  position: absolute; z-index: 4; top: 10px; right: 10px; display: flex; align-items: center; gap: 8px;
  padding: 5px 12px; border-radius: 99px; font-size: 12.5px; color: #fff;
  background: rgba(20, 22, 30, .78); backdrop-filter: blur(6px); transition: opacity .3s ease;
}
.stream-pill[hidden] { display: none; }
.stream-pill.fade { opacity: 0; }
.stream-pill button { padding: 3px 10px; margin-right: -6px; font-size: 12px; border-radius: 99px; }
.enhanced-check { margin: 10px 0 2px; }
.admin-banner { border-color: #c8d2f6; background: var(--accent-soft); color: var(--ink); }
.admin-panel { border-color: #c8d2f6; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters .field { margin: 0; min-width: 180px; }

@media (max-width: 760px) {
  .grid.two, .grid.three { grid-template-columns: 1fr; }
  .grid.four { grid-template-columns: 1fr 1fr; }
}

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

/* ---- network: addresses and forwarded ports ---- */
.net-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.net-ips { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 6px; }
.ip-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 6px 4px 10px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel-sunken);
}
.ip-chip .mono { font-size: 14px; color: var(--ink); }
button.copy { padding: 2px 8px; font-size: 12px; font-weight: 500; }
.fwd { margin-top: 14px; }
.fwd-lede { margin: 0 0 8px; }
.fwd-lede b { color: var(--accent); font-weight: 600; }
.fwd-table td { padding-top: 6px; padding-bottom: 6px; }
.net-inline { font-size: 12.5px; color: var(--muted); }
.net-inline .mono { font-size: 12.5px; }

/* ---- usage graphs (static/usage.js) ---- */
.usage-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.usage-head h3 { margin: 0; }
.usage-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-top: 14px; }
.spark { position: relative; margin: 0; padding: 12px 14px 10px; border: 1px solid var(--line);
         border-radius: var(--radius); background: var(--panel-sunken); }
.spark figcaption { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; color: var(--muted); }
.spark figcaption b { color: var(--ink); font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.spark svg { display: block; width: 100%; height: 96px; margin-top: 6px; overflow: visible; touch-action: none; }
.spark-grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.spark-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark-area { fill: var(--accent); opacity: .12; }
.spark-hair { stroke: var(--ink-soft); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.spark-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 4px; }
.spark.empty svg { opacity: .35; }
.spark.empty::after { content: "No data yet"; position: absolute; left: 0; right: 0; top: 64px;
                      text-align: center; font-size: 12px; color: var(--muted); }
.spark-tip { position: absolute; top: 34px; transform: translateX(-50%); margin-left: 14px; padding: 3px 8px;
             font-size: 12px; white-space: nowrap; color: #fff; background: var(--ink); border-radius: 6px;
             pointer-events: none; font-variant-numeric: tabular-nums; }
.spark-tip[hidden] { display: none; }
.spark-dot { position: absolute; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%;
             background: var(--accent); box-shadow: 0 0 0 2px var(--panel-sunken); pointer-events: none; }
.spark.empty .spark-dot { display: none; }

.pool-sub { margin: 6px 0 8px; font-size: 13px; font-weight: 600; color: var(--muted); }

/* ---- GPU offering cards: vendor badge ---- */
.gpu-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.gpu-vendor {
  display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: 4px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .06em; color: #4d6b00;
  background: #f1f7e3; border: 1px solid #d7e7b4; flex: none;
}
.gpu-vendor img { height: 14px; width: auto; display: block; }
.gpu-vendor:has(img) { background: transparent; border-color: transparent; padding: 0; }

/* ---- Terms of Use ---- */
.doc { max-width: 760px; margin: 6vh auto; padding: 0 16px; }
.terms { padding: 28px 32px; line-height: 1.6; }
.terms h1 { margin-bottom: 2px; }
.terms h2 { font-size: 16px; margin: 26px 0 6px; }
.terms p, .terms li { color: var(--ink-soft); max-width: 68ch; }
.terms ul { padding-left: 20px; margin: 6px 0; }
.terms li { margin: 4px 0; }
.terms mark.todo { background: #fff2cc; color: #7a5200; padding: 0 3px; border-radius: 3px; font-size: .92em; }
.doc .company { text-align: center; }
.terms-check { align-items: flex-start; }
.terms-check input { margin-top: 3px; }
.terms-check label { font-size: 13.5px; line-height: 1.45; }
@media (max-width: 600px) { .terms { padding: 20px 18px; } }

/* ---- public pages: demos (templates/_public_base.html) ---- */
body.public { min-height: 100vh; }
.pub-top {
  display: flex; align-items: center; gap: 16px; padding: 12px 24px; background: var(--panel);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; flex-wrap: wrap;
}
.pub-logo img { height: 30px; width: auto; display: block; }
.pub-logo { color: var(--ink); font-size: 18px; }
.pub-top nav { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.pub-top nav a:not(.btn) { padding: 8px 10px; color: var(--ink-soft); }
.pub-main { max-width: 1100px; margin: 0 auto; padding: 28px 24px 48px; }
.pub-main h1 { margin-bottom: 6px; }
.demo-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.demo-card { display: flex; flex-direction: column; gap: 10px; color: inherit; margin: 0; transition: border-color .15s; }
.demo-card:hover { border-color: var(--accent); text-decoration: none; }
.demo-card h3 { margin: 0; }
.demo-card p { margin: 0; color: var(--ink-soft); }
.demo-card .btn { align-self: flex-start; margin-top: auto; }
.demo-card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.pill.free { background: #e8f6ef; border-color: #bfe3cf; color: #1c7a55; }
.pill.busy { background: #fdf3e8; border-color: #efd9be; color: var(--meter); }
.demo-specs { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); padding: 0; margin: 4px 0 12px; list-style: none; }
.demo-specs > * { display: inline-flex; align-items: center; gap: 6px; }
.demo-intro, .demo-ended { max-width: 640px; margin: 4vh auto 0; padding: 28px; }
.demo-intro .actions, .demo-ended .actions { margin: 16px 0 6px; }
.terms-note { margin-top: 14px; }
.demo-main .stream-prep { margin: 4vh auto 0; }
.demo-bar { display: flex; align-items: center; gap: 10px; min-width: 0; }
.demo-bar[hidden] { display: none; }
.demo-bar b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30vw; }
.demo-timer { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13.5px; padding: 3px 8px;
              border-radius: 99px; background: var(--panel-sunken); border: 1px solid var(--line); }
.demo-timer.low { color: var(--warn); border-color: #e7c7c4; background: #fbf0ef; }
body.demo-page .demo-main { max-width: none; padding: 16px; }
.demo-wrap iframe { height: calc(100vh - 110px); }
@media (max-width: 700px) {
  .pub-top { padding: 10px 16px; }
  .pub-main { padding: 20px 16px 40px; }
  .demo-bar { order: 3; width: 100%; }
  .demo-bar b { max-width: 40vw; }
}
.copy-row { display: flex; gap: 8px; align-items: center; margin: 4px 0 16px; }
.copy-row input { flex: 1; min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.copy-row button.copy { padding: 8px 12px; font-size: 13px; }

/* ---- Admin -> Services ---- */
.svc-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; vertical-align: 1px; }
.svc-dot.ok { background: #1c7a55; }
.svc-dot.bad { background: var(--warn); box-shadow: 0 0 0 3px #fbf0ef; }
.warn-text { color: var(--warn); }
.svc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.svc-grid td { overflow-wrap: anywhere; }
.svc-table th.num, .svc-table td.num { padding-right: 24px; }
@media (max-width: 760px) { .svc-grid { grid-template-columns: 1fr; } }

/* Terms of Use after signing in (terms_accept.html) */
.terms-scroll { max-height: 55vh; overflow-y: auto; margin: 14px 0 18px; padding: 4px 16px 8px;
  border: 1px solid var(--line); border-radius: 10px; }
.terms-accept .actions { margin-top: 6px; }
.legal-links a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.auth-legal { text-align: center; font-size: 12px; color: var(--muted); margin: 22px 0 0; }

/* ---- server (node) picker ---- */
.options.nodes { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.node-opt.off { opacity: .55; cursor: not-allowed; }
.node-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.node-head b { display: inline; }
.node-specs { list-style: none; margin: 8px 0 6px; padding: 0; font-size: 13px; }
.node-specs li { display: flex; gap: 8px; padding: 2px 0; }
.node-specs li span { flex: 0 0 64px; color: var(--muted); font-size: 12.5px; }

/* ---- port mapping editor ---- */
.fwd-table input.port { width: 92px; padding: 4px 6px; font-family: var(--mono); font-size: 13px; }
.fwd-table tr.changed td { background: var(--accent-soft); }
.fwd-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }

/* ---- theme switch (both themes) ---- */
.theme-switch { display: inline-flex; gap: 2px; padding: 2px; margin: 4px 0 8px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel-sunken); }
.theme-switch button { padding: 3px 9px; font-size: 12px; font-weight: 520; border: 0; border-radius: 6px;
  background: transparent; color: var(--muted); }
.theme-switch button:hover { background: transparent; color: var(--ink); }
.theme-switch button[aria-checked="true"] { background: var(--panel); color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.auth-theme { display: flex; justify-content: center; margin-top: 10px; }

/* =====================================================================
   Dark theme -- the landing page's look: black with deep cobalt light,
   and panels of frosted glass that catch it. <html data-theme="dark"> is
   set before the first paint by templates/_theme_head.html.

   Only the outermost surfaces (sidebar, panels, gauge, flashes, top bar)
   blur what is behind them; cards inside a panel are tinted glass without
   a blur of their own, so the browser never stacks blurs.
   ===================================================================== */
html[data-theme="dark"] {
  color-scheme: dark;
  --void: #020306;
  --surface: #04060b;
  --panel: rgba(18, 26, 40, 0.52);
  --panel-sunken: rgba(190, 210, 240, 0.055);
  --ink: #e4ebf4;
  --ink-soft: #c2cddb;
  --muted: #8b98ab;
  --line: rgba(200, 220, 255, 0.13);
  --accent: #6f9bff;
  --accent-soft: rgba(74, 130, 255, 0.17);
  --meter: #f2ab5e;
  --ok: #3fcf8e;
  --warn: #ff7d72;

  --glass-fill: linear-gradient(180deg, rgba(190, 210, 240, 0.105), rgba(120, 140, 175, 0.04));
  --glass-edge: rgba(200, 220, 255, 0.15);
  --glass-hi: rgba(255, 255, 255, 0.12);
  --glass-shadow: inset 0 1px 0 var(--glass-hi), inset 0 -1px 0 rgba(0, 0, 0, 0.35),
                  0 30px 60px -34px rgba(0, 0, 0, 0.9);
  --tint-ok: rgba(63, 207, 142, 0.13);   --edge-ok: rgba(63, 207, 142, 0.38);
  --tint-warn: rgba(255, 125, 114, 0.13); --edge-warn: rgba(255, 125, 114, 0.4);
  --tint-meter: rgba(242, 171, 94, 0.12); --edge-meter: rgba(242, 171, 94, 0.36);
  --edge-accent: rgba(122, 164, 255, 0.45);
  /* Light for the glass to catch, on the root so it fills the whole window
     however short the page, and fixed so every panel has some behind it. */
  background:
    radial-gradient(1000px 720px at 82% 2%, rgba(46, 98, 235, 0.42), transparent 68%),
    radial-gradient(820px 640px at 2% 48%, rgba(96, 114, 146, 0.24), transparent 70%),
    radial-gradient(1100px 760px at 62% 112%, rgba(22, 64, 170, 0.46), transparent 70%),
    var(--void);
  background-attachment: fixed;
  min-height: 100%;
}

html[data-theme="dark"] body {
  color: var(--ink);
  background: transparent;
  -webkit-font-smoothing: antialiased;
}
html[data-theme="dark"] .auth-logo { color: var(--ink); }
html[data-theme="dark"] ::selection { background: rgba(74, 130, 255, 0.45); color: #fff; }
html[data-theme="dark"] a { color: #8fb2ff; }
html[data-theme="dark"] a:hover { color: #b4cbff; }

/* -- glass surfaces -- */
html[data-theme="dark"] .panel,
html[data-theme="dark"] .gauge,
html[data-theme="dark"] .empty,
html[data-theme="dark"] .flash {
  background: var(--glass-fill);
  border-color: var(--glass-edge);
  box-shadow: var(--glass-shadow);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  backdrop-filter: blur(22px) saturate(140%);
}
html[data-theme="dark"] .panel, html[data-theme="dark"] .gauge,
html[data-theme="dark"] .option, html[data-theme="dark"] .empty { border-radius: 12px; }
html[data-theme="dark"] .empty { border-style: dashed; }
/* Frames that only hold an iframe: nothing to see through, nothing to blur. */
html[data-theme="dark"] .files-wrap {
  -webkit-backdrop-filter: none; backdrop-filter: none; background: rgba(2, 3, 6, 0.6);
}
html[data-theme="dark"] .stream-wrap {
  -webkit-backdrop-filter: none; backdrop-filter: none; background: #000; box-shadow: none;
}

html[data-theme="dark"] .rail {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: linear-gradient(180deg, rgba(14, 20, 32, 0.72), rgba(6, 9, 16, 0.6));
  border-right: 1px solid var(--glass-edge);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.04);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  backdrop-filter: blur(24px) saturate(140%);
}
html[data-theme="dark"] .rail nav a { color: var(--ink-soft); }
html[data-theme="dark"] .rail nav a:hover { background: rgba(190, 210, 240, 0.07); color: var(--ink); }
html[data-theme="dark"] .rail nav a.on {
  background: linear-gradient(180deg, rgba(90, 141, 255, 0.26), rgba(59, 111, 239, 0.16));
  color: #fff; box-shadow: inset 0 0 0 1px rgba(122, 164, 255, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
html[data-theme="dark"] .pub-top {
  background: linear-gradient(180deg, rgba(2, 3, 6, 0.82), rgba(2, 3, 6, 0.45));
  border-bottom-color: rgba(200, 220, 255, 0.08);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}

/* -- cards inside panels: tinted glass, no blur of their own -- */
html[data-theme="dark"] .option {
  background: rgba(190, 210, 240, 0.045);
  border-color: var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
html[data-theme="dark"] .option:hover { border-color: rgba(200, 220, 255, 0.28); }
html[data-theme="dark"] .option:has(input:checked),
html[data-theme="dark"] .gpu-offer.picked {
  background: linear-gradient(180deg, rgba(90, 141, 255, 0.22), rgba(59, 111, 239, 0.1));
  border-color: var(--edge-accent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 12px 30px -18px rgba(74, 130, 255, 0.8);
}
html[data-theme="dark"] .spark, html[data-theme="dark"] .ip-chip, html[data-theme="dark"] .toml {
  background: rgba(2, 4, 9, 0.35); border-color: var(--line);
}

/* -- headings get the landing page's tighter, brighter look -- */
html[data-theme="dark"] h1 { color: #f4f7fb; letter-spacing: -0.02em; }
html[data-theme="dark"] .gauge .runway { color: #f4f7fb; }

/* -- tables -- */
html[data-theme="dark"] th { color: var(--muted); border-bottom-color: var(--line); }
html[data-theme="dark"] td { border-bottom-color: rgba(200, 220, 255, 0.08); }
html[data-theme="dark"] tbody tr:hover td { background: rgba(190, 210, 240, 0.03); }

/* -- form controls -- */
html[data-theme="dark"] input[type=text], html[data-theme="dark"] input[type=email],
html[data-theme="dark"] input[type=password], html[data-theme="dark"] input[type=number],
html[data-theme="dark"] select, html[data-theme="dark"] textarea {
  background: rgba(2, 4, 9, 0.5);
  border-color: rgba(200, 220, 255, 0.16);
  color: var(--ink);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
}
html[data-theme="dark"] input::placeholder, html[data-theme="dark"] textarea::placeholder { color: #66748a; }
html[data-theme="dark"] input:focus, html[data-theme="dark"] select:focus, html[data-theme="dark"] textarea:focus {
  outline: none; border-color: rgba(122, 164, 255, 0.7);
  box-shadow: 0 0 0 3px rgba(74, 130, 255, 0.22), inset 0 1px 2px rgba(0, 0, 0, 0.35);
}
html[data-theme="dark"] select option { background: #0c121d; color: var(--ink); }
html[data-theme="dark"] :focus-visible { outline-color: #8fb2ff; }

/* -- buttons: ghost glass, and the landing page's blue for primary -- */
html[data-theme="dark"] button, html[data-theme="dark"] .btn {
  background: rgba(190, 210, 240, 0.07);
  border-color: var(--glass-edge);
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
}
html[data-theme="dark"] button:hover, html[data-theme="dark"] .btn:hover { background: rgba(190, 210, 240, 0.13); }
html[data-theme="dark"] button.primary, html[data-theme="dark"] .btn.primary {
  color: #fff;
  background: linear-gradient(180deg, #5a8dff, #3b6fef);
  border-color: rgba(160, 190, 255, 0.55);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 10px 26px -12px rgba(74, 130, 255, 0.9);
}
html[data-theme="dark"] button.primary:hover, html[data-theme="dark"] .btn.primary:hover {
  background: linear-gradient(180deg, #6a99ff, #4679f5);
}
html[data-theme="dark"] button.danger { color: var(--warn); border-color: var(--edge-warn); }
html[data-theme="dark"] button.danger:hover { background: var(--tint-warn); }
html[data-theme="dark"] .theme-switch button { background: transparent; box-shadow: none; border: 0; color: var(--muted); }
html[data-theme="dark"] .theme-switch button:hover { color: var(--ink); background: transparent; }
html[data-theme="dark"] .theme-switch button[aria-checked="true"] {
  background: linear-gradient(180deg, rgba(90, 141, 255, 0.35), rgba(59, 111, 239, 0.22)); color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

/* -- power controls -- */
html[data-theme="dark"] .pwr-start {
  color: #fff; border-color: rgba(120, 230, 180, 0.5);
  background: linear-gradient(180deg, #2fb57a, #1f8e5e);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 10px 24px -14px rgba(63, 207, 142, 0.8);
}
html[data-theme="dark"] .pwr-start:hover { background: linear-gradient(180deg, #36c486, #239a67); }
html[data-theme="dark"] .pwr-restart { color: #8fb2ff; border-color: var(--edge-accent); }
html[data-theme="dark"] .pwr-restart:hover { background: var(--accent-soft); }
html[data-theme="dark"] .pwr-shutdown { color: var(--meter); border-color: var(--edge-meter); background: var(--tint-meter); }
html[data-theme="dark"] .pwr-shutdown:hover { background: rgba(242, 171, 94, 0.2); }
html[data-theme="dark"] .pwr-force {
  color: #fff; border-color: rgba(255, 150, 140, 0.5);
  background: linear-gradient(180deg, #e0574b, #b83b31);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
}
html[data-theme="dark"] .pwr-force:hover { background: linear-gradient(180deg, #ea6458, #c4443a); }
html[data-theme="dark"] .pwr:disabled, html[data-theme="dark"] .pwr:disabled:hover {
  background: rgba(190, 210, 240, 0.04); border-color: var(--line); color: var(--muted); box-shadow: none;
}

/* -- status colours that were hard-coded for white -- */
html[data-theme="dark"] .flash.error { background: var(--tint-warn); border-color: var(--edge-warn); color: #ffc9c3; }
html[data-theme="dark"] .flash.success { background: var(--tint-ok); border-color: var(--edge-ok); color: #b9f1d6; }
html[data-theme="dark"] .flash.info { background: var(--accent-soft); border-color: var(--edge-accent); }
html[data-theme="dark"] .pill { background: rgba(190, 210, 240, 0.07); border-color: var(--line); color: var(--ink-soft); }
html[data-theme="dark"] .pill.missing { background: var(--tint-warn); border-color: var(--edge-warn); color: #ffb3ab; }
html[data-theme="dark"] .pill.vgpu, html[data-theme="dark"] .pill.busy { background: var(--tint-meter); border-color: var(--edge-meter); color: #ffcf96; }
html[data-theme="dark"] .pill.free { background: var(--tint-ok); border-color: var(--edge-ok); color: #a9efcc; }
html[data-theme="dark"] .state.running::before { box-shadow: 0 0 8px rgba(63, 207, 142, 0.75); }
html[data-theme="dark"] .state.creating::before { box-shadow: 0 0 8px rgba(111, 155, 255, 0.8); }
html[data-theme="dark"] .state.suspended::before, html[data-theme="dark"] .state.error::before {
  box-shadow: 0 0 8px rgba(255, 125, 114, 0.7);
}
html[data-theme="dark"] .gpu-vendor { color: #b9e06a; background: rgba(140, 200, 40, 0.12); border-color: rgba(160, 210, 80, 0.35); }
html[data-theme="dark"] .gpu-vendor:has(img) { background: transparent; border-color: transparent; }
html[data-theme="dark"] .terms mark.todo { background: rgba(255, 200, 80, 0.2); color: #ffd98a; }
html[data-theme="dark"] .demo-timer { background: rgba(190, 210, 240, 0.07); border-color: var(--line); }
html[data-theme="dark"] .demo-timer.low { color: var(--warn); border-color: var(--edge-warn); background: var(--tint-warn); }
html[data-theme="dark"] .svc-dot.ok { background: var(--ok); box-shadow: 0 0 8px rgba(63, 207, 142, 0.7); }
html[data-theme="dark"] .svc-dot.bad { box-shadow: 0 0 0 3px var(--tint-warn); }
html[data-theme="dark"] .build, html[data-theme="dark"] .admin-panel,
html[data-theme="dark"] .admin-banner { border-color: var(--edge-accent); }
html[data-theme="dark"] .admin-banner {
  background: linear-gradient(180deg, rgba(90, 141, 255, 0.2), rgba(59, 111, 239, 0.08));
}
html[data-theme="dark"] .stream-prep.failed { border-color: var(--edge-warn); }
html[data-theme="dark"] .fwd-table tr.changed td { background: rgba(74, 130, 255, 0.12); }
html[data-theme="dark"] .company img { opacity: .9; }

/* -- meters, progress, graphs -- */
html[data-theme="dark"] .track, html[data-theme="dark"] .bar, html[data-theme="dark"] .build-track {
  background: rgba(2, 4, 9, 0.55); border-color: var(--line);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
}
html[data-theme="dark"] .track i { background: linear-gradient(90deg, #c97a2e, var(--meter)); box-shadow: 0 0 12px rgba(242, 171, 94, 0.5); }
html[data-theme="dark"] .track i.low { background: var(--warn); box-shadow: 0 0 12px rgba(255, 125, 114, 0.5); }
html[data-theme="dark"] .bar i { background: linear-gradient(90deg, #3b6fef, #7aa4ff); }
html[data-theme="dark"] .build-track i { background-color: #4a82ff; box-shadow: 0 0 14px rgba(74, 130, 255, 0.6); }
html[data-theme="dark"] .build-track.failed i { background-color: var(--warn); }
html[data-theme="dark"] .build-track.done i { background-color: var(--ok); }
html[data-theme="dark"] .spark-line { stroke: #7aa4ff; filter: drop-shadow(0 0 4px rgba(74, 130, 255, 0.6)); }
html[data-theme="dark"] .spark-area { fill: #4a82ff; opacity: .18; }
html[data-theme="dark"] .spark-grid { stroke: rgba(200, 220, 255, 0.09); }
html[data-theme="dark"] .spark-hair { stroke: rgba(228, 235, 244, 0.5); }
html[data-theme="dark"] .spark-tip { background: rgba(12, 18, 29, 0.92); border: 1px solid var(--glass-edge); color: var(--ink); }
html[data-theme="dark"] .spark-dot { background: #7aa4ff; box-shadow: 0 0 0 2px #05080f, 0 0 8px rgba(74, 130, 255, 0.8); }


/* Browsers without backdrop-filter: a solid, slightly lighter glass. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  html[data-theme="dark"] .panel, html[data-theme="dark"] .gauge, html[data-theme="dark"] .empty,
  html[data-theme="dark"] .flash, html[data-theme="dark"] .rail { background: rgba(16, 22, 34, 0.94); }
}


/* ---- the stream on the portal's own page ----
   The stream is sent at the person's whole display size, so the box it is
   shown in has the display's shape (--stream-ar, set by static/stream.js)
   and is as big as the page allows: no black bars, no frame around it, and
   going full screen just shows the same picture larger. */
.content:has(> .stream-wrap) { max-width: none; }
.stream-wrap {
  position: relative; border: 0; border-radius: 8px; background: #000; box-shadow: none;
  aspect-ratio: var(--stream-ar, 16 / 9);
  width: min(100%, calc((100vh - 150px) * var(--stream-ar-n, 1.7778)));
  height: auto; min-height: 0; margin: 0 auto 16px;
}
.stream-wrap iframe, .stream-wrap.enhanced iframe {
  position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; border: 0; background: #000;
}
.stream-wrap.enhanced { height: auto; min-height: 0; }
.stream-wrap:fullscreen, .stream-wrap.enhanced:fullscreen {
  aspect-ratio: auto; width: 100%; height: 100%; border-radius: 0; margin: 0;
}
.stream-wrap.solo, .stream-wrap.enhanced.solo {
  position: fixed; inset: 0; aspect-ratio: auto; width: auto; height: auto; border-radius: 0; margin: 0;
}

/* =====================================================================
   Phones (and narrow windows): a slim bar on top, the sidebar as a drawer
   behind "Menu", the main places in a tab bar at the bottom, lists as
   cards, controls big enough for a thumb, and inputs at 16 px so iOS
   doesn't zoom in on them. The bars respect the notch and the home
   indicator (viewport-fit=cover + safe-area insets), which matters for the
   installed app.
   ===================================================================== */
.appbar, .tabbar, .drawer-close, .drawer-scrim { display: none; }

@media (max-width: 760px) {
  :root { --appbar-h: 54px; --tabbar-h: 58px; }
  body { overflow-x: hidden; }
  body.drawer-open { overflow: hidden; }

  /* -- top bar -- */
  .appbar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 40;
    height: calc(var(--appbar-h) + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) max(12px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left));
    background: var(--panel); border-bottom: 1px solid var(--line);
  }
  .appbar-brand { display: flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 640;
    font-size: 16px; min-width: 0; margin-right: auto; }
  .appbar-brand:hover { text-decoration: none; }
  .appbar-brand img { width: 28px; height: 28px; border-radius: 7px; flex: none; }
  .appbar-brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .appbar-balance { display: inline-flex; align-items: baseline; gap: 4px; padding: 5px 10px; border-radius: 99px;
    border: 1px solid var(--line); background: var(--panel-sunken); color: var(--ink); font-weight: 600;
    font-size: 14px; white-space: nowrap; font-variant-numeric: tabular-nums; }
  .appbar-balance small { font-weight: 500; font-size: 11.5px; color: var(--muted); }
  .appbar-balance:hover { text-decoration: none; }
  .appbar-menu { width: 42px; height: 42px; padding: 0; display: inline-flex; align-items: center;
    justify-content: center; border-radius: 10px; }

  /* -- the sidebar, as a drawer -- */
  .shell { display: block; }
  .rail {
    position: fixed; z-index: 60; top: 0; bottom: 0; left: 0; width: min(84vw, 320px); height: auto;
    padding: calc(18px + env(safe-area-inset-top)) 16px calc(18px + env(safe-area-inset-bottom))
             max(16px, env(safe-area-inset-left));
    overflow-y: auto; overscroll-behavior: contain; border-right: 1px solid var(--line);
    transform: translateX(-105%); transition: transform .22s ease; visibility: hidden;
    box-shadow: 0 0 40px rgba(0, 0, 0, .35);
  }
  body.drawer-open .rail { transform: none; visibility: visible; }
  .drawer-close { display: inline-flex; position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 12px;
    width: 38px; height: 38px; padding: 0; align-items: center; justify-content: center; border-radius: 10px; }
  .drawer-scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(4, 8, 16, .5);
    -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
  .drawer-scrim[hidden] { display: none; }
  .rail nav a { padding: 11px 12px; font-size: 15.5px; }
  .rail .group, .rail .foot { display: block; }
  .rail .foot { margin-top: 18px; }

  /* -- bottom tab bar -- */
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; z-index: 40; left: 0; right: 0; bottom: 0;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    background: var(--panel); border-top: 1px solid var(--line);
  }
  .tabbar a, .tabbar button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    color: var(--muted); font: inherit; font-size: 11px; font-weight: 560; background: none; border: 0;
    border-radius: 0; padding: 0; min-height: 0; box-shadow: none; cursor: pointer;
  }
  .tabbar a:hover, .tabbar button:hover { text-decoration: none; background: none; color: var(--ink); }
  .tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8;
    stroke-linecap: round; stroke-linejoin: round; }
  .tabbar a.on { color: var(--accent); }

  /* -- the page -- */
  .content { padding: 18px max(14px, env(safe-area-inset-right))
             calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 28px) max(14px, env(safe-area-inset-left));
             max-width: none; }
  h1 { font-size: 22px; }
  .lede { margin-bottom: 16px; }
  .panel { padding: 16px 14px; border-radius: 10px; overflow-x: auto; }
  .gauge { padding: 18px 16px; }
  .gauge .runway { font-size: 36px; }
  .split { flex-wrap: wrap; align-items: flex-start; }
  .split > .actions { width: 100%; }
  .actions > form { display: contents; }
  .stat b { font-size: 19px; }
  .usage-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .spark { padding: 10px 10px 8px; }
  .spark svg { height: 70px; }
  .row > .field { min-width: 100%; }
  .filters .field { min-width: 100%; }
  .options, .options.nodes { grid-template-columns: 1fr; }

  /* thumbs, and no zooming in on focus (iOS zooms anything under 16 px) */
  input[type=text], input[type=email], input[type=password], input[type=number], select, textarea { font-size: 16px; }
  button, .btn { min-height: 42px; padding: 9px 14px; }
  button.copy { min-height: 32px; }
  .stepper button { width: 42px; min-height: 42px; }
  .option .stepper input { width: 64px; min-height: 42px; }
  .theme-switch button { min-height: 34px; padding: 4px 12px; }
  .power .pwr { flex: 1 1 auto; justify-content: center; }
  .power.compact .pwr { flex: 0 0 auto; min-width: 46px; }
  .hide-phone { display: none !important; }
  .stream-cta { flex-direction: column; align-items: stretch; }
  .stream-cta .btn.big, .stream-cta button.big { text-align: center; }

  /* the builder's price bar stays in view above the tab bar */
  #builder > .panel:last-child, #buildForm > .panel:last-child {
    position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px); z-index: 5;
  }
  #builder > .panel:last-child .runway { font-size: 19px !important; white-space: nowrap; }
  #builder > .panel:last-child, #buildForm > .panel:last-child { padding: 12px 14px; background: var(--panel);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, .12); }
  #builder > .panel:last-child button.primary, #buildForm > .panel:last-child button.primary {
    white-space: nowrap; flex: none; padding: 10px 16px; }
  #buildForm > .panel:last-child h3 { display: none; }
  #builder > .panel:last-child .split, #buildForm > .panel:last-child .split { flex-wrap: nowrap; align-items: center; }
  #builder > .panel:last-child .split > div, #buildForm > .panel:last-child .split > div { min-width: 0; }
  #builder > .panel:last-child #breakdown { display: none; }

  /* -- lists as cards: table.stack (labels from the header, static/shell.js) -- */
  table.stack thead { display: none; }
  table.stack, table.stack tbody { display: block; width: 100%; }
  table.stack tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; padding: 12px 0;
    border-bottom: 1px solid var(--line); }
  table.stack tr:last-child { border-bottom: 0; }
  table.stack td { display: block; padding: 0; border: 0; text-align: left; min-width: 0; overflow-wrap: anywhere; }
  table.stack td[data-label]::before { content: attr(data-label); display: block; font-size: 11.5px;
    font-weight: 560; color: var(--muted); margin-bottom: 1px; }
  table.stack td:first-child { grid-column: 1 / -1; font-size: 15.5px; }
  table.stack td:first-child::before { display: none; }
  table.stack td.num { text-align: left; }
  table.stack td.wide, table.stack td:has(.actions), table.stack td:has(form) { grid-column: 1 / -1; }
  table.stack td .actions { justify-content: flex-start !important; }

  /* -- streaming: as big as the phone allows -- */
  .stream-wrap { width: 100%; border-radius: 8px; }
  body.page-stream .stream-rotate { display: block; margin: 0 0 10px; }
}

/* A phone on its side: the stream takes the whole screen, with a small
   button back. (iOS can't put a frame in full screen, so this is how a
   stream gets the whole display there.) */
.stream-rotate, .stream-exit { display: none; }
@media (max-width: 960px) and (max-height: 520px) and (orientation: landscape) {
  body.page-stream .appbar, body.page-stream .tabbar, body.page-stream .content > .split,
  body.page-stream .content > .flash, body.page-stream .admin-banner, body.page-stream .stream-rotate { display: none !important; }
  body.page-stream .stream-wrap:not([hidden]) {
    position: fixed; inset: 0; z-index: 70; width: auto; height: auto; aspect-ratio: auto;
    margin: 0; border-radius: 0;
  }
  body.page-stream .stream-wrap:not([hidden]) ~ .stream-exit { display: inline-flex; }
}
/* The Fullscreen button where the browser has no full screen for a frame
   (iPhone): the same whole-window layout, in either orientation. */
body.stream-immersive { overflow: hidden; }
body.stream-immersive .appbar, body.stream-immersive .tabbar { display: none !important; }
body.stream-immersive .stream-wrap:not([hidden]) {
  position: fixed; inset: 0; z-index: 70; width: auto; height: auto; aspect-ratio: auto;
  margin: 0; border-radius: 0;
}
body.stream-immersive .stream-wrap:not([hidden]) ~ .stream-exit { display: inline-flex; }
.stream-exit {
  position: fixed; z-index: 75; top: max(8px, env(safe-area-inset-top)); left: max(8px, env(safe-area-inset-left));
  align-items: center; gap: 6px; min-height: 34px; padding: 4px 12px; border-radius: 99px;
  font-size: 13px; color: #fff; background: rgba(10, 14, 22, .6); border: 1px solid rgba(255, 255, 255, .2);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); opacity: .75;
}
.stream-exit:hover { opacity: 1; color: #fff; text-decoration: none; }

/* -- phones, dark theme: the bars are glass too -- */
@media (max-width: 760px) {
  html[data-theme="dark"] .appbar, html[data-theme="dark"] .tabbar {
    background: linear-gradient(180deg, rgba(10, 14, 24, .82), rgba(4, 6, 12, .72));
    border-color: var(--glass-edge);
    -webkit-backdrop-filter: blur(18px) saturate(140%); backdrop-filter: blur(18px) saturate(140%);
  }
  html[data-theme="dark"] .rail {
    position: fixed; top: 0; height: auto;
    background: linear-gradient(180deg, rgba(14, 20, 32, .94), rgba(6, 9, 16, .92));
  }
  html[data-theme="dark"] .appbar-balance { background: rgba(190, 210, 240, .07); border-color: var(--glass-edge); }
  html[data-theme="dark"] .tabbar a.on { color: #8fb2ff; }
  html[data-theme="dark"] .tabbar a, html[data-theme="dark"] .tabbar button { background: none; box-shadow: none; border: 0; }
  html[data-theme="dark"] .panel { border-radius: 12px; }
  html[data-theme="dark"] #builder > .panel:last-child, html[data-theme="dark"] #buildForm > .panel:last-child {
    background: linear-gradient(180deg, rgba(22, 32, 52, .94), rgba(10, 14, 24, .94));
  }
}

/* ---- stream toolbar (templates/_stream_toolbar.html, static/stream_tools.js) ---- */
.stream-tools { margin: 0 0 12px; position: relative; z-index: 20; }
.stream-tools[hidden] { display: none; }
.tools-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tool { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; font-size: 13.5px; }
.tool svg, .tools-handle svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tool-exit { margin-left: auto; }
.tool-menu { position: relative; display: inline-block; }
.tool-pop { position: absolute; top: calc(100% + 6px); left: 0; z-index: 90; min-width: 240px; padding: 6px;
  display: flex; flex-direction: column; gap: 2px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 14px 34px rgba(0, 0, 0, .2);
  max-height: min(72vh, 620px); overflow-y: auto; overscroll-behavior: contain; }
.tool-pop[hidden] { display: none; }
.tool-pop button { text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: 6px;
  box-shadow: none; min-height: 0; font-size: 14px; }
.tool-pop button:hover { background: var(--panel-sunken); }
.tool-pop button small { display: block; font-size: 11.5px; color: var(--muted); font-weight: 400; }
.tool-pop button[aria-checked="true"] { color: var(--accent); background: var(--accent-soft); }
.tool-pop hr { border: 0; border-top: 1px solid var(--line); margin: 4px 2px; }
.pop-title { margin: 4px 10px 2px; font-size: 12px; color: var(--muted); font-weight: 600; }
.touch-only { display: none !important; }
.has-touch .touch-only { display: inline-flex !important; }
.has-touch .tool-menu.touch-only { display: inline-block !important; }
.no-stream .ml-only { display: none !important; }
.has-touch .desk-only { display: none !important; }
.no-stream .stream-only { display: none !important; }
.quality-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px 14px; margin: 4px 0 12px; }
.quality-grid .field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; margin: 0; }
.quality-grid select { font-weight: 400; }
.tool-capture[aria-pressed="true"] { color: #fff; background: var(--accent); border-color: var(--accent); }
.pop-shortcuts { padding: 2px 10px 6px; font-size: 12.5px; }
.pop-shortcuts dl { margin: 0; display: grid; gap: 2px 0; }
.pop-shortcuts dt { margin-top: 6px; white-space: nowrap; }
.pop-shortcuts dd { margin: 0; color: var(--muted); }
.stream-tools kbd { display: inline-block; padding: 0 5px; border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 4px; font: 600 11px/1.6 var(--mono, ui-monospace, monospace); background: var(--panel-sunken); }
.stream-tools:not(.connected) .ml-only > .tool, .stream-tools:not(.connected) .tool.ml-only,
.stream-tools:not(.connected) .tools-panel .ml-only { opacity: .45; pointer-events: none; }
.kbd-proxy { position: fixed; left: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; font-size: 16px;
  border: 0; padding: 0; pointer-events: none; }
.tools-panel { margin-top: 10px; padding: 14px 16px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; }
.tools-panel[hidden] { display: none; }
.tools-panel textarea { font-family: var(--sans); font-size: 14px; min-height: 90px; margin-bottom: 10px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.panel-head h3 { margin: 0; }
.panel-x { padding: 2px 9px; min-height: 0; }
.files-bar { display: flex; gap: 8px; align-items: center; }
.files-bar .js-path { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files-bar button { padding: 4px 10px; min-height: 0; }
.files-list { max-height: 280px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; margin: 8px 0; }
.files-list > .hint { padding: 10px 12px; margin: 0; }
.file-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%;
  padding: 8px 12px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: none;
  color: var(--ink); text-align: left; font-size: 14px; box-shadow: none; min-height: 0; }
.file-row:last-child { border-bottom: 0; }
.file-row:hover { background: var(--panel-sunken); text-decoration: none; }
.file-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { flex: none; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.dropzone { display: block; border: 1.5px dashed var(--line); border-radius: 10px; padding: 14px; text-align: center;
  cursor: pointer; color: var(--muted); font-size: 13.5px; margin: 0; }
.dropzone input { display: none; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.tools-handle { display: none; }

/* Floating: the own-window page, a phone on its side, and the iPhone
   whole-window view -- a small "Controls" handle at the top that opens
   the bar (icons only) over the stream. */
.stream-tools.floating, body.stream-immersive .stream-tools {
  position: fixed; z-index: 80; top: max(8px, env(safe-area-inset-top)); left: 50%;
  transform: translateX(-50%); margin: 0; width: max-content; max-width: calc(100vw - 16px);
}
.stream-tools.floating .tools-handle, body.stream-immersive .stream-tools .tools-handle {
  display: inline-flex; align-items: center; gap: 6px; margin: 0 auto; padding: 4px 12px; min-height: 30px;
  font-size: 12.5px; color: #fff; border-radius: 99px; background: rgba(10, 14, 22, .62);
  border: 1px solid rgba(255, 255, 255, .18); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  opacity: .7; box-shadow: none;
}
.stream-tools.floating .tools-handle:hover, body.stream-immersive .stream-tools .tools-handle:hover { opacity: 1; }
.stream-tools.floating:not(.open) .tools-row, .stream-tools.floating:not(.open) .tools-panel,
body.stream-immersive .stream-tools:not(.open) .tools-row,
body.stream-immersive .stream-tools:not(.open) .tools-panel { display: none; }
.stream-tools.floating .tools-row, body.stream-immersive .stream-tools .tools-row {
  margin-top: 6px; flex-wrap: nowrap; overflow-x: auto; padding: 5px; border-radius: 12px;
  background: rgba(10, 14, 22, .82); border: 1px solid rgba(255, 255, 255, .15);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.stream-tools.floating .tool span, body.stream-immersive .stream-tools .tool span { display: none; }
.stream-tools.floating .tool, body.stream-immersive .stream-tools .tool {
  color: #fff; background: transparent; border-color: transparent; box-shadow: none; padding: 7px 9px; }
.stream-tools.floating .tool:hover, body.stream-immersive .stream-tools .tool:hover { background: rgba(255, 255, 255, .1); }
.stream-tools.floating .tool-exit, body.stream-immersive .stream-tools .tool-exit { margin-left: 0; }
.stream-tools.floating .tools-panel, body.stream-immersive .stream-tools .tools-panel {
  width: min(560px, calc(100vw - 16px)); max-height: 70vh; overflow: auto; }
/* in a floating bar the menus can't hang off a scrolling row; they open as a sheet under it */
.stream-tools.floating .tool-menu, body.stream-immersive .stream-tools .tool-menu { position: static; }
.stream-tools.floating .tool-pop, body.stream-immersive .stream-tools .tool-pop {
  left: 50%; transform: translateX(-50%); top: calc(100% + 6px); }

@media (max-width: 960px) and (max-height: 520px) and (orientation: landscape) {
  body.page-stream .stream-tools {
    position: fixed; z-index: 80; top: max(6px, env(safe-area-inset-top)); left: 50%;
    transform: translateX(-50%); margin: 0; width: max-content; max-width: calc(100vw - 16px);
  }
  body.page-stream .stream-tools .tools-handle {
    display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; min-height: 30px; font-size: 12.5px;
    color: #fff; border-radius: 99px; background: rgba(10, 14, 22, .62); border: 1px solid rgba(255, 255, 255, .18);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); opacity: .7; box-shadow: none;
  }
  body.page-stream .stream-tools:not(.open) .tools-row, body.page-stream .stream-tools:not(.open) .tools-panel { display: none; }
  body.page-stream .stream-tools .tools-row { margin-top: 6px; flex-wrap: nowrap; overflow-x: auto; padding: 5px;
    border-radius: 12px; background: rgba(10, 14, 22, .82); border: 1px solid rgba(255, 255, 255, .15); }
  body.page-stream .stream-tools .tool span { display: none; }
  body.page-stream .stream-tools .tool { color: #fff; background: transparent; border-color: transparent;
    box-shadow: none; min-height: 36px; padding: 6px 9px; }
  body.page-stream .stream-tools .tool-exit { margin-left: 0; }
  body.page-stream .stream-tools .tool-menu { position: static; }
  body.page-stream .stream-tools .tool-pop { left: 50%; transform: translateX(-50%); max-height: 70vh; overflow: auto; }
  body.page-stream .stream-tools .tools-panel { width: min(560px, calc(100vw - 16px)); max-height: 75vh; overflow: auto; }
}

/* dark theme: the menus and panels are glass like everything else */
html[data-theme="dark"] .tool-pop, html[data-theme="dark"] .tools-panel {
  background: linear-gradient(180deg, rgba(22, 32, 52, .96), rgba(10, 14, 24, .96));
  border-color: var(--glass-edge); box-shadow: 0 18px 40px rgba(0, 0, 0, .55);
}
html[data-theme="dark"] .tool-pop button { background: transparent; box-shadow: none; }
html[data-theme="dark"] .tool-pop button:hover { background: rgba(190, 210, 240, .08); }
html[data-theme="dark"] .file-row { background: none; box-shadow: none; }
html[data-theme="dark"] .file-row:hover { background: rgba(190, 210, 240, .06); }

/* The logo: its dark-background version in dark theme (assets/cloudstream-logo-dark) */
.logo-img-dark { display: none !important; }
html[data-theme="dark"] .logo-img.has-dark { display: none !important; }
html[data-theme="dark"] .logo-img-dark { display: block !important; }

/* Build page: "Create from scratch", the first and biggest choice */
.option-scratch { display: flex; align-items: center; gap: 14px; grid-column: 1 / -1; padding: 18px 20px;
  border: 2px dashed var(--accent); background: var(--accent-soft); color: inherit; text-decoration: none; }
.option-scratch:hover { border-style: solid; text-decoration: none; }
.option-scratch b { font-size: 17px; }
.option-scratch .scratch-icon { flex: none; width: 46px; height: 46px; border-radius: 12px; background: var(--accent);
  display: grid; place-items: center; }
.option-scratch .scratch-icon svg { width: 26px; height: 26px; fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; }
@media (max-width: 560px) { .option-scratch { padding: 14px; } .option-scratch b { font-size: 16px; } }
.tool-pop .pop-sub { margin-top: 6px; }

/* A short message over the stream / console (capture, clipboard shortcuts) */
.stream-note { position: absolute; left: 50%; top: 14px; z-index: 30; transform: translate(-50%, -10px);
  max-width: min(92%, 560px); padding: 9px 16px; border-radius: 10px; pointer-events: none; opacity: 0;
  background: rgba(12, 18, 29, .9); border: 1px solid rgba(200, 220, 255, .22); color: #fff; font-size: 13.5px;
  text-align: center; transition: opacity .18s ease, transform .18s ease; backdrop-filter: blur(10px); }
.stream-note.show { opacity: 1; transform: translate(-50%, 0); }
.stream-note.bad { border-color: rgba(255, 120, 110, .55); }
.stream-note kbd { display: inline-block; padding: 0 5px; border-radius: 4px; border: 1px solid rgba(255,255,255,.3);
  font: 600 11.5px/1.5 ui-monospace, monospace; background: rgba(255,255,255,.08); }

/* Money next to credits, for administrators (eur() in templates) */
.eur { color: var(--muted); font-weight: 400; font-size: .86em; white-space: nowrap; font-variant-numeric: tabular-nums; }
.stat span .eur { display: block; margin-top: 2px; }

/* A machine's activity log (_activity_rows.html) */
table.activity { width: 100%; }
table.activity td { vertical-align: top; padding-top: 7px; padding-bottom: 7px; }
table.activity td.when { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); width: 1%; }
table.activity td.who { white-space: nowrap; text-align: right; width: 1%; }
table.activity .act-detail { display: block; margin-top: 2px; word-break: break-word; }
table.activity tr.bad td.what { color: var(--warn); }
.act-kind { display: inline-block; font-size: 11.5px; line-height: 1; padding: 4px 7px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.act-power { color: var(--accent); border-color: currentColor; }
.act-billing, .act-server { color: var(--meter); border-color: currentColor; }
.act-build { color: var(--ok); border-color: currentColor; }
@media (max-width: 640px) {
  table.activity td.who { display: none; }
}
