/* ===== Ruckus AI — styles ===== */
:root {
  /* Dark surfaces, lifted a step off near-black so content doesn't feel lost in
     a void (base ~#1a1a1d). The whole dark-surface ramp moves up together so the
     stepping stays consistent; still a dark theme. */
  --bg: #1A1A1D;
  --surface: #232327;
  --surface-2: #2B2B32;
  --surface-3: #34343F;
  --accent: #6C63FF;
  --accent-soft: rgba(108, 99, 255, 0.14);
  --accent-glow: rgba(108, 99, 255, 0.35);
  --text: #E8E8F0;
  --muted: #7A7A8C;
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.12);
  --radius: 8px;
  --radius-lg: 12px;
  --danger: #FF5C6C;
  --ok: #44D88B;
  /* progress-bar accents (stage-aware thinking bubble) */
  --orange: #F97316;
  --orange-2: #FB923C;
  --indigo: #6366F1;
  /* ---- Mode color system (single source of truth) ----
     One hue per mode, matching the welcome mode cards: Game Addons = purple,
     Web = green, General = amber. Used by the mode badge, thinking bubbles,
     progress bars, and the Ranks FAB accent — so each mode reads as one
     consistent color everywhere. `-2` = lighter gradient stop; `-text` =
     readable-on-dark text tint (amber runs a slightly deeper text tone so it
     doesn't glare, with the brighter tone reserved for bars/accents). */
  --mode-game: #6C63FF;         --mode-game-2: #A79FFF;    --mode-game-text: #BDB6FF;
  --mode-web: #44D88B;          --mode-web-2: #7FE9B4;     --mode-web-text: #7FE9B4;
  --mode-general: #FFCB6B;      --mode-general-2: #FFE0A3; --mode-general-text: #F2BA5C;
  --dim: #6B6B7B;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
/* Ensure the [hidden] attribute always wins over author display rules
   (modals and the auth screen set display:flex). */
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
/* The opaque base background lives on the ROOT (html), with body transparent, so
   the translucent sidebar (background: color-mix(--surface, transparent)) shows
   the base through it rather than an opaque body box. Kept as-is. */
html { background: var(--bg); }
body {
  background: transparent;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; color: inherit; }
::selection { background: color-mix(in srgb, var(--mode-accent) 32%, transparent); }

/* ============================================================
   Coordinated mode accent — a single active-mode colour resolved on #app from
   the ONE data-mode source of truth that renderModeBadge() already stamps. Every
   restrained accent below (send button, focus ring, active pill, header hairline,
   links, active-chat indicator) reads var(--mode-accent), so they all retint
   together the instant the mode changes. Registered so the colour interpolates:
   #app transitions --mode-accent over .5s → the whole set cross-fades at once,
   matching the glow/badge. `-fg` is the readable foreground on a mode-coloured
   fill (dark on the light amber/green fills, white on the darker purple).
   ============================================================ */
@property --mode-accent      { syntax: '<color>'; inherits: true; initial-value: #FFCB6B; }
@property --mode-accent-2    { syntax: '<color>'; inherits: true; initial-value: #FFE0A3; }
@property --mode-accent-fg   { syntax: '<color>'; inherits: true; initial-value: #14141A; }
#app {
  --mode-accent: var(--mode-general); --mode-accent-2: var(--mode-general-2); --mode-accent-fg: #14141A;
  transition: --mode-accent .5s ease, --mode-accent-2 .5s ease, --mode-accent-fg .5s ease;
}
#app[data-mode="gameaddons"] { --mode-accent: var(--mode-game);    --mode-accent-2: var(--mode-game-2);    --mode-accent-fg: #FFFFFF; }
#app[data-mode="web"]        { --mode-accent: var(--mode-web);     --mode-accent-2: var(--mode-web-2);     --mode-accent-fg: #14141A; }
#app[data-mode="general"]    { --mode-accent: var(--mode-general); --mode-accent-2: var(--mode-general-2); --mode-accent-fg: #14141A; }

/* scrollbars */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #2a2a35; border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: #3a3a48; background-clip: padding-box; }

#app { display: flex; height: 100vh; overflow: hidden; }


/* ===== Sidebar ===== */
.sidebar {
  position: relative;            /* desktop base — mobile overrides with position: fixed !important */
  width: 270px;
  flex-shrink: 0;
  /* ~20% more transparent than the opaque surface (alpha 1 → 0.8) for a slightly
     softer panel that lets the base show through. Still clearly its own surface
     (lighter than the transparent chat area, plus the right border). */
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform .25s ease;
}
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; cursor: pointer; border-radius: 8px; transition: opacity .12s; }
.brand:hover { opacity: .82; }
.brand:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.brand-mark { display: flex; filter: drop-shadow(0 2px 8px var(--accent-glow)); }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.brand-ai { color: var(--accent); }

.new-chat {
  margin: 0 12px 12px;
  display: flex; align-items: center; gap: 8px; justify-content: center;
  background: var(--accent-soft);
  color: var(--text);
  border: 1px solid rgba(108,99,255,0.25);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-weight: 600; font-size: 14px;
  transition: background .15s, border-color .15s, transform .05s;
}
.new-chat:hover { background: rgba(108,99,255,0.22); border-color: rgba(108,99,255,0.45); }
.new-chat:active { transform: translateY(1px); }

.conv-list { flex: 1; overflow-y: auto; padding: 4px 8px 8px; }
.conv-group-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); padding: 12px 8px 6px; font-weight: 600;
}
.conv-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px; border-radius: var(--radius);
  cursor: pointer; position: relative;
  transition: background .12s;
}
.conv-item:hover { background: var(--surface-2); }
.conv-item.active { background: var(--surface-3); }
.conv-item.active::before {
  content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px;
  background: var(--mode-accent); border-radius: 0 3px 3px 0; /* active-chat indicator = mode colour */
}
.conv-main { min-width: 0; flex: 1; }
.conv-title {
  font-size: 13.5px; font-weight: 500; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.conv-meta { font-size: 11px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.conv-mode-tag { color: var(--accent); font-weight: 600; }
.conv-del {
  opacity: 0; background: none; border: none; padding: 4px;
  color: var(--muted); border-radius: 6px; display: flex;
  transition: opacity .12s, color .12s, background .12s;
}
.conv-item:hover .conv-del { opacity: 1; }
.conv-del:hover { color: var(--danger); background: rgba(255,92,108,0.12); }
.conv-rename-btn {
  opacity: 0; background: none; border: none; padding: 4px;
  color: var(--muted); border-radius: 6px; display: flex;
  transition: opacity .12s, color .12s, background .12s;
}
.conv-item:hover .conv-rename-btn { opacity: 1; }
.conv-rename-btn:hover { color: var(--accent); background: rgba(108,99,255,0.14); }
.conv-title-input {
  width: 100%; font-size: 13.5px; font-weight: 500; font-family: inherit;
  color: var(--text); background: transparent;
  border: none; border-bottom: 1px solid var(--accent); outline: none;
  box-shadow: none; padding: 0 0 1px; margin: 0;
}

.sidebar-foot { padding: 10px 12px; border-top: 1px solid var(--border); overflow: visible; }

/* ===== buttons ===== */
.icon-btn {
  background: none; border: none; color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  padding: 7px; border-radius: var(--radius);
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.ghost-btn {
  display: flex; align-items: center; gap: 8px; width: 100%;
  justify-content: flex-start;
  background: none; border: 1px solid transparent; color: var(--muted);
  padding: 8px 10px; border-radius: var(--radius); font-size: 13.5px; font-weight: 500;
  transition: background .12s, color .12s, border-color .12s;
}
.ghost-btn:hover { background: var(--surface-2); color: var(--text); }
.ghost-btn.active { background: var(--accent-soft); color: var(--text); border-color: rgba(108,99,255,0.3); }
.ghost-btn.small { width: auto; padding: 6px 10px; font-size: 12.5px; border: 1px solid var(--border); }
.ghost-btn.small:hover { border-color: var(--border-strong); }
.primary-btn {
  background: var(--accent); color: #fff; border: none;
  padding: 10px 20px; border-radius: var(--radius); font-weight: 600; font-size: 14px;
  transition: background .15s, transform .05s, box-shadow .15s;
  box-shadow: 0 2px 14px var(--accent-glow);
}
.primary-btn:hover { background: #7B72FF; }
.primary-btn:active { transform: translateY(1px); }

/* ===== Main ===== */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 20px; border-bottom: 1px solid var(--border);
  /* The single active-mode accent hairline — a 2px top edge in the mode colour
     (the one such line in the UI). Cross-fades via --mode-accent. */
  border-top: 2px solid var(--mode-accent);
  flex-shrink: 0;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.status-chip {
  font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px;
}
/* At-a-glance current-mode indicator (colours match the .think-bubble gradients) */
.mode-badge {
  display: inline-flex; align-items: center; white-space: nowrap;
  font-size: 11.5px; font-weight: 600; padding: 4px 11px; border-radius: 999px;
  border: 1px solid transparent; color: var(--muted); background: var(--surface-2);
}
.mode-badge:empty { display: none; }
/* Mode badge: text + subtle tint/border in the mode's canonical color
   (Game = purple, Web = green, General = amber — same hues as the thinking
   bubbles and mode cards). */
.mode-badge[data-mode="gameaddons"] {
  color: var(--mode-game-text);
  background: color-mix(in srgb, var(--mode-game) 14%, transparent);
  border-color: color-mix(in srgb, var(--mode-game) 35%, transparent);
}
.mode-badge[data-mode="web"] {
  color: var(--mode-web-text);
  background: color-mix(in srgb, var(--mode-web) 12%, transparent);
  border-color: color-mix(in srgb, var(--mode-web) 35%, transparent);
}
.mode-badge[data-mode="general"] {
  color: var(--mode-general-text);
  background: color-mix(in srgb, var(--mode-general) 12%, transparent);
  border-color: color-mix(in srgb, var(--mode-general) 35%, transparent);
}

/* mode switch */
.mode-switch {
  position: relative; display: inline-flex;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px;
}
.mode-glider {
  position: absolute; top: 4px; bottom: 4px; left: 4px;
  border-radius: 999px; background: var(--mode-accent);        /* active pill = mode colour */
  box-shadow: 0 2px 12px color-mix(in srgb, var(--mode-accent) 35%, transparent);
  transition: transform .28s cubic-bezier(.4,1.2,.4,1), width .28s cubic-bezier(.4,1.2,.4,1);
  z-index: 0;
}
.mode-pill {
  position: relative; z-index: 1;
  background: none; border: none; color: var(--muted);
  padding: 7px 18px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
  display: flex; align-items: center; gap: 7px;
  transition: color .2s;
}
.mode-pill:hover { color: var(--text); }
/* Active pill sits on the mode-coloured glider → use the readable foreground
   (dark on light amber/green, white on purple), cross-faded via --mode-accent-fg. */
.mode-pill.active { color: var(--mode-accent-fg); transition: color .5s ease; }
.mode-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; opacity: .5; transition: opacity .2s;
}
.mode-pill.active .mode-dot { opacity: 1; background: currentColor; animation: pulse-dot 2s ease-in-out infinite; }

/* Game Addons quality tier — compact dropdown inside the composer (chat bar). The
   trigger matches the chat-bar control language; the menu opens upward above it. */
.tier-select { position: relative; flex-shrink: 0; align-self: flex-end; margin-bottom: 2px; }
.tier-select[hidden] { display: none; }
.tier-btn {
  display: inline-flex; align-items: center; gap: 4px;
  height: 34px; padding: 0 8px 0 11px; border-radius: 9px;
  background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text);
  font: inherit; font-size: 13px; font-weight: 600; white-space: nowrap; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.tier-btn:hover { background: var(--surface-3); border-color: var(--mode-accent); }
.tier-caret { color: var(--muted); transition: transform .15s; }
.tier-btn[aria-expanded="true"] .tier-caret { transform: rotate(180deg); }
.tier-menu {
  position: absolute; bottom: calc(100% + 8px); left: 0; z-index: 30;
  min-width: 232px; padding: 6px;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg); box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
  animation: fade .12s ease;
}
.tier-menu[hidden] { display: none; }
.tier-option {
  display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left;
  padding: 8px 10px; border: none; border-radius: 8px; background: none; cursor: pointer;
  transition: background .12s;
}
.tier-option:hover { background: var(--surface-3); }
.tier-option-title { font-size: 13px; font-weight: 600; color: var(--text); }
.tier-option-sub { font-size: 11.5px; color: var(--muted); line-height: 1.35; white-space: normal; }
/* Selected option = current mode accent tick via a left border + accented title. */
.tier-option[aria-checked="true"] { background: color-mix(in srgb, var(--mode-accent) 14%, transparent); }
.tier-option[aria-checked="true"] .tier-option-title { color: var(--mode-accent); }
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.3); }
}

/* ===== Game Picker modal (Game Addons) ===== */
.game-picker-backdrop {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.game-picker {
  position: relative;
  background: #16161A; border: 1px solid #2A2A35; border-radius: 16px;
  padding: 32px; width: 420px; max-width: 92vw;
  animation: gamePickerIn .2s ease;
}
@keyframes gamePickerIn { from { opacity: 0; transform: scale(.95); } to { opacity: 1; transform: scale(1); } }
.game-picker-title { margin: 0; color: #E8E8F0; font-size: 1.2rem; font-weight: 700; }
.game-picker-sub { margin: 6px 0 22px; color: #7A7A8C; font-size: 0.85rem; }
.game-picker-cards { display: flex; gap: 14px; }

/* Import & modify — ownership acknowledgement modal */
.import-ack { max-width: 480px; text-align: left; }
.import-ack .game-picker-title, .import-ack .game-picker-sub { text-align: left; }
.import-ack-check {
  display: flex; gap: 12px; align-items: flex-start; cursor: pointer;
  padding: 14px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface-2); color: var(--text); font-size: 0.85rem; line-height: 1.5;
}
.import-ack-check:hover { border-color: rgba(108, 99, 255, 0.45); }
.import-ack-check input { margin-top: 2px; width: 16px; height: 16px; accent-color: var(--accent); flex: 0 0 auto; cursor: pointer; }
.import-ack-actions { display: flex; justify-content: flex-end; align-items: center; gap: 16px; margin-top: 20px; }
.import-ack-actions .primary-btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.game-card {
  flex: 1; display: flex; flex-direction: column; align-items: center; text-align: center;
  background: #0D0D0F; border: 1px solid #2A2A35; border-radius: 12px;
  padding: 24px 20px; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.game-card:hover { border-color: #6C63FF; background: #1A1A24; }
.game-card-icon { font-size: 2rem; line-height: 1; }
.game-card-name { margin-top: 12px; color: #E8E8F0; font-size: 1rem; font-weight: 700; }
.game-card-sub { margin-top: 4px; color: #7A7A8C; font-size: 0.8rem; }
.game-picker-close {
  position: absolute; top: 14px; right: 14px;
  background: none; border: none; cursor: pointer; padding: 4px;
  color: #7A7A8C; display: flex; transition: color .15s;
}
.game-picker-close:hover { color: #E8E8F0; }
.game-picker-back {
  display: inline-flex; align-items: center; gap: 5px;
  background: none; border: none; cursor: pointer; padding: 0 0 14px;
  color: #7A7A8C; font-size: 0.82rem; transition: color .15s;
}
.game-picker-back:hover { color: #E8E8F0; }

/* ===== Chat ===== */
.chat { flex: 1; min-height: 0; overflow-y: auto; scroll-behavior: smooth; }
.messages { max-width: 820px; margin: 0 auto; padding: 28px 24px 40px; display: flex; flex-direction: column; gap: 26px; }

.msg { display: flex; gap: 14px; animation: rise .25s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg-avatar {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
}
.msg.user .msg-avatar { background: var(--surface-3); color: var(--text); }
.msg.assistant .msg-avatar { background: linear-gradient(135deg, #8B7BFF, #5A4FE0); color: #fff; box-shadow: 0 2px 10px var(--accent-glow); }
.msg-body { min-width: 0; flex: 1; padding-top: 2px; position: relative; }
.msg-role { font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.msg-content { word-wrap: break-word; }

/* copy button on assistant messages (hover-reveal) */
.msg-copy {
  position: absolute; top: -2px; right: 0;
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; padding: 0;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--muted); border-radius: 7px; cursor: pointer;
  opacity: 0; transition: opacity .15s, color .15s, background .15s, border-color .15s;
}
.msg.assistant:hover .msg-copy { opacity: 1; }
.msg-copy:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }
.msg-copy.copied { color: var(--ok); border-color: rgba(68,216,139,0.4); opacity: 1; }

/* typing indicator (● ● ●) before the first chunk arrives */
.typing-dots { display: inline-flex; gap: 5px; padding: 4px 0; }
.typing-dots span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--muted);
  animation: typing-pulse 1.2s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .18s; }
.typing-dots span:nth-child(3) { animation-delay: .36s; }
@keyframes typing-pulse {
  0%, 60%, 100% { opacity: .25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* system note */
.sys-note {
  align-self: center; font-size: 12px; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border);
  padding: 5px 14px; border-radius: 999px;
}
.sys-note .accent { color: var(--accent); font-weight: 600; }

/* markdown content */
.msg-content p { margin: 0 0 12px; }
.msg-content p:last-child { margin-bottom: 0; }
.msg-content h1, .msg-content h2, .msg-content h3 { margin: 18px 0 10px; line-height: 1.3; font-weight: 650; }
.msg-content h1 { font-size: 1.4em; }
.msg-content h2 { font-size: 1.22em; }
.msg-content h3 { font-size: 1.08em; }
.msg-content ul, .msg-content ol { margin: 0 0 12px; padding-left: 22px; }
.msg-content li { margin: 4px 0; }
.msg-content a { color: var(--mode-accent); text-decoration: none; transition: color .5s ease; }
.msg-content a:hover { text-decoration: underline; }
.msg-content blockquote {
  margin: 0 0 12px; padding: 4px 14px; border-left: 3px solid var(--accent);
  color: var(--muted); background: var(--surface);
}
.msg-content code.inline {
  font-family: var(--mono); font-size: .88em;
  background: var(--surface-3); padding: 2px 6px; border-radius: 5px;
}
.msg-content table { border-collapse: collapse; margin: 0 0 12px; width: 100%; font-size: .92em; }
.msg-content th, .msg-content td { border: 1px solid var(--border-strong); padding: 6px 10px; text-align: left; }
.msg-content th { background: var(--surface); }
.msg-content hr { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

/* code blocks */
.code-block {
  position: relative; margin: 0 0 14px;
  background: #0A0A0C; border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
}
.code-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 12px; background: #141418; border-bottom: 1px solid var(--border);
  font-size: 11.5px; color: var(--muted);
}
.code-lang { font-family: var(--mono); text-transform: lowercase; letter-spacing: .03em; }
.code-copy {
  background: none; border: none; color: var(--muted); font-size: 11.5px;
  display: flex; align-items: center; gap: 5px; padding: 3px 7px; border-radius: 6px;
  transition: background .12s, color .12s;
}
.code-copy:hover { background: var(--surface-3); color: var(--text); }
.code-block pre { margin: 0; padding: 14px 16px; overflow-x: auto; }
.code-block code {
  font-family: var(--mono); font-size: 13px; line-height: 1.6;
  color: #D4D4E0; white-space: pre;
}

/* syntax tokens */
.tok-kw { color: #C792EA; }
.tok-str { color: #C3E88D; }
.tok-com { color: #5C6370; font-style: italic; }
.tok-num { color: #F78C6C; }
.tok-fn { color: #82AAFF; }
.tok-type { color: #FFCB6B; }
.tok-anno { color: #89DDFF; }
.tok-punc { color: #89DDFF; }

/* compile bar */
.compile-bar { margin: 2px 0 0; display: flex; flex-direction: column; gap: 8px; }

/* Broken-edit guard notice (Game Addons): shown when a follow-up would have wiped
   the project's main class / config, so it was not applied. */
.edit-guard-notice {
  display: flex; align-items: flex-start; gap: 10px; margin: 8px 0 0;
  padding: 12px 14px; border: 1px solid rgba(245, 158, 11, 0.4); border-radius: 10px;
  background: rgba(245, 158, 11, 0.08); color: var(--text); font-size: 13.5px; line-height: 1.5;
}
.edit-guard-notice .egn-icon { color: #F59E0B; flex: 0 0 auto; margin-top: 1px; }
.edit-guard-notice .egn-text { flex: 1; }
.edit-guard-notice .egn-text strong { color: #FDE68A; }
.edit-guard-notice .egn-retry {
  flex: 0 0 auto; align-self: center; background: rgba(108, 99, 255, 0.16);
  border: 1px solid rgba(108, 99, 255, 0.4); color: var(--accent);
  border-radius: 8px; padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.edit-guard-notice .egn-retry:hover { background: rgba(108, 99, 255, 0.26); }
.compile-btn {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent-soft); border: 1px solid rgba(108,99,255,0.3);
  color: var(--text); padding: 8px 14px; border-radius: var(--radius);
  font-weight: 600; font-size: 13px;
  transition: background .15s, border-color .15s, transform .05s;
}
.compile-btn:hover:not(:disabled) { background: rgba(108,99,255,0.22); border-color: rgba(108,99,255,0.5); }
.compile-btn:active:not(:disabled) { transform: translateY(1px); }
.compile-btn:disabled { opacity: .6; cursor: progress; }
.build-log {
  font-family: var(--mono); font-size: 12px; line-height: 1.55;
  background: #0A0A0C; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; max-height: 220px; overflow-y: auto; white-space: pre-wrap;
  color: var(--muted);
}
.build-log .ok { color: var(--ok); }
.build-log .err { color: var(--danger); }
.build-log .step { color: var(--text); }

/* Terminal-style build result */
.build-status { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.build-terminal {
  font-family: var(--mono); font-size: 12.5px; line-height: 1.6;
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
}
.build-terminal.ok { border-color: rgba(68,216,139,0.35); }
.build-terminal.err { border-color: rgba(255,92,108,0.35); }
.bt-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border);
  font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted);
}
.bt-badge { font-weight: 700; }
.build-terminal.ok .bt-badge { color: var(--ok); }
.build-terminal.err .bt-badge { color: var(--danger); }
.bt-body { padding: 12px 14px; color: #C0C0D0; white-space: pre-wrap; word-break: break-word; }
.bt-line { min-height: 1.6em; }
.bt-line.cmd { color: var(--text); }
.bt-line.ok { color: var(--ok); }
.bt-line.err { color: var(--danger); }
.bt-key { display: inline-block; min-width: 78px; color: var(--muted); }
.bt-download {
  width: 100%; margin-top: 8px; padding: 11px; border: none; border-radius: 10px;
  background: var(--ok); color: #08130C; font-family: inherit; font-weight: 700; font-size: 13px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: filter .15s, transform .1s;
}
.bt-download:hover { filter: brightness(1.08); }
.bt-download:active { transform: translateY(1px); }

/* Compile-error bubble: reason + trimmed errors + Auto Fix / View Full Log */
.build-error {
  font-family: var(--mono); font-size: 12.5px; line-height: 1.6;
  background: var(--bg); border: 1px solid rgba(255,92,108,0.35); border-radius: 10px;
  padding: 12px 14px; display: flex; flex-direction: column; gap: 10px;
}
.be-head { color: var(--danger); font-weight: 700; font-family: var(--font); font-size: 13.5px; }
.be-lines { display: flex; flex-direction: column; gap: 2px; color: #C0C0D0; white-space: pre-wrap; word-break: break-word; }
.be-line { min-height: 1.5em; }
.be-more { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.be-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.be-autofix {
  border: none; background: var(--accent); color: #fff; font-family: var(--font);
  font-size: 13px; font-weight: 700; cursor: pointer; padding: 8px 14px; border-radius: 8px;
  display: inline-flex; align-items: center; gap: 6px; transition: background .12s, transform .1s;
}
.be-autofix:hover { background: #7B72FF; }
.be-autofix:active { transform: translateY(1px); }
.be-cost { font-weight: 500; opacity: .85; }
.be-viewlog {
  border: 1px solid #2A2A35; background: transparent; color: #C0C0D0; font-family: var(--font);
  font-size: 12.5px; font-weight: 600; cursor: pointer; padding: 8px 12px; border-radius: 8px;
  transition: border-color .12s, background .12s;
}
.be-viewlog:hover { border-color: var(--accent); background: var(--surface-2); }
.build-fulllog {
  margin: 0; max-height: 260px; overflow: auto; white-space: pre-wrap; word-break: break-word;
  background: #0A0A0C; border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; color: var(--muted); font-size: 11.5px; line-height: 1.5;
}
.build-fulllog[hidden] { display: none; }

/* typing cursor */
.cursor-blink::after {
  content: '▋'; color: var(--accent); margin-left: 2px;
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.msg-error {
  background: rgba(255,92,108,0.08); border: 1px solid rgba(255,92,108,0.3);
  color: #FF9AA5; padding: 10px 14px; border-radius: var(--radius); font-size: 13.5px;
}

/* ===== Welcome ===== */
.welcome {
  max-width: 880px; margin: 0 auto; padding: 7vh 24px 40px;
  text-align: center; display: flex; flex-direction: column; align-items: center;
}
.welcome-mark {
  display: flex; align-items: center; justify-content: center;
  filter: drop-shadow(0 6px 24px var(--accent-glow)); margin-bottom: 18px;
}
.welcome-mark svg { display: block; margin: 0; }
.welcome-title { font-size: 38px; font-weight: 700; letter-spacing: -.02em; margin: 0 0 8px; }
.welcome-sub { color: var(--muted); font-size: 16px; margin: 0 0 36px; max-width: 480px; }
.mode-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; width: 100%; }
/* Each card is quietly associated with its own mode colour (a low-opacity border
   from --card-accent). The card matching the ACTIVE mode (#app[data-mode]) gets
   the full-strength treatment below. Border/tint cross-fade at .5s to match the
   rest of the mode-accent system; transform stays snappy for hover feedback. */
.mode-card {
  text-align: left; background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--card-accent) 28%, transparent);
  border-radius: var(--radius-lg); padding: 20px;
  transition: border-color .5s ease, box-shadow .5s ease, background .5s ease, transform .15s ease;
}
.mode-card[data-mode="gameaddons"] { --card-accent: var(--mode-game); }
.mode-card[data-mode="web"]        { --card-accent: var(--mode-web); }
.mode-card[data-mode="general"]    { --card-accent: var(--mode-general); }
.mode-card:hover { border-color: color-mix(in srgb, var(--card-accent) 55%, transparent); transform: translateY(-3px); }
/* Selected = the card for the currently active mode. Unmistakable: full-strength
   border + a 1px inner ring (reads as a touch thicker, no layout shift) + a faint
   matching tint. Higher specificity than :hover, so it holds while hovered too. */
#app[data-mode="gameaddons"] .mode-card[data-mode="gameaddons"],
#app[data-mode="web"]        .mode-card[data-mode="web"],
#app[data-mode="general"]    .mode-card[data-mode="general"] {
  border-color: var(--card-accent);
  box-shadow: inset 0 0 0 1px var(--card-accent);
  background: color-mix(in srgb, var(--card-accent) 7%, var(--surface));
}
.mc-icon {
  width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-size: 19px; margin-bottom: 14px;
}
.mc-icon.gameaddons { background: rgba(108,99,255,0.16); color: var(--accent); }
.mc-icon.web { background: rgba(68,216,139,0.14); color: var(--ok); }
.mc-icon.general { background: rgba(255,203,107,0.14); color: #FFCB6B; }
.mode-card h3 { margin: 0 0 6px; font-size: 15.5px; font-weight: 650; }
.mode-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.mode-card code { font-family: var(--mono); font-size: .9em; color: var(--text); }

/* starter prompt chips */
.starter-chips {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
  width: 100%; max-width: 680px; margin: 22px auto 0;
}
.starter-chip {
  text-align: left; background: #1E1E26; border: 1px solid #2A2A35;
  color: #C0C0D0; font-size: 13px; line-height: 1.35; font-weight: 500;
  padding: 11px 14px; border-radius: 10px; cursor: pointer;
  transition: border-color .15s, transform .12s, background .15s, color .15s;
}
.starter-chip:hover {
  border-color: var(--accent); color: var(--text); background: var(--surface-2);
  transform: translateY(-2px);
}
.starter-chip:active { transform: translateY(0); }

/* ===== Composer ===== */
.composer-wrap { flex-shrink: 0; padding: 0 24px 14px; max-width: 820px; margin: 0 auto; width: 100%; }

/* live cost preview pill (above the composer) */
.cost-preview {
  font-size: 0.75rem; font-weight: 500; color: var(--muted);
  max-height: 0; opacity: 0; overflow: hidden;
  transition: max-height .2s ease, opacity .2s ease, margin .2s ease;
  margin: 0 0 0 2px;
}
.cost-preview.visible { max-height: 1.4em; opacity: 1; margin: 0 0 6px 2px; }
.cost-preview.quick { color: #4ADE80; }
.cost-preview.standard { color: #7A7A8C; }
.cost-preview.deep { color: #FBBF24; }
.cost-preview.edit { color: #FB923C; } /* Web edit — flat 9-credit tier */

/* low credit warning banner (above the composer) */
.low-credit-banner {
  flex-shrink: 0; max-width: 820px; width: 100%; margin: 0 auto 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: #2A1F0A; border: 1px solid #92400E; color: #FCD34D;
  font-size: 0.8rem; padding: 8px 16px; border-radius: var(--radius);
  overflow: hidden; transition: opacity .25s ease, max-height .25s ease;
}
.low-credit-banner[hidden] { display: none; }
.low-credit-banner .lcb-bolt { margin-right: 2px; }
.lcb-link {
  background: none; border: none; color: #FCD34D; font-weight: 700;
  font-size: 0.8rem; cursor: pointer; white-space: nowrap; padding: 0;
}
.lcb-link:hover { text-decoration: underline; }

/* out-of-credits inline message (distinct from AI bubbles) */
.ooc-message {
  align-self: center; max-width: 560px; width: 100%;
  display: flex; align-items: flex-start; gap: 12px;
  background: rgba(146, 64, 14, 0.12); border: 1px solid #92400E;
  color: #FCD34D; border-radius: var(--radius-lg); padding: 16px 18px;
}
.ooc-message .ooc-icon { font-size: 18px; line-height: 1.2; }
.ooc-message .ooc-text { flex: 1; font-size: 14px; line-height: 1.5; }
.ooc-message .ooc-text strong { color: #FDE68A; }
.ooc-message .ooc-cta {
  align-self: center; background: #92400E; color: #FCD34D; border: none;
  font-weight: 650; font-size: 13px; padding: 9px 14px; border-radius: var(--radius);
  white-space: nowrap; cursor: pointer; transition: background .15s;
}
.ooc-message .ooc-cta:hover { background: #B45309; }

.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.attachment {
  display: flex; align-items: center; gap: 8px; background: var(--surface-2);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 6px 8px 6px 10px; font-size: 12.5px; max-width: 220px;
}
.attachment .att-icon { color: var(--accent); display: flex; }
.attachment .att-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attachment .att-size { color: var(--muted); flex-shrink: 0; }
.attachment .att-del { color: var(--muted); display: flex; padding: 2px; border-radius: 4px; }
.attachment .att-del:hover { color: var(--danger); }

.composer {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg); padding: 8px 8px 8px 10px;
  transition: border-color .15s, box-shadow .15s;
}
.composer:focus-within {
  border-color: var(--mode-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--mode-accent) 20%, transparent);
}
.composer-input {
  flex: 1; background: none; border: none; outline: none; resize: none;
  color: var(--text); font-family: inherit; font-size: 15px; line-height: 1.5;
  padding: 6px 4px; max-height: 200px;
}
.composer-input::placeholder { color: var(--muted); opacity: 1; transition: opacity .3s ease; }
.composer-input.ph-fade::placeholder { opacity: 0; } /* fade between rotating hints */
.attach-btn { align-self: flex-end; margin-bottom: 2px; }
.send-btn {
  /* The constant "you are in X mode" cue — filled with the mode colour, with the
     readable per-mode foreground (dark on light amber/green, white on purple).
     Background follows the interpolating --mode-accent for the .5s cross-fade;
     the short transitions here are just for hover/press. */
  flex-shrink: 0; width: 36px; height: 36px; border-radius: 9px; border: none;
  background: var(--mode-accent); color: var(--mode-accent-fg);
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .3s, transform .05s, opacity .15s;
}
.send-btn:hover:not(:disabled) { background: var(--mode-accent-2); }
.send-btn:active:not(:disabled) { transform: translateY(1px); }
.send-btn:disabled { background: var(--surface-3); color: var(--muted); cursor: not-allowed; }
.stop-btn {
  flex-shrink: 0; width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text); display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.stop-btn:hover { background: var(--surface-3); }
.composer-hint { text-align: center; font-size: 11.5px; color: var(--muted); margin: 8px 0 0; }

/* ===== Mode-mismatch "did you mean" nudge (above the composer) =====
   A small, non-blocking hint. Confirm button carries the DETECTED mode's
   canonical accent (via data-target) with a readable foreground. */
.mismatch-pop {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: 0 0 10px; padding: 10px 14px;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg); box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
  animation: fade .15s ease;
}
.mismatch-pop-text { flex: 1; min-width: 180px; font-size: 13px; color: var(--text); line-height: 1.5; }
.mismatch-pop-text strong { font-weight: 700; }
.mismatch-pop-note { display: block; margin-top: 4px; font-size: 11.5px; color: var(--muted); line-height: 1.4; }
/* "Older…" version dropdown inside the version popup — anchors the reused .tier-menu. */
.ver-pick { position: relative; display: inline-flex; }
.mismatch-pop-actions { display: flex; gap: 8px; flex-shrink: 0; }
.mismatch-yes, .mismatch-ignore {
  font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
  padding: 6px 14px; border-radius: 8px; transition: background .15s, color .15s, border-color .15s, filter .15s;
}
.mismatch-ignore { background: transparent; border: 1px solid var(--border-strong); color: var(--muted); }
.mismatch-ignore:hover { color: var(--text); background: var(--surface-3); }
/* Confirm button = detected mode's accent + readable foreground (dark on the
   light amber/green fills, white on the darker purple). */
.mismatch-yes { border: none; color: #14141A; background: var(--mode-general); }
.mismatch-pop[data-target="gameaddons"] .mismatch-yes { background: var(--mode-game); color: #FFFFFF; }
.mismatch-pop[data-target="web"]        .mismatch-yes { background: var(--mode-web);  color: #14141A; }
.mismatch-pop[data-target="general"]    .mismatch-yes { background: var(--mode-general); color: #14141A; }
.mismatch-yes:hover { filter: brightness(1.08); }

/* ===== Settings modal ===== */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center;
  z-index: 300; padding: 20px; animation: fade .15s ease; /* above the editor overlay (250) */
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg); width: 100%; max-width: 560px;
  max-height: 88vh; display: flex; flex-direction: column;
  box-shadow: 0 24px 70px rgba(0,0,0,0.5); animation: pop .2s cubic-bezier(.4,1.3,.5,1);
}
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(8px); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 18px; font-weight: 650; }
.modal-body { padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 22px; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 16px 20px; border-top: 1px solid var(--border); }

.field { display: flex; flex-direction: column; gap: 8px; }
.field > label { font-weight: 600; font-size: 13.5px; }
.field-hint { font-size: 12px; color: var(--muted); margin: 0; line-height: 1.45; }
.key-row { display: flex; gap: 8px; }
.key-row input { flex: 1; }
input[type="text"], input[type="password"], .prompt-area, .composer-input {
  font-family: inherit;
}
input[type="text"], input[type="password"] {
  background: var(--bg); border: 1px solid var(--border-strong); color: var(--text);
  padding: 10px 12px; border-radius: var(--radius); font-size: 14px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus { border-color: rgba(108,99,255,0.5); box-shadow: 0 0 0 3px var(--accent-soft); }
.prompt-area {
  background: var(--bg); border: 1px solid var(--border-strong); color: var(--text);
  padding: 12px; border-radius: var(--radius); font-size: 13.5px; line-height: 1.5;
  outline: none; resize: vertical; font-family: var(--mono);
  transition: border-color .15s, box-shadow .15s;
}
.prompt-area:focus { border-color: rgba(108,99,255,0.5); box-shadow: 0 0 0 3px var(--accent-soft); }
.prompt-tabs { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: var(--radius); width: fit-content; }
.ptab {
  background: none; border: none; color: var(--muted); padding: 6px 14px;
  border-radius: 6px; font-size: 13px; font-weight: 600; transition: background .12s, color .12s;
}
.ptab:hover { color: var(--text); }
.ptab.active { background: var(--surface-3); color: var(--text); }
.saved-note { color: var(--ok); font-size: 13px; font-weight: 600; }

/* toast */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--surface-3); border: 1px solid var(--border-strong); color: var(--text);
  padding: 11px 18px; border-radius: var(--radius); font-size: 13.5px; z-index: 80;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4); opacity: 0;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: rgba(255,92,108,0.5); }

.mobile-only { display: none; }

/* ===== credit balance + top up ===== */
.credit-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.credit-balance {
  display: flex; align-items: center; gap: 6px; flex: 1;
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 7px 10px; border-radius: var(--radius); font-size: 13.5px; font-weight: 600;
}
.credit-balance .bolt { color: var(--accent); }
.topup-btn {
  background: var(--accent); color: #fff; border: none; font-weight: 600; font-size: 13px;
  padding: 7px 14px; border-radius: var(--radius); transition: background .15s, transform .05s;
}
.topup-btn:hover { background: #7B72FF; }
.topup-btn:active { transform: translateY(1px); }

.account-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.account-email { font-size: 13.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== top up packs ===== */
.packs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 4px; }
.pack {
  position: relative; text-align: center; background: var(--surface-2);
  border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  padding: 18px 12px 16px; transition: border-color .15s, transform .15s, background .15s;
}
.pack:hover { border-color: rgba(108,99,255,0.5); transform: translateY(-3px); }
.pack.featured { border-color: rgba(108,99,255,0.55); background: var(--accent-soft); }
.pack-badge {
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #fff; font-size: 10.5px; font-weight: 700;
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.pack-name { font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.pack-credits { font-size: 22px; font-weight: 700; margin: 6px 0 2px; }
.pack-credits span { font-size: 12px; color: var(--muted); font-weight: 500; }
.pack-price { font-size: 15px; font-weight: 650; color: var(--accent); margin-top: 6px; }
.pack:disabled { opacity: .6; cursor: progress; }

.link-btn { background: none; border: none; color: var(--mode-accent); font-weight: 600; padding: 0; font-size: inherit; transition: color .5s ease; }
.link-btn:hover { text-decoration: underline; }

/* ===== auth screen ===== */
.auth-screen {
  position: fixed; inset: 0; z-index: 100; background: var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.auth-screen::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(900px 500px at 50% -10%, rgba(108,99,255,0.18), transparent 70%);
}
.auth-card {
  position: relative; width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg); padding: 32px 30px;
  box-shadow: 0 24px 70px rgba(0,0,0,0.5); animation: pop .25s cubic-bezier(.4,1.3,.5,1);
}
.auth-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 22px; }
.auth-brand .brand-name { font-weight: 700; font-size: 19px; }
.auth-title { font-size: 23px; font-weight: 700; margin: 0 0 4px; letter-spacing: -.01em; }
.auth-sub { color: var(--muted); margin: 0 0 24px; font-size: 14px; }
/* Google sign-in (kept light per Google brand guidelines — intentionally not themed) */
.google-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 11px; border-radius: var(--radius);
  background: #fff; color: #1F1F1F; border: 1px solid #DADCE0;
  font-size: 14px; font-weight: 600; font-family: inherit; cursor: pointer;
  transition: background .12s, box-shadow .12s;
}
.google-btn:hover { background: #F5F6F7; box-shadow: 0 1px 4px rgba(0,0,0,0.25); }
.google-btn:active { background: #ECEDEF; }
.google-btn:disabled { opacity: .6; cursor: progress; }
.google-g { flex-shrink: 0; }
.auth-divider {
  display: flex; align-items: center; text-align: center;
  color: var(--muted); font-size: 12px; margin: 16px 0;
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}
.auth-divider span { padding: 0 12px; }

.auth-form { display: flex; flex-direction: column; }
.auth-label { font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 0 0 6px; }
.auth-form input { margin-bottom: 16px; }
.auth-submit { width: 100%; margin-top: 4px; padding: 11px; justify-content: center; }
.auth-error {
  background: rgba(255,92,108,0.08); border: 1px solid rgba(255,92,108,0.3);
  color: #FF9AA5; padding: 9px 12px; border-radius: var(--radius); font-size: 13px; margin-bottom: 14px;
}
.auth-switch { text-align: center; font-size: 13.5px; color: var(--muted); margin: 20px 0 0; }
/* Post-signup "check your email" state — distinct from the sign-in form. */
#authVerify { text-align: center; }
.auth-verify-icon {
  width: 56px; height: 56px; margin: 4px auto 16px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--ok, #44d88b); background: color-mix(in srgb, var(--ok, #44d88b) 14%, transparent);
}
#authVerify .auth-sub { margin-bottom: 12px; }
#authVerify .auth-sub strong { color: var(--text); word-break: break-all; }
.auth-verify-note { font-size: 12.5px; color: var(--muted); line-height: 1.5; margin: 0 0 18px; }
.auth-verify-resend { display: inline-block; margin-top: 14px; font-size: 13.5px; }
.app-hidden { display: none !important; }

/* ===== rank system ===== */
/* Badge color comes from rank tier (applied inline by JS). */
/* The rank colour, glow, and text colour are applied INLINE per rank by
   paintBadge() (app.js) and override the fallback values below. No stylesheet
   rule overrides the inline background — if a badge ever looks un-coloured, the
   cause is a stale/cached asset, not this CSS. */
.rank-badge {
  display: inline-flex; align-items: center; flex-shrink: 0;
  font-size: 11px; font-weight: 700; letter-spacing: .03em;
  padding: 2px 9px; border-radius: 999px; white-space: nowrap;
  color: #0D0D0F; background: #7A7A8C;
}
.account-mini {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  margin-bottom: 9px; min-width: 0; overflow: visible;
}
/* Top row of the account block: rank badge on the left, Discord button on the
   right. Wraps gracefully if the sidebar gets too narrow. */
.account-mini-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; flex-wrap: wrap; row-gap: 6px; width: 100%;
}
/* Compact, understated Discord button — neutral by default, blurple on hover. */
.discord-btn {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; line-height: 1; white-space: nowrap;
  color: var(--muted); background: var(--surface-2); border: 1px solid var(--border);
  transition: color .12s, background .12s, border-color .12s;
}
.discord-btn:hover { color: #fff; background: #5865F2; border-color: #5865F2; }
.discord-btn .ic { width: 1.05em; height: 1.05em; vertical-align: middle; }
.account-mini-email {
  color: var(--muted); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; min-width: 0;
  width: 100%; font-size: 0.72rem; opacity: 0.6;
}

/* Settings → Your Rank */
.rank-head { display: flex; align-items: center; gap: 10px; }
.rank-total { font-size: 13px; color: var(--muted); }
.rank-progress { margin-top: 4px; }
.rank-progress-bar {
  height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden;
}
.rank-progress-fill {
  height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, #8B7BFF, #5A4FE0); transition: width .4s ease;
}
.perk-list { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.perk-item { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; line-height: 1.45; }
.perk-item .perk-check {
  flex-shrink: 0; width: 16px; height: 16px; margin-top: 1px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 800;
}
.perk-item.unlocked .perk-check { background: rgba(68,216,139,0.16); color: var(--ok); }
.perk-item.unlocked { color: var(--text); }
.perk-item.locked .perk-check { background: var(--surface-3); color: var(--muted); }
.perk-item.locked { color: var(--muted); }
.perk-tier {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  opacity: .75; margin-left: auto; flex-shrink: 0; padding-left: 8px;
}

/* pack bonus line */
.pack-bonus { font-size: 11px; font-weight: 600; color: var(--ok); margin-top: 3px; }

/* welcome rank callout */
/* (The old inline .rank-callout welcome block was replaced by the floating
   Ranks FAB + popover — see .ranks-fab / .ranks-pop.) */

/* ===== Welcome: Recent Builds cards ===== */
.recent-builds { width: 100%; max-width: 680px; margin: 4px auto 26px; text-align: center; }
.recent-builds-head {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin: 0 0 10px;
}
.recent-builds-row {
  display: flex; gap: 12px; justify-content: center; overflow-x: auto;
  padding: 0 24px 4px; scrollbar-width: thin;
}
/* Thumbnail fills the whole card; the meta overlays its bottom edge. The card
   MUST be position:relative + overflow:hidden so the absolute meta clips to it. */
.build-card {
  position: relative; overflow: hidden;
  flex: 0 0 auto; width: 160px; height: 120px; padding: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  cursor: pointer; text-align: left;
  transition: border-color .15s, transform .15s;
}
.build-card:hover { border-color: rgba(108,99,255,0.45); transform: translateY(-3px); }
.build-thumb { position: absolute; inset: 0; width: 100%; height: 100%; overflow: hidden; background: var(--surface-2); }
/* Web cards: real scaled-down iframe preview of the stored page. The iframe is
   authored at desktop size (1280×800, set as attributes) and shrunk to the card
   with transform: scale(cardWidth/1280) computed at load time. Strictly inert:
   empty sandbox (no scripts), no pointer events, clipped by the thumb. */
.bt-frame {
  position: absolute; top: 0; left: 0;
  width: 1280px; height: 800px;
  transform-origin: top left;
  pointer-events: none; border: 0; background: #fff; z-index: 1;
}
/* Neutral placeholder under the lazy iframe — also the no-HTML fallback tile
   (green Web accent from the canonical mode vars). */
.bt-ph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 22px; }
.bt-ph.web {
  color: var(--mode-web);
  background: color-mix(in srgb, var(--mode-web) 8%, var(--surface-2));
}
/* Game Addons cards: premium purple tile with a seeded identicon-style block
   pattern (inline SVG generated from the plugin name — deterministic, free). */
.game-thumb {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--mode-game) 55%, #14141C),
    color-mix(in srgb, var(--mode-game-2) 28%, #14141C));
}
.game-thumb svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.gt-fg {
  position: absolute; inset: 0; z-index: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 8px 10px 26px; text-align: center; /* bottom padding clears the meta bar */
}
.gt-name {
  font-size: 12px; font-weight: 700; color: #fff; line-height: 1.25;
  max-height: 2.5em; overflow: hidden;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.45);
}
.gt-game {
  font-size: 9px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--mode-game-text); background: rgba(0, 0, 0, 0.35);
  border: 1px solid color-mix(in srgb, var(--mode-game-2) 40%, transparent);
  padding: 2px 7px; border-radius: 999px;
}
.build-meta {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  padding: 6px 8px; display: flex; flex-direction: column; gap: 2px; min-width: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.78) 0%, rgba(0,0,0,0.35) 55%, transparent 100%);
}
.build-title {
  display: block; font-size: 11px; font-weight: 600; color: #fff; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.build-info { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.build-mode { display: inline-flex; align-items: center; gap: 5px; font-size: 10px; font-weight: 600; color: rgba(255,255,255,0.85); }
.build-dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,0.7); flex-shrink: 0; }
.build-mode.web .build-dot { background: var(--ok); }
.build-mode.gameaddons .build-dot { background: #a78bfa; }
.build-date { font-size: 10px; color: rgba(255,255,255,0.65); flex-shrink: 0; }

/* ===== Signal Strength rank progress (lives inside the Ranks popover) ===== */
.signal-strength {
  display: flex; flex-direction: column; gap: 8px; /* rank/detail row, then bar below */
  width: 100%; margin: 12px 0 0;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 12px 16px; text-align: left;
}
.ss-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ss-rank { display: inline-flex; align-items: center; gap: 7px; font-weight: 700; font-size: 13.5px; color: var(--text); }
.ss-icon { font-size: 14px; line-height: 1; }
.ss-detail { font-size: 12px; color: var(--muted); white-space: nowrap; }
.ss-bar { display: block; height: 4px; width: 100%; border-radius: 999px; background: rgba(255, 255, 255, 0.15); overflow: hidden; }
.ss-fill {
  height: 100%; border-radius: 999px; /* width is set inline by renderSignalStrength() */
  background: linear-gradient(90deg, var(--orange), var(--orange-2));
  transition: width .6s ease;
}

/* ===== Floating Ranks CTA (bottom-right, app-wide) + popover ===== */
.ranks-fab {
  position: fixed; right: 24px; bottom: 24px; z-index: 90; /* above chat, below sidebar (200) / editor (250) / modals (300) */
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 16px; border-radius: 999px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  color: var(--text); font: inherit; font-size: 13px; font-weight: 650;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.ranks-fab:hover { transform: translateY(-2px); }
.ranks-fab-bolt { font-size: 15px; line-height: 1; }
/* Accent follows the ACTIVE mode's canonical color (set via data-mode by
   renderModeBadge) so the FAB always matches the badge/thinking theme. */
.ranks-fab[data-mode="gameaddons"] { border-color: color-mix(in srgb, var(--mode-game) 45%, transparent); }
.ranks-fab[data-mode="gameaddons"] .ranks-fab-bolt,
.ranks-fab[data-mode="gameaddons"]:hover { color: var(--mode-game-text); }
.ranks-fab[data-mode="web"] { border-color: color-mix(in srgb, var(--mode-web) 45%, transparent); }
.ranks-fab[data-mode="web"] .ranks-fab-bolt,
.ranks-fab[data-mode="web"]:hover { color: var(--mode-web-text); }
.ranks-fab[data-mode="general"] { border-color: color-mix(in srgb, var(--mode-general) 45%, transparent); }
.ranks-fab[data-mode="general"] .ranks-fab-bolt,
.ranks-fab[data-mode="general"]:hover { color: var(--mode-general-text); }

.ranks-pop {
  position: fixed; right: 24px; bottom: 74px; z-index: 91;
  width: 340px; max-width: calc(100vw - 48px);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg); padding: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
  animation: fade .15s ease;
}
.ranks-pop-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.ranks-pop-title { font-size: 14px; font-weight: 700; color: var(--text); }
.ranks-pop-close {
  border: none; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 13px; padding: 2px 4px; border-radius: 6px;
}
.ranks-pop-close:hover { color: var(--text); }
.ranks-pop-text { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.55; }
.ranks-pop-text::first-line { color: var(--muted); }

/* The editor/preview panel occupies the right side (desktop) or the whole
   screen (mobile) — hide the FAB + popover whenever it is open. */
body.panel-open .ranks-fab, body.panel-open .ranks-pop { display: none; }

/* Narrower screens: the composer spans nearly full width — lift the FAB above
   it so it never overlaps the input. */
@media (max-width: 1100px) {
  .ranks-fab { bottom: 104px; right: 16px; }
  .ranks-pop { bottom: 154px; right: 16px; }
}
/* Phones: icon-only pill to save space. */
@media (max-width: 767px) {
  .ranks-fab { padding: 10px 12px; }
  .ranks-fab-label { display: none; }
}

/* ===== Pricing view ===== */
.pricing-view { flex: 1; min-height: 0; overflow-y: auto; }
.pricing-inner { max-width: 1040px; margin: 0 auto; padding: 40px 24px 64px; }

.pricing-hero { text-align: center; margin-bottom: 40px; }
.pricing-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: #B7B0FF; background: var(--accent-soft);
  border: 1px solid rgba(108,99,255,0.3); padding: 6px 14px; border-radius: 999px;
}
.pricing-title { font-size: 40px; font-weight: 700; letter-spacing: -.02em; margin: 18px 0 10px; }
.pricing-sub { color: var(--muted); font-size: 16px; margin: 0 auto; max-width: 520px; }

/* packs row */
.pricing-packs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 56px; }
.pp-card {
  position: relative; display: flex; flex-direction: column; align-items: center; text-align: center;
  background: var(--surface); border: 1px solid #2A2A35; border-radius: var(--radius-lg);
  padding: 26px 18px 20px; transition: border-color .15s, transform .15s, box-shadow .15s;
}
.pp-card:hover {
  border-color: rgba(108,99,255,0.55); transform: translateY(-4px);
  box-shadow: 0 14px 40px rgba(108,99,255,0.18);
}
.pp-card.featured { border-color: rgba(108,99,255,0.6); box-shadow: 0 0 0 1px rgba(108,99,255,0.25); }
.pp-badge {
  position: absolute; top: -11px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #fff; font-size: 10.5px; font-weight: 700;
  letter-spacing: .03em; padding: 4px 11px; border-radius: 999px; white-space: nowrap;
  box-shadow: 0 2px 12px var(--accent-glow);
}
.pp-name { font-size: 19px; font-weight: 700; }
.pp-price { font-size: 30px; font-weight: 700; color: var(--accent); margin: 6px 0 16px; }
.pp-credits { font-family: var(--mono); font-size: 30px; font-weight: 600; line-height: 1; }
.pp-credits-label { font-size: 12px; color: var(--muted); margin-top: 4px; letter-spacing: .03em; }
.pp-sub { font-size: 12px; color: var(--muted); margin: 4px 0 10px; }
.pp-rank-label { font-size: 0.75rem; color: #7A7A8C; font-weight: 400; margin: 0 0 16px; }
.pp-cta {
  margin-top: auto; width: 100%; background: var(--accent-soft); color: var(--text);
  border: 1px solid rgba(108,99,255,0.35); font-weight: 650; font-size: 14px;
  padding: 10px; border-radius: var(--radius); transition: background .15s, border-color .15s, transform .05s;
}
.pp-cta:hover { background: rgba(108,99,255,0.22); border-color: rgba(108,99,255,0.6); }

/* rank-up upgrade box (above the packs) */
.rankup-box {
  display: flex; flex-wrap: wrap; gap: 16px 24px; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid #2A2A35; border-radius: var(--radius-lg);
  padding: 20px 24px; margin-bottom: 18px;
}
.rankup-left { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.rankup-row { display: flex; align-items: center; gap: 8px; }
.rankup-label { font-size: 12.5px; color: var(--muted); }
.rankup-right { display: flex; flex-direction: column; gap: 5px; align-items: flex-end; text-align: right; margin-left: auto; }
.rankup-price { font-size: 30px; font-weight: 700; color: var(--accent); line-height: 1; }
.rankup-detail { font-size: 12.5px; color: var(--muted); }
.rankup-cta {
  margin-top: 6px; background: var(--accent); color: #fff; border: none;
  font-weight: 650; font-size: 14px; padding: 10px 22px; border-radius: var(--radius);
  cursor: pointer; transition: background .15s, transform .05s;
}
.rankup-cta:hover { background: #7B72FF; }
.rankup-cta:active { transform: translateY(1px); }
.rankup-cta:disabled { opacity: .6; cursor: progress; }
@media (max-width: 600px) {
  .rankup-box { flex-direction: column; align-items: stretch; }
  .rankup-right { align-items: flex-start; text-align: left; margin-left: 0; }
  .rankup-cta { width: 100%; }
}
.pp-cta:active { transform: translateY(1px); }
.pp-card.featured .pp-cta { background: var(--accent); color: #fff; border-color: var(--accent); }
.pp-card.featured .pp-cta:hover { background: #7B72FF; }
.pp-cta:disabled { opacity: .6; cursor: progress; }

/* section */
.pricing-block { margin-bottom: 48px; }
.pricing-h2 { font-size: 24px; font-weight: 700; letter-spacing: -.01em; text-align: center; margin: 0 0 6px; }
.pricing-sub2 { text-align: center; color: var(--muted); font-size: 14px; margin: 0 0 28px; }

/* comparison table */
.pricing-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); }
.pricing-table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 720px; }
.pricing-table th, .pricing-table td {
  padding: 13px 16px; text-align: center; border-bottom: 1px solid var(--border);
}
.pricing-table tr:last-child td { border-bottom: none; }
.pricing-table thead th { background: var(--surface); }
.pricing-table .feat-label {
  text-align: left; color: var(--muted); font-weight: 500; white-space: nowrap;
  position: sticky; left: 0; background: var(--bg);
}
.pricing-table tbody tr:nth-child(odd) td { background: rgba(255,255,255,0.015); }
.pricing-table tbody tr:nth-child(odd) td.feat-label { background: var(--bg); }
.pt-check { color: var(--ok); font-weight: 700; }
.pt-dash { color: var(--muted); }
.pt-rank-badge {
  display: inline-flex; font-size: 11px; font-weight: 700; letter-spacing: .03em;
  padding: 3px 10px; border-radius: 999px; color: #0D0D0F;
}
/* current-rank column highlight */
.pricing-table .col-current {
  background: rgba(108,99,255,0.10) !important;
  box-shadow: inset 1px 0 0 rgba(108,99,255,0.5), inset -1px 0 0 rgba(108,99,255,0.5);
}
.pricing-table thead th.col-current { box-shadow: inset 1px 0 0 rgba(108,99,255,0.5), inset -1px 0 0 rgba(108,99,255,0.5), inset 0 1px 0 rgba(108,99,255,0.5); }
.pricing-table tbody tr:last-child td.col-current { box-shadow: inset 1px 0 0 rgba(108,99,255,0.5), inset -1px 0 0 rgba(108,99,255,0.5), inset 0 -1px 0 rgba(108,99,255,0.5); }
.col-current-label { display: block; font-size: 10px; font-weight: 700; color: var(--accent); letter-spacing: .05em; margin-top: 3px; }

/* current signal card */
.current-signal {
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg); padding: 22px 24px;
}
.cs-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.cs-stats { display: flex; gap: 28px; flex-wrap: wrap; margin: 18px 0; }
.cs-stat-label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.cs-stat-value { font-family: var(--mono); font-size: 20px; font-weight: 600; margin-top: 3px; }
.cs-progress-text { font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.cs-cta { margin-left: auto; }
.cs-signin { color: var(--muted); font-size: 14px; text-align: center; padding: 8px 0; }
.cs-signin .link-btn { font-size: 14px; }

/* ===== Code editor side panel (Game Addons) ===== */
.editor-panel {
  flex-shrink: 0;
  width: 0;
  overflow: hidden;
  background: #16161A;
  border-left: 1px solid #2A2A35;
  display: flex;
  flex-direction: column;
  transition: width 0.25s ease;
}
.editor-panel.open { width: 45%; }
.editor-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; border-bottom: 1px solid #2A2A35; flex-shrink: 0;
}
.editor-panel-title { color: #E8E8F0; font-weight: 700; font-size: 14px; }
.editor-panel-close {
  background: none; border: none; cursor: pointer; color: var(--muted);
  font-size: 15px; line-height: 1; padding: 6px 8px; border-radius: 6px;
  transition: color .15s, background .15s;
}
.editor-panel-close:hover { color: var(--text); background: var(--surface-2); }
.editor-panel-body { flex: 1; display: flex; min-height: 0; min-width: 0; }
.editor-file-tree {
  width: 180px; flex-shrink: 0; background: #0D0D0F; border-right: 1px solid #2A2A35;
  overflow-y: auto; padding: 8px 0;
}
.editor-file-tree.hidden { display: none; }
.editor-file-row {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 8px 12px; border-left: 2px solid transparent;
  color: #C0C0D0; font-size: 12.5px; transition: background .12s;
}
.editor-file-row:hover { background: #15151B; }
.editor-file-row.active { background: #1E1E26; border-left-color: #6C63FF; }
.editor-file-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: #7A7A8C; }
.editor-file-info { min-width: 0; flex: 1; }
.editor-file-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.editor-file-folder { font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.editor-file-dirty {
  width: 7px; height: 7px; border-radius: 50%; background: #FBBF24; flex-shrink: 0;
  opacity: 0; transition: opacity .12s;
}
.editor-file-dirty.show { opacity: 1; }
.editor-main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.editor-tabs {
  flex-shrink: 0; display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-bottom: 1px solid #2A2A35;
  color: #E8E8F0; font-size: 12.5px; font-family: var(--mono);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.editor-monaco-container { flex: 1; min-height: 0; min-width: 0; }

/* Web Mode preview: header controls + sandboxed iframe */
.editor-web-controls { display: flex; align-items: center; gap: 8px; margin-left: auto; margin-right: 10px; }
/* Game Addons code controls (Recompile) — same layout as the web controls */
.editor-code-controls { display: flex; align-items: center; gap: 8px; margin-left: auto; margin-right: 10px; }
.editor-recompile { color: var(--ok); border-color: rgba(68,216,139,0.4); }
.editor-recompile:hover { border-color: var(--ok); background: rgba(68,216,139,0.12); }
.editor-web-tabs { display: inline-flex; background: #0D0D0F; border: 1px solid #2A2A35; border-radius: 8px; padding: 2px; }
.editor-web-tab {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 12px; font-weight: 600; padding: 4px 12px; border-radius: 6px; transition: background .12s, color .12s;
}
.editor-web-tab:hover { color: var(--text); }
.editor-web-tab.active { background: var(--accent); color: #fff; }
.editor-web-action {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 1px solid #2A2A35; color: #C0C0D0; cursor: pointer;
  font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 8px; transition: border-color .12s, background .12s;
}
.editor-web-action:hover { border-color: var(--accent); background: var(--surface-2); }
.editor-web-action .ewa-icon { display: none; }           /* desktop: text label only */
.editor-web-action .ewa-icon svg { display: block; }
/* Mobile-only "← Back to chat" button — hidden on desktop split view. */
.editor-back-mobile {
  display: none;
  background: none; border: none; cursor: pointer; color: var(--accent);
  font-size: 13px; font-weight: 700; padding: 6px 8px; border-radius: 6px;
  white-space: nowrap; transition: background .15s;
}
.editor-back-mobile:hover { background: var(--surface-2); }
.editor-preview-frame { flex: 1; min-height: 0; min-width: 0; width: 100%; height: 100%; border: none; background: #fff; }

/* Web Mode tab layering: keep the sandboxed iframe in the render tree at ALL
   times (never display:none — a hide/show cycle blanks it to white). The Code
   tab overlays Monaco on top of the still-rendered iframe instead of hiding it.
   Scoped to .web-mode so the Game Addons code editor is unaffected. */
.editor-panel.web-mode .editor-main { position: relative; }
.editor-panel.web-mode .editor-preview-frame {
  position: absolute; inset: 0; width: 100%; height: 100%;
  border: none; z-index: 1; display: block !important;   /* never hidden */
}
.editor-panel.web-mode .editor-monaco-container { display: none; }        /* Preview tab: only the iframe shows */
.editor-panel.web-mode.code-tab-active .editor-monaco-container {
  display: block; position: absolute; inset: 0; z-index: 5;               /* Code tab: overlay Monaco on top */
  background: var(--surface);
}

/* Stage-aware thinking / progress bubble (all three modes) */
.think-bubble { display: flex; flex-direction: column; gap: 12px; padding: 4px 0; }
.think-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.think-stage-wrap { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.think-stage { color: var(--text); font-weight: 500; font-size: 14px; transition: opacity .2s ease; }
.think-sub { color: var(--muted); font-size: 12px; transition: opacity .2s ease; }
.think-timer { color: var(--dim); font-size: 12px; font-family: var(--mono); white-space: nowrap; flex-shrink: 0; text-align: right; }
.think-bar-track { width: 100%; height: 4px; background: var(--border); border-radius: 999px; overflow: hidden; }
.think-bar-fill {
  height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, var(--mode-general), var(--mode-general-2));
  transition: width 0.5s ease;
}
/* Progress-bar gradients keyed to the canonical mode colors — the badge, the
   thinking bubble, and the bar always share one hue per mode. */
.think-bubble[data-mode="web"]        .think-bar-fill { background: linear-gradient(90deg, var(--mode-web), var(--mode-web-2)); }
.think-bubble[data-mode="gameaddons"] .think-bar-fill { background: linear-gradient(90deg, var(--mode-game), var(--mode-game-2)); }
.think-bubble[data-mode="general"]    .think-bar-fill { background: linear-gradient(90deg, var(--mode-general), var(--mode-general-2)); }
/* Stage label tinted to the mode hue as well (sub/timer stay neutral). */
.think-bubble[data-mode="web"]        .think-stage { color: var(--mode-web-text); }
.think-bubble[data-mode="gameaddons"] .think-stage { color: var(--mode-game-text); }
.think-bubble[data-mode="general"]    .think-stage { color: var(--mode-general-text); }
/* General mode crossfade: thinking bubble → live streaming text */
.think-crossfade { animation: thinkCrossfade .25s ease; }
@keyframes thinkCrossfade { from { opacity: .25; } to { opacity: 1; } }
/* Completion bubble — the whole thing is clickable to reopen the preview. */
.web-done {
  display: inline-flex; align-items: center; gap: 12px; flex-wrap: wrap;
  color: var(--ok); font-weight: 600; font-size: 14px; cursor: pointer;
}
.web-reopen {
  border: 1px solid var(--accent); background: transparent; color: var(--accent);
  font: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
  padding: 4px 10px; border-radius: 8px; transition: background .12s, color .12s;
}
.web-reopen:hover { background: var(--accent); color: #fff; }
/* Change-summary bullets under a build/edit result ("what actually changed"). */
.change-summary {
  margin: 8px 0 0; padding: 0 0 0 4px; list-style: none;
  display: flex; flex-direction: column; gap: 4px;
}
.change-summary li {
  position: relative; padding-left: 16px;
  color: var(--muted); font-size: 13px; font-weight: 500; line-height: 1.45;
}
.change-summary li::before {
  content: '•'; position: absolute; left: 2px; color: var(--ok);
}
/* Game Addons variant: boxed summary appended under the message body. */
.change-summary-box {
  margin-top: 10px; padding: 10px 14px;
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: 10px; background: rgba(74, 222, 128, 0.05);
}
.cs-build-head { color: var(--ok); font-weight: 600; font-size: 13px; margin-bottom: 4px; }
/* A failed compile marks its message .build-failed → hide the success Build summary so
   it never sits above a "Build failed"/error terminal. A successful (re)compile clears it. */
.msg-body.build-failed .change-summary-box { display: none; }
.web-error { color: var(--danger); font-weight: 600; font-size: 14px; }
/* Incomplete-build bubble: message + Try again / Continue actions */
.web-incomplete { display: flex; flex-direction: column; gap: 10px; }
.web-error-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.web-retry, .web-continue, .web-resume {
  border: 1px solid var(--accent); background: transparent; color: var(--accent);
  font: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
  padding: 5px 12px; border-radius: 8px; transition: background .12s, color .12s;
}
.web-retry:hover, .web-continue:hover, .web-resume:hover { background: var(--accent); color: #fff; }
/* Delivered PARTIAL build (Stopped mid-generation): kept preview + Resume action. */
.web-partial { display: flex; flex-direction: column; gap: 10px; }
.web-partial-note { color: var(--muted); font-weight: 600; font-size: 13px; line-height: 1.45; }
.web-partial .web-done-label { color: var(--accent); }

/* ---------- inline UI icons (replaced the former emoji) ----------
   Thin-stroke line icons that inherit the surrounding text size + color via
   currentColor, so they still pick up mode-accent theming where relevant. */
.ic { width: 1em; height: 1em; vertical-align: -0.15em; flex: none; }
/* Leading warning icon in Web error / incomplete bubbles. */
.web-error > .ic, .web-error-text > .ic { margin-right: 5px; margin-top: 1px; }
/* Icon chips that were sized by font-size on an emoji glyph. */
.mc-icon svg { width: 22px; height: 22px; }
.game-card-icon svg, .game-card-icon img { width: 30px; height: 30px; display: block; }
.ss-icon svg, .ranks-fab-bolt svg, .lcb-bolt svg { width: 1em; height: 1em; display: block; }
.ooc-icon svg { width: 20px; height: 20px; display: block; }
.bt-ph svg { width: 26px; height: 26px; }
.topup-bolt-particle svg { width: 1.5rem; height: 1.5rem; display: block; }

/* Below 1024px there's no room for split view — the panel is a full-screen
   overlay that slides up (matching the modal overlay pattern). */
@media (max-width: 1023px) {
  .editor-panel {
    position: fixed; inset: 0; z-index: 250; width: auto;
    transform: translateY(100%); transition: transform 0.25s ease;
    border-left: none;
  }
  .editor-panel.open { width: auto; transform: translateY(0); }
}

/* Phones: the preview panel is a full-screen sheet. Hide the chat underneath,
   show a "← Back to chat" button, drop the title, and shrink the action buttons
   to icons so the header fits. */
@media (max-width: 767px) {
  .editor-panel.open { width: 100vw; height: 100vh; }        /* full screen */
  body.panel-open .main { display: none; }                    /* hide chat underneath */
  .editor-back-mobile { display: inline-flex; align-items: center; }
  .editor-panel-title { display: none; }                      /* free up header space */
  .editor-panel-header { padding: 12px 12px; gap: 8px; }
  .editor-web-controls, .editor-code-controls { margin-right: 6px; gap: 6px; }
  .editor-web-action { padding: 6px 8px; }
  .editor-web-action .ewa-label { display: none; }            /* icon-only actions */
  .editor-web-action .ewa-icon { display: inline-flex; }
  .editor-web-tab { padding: 4px 10px; }                      /* Preview/Code stay visible */
}

/* ===== Top-up success celebration (full-screen, passive, auto-dismiss) ===== */
.topup-celebration {
  position: fixed; inset: 0; width: 100%; height: 100%; z-index: 2000; /* above panels/modals */
  pointer-events: none;                 /* never block the app underneath */
  display: flex; align-items: center; justify-content: center;
  /* Soft dim so the message clearly stands out against a busy chat, plus a brand
     radial glow behind the content. Tasteful, not a harsh full-black overlay. */
  background:
    radial-gradient(circle at 50% 45%, rgba(108,99,255,0.28), transparent 55%),
    rgba(8, 8, 12, 0.55);
  opacity: 0; transform: scale(0.96); visibility: hidden;
  transition: opacity 0.45s ease, transform 0.4s ease-out, visibility 0s 0.45s;
}
.topup-celebration.show {
  opacity: 1; transform: scale(1); visibility: visible;
  transition: opacity 0.3s ease-out, transform 0.35s cubic-bezier(.2,.9,.3,1.2), visibility 0s 0s;
}
.topup-celebration-content {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  text-align: center; padding: 0 20px;
}
.topup-bolt-burst { position: absolute; inset: -40px; pointer-events: none; }
.topup-celebration-text { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.topup-celebration-headline {
  font-size: 3.2rem; font-weight: 800; line-height: 1.05; letter-spacing: -.02em;
  background: linear-gradient(135deg, #B4A8FF, #7A6CFF);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  /* Glow gives the gradient text real contrast/pop against the dimmed backdrop. */
  filter: drop-shadow(0 2px 18px rgba(124, 108, 255, 0.55));
}
.topup-celebration-subtext { color: #E4E4F0; font-size: 1.2rem; font-weight: 500; }
.topup-celebration-amount {
  color: #6EF0A6; font-size: 1.6rem; font-weight: 800;
  text-shadow: 0 2px 14px rgba(74, 222, 128, 0.35);
}
@media (max-width: 767px) {
  .topup-celebration-headline { font-size: 2.4rem; }
  .topup-celebration-subtext { font-size: 1.05rem; }
}

/* staggered entrance — runs only while .show is applied */
@keyframes celebRise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.topup-celebration.show .topup-celebration-headline { animation: celebRise .4s ease-out both; }
.topup-celebration.show .topup-celebration-subtext  { animation: celebRise .4s ease-out .1s both; }
.topup-celebration.show .topup-celebration-amount   { animation: celebRise .4s ease-out .2s both; }

/* bolt particle burst (one-shot, generated in JS) */
.topup-bolt-particle {
  position: absolute; top: 50%; left: 50%; font-size: 1.5rem;
  opacity: 0; transform: translate(-50%, -50%) scale(0);
  animation-name: boltBurstOut; animation-timing-function: ease-out; animation-fill-mode: forwards;
}
@keyframes boltBurstOut {
  0%   { transform: translate(-50%, -50%) scale(0); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) scale(var(--scale)); opacity: 0; }
}
/* Reduced motion: no scale/slide/particles — a plain opacity fade-in only. */
@media (prefers-reduced-motion: reduce) {
  .topup-celebration, .topup-celebration.show { transform: none; }
  .topup-celebration.show .topup-celebration-headline,
  .topup-celebration.show .topup-celebration-subtext,
  .topup-celebration.show .topup-celebration-amount { animation: none; opacity: 1; }
  .mode-pill.active .mode-dot { animation: none; }
}

/* ===== Admin panel ===== */
.admin-link svg { color: #FBBF24; }
.admin-view { flex: 1; min-height: 0; overflow-y: auto; }
.admin-inner { max-width: 1000px; margin: 0 auto; padding: 28px 24px 60px; }
.admin-head { margin-bottom: 22px; }
.admin-title { font-size: 28px; font-weight: 700; margin: 0 0 4px; }
.admin-sub { color: var(--muted); font-size: 13px; margin: 0; }
.admin-h2 { font-size: 16px; font-weight: 650; margin: 0 0 12px; }
.admin-block { margin-top: 30px; }
.admin-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.admin-stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; }
.admin-stat-label { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
.admin-stat-value { font-family: var(--mono); font-size: 22px; font-weight: 600; margin-top: 6px; }
.admin-rank-dist { display: flex; flex-direction: column; gap: 3px; margin-top: 8px; }
.admin-rank-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }

/* ---------- cost-runaway protection dashboard ---------- */
.admin-est-tag { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; margin-left: 8px; vertical-align: middle; }
.admin-protection { display: flex; flex-direction: column; gap: 14px; }
.admin-protection .admin-span2 { grid-column: span 2; }
.admin-stat-value.danger, .admin-breaker.on { color: var(--danger, #ff6b6b); }
.admin-stat-value.ok { color: var(--ok, #44d88b); }
.admin-cap-of { font-size: 13px; color: var(--muted); font-family: var(--font, inherit); font-weight: 500; }
.admin-spend-bar { margin-top: 10px; height: 7px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.admin-spend-fill { height: 100%; background: var(--ok, #44d88b); transition: width .3s; }
.admin-spend-fill.warn { background: #FFCB6B; }
.admin-spend-fill.over { background: var(--danger, #ff6b6b); }
.admin-outcomes { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; font-size: 13px; color: var(--muted); font-family: var(--mono); }
.admin-outcomes .warn { color: #FFCB6B; }
.admin-breaker-banner { display: flex; flex-wrap: wrap; gap: 10px; }
.admin-breaker { font-size: 12.5px; font-weight: 600; padding: 5px 10px; border-radius: 8px; border: 1px solid var(--border); }
.admin-breaker.on { border-color: color-mix(in srgb, var(--danger, #ff6b6b) 45%, transparent); background: color-mix(in srgb, var(--danger, #ff6b6b) 10%, transparent); }
.admin-breaker.off { color: var(--ok, #44d88b); border-color: color-mix(in srgb, var(--ok, #44d88b) 35%, transparent); }
.admin-kill-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.admin-kill-btn { font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; padding: 8px 14px;
  border-radius: 10px; border: 1px solid var(--border-strong, var(--border)); background: var(--surface-2); color: var(--text);
  transition: background .12s, border-color .12s, color .12s; }
.admin-kill-btn:hover { border-color: var(--danger, #ff6b6b); color: var(--danger, #ff6b6b); }
.admin-kill-btn.on { background: color-mix(in srgb, var(--danger, #ff6b6b) 16%, transparent); border-color: var(--danger, #ff6b6b); color: var(--danger, #ff6b6b); }
.admin-kill-btn:disabled { opacity: .5; cursor: default; }
.admin-kill-msg { font-size: 12px; color: var(--muted); }
.admin-leaders { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px 14px; }
.admin-leaders-head { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }
.admin-leader-row { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 3px 0; font-family: var(--mono); }
.admin-leader-row.muted { color: var(--muted); font-family: inherit; }
.admin-leader-id { color: var(--muted); }
.admin-leader-gens { color: var(--muted); }
.admin-note { font-size: 11.5px; color: var(--muted); line-height: 1.5; margin: 2px 0 0; }

/* ---------- editable spend caps (compact — sits in the top card row) ---------- */
.admin-caps-card { display: flex; flex-direction: column; gap: 8px; }
.admin-cap-hint { font-size: 10.5px; font-weight: 500; color: var(--muted); margin-left: 6px;
  text-transform: none; letter-spacing: 0; }
.admin-cap-row { border: 1px solid var(--border); border-radius: 9px; padding: 6px 8px; background: var(--surface-2); }
.admin-cap-row.off { border-color: color-mix(in srgb, var(--danger, #ff6b6b) 55%, transparent);
  background: color-mix(in srgb, var(--danger, #ff6b6b) 9%, var(--surface-2)); }
.admin-cap-line { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.admin-cap-label { flex: 1 1 90px; min-width: 84px; font-size: 12px; font-weight: 600; color: var(--text);
  display: inline-flex; align-items: center; gap: 6px; }
.admin-cap-tag { font-size: 9px; font-weight: 800; letter-spacing: .05em; color: var(--danger, #ff6b6b);
  border: 1px solid var(--danger, #ff6b6b); border-radius: 5px; padding: 0 5px; }
.admin-cap-field { display: inline-flex; align-items: center; gap: 2px; }
.admin-cap-dollar { color: var(--muted); font-size: 12.5px; }
.admin-cap-input { width: 62px; font: inherit; font-size: 12.5px; font-family: var(--mono); padding: 4px 6px;
  border-radius: 7px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.admin-cap-input:focus { outline: none; border-color: var(--accent); }
.admin-cap-save, .admin-cap-disable {
  font: inherit; font-size: 11.5px; font-weight: 600; cursor: pointer; padding: 4px 10px; border-radius: 7px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  transition: background .12s, border-color .12s, color .12s;
}
.admin-cap-save { border-color: var(--accent); color: var(--accent); }
.admin-cap-save:hover { background: var(--accent); color: #fff; }
.admin-cap-disable { color: var(--danger, #ff6b6b); border-color: color-mix(in srgb, var(--danger, #ff6b6b) 40%, transparent); }
.admin-cap-disable:hover { background: color-mix(in srgb, var(--danger, #ff6b6b) 12%, transparent); }
.admin-cap-save:disabled, .admin-cap-disable:disabled { opacity: .5; cursor: default; }
.admin-cap-msg { flex: 1 1 100%; font-size: 11px; color: var(--muted); }
/* Shared warning style — used loud on the spend card, and .compact inside a cap row. */
.admin-cap-warning {
  display: flex; align-items: flex-start; gap: 8px; margin: 6px 0 0; padding: 8px 11px; border-radius: 9px;
  font-size: 12px; font-weight: 600; line-height: 1.45;
  color: #FCD34D; background: #2A1F0A; border: 1px solid #F59E0B;
}
.admin-cap-warning.compact { font-size: 11.5px; padding: 6px 9px; }
.admin-cap-warning .ic { flex: none; margin-top: 1px; color: #F59E0B; }
.admin-cap-warning strong { color: #FDE68A; }

/* ---------- admin tabs (Part 4b restructure) ---------- */
.admin-tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--border); margin: 18px 0 20px; }
.admin-tab {
  font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
  background: none; border: none; color: var(--muted); padding: 10px 14px;
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .12s, border-color .12s;
}
.admin-tab:hover { color: var(--text); }
.admin-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.admin-tabpanel[hidden] { display: none; }
.admin-tabpanel { display: flex; flex-direction: column; gap: 20px; }
.admin-sub2 { font-size: 13px; color: var(--muted); line-height: 1.55; margin: 0 0 14px; }

/* ---------- session lookup (read-only shared-chat viewer) ---------- */
.admin-lookup-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.admin-lookup-form input {
  font: inherit; font-size: 13px; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); min-width: 160px;
}
.admin-lookup-form input:focus { outline: none; border-color: var(--accent); }
.admin-lookup-result { margin-top: 16px; }
.admin-lookup-meta { font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
.admin-lookup-deny { color: var(--danger); font-weight: 600; }
.admin-chat-readonly {
  border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 6px 14px; max-height: 60vh; overflow: auto;
  background: var(--surface);
}
.admin-chat-msg { padding: 12px 0; border-bottom: 1px solid var(--border); }
.admin-chat-msg:last-child { border-bottom: none; }
.admin-chat-role { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 5px; }
.admin-chat-body { font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; color: var(--text); }
.admin-readonly-tag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; margin-left: 8px; vertical-align: middle; }

/* ---------- READ-ONLY session review overlay (admin) ----------
   A temporary, full-screen takeover shown ONLY while reviewing a shared session.
   Amber accent throughout so it can never be confused with a normal chat. */
.admin-review { position: fixed; inset: 0; z-index: 1500; display: flex; flex-direction: column;
  background: var(--bg, #0b0b10); }
.admin-review[hidden] { display: none; }
.admin-review-banner {
  flex: none; display: flex; align-items: center; gap: 12px; padding: 12px 20px;
  background: linear-gradient(0deg, rgba(245,158,11,0.14), rgba(245,158,11,0.14)), #2A1F0A;
  border-bottom: 2px solid #F59E0B; color: #FCD34D; font-size: 13.5px; font-weight: 600;
  position: sticky; top: 0;
}
.admin-review-banner .arb-text { flex: 1; min-width: 0; }
.admin-review-banner code { font-family: var(--mono); background: rgba(0,0,0,0.25); padding: 1px 6px; border-radius: 5px; color: #FDE68A; }
.admin-review-banner strong { color: #FDE68A; letter-spacing: .04em; }
.arb-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: #F59E0B; box-shadow: 0 0 0 4px rgba(245,158,11,0.25); }
.arb-close { flex: none; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
  padding: 7px 14px; border-radius: 9px; border: 1px solid #F59E0B; background: transparent; color: #FCD34D;
  transition: background .12s, color .12s; }
.arb-close:hover { background: #F59E0B; color: #1A1205; }
.admin-review-scroll { flex: 1; overflow-y: auto; }
.admin-review-body { max-width: 860px; margin: 0 auto; padding: 24px 20px 60px; }
.admin-review-empty { color: var(--muted); text-align: center; padding: 40px 0; }
/* Inert web preview inside a review message: scaled desktop render, non-interactive. */
.admin-preview-box { position: relative; width: 100%; overflow: hidden; margin-top: 10px;
  border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.admin-preview-frame { position: absolute; top: 0; left: 0; transform-origin: top left; border: 0; pointer-events: none; }
.admin-code-details { margin-top: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.admin-code-details > summary { cursor: pointer; padding: 8px 12px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.admin-code-details[open] > summary { border-bottom: 1px solid var(--border); }
.admin-code-pre { margin: 0; padding: 12px; max-height: 340px; overflow: auto; font-family: var(--mono); font-size: 12px; line-height: 1.5; color: var(--text); white-space: pre; }

/* ---------- share-with-support modal ---------- */
.share-field { margin-bottom: 12px; }
.share-field label { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 5px; }
.share-copyrow { display: flex; align-items: center; gap: 8px; }
.share-code { flex: 1; min-width: 0; font-family: var(--mono); font-size: 13px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; overflow: auto; white-space: nowrap; color: var(--text); }
.share-copy { flex: none; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; padding: 7px 12px;
  border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); transition: color .12s, border-color .12s; }
.share-copy:hover { border-color: var(--accent); color: var(--accent); }
.share-note { font-size: 13px; color: var(--muted); line-height: 1.55; margin: 10px 0 14px; }
.share-note strong { color: var(--text); }
.share-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.share-viewed { margin-top: 14px; font-size: 12.5px; color: var(--ok); display: flex; align-items: center; gap: 6px; }
.share-err { color: var(--danger); }
.share-revoke { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.share-revoke:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); }
.admin-search { width: 100%; max-width: 360px; background: #16161A; border: 1px solid #2A2A35; border-radius: 8px; color: #E8E8F0; font-size: 0.9rem; padding: 9px 14px; margin-bottom: 12px; }
.admin-search:focus { outline: none; border-color: var(--accent); }
.admin-user-list { display: flex; flex-direction: column; gap: 6px; }
.admin-user-row { display: flex; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; cursor: pointer; transition: border-color .12s, background .12s; }
.admin-user-row:hover { border-color: rgba(108,99,255,0.4); background: var(--surface-2); }
.admin-user-email { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.admin-user-meta { font-size: 12px; color: var(--muted); font-family: var(--mono); white-space: nowrap; }
.admin-badge { font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.admin-badge.banned { background: rgba(255,92,108,0.15); color: var(--danger); }
.admin-badge.admin { background: rgba(251,191,36,0.15); color: #FBBF24; }
.admin-pager { display: flex; gap: 10px; align-items: center; margin-top: 12px; color: var(--muted); font-size: 12px; }
.admin-audit { display: flex; flex-direction: column; gap: 6px; }
.admin-audit-row { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 9px 12px; font-size: 12px; }
.admin-audit-action { font-weight: 700; color: var(--accent); }
.admin-audit-action.danger { color: var(--danger); }
.admin-audit-meta { color: var(--muted); font-size: 11px; margin-top: 2px; word-break: break-word; }
.admin-refusal-game { color: var(--muted); font-weight: 600; text-transform: capitalize; }
.admin-refusal-prompt { margin-top: 5px; padding: 6px 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; font-family: var(--mono, ui-monospace, monospace); font-size: 11.5px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; color: var(--text); }
.admin-modal { max-width: 560px; }
.admin-detail-row { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; padding: 5px 0; border-bottom: 1px solid var(--border); }
.admin-detail-row .k { color: var(--muted); }
.admin-detail-row .v { font-family: var(--mono); text-align: right; word-break: break-all; }
.admin-action-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-top: 14px; }
.admin-action-card.danger { border-color: rgba(255,92,108,0.4); }
.admin-action-card h4 { margin: 0 0 10px; font-size: 13px; font-weight: 650; }
.admin-action-card.danger h4 { color: var(--danger); }
.admin-field { display: block; width: 100%; background: #16161A; border: 1px solid #2A2A35; border-radius: 8px; color: #E8E8F0; font-size: 13px; padding: 8px 12px; margin-bottom: 8px; font-family: inherit; box-sizing: border-box; }
.admin-field:focus { outline: none; border-color: var(--accent); }
.admin-confirm-label { font-size: 11px; color: var(--muted); margin: 2px 0 4px; display: block; }
.admin-checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #FCD34D; margin-bottom: 8px; }
.admin-action-btn { width: 100%; padding: 9px; border-radius: 8px; border: none; background: var(--accent); color: #fff; font-weight: 600; font-size: 13px; cursor: pointer; }
.admin-action-btn:disabled { opacity: .45; cursor: not-allowed; }
.admin-action-btn.danger { background: var(--danger); }
.admin-action-msg { font-size: 12px; margin-top: 8px; min-height: 1em; }
.admin-action-msg.ok { color: var(--ok); }
.admin-action-msg.err { color: var(--danger); }

/* ===== Legal / docs pages ===== */
.doc-view { flex: 1; min-height: 0; overflow-y: auto; }
.doc-inner { max-width: 720px; margin: 0 auto; padding: 24px 24px 56px; }
.doc-back { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 13px; font-weight: 600; padding: 6px 0; margin-bottom: 8px; }
.doc-back:hover { text-decoration: underline; }
.doc-content { color: #E8E8F0; font-size: 14px; line-height: 1.7; }
.doc-content h1 { font-size: 26px; font-weight: 700; letter-spacing: -.01em; margin: 4px 0 14px; }
.doc-content h2 { font-size: 18px; font-weight: 650; margin: 30px 0 10px; }
.doc-content h3 { font-size: 15px; font-weight: 600; margin: 22px 0 8px; }
.doc-content p { margin: 0 0 12px; color: #C9C9D6; }
.doc-content strong { color: #E8E8F0; font-weight: 650; }
.doc-content ul, .doc-content ol { margin: 0 0 14px; padding-left: 22px; color: #C9C9D6; }
.doc-content li { margin: 5px 0; }
.doc-content hr { border: none; border-top: 1px solid var(--border); margin: 22px 0; }
.doc-content a { color: var(--mode-accent); transition: color .5s ease; }

/* ===== Persistent footer ===== */
.app-footer {
  flex-shrink: 0; text-align: center; color: #5A5A6C; font-size: 0.7rem;
  line-height: 1.7; padding: 6px 16px 12px;
}
.footer-link {
  background: none; border: none; color: #5A5A6C; font-size: 0.7rem; font-family: inherit;
  cursor: pointer; padding: 0; text-decoration: underline;
}
.footer-link:hover { color: #8A8A9C; }

/* ===== Responsive ===== */
/* Mobile sidebar backdrop (element is created by JS only on mobile). */
#sidebarBackdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 199; }

@media (max-width: 768px) {
  /* CHANGE 1 — sidebar as a slide-over overlay drawer */
  .sidebar {
    position: fixed !important; top: 0; left: 0; height: 100%; width: 280px; z-index: 200;
    transform: translateX(-100%); transition: transform 0.25s ease;
    box-shadow: 0 0 40px rgba(0,0,0,0.5);
    /* As a full overlay over the dimmed chat, an opaque surface keeps the drawer a
       solid, distinct panel — the desktop see-through-to-glow tint doesn't apply
       here (the drawer covers the edge, and a backdrop already sits behind it). */
    background: var(--surface);
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-only { display: flex; }

  /* CHANGE 4 — main content full width (sidebar is out of flow) */
  .main { width: 100%; }
  .messages, .composer-wrap { padding-left: 16px; padding-right: 16px; }

  /* CHANGE 3 — header + mode pills fit without clipping */
  .topbar { gap: 8px; padding: 10px 12px; }
  .mode-switch { padding: 3px; }
  .mode-pill { padding: 4px 10px; font-size: 0.8rem; }
  .tier-btn { height: 32px; font-size: 12.5px; padding: 0 6px 0 9px; }
  .tier-menu { min-width: 208px; }
  .mode-badge { font-size: 10px; padding: 3px 7px; max-width: 42vw; overflow: hidden; text-overflow: ellipsis; }

  /* CHANGE 2 — welcome screen stacks */
  .welcome { padding: 24px 16px 36px; }
  .welcome-mark { margin-bottom: 12px; }
  .welcome-title { font-size: 28px; }
  .welcome-sub { font-size: 14px; margin-bottom: 24px; }
  .mode-cards { grid-template-columns: 1fr; }
  .starter-chips { grid-template-columns: 1fr; }

  /* CHANGE 5 — touch targets ≥ 44px, 16px input to avoid iOS zoom */
  .send-btn, .stop-btn { width: 44px; height: 44px; }
  .icon-btn.mobile-only { width: 44px; height: 44px; }
  .topup-btn { min-height: 44px; }
  .composer-input { font-size: 16px; }

  /* CHANGE 6 — full-width modals */
  .modal-backdrop { padding: 8px; }
  .modal { width: 95vw; max-width: 95vw; max-height: 90vh; overflow-y: auto; }

  /* pricing page */
  .pricing-packs { grid-template-columns: repeat(2, 1fr); }
  .pricing-title { font-size: 30px; }
  .cs-cta { margin-left: 0; width: 100%; }
}
@media (max-width: 520px) {
  .pricing-packs { grid-template-columns: 1fr; }
}
