/* Everdeep Editor. Colours taken from the Everdeep Dungeons trailer: gold titles outlined in dark brown, leaf greens,
   soft sky, terracotta voxel steps, heart red, mana cyan, the pink-magenta accent. */

@font-face { font-family: "Almendra"; src: url("fonts/almendra-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Almendra"; src: url("fonts/almendra-latin-ext-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; unicode-range: U+0100-024F, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Almendra"; src: url("fonts/almendra-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+FEFF, U+FFFD; }
@font-face { font-family: "Almendra"; src: url("fonts/almendra-latin-ext-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; unicode-range: U+0100-024F, U+1E00-1EFF, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Nunito"; src: url("fonts/nunito-latin-wght-normal.woff2") format("woff2"); font-weight: 200 1000; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Nunito"; src: url("fonts/nunito-latin-ext-wght-normal.woff2") format("woff2"); font-weight: 200 1000; font-display: swap; unicode-range: U+0100-024F, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Nunito"; src: url("fonts/nunito-latin-wght-italic.woff2") format("woff2"); font-weight: 200 1000; font-style: italic; font-display: swap; }

:root {
  /* trailer swatches */
  --gold-hi: #fff0b8;
  --gold: #f0c463;
  --gold-lo: #b98128;
  --bark: #3a2212;
  --leaf: #6fa63a;
  --leaf-hi: #a6d45a;
  --moss: #2c4420;
  --sky: #a9cdf2;
  --sky-deep: #5f93cf;
  --terracotta: #b4633a;
  --soil: #6e3b22;
  --heart: #e2262e;
  --mana: #22b8ea;
  --magenta: #e0409c;

  --radius-s: 6px;
  --radius: 10px;
  --radius-l: 16px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --rail: 248px;
  --font-display: "Almendra", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-body: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* night canopy (default) */
  color-scheme: dark;
  --bg: #111a0d;
  --bg-glow: rgba(95, 147, 207, .16);
  --surface: #182413;
  --surface-2: #1f2e18;
  --surface-3: #283a1f;
  --line: rgba(166, 212, 90, .14);
  --line-strong: rgba(166, 212, 90, .32);
  --text: #eef3e2;
  --muted: #a7b598;
  --faint: #76866a;
  --accent: var(--leaf-hi);
  --on-accent: #142008;
  --focus: var(--mana);
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --track: #34472a;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #eef5e3;
    --bg-glow: rgba(169, 205, 242, .75);
    --surface: #ffffff;
    --surface-2: #f5f9ec;
    --surface-3: #e8f0da;
    --line: rgba(44, 68, 32, .12);
    --line-strong: rgba(44, 68, 32, .28);
    --text: #1d2a13;
    --muted: #586a48;
    --faint: #8a9a7b;
    --accent: #4f8a22;
    --on-accent: #ffffff;
    --focus: #1290c4;
    --shadow: 0 10px 30px rgba(44, 68, 32, .14);
    --track: #d6e3c3;
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eef5e3;
  --bg-glow: rgba(169, 205, 242, .75);
  --surface: #ffffff;
  --surface-2: #f5f9ec;
  --surface-3: #e8f0da;
  --line: rgba(44, 68, 32, .12);
  --line-strong: rgba(44, 68, 32, .28);
  --text: #1d2a13;
  --muted: #586a48;
  --faint: #8a9a7b;
  --accent: #4f8a22;
  --on-accent: #ffffff;
  --focus: #1290c4;
  --shadow: 0 10px 30px rgba(44, 68, 32, .14);
  --track: #d6e3c3;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font: 15px/1.5 var(--font-body);
  color: var(--text);
  background:
    radial-gradient(1200px 520px at 70% -10%, var(--bg-glow), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--gold); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
button, input, select, textarea { font: inherit; color: inherit; }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .9em; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: var(--radius); }
.skip:focus { left: 8px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* The trailer's title: warm gold in a dark-brown outline. The one loud thing on the page. */
.title-gold {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: .01em;
  color: var(--gold);
  background: linear-gradient(180deg, var(--gold-hi) 0%, var(--gold) 48%, var(--gold-lo) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  -webkit-text-stroke: .07em var(--bark);
  paint-order: stroke fill;
  filter: drop-shadow(0 2px 0 rgba(58, 34, 18, .55));
}

/* Voxel terrace: the stepped edge from the trailer's pyramid, used as the header's foot. */
.terrace {
  height: 14px;
  background:
    linear-gradient(var(--leaf) 0 4px, transparent 4px),
    var(--terracotta);
  -webkit-mask: linear-gradient(90deg, #000 0 0) 0 0 / 100% 4px no-repeat,
    repeating-linear-gradient(90deg, #000 0 28px, transparent 28px 56px) 0 4px / 100% 5px no-repeat,
    repeating-linear-gradient(90deg, #000 0 14px, transparent 14px 28px) 0 9px / 100% 5px no-repeat;
  mask: linear-gradient(90deg, #000 0 0) 0 0 / 100% 4px no-repeat,
    repeating-linear-gradient(90deg, #000 0 28px, transparent 28px 56px) 0 4px / 100% 5px no-repeat,
    repeating-linear-gradient(90deg, #000 0 14px, transparent 14px 28px) 0 9px / 100% 5px no-repeat;
  opacity: .85;
}

/* ---- buttons and fields ------------------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 14px;
  border-radius: var(--radius); border: 1px solid var(--line-strong);
  background: var(--surface-2); color: var(--text);
  font-weight: 700; text-decoration: none; cursor: pointer;
  transition: background .15s var(--ease), border-color .15s var(--ease), transform .1s var(--ease);
}
.btn:hover { background: var(--surface-3); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-gold {
  background: linear-gradient(180deg, #ffe39a, var(--gold) 55%, #d69a3a);
  border-color: var(--bark); color: var(--bark);
  box-shadow: inset 0 -2px 0 rgba(58, 34, 18, .35);
}
.btn-gold:hover { background: linear-gradient(180deg, #fff0bf, #f6cf73 55%, #dea548); color: var(--bark); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { color: var(--heart); border-color: color-mix(in srgb, var(--heart) 45%, transparent); background: transparent; }
.btn-danger:hover { background: color-mix(in srgb, var(--heart) 12%, transparent); color: var(--heart); }
.btn-wide { width: 100%; }
.btn-icon { width: 38px; padding: 0; }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 13px; border-radius: var(--radius-s); }
.btn-sm.btn-icon { width: 30px; }

.field { display: grid; gap: 4px; }
.field > span { font-size: 13px; font-weight: 700; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; min-height: 38px; padding: 7px 10px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-s);
  background: var(--surface); color: var(--text);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.check input { width: 18px; height: 18px; accent-color: var(--leaf); }
.stack { display: grid; gap: 14px; }

.flash { padding: 10px 12px; border-radius: var(--radius-s); border-left: 4px solid; margin: 0 0 14px; }
.flash-error { border-color: var(--heart); background: color-mix(in srgb, var(--heart) 12%, transparent); }
.flash-ok { border-color: var(--leaf); background: color-mix(in srgb, var(--leaf) 14%, transparent); }

/* ---- card pages (sign-in, set password) and legal --------------------------------------------------------- */
.meadow {
  position: fixed; inset: auto 0 0 0; height: 38vh; z-index: -1; pointer-events: none;
  background:
    linear-gradient(180deg, transparent, color-mix(in srgb, var(--moss) 55%, transparent)),
    repeating-linear-gradient(90deg, color-mix(in srgb, var(--terracotta) 30%, transparent) 0 64px, color-mix(in srgb, var(--soil) 30%, transparent) 64px 128px);
  -webkit-mask: linear-gradient(180deg, transparent, #000 60%);
  mask: linear-gradient(180deg, transparent, #000 60%);
  clip-path: polygon(0 60%, 12% 60%, 12% 45%, 24% 45%, 24% 30%, 36% 30%, 36% 15%, 64% 15%, 64% 30%, 76% 30%, 76% 45%, 88% 45%, 88% 60%, 100% 60%, 100% 100%, 0 100%);
  opacity: .55;
}
.card-wrap { min-height: calc(100dvh - 64px); display: grid; place-items: center; padding: 32px 16px; }
.card {
  width: min(420px, 100%);
  padding: 28px 26px 24px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}
.card .brand { margin-bottom: 18px; }
.card-title { font-family: var(--font-display); font-weight: 700; font-size: 26px; line-height: 1.15; margin: 0 0 8px; }
.card-lede { color: var(--muted); margin: 0 0 18px; }
.card-alt { margin: 16px 0 0; text-align: center; font-size: 14px; }

.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.steps-soil { fill: var(--terracotta); }
.steps-grass { fill: var(--leaf); }
.brand-word { font-size: 26px; line-height: 1; }
.brand-sub { font-family: var(--font-display); font-size: 17px; color: var(--muted); align-self: flex-end; }

.legal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; max-width: 760px; margin: 0 auto; padding: 20px 16px 0; }
.legal { max-width: 760px; margin: 0 auto; padding: 16px 16px 48px; }
.legal h1 { font-size: clamp(32px, 6vw, 44px); margin: 18px 0 12px; }
.legal h2 { font-family: var(--font-display); font-size: 21px; margin: 28px 0 6px; color: var(--text); }
.legal p, .legal li { max-width: 68ch; }
.legal-note { color: var(--muted); font-size: 14px; border-left: 3px solid var(--sky-deep); padding-left: 10px; }
.lang { font-weight: 700; }

.site-foot {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 20px;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  font-size: 13px; color: var(--faint);
  border-top: 1px solid var(--line);
}
.site-foot nav { display: flex; gap: 16px; }
.site-foot a { color: var(--muted); }
.page-app .site-foot { padding-left: calc(var(--rail) + 16px); }

.consent {
  position: fixed; z-index: 60; left: 16px; right: 16px; bottom: 16px;
  max-width: 560px; margin: 0 auto;
  display: flex; gap: 14px; align-items: center;
  padding: 14px 16px; border-radius: var(--radius);
  background: linear-gradient(var(--surface), var(--surface)), var(--bg); border: 1px solid var(--line-strong); box-shadow: var(--shadow);
  animation: rise .35s var(--ease);
}
.consent p { margin: 0; font-size: 14px; color: var(--muted); }
.consent strong { color: var(--text); }
.consent .btn { white-space: nowrap; flex: none; }
@media (max-width: 520px) { .consent { flex-direction: column; align-items: stretch; } }

/* ---- the editor app ----------------------------------------------------------------------------------------- */
.boot { min-height: 70vh; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--muted); }
.boot .title-gold { font-size: 44px; }
.boot-steps { display: flex; gap: 4px; align-items: flex-end; height: 28px; }
.boot-steps i { width: 12px; background: var(--terracotta); border-top: 4px solid var(--leaf); animation: step 1s var(--ease) infinite alternate; }
.boot-steps i:nth-child(1) { height: 8px; } .boot-steps i:nth-child(2) { height: 14px; animation-delay: .1s; }
.boot-steps i:nth-child(3) { height: 20px; animation-delay: .2s; } .boot-steps i:nth-child(4) { height: 26px; animation-delay: .3s; }
@keyframes step { to { transform: translateY(-4px); } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.app { min-height: calc(100dvh - 50px); }
.shell { display: grid; grid-template-columns: var(--rail) 1fr; min-height: calc(100dvh - 50px); }

.rail {
  position: sticky; top: 0; height: 100dvh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px;
  padding: 16px 12px;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  border-right: 1px solid var(--line);
}
.rail .brand { padding: 4px 6px 14px; }
.rail-label { font-size: 12px; font-weight: 800; color: var(--faint); padding: 14px 10px 4px; }
.rail-item {
  display: flex; align-items: center; gap: 10px;
  min-height: 40px; padding: 0 10px;
  border-radius: var(--radius-s); color: var(--muted);
  text-decoration: none; font-weight: 700; position: relative;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.rail-item svg { width: 20px; height: 20px; flex: none; }
.rail-item:hover { background: var(--surface-2); color: var(--text); }
.rail-item[aria-current="page"] { background: var(--surface-3); color: var(--text); }
.rail-item[aria-current="page"]::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 4px; background: var(--gold); border-radius: 0 3px 3px 0; }
.rail-item .count {
  margin-left: auto; font-size: 12px; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 10px;
  display: grid; place-items: center; background: color-mix(in srgb, var(--magenta) 22%, transparent); color: var(--magenta);
}
.rail-item.dev-only { opacity: .55; }
.rail-foot { margin-top: auto; display: grid; gap: 4px; padding-top: 12px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 12px 20px 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
}
.topbar-foot { position: sticky; top: var(--topbar-h, 62px); z-index: 19; }
.profile-pick { display: flex; align-items: center; gap: 8px; min-width: 0; }
.profile-pick select { min-width: 160px; max-width: 260px; font-weight: 800; }
.live-badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 800;
  padding: 3px 9px; border-radius: 20px; color: var(--bark); background: var(--gold);
}
.live-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--heart); box-shadow: 0 0 0 3px rgba(226, 38, 46, .25); }
.spacer { flex: 1; }
.search { position: relative; width: min(280px, 100%); }
.search svg { position: absolute; left: 10px; top: 50%; translate: 0 -50%; width: 16px; height: 16px; color: var(--faint); }
.search input { padding-left: 32px; }
.kbd { font-family: ui-monospace, Consolas, monospace; font-size: 11px; padding: 1px 6px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; color: var(--muted); }

/* Game design / Developer switch */
.level {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: 22px;
  background: var(--surface-2); border: 1px solid var(--line);
}
.level button {
  border: 0; background: transparent; padding: 5px 12px; border-radius: 18px; cursor: pointer;
  font-weight: 800; font-size: 13px; color: var(--muted); transition: background .2s var(--ease), color .2s var(--ease);
}
.level button[aria-pressed="true"] { background: var(--leaf); color: #10200a; }
.level button.dev[aria-pressed="true"] { background: var(--sky-deep); color: #08182b; }

.presence { display: flex; align-items: center; }
.avatar {
  --h: 120;
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; font-weight: 900; color: #fff;
  background: hsl(var(--h) 45% 38%); border: 2px solid var(--bg);
  margin-left: -6px; position: relative;
}
.avatar:first-child { margin-left: 0; }
.avatar.me { outline: 2px solid var(--gold); outline-offset: -2px; }
.avatar-sm { width: 22px; height: 22px; font-size: 10px; margin: 0; border-width: 1px; }
.conn { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); flex: none; }
.conn.on { background: var(--leaf-hi); box-shadow: 0 0 0 3px color-mix(in srgb, var(--leaf-hi) 25%, transparent); }
.conn.poll { background: var(--gold); }

.note-bar { display: flex; gap: 8px; align-items: center; padding: 0 20px 10px; }
.note-bar input { max-width: 520px; }
.note-bar .hint { font-size: 12px; color: var(--faint); }

.content { padding: 8px 20px 40px; max-width: 1180px; width: 100%; }
.view-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 16px; margin: 6px 0 4px; }
.view-title { font-size: clamp(30px, 4vw, 40px); margin: 0; line-height: 1.1; }
.view-sub { color: var(--muted); margin: 0 0 18px; max-width: 75ch; }

/* property groups */
.group { margin: 0 0 22px; border: 1px solid var(--line); border-radius: var(--radius-l); background: color-mix(in srgb, var(--surface) 80%, transparent); overflow: hidden; }
.group-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.group-head h3 { font-family: var(--font-display); font-size: 19px; margin: 0; }
.group-head .more { margin-left: auto; font-size: 12px; color: var(--faint); }

.prop {
  display: grid;
  grid-template-columns: minmax(180px, 1.1fr) minmax(220px, 1.6fr) auto;
  gap: 6px 18px; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
  position: relative; transition: background .4s var(--ease);
}
.prop:last-child { border-bottom: 0; }
.prop:hover { background: color-mix(in srgb, var(--surface-3) 45%, transparent); }
.prop.flash { animation: remote 1.6s var(--ease); }
@keyframes remote { 0% { background: color-mix(in srgb, var(--mana) 28%, transparent); } 100% { background: transparent; } }
.prop.set::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--magenta); }
.prop-name { min-width: 0; }
.prop-label { font-weight: 800; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.prop-key { font-size: 12px; color: var(--faint); font-family: ui-monospace, Consolas, monospace; overflow-wrap: anywhere; }
.prop-desc { font-size: 13px; color: var(--muted); margin-top: 2px; max-width: 60ch; }
.tag { font-size: 11px; font-weight: 800; padding: 1px 7px; border-radius: 10px; background: var(--surface-3); color: var(--muted); }
.tag.dev { background: color-mix(in srgb, var(--sky-deep) 24%, transparent); color: var(--sky); }
.tag.warn { background: color-mix(in srgb, var(--heart) 18%, transparent); color: var(--heart); }
.prop-ctl { display: flex; align-items: center; gap: 10px; min-width: 0; }
.prop-side { display: flex; align-items: center; gap: 6px; justify-content: flex-end; min-width: 168px; }
.prop-side .default { font-size: 12px; color: var(--faint); white-space: nowrap; }
.editing-ring { position: absolute; right: 8px; top: 6px; }
.unit { font-size: 12px; color: var(--faint); white-space: nowrap; min-width: 36px; }

/* slider: leaf track, gold gem thumb */
.range { -webkit-appearance: none; appearance: none; flex: 1; min-width: 80px; height: 26px; background: transparent; cursor: pointer; --p: 50%; }
.range::-webkit-slider-runnable-track { height: 8px; border-radius: 4px; background: linear-gradient(90deg, var(--leaf) var(--p), var(--track) var(--p)); }
.range::-moz-range-track { height: 8px; border-radius: 4px; background: var(--track); }
.range::-moz-range-progress { height: 8px; border-radius: 4px; background: var(--leaf); }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -6px; transform: rotate(45deg); border-radius: 4px; background: linear-gradient(135deg, var(--gold-hi), var(--gold) 50%, var(--gold-lo)); border: 2px solid var(--bark); transition: transform .15s var(--ease); }
.range::-moz-range-thumb { width: 16px; height: 16px; transform: rotate(45deg); border-radius: 4px; background: var(--gold); border: 2px solid var(--bark); }
.range:active::-webkit-slider-thumb { transform: rotate(45deg) scale(1.2); }
input.num { width: 108px; flex: none; text-align: right; font-weight: 800; }
input.num.small { width: 80px; }

/* switch */
.switch { position: relative; width: 48px; height: 28px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 14px; background: var(--track); transition: background .2s var(--ease); pointer-events: none; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s var(--ease); }
.switch input:checked + span { background: var(--leaf); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch-text { font-size: 13px; color: var(--muted); font-weight: 700; }

.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: var(--radius-s); background: var(--surface-2); border: 1px solid var(--line); }
.seg button { border: 0; background: transparent; padding: 4px 10px; border-radius: 5px; cursor: pointer; font-weight: 700; font-size: 13px; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.vec { display: flex; gap: 6px; flex-wrap: wrap; }
.vec label { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--faint); font-weight: 800; }
.color { display: flex; gap: 8px; align-items: center; }
.color input[type=color] { width: 44px; height: 34px; padding: 2px; border: 1px solid var(--line-strong); border-radius: var(--radius-s); background: var(--surface); }
.curve { width: 100%; max-width: 360px; height: 120px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-s); touch-action: none; }
.curve path { fill: none; stroke: var(--leaf-hi); stroke-width: 2; }
.curve circle { fill: var(--gold); stroke: var(--bark); stroke-width: 1.5; cursor: grab; }

/* tables: compare, history, users */
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.table th { text-align: left; font-size: 12px; color: var(--faint); font-weight: 800; padding: 8px 10px; border-bottom: 1px solid var(--line-strong); background: var(--bg); }
.table td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr.differs td { background: color-mix(in srgb, var(--magenta) 7%, transparent); }
.table .val { font-weight: 800; font-family: ui-monospace, Consolas, monospace; font-size: 13px; overflow-wrap: anywhere; }
.val.a { color: var(--sky); } .val.b { color: var(--magenta); }
:root[data-theme="light"] .val.a { color: var(--sky-deep); }
.val.default { color: var(--faint); font-weight: 600; }
.arrow { color: var(--faint); padding: 0 4px; }
.old { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--heart) 60%, transparent); }
.new { color: var(--text); font-weight: 800; }
.mod-row td { background: var(--surface-2); font-family: var(--font-display); font-size: 17px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-l); background: color-mix(in srgb, var(--surface) 80%, transparent); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 14px; }
.filters select, .filters input { width: auto; min-width: 140px; }
.filters .check input { min-width: 0; width: 18px; }

.hist { display: grid; gap: 8px; }
.hist-item { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: color-mix(in srgb, var(--surface) 80%, transparent); }
.hist-item.undone { opacity: .55; }
.hist-meta { font-size: 12px; color: var(--faint); }
.hist-what { min-width: 0; overflow-wrap: anywhere; }
.hist-comment { font-style: italic; color: var(--muted); font-size: 13px; }
.hist-actions { display: flex; gap: 6px; align-items: start; flex-wrap: wrap; justify-content: flex-end; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.pcard { padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-l); background: color-mix(in srgb, var(--surface) 85%, transparent); display: grid; gap: 8px; align-content: start; }
.pcard.live { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.pcard.archived { opacity: .6; }
.pcard h3 { font-family: var(--font-display); font-size: 22px; margin: 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pcard p { margin: 0; color: var(--muted); font-size: 14px; }
.pcard .row { display: flex; flex-wrap: wrap; gap: 6px; }
.slug { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: var(--faint); }

.panel { padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-l); background: color-mix(in srgb, var(--surface) 85%, transparent); margin-bottom: 18px; }
.panel h3 { font-family: var(--font-display); font-size: 20px; margin: 0 0 10px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.inline-form .field { flex: 1 1 180px; }
.secret { display: flex; gap: 8px; align-items: center; padding: 10px; border-radius: var(--radius-s); background: color-mix(in srgb, var(--gold) 14%, transparent); border: 1px dashed var(--gold); margin-top: 10px; }
.secret code { overflow-wrap: anywhere; flex: 1; }
.empty { padding: 28px; text-align: center; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--radius-l); }
.issues { border-left: 4px solid var(--heart); padding: 10px 14px; margin: 0 0 16px; border-radius: var(--radius-s); background: color-mix(in srgb, var(--heart) 8%, transparent); font-size: 14px; }
.issues ul { margin: 6px 0 0; padding-left: 18px; }

/* toasts and dialogs */
.toasts { position: fixed; z-index: 80; right: 16px; bottom: 16px; display: grid; gap: 8px; width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line-strong); box-shadow: var(--shadow); animation: rise .25s var(--ease); font-size: 14px; }
.toast.err { border-left: 4px solid var(--heart); }
.toast.live { border-left: 4px solid var(--mana); }
.toast.ok { border-left: 4px solid var(--leaf); }
.toast .grow { flex: 1; min-width: 0; }
dialog { border: 1px solid var(--line-strong); border-radius: var(--radius-l); background: linear-gradient(var(--surface), var(--surface)), var(--bg); color: var(--text); padding: 20px; width: min(520px, calc(100vw - 32px)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(10, 16, 6, .55); backdrop-filter: blur(2px); }
dialog h2 { font-family: var(--font-display); margin: 0 0 12px; font-size: 24px; }
dialog[open] { animation: rise .2s var(--ease); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.keys-list { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; align-items: center; font-size: 14px; }

.chips { display: none; }
.menu-btn { display: none; }

/* ---- tablet: rail shrinks to icons ---------------------------------------------------------------------------- */
@media (max-width: 1080px) {
  :root { --rail: 72px; }
  .rail { padding: 14px 8px; align-items: center; }
  .rail .brand-word, .rail .brand-sub, .rail-label, .rail-item .txt { display: none; }
  .rail-item { width: 48px; justify-content: center; padding: 0; }
  .rail-item .count { position: absolute; top: 2px; right: 0; min-width: 16px; height: 16px; font-size: 10px; padding: 0 4px; }
  .rail-item[aria-current="page"]::before { left: -8px; }
  .prop { grid-template-columns: minmax(160px, 1fr) minmax(200px, 1.4fr) auto; }
}
/* ---- phone: no rail, module chips, stacked rows --------------------------------------------------------------- */
@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    position: fixed; z-index: 50; left: 0; top: 0; bottom: 0; width: 260px; height: auto; align-items: stretch;
    transform: translateX(-105%); transition: transform .25s var(--ease); background: var(--surface); box-shadow: var(--shadow);
  }
  .rail.open { transform: none; }
  .rail .brand-word, .rail .brand-sub, .rail-label, .rail-item .txt { display: initial; }
  .rail-item { width: auto; justify-content: flex-start; padding: 0 10px; }
  .rail-item .count { position: static; }
  .menu-btn { display: inline-flex; }
  .page-app .site-foot { padding-left: 16px; }
  .topbar { padding: 10px 16px 8px; gap: 8px; }
  .search { order: 10; width: 100%; }
  .profile-pick select { min-width: 0; max-width: 46vw; }
  .note-bar { padding: 0 16px 8px; }
  .note-bar .hint { display: none; }
  .chips { display: flex; gap: 6px; overflow-x: auto; padding: 0 16px 10px; scrollbar-width: none; }
  .chips a { flex: none; display: inline-flex; gap: 6px; align-items: center; padding: 6px 12px; border-radius: 18px; border: 1px solid var(--line-strong); color: var(--muted); text-decoration: none; font-weight: 800; font-size: 13px; }
  .chips a[aria-current="page"] { background: var(--leaf); color: #10200a; border-color: var(--leaf); }
  .chips svg { width: 15px; height: 15px; }
  .content { padding: 4px 16px 32px; }
  .prop { grid-template-columns: 1fr auto; padding: 12px; }
  .prop-ctl { grid-column: 1 / -1; grid-row: 2; }
  .prop-side { grid-column: 2; grid-row: 1; min-width: 0; }
  .prop-side .default { display: none; }
  input.num { width: 92px; }
  .hist-item { grid-template-columns: 1fr; }
  .hist-actions { justify-content: flex-start; }
  .table th { top: 0; }
  .level button { padding: 5px 9px; }
}
.scrim { position: fixed; inset: 0; z-index: 45; background: rgba(10, 16, 6, .45); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
.toast .grow .avatar { display: inline-grid; vertical-align: middle; margin-right: 4px; }
