:root {
  /* Cobalt. Blue-black ground, one electric accent, red reserved for live
     signals. Every colour below is referenced through a token - nothing in
     this file hard-codes a hue, so swapping themes is swapping this block. */
  --bg: #080b14;
  --surface: #0f1522;
  --surface-2: #162033;
  --stage: #000000;
  --field: #0b1019;
  --border: #1b2740;

  --text: #e6ecf7;
  --muted: #7f8ca6;

  --accent: #2f6bff;
  --accent-text: #ffffff;
  --on-bright: #050a14;      /* ink on an accent-coloured fill */

  --live: #ff4757;           /* viewer count, offline dot - signals, not UI */
  --danger: #ff6b6b;
  --ok: #3ddc97;

  --radius: 6px;
  --radius-lg: 8px;
  --bar-h: 52px;
  --chat-w: 340px;

  --font: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

/* The `hidden` attribute only works through the browser's default stylesheet,
   which ANY author rule setting `display` outranks. Give a class both a
   display value and a `hidden` attribute and the element stays on screen,
   while every `el.hidden = true` in the JS silently does nothing. The
   !important here wins regardless of source order, so this holds no matter
   where a later rule appears. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
}

a { color: var(--accent); }
.mono { font-family: var(--font-mono); }
.dim { color: var(--muted); }
.small-text { font-size: 12px; }
.right { text-align: right; }

/* --- header ---------------------------------------------------------------- */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: var(--bar-h);
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 700; letter-spacing: -.02em; font-size: 17px;
  text-decoration: none; color: var(--text);
}

.bar-right { display: flex; align-items: center; gap: 14px; }
.bar-right form { margin: 0; }
.who { color: var(--muted); font-size: 13px; }

button.link, a.link {
  background: none; border: 0; padding: 0;
  color: var(--accent); font: inherit; font-size: 13px;
  cursor: pointer; text-decoration: none;
}

/* --- forms ----------------------------------------------------------------- */

body.centred main { display: flex; justify-content: center; padding: 48px 16px; }

.card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}
.card h1 { margin: 0 0 20px; font-size: 20px; font-weight: 600; }
.card.notice { max-width: 460px; text-align: center; }
.card.notice h1 { margin-bottom: 12px; }
.reason {
  margin: 0 0 16px; padding: 10px 12px;
  background: var(--surface-2); border-radius: var(--radius);
  color: var(--text); font-size: 14px;
}

label { display: block; margin: 16px 0 6px; font-size: 13px; color: var(--muted); }

/* Match by exclusion, not by listing types. An attribute selector like
   [type=text] only matches when the attribute is literally present, so any
   <input> written without one - which behaves as text - fell through to the
   browser's native white box. */
input:not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=button]):not([type=file]),
select, textarea {
  width: 100%; padding: 10px 12px;
  background: var(--field); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .75; }
input:disabled, textarea:disabled { opacity: .6; }

input[type=checkbox], input[type=radio] {
  width: auto; margin: 0; accent-color: var(--accent);
}

/* File inputs size to their content instead of stretching a whole panel. */
input[type=file] {
  width: auto; max-width: 100%;
  padding: 7px 10px;
  background: var(--field); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--muted); font: inherit; font-size: 13px;
}
input[type=file]::file-selector-button {
  margin-right: 10px; padding: 6px 12px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  font: inherit; font-size: 13px; cursor: pointer;
}
input[type=file]::file-selector-button:hover { border-color: var(--accent); }
input[type=file]:focus { outline: none; border-color: var(--accent); }

/* Chrome paints autofilled fields yellow with its own text colour, and neither
   responds to `background`. The inset shadow is the only way to cover it. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--field) inset;
  box-shadow: 0 0 0 1000px var(--field) inset;
  caret-color: var(--text);
  border: 1px solid var(--border);
  transition: background-color 100000s ease-in-out 0s;
}

button.primary, a.as-button {
  display: inline-block; width: 100%; margin-top: 22px;
  padding: 11px 16px; background: var(--accent); color: var(--accent-text);
  border: 0; border-radius: var(--radius); font: inherit; font-weight: 600;
  cursor: pointer; text-align: center; text-decoration: none;
}
button.primary:hover, a.as-button:hover { filter: brightness(1.08); }
button.primary:disabled { opacity: .5; cursor: default; }
button.primary.small, button.small, button.danger {
  width: auto; margin: 0; padding: 7px 12px;
  font-size: 13px; font-weight: 500; border-radius: var(--radius);
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); cursor: pointer;
}
button.primary.small { background: var(--accent); border-color: var(--accent); font-weight: 600; }
button.danger { background: transparent; border-color: color-mix(in srgb, var(--danger) 42%, transparent); color: var(--danger); }
button.danger:hover { background: color-mix(in srgb, var(--danger) 13%, transparent); }

.error {
  margin: 0 0 4px; padding: 10px 12px;
  background: color-mix(in srgb, var(--danger) 11%, transparent); border: 1px solid color-mix(in srgb, var(--danger) 36%, transparent);
  border-radius: var(--radius); color: var(--danger); font-size: 14px;
}
.ok-banner {
  margin: 0 0 4px; padding: 10px 12px;
  background: color-mix(in srgb, var(--ok) 11%, transparent); border: 1px solid color-mix(in srgb, var(--ok) 36%, transparent);
  border-radius: var(--radius); color: var(--ok); font-size: 14px;
}
.muted { margin-top: 20px; color: var(--muted); font-size: 13px; }

/* --- blank refusal page ---------------------------------------------------- */

body.blank { height: 100vh; }
.blank-main { display: flex; align-items: center; justify-content: center; height: 100vh; }
.blank-message { margin: 0; color: var(--muted); font-size: 18px; letter-spacing: .3px; }

/* --- player + chat layout -------------------------------------------------- */
/*
 * The video area is a flex child that owns whatever space the chat column does
 * not. The <video> is absolutely positioned inside it with object-fit: contain,
 * so it scales to the largest size that fits without cropping and without
 * forcing letterbox bars from a hard-coded aspect ratio.
 */

body.app { height: 100vh; overflow: hidden; }
body.app main { height: calc(100vh - var(--bar-h)); }

.layout { display: flex; height: 100%; }

.stage-wrap {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--stage);
}

.stage { position: relative; width: 100%; height: 100%; }

.stage video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: var(--stage);
}

.overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  transition: opacity .2s;
}
.overlay.hidden { opacity: 0; pointer-events: none; }
.overlay p { margin: 0; color: var(--muted); }
.overlay button.primary { width: auto; margin: 0; }

.spinner {
  width: 26px; height: 26px;
  border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 1s linear infinite; opacity: 0;
}
.overlay.busy .spinner { opacity: 1; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

.unmute {
  position: absolute; left: 16px; bottom: 16px;
  padding: 9px 14px; background: color-mix(in srgb, var(--bg) 82%, transparent);
  border: 1px solid var(--border); border-radius: 999px;
  color: var(--text); font: inherit; font-size: 13px; cursor: pointer;
}

/* --- chat ------------------------------------------------------------------ */

.chat {
  position: relative;
  flex: 0 0 var(--chat-w);
  width: var(--chat-w);
  display: flex; flex-direction: column;
  border-left: 1px solid var(--border);
  background: var(--surface);
  min-height: 0;
}

.chat-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .5px; color: var(--muted);
}
/* Viewer count: a red person glyph and the number, no wording. */
.viewers {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px 3px 7px;
  background: color-mix(in srgb, var(--live) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--live) 34%, transparent);
  border-radius: 999px;
  color: var(--live);
  font-size: 13px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-transform: none; letter-spacing: 0;
}
.viewer-icon { width: 13px; height: 13px; fill: currentColor; display: block; }

.messages {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  padding: 10px 12px;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.msg { padding: 3px 0; line-height: 1.45; }
.msg.notice { color: var(--muted); font-style: italic; }
.msg-time { color: var(--muted); font-size: 11px; margin-right: 6px;
  font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.msg-user { font-weight: 700; }
.msg-colon { color: var(--muted); }

img.emote {
  height: 32px; width: auto; max-width: 96px;
  vertical-align: middle; margin: -6px 2px;
}

.composer { padding: 10px 12px; border-top: 1px solid var(--border); }
.composer-row { display: flex; align-items: center; gap: 6px; }
.composer-row input[type=text] { flex: 1 1 auto; padding: 9px 10px; }
.composer button.primary.small { width: 100%; margin-top: 8px; }
.composer-note { margin: 8px 0 0; font-size: 12px; color: var(--muted); }

button.icon {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  background: transparent; border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--muted);
  font-size: 16px; line-height: 1; cursor: pointer;
}
button.icon:hover { color: var(--text); border-color: var(--accent); }

/* --- popovers -------------------------------------------------------------- */

.popover {
  position: absolute; right: 12px; bottom: 96px; z-index: 20;
  width: calc(var(--chat-w) - 24px);
  max-height: 320px; overflow-y: auto;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0,0,0,.5);
}
.popover-head {
  margin: 4px 0 8px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px; color: var(--muted);
}
.popover-note { margin: 10px 0 0; font-size: 12px; color: var(--ok); min-height: 16px; }

.emote-grid { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.emote-pick {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid transparent; border-radius: var(--radius);
  cursor: pointer; font-size: 20px; padding: 2px;
}
.emote-pick:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.emote-pick img { max-width: 100%; max-height: 100%; }

.switch { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; color: var(--text); font-size: 14px; }
.switch input { width: auto; margin: 0; }

.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer; padding: 0;
}
.swatch.on { border-color: var(--text); }

/* --- admin ----------------------------------------------------------------- */

body.admin-page main { padding: 20px 16px 60px; }
.admin { max-width: 1000px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }

.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.panel h2 { margin: 0 0 14px; font-size: 16px; font-weight: 600; }

.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.inline-form input:not([type=file]) { width: auto; flex: 1 1 160px; }
.inline-form input[type=file] { flex: 0 1 auto; }
.inline-form input.tiny { width: 70px; flex: 0 0 auto; }
.inline-form input.tiny-text { width: 120px; flex: 0 0 auto; padding: 6px 8px; font-size: 13px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; padding: 8px 10px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px; color: var(--muted);
  border-bottom: 1px solid var(--border);
}
td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }

td.actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
td.actions form { display: flex; gap: 4px; align-items: center; margin: 0; }

.tag {
  display: inline-block; padding: 2px 7px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
}
.tag.free { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.tag.used { background: var(--surface-2); color: var(--muted); }
.tag.banned { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.tag.admin { background: color-mix(in srgb, var(--accent) 17%, transparent); color: var(--accent); margin-left: 6px; }

.emote-admin-grid { display: flex; flex-wrap: wrap; gap: 12px; }
.emote-card {
  margin: 0; padding: 10px; width: 110px; text-align: center;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
}
.emote-card img { height: 40px; width: auto; max-width: 100%; }
.emote-card figcaption { margin: 6px 0 8px; font-size: 12px; overflow-wrap: anywhere; }
.emote-card form { margin: 0; }
.emote-card button { width: 100%; }

/* --- narrow screens --------------------------------------------------------- */

@media (max-width: 860px) {
  body.app { overflow: auto; height: auto; }
  body.app main { height: auto; }
  .layout { flex-direction: column; }
  .stage-wrap { aspect-ratio: 16 / 9; width: 100%; }
  .chat {
    flex: 1 1 auto; width: 100%;
    height: 60vh; border-left: 0; border-top: 1px solid var(--border);
  }
  .popover { width: calc(100% - 24px); }
  td.actions { justify-content: flex-start; }
}

/* ============================================================================
   Additions: avatars, menus, modals, tabs, moderation, offline screen
   ========================================================================== */

/* --- avatars & header menu -------------------------------------------------- */

.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  object-fit: cover;
  display: inline-flex; align-items: center; justify-content: center;
  vertical-align: middle;
  flex: 0 0 auto;
}
.avatar.letter {
  color: var(--on-bright); font-weight: 700; font-size: 13px; line-height: 1;
  text-transform: uppercase;
}
.avatar.big { width: 64px; height: 64px; font-size: 26px; }

.avatar-btn {
  padding: 0; background: none; border: 0; cursor: pointer;
  border-radius: 50%; line-height: 0;
}
.avatar-btn:hover .avatar { box-shadow: 0 0 0 2px var(--accent); }

.bar-right { position: relative; }

.menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 40;
  min-width: 180px; padding: 6px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,.5);
}
.menu form { margin: 0; }
.menu-who {
  padding: 8px 10px 10px; border-bottom: 1px solid var(--border);
  margin-bottom: 6px; font-size: 14px;
}
.menu-item {
  display: block; width: 100%; text-align: left;
  padding: 8px 10px; margin: 0;
  background: none; border: 0; border-radius: var(--radius);
  color: var(--text); font: inherit; font-size: 14px;
  cursor: pointer; text-decoration: none;
}
.menu-item:hover { background: color-mix(in srgb, var(--text) 8%, transparent); }

/* --- modal ------------------------------------------------------------------ */

.modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 20px; background: rgba(0,0,0,.6);
}
.modal-card {
  width: 100%; max-width: 460px; max-height: 82vh;
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.modal-body { padding: 16px; overflow-y: auto; }
.modal .icon { width: 28px; height: 28px; font-size: 18px; }

.settings-avatar { display: flex; align-items: center; gap: 16px; margin-bottom: 8px; }
.settings-avatar label { margin-top: 0; }
.settings-avatar input[type=file] { font-size: 13px; }

.popover-note.bad { color: var(--danger); }

/* --- offline screen --------------------------------------------------------- */
/* Both layers are always present; only opacity changes, so a retry can never
   cause a flash of layout. */

.stage video { opacity: 0; transition: opacity .35s ease; }
.stage video.on { opacity: 1; }

.offline {
  position: absolute; inset: 0; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  background: var(--stage);
  opacity: 1; transition: opacity .35s ease;
}
.offline.gone { opacity: 0; pointer-events: none; }
.offline img { width: 100%; height: 100%; object-fit: contain; display: block; }

.offline-default { text-align: center; color: var(--muted); padding: 24px; }
.offline-default p { margin: 14px 0 6px; font-size: 18px; color: var(--text); }
.offline-default span { font-size: 13px; }
.offline-dot {
  width: 10px; height: 10px; margin: 0 auto; border-radius: 50%;
  background: var(--live);
  animation: offline-pulse 2.4s ease-out infinite;
}
@keyframes offline-pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--live) 55%, transparent); }
  70%,
  100% { box-shadow: 0 0 0 15px transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .offline-dot { animation: none; box-shadow: 0 0 0 5px color-mix(in srgb, var(--live) 18%, transparent); }
}

/* --- composer --------------------------------------------------------------- */

.input-shell {
  position: relative;
  display: flex; align-items: center;
  background: var(--field); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding-right: 4px;
}
.input-shell:focus-within { border-color: var(--accent); }
.input-shell.locked { opacity: .65; }
.input-shell input[type=text] {
  flex: 1 1 auto; min-width: 0;
  background: none; border: 0; padding: 10px 4px 10px 12px;
}
.input-shell input[type=text]:focus { outline: none; }

button.in-input {
  flex: 0 0 auto;
  width: 30px; height: 30px; margin: 0 2px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 0; border-radius: var(--radius);
  color: color-mix(in srgb, var(--text) 62%, transparent);
  font-size: 16px; line-height: 1; cursor: pointer;
}
button.in-input:hover:not(:disabled) { color: var(--text); background: color-mix(in srgb, var(--text) 8%, transparent); }
button.in-input.send { background: var(--accent); color: var(--accent-text); font-weight: 700; }
button.in-input.send:hover:not(:disabled) { filter: brightness(1.1); background: var(--accent); }
button.in-input:disabled { opacity: .45; cursor: default; }

/* --- messages & moderation -------------------------------------------------- */

.msg { position: relative; }
.msg-user.clickable { cursor: pointer; }
.msg-user.clickable:hover { text-decoration: underline; }
.deleted-note { color: var(--muted); }

.mod-card { bottom: 70px; max-height: 400px; }
.mod-head {
  display: flex; align-items: center; gap: 8px;
  padding-bottom: 10px; margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.mod-head strong { flex: 1 1 auto; overflow-wrap: anywhere; }
.mod-head .icon { width: 24px; height: 24px; font-size: 16px; border: 0; }
.mod-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.mod-actions button { font-size: 12px; padding: 5px 9px; }
.timeout-row {
  display: flex; flex-wrap: wrap; gap: 5px; align-items: center;
  width: 100%; padding: 8px; border-radius: var(--radius); background: color-mix(in srgb, var(--text) 4%, transparent);
}
.mod-log {
  max-height: 150px; overflow-y: auto;
  background: var(--field); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px; font-size: 12px;
}

.log-line { padding: 3px 0; display: flex; gap: 8px; align-items: baseline; }
.log-line.deleted .log-text { color: var(--muted); text-decoration: line-through; }
.log-time { color: var(--muted); font-size: 11px; flex: 0 0 auto;
  font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.log-text { overflow-wrap: anywhere; }
.log-mark { color: var(--danger); font-size: 11px; flex: 0 0 auto; }

/* --- admin tabs ------------------------------------------------------------- */

.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }
.tab {
  padding: 9px 15px; background: none; border: 0;
  border-bottom: 2px solid transparent; border-radius: var(--radius) 8px 0 0;
  color: var(--muted); font: inherit; font-size: 14px; cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.on { color: var(--text); border-bottom-color: var(--accent); }

.spaced { margin-top: 28px !important; }
.rule { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
.user-cell { display: flex; align-items: center; gap: 9px; }

.tag.role-admin { background: color-mix(in srgb, var(--accent) 17%, transparent); color: var(--accent); }
.tag.role-moderator { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.tag.role-user { background: var(--surface-2); color: var(--muted); }

.upload-row { max-width: 520px; }
.offline-preview {
  max-width: 420px; margin-bottom: 12px;
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  background: var(--stage);
}
.offline-preview img { display: block; width: 100%; height: auto; }

/* --- settings modal actions ------------------------------------------------- */

.modal-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border);
}
.modal-actions button { margin: 0; }

/* --- admin overlay ---------------------------------------------------------- */

.overlay {
  position: fixed; inset: 0; z-index: 120;
  display: flex; align-items: center; justify-content: center;
  padding: 24px; background: rgba(0,0,0,.65);
}
.overlay-card {
  width: 100%; max-width: 1100px; height: 88vh;
  display: flex; flex-direction: column;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
  box-shadow: 0 24px 70px rgba(0,0,0,.65);
}
.overlay-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.overlay iframe { flex: 1 1 auto; width: 100%; border: 0; background: var(--bg); }

/* The admin page inside the frame drops its own chrome. */
body.embedded { background: var(--bg); }
body.embedded main { padding: 0; }
.embedded-admin { max-width: none; padding: 18px; }

/* --- profile window --------------------------------------------------------- */

.profile {
  position: fixed;
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 90;
  width: 340px; max-width: calc(100vw - 24px);
  background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: 0 18px 50px rgba(0,0,0,.6);
  overflow: hidden;
}
.profile.dragging { user-select: none; }

.profile-head {
  position: relative;
  display: flex; align-items: center; gap: 4px;
  padding: 9px 8px 9px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  cursor: grab;
  touch-action: none;
}
.profile.dragging .profile-head { cursor: grabbing; }
.profile-title {
  flex: 1 1 auto; font-weight: 600; font-size: 14px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.profile-head .icon { width: 26px; height: 26px; font-size: 15px; border: 0; }

.small-menu { top: calc(100% + 4px); right: 8px; min-width: 150px; }

.profile-body { padding: 14px; max-height: 60vh; overflow-y: auto; }

.profile-top { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.profile-meta { min-width: 0; }
.profile-meta strong { display: block; font-size: 16px; overflow-wrap: anywhere; }
.profile-meta .tag { margin-top: 3px; }
.profile-mod { border-top: 1px solid var(--border); padding-top: 12px; }

@media (max-width: 860px) {
  .overlay { padding: 0; }
  .overlay-card { height: 100vh; max-width: none; border-radius: 0; border: 0; }
}

/* --- stacked forms (general tab) -------------------------------------------- */

.stacked-form { max-width: 520px; }
.stacked-form .switch { margin-bottom: 8px; }
.stacked-form button { margin-top: 12px; }

/* --- two-column tab panels --------------------------------------------------- */

.two-up {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 20px;
  align-items: start;
}
.two-up .panel { margin: 0; }
.two-up .offline-preview { max-width: 100%; }
