/* jasondent.com: one stylesheet for the public page, /apps and /admin.
   Brand (2026-10-02): "cozy midnight forest". Dentwood's colours, Make a
   Dent's style: Bricolage Grotesque headings, Atkinson Hyperlegible text,
   chunky 2 px outlines and offset shadows, the dented-ball mark.
   Midnight is the default; theme.js sets <html data-theme> to "dark",
   "light" (forest by day) or "system" (follow the OS). */

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/assets/fonts/bricolage-grotesque.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("/assets/fonts/atkinson-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("/assets/fonts/atkinson-700.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("/assets/fonts/atkinson-400-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

/* Midnight (default): a near-black night sky with cartoon stars; the forest
   green lives on in the top bar and the offset shadows. */
:root {
  color-scheme: dark;
  --bg: #0a0c0b;
  --bg-glow-1: transparent;
  --bg-glow-2: transparent;
  --surface: #141816;
  --surface-2: #1b201d;
  --header: rgba(19, 30, 24, 0.95);
  --text: #e8ece8;
  --muted: #a4afa8;
  --line: #2a312d;
  --sky: url("/assets/sky.svg");
  /* Text sits on a soft patch of plain sky (see "Star-free halo"). */
  --halo: 0 0 26px 18px var(--bg);
  --halo-bg: var(--bg);
  --accent: #d99566;
  --accent-hover: #e8ab80;
  --accent-soft: rgba(217, 149, 102, 0.15);
  --accent-text: #1a120c;
  --pop: #2f5d46;
  --ok: #7fd1a0;
  --warn: #f0c36a;
  --danger: #f08a7a;
  --shadow: 5px 5px 0 var(--pop);
  --shadow-hover: 7px 7px 0 var(--pop);
  --radius: 20px;
  --radius-sm: 12px;
  --font: "Atkinson Hyperlegible", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Bricolage Grotesque", "Atkinson Hyperlegible", ui-sans-serif, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
}

/* Forest by day. */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eef1ea;
  --bg-glow-1: rgba(185, 119, 79, 0.10);
  --bg-glow-2: rgba(47, 93, 70, 0.10);
  --surface: #fbfcf8;
  --surface-2: #e3e9dd;
  --header: rgba(238, 241, 234, 0.86);
  --text: #1e2b24;
  --muted: #4c5e53;
  --line: #c3cfbd;
  --sky: none;
  --halo: none;
  --halo-bg: transparent;
  --accent: #2f5d46;
  --accent-hover: #234a37;
  --accent-soft: rgba(47, 93, 70, 0.12);
  --accent-text: #f6f8f3;
  --pop: #b9774f;
  --ok: #23784d;
  --warn: #9a5b14;
  --danger: #b8382a;
}
@media (prefers-color-scheme: light) {
  :root[data-theme="system"] {
    color-scheme: light;
    --bg: #eef1ea;
    --bg-glow-1: rgba(185, 119, 79, 0.10);
    --bg-glow-2: rgba(47, 93, 70, 0.10);
    --surface: #fbfcf8;
    --surface-2: #e3e9dd;
    --header: rgba(238, 241, 234, 0.86);
    --text: #1e2b24;
    --muted: #4c5e53;
    --line: #c3cfbd;
  --sky: none;
  --halo: none;
  --halo-bg: transparent;
    --accent: #2f5d46;
    --accent-hover: #234a37;
    --accent-soft: rgba(47, 93, 70, 0.12);
    --accent-text: #f6f8f3;
    --pop: #b9774f;
    --ok: #23784d;
    --warn: #9a5b14;
    --danger: #b8382a;
  }
}

/* --- Base ------------------------------------------------------------------ */

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(60rem 40rem at 15% -10%, var(--bg-glow-1), transparent 60%),
    radial-gradient(50rem 35rem at 100% 0%, var(--bg-glow-2), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 16px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s, color 0.2s;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }

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

.wrap { max-width: 64rem; margin: 0 auto; padding: 0 20px; }

main { padding-bottom: 48px; }

h1 { font-size: clamp(1.8rem, 1.2rem + 2.2vw, 2.6rem); line-height: 1.15; letter-spacing: -0.025em; margin: 8px 0 12px; }
h2 { font-size: 1.25rem; letter-spacing: -0.01em; margin: 40px 0 14px; }
h3 { font-size: 1.05rem; margin: 0 0 6px; }
p.lead { color: var(--muted); font-size: 1.15rem; margin-top: 0; max-width: 42rem; }
.meta { color: var(--muted); font-size: 14px; }

code, .mono { font-family: var(--mono); font-size: 0.9em; overflow-wrap: anywhere; }
code { background: var(--surface-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; }

/* --- Header ---------------------------------------------------------------- */

header.top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 0;
  margin-bottom: 28px;
}
/* Full-width bar while the content stays in .wrap. A pseudo-element rather
   than clip-path, which would also cut off the account menu dropping below. */
header.top::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 100vw;
  margin-left: -50vw;
  z-index: -1;
  background: var(--header);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}
html, body { overflow-x: clip; }

header.top .brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--text);
}
header.top .brand::before {
  content: "";
  width: 32px;
  height: 32px;
  /* Plays the moon's phases once per page load, then rests as the mark. */
  background: url("/assets/moon-once.svg") center / contain no-repeat;
}
@media (prefers-reduced-motion: reduce) {
  header.top .brand::before { background-image: url("/assets/mark.svg"); }
}

header.top nav { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
header.top nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 999px;
  transition: background-color 0.15s, color 0.15s;
}
header.top nav a:hover { color: var(--text); background: var(--surface-2); }
header.top nav a.active { color: var(--text); background: var(--accent-soft); }
header.top nav .who { padding: 0 6px; overflow-wrap: anywhere; }

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
}
.theme-toggle:hover { color: var(--text); background: var(--surface-2); border-color: var(--line); }
.theme-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* --- Cards and layout ------------------------------------------------------ */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
section > .card + .card, main > .card + .card, main > div > .card + .card { margin-top: 16px; }
.card h2 { margin-top: 0; font-size: 1.1rem; }
.card .meta { margin: 0 0 12px; }
.card .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; align-items: center; }

.grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); }
.grid > .card { transition: transform 0.15s, box-shadow 0.15s; }
.grid > .card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.grid > .card h3 { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 1.15rem; }

.step h2 { display: flex; align-items: center; gap: 10px; }
.step-mark {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--line);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
}
.step.done .step-mark { background: var(--ok); border-color: var(--ok); color: #fff; }
.step.done { border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); }

/* --- Controls -------------------------------------------------------------- */

button, .button {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, transform 0.05s;
}
button:hover, .button:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-text); }
button:active, .button:active { transform: translateY(1px); }

button.secondary, .button.secondary { background: transparent; color: var(--accent); border-color: var(--line); }
button.secondary:hover, .button.secondary:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-soft); }

button.danger { background: transparent; border-color: var(--line); color: var(--danger); }
button.danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); border-color: var(--danger); color: var(--danger); }

button:disabled, button:disabled:hover { opacity: 0.5; cursor: default; transform: none; }

input, select {
  font: inherit;
  font-size: 14px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  max-width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }

form.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.checks { display: flex; gap: 8px; flex-wrap: wrap; }
.checks label {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  white-space: nowrap;
  font-size: 13px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
}

/* --- Status ---------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.running { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); border-color: transparent; }
.badge.running::before { animation: pulse 2s infinite; }
.badge.starting { color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); border-color: transparent; }
.badge.stopped { color: var(--muted); }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 60%, transparent); }
  70% { box-shadow: 0 0 0 6px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.notice {
  display: block;
  padding: 14px 18px;
  margin-bottom: 20px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
}
.notice.error {
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  border-color: color-mix(in srgb, var(--danger) 30%, transparent);
  color: var(--text);
}

/* --- Tables ---------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
th { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; background: var(--surface-2); }
tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
td .actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* --- Public home page ------------------------------------------------------ */

.hero { display: grid; grid-template-columns: auto 1fr; gap: 28px; align-items: center; padding: 40px 0 16px; }
.avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: url("/assets/mark.svg") center / 86% no-repeat;
}
.eyebrow { color: var(--accent); font-weight: 600; font-size: 14px; letter-spacing: 0.04em; text-transform: uppercase; margin: 0; }
.gradient-text { color: var(--accent); }
.hero .actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

.links { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }
.link-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.link-card:hover { color: var(--text); transform: translateY(-2px); box-shadow: var(--shadow-hover); border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.link-card .icon {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
}
.link-card .icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.link-card strong { display: block; font-size: 15px; }
.link-card span { color: var(--muted); font-size: 13px; }

/* --- Footer and helpers ---------------------------------------------------- */

footer {
  color: var(--muted);
  font-size: 14px;
  padding: 32px 0 40px;
  margin-top: 24px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.hidden { display: none !important; }

@media (max-width: 560px) {
  .hero { grid-template-columns: 1fr; gap: 18px; padding-top: 24px; }
  .avatar { width: 84px; height: 84px; font-size: 30px; border-radius: 22px; }
  header.top nav .who { display: none; }
}

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

/* --- Analytics and charts ---------------------------------------------------- */
.range { margin: 8px 0 14px; }
.range .actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.subtabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chart-box { width: 100%; margin: 6px 0; }
svg.chart { display: block; width: 100%; height: auto; touch-action: pan-y; user-select: none; }
svg.chart .grid { stroke: var(--line); stroke-width: 1; }
svg.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--font); }
svg.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; }
svg.chart .area { stroke: none; opacity: 0.14; }
svg.chart .limit { stroke: var(--danger); stroke-width: 1.5; stroke-dasharray: 5 4; }
svg.chart .limit-label { fill: var(--danger); }
svg.chart .guide { stroke: var(--muted); stroke-width: 1; }
svg.chart .band { fill: var(--accent-soft); }
svg.chart .hit { fill: transparent; cursor: crosshair; }
svg.chart .s0.line { stroke: var(--accent); } svg.chart .s0.area { fill: var(--accent); }
svg.chart .s1.line { stroke: var(--ok); } svg.chart .s1.area { fill: var(--ok); }
svg.chart .s2.line { stroke: var(--warn); } svg.chart .s2.area { fill: var(--warn); }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.chart-legend .key::before { content: ""; display: inline-block; width: 12px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; background: currentColor; }
.chart-legend .key.s0 { color: var(--accent); } .chart-legend .key.s1 { color: var(--ok); } .chart-legend .key.s2 { color: var(--warn); }
.chart-tip { min-height: 2.6em; margin: 4px 0 0; }
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); margin: 6px 0 12px; }
.stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; }
.stat strong { display: block; font-size: 1.3rem; }
.who-on { font-size: 14px; margin: 0 0 4px; }
.form.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* --- Phones ------------------------------------------------------------------- */
@media (max-width: 640px) {
  .wrap { padding: 0 max(16px, env(safe-area-inset-left)) 0 max(16px, env(safe-area-inset-right)); }
  header.top { padding: 10px 0; margin-bottom: 18px; }
  h2 { margin-top: 28px; }
  .card { padding: 16px; }
  /* Big enough to tap; 16px text stops iOS zooming into inputs. */
  button, .button, input, select { min-height: 44px; font-size: 16px; }
  input[type="checkbox"] { min-height: 0; width: 20px; height: 20px; }
  .checks label { padding: 8px 12px; font-size: 15px; }
  .form.inline > input, .form.inline > select, form.inline > input { flex: 1 1 100%; }
  .range input[type="datetime-local"] { flex: 1 1 40%; }
  /* Tables become stacked cards: each cell shows its column name. */
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { padding: 10px 0; border-bottom: 1px solid var(--line); }
  table.stack td { border: 0; padding: 4px 14px; }
  table.stack td[data-label]:not([data-label=""])::before {
    content: attr(data-label); display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em;
  }
  .hero { grid-template-columns: 1fr; gap: 16px; padding-top: 16px; }
  .avatar { width: 80px; height: 80px; font-size: 28px; border-radius: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* --- Portal shell: Apps | Admin switch, account menu, section tabs ------------ */
header.top:has(> details.account) { display: grid; grid-template-columns: 1fr auto 1fr; margin-bottom: 0; }
header.top .area-title { font-weight: 700; }
header.top .switch {
  display: flex; gap: 4px; padding: 4px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
}
header.top .switch a {
  padding: 7px 22px; border-radius: 9px; font-size: 14px; font-weight: 600;
  color: var(--muted); text-decoration: none;
}
header.top .switch a:hover { color: var(--text); background: transparent; }
header.top .switch a.active { color: var(--text); background: var(--surface); box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12); }

details.account { justify-self: end; position: relative; }
details.account summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px;
  padding: 4px 12px 4px 4px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); font-size: 14px; color: var(--text);
}
details.account summary::-webkit-details-marker { display: none; }
details.account .initials {
  width: 30px; height: 30px; border-radius: 999px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700;
}
details.account .name { max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details.account .menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; width: 16rem;
  display: flex; flex-direction: column; gap: 12px; padding: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-hover);
}
details.account .menu .meta { margin: 0; overflow-wrap: anywhere; }
details.account .menu-row { display: flex; align-items: center; justify-content: space-between; font-size: 14px; }

nav.tabs {
  display: flex; gap: 28px; margin-bottom: 28px; overflow-x: auto;
  border-bottom: 1px solid var(--line);
}
nav.tabs a {
  display: inline-flex; align-items: center; gap: 8px; padding: 14px 2px 12px; white-space: nowrap;
  color: var(--muted); font-weight: 500; text-decoration: none; border-bottom: 2px solid transparent;
}
nav.tabs a:hover { color: var(--text); }
nav.tabs a.active { color: var(--accent); font-weight: 600; border-bottom-color: var(--accent); }
nav.tabs .icon { display: none; }
nav.tabs .tab-badge {
  font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px;
  color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent);
}
main > h1:first-child { margin-top: 0; }
svg.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Phones: brand and name shrink to icons; section tabs become a bottom bar. */
@media (max-width: 640px) {
  header.top .brand-name, details.account .name { display: none; }
  details.account summary { padding: 4px; }
  details.account .initials { width: 36px; height: 36px; }
  header.top .switch a { padding: 0 18px; min-height: 40px; display: flex; align-items: center; font-size: 15px; }
  nav.tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; margin: 0; gap: 0;
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
    padding: 4px 4px max(10px, env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--line); border-bottom: 0;
    box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.06);
  }
  nav.tabs.many { grid-auto-columns: minmax(84px, 1fr); }
  nav.tabs a {
    flex-direction: column; justify-content: center; gap: 2px; min-height: 52px; padding: 4px 2px;
    font-size: 12px; border-bottom: 0; position: relative; text-align: center;
  }
  nav.tabs a .label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  nav.tabs .icon { display: block; }
  nav.tabs .tab-badge { position: absolute; top: 2px; left: calc(50% + 6px); font-size: 10px; padding: 0 5px; }
  main { padding-top: 20px; padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
}

/* --- Server cards (Apps page) ----------------------------------------------- */
.group-section h2 { margin-top: 32px; }
.grid.servers { grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr)); }
.server-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.server-card .art {
  position: relative; aspect-ratio: 16 / 7; overflow: hidden;
  background: linear-gradient(135deg, #2a1712, #6b2a12);
}
.server-card .app-banner { width: 100%; height: 100%; object-fit: cover; display: block; }
.server-card.stopped .app-banner { filter: grayscale(0.7) brightness(0.7); }
.server-card .art .badge { position: absolute; top: 12px; right: 12px; background: rgba(15, 23, 42, 0.72); color: #fff; border: 0; backdrop-filter: blur(6px); }
.server-card .art .badge.running { color: #6ee7b7; }
.server-card .art .badge.starting { color: #fcd34d; }
.server-card .body { padding: 0 18px 18px; display: flex; flex-direction: column; gap: 8px; }
.server-card .title { display: flex; align-items: flex-start; gap: 12px; margin-top: -28px; }
.server-card .title > div { padding-top: 32px; min-width: 0; }
.server-card .title h3 { margin: 0; }
.server-card .title .meta { margin: 0; }
.server-card .app-icon {
  width: 56px; height: 56px; flex: none; border-radius: 14px; padding: 6px;
  background: var(--surface); box-shadow: var(--shadow); position: relative;
}
.server-card .actions { margin-top: 4px; }
button.copy { padding: 4px 10px; font-size: 13px; min-height: 0; gap: 6px; border-width: 2px; }
button.copy .icon { width: 15px; height: 15px; }
@media (max-width: 640px) { button.copy { min-height: 36px; font-size: 14px; } }
.grid > .card.server-card h3 { display: block; font-size: 1.1rem; }
.server-card .body > p.meta:empty { display: none; }

/* --- Brand: chunky outlines, offset shadows, display type --------------------- */
body {
  background:
    radial-gradient(50rem 32rem at 10% -8%, var(--bg-glow-1), transparent 60%),
    radial-gradient(60rem 40rem at 100% 0%, var(--bg-glow-2), transparent 65%),
    var(--sky) 0 0 / 640px 640px repeat,
    var(--bg);
  background-attachment: fixed;
}
h1, h2, h3, .brand, .eyebrow, details.account .initials, .stat strong {
  font-family: var(--display);
}
h1 { font-weight: 800; letter-spacing: -0.035em; }
h2 { font-weight: 800; letter-spacing: -0.02em; font-size: 1.5rem; }
h3 { font-weight: 700; letter-spacing: -0.01em; }
header.top .brand { font-weight: 800; font-size: 20px; letter-spacing: -0.02em; }
.eyebrow { color: var(--accent); }

.card, .table-wrap, .link-card {
  border: 2px solid var(--line);
  box-shadow: var(--shadow);
}
.grid > .card:hover, .link-card:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow-hover); border-color: var(--line); }

button, .button { border-width: 2px; border-radius: var(--radius-sm); font-weight: 700; }
button:not(.secondary):not(.danger):not(.theme-toggle), .button:not(.secondary) { box-shadow: 3px 3px 0 var(--pop); }
button:not(.secondary):not(.danger):not(.theme-toggle):active, .button:not(.secondary):active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--pop); }
button.secondary, .button.secondary { border-color: var(--line); }
input, select { border-width: 2px; }

.notice { border-width: 2px; }
.badge { border-width: 0; }
.badge.running { color: var(--ok); }

nav.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }
header.top .switch { border-width: 2px; }
header.top .switch a.active { background: var(--accent); color: var(--accent-text); box-shadow: 2px 2px 0 var(--pop); }
details.account summary { border-width: 2px; }
details.account .initials { background: var(--accent-soft); color: var(--accent); }

.server-card .app-icon { background: var(--surface-2); border: 2px solid var(--line); }
.server-card .art .badge { background: rgba(9, 16, 12, 0.78); }
svg.chart .s0.line { stroke: var(--accent); } svg.chart .s0.area { fill: var(--accent); }
.chart-legend .key.s0 { color: var(--accent); }

/* --- Home page ---------------------------------------------------------------- */
.home-hero {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 26rem); gap: 48px;
  align-items: center; padding: 40px 0 56px;
}
.home-hero h1 { font-size: clamp(3rem, 1.6rem + 5vw, 5.5rem); line-height: 0.95; margin: 0 0 18px; }
.home-hero .lead { font-size: 1.25rem; }
.home-hero .actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }
.cover { margin: 0; transform: rotate(1.5deg); }
.cover img {
  display: block; width: 100%; height: auto; aspect-ratio: 4 / 5; object-fit: cover;
  border: 2px solid var(--line); border-radius: var(--radius); box-shadow: 8px 8px 0 var(--pop);
}

.guide { scroll-margin-top: 90px; }
.guide h2 { margin: 4px 0 10px; font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.2rem); }
.guide .lead { margin-bottom: 28px; }
.steps {
  list-style: none; margin: 0; padding: 0; display: grid; gap: 22px;
  grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr));
}
.steps > li { position: relative; padding-top: 22px; font-size: 1.05rem; }
.steps h3 { font-size: 1.2rem; margin: 10px 0 8px; }
.steps p { margin: 0 0 10px; }
.steps p:last-child { margin-bottom: 0; }
.steps ul { margin: 0 0 10px; padding-left: 1.2em; }
.steps ul li { margin-bottom: 6px; }
.steps .num {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent); color: var(--accent-text); font: 800 1.15rem var(--display);
  box-shadow: 3px 3px 0 var(--pop);
}
.guide .rest { margin-top: 22px; font-size: 1.05rem; }
.guide .rest h3 { font-size: 1.2rem; }
.guide .rest p { margin: 0 0 10px; }
.guide .rest p:last-child { margin-bottom: 0; }
.guide-cta { margin: 32px 0 0; text-align: center; }

@media (max-width: 760px) {
  .home-hero { grid-template-columns: 1fr; gap: 32px; padding: 16px 0 40px; }
  .cover { max-width: 22rem; justify-self: center; width: 90%; }
}
@media (max-width: 480px) {
  header.top nav .wide-only { display: none; }
}

/* --- Loading screen: the animated moon (moon-loader.svg) ---------------------- */
.loader {
  min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; text-align: center; padding: 24px 0;
}
.loader img { width: 112px; height: 112px; }
.loader h1 { margin: 12px 0 0; font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.2rem); }
.loader p { margin: 0; color: var(--muted); max-width: 30rem; }
.loader .actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 14px; }

/* --- Star-free halo ------------------------------------------------------------ */
/* Stars never sit behind text: text that isn't already on a card gets a soft
   patch of plain night sky that hugs it and fades out around it (fit-content,
   so wide headings don't cut star-free bands across the page). Box-shadows
   paint below all text, so overlapping halos never cover a neighbour's words.
   :where() keeps this at zero specificity so component styles still win.
   Midnight only: --halo is none by day. */
:where(main h1, main h2, main h3, main p, main ul, main ol, main .eyebrow, main .actions,
       .loader > *, footer > *):where(:not(.card *, .table-wrap *, .card, .steps)) {
  width: fit-content;
  max-width: 100%;
  background-color: var(--halo-bg);
  box-shadow: var(--halo);
  border-radius: 14px;
}
.loader > * { margin-inline: auto; }
@media (min-width: 641px) {
  /* Desktop section tabs sit on the sky; on phones they're a solid bottom bar. */
  :where(nav.tabs a) { background-color: var(--halo-bg); box-shadow: var(--halo); }
}

/* --- Transitions ---------------------------------------------------------------- */
/* View Transitions between pages and tabs (browsers without them just switch):
   - the header stays put (site-header), its Portal | Admin highlight slides
     to the new side (area-pill) and the tab underline glides to the new tab
     (tab-ink);
   - the content slides toward where you're going: home -> portal -> admin is
     "forward", the other way "back" (theme.js sets html.vt-forward /
     html.vt-back from the URLs; sectionTabs does the same for tabs); anything
     else fades and rises;
   - the theme toggle reveals the new theme in a circle from the button
     (theme.js; html.theme-vt turns all of the above off for that one).
   Portal pages draw their header and tabs in their first frame (render-
   blocking module), so there is never a loading screen between pages. */
@view-transition { navigation: auto; }
:root { --ease-out: cubic-bezier(.2, .8, .2, 1); }
html:not(.theme-vt) header.top { view-transition-name: site-header; }
html:not(.theme-vt) main { view-transition-name: page; }
html:not(.theme-vt) header.top .switch .pill { view-transition-name: area-pill; }
/* The labels ride above the sliding pill (named after it, so they paint on top). */
html:not(.theme-vt) header.top .switch a[href="/apps/"] .label { view-transition-name: area-label-portal; }
html:not(.theme-vt) header.top .switch a[href="/admin/"] .label { view-transition-name: area-label-admin; }
html:not(.theme-vt) nav.tabs .tab-ink { view-transition-name: tab-ink; }

::view-transition-group(site-header) { animation-duration: 380ms; animation-timing-function: var(--ease-out); }
::view-transition-group(area-pill),
::view-transition-group(tab-ink) { animation-duration: 420ms; animation-timing-function: var(--ease-out); }
::view-transition-old(area-pill), ::view-transition-new(area-pill),
::view-transition-old(tab-ink), ::view-transition-new(tab-ink) { animation: none; }
::view-transition-group(area-label-portal), ::view-transition-group(area-label-admin) { animation-duration: 420ms; }

/* Content: no size morph, just its own enter/leave animations. */
::view-transition-group(page) { animation: none; }
::view-transition-old(page) { animation: 170ms ease-in both page-out; }
::view-transition-new(page) { animation: 380ms var(--ease-out) 70ms both page-in; }
html.vt-forward::view-transition-old(page) { animation-name: slide-out-left; }
html.vt-forward::view-transition-new(page) { animation-name: slide-in-right; }
html.vt-back::view-transition-old(page) { animation-name: slide-out-right; }
html.vt-back::view-transition-new(page) { animation-name: slide-in-left; }
@keyframes page-out { to { opacity: 0; transform: translateY(-6px); } }
@keyframes page-in { from { opacity: 0; transform: translateY(12px); } }
@keyframes slide-out-left { to { opacity: 0; transform: translateX(-48px); } }
@keyframes slide-in-right { from { opacity: 0; transform: translateX(48px); } }
@keyframes slide-out-right { to { opacity: 0; transform: translateX(48px); } }
@keyframes slide-in-left { from { opacity: 0; transform: translateX(-48px); } }

/* Content arriving after a section loader (portal.js reveal()). */
.reveal > * { animation: page-in 420ms var(--ease-out) both; }
.reveal > :nth-child(2) { animation-delay: 40ms; }
.reveal > :nth-child(3) { animation-delay: 80ms; }
.reveal > :nth-child(n+4) { animation-delay: 120ms; }

html.theme-vt::view-transition-old(root),
html.theme-vt::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
html.theme-vt::view-transition-new(root) { z-index: 1; }
/* Fallback for browsers without View Transitions: colours ease over. */
html.theme-fade, html.theme-fade * {
  transition: background-color 0.4s ease, color 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease !important;
}

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}

/* --- Portal | Admin highlight and tab underline as movable elements ---------- */
header.top .switch a { position: relative; }
header.top .switch a .label { position: relative; z-index: 1; }
header.top .switch a.active { background: transparent; box-shadow: none; color: var(--accent-text); }
header.top .switch .pill {
  position: absolute; inset: 0; z-index: 0; border-radius: 9px;
  background: var(--accent); box-shadow: 2px 2px 0 var(--pop);
}
nav.tabs a { position: relative; }
nav.tabs a.active { border-bottom-color: transparent; }
nav.tabs .tab-ink {
  position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  border-radius: 2px; background: var(--accent);
}
@media (max-width: 640px) {
  nav.tabs .tab-ink { top: 0; bottom: auto; left: 28%; right: 28%; height: 3px; }
}

/* --- Section loader (moon inside a content area) ------------------------------ */
.loader.section { min-height: 38vh; }
.loader.section img { width: 64px; height: 64px; }
.loader.section.small { min-height: 0; padding: 18px 0; gap: 6px; }
.loader.section.small img { width: 40px; height: 40px; }

/* --- Compact server tiles ------------------------------------------------------ */
.grid.servers { grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 16px; }
.server-card .art { aspect-ratio: 16 / 6; }
.server-card .body { padding: 0 14px 14px; gap: 6px; }
.server-card .title { margin-top: -22px; gap: 10px; }
.server-card .title > div { padding-top: 26px; }
.server-card .app-icon { width: 44px; height: 44px; border-radius: 12px; padding: 5px; }
.grid > .card.server-card h3 { font-size: 1.05rem; }
.server-card .actions { margin-top: 2px; gap: 8px; }
.server-card .actions .button, .server-card .actions button { padding: 7px 14px; }
.server-card .who-on, .server-card .body > p.meta { font-size: 13px; margin: 0; }

/* --- Header moon: tonight's phase, night or day (theme.js sets the variables) --- */
header.top .brand::before { background-image: var(--moon-once, url("/assets/moon-once.svg")); }
@media (prefers-reduced-motion: reduce) {
  header.top .brand::before { background-image: var(--moon-still, url("/assets/mark.svg")); }
}
.badge.full { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.server-card .art .badge.full { color: #fcd34d; }
.loader .who-on.faces { justify-content: center; }

/* --- Living sky (midnight only): twinkles and the odd shooting star ----------- */
/* Both sit just above the sky and below everything else (z-index -1), so text
   halos and cards still cover them. Off by day and for reduced motion. */
:root { --sky-motion: block; }
:root[data-theme="light"] { --sky-motion: none; }
@media (prefers-color-scheme: light) { :root[data-theme="system"] { --sky-motion: none; } }
body::before, body::after { content: ""; position: fixed; pointer-events: none; z-index: -1; display: var(--sky-motion); }
body::before { inset: 0; background: url("/assets/twinkle.svg") 120px 80px / 960px 960px repeat; }
/* A short streak that crosses the sky once every 23 s (moving for ~1 s). */
body::after {
  top: 12vh; left: 72vw; width: 140px; height: 2px; border-radius: 2px;
  /* Bright head on the left (the way it travels), fading tail to the upper right. */
  background: linear-gradient(90deg, rgba(243, 230, 200, 0.95), rgba(243, 230, 200, 0));
  transform-origin: left center; opacity: 0;
  animation: shooting-star 23s linear 6s infinite;
}
@keyframes shooting-star {
  0% { opacity: 0; transform: translate(0, 0) rotate(-24deg) scaleX(0.3); }
  0.8% { opacity: 1; }
  4% { opacity: 0; transform: translate(-46vw, 22vw) rotate(-24deg) scaleX(1); }
  100% { opacity: 0; transform: translate(-46vw, 22vw) rotate(-24deg) scaleX(1); }
}
@media (prefers-reduced-motion: reduce) { body::before, body::after { display: none; } }

/* --- Toasts ("Link copied") ----------------------------------------------------- */
.toasts {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 40; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
}
.toast {
  padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 700;
  background: var(--surface-2); color: var(--text); border: 2px solid var(--line); box-shadow: 3px 3px 0 var(--pop);
  animation: toast-in 260ms var(--ease-out) both;
}
.toast.leaving { animation: toast-out 380ms ease-in both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(0.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-8px); } }
@media (max-width: 640px) { .toasts { bottom: calc(88px + env(safe-area-inset-bottom)); } }

/* --- Who's on: initials bubbles ------------------------------------------------- */
.who-on.faces { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.who-on.faces .meta { margin: 0 2px 0 0; font-size: 13px; }
.face {
  width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center;
  font: 800 11px var(--display); color: var(--accent-text); background: var(--accent);
  border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line);
}
.face + .face { margin-left: -8px; }
.face.pop { animation: face-pop 520ms cubic-bezier(.3, 1.6, .5, 1) both; }
@keyframes face-pop { from { transform: scale(0); } }

/* --- Server cards changing state (apps.js nameCards + html.vt-cards) ----------- */
html.vt-cards::view-transition-old(page),
html.vt-cards::view-transition-new(page) { animation: none; }
html.vt-cards::view-transition-group(*) { animation-duration: 450ms; animation-timing-function: var(--ease-out); }

/* --- Start: the card lifts off ------------------------------------------------- */
.server-card.launching { animation: lift-off 850ms var(--ease-out) both; }
@keyframes lift-off {
  0% { transform: none; }
  35% { transform: translate(-3px, -6px) scale(1.03); box-shadow: 10px 12px 0 var(--pop), 0 0 0 3px var(--accent-soft); }
  100% { transform: none; }
}

/* --- Wake-up screen banner (grows from card size, zooms away when ready) ------- */
.launch-hero {
  position: relative; margin: 28px auto 0; width: min(100%, 44rem); aspect-ratio: 16 / 6;
  border-radius: var(--radius); overflow: hidden; border: 2px solid var(--line); box-shadow: 6px 6px 0 var(--pop);
  background: linear-gradient(135deg, #2a1712, #6b2a12);
  animation: hero-grow 700ms var(--ease-out) both;
}
.launch-hero .app-banner { width: 100%; height: 100%; object-fit: cover; display: block; }
.launch-hero-name {
  position: absolute; left: 14px; bottom: 12px; display: flex; align-items: center; gap: 10px;
  padding: 6px 14px 6px 6px; border-radius: 999px; background: rgba(10, 12, 11, 0.78); color: #e8ece8;
}
.launch-hero-name .app-icon { width: 34px; height: 34px; border-radius: 10px; }
.launch-hero-name strong { display: block; font-family: var(--display); line-height: 1.1; }
.launch-hero-name span { display: block; font-size: 12px; color: #a4afa8; }
.launch-hero.go { animation: hero-go 450ms ease-in both; }
.launch-hero + .loader { min-height: 0; padding-top: 18px; }
@keyframes hero-grow { from { opacity: 0; transform: scale(0.42) translateY(30px); border-radius: 28px; } }
@keyframes hero-go { to { opacity: 0; transform: scale(1.12); filter: blur(2px); } }

/* --- Admin: Server options and in-place backups ------------------------------- */
.grid.options { grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); }
.grid.options .card h3 { display: block; font-size: 1.05rem; }
label.field { display: flex; flex-direction: column; gap: 4px; margin: 0 0 10px; font-size: 13px; color: var(--muted); }
label.field select, label.field input { width: 100%; color: var(--text); }
tr.backups-row > td { padding: 0 10px 14px; background: color-mix(in srgb, var(--surface-2) 50%, transparent); }
tr.backups-row .card { box-shadow: none; margin-top: 10px; animation: page-in 300ms var(--ease-out) both; }

/* --- Acting as another user (admins) ----------------------------------------- */
.acting-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin: 12px 0 0; padding: 10px 14px; border-radius: var(--radius-sm); font-size: 14px;
  background: color-mix(in srgb, var(--warn) 16%, var(--surface)); border: 2px solid var(--warn); color: var(--text);
}
.acting-bar button { padding: 6px 14px; }
