/* ===== Ruckus AI — styles ===== */
:root {
  --bg: #0D0D0F;
  --surface: #16161A;
  --surface-2: #1C1C22;
  --surface-3: #232330;
  --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;
  --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; }
body {
  background: var(--bg);
  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: var(--accent-glow); }

/* 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;
  background: var(--surface);
  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(--accent); border-radius: 0 3px 3px 0;
}
.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); }

/* ===== 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);
  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;
}

/* 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(--accent);
  box-shadow: 0 2px 12px var(--accent-glow);
  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); }
.mode-pill.active { color: #fff; }
.mode-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; opacity: .5; transition: opacity .2s;
}
.mode-pill.active .mode-dot { opacity: 1; background: #fff; }

/* ===== 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; }
.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; }

/* ===== 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(--accent); text-decoration: none; }
.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; }
.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); }

/* 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%; }
.mode-card {
  text-align: left; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px; transition: border-color .15s, transform .15s, background .15s;
}
.mode-card:hover { border-color: rgba(108,99,255,0.4); transform: translateY(-3px); background: var(--surface-2); }
.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; }

/* 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: rgba(108,99,255,0.5); box-shadow: 0 0 0 3px var(--accent-soft); }
.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); }
.attach-btn { align-self: flex-end; margin-bottom: 2px; }
.send-btn {
  flex-shrink: 0; width: 36px; height: 36px; border-radius: 9px; border: none;
  background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center;
  transition: background .15s, transform .05s, opacity .15s;
}
.send-btn:hover:not(:disabled) { background: #7B72FF; }
.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; }

/* ===== 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(--accent); font-weight: 600; padding: 0; font-size: inherit; }
.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; }
.app-hidden { display: none !important; }

/* ===== rank system ===== */
/* Badge color comes from rank tier (applied inline by JS). */
.rank-badge {
  display: inline-flex; align-items: center;
  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; align-items: center; gap: 8px; margin-bottom: 9px; min-width: 0; }
.account-mini-email {
  font-size: 12px; color: var(--muted); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}

/* 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 */
.rank-callout {
  display: flex; align-items: flex-start; gap: 10px; text-align: left;
  margin: 22px auto 0; max-width: 620px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px 16px;
  font-size: 13px; color: var(--muted); line-height: 1.5;
}
.rank-callout strong { color: var(--text); }
.rank-callout-icon { font-size: 18px; line-height: 1.2; }

/* ===== 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; }

/* 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); }
}

/* ===== Top-up success celebration (half-screen, passive) ===== */
.topup-celebration {
  position: fixed; top: 0; left: 0; width: 100%; height: 50vh; z-index: 400;
  pointer-events: none;                 /* never block the app underneath */
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 50%, rgba(108,99,255,0.15), transparent 70%);
  opacity: 0; transform: scale(0.95); visibility: hidden;
  transition: opacity 0.4s ease, transform 0.3s ease-out, visibility 0s 0.4s;
}
.topup-celebration.show {
  opacity: 1; transform: scale(1); visibility: visible;
  transition: opacity 0.3s ease-out, transform 0.3s ease-out, visibility 0s 0s;
}
.topup-celebration-content {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  text-align: center; padding: 0 20px;
}
.topup-bolt-burst { position: absolute; inset: 0; pointer-events: none; }
.topup-celebration-text { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.topup-celebration-headline {
  font-size: 2.5rem; font-weight: 800; line-height: 1.1; letter-spacing: -.02em;
  background: linear-gradient(135deg, #8B7BFF, #5A4FE0);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.topup-celebration-subtext { color: #C0C0D0; font-size: 1.1rem; font-weight: 400; }
.topup-celebration-amount { color: #4ADE80; font-size: 1.3rem; font-weight: 700; }

/* 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; }
}
@media (max-width: 768px) {
  .topup-celebration-headline { font-size: 1.8rem; }
}
/* 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; }
}

/* ===== 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); }
.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-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(--accent); }

/* ===== 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);
  }
  .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; }

  /* 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; }
  .rank-callout { max-width: 100%; }

  /* 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; }
}
