/* ═══════════════════════════════════════════════════════════
   Overgeared RPG — Dark Fantasy Mobile-First Stylesheet
   ═══════════════════════════════════════════════════════════ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  /* ── Theme-controllable (set by applyTheme() per universe) ── */
  --primary-bg:   #0a0a0f;
  --secondary-bg: #0f101a;
  --accent:       #c8a84e;
  --accent-glow:  #e8c870;
  --text-primary: #e8e0d0;
  --text-muted:   #8a8070;
  --hp-color:     #b83030;
  --mp-color:     #3060b8;
  --xp-color:     #3a8a50;

  /* ── Derived / internal (not overridden by theme) ─────────── */
  --bg-card:      #13141f;
  --bg-card-h:    #1a1b28;
  --border:       #2a2b3d;
  --border-gold:  #4a3e1a;

  --gold-dim:     #6a5820;
  --text-dim:     #4a4438;

  --hp-bg:        #3a1010;
  --mp-bg:        #101830;
  --xp-bg:        #101e14;

  --danger:       #c83030;
  --success:      #3a9050;
  --info:         #4a80c0;

  /* Item grade colours */
  --grade-normal:    #c8c0b0;
  --grade-rare:      #50a868;
  --grade-epic:      #5888d8;
  --grade-unique:    #9060e8;
  --grade-legendary: #e89830;
  --grade-myth:      #e84040;

  /* Class accent colours */
  --class-warrior:    #c84030;
  --class-knight:     #8090c0;
  --class-swordsman:  #c09040;
  --class-archer:     #60a850;
  --class-mage:       #7060d8;
  --class-assassin:   #305840;
  --class-blacksmith: #a06030;
  --class-merchant:   #a0a040;

  --font-narrative: Georgia, 'Times New Roman', serif;
  --font-stats:     'Courier New', Courier, monospace;
  --font-ui:        -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --radius:    6px;
  --radius-lg: 10px;
  --shadow:    0 2px 12px rgba(0,0,0,.6);
  --glow-accent: 0 0 12px rgba(200,168,78,.25);
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; overflow: hidden; background: var(--primary-bg); color: var(--text-primary); font-family: var(--font-ui); font-size: 15px; -webkit-tap-highlight-color: transparent; }

/* ── Noise overlay ──────────────────────────────────────────── */
body::after {
  content: '';
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: .03;
  pointer-events: none;
  z-index: 9999;
}

/* ── Screens ────────────────────────────────────────────────── */
.screen { display: none; position: fixed; inset: 0; overflow: hidden; flex-direction: column; }
.screen.active { display: flex; }

/* ═══════════════════════════════════════════════════════════
   LOGIN SCREEN
   ═══════════════════════════════════════════════════════════ */
#screen-login { align-items: center; justify-content: center; background: var(--primary-bg); }

.login-wrap { width: 100%; max-width: 340px; padding: 2rem 1.5rem; display: flex; flex-direction: column; gap: 2rem; }

.logo { text-align: center; }
.logo-glyph { font-size: 3.5rem; line-height: 1; color: var(--accent); filter: drop-shadow(0 0 16px rgba(200,168,78,.6)); }
.logo h1 { font-family: var(--font-stats); font-size: 1.8rem; letter-spacing: .25em; color: var(--accent); margin: .4rem 0 .2rem; }
.logo-sub { color: var(--text-muted); font-size: .85rem; letter-spacing: .1em; }

#login-form { display: flex; flex-direction: column; gap: .9rem; }
#login-form input[type="password"] {
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text-primary);
  padding: .8rem 1rem; border-radius: var(--radius); font-size: 1rem; width: 100%;
  outline: none; transition: border-color .2s;
}
#login-form input[type="password"]:focus { border-color: var(--gold-dim); }

/* ═══════════════════════════════════════════════════════════
   UNIVERSE SELECT
   ═══════════════════════════════════════════════════════════ */
#screen-universe { background: var(--primary-bg); overflow-y: auto; padding-bottom: 5rem; }

.universe-list { display: flex; flex-direction: column; gap: 1rem; padding: 1rem; }

.universe-card {
  position: relative; border-radius: var(--radius-lg); overflow: hidden;
  min-height: 130px; cursor: pointer; border: 1px solid var(--border);
  transition: border-color .2s, box-shadow .2s, transform .15s;
}
.universe-card:hover, .universe-card:active {
  border-color: var(--universe-accent, var(--accent));
  box-shadow: 0 0 24px rgba(200,168,78,.18);
  transform: translateY(-1px);
}
.universe-bg { position: absolute; inset: 0; /* background gradient set inline per card */ }
.universe-card-content {
  position: relative; z-index: 1; padding: 1.4rem 1.2rem;
  display: flex; flex-direction: column; gap: .35rem;
}
.universe-name { font-family: var(--font-stats); font-size: 1.25rem; letter-spacing: .12em; /* color set inline */ }
.universe-tagline { font-size: .88rem; color: var(--text-muted); line-height: 1.4; max-width: 36ch; }
.universe-char-count { font-family: var(--font-stats); font-size: .72rem; color: var(--text-dim); margin-top: .3rem; }

/* Universe name badge in game top bar */
.universe-badge { font-family: var(--font-stats); font-size: .62rem; color: var(--text-dim); letter-spacing: .08em; text-transform: uppercase; opacity: .8; }

/* ═══════════════════════════════════════════════════════════
   CHARACTER SELECT
   ═══════════════════════════════════════════════════════════ */
#screen-select { background: var(--primary-bg); overflow-y: auto; padding-bottom: 5rem; }

.select-header { display: flex; align-items: center; justify-content: space-between; padding: 1.2rem 1rem .8rem; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--primary-bg); z-index: 10; gap: .5rem; }
.select-header h2 { font-family: var(--font-stats); color: var(--accent); font-size: 1rem; letter-spacing: .12em; flex: 1; }

.char-list { display: flex; flex-direction: column; gap: .6rem; padding: .8rem 1rem; }

/* Character card */
.char-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: .9rem 1rem; cursor: pointer; transition: border-color .2s, background .2s, box-shadow .2s;
  position: relative; display: flex; justify-content: space-between; align-items: center;
  -webkit-user-select: none; user-select: none;
}
.char-card:hover, .char-card:active { background: var(--bg-card-h); border-color: var(--gold-dim); box-shadow: var(--glow-accent); }
.char-card .card-left { display: flex; flex-direction: column; gap: .25rem; }
.char-card .card-name { font-size: 1.05rem; font-weight: 600; color: var(--text-primary); }
.char-card .card-meta { font-family: var(--font-stats); font-size: .78rem; color: var(--text-muted); }
.char-card .card-time { font-size: .75rem; color: var(--text-dim); }
.char-card .card-arrow { color: var(--gold-dim); font-size: 1.2rem; }
.char-card.deleted { opacity: .5; }
.char-card .btn-restore { font-size: .75rem; padding: .3rem .7rem; }

/* Class accent stripe */
.char-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; border-radius: var(--radius-lg) 0 0 var(--radius-lg); background: var(--card-accent, var(--gold-dim)); }
.char-card .card-right { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }
.char-card .btn-delete-card { font-size: .72rem; padding: .25rem .55rem; }

.deleted-section { padding: 0 1rem; }
.section-label { color: var(--text-dim); font-size: .75rem; letter-spacing: .1em; text-transform: uppercase; margin-bottom: .5rem; }

.btn-new-char {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  background: var(--bg-card); border: 1px solid var(--gold-dim); color: var(--accent);
  padding: .75rem 2rem; border-radius: 2rem; font-size: .95rem; cursor: pointer;
  box-shadow: var(--shadow); transition: background .2s, box-shadow .2s;
}
.btn-new-char:hover { background: var(--bg-card-h); box-shadow: var(--glow-accent); }

/* ── Creation Wizard ─────────────────────────────────────────── */
.creation-flow {
  position: fixed; inset: 0; background: var(--primary-bg); z-index: 20; display: flex;
  flex-direction: column; overflow-y: auto; padding-bottom: 2rem;
}
.wizard-step { display: flex; flex-direction: column; gap: 1rem; padding: 1rem; min-height: 100%; }
.wizard-header { display: flex; align-items: center; gap: .8rem; padding-bottom: .5rem; border-bottom: 1px solid var(--border); }
.wizard-title { flex: 1; font-family: var(--font-stats); color: var(--accent); font-size: .95rem; letter-spacing: .08em; }
.wizard-step-count { font-size: .75rem; color: var(--text-muted); font-family: var(--font-stats); }

#char-name { background: var(--bg-card); border: 1px solid var(--border); color: var(--text-primary); padding: .9rem 1rem; border-radius: var(--radius); font-size: 1.1rem; width: 100%; outline: none; transition: border-color .2s; }
#char-name:focus { border-color: var(--gold-dim); }
.hint-text { color: var(--text-muted); font-size: .82rem; }

/* Class grid */
.class-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.class-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: .8rem; cursor: pointer; transition: border-color .2s, background .2s;
  display: flex; flex-direction: column; gap: .3rem; position: relative; overflow: hidden;
}
.class-card::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 2px; background: var(--class-accent, var(--gold-dim)); opacity: 0; transition: opacity .2s; }
.class-card:hover::after, .class-card.selected::after { opacity: 1; }
.class-card.selected { border-color: var(--class-accent, var(--gold-dim)); background: var(--bg-card-h); }
.class-icon { font-size: 1.6rem; line-height: 1; }
.class-name { font-weight: 700; font-size: .9rem; color: var(--text-primary); }
.class-role { font-size: .75rem; color: var(--text-muted); }
.class-stats { font-family: var(--font-stats); font-size: .7rem; color: var(--text-dim); margin-top: .2rem; }

/* Stat allocation */
.stat-pool { display: flex; gap: .5rem; flex-wrap: wrap; padding: .5rem 0; }
.pool-chip {
  background: var(--bg-card); border: 1px solid var(--border-gold); color: var(--accent);
  font-family: var(--font-stats); font-size: .9rem; font-weight: 700;
  padding: .45rem .9rem; border-radius: var(--radius); cursor: pointer; transition: background .15s;
}
.pool-chip:hover { background: var(--bg-card-h); }
.pool-chip.disabled { opacity: .3; cursor: default; }

.stat-assignment-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.stat-slot {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .6rem .8rem; display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; transition: border-color .15s;
}
.stat-slot:hover { border-color: var(--gold-dim); }
.stat-slot.active { border-color: var(--accent); box-shadow: var(--glow-accent); }
.stat-slot .stat-name { font-family: var(--font-stats); font-size: .8rem; color: var(--text-muted); }
.stat-slot .stat-value { font-family: var(--font-stats); font-size: 1.1rem; font-weight: 700; color: var(--accent); min-width: 1.5rem; text-align: right; }
.stat-slot .stat-value.empty { color: var(--text-dim); }

/* ── Dialog ──────────────────────────────────────────────────── */
.dialog-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.75); z-index: 500; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.dialog { background: var(--secondary-bg); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.5rem; max-width: 320px; width: 100%; }
.dialog h3 { color: var(--text-primary); margin-bottom: .5rem; }
.dialog-body { color: var(--text-primary); font-weight: 600; margin-bottom: .3rem; }
.dialog-note { color: var(--text-muted); font-size: .82rem; margin-bottom: 1rem; }
.dialog-btns { display: flex; gap: .6rem; justify-content: flex-end; }

/* ═══════════════════════════════════════════════════════════
   GAME SCREEN
   ═══════════════════════════════════════════════════════════ */
#screen-game { flex-direction: column; background: var(--primary-bg); }

/* ── Status Bar ──────────────────────────────────────────────── */
#status-bar {
  flex-shrink: 0; background: var(--secondary-bg); border-bottom: 1px solid var(--border);
  padding: .5rem .8rem .4rem; display: flex; flex-direction: column; gap: .25rem; z-index: 5;
}
.status-left { display: flex; align-items: center; gap: .5rem; }
.char-name-btn {
  background: none; border: none; color: var(--accent); font-family: var(--font-stats);
  font-size: .9rem; font-weight: 700; letter-spacing: .04em; cursor: pointer; padding: 0;
  text-decoration: underline dotted var(--gold-dim);
}
.char-class-level { font-family: var(--font-stats); font-size: .75rem; color: var(--text-muted); }

.status-bars { display: flex; flex-direction: column; gap: .2rem; }
.bar-row { display: flex; align-items: center; gap: .4rem; }
.bar-lbl { font-family: var(--font-stats); font-size: .65rem; color: var(--text-dim); width: 1.5rem; text-align: right; flex-shrink: 0; }
.bar-track { flex: 1; height: 6px; background: var(--bg-card); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 3px; transition: width .5s ease; width: 0%; }
.hp-fill  { background: linear-gradient(90deg, var(--hp-color), #e05050); box-shadow: 0 0 6px rgba(200,50,50,.4); }
.mp-fill  { background: linear-gradient(90deg, var(--mp-color), #5090e0); box-shadow: 0 0 6px rgba(50,90,200,.4); }
.xp-fill  { background: linear-gradient(90deg, var(--xp-color), #60c070); box-shadow: 0 0 6px rgba(60,140,80,.4); }
.bar-val  { font-family: var(--font-stats); font-size: .65rem; color: var(--text-muted); width: 4.5rem; text-align: right; flex-shrink: 0; }
.location-line { font-size: .7rem; color: var(--text-muted); font-style: italic; padding-left: 2rem; margin-top: .1rem; }

/* ── Narrative Log ───────────────────────────────────────────── */
#narrative-log {
  flex: 1; overflow-y: auto; padding: 1rem; scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}
#narrative-log::-webkit-scrollbar { width: 4px; }
#narrative-log::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.narrative-entry { margin-bottom: 1.2rem; animation: entry-fade .3s ease; }
@keyframes entry-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.entry-player { text-align: right; }
.entry-player .bubble {
  display: inline-block; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 var(--radius); padding: .5rem .8rem;
  color: var(--text-muted); font-size: .88rem; max-width: 80%;
}

.entry-gm .bubble {
  display: block; font-family: var(--font-narrative); line-height: 1.75; font-size: .95rem;
  color: var(--text-primary); border-left: 2px solid var(--gold-dim); padding-left: .8rem;
}
.entry-gm .bubble em    { color: var(--accent); font-style: italic; }
.entry-gm .bubble strong{ color: #fff; }
.entry-gm .bubble code  { font-family: var(--font-stats); font-size: .82em; color: var(--accent); background: var(--bg-card); padding: .1em .3em; border-radius: 3px; }
.entry-gm .bubble .roll { font-family: var(--font-stats); color: var(--accent); font-size: .85em; }

.entry-system .bubble { display: block; color: var(--text-dim); font-size: .8rem; font-family: var(--font-stats); padding: .3rem 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); text-align: center; margin: .5rem 0; }

/* Typewriter cursor while streaming */
.streaming::after { content: '▌'; animation: blink .7s step-end infinite; color: var(--accent); }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }

.typing-indicator { display: flex; gap: 4px; align-items: center; padding: .4rem .8rem; }
.typing-indicator span { width: 7px; height: 7px; background: var(--gold-dim); border-radius: 50%; animation: bounce .9s infinite; }
.typing-indicator span:nth-child(2) { animation-delay: .15s; }
.typing-indicator span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%,60%,100% { transform: translateY(0); } 30% { transform: translateY(-5px); } }

/* ── Input Area ──────────────────────────────────────────────── */
#input-area { flex-shrink: 0; background: var(--secondary-bg); border-top: 1px solid var(--border); padding: .5rem .6rem; }
.quick-actions { display: flex; gap: .4rem; margin-bottom: .4rem; overflow-x: auto; padding-bottom: 2px; }
.quick-actions::-webkit-scrollbar { height: 2px; }
.quick-btn {
  flex-shrink: 0; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .45rem .65rem; font-size: 1rem; cursor: pointer;
  transition: background .15s, border-color .15s; color: var(--text-primary);
}
.quick-btn:hover, .quick-btn:active { background: var(--bg-card-h); border-color: var(--gold-dim); }

.input-row { display: flex; gap: .5rem; align-items: flex-end; }
#action-input {
  flex: 1; background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-primary); border-radius: var(--radius); padding: .55rem .8rem;
  font-size: .95rem; font-family: var(--font-ui); resize: none; outline: none;
  transition: border-color .2s; line-height: 1.4;
}
#action-input:focus { border-color: var(--gold-dim); }
#action-input:disabled { opacity: .5; }
.btn-send {
  background: var(--gold-dim); border: none; color: var(--primary-bg); width: 2.6rem; height: 2.6rem;
  border-radius: var(--radius); font-size: 1rem; cursor: pointer; flex-shrink: 0;
  transition: background .15s; display: flex; align-items: center; justify-content: center;
}
.btn-send:hover { background: var(--accent); }
.btn-send:disabled { opacity: .4; cursor: default; }

/* ── Drawer ──────────────────────────────────────────────────── */
.drawer-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 30; }
#drawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: min(85vw, 320px);
  background: var(--secondary-bg); border-right: 1px solid var(--border);
  z-index: 31; display: flex; flex-direction: column;
  transform: translateX(-100%); transition: transform .3s cubic-bezier(.25,.8,.25,1);
}
#drawer.open { transform: translateX(0); }
.drawer-top { display: flex; justify-content: flex-end; padding: .6rem .6rem .2rem; }
.drawer-tabs { display: flex; border-bottom: 1px solid var(--border); overflow-x: auto; }
.drawer-tabs::-webkit-scrollbar { height: 0; }
.dtab {
  flex: 1; background: none; border: none; color: var(--text-muted);
  padding: .55rem .4rem; font-size: .75rem; cursor: pointer; white-space: nowrap;
  border-bottom: 2px solid transparent; transition: color .15s, border-color .15s;
}
.dtab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-panel { display: none; flex: 1; overflow-y: auto; padding: .8rem; }
.tab-panel.active { display: block; }
.tab-panel::-webkit-scrollbar { width: 3px; }
.tab-panel::-webkit-scrollbar-thumb { background: var(--border); }

/* Tab content styles */
.stat-row { display: flex; justify-content: space-between; padding: .3rem 0; border-bottom: 1px solid var(--border); font-size: .85rem; }
.stat-row .sn { color: var(--text-muted); font-family: var(--font-stats); }
.stat-row .sv { color: var(--text-primary); font-family: var(--font-stats); font-weight: 700; }
.stat-row .sv.gold { color: var(--accent); }

.inv-item { display: flex; justify-content: space-between; align-items: center; padding: .4rem 0; border-bottom: 1px solid var(--border); }
.inv-name { font-size: .88rem; }
.inv-badge { font-family: var(--font-stats); font-size: .7rem; padding: .15rem .5rem; border-radius: 3px; background: var(--bg-card); }
.grade-Normal    { color: var(--grade-normal); border: 1px solid var(--grade-normal); }
.grade-Rare      { color: var(--grade-rare);   border: 1px solid var(--grade-rare); }
.grade-Epic      { color: var(--grade-epic);   border: 1px solid var(--grade-epic); }
.grade-Unique    { color: var(--grade-unique);  border: 1px solid var(--grade-unique); }
.grade-Legendary { color: var(--grade-legendary); border: 1px solid var(--grade-legendary); }
.grade-Myth      { color: var(--grade-myth);   border: 1px solid var(--grade-myth); }

.quest-item { padding: .5rem 0; border-bottom: 1px solid var(--border); }
.quest-name { font-size: .88rem; font-weight: 600; }
.quest-grade { font-family: var(--font-stats); font-size: .7rem; }
.quest-desc { font-size: .78rem; color: var(--text-muted); margin-top: .2rem; }
.status-active    { color: var(--xp-color); }
.status-completed { color: var(--text-muted); }
.status-failed    { color: var(--danger); }

.npc-item { display: flex; align-items: center; gap: .6rem; padding: .4rem 0; border-bottom: 1px solid var(--border); }
.npc-name { font-size: .88rem; flex: 1; }
.affinity-bar-wrap { width: 60px; height: 6px; background: var(--bg-card); border-radius: 3px; overflow: hidden; }
.affinity-bar { height: 100%; border-radius: 3px; }
.affinity-val { font-family: var(--font-stats); font-size: .7rem; color: var(--text-muted); width: 2rem; text-align: right; }

.timeline-item { padding: .5rem 0; border-bottom: 1px solid var(--border); }
.timeline-chapter { font-family: var(--font-stats); font-size: .7rem; color: var(--text-dim); }
.timeline-desc { font-size: .85rem; }
.timeline-diverted { font-size: .75rem; color: var(--grade-legendary); margin-top: .2rem; }
.status-happened  { text-decoration: line-through; color: var(--text-dim); }
.status-diverted  { color: var(--grade-legendary); }
.status-prevented { color: var(--grade-rare); }

.drawer-footer { border-top: 1px solid var(--border); padding: .6rem; display: flex; gap: .4rem; flex-wrap: wrap; }
.drawer-footer button { flex: 1; min-width: 80px; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn-primary {
  background: var(--gold-dim); border: 1px solid var(--gold-dim); color: var(--text-primary);
  padding: .75rem 1.5rem; border-radius: var(--radius); font-size: .95rem; cursor: pointer;
  transition: background .2s, box-shadow .2s; width: 100%;
}
.btn-primary:hover:not(:disabled) { background: var(--accent); box-shadow: var(--glow-accent); }
.btn-primary:disabled { opacity: .4; cursor: default; }

.btn-ghost {
  background: none; border: 1px solid var(--border); color: var(--text-muted);
  padding: .5rem 1rem; border-radius: var(--radius); font-size: .85rem; cursor: pointer;
  transition: border-color .15s, color .15s;
}
.btn-ghost:hover { border-color: var(--text-muted); color: var(--text-primary); }
.btn-ghost.sm { padding: .3rem .7rem; font-size: .8rem; }
.btn-ghost.danger, .btn-ghost.danger:hover { color: var(--danger); border-color: var(--danger); }

.btn-danger { background: var(--danger); border: 1px solid var(--danger); color: #fff; padding: .5rem 1rem; border-radius: var(--radius); font-size: .85rem; cursor: pointer; }
.btn-back { background: none; border: none; color: var(--text-muted); font-size: 1.1rem; cursor: pointer; padding: 0 .3rem; line-height: 1; }

/* ── Language toggle (creation wizard) ─────────────────────── */
.lang-toggle { display: flex; gap: .5rem; margin: .5rem 0; }
.lang-btn { flex: 1; background: var(--bg-card); border: 1px solid var(--border); color: var(--text-muted); padding: .5rem .6rem; border-radius: var(--radius); font-size: .85rem; cursor: pointer; transition: border-color .15s, color .15s, background .15s; }
.lang-btn:hover { border-color: var(--text-muted); color: var(--text-primary); }
.lang-btn.active { border-color: var(--accent); color: var(--accent); background: rgba(200,168,78,.12); font-weight: 600; }

/* ── Toast ──────────────────────────────────────────────────── */
#toasts { position: fixed; bottom: calc(3.5rem + env(safe-area-inset-bottom)); right: .8rem; z-index: 200; display: flex; flex-direction: column; gap: .4rem; align-items: flex-end; }
.toast {
  background: var(--secondary-bg); border: 1px solid var(--border); color: var(--text-primary);
  padding: .5rem .9rem; border-radius: var(--radius); font-size: .82rem; max-width: 220px;
  animation: toast-in .25s ease; box-shadow: var(--shadow);
}
.toast.removing { animation: toast-out .25s ease forwards; }
.toast.ok   { border-color: var(--success); color: var(--success); }
.toast.err  { border-color: var(--danger); color: var(--danger); }
@keyframes toast-in  { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to   { opacity: 0; transform: translateX(20px); } }

/* ── Error msg ──────────────────────────────────────────────── */
.error-msg { color: var(--danger); font-size: .82rem; text-align: center; }

/* ── Scrollbar (non-webkit) ──────────────────────────────────── */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (min-width: 768px) {
  .login-wrap  { max-width: 360px; }
  .class-grid  { grid-template-columns: repeat(4, 1fr); }
  .stat-assignment-grid { grid-template-columns: repeat(3, 1fr); }
  #status-bar { flex-direction: row; align-items: center; gap: 1rem; flex-wrap: wrap; }
  .status-bars { flex-direction: row; gap: .8rem; }
  .bar-row { min-width: 140px; }
  #drawer { width: 300px; }
  .universe-list { display: grid; grid-template-columns: repeat(2, 1fr); }
}
