/* Addon Studio. Every size is a whole pixel on a 4px grid: controls are
   40px (regular) or 32px (small), text is 11/12/13/14/15px. */
:root {
  --bg: #13100e;
  --bg-2: #1a1613;
  --panel: #1f1a16;
  --panel-2: #29221c;
  --line: #342b24;
  --line-2: #4a3d32;
  --ink: #f3e9dc;
  --ink-2: #cdbda8;
  --muted: #978671;
  --amber: #ffb547;
  --amber-2: #ff9a1f;
  --amber-ink: #1d1206;
  --amber-glow: rgba(255, 181, 71, .14);
  --teal: #5fd4c4;
  --teal-bg: rgba(95, 212, 196, .1);
  --coral: #ff6f5e;
  --coral-bg: rgba(255, 111, 94, .1);
  --violet: #b9a2ff;
  --violet-bg: rgba(185, 162, 255, .1);
  --r-l: 16px;
  --r: 10px;
  --r-s: 8px;
  --display: "Bricolage Grotesque", "Iowan Old Style", Georgia, serif;
  --body: "Instrument Sans", "Avenir Next", "Segoe UI", sans-serif;
  --mono: "Martian Mono", "JetBrains Mono", ui-monospace, monospace;
  --shadow: 0 24px 60px -24px rgba(0, 0, 0, .8);
  --ring: 0 0 0 3px var(--amber-glow);
  --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23978671' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  --head-h: 0px; /* set from JS: height of the sticky editor header */
}

* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
html, body { margin: 0; height: 100%; }
body {
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(255, 154, 31, .09), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(95, 212, 196, .05), transparent 60%),
    var(--bg);
  background-attachment: fixed; /* the glows stay put instead of tiling down the page */
  color: var(--ink);
  font: 400 15px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-variant-numeric: tabular-nums;
}
[hidden] { display: none !important; }
a { color: var(--amber); }
p { margin: 0; }
h1, h2, h3, h4 { font-family: var(--display); font-weight: 800; letter-spacing: -.02em; margin: 0; }
em { font-style: normal; color: var(--amber); }
code { font-family: var(--mono); }
.muted { color: var(--muted); }
.mono { font: 400 12px/1 var(--mono); }
.grow { flex: 1; min-width: 0; }
.ic { width: 16px; height: 16px; flex: none; display: block; }
.error { color: var(--coral); font-size: 13px; line-height: 20px; }
.error:empty { display: none; }
.eyebrow { font: 500 11px/16px var(--mono); letter-spacing: .18em; text-transform: uppercase; color: var(--amber); }
.label { font: 500 11px/16px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
.hint { display: block; font-size: 13px; line-height: 20px; color: var(--muted); }

/* film grain */
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 100; opacity: .045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 1.2s steps(6) infinite;
}
@keyframes grain {
  0% { background-position: 0 0; } 20% { background-position: -40px 25px; } 40% { background-position: 30px -45px; }
  60% { background-position: -25px -15px; } 80% { background-position: 45px 40px; } 100% { background-position: 0 0; }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) {
  .grain { animation: none; }
  *, *::before, *::after { animation-duration: 0s !important; animation-delay: 0s !important; transition: none !important; }
}

/* ---------- buttons ---------- */
.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border: 1px solid var(--line-2); border-radius: 999px;
  background: var(--panel-2); color: var(--ink); font: 600 14px/1 var(--body); white-space: nowrap;
  text-decoration: none; cursor: pointer; flex: none;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s, transform .15s;
}
.btn:hover { border-color: var(--amber); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn:disabled:hover { border-color: var(--line-2); }
.btn.primary {
  background: linear-gradient(180deg, var(--amber), var(--amber-2)); color: var(--amber-ink); border-color: transparent;
  box-shadow: 0 8px 24px -12px var(--amber), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.btn.primary:hover { box-shadow: 0 10px 28px -10px var(--amber), inset 0 1px 0 rgba(255, 255, 255, .25); }
.btn.primary:disabled { background: var(--panel-2); color: var(--muted); border-color: var(--line-2); box-shadow: none; opacity: 1; }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.danger { background: transparent; border-color: rgba(255, 111, 94, .45); color: var(--coral); }
.btn.danger:hover { background: var(--coral-bg); border-color: var(--coral); }
.btn.small { height: 32px; padding: 0 12px; gap: 6px; font-size: 13px; }
.btn.small .ic { width: 14px; height: 14px; }
.btn.small:has(> .ic:first-child) { padding-left: 10px; }
.btn.wide { width: 100%; }
.btn.icon { width: 32px; height: 32px; padding: 0; border-radius: var(--r-s); }
.btn.icon.tiny { width: 28px; height: 28px; }
.btn.icon.tiny .ic { width: 14px; height: 14px; }
.btn.round { width: 40px; padding: 0; }
.btn.del { color: var(--ink-2); }
.btn.del:hover { color: var(--coral); border-color: var(--coral); background: var(--coral-bg); }

/* ---------- inputs ---------- */
input, select, textarea {
  width: 100%; margin: 0; background: var(--bg-2); color: var(--ink); border: 1px solid var(--line);
  border-radius: var(--r); font: 500 14px/20px var(--body); transition: border-color .15s, box-shadow .15s;
}
input, select { height: 40px; padding: 0 12px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; font-family: var(--body); font-weight: 400; }
textarea::placeholder { font-family: var(--mono); }
input[type=number] { font: 500 13px/20px var(--mono); -moz-appearance: textfield; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=date]::-webkit-calendar-picker-indicator { opacity: .6; cursor: pointer; }
select {
  appearance: none; padding-right: 36px; cursor: pointer; text-overflow: ellipsis;
  background: var(--bg-2) var(--chev) no-repeat right 12px center / 16px 16px;
}
select option, select optgroup { background: var(--panel-2); color: var(--ink); }
textarea { display: block; padding: 10px 12px; font: 400 12px/18px var(--mono); resize: vertical; min-height: 92px; }
input:hover, select:hover, textarea:hover { border-color: var(--line-2); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--amber); box-shadow: var(--ring); }
.btn:focus-visible, .chip:focus-visible, .pv-tab:focus-visible, .seg button:focus-visible, .jump a:focus-visible, summary:focus-visible {
  outline: none; box-shadow: var(--ring); border-color: var(--amber);
}
input.invalid, textarea.invalid { border-color: var(--coral); box-shadow: 0 0 0 3px var(--coral-bg); }
select.sm, input.sm { height: 32px; border-radius: var(--r-s); font-size: 13px; }
select.sm { padding: 0 32px 0 10px; background-position: right 10px center; background-size: 14px 14px; }
input.sm { padding: 0 10px; }
select.add {
  width: auto; max-width: 100%; height: 32px; padding: 0 30px 0 12px; border-radius: 999px; border-style: dashed;
  border-color: var(--line-2); background-color: transparent; background-position: right 10px center; background-size: 14px 14px;
  color: var(--ink-2); font-size: 13px;
}
select.add:hover { border-color: var(--amber); color: var(--ink); }

.field { display: grid; gap: 8px; min-width: 0; margin: 0; }
.field > .label { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field-head { display: flex; align-items: baseline; gap: 8px 16px; flex-wrap: wrap; min-width: 0; }
.field-head .label { flex: 1; }
.field > .hint { margin-top: -2px; }
/* input group: one frame holding the input and its unit */
.ig {
  display: flex; align-items: center; min-width: 0; height: 40px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--bg-2); transition: border-color .15s, box-shadow .15s; cursor: text;
}
.ig:hover { border-color: var(--line-2); }
.ig:focus-within { border-color: var(--amber); box-shadow: var(--ring); }
.ig:has(input.invalid) { border-color: var(--coral); box-shadow: 0 0 0 3px var(--coral-bg); }
.ig input { flex: 1; min-width: 0; height: 38px; border: 0; border-radius: var(--r); background: transparent; box-shadow: none; }
.ig input:focus, .ig input.invalid { box-shadow: none; }
.ig .unit { flex: none; padding: 0 12px 0 4px; font: 400 12px/1 var(--mono); color: var(--muted); white-space: nowrap; }
/* The slug input is sized to its text (exact in a monospace face) so the
   domain follows it directly and the box reads as one hostname. */
.ig.domain input { flex: none; width: calc(var(--n, 12) * 1ch + 13px); max-width: 70%; padding-right: 0; font: 500 13px/20px var(--mono); }
.ig.domain input::placeholder { font-family: var(--mono); }
.ig .unit.domain { flex: 1; min-width: 0; padding-left: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.range { display: flex; align-items: center; gap: 8px; }
.range .ig { flex: 1; }
.range .dash { flex: none; color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 20px 16px; align-items: start; }
.cols.wide { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.cols.narrow { grid-template-columns: repeat(auto-fit, minmax(136px, 1fr)); }
.stack { display: grid; gap: 20px; }

/* ---------- login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 32px 16px; }
.login-card {
  position: relative; display: grid; gap: 20px; width: min(420px, 100%); padding: 40px 36px 36px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); overflow: hidden;
  animation: rise .6s cubic-bezier(.2, .8, .2, 1) both;
}
.login-card header { display: grid; gap: 12px; position: relative; }
.login-card h1 { font-size: 44px; line-height: 1; }
.login-card .note { color: var(--muted); font-size: 15px; line-height: 22px; max-width: 30ch; }
.reel {
  position: absolute; right: -64px; top: -64px; width: 192px; height: 192px; border-radius: 50%;
  border: 14px solid rgba(255, 181, 71, .1);
  background: radial-gradient(circle, rgba(255, 181, 71, .22) 0 12px, transparent 13px),
    conic-gradient(from 0deg, transparent 0 20deg, rgba(255, 181, 71, .07) 20deg 40deg, transparent 40deg 80deg,
      rgba(255, 181, 71, .07) 80deg 100deg, transparent 100deg 140deg, rgba(255, 181, 71, .07) 140deg 160deg, transparent 160deg);
  animation: spin 24s linear infinite;
}

/* ---------- shell & rail ---------- */
.shell { display: grid; grid-template-columns: 288px minmax(0, 1fr); min-height: 100%; }
.rail {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 16px;
  padding: 20px 16px 16px 32px; border-right: 1px solid var(--line); background: rgba(19, 16, 14, .8);
  backdrop-filter: blur(8px);
}
.rail::before { /* film perforations */
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 16px; border-right: 1px solid var(--line);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='24'%3E%3Crect x='5' y='7' width='6' height='10' rx='2' fill='%23ffb547' fill-opacity='.2'/%3E%3C/svg%3E") repeat-y 0 0 / 16px 24px;
}
.brand { display: flex; align-items: center; gap: 12px; height: 40px; }
.brand strong { display: block; font: 800 17px/20px var(--display); letter-spacing: -.01em; }
.brand small { display: block; font: 400 11px/16px var(--mono); color: var(--muted); }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  background: radial-gradient(circle at 50% 50%, var(--amber) 0 3.5px, transparent 4px),
    radial-gradient(circle at 50% 23%, var(--amber) 0 3px, transparent 3.5px),
    radial-gradient(circle at 50% 77%, var(--amber) 0 3px, transparent 3.5px),
    radial-gradient(circle at 23% 50%, var(--amber) 0 3px, transparent 3.5px),
    radial-gradient(circle at 77% 50%, var(--amber) 0 3px, transparent 3.5px), var(--panel-2);
  border: 2px solid var(--amber); animation: spin 18s linear infinite;
}
.addon-list { flex: 1; overflow: auto; display: grid; align-content: start; gap: 8px; margin: 0 -4px; padding: 2px 4px; }
.addon-card {
  display: grid; gap: 4px; padding: 12px 14px; border-radius: 12px; text-decoration: none; color: inherit;
  border: 1px solid var(--line); background: var(--panel); transition: border-color .15s, background-color .15s;
  animation: rise .45s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--i, 0) * 45ms);
}
.addon-card:hover { border-color: var(--line-2); background: var(--panel-2); }
.addon-card.active { border-color: var(--amber); background: linear-gradient(90deg, var(--amber-glow), var(--panel) 75%); }
.addon-card .t { display: flex; align-items: center; justify-content: space-between; gap: 8px; font: 600 15px/20px var(--display); }
.addon-card .t span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.addon-card .s { font: 400 11px/16px var(--mono); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.addon-card .u { display: flex; gap: 6px; margin-top: 4px; font: 400 11px/16px var(--mono); color: var(--ink-2); white-space: nowrap; overflow: hidden; }
.addon-card .u i { font-style: normal; color: var(--line-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 8px var(--teal); flex: none; }
.dot.off { background: var(--muted); box-shadow: none; }
.dot.live { background: var(--amber); box-shadow: 0 0 10px var(--amber); animation: pulse 1.4s ease-in-out infinite; }
.rail-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 32px; }
#rail-status { display: grid; gap: 2px; min-width: 0; }
#rail-status .k { font: 500 10px/12px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
#rail-status .v { font: 400 12px/16px var(--mono); color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.view { min-width: 0; padding: 24px 32px 64px; }

/* ---------- home ---------- */
.home-hero { max-width: 800px; padding: 48px 0 16px; display: grid; gap: 20px; animation: rise .5s both; }
.home-hero h1 { font-size: clamp(40px, 5vw, 64px); line-height: .95; }
.home-hero .lede { color: var(--ink-2); max-width: 56ch; font-size: 17px; line-height: 26px; }
.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 12px; }
.home-hero .stat-strip { margin-top: 16px; }
.stat { display: grid; gap: 8px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); min-width: 0; }
.stat b { font: 800 28px/1 var(--display); color: var(--amber); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat span { font: 500 11px/16px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }

/* ---------- editor ---------- */
.editor-head {
  position: sticky; top: 0; z-index: 20; margin: -24px -32px 20px; padding: 16px 32px 0;
  background: rgba(19, 16, 14, .88); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
  display: grid; gap: 12px;
}
.eh-row { display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap; min-height: 40px; }
.eh-title { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.eh-title h2 { font-size: 28px; line-height: 36px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eh-actions { display: flex; align-items: center; gap: 8px; }
.install { display: flex; align-items: center; gap: 8px; min-width: 0; }
.install .label { margin-right: 4px; }
.url-pill {
  display: block; min-width: 0; flex: 0 1 auto; height: 32px; padding: 0 14px; font: 400 12px/30px var(--mono);
  color: var(--ink-2); background: var(--bg-2); border: 1px dashed var(--line-2); border-radius: 999px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; user-select: all;
}
.dirty-flag { display: inline-flex; align-items: center; gap: 6px; font: 500 11px/16px var(--mono); color: var(--amber); letter-spacing: .08em; text-transform: uppercase; margin-right: 4px; }
.dirty-flag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--amber); }
.badge {
  display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border-radius: 6px; border: 1px solid var(--line-2);
  font: 500 10px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); white-space: nowrap; flex: none;
}
.badge.warn { color: var(--coral); border-color: rgba(255, 111, 94, .45); }
.badge.ok { color: var(--teal); border-color: rgba(95, 212, 196, .45); }

.jump {
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; margin: 0 -8px; padding: 0 8px;
  mask-image: linear-gradient(90deg, transparent, #000 8px, #000 calc(100% - 32px), transparent);
}
.jump::-webkit-scrollbar { display: none; }
.jump a {
  flex: none; display: flex; align-items: center; height: 36px; padding: 0 10px; border-bottom: 2px solid transparent;
  font: 500 13px/1 var(--body); color: var(--muted); text-decoration: none; transition: color .15s, border-color .15s;
}
.jump a:hover { color: var(--ink); }
.jump a.on { color: var(--ink); border-bottom-color: var(--amber); }
.jump a:focus-visible { box-shadow: inset 0 0 0 2px var(--amber-glow); border-radius: 6px 6px 0 0; }

.workbench { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 42%); gap: 24px; align-items: start; }
.sections { display: grid; gap: 12px; min-width: 0; }

.section {
  border: 1px solid var(--line); border-radius: var(--r-l); background: var(--panel); min-width: 0;
  animation: rise .45s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--i, 0) * 25ms);
  scroll-margin-top: calc(var(--head-h) + 20px);
}
.section > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 16px 0 20px;
  border-radius: var(--r-l); user-select: none;
}
.section > summary::-webkit-details-marker { display: none; }
.section > summary:hover h3 { color: var(--amber); }
.section > summary .n { font: 500 11px/1 var(--mono); color: var(--amber); width: 18px; flex: none; }
.section > summary h3 { font: 600 17px/24px var(--display); letter-spacing: -.01em; flex: none; transition: color .15s; }
.section > summary .sum { margin-left: auto; min-width: 0; font: 400 11px/16px var(--mono); color: var(--muted); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.section > summary .chev { color: var(--muted); transition: transform .2s cubic-bezier(.2, .8, .2, 1); }
.section[open] > summary .chev { transform: rotate(180deg); }
.section > .body { display: grid; gap: 24px; padding: 20px; border-top: 1px dashed var(--line); min-width: 0; }

/* ---------- toggles ---------- */
.toggle { position: relative; display: flex; gap: 12px; align-items: flex-start; cursor: pointer; min-width: 0; }
/* The real checkbox stays focusable but takes no space. */
.toggle input { position: absolute; left: 0; top: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.toggle .sw {
  flex: none; position: relative; width: 36px; height: 20px; border-radius: 999px; background: var(--bg-2);
  border: 1px solid var(--line-2); transition: background-color .2s, border-color .2s, box-shadow .2s;
}
.toggle .sw::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--muted); transition: transform .2s cubic-bezier(.2, .8, .2, 1), background-color .2s;
}
.toggle:hover .sw { border-color: var(--muted); }
.toggle input:checked + .sw { background: var(--amber-glow); border-color: var(--amber); }
.toggle input:checked + .sw::after { transform: translateX(16px); background: var(--amber); }
.toggle input:focus-visible + .sw { box-shadow: var(--ring); }
.toggle .tx { display: grid; gap: 2px; min-width: 0; }
.toggle b { font: 600 14px/20px var(--body); }
.toggle small { font-size: 13px; line-height: 19px; color: var(--muted); }
.toggles { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px 24px; align-items: start; }

/* ---------- chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  appearance: none; display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  font: 500 13px/1 var(--body); color: var(--ink-2); background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 999px; cursor: pointer; user-select: none; white-space: nowrap;
  transition: background-color .15s, color .15s, border-color .15s, transform .12s;
}
.chip:hover { border-color: var(--line-2); color: var(--ink); }
.chip:active { transform: scale(.97); }
.chip.allow { background: var(--teal-bg); border-color: rgba(95, 212, 196, .7); color: var(--teal); }
.chip.deny { background: var(--coral-bg); border-color: rgba(255, 111, 94, .7); color: var(--coral); }
.chip.allow::before, .chip.deny::before { font: 700 12px/1 var(--body); width: 10px; text-align: center; margin-left: -2px; }
.chip.allow::before { content: "✓"; }
.chip.deny::before { content: "✕"; }
.chip.deny .tx { text-decoration: line-through; text-decoration-thickness: 1px; }
.chip.on { background: var(--amber-glow); border-color: rgba(255, 181, 71, .7); color: var(--amber); }
.chip.more { border-style: dashed; color: var(--muted); background: transparent; }
.chip.more:hover { color: var(--ink); border-color: var(--amber); }
.chip .fl { font-size: 14px; line-height: 1; }
.legend { display: inline-flex; gap: 12px; font: 400 11px/16px var(--mono); color: var(--muted); white-space: nowrap; cursor: help; }
.legend i { font-style: normal; }
.legend .a { color: var(--teal); } .legend .d { color: var(--coral); } .legend .p { color: var(--violet); }

.pref-row select.add { width: 144px; }
.pref-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; min-height: 32px; }
.pref-k { font: 500 11px/16px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--violet); margin-right: 4px; }
.pchip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 4px 0 6px; border-radius: 999px;
  background: var(--violet-bg); border: 1px solid rgba(185, 162, 255, .6); color: var(--violet); font: 500 13px/1 var(--body);
  cursor: grab; user-select: none; white-space: nowrap;
}
.pchip .i {
  display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: rgba(185, 162, 255, .2);
  font: 500 10px/1 var(--mono); color: var(--violet);
}
.pchip.dragging { opacity: .4; }
.pchip.over { box-shadow: -3px 0 0 var(--violet); }
.x {
  appearance: none; display: grid; place-items: center; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%;
  background: none; color: inherit; opacity: .6; cursor: pointer; flex: none;
}
.x .ic { width: 12px; height: 12px; }
.x:hover { opacity: 1; background: rgba(255, 255, 255, .08); }

/* ---------- tag lists ---------- */
.tag-stack { display: grid; gap: 8px; }
.tags {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 40px; padding: 3px 4px 3px 12px;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--bg-2); cursor: text;
  transition: border-color .15s, box-shadow .15s;
}
.tags:focus-within { border-color: var(--amber); box-shadow: var(--ring); }
.tags-k { width: 56px; flex: none; font: 500 11px/16px var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.tags.allow .tags-k { color: var(--teal); } .tags.deny .tags-k { color: var(--coral); } .tags.prefer .tags-k { color: var(--violet); }
.tags input { flex: 1; min-width: 120px; height: 32px; padding: 0 6px; border: 0; background: transparent; box-shadow: none; }
.tags input:focus { box-shadow: none; }
.tag {
  display: inline-flex; align-items: center; gap: 2px; height: 28px; padding: 0 3px 0 10px; border-radius: 999px;
  font: 500 13px/1 var(--body); border: 1px solid; white-space: nowrap;
}
.tags.allow .tag { background: var(--teal-bg); border-color: rgba(95, 212, 196, .6); color: var(--teal); }
.tags.deny .tag { background: var(--coral-bg); border-color: rgba(255, 111, 94, .6); color: var(--coral); }
.tags.prefer .tag { background: var(--violet-bg); border-color: rgba(185, 162, 255, .6); color: var(--violet); }

/* ---------- per-resolution table ---------- */
/* border-spacing also pads the outer edge; the wider box and negative margins cancel it so inputs line up with the fields above */
.res-table { width: calc(100% + 16px); border-collapse: separate; border-spacing: 8px 6px; margin: -6px -8px; table-layout: fixed; }
.res-table th { text-align: left; font: 500 11px/16px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 0 0 2px; }
.res-table th.grp { color: var(--ink-2); padding-bottom: 0; }
.res-table th:first-child { width: 72px; }
.res-table td { padding: 0; }
.res-table td:first-child { font: 500 12px/1 var(--mono); color: var(--ink-2); }
.res-table input { height: 32px; padding: 0 10px; border-radius: var(--r-s); }

/* ---------- ordered lists (sort, upstream priority) ---------- */
.olist { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; counter-reset: s; }
.olist li {
  display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 6px 0 12px; border: 1px solid var(--line);
  border-radius: var(--r); background: var(--bg-2); counter-increment: s;
}
.olist li::before { content: counter(s); width: 16px; flex: none; font: 500 11px/1 var(--mono); color: var(--amber); text-align: center; }
.olist li > span { flex: 1; min-width: 0; font-size: 14px; line-height: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.olist li > span.mono { font-size: 12px; }
.olist + .row select.add { width: 200px; }
.dir {
  appearance: none; display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--line-2); background: transparent; color: var(--ink-2); font: 500 12px/1 var(--body); cursor: pointer; white-space: nowrap;
}
.dir .ic { width: 14px; height: 14px; }
.dir:hover { border-color: var(--amber); color: var(--ink); }

/* ---------- context overrides ---------- */
.ovr { display: grid; gap: 10px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-2); }
.ovr textarea { background: var(--bg); min-height: 64px; }
.ovr-head { display: grid; gap: 2px; }
.ovr-head b { font: 600 14px/20px var(--body); }
.presets { display: flex; gap: 6px; flex-wrap: wrap; }

details.help > summary {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer; list-style: none;
  font: 500 11px/16px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2);
}
details.help > summary::-webkit-details-marker { display: none; }
details.help > summary .ic { width: 14px; height: 14px; transition: transform .2s; transform: rotate(-90deg); }
details.help[open] > summary .ic { transform: none; }
details.help > summary:hover { color: var(--amber); }
details.help .help-body { display: grid; gap: 12px; margin-top: 12px; font-size: 13px; line-height: 20px; color: var(--muted); }
.code { font: 400 12px/20px var(--mono); color: var(--amber); word-break: break-word; }
.danger-zone { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 20px; border-top: 1px dashed var(--line); }

/* ---------- preview ---------- */
.preview {
  position: sticky; top: calc(var(--head-h) + 20px); max-height: calc(100vh - var(--head-h) - 40px);
  display: flex; flex-direction: column; gap: 12px; min-width: 0;
}
.pv-box { display: grid; gap: 12px; padding: 16px; border: 1px solid var(--line); border-radius: var(--r-l); background: var(--panel); }
.pv-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pv-head h3 { font-size: 17px; line-height: 24px; }
.pv-controls { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.seg { display: inline-flex; height: 32px; padding: 2px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg-2); }
.seg button {
  appearance: none; height: 26px; padding: 0 14px; border: 0; border-radius: 999px; background: transparent; color: var(--muted);
  font: 600 13px/1 var(--body); cursor: pointer; transition: color .15s, background-color .15s;
}
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--panel-2); color: var(--amber); box-shadow: inset 0 0 0 1px var(--line-2); }
.pv-controls .toggle { align-items: center; }
.search { position: relative; }
.search > .ic { position: absolute; left: 12px; top: 12px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 38px; }
.search input::-webkit-search-cancel-button { filter: grayscale(1); opacity: .5; }
.results {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 6px); padding: 4px; background: var(--panel-2);
  border: 1px solid var(--line-2); border-radius: 12px; box-shadow: var(--shadow); max-height: 336px; overflow: auto;
}
.results button {
  display: flex; gap: 10px; align-items: center; width: 100%; padding: 6px 8px; border: 0; border-radius: var(--r-s);
  background: none; color: var(--ink); text-align: left; cursor: pointer; font: 500 14px/20px var(--body);
}
.results button:hover, .results button:focus { background: var(--amber-glow); outline: none; }
.results button small { color: var(--muted); font: 400 12px/1 var(--mono); margin-left: 6px; }
.poster { width: 32px; height: 48px; border-radius: 6px; object-fit: cover; background: var(--bg-2); flex: none; }
.poster.broken { visibility: hidden; }
.picked { display: flex; gap: 12px; align-items: center; min-height: 48px; }
.picked .t { display: grid; gap: 2px; min-width: 0; }
.picked b { font: 700 16px/20px var(--display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picked .t span { font: 400 12px/16px var(--mono); color: var(--muted); }
.picked .empty { color: var(--muted); font-size: 14px; }
.ep-controls { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 8px; }

.pv-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.pv-tab {
  appearance: none; display: grid; gap: 8px; padding: 12px 14px; text-align: left; border: 1px solid var(--line);
  border-radius: 12px; background: var(--panel); color: var(--ink); cursor: pointer; min-width: 0;
  transition: border-color .15s, background-color .15s;
}
.pv-tab:hover { border-color: var(--line-2); }
.pv-tab b { font: 800 26px/1 var(--display); }
.pv-tab span { font: 500 11px/16px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-tab.k b { color: var(--teal); } .pv-tab.r b { color: var(--coral); } .pv-tab.l b { color: var(--violet); }
.pv-tab.k.on { border-color: rgba(95, 212, 196, .7); background: var(--teal-bg); }
.pv-tab.r.on { border-color: rgba(255, 111, 94, .7); background: var(--coral-bg); }
.pv-tab.l.on { border-color: rgba(185, 162, 255, .7); background: var(--violet-bg); }
.pv-meta { font: 400 12px/18px var(--body); color: var(--muted); }
.bars { display: grid; gap: 6px; }
.bar { display: grid; grid-template-columns: minmax(0, 40%) minmax(0, 1fr) 40px; gap: 10px; align-items: center; font: 400 11px/16px var(--mono); color: var(--ink-2); }
.bar > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar i { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--coral), rgba(255, 111, 94, .35)); width: var(--w, 0%); min-width: 2px; transition: width .5s cubic-bezier(.2, .8, .2, 1); }
.bar i.lim { background: linear-gradient(90deg, var(--violet), rgba(185, 162, 255, .35)); }
.bar em { color: var(--muted); text-align: right; font-style: normal; }
.pv-list { overflow: auto; flex: 1; min-height: 160px; display: grid; align-content: start; gap: 8px; padding: 2px; margin: -2px; }
.pv-state { padding: 32px 16px; text-align: center; color: var(--muted); font-size: 14px; line-height: 20px; }
.spinner { width: 24px; height: 24px; margin: 0 auto 12px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--amber); animation: spin .8s linear infinite; }

/* Nuvio-like stream rows */
.stream {
  padding: 14px 16px; border-radius: 14px; background: linear-gradient(180deg, rgba(255, 255, 255, .06), rgba(255, 255, 255, .03));
  border: 1px solid rgba(255, 255, 255, .06); animation: rise .35s both; animation-delay: calc(var(--i, 0) * 18ms);
}
.stream .sn { font: 700 16px/20px var(--body); white-space: pre-line; color: #fff; }
.stream .sd { font-size: 13px; line-height: 20px; white-space: pre-line; color: #bdb4a9; margin-top: 6px; overflow-wrap: anywhere; }
.stream .sz { display: inline-flex; align-items: center; height: 20px; margin-top: 10px; padding: 0 6px; border-radius: 5px; font: 700 10px/1 var(--mono); letter-spacing: .06em; background: rgba(255, 255, 255, .92); color: #111; }
.stream.fallback { border-color: rgba(255, 181, 71, .45); }
.rej { display: grid; gap: 8px; padding: 10px 12px; border-radius: var(--r); border: 1px solid var(--line); background: var(--bg-2); }
.rej .rn { font: 400 11px/17px var(--mono); color: var(--ink-2); overflow-wrap: anywhere; }
.rej .rm { display: flex; gap: 6px; flex-wrap: wrap; }
.reason { display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border-radius: 6px; font: 500 10px/1 var(--mono); background: var(--coral-bg); color: var(--coral); white-space: nowrap; }
.reason.lim { background: var(--violet-bg); color: var(--violet); }

/* ---------- dialog, toast ---------- */
.dialog {
  border: 1px solid var(--line-2); border-radius: 20px; background: var(--panel); color: var(--ink); padding: 28px;
  width: min(460px, calc(100vw - 32px)); box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgba(8, 6, 5, .72); backdrop-filter: blur(3px); }
.dialog form { display: grid; gap: 20px; }
.dialog header { display: grid; gap: 6px; }
.dialog h2 { font-size: 24px; line-height: 30px; }
.dialog header p { color: var(--muted); font-size: 14px; line-height: 21px; }
.dialog .row.end { margin-top: 4px; }
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 200; display: flex; align-items: center; gap: 8px; height: 40px;
  padding: 0 18px; border-radius: 999px; background: var(--ink); color: var(--bg); font: 600 14px/1 var(--body);
  box-shadow: var(--shadow); white-space: nowrap; pointer-events: none;
  opacity: 0; visibility: hidden; transform: translate(-50%, 12px);
  transition: opacity .2s, transform .3s cubic-bezier(.2, .8, .2, 1), visibility 0s .3s;
}
.toast.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); transition: opacity .2s, transform .3s cubic-bezier(.2, .8, .2, 1); }
.toast.bad { background: var(--coral); color: #1f0b08; }

/* ---------- display builder: sized by its own width, not the window's ---------- */
.disp { container-type: inline-size; display: grid; gap: 20px; min-width: 0; }
.disp-presets { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.disp-presets .label { margin-right: 4px; }
.disp-grid { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 20px; align-items: start; }
.disp-mock { position: sticky; top: calc(var(--head-h) + 20px); z-index: 5; }
@container (max-width: 760px) {
  .disp-grid { grid-template-columns: minmax(0, 1fr); }
  .disp-mock { box-shadow: 0 16px 32px -12px rgba(0, 0, 0, .85); border-radius: 14px; }
}
.mock { padding: 12px; border-radius: 14px; background: #0c0b0a; border: 1px solid var(--line); }
.mock-head { display: flex; align-items: center; gap: 8px; min-height: 28px; margin-bottom: 12px; }
.mock-head small { font-size: 12px; line-height: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mock .hint { margin-bottom: 12px; }
.mock-row { animation: none; }
.parts { display: grid; gap: 20px; min-width: 0; }
.part { display: grid; gap: 10px; min-width: 0; }
.part-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.part-head h4 { font: 600 15px/20px var(--display); letter-spacing: -.01em; }
.part-head small { font-size: 12px; line-height: 16px; }
.lines { display: grid; gap: 8px; min-width: 0; }
.lines > .btn { justify-self: start; }
.ln { display: grid; gap: 8px; min-width: 0; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-2); }
.ln-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.ln-n { width: 16px; flex: none; font: 500 11px/1 var(--mono); color: var(--amber); text-align: center; }
.ln-icon { width: 88px; flex: none; text-align: center; }
.ln-sep { width: auto; flex: none; font-family: var(--mono); }
.ln-tools { display: flex; gap: 4px; margin-left: auto; flex: none; }
.ln-out {
  display: block; min-width: 0; height: 28px; padding: 0 10px; border-radius: 6px; background: rgba(255, 255, 255, .03);
  font: 400 12px/28px var(--mono); color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ln-out.empty { color: var(--muted); font-style: italic; }
.ln-fields { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; min-height: 32px; margin: -2px; padding: 2px; border-radius: var(--r-s); transition: background-color .15s; }
.ln-fields.over { background: var(--amber-glow); }
.ln-fields .empty { font-size: 12px; color: var(--muted); padding: 0 4px; }
.ln-fields select.add { width: 116px; height: 28px; font-size: 12px; }
.fchip {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 3px 0 10px; border-radius: var(--r-s);
  background: var(--panel-2); border: 1px solid var(--line-2); font-size: 12px; max-width: 100%; min-width: 0; cursor: grab; user-select: none;
}
.fchip b { font-weight: 600; color: var(--ink); white-space: nowrap; }
.fchip i { font: normal 400 11px/1 var(--mono); color: var(--teal); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fchip i.none { color: var(--muted); }
.fchip .x { width: 20px; height: 20px; color: var(--muted); }
.fchip .x:hover { color: var(--coral); }
.fchip.dragging { opacity: .4; }
.fchip.over { border-color: var(--amber); box-shadow: -3px 0 0 var(--amber); }

/* Single-column grids never grow past their container (the implicit
   column would otherwise stretch to its widest child's min-content). */
.section > .body, .field, .stack, .lines, .ln, .part, .parts, .tag-stack, .olist, .pv-box, .disp, .ovr, .rej {
  grid-template-columns: minmax(0, 1fr);
}

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .workbench { grid-template-columns: minmax(0, 1fr); }
  .preview { position: static; max-height: none; }
  .pv-list { max-height: 70vh; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { position: static; height: auto; padding: 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .rail::before { display: none; }
  .addon-list { overflow: visible; }
  .view { padding: 16px 16px 48px; }
  .editor-head { position: static; margin: -16px -16px 16px; padding: 16px 16px 0; }
  .eh-title h2 { font-size: 24px; line-height: 32px; }
  .install { flex-wrap: wrap; }
  .install .url-pill { flex-basis: 100%; order: 1; }
  .install .label { flex-basis: 100%; }
  .install .btn { order: 2; }
  .section > summary .sum { display: none; }
  .section > summary .chev { margin-left: auto; }
  .section > .body { padding: 16px; }
  .home-hero { padding-top: 24px; }
  .dir { width: 28px; padding: 0; justify-content: center; }
  .dir .t { display: none; }
  .login-card { padding: 32px 24px 24px; }
}
