/* ============================================================
   FatFigures — profile editor

   Loaded after style.css and only on /edit. The preview pane reuses the
   real .card rules from style.css rather than reimplementing them, so
   what you see there is the actual card, scaled down — the per-profile
   custom properties are just scoped to #frame instead of :root.
   ============================================================ */

.editor {
  --panel:      rgba(255, 255, 255, 0.035);
  --panel-edge: rgba(255, 255, 255, 0.09);
  --field:      rgba(8, 8, 12, 0.55);
  --field-edge: rgba(255, 255, 255, 0.13);
  --focus:      rgba(255, 255, 255, 0.42);
  --danger:     #ff6b6b;
  --ok:         #5fd28c;
  /* the picker draws real glyphs, not icons, so it needs the platform's
     colour emoji face rather than the UI font */
  --emoji-font: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji',
                'Segoe UI Symbol', sans-serif;

  background:
    radial-gradient(900px 600px at 80% -10%, rgba(74, 82, 104, 0.28), transparent 60%),
    radial-gradient(700px 500px at 0% 100%, rgba(45, 50, 66, 0.3), transparent 60%),
    var(--void);
  min-height: 100vh;
  min-height: 100dvh;
}

.editor .grain { opacity: 0.03; }

/* ============================================================
   Signed-out gate
   ============================================================ */
.ed-gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
}
.ed-gate[hidden] { display: none; }

.ed-gate-inner {
  max-width: 420px;
  text-align: center;
  animation: ed-rise 0.7s var(--ease) both;
}
.ed-gate h1 {
  margin: 0 0 12px;
  font-size: clamp(28px, 5vw, 38px);
  letter-spacing: -0.03em;
}
.ed-gate p {
  margin: 0 0 28px;
  color: var(--muted);
  line-height: 1.6;
  font-size: 15px;
}

.ed-discord {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 13px 24px;
  border-radius: 14px;
  background: #5865F2;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
  box-shadow: 0 12px 34px rgba(88, 101, 242, 0.32);
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease), background 0.2s ease;
}
.ed-discord:hover {
  background: #4752c4;
  transform: translateY(-2px);
  box-shadow: 0 16px 40px rgba(88, 101, 242, 0.42);
}
.ed-discord svg { width: 22px; height: 22px; fill: currentColor; }

/* ---- the one-time fee ----
   Sits where the Discord button sits when signed out, and takes the
   accent rather than blurple: this is the site asking, not Discord. */
.ed-pay {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 13px 24px;
  border: 0;
  border-radius: 14px;
  background: var(--ink);
  color: #07070B;
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 12px 34px rgba(245, 243, 238, 0.16);
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease), opacity 0.2s ease;
}
.ed-pay[hidden] { display: none; }
.ed-pay:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 40px rgba(245, 243, 238, 0.24);
}
.ed-pay:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.ed-pay:disabled {
  opacity: 0.55;
  cursor: progress;
  transform: none;
  box-shadow: none;
}
.ed-pay svg { width: 20px; height: 20px; fill: currentColor; }

/* With both on screen, signing out is the quiet one on its own line
   underneath. Both become block-level so the centred text flow cannot
   run them together, and :not([hidden]) leaves the signed-out screen —
   where there is no pay button — exactly as it was. */
.ed-pay:not([hidden]),
.ed-pay:not([hidden]) + .ed-discord {
  display: flex;
  width: fit-content;
  margin-inline: auto;
}
.ed-pay:not([hidden]) + .ed-discord { margin-top: 14px; }

.ed-gate-fine {
  margin: 16px 0 0 !important;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  line-height: 1.6;
  letter-spacing: 0.02em;
  color: var(--muted);
}
.ed-gate-fine[hidden] { display: none; }

.ed-gate-note {
  margin: 20px 0 0 !important;
  font-size: 13px;
  color: var(--danger);
  min-height: 1em;
}
.ed-gate-note.ok { color: var(--ok); }

/* ---- waiting on an admin ----
   The sign-in button becomes a way back out, so it drops the Discord
   blurple — nothing here is an invitation to sign in again. */
.ed-discord.ghosted {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: var(--muted);
  font-weight: 500;
  box-shadow: none;
}
.ed-discord.ghosted:hover {
  background: rgba(255, 255, 255, 0.11);
  color: var(--ink);
  transform: none;
  box-shadow: none;
}
.ed-discord.ghosted svg { display: none; }

.ed-gate-id {
  margin-top: 24px;
  display: grid;
  gap: 7px;
  justify-items: center;
}
.ed-gate-id[hidden] { display: none; }
.ed-gate-id-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.ed-gate-id-value {
  padding: 10px 16px;
  border-radius: 11px;
  background: var(--field);
  border: 1px solid var(--field-edge);
  color: var(--ink);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 15px;
  letter-spacing: 0.02em;
  cursor: copy;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.ed-gate-id-value:hover { border-color: var(--focus); background: rgba(8, 8, 12, 0.75); }
.ed-gate-id-value:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.ed-gate-back {
  display: inline-block;
  margin-top: 26px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
}
.ed-gate-back:hover { color: var(--ink); }

@keyframes ed-rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* ============================================================
   Shell + top bar
   ============================================================ */
.ed-shell[hidden] { display: none; }

.ed-bar {
  flex: none;
  position: relative;
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: rgba(7, 7, 11, 0.78);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--panel-edge);
}

.ed-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}
.ed-brand:hover { color: var(--ink); }
.ed-brand-mark {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ink);
  opacity: 0.7;
}

.ed-bar-status {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* One tab per page the account holds. Sits ahead of the URL pill
   because it says WHICH page that URL belongs to. */
.ed-pages {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--panel-edge);
  background: rgba(255, 255, 255, 0.03);
  flex: none;
}
.ed-pages[hidden] { display: none; }

.ed-page {
  max-width: 130px;
  padding: 4px 11px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11.5px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.2s ease, color 0.2s ease;
}
.ed-page:hover { color: var(--ink); background: rgba(255, 255, 255, 0.06); }
.ed-page.on {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.11);
  cursor: default;
}
/* The draft tab is a label, not a target — there is nowhere to go. */
.ed-page:disabled { cursor: default; opacity: 1; }
.ed-page.add { padding: 4px 10px; font-size: 14px; line-height: 1; }
.ed-page:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* the live URL, always in the bar rather than buried in a card */
.ed-url {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 320px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--panel-edge);
  background: rgba(255, 255, 255, 0.04);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.ed-url:hover { color: var(--ink); border-color: var(--field-edge); }
.ed-url[hidden] { display: none; }

.ed-dirty {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11.5px;
  letter-spacing: 0.02em;
  text-transform: lowercase;
  color: #ffcf70;
  white-space: nowrap;
}
.ed-dirty::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}
.ed-dirty[hidden] { display: none; }

.ed-bar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ed-user { position: relative; }
.ed-user-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  font: inherit;
  padding: 4px 8px 4px 4px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: none;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.ed-user-btn:hover,
.ed-user-btn[aria-expanded='true'] {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--field-edge);
}
.ed-user-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.ed-user img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: #1E222C;
  border: 1px solid var(--panel-edge);
}
.ed-user-name {
  font-size: 13px;
  color: var(--muted);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* a plain chevron, drawn rather than fetched */
.ed-user-caret {
  width: 7px;
  height: 7px;
  margin-right: 1px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: translateY(-2px) rotate(45deg);
  transition: transform 0.2s var(--ease);
}
.ed-user-btn[aria-expanded='true'] .ed-user-caret { transform: translateY(1px) rotate(225deg); }

.ed-user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 90;
  min-width: 160px;
  padding: 6px;
  display: grid;
  gap: 2px;
  border-radius: 12px;
  border: 1px solid var(--panel-edge);
  background: rgba(16, 16, 22, 0.96);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}
.ed-user-menu[hidden] { display: none; }
.ed-user-item {
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.ed-user-item:hover { background: rgba(255, 255, 255, 0.08); }

@media (max-width: 760px) { .ed-user-name { display: none; } }

/* ---------- buttons ---------- */
.ed-btn {
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid var(--field-edge);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s var(--ease), opacity 0.2s ease;
}
.ed-btn:hover { background: rgba(255, 255, 255, 0.11); border-color: rgba(255, 255, 255, 0.24); }
.ed-btn:active { transform: translateY(1px); }
.ed-btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.ed-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.ed-btn.primary {
  background: var(--ink);
  color: #0b0b10;
  border-color: transparent;
  font-weight: 700;
  min-width: 84px;
}
.ed-btn.primary:hover { background: #fff; }
.ed-btn.primary:disabled { background: rgba(255, 255, 255, 0.22); color: rgba(255, 255, 255, 0.5); }
.ed-btn.ghost { background: transparent; }
/* Revert sits next to Save, so it has to match it exactly */
#revert { min-width: 84px; font-weight: 700; }
.ed-btn.small { padding: 6px 12px; font-size: 12.5px; }
.ed-btn.danger { color: var(--danger); border-color: rgba(255, 107, 107, 0.35); background: rgba(255, 107, 107, 0.08); }
.ed-btn.danger:hover { background: rgba(255, 107, 107, 0.16); border-color: rgba(255, 107, 107, 0.5); }

.ed-inline-btn {
  font: inherit;
  font-size: inherit;
  color: var(--ink);
  background: none;
  border: none;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.35);
  padding: 0;
  cursor: pointer;
}
.ed-inline-btn:hover { border-bottom-style: solid; }

/* ============================================================
   App layout

   The whole editor is one viewport-height frame. Only the middle
   column scrolls — the rail and the preview never move, so the card is
   always on screen while you are changing it.
   ============================================================ */
/* vh first, dvh second: browsers without dvh drop that declaration and
   keep the vh, rather than dropping `height` altogether and collapsing
   the shell to auto. */
body.ed-app { height: 100vh; height: 100dvh; overflow: hidden; }
body.ed-app .ed-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.ed-main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 186px minmax(0, 1fr) minmax(360px, 0.82fr);
}

/* ---------- section rail ---------- */
.ed-rail {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px 12px;
  overflow-y: auto;
  border-right: 1px solid var(--panel-edge);
}

.ed-rail-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
.ed-rail-item:hover { background: rgba(255, 255, 255, 0.05); color: var(--ink); }
.ed-rail-item[aria-current="true"] {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--panel-edge);
  color: var(--ink);
}
.ed-rail-item:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.ed-rail-item svg {
  width: 17px;
  height: 17px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ed-rail-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* a dot on any section holding changes you have not saved yet */
.ed-rail-dot {
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: #ffcf70;
  box-shadow: 0 0 8px rgba(255, 207, 112, 0.6);
}
.ed-rail-dot[hidden] { display: none; }

.ed-rail-item.danger { color: rgba(255, 107, 107, 0.7); margin-top: auto; }
.ed-rail-item.danger:hover { color: var(--danger); background: rgba(255, 107, 107, 0.08); }

/* ---------- the scrolling column ---------- */
.ed-panel {
  min-width: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px 24px 80px;
  scroll-behavior: smooth;
}

.ed-form { display: flex; flex-direction: column; gap: 18px; min-width: 0; max-width: 720px; }

/* the panel scrolls constantly — keep its bar out of the way */
.ed-panel, .ed-rail, .ed-icon-grid { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.16) transparent; }
.ed-panel::-webkit-scrollbar, .ed-rail::-webkit-scrollbar, .ed-icon-grid::-webkit-scrollbar { width: 9px; height: 9px; }
.ed-panel::-webkit-scrollbar-track, .ed-rail::-webkit-scrollbar-track, .ed-icon-grid::-webkit-scrollbar-track { background: transparent; }
.ed-panel::-webkit-scrollbar-thumb, .ed-rail::-webkit-scrollbar-thumb, .ed-icon-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border: 2px solid transparent;
  background-clip: padding-box;
  border-radius: 999px;
}
.ed-panel:hover::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.24); background-clip: padding-box; }

/* only the active section is mounted on screen */
.ed-card.off { display: none; }
.ed-card { animation: ed-panel-in 0.24s var(--ease) both; }
@keyframes ed-panel-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.ed-card {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 18px;
  padding: 22px 22px 24px;
}
.ed-card[hidden] { display: none; }
.ed-card h2 {
  margin: 0 0 18px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.ed-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.ed-card-head h2 { margin: 0; }

/* ---------- fields ---------- */
.ed-field { display: block; margin-bottom: 18px; }
.ed-field:last-child { margin-bottom: 0; }
/* display:block above outranks the UA [hidden] rule — say it again */
.ed-field[hidden] { display: none; }

.ed-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
  font-size: 13.5px;
  color: rgba(255, 255, 255, 0.82);
}
.ed-label em {
  font-style: normal;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--muted);
}

.editor input[type="text"],
.editor input[type="url"],
.editor input[type="search"],
.editor textarea {
  width: 100%;
  padding: 11px 13px;
  border-radius: 11px;
  background: var(--field);
  border: 1px solid var(--field-edge);
  color: var(--ink);
  font: inherit;
  font-size: 14.5px;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.editor textarea { resize: vertical; min-height: 76px; line-height: 1.5; }
.editor input::placeholder,
.editor textarea::placeholder { color: rgba(255, 255, 255, 0.28); }
.editor input:focus,
.editor textarea:focus {
  outline: none;
  border-color: var(--focus);
  background: rgba(8, 8, 12, 0.75);
}
.editor input[aria-invalid="true"] { border-color: var(--danger); }

.ed-hint {
  display: block;
  margin-top: 7px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}
.ed-hint.bad { color: var(--danger); }
.ed-hint.good { color: var(--ok); }

.ed-empty {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
}
.ed-empty[hidden] { display: none; }

/* ---------- slug ---------- */
.ed-slug {
  display: flex;
  align-items: center;
  border-radius: 11px;
  background: var(--field);
  border: 1px solid var(--field-edge);
  overflow: hidden;
  transition: border-color 0.2s ease;
}
.ed-slug:focus-within { border-color: var(--focus); }
.ed-slug-host {
  padding: 11px 2px 11px 13px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13.5px;
  color: var(--muted);
  white-space: nowrap;
}
.ed-slug input {
  border: none !important;
  background: none !important;
  padding-left: 2px !important;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13.5px !important;
}

/* ---------- ranges ---------- */
.editor input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: none;
  cursor: pointer;
}
.editor input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.16);
}
.editor input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.16);
}
.editor input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  margin-top: -5.5px;
  border-radius: 50%;
  background: var(--ink);
  border: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}
.editor input[type="range"]::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--ink);
  border: none;
}
.editor input[type="range"]:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; border-radius: 4px; }

/* ---------- colour ---------- */
.ed-color { display: flex; gap: 8px; align-items: center; }
.ed-color input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 44px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--field-edge);
  border-radius: 11px;
  background: none;
  cursor: pointer;
  flex: none;
}
.ed-color input[type="color"]::-webkit-color-swatch-wrapper { padding: 3px; }
.ed-color input[type="color"]::-webkit-color-swatch { border: none; border-radius: 8px; }
.ed-color input[type="color"]::-moz-color-swatch { border: none; border-radius: 8px; }
.ed-color input[type="text"] { font-family: 'IBM Plex Mono', monospace; text-transform: lowercase; }

.ed-grid2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 18px;
}
.ed-span2 { grid-column: 1 / -1; }
@media (max-width: 560px) { .ed-grid2 { grid-template-columns: minmax(0, 1fr); } }

/* ---------- look presets ---------- */
.ed-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}
.ed-preset {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: var(--swatch, #101016);
  transition: transform 0.25s var(--ease), border-color 0.2s ease;
}
.ed-preset:hover { transform: translateY(-2px); border-color: rgba(255, 255, 255, 0.45); }
.ed-preset:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ============================================================
   Links
   ============================================================ */
.ed-links { display: flex; flex-direction: column; gap: 10px; }
.ed-links:not(:empty) + .ed-empty { display: none; }

.ed-link {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-edge);
  transition: border-color 0.2s ease, opacity 0.2s ease, background 0.2s ease;
}
.ed-link.dragging { opacity: 0.4; }
.ed-link.over { border-color: var(--focus); background: rgba(255, 255, 255, 0.07); }

.ed-drag {
  width: 22px;
  height: 34px;
  cursor: grab;
  border: none;
  background: none;
  color: rgba(255, 255, 255, 0.28);
  display: grid;
  place-items: center;
  padding: 0;
}
.ed-drag:hover { color: var(--ink); }
.ed-drag:active { cursor: grabbing; }
.ed-drag svg { width: 16px; height: 16px; fill: currentColor; }

/* the icon button — mask-image renders any of the 4,800 icons in the
   current text colour, without fetching or inlining its markup */
.ed-icon-btn {
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 11px;
  border: 1px solid var(--field-edge);
  background: var(--field);
  cursor: pointer;
  display: grid;
  place-items: center;
  color: var(--ink);
  transition: border-color 0.2s ease, background 0.2s ease;
}
.ed-icon-btn:hover { border-color: var(--focus); background: rgba(255, 255, 255, 0.07); }
.ed-icon-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.ed-ico {
  display: block;
  width: 21px;
  height: 21px;
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}

.ed-link-fields { display: grid; gap: 7px; min-width: 0; }
.ed-link-fields input { font-size: 13.5px !important; padding: 8px 11px !important; }

.ed-link-x {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: none;
  color: rgba(255, 255, 255, 0.35);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
}
.ed-link-x:hover { color: var(--danger); background: rgba(255, 107, 107, 0.12); }

/* ============================================================
   Media fields
   ============================================================ */
.ed-media { display: grid; gap: 14px; }

.ed-media-item {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 14px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed var(--panel-edge);
  transition: border-color 0.2s ease, background 0.2s ease;
}
/* display:grid above outranks the UA [hidden] rule — say it again */
.ed-media-item[hidden] { display: none; }
.ed-media-item.drop { border-color: var(--focus); background: rgba(255, 255, 255, 0.07); }
.ed-media-item.busy { opacity: 0.6; pointer-events: none; }

.ed-thumb {
  width: 74px;
  height: 74px;
  border-radius: 11px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--panel-edge);
  overflow: hidden;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.25);
  position: relative;
}
.ed-thumb img, .ed-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ed-thumb svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; }

.ed-media-body { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.ed-media-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.ed-media-name { font-size: 13.5px; }
.ed-media-cap { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--muted); }
.ed-media-actions { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.ed-media-url { font-size: 12.5px !important; padding: 8px 11px !important; }
.ed-media-status { font-size: 11.5px; color: var(--muted); font-family: 'IBM Plex Mono', monospace; }
.ed-media-status.bad { color: var(--danger); }

.ed-bar-progress {
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
.ed-bar-progress i {
  display: block;
  height: 100%;
  background: var(--ink);
  width: 0;
  transition: width 0.2s linear;
}

/* ---------- uploads library ---------- */
.ed-uploads { display: grid; gap: 8px; }
.ed-upload {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 11px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-edge);
  font-size: 13px;
}
.ed-upload code {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11.5px;
  color: var(--muted);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ed-upload .used { color: var(--ok); font-size: 11px; }

/* ---------- danger ---------- */
.ed-danger { border-color: rgba(255, 107, 107, 0.22); }
.ed-danger-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.ed-danger-row strong { font-size: 14px; font-weight: 500; }
.ed-danger-row p { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); max-width: 44ch; }

/* ============================================================
   Preview

   #frame scopes the per-profile custom properties, so the real .card
   rules from style.css paint exactly as they will on the live page.
   ============================================================ */
.ed-preview {
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--panel-edge);
  padding: 14px 16px 16px;
  background: rgba(0, 0, 0, 0.18);
}

.ed-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  color: var(--muted);
}
.ed-preview-title { font-size: 14px; font-weight: 700; color: var(--ink); }
.ed-preview-tools { display: flex; align-items: center; gap: 8px; }
.ed-preview-open { color: var(--ink); text-decoration: none; font-size: 12.5px; }
.ed-preview-open[hidden] { display: none; }
.ed-preview-x { display: none; }

/* desktop / phone segmented control */
.ed-seg {
  display: flex;
  padding: 2px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-edge);
}
.ed-seg button {
  border: none;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}
.ed-seg button:hover { color: var(--ink); }
.ed-seg button[aria-pressed="true"] { background: rgba(255, 255, 255, 0.14); color: var(--ink); }

.ed-frame {
  position: relative;
  flex: 1;
  min-height: 0;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--panel-edge);
  background: #06060a;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 26px 18px;
  isolation: isolate;
}

.ed-frame-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-size: cover;
  background-position: center;
}
.ed-frame-bg video, .ed-frame-bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
/* The same scrim the live page puts over .bg-media, and for the same
   reason it has to be the same one: this was a flat 35% wash, so the
   preview showed a background lighter and flatter than the real thing
   and the dimming dial had nothing to act on in here. */
.ed-frame-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 70% at center,
      rgba(0, 0, 0, calc(0.62 * var(--bg-scrim, 1))) 0%,
      rgba(0, 0, 0, calc(0.76 * var(--bg-scrim, 1))) 55%,
      rgba(0, 0, 0, calc(0.94 * var(--bg-scrim, 1))) 100%),
    linear-gradient(to bottom,
      rgba(0, 0, 0, calc(0.35 * var(--bg-scrim, 1))),
      transparent 28%,
      transparent 72%,
      rgba(0, 0, 0, calc(0.45 * var(--bg-scrim, 1))));
}

/* The card is laid out at its true width (580 desktop, 390 phone) and
   then zoomed to fit the pane, so proportions match the live page and
   nothing is ever cut off. --pv-w / --pv-zoom are set from JS. */
.ed-frame-scale {
  position: relative;
  z-index: 1;
  flex: none;
  width: var(--pv-w, 580px);
  zoom: var(--pv-zoom, 1);
}
.ed-frame .card { max-width: 100%; }
/* The children don't replay their reveal on every keystroke — but the
   sheen and the sparkles are profile settings now, so they stay: you
   cannot pick a sparkle count you can't see. */
.ed-frame .reveal { opacity: 1; transform: none; animation: none; }

/* Phone width should look like a phone: style.css narrows the card at
   620px of *viewport*, which the pane never hits, so mirror it here. */
.ed-frame[data-device="phone"] .card {
  padding: 34px 22px 40px;
  border-radius: 22px;
}
.ed-frame[data-device="phone"] .avatar-wrap {
  width: min(var(--avatar-size, 116px), 96px);
  height: min(var(--avatar-size, 116px), 96px);
}
.ed-frame[data-device="phone"] .links { gap: 16px; }
.ed-frame[data-device="phone"] .links .ed-ico { width: 24px; height: 24px; }

/* ---------- field ⇄ preview link ----------
   Focus a field and the thing it changes is outlined in the preview,
   so you never have to hunt for what moved. */
.ed-frame .pv-hot {
  outline: 1.5px dashed rgba(255, 255, 255, 0.55);
  outline-offset: 7px;
  border-radius: 6px;
  animation: ed-hot-in 0.3s ease both;
}
.ed-frame-bg.pv-hot { outline-offset: -8px; border-radius: 18px; }
@keyframes ed-hot-in { from { outline-color: transparent; } }

/* ============================================================
   Narrow screens

   The rail folds into a strip of tabs and the preview becomes a sheet
   you pull up over the form — still one keypress away, still never
   something you have to scroll to.
   ============================================================ */
.ed-preview-fab {
  display: none;
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 999px;
  border: 1px solid var(--field-edge);
  background: rgba(14, 14, 20, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.6);
}
.ed-preview-fab svg {
  width: 17px; height: 17px;
  fill: none; stroke: currentColor; stroke-width: 1.8;
}

@media (max-width: 1180px) {
  .ed-main { grid-template-columns: 64px minmax(0, 1fr) minmax(320px, 0.72fr); }
  .ed-rail-item { justify-content: center; padding: 12px 0; }
  .ed-rail-label { display: none; }
  .ed-rail-dot { position: absolute; top: 7px; right: 11px; }
  .ed-panel { padding: 20px 18px 80px; }
}

@media (max-width: 900px) {
  .ed-main { grid-template-columns: 64px minmax(0, 1fr); }
  .ed-preview-fab { display: inline-flex; }

  /* The sheet stays open while you type — the form keeps its own
     scroll and gains room underneath, so you are still editing against
     a card you can see. */
  .ed-shell { --sheet-h: min(58dvh, 520px); }
  .ed-shell.preview-open .ed-panel { padding-bottom: calc(var(--sheet-h) + 24px); }

  .ed-preview {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 70;
    height: var(--sheet-h);
    border-left: none;
    border-top: 1px solid var(--panel-edge);
    border-radius: 20px 20px 0 0;
    background: rgba(10, 10, 15, 0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.6);
    transform: translateY(102%);
    transition: transform 0.32s var(--ease);
  }
  .ed-shell.preview-open .ed-preview { transform: none; }
  .ed-shell.preview-open .ed-preview-fab { display: none; }
  .ed-preview-x {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 9px;
    border: 1px solid var(--field-edge);
    background: none;
    color: var(--muted);
    font-size: 19px;
    line-height: 1;
    cursor: pointer;
  }
}

@media (max-width: 600px) {
  .ed-main { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .ed-rail {
    flex-direction: row;
    gap: 6px;
    padding: 10px 12px;
    border-right: none;
    border-bottom: 1px solid var(--panel-edge);
    overflow-x: auto;
    overflow-y: hidden;
  }
  .ed-rail-item { width: auto; padding: 9px 13px; }
  .ed-rail-item.danger { margin-top: 0; margin-left: auto; }
  .ed-rail-label { display: block; }
  .ed-rail-dot { position: static; }
  .ed-bar { padding: 10px 12px; gap: 10px; }
  .ed-url { display: none; }
  .ed-panel { padding: 16px 14px 90px; }
}

/* ============================================================
   Icon picker
   ============================================================ */
.ed-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 20px;
}
.ed-modal[hidden] { display: none; }

.ed-modal-scrim {
  position: absolute;
  inset: 0;
  background: rgba(4, 4, 7, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: ed-fade 0.2s ease both;
}

.ed-modal-panel {
  position: relative;
  width: min(760px, 100%);
  max-height: min(80dvh, 680px);
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  background: #0d0d13;
  border: 1px solid rgba(255, 255, 255, 0.13);
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.7);
  overflow: hidden;
  animation: ed-pop 0.28s var(--ease) both;
}

@keyframes ed-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ed-pop {
  from { opacity: 0; transform: translateY(12px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

/* The panel is a column flex box whose middle child is a grid of
   thousands of cells. Head, tabs and foot must hold their own height
   or the grid squeezes them flat. */
.ed-modal-head, .ed-tabs, .ed-modal-foot { flex: none; }

.ed-modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--panel-edge);
}
.ed-modal-head input { font-size: 15px !important; }

.ed-modal-x {
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 10px;
  border: 1px solid var(--field-edge);
  background: none;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.ed-modal-x:hover { color: var(--ink); background: rgba(255, 255, 255, 0.07); }

.ed-tabs {
  display: flex;
  gap: 6px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--panel-edge);
  overflow-x: auto;
}
.ed-tab {
  /* the strip scrolls sideways — tabs must keep their own width rather
     than squash into each other when the sets do not fit */
  flex: none;
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid var(--field-edge);
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}
.ed-tab:hover { color: var(--ink); }
.ed-tab[aria-selected="true"] {
  color: #0b0b10;
  background: var(--ink);
  border-color: transparent;
  font-weight: 600;
}

.ed-icon-grid {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
  gap: 6px;
  align-content: start;
}
.ed-icon-grid:focus-visible { outline: none; }

.ed-icon-cell {
  aspect-ratio: 1;
  border-radius: 11px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.035);
  color: rgba(255, 255, 255, 0.86);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s var(--ease);
}
.ed-icon-cell:hover,
.ed-icon-cell.active {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.28);
  transform: translateY(-1px);
  color: #fff;
}
.ed-icon-cell[aria-current="true"] { border-color: var(--ink); }
.ed-icon-cell .ed-ico { width: 24px; height: 24px; }

.ed-icon-more {
  grid-column: 1 / -1;
  padding: 14px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.ed-modal-foot {
  padding: 10px 16px;
  border-top: 1px solid var(--panel-edge);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--muted);
}

/* ============================================================
   Emoji picker

   Shares the modal, the tabs and the grid with the icon picker; only
   the cells and the chosen-row are its own. An emoji cell holds a glyph
   rather than a mask, so it wants a font stack and no colour of its own
   — the emoji brings its own colours.
   ============================================================ */
/* the row in the side panel: what is picked, and the way in */
.ed-emoji-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.ed-emoji-set {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  min-height: 34px;
  align-items: center;
}

.ed-emoji-chip {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid var(--field-edge);
  background: rgba(255, 255, 255, 0.04);
  font-family: var(--emoji-font);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s var(--ease);
}
.ed-emoji-chip:hover:not(:disabled) {
  background: rgba(255, 80, 80, 0.14);
  border-color: rgba(255, 120, 120, 0.5);
  transform: translateY(-1px);
}
/* the last one is not removable — say so by look as well as by tooltip */
.ed-emoji-chip:disabled { cursor: default; opacity: 0.75; }
.ed-emoji-chip:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.ed-emoji-add {
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--field-edge);
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}
.ed-emoji-add:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.26);
}
.ed-emoji-add:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* the same row again, inside the dialog, so the set stays in sight
   while you browse a thousand cells */
.ed-emoji-picked {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--panel-edge);
}
.ed-emoji-picked-label {
  flex: none;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.ed-emoji-grid { grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); }

.ed-emoji-cell {
  aspect-ratio: 1;
  border-radius: 10px;
  border: 1px solid transparent;
  background: none;
  font-family: var(--emoji-font);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s var(--ease);
}
.ed-emoji-cell:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px) scale(1.06);
}
.ed-emoji-cell:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.ed-emoji-cell[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.14);
  border-color: var(--ink);
}

/* ============================================================
   Toasts
   ============================================================ */
.ed-toasts {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.ed-toast {
  padding: 11px 18px;
  border-radius: 12px;
  background: rgba(14, 14, 20, 0.95);
  border: 1px solid var(--panel-edge);
  color: var(--ink);
  font-size: 13.5px;
  max-width: min(440px, calc(100vw - 40px));
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.55);
  animation: ed-toast-in 0.3s var(--ease) both;
}
.ed-toast.bad { border-color: rgba(255, 107, 107, 0.45); color: #ffc9c9; }
.ed-toast.good { border-color: rgba(95, 210, 140, 0.4); }
.ed-toast.out { animation: ed-toast-out 0.3s ease forwards; }

@keyframes ed-toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}
@keyframes ed-toast-out {
  to { opacity: 0; transform: translateY(8px); }
}

@media (prefers-reduced-motion: reduce) {
  .editor *, .editor *::before, .editor *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* The preview draws its link icons as masks too, so it needs the sizing
   that style.css gives real <svg> children of .links. */
.ed-frame .links .ed-ico { width: 27px; height: 27px; }
.ed-frame .links a { cursor: default; }

/* ============================================================
   Admin
   ============================================================ */
.ed-admin-table { display: grid; gap: 8px; }

.ed-admin-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-edge);
}
/* The allowlist rows have no drag grip and nothing to hide, so they
   drop the two columns the profile rows need. */
.ed-admin-row.plain { grid-template-columns: minmax(0, 1fr) auto; }
.ed-admin-row.hidden-profile { opacity: 0.55; }
.ed-admin-row .grip { color: rgba(255, 255, 255, 0.28); cursor: grab; }
.ed-admin-row.dragging { opacity: 0.4; }
.ed-admin-row.over { border-color: var(--focus); }

.ed-admin-name { min-width: 0; }
.ed-admin-name strong { display: block; font-size: 14px; font-weight: 500; }
.ed-admin-name code {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11.5px;
  color: var(--muted);
}
.ed-admin-actions { display: flex; gap: 6px; }

/* ID, note and the add button on one line, collapsing to a stack when
   there is no room for three. */
.ed-allow-form {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}
.ed-allow-form input { font-family: 'IBM Plex Mono', monospace; font-size: 13.5px !important; }
@media (max-width: 640px) {
  .ed-allow-form { grid-template-columns: minmax(0, 1fr); }
}

/* ============================================================
   Toggle

   Used for the Discord card. There is no user-ID field any more — the
   page always shows the account that owns it — so the only choice left
   is whether the card appears at all.
   ============================================================ */
.ed-toggle {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}
.ed-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }

.ed-toggle-track {
  position: relative;
  flex: none;
  width: 42px;
  height: 24px;
  margin-top: 1px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--field-edge);
  transition: background 0.25s ease, border-color 0.25s ease;
}
.ed-toggle-track i {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  transition: transform 0.25s var(--ease), background 0.25s ease;
}
.ed-toggle input:checked + .ed-toggle-track {
  background: rgba(255, 255, 255, 0.9);
  border-color: transparent;
}
.ed-toggle input:checked + .ed-toggle-track i {
  transform: translateX(18px);
  background: #0b0b10;
}
.ed-toggle input:focus-visible + .ed-toggle-track { outline: 2px solid var(--focus); outline-offset: 3px; }

.ed-toggle-label { display: grid; gap: 3px; min-width: 0; }
.ed-toggle-label strong { font-size: 13.5px; font-weight: 500; color: rgba(255, 255, 255, 0.82); }
.ed-toggle-label em {
  font-style: normal;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 7px;
}
.ed-toggle-label em img {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #1E222C;
}

/* The linked account, shown on its own now that the Discord card is
   chosen by the card-slot control rather than by a toggle here. */
.ed-who {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
}
.ed-who img {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #1E222C;
}

/* live / not-live indicator on the presence hint */
.ed-pip {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: 1px;
  background: var(--muted);
}
.ed-pip.live { background: var(--ok); box-shadow: 0 0 8px rgba(95, 210, 140, 0.7); }

/* ============================================================
   Effects controls

   Motion, Cursor and Scene are generated from FX_GROUPS at runtime, so
   these rules dress a handful of widget shapes rather than any
   particular field. Adding a knob to fx-schema.js needs nothing here.
   ============================================================ */

/* the generated cards sit inside a host div, which is the thing the
   section rail shows and hides */
.ed-fx-host { display: contents; }
.ed-fx-host.off { display: none; }

.ed-fx-field { margin-bottom: 16px; }
.ed-fx-field[hidden] { display: none; }
.ed-fx-field .ed-hint { margin-top: 6px; }

/* ---------- chips: one button per enum value ---------- */
.ed-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ed-chip {
  padding: 7px 12px;
  border-radius: 9px;
  border: 1px solid var(--field-edge);
  background: var(--field);
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.18s var(--ease);
}
.ed-chip:hover { color: var(--ink); border-color: rgba(255, 255, 255, 0.26); }
.ed-chip:active { transform: translateY(1px); }
.ed-chip:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.ed-chip[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.92);
  border-color: transparent;
  color: #0b0b10;
  font-weight: 600;
}

/* ---------- themes ---------- */
.ed-themes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 8px;
  margin-top: 14px;
}
.ed-theme {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--panel-edge);
  background: var(--field);
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
  transition: transform 0.2s var(--ease), border-color 0.2s ease, background 0.2s ease;
}
.ed-theme:hover {
  transform: translateY(-2px);
  border-color: var(--swatch);
  background: rgba(255, 255, 255, 0.06);
}
.ed-theme:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.ed-theme-dot {
  flex: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: 0 0 12px var(--swatch);
}

/* ---------- replay ---------- */
.ed-preview-replay {
  border: 1px solid var(--panel-edge);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  padding: 5px 11px;
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.18s ease, background 0.18s ease;
}
.ed-preview-replay:hover { color: var(--ink); background: rgba(255, 255, 255, 0.11); }
.ed-preview-replay:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- preview pane ----------
   The pane is the fx runtime's viewport: the canvas, the drawn pointer
   and the atmosphere overlay all position themselves against it, so it
   has to be a containing block and has to clip. */
/* Only ever on screen when one of the visitor's own OS settings is
   suppressing the effects — see paintEnvironmentNote() in editor.js. */
.ed-preview-note {
  flex: none;
  margin: 0 0 10px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 209, 102, 0.28);
  background: rgba(255, 209, 102, 0.08);
  color: rgba(255, 226, 160, 0.92);
  font-size: 12.5px;
  line-height: 1.45;
}
.ed-preview-note[hidden] { display: none; }

.ed-frame { position: relative; overflow: hidden; }

/* Layer order inside the pane mirrors the live page: media, then the
   particles and atmosphere, then the card (.ed-frame-scale, z-index 1),
   with the drawn pointer over the lot. Leaving these above the scale
   wrapper hides the card behind its own snowfall. */
.ed-frame .fx-canvas,
.ed-frame .fx-overlay,
.ed-frame .cursor-glow {
  z-index: 0;
  border-radius: inherit;
}
.ed-frame .fx-cursor { z-index: 6; border-radius: inherit; }

/* No gate in here, so nothing to wait for: undo the hold that style.css
   puts on the entrance and the reveals until `body.revealed`. Important
   for the same reason the hold is — see the note beside it. */
.ed-frame .card,
.ed-frame .reveal { animation-play-state: running !important; }
.ed-frame .card { will-change: transform; }
