/* ===== RESET & ROOT ===== */
:root {
  --bg: #050810;
  --card: rgba(255,255,255,.055);
  --card-hover: rgba(255,255,255,.08);
  --stroke: rgba(255,255,255,.10);
  --stroke-bright: rgba(255,255,255,.22);
  --text: rgba(255,255,255,.93);
  --muted: rgba(255,255,255,.60);
  --muted2: rgba(255,255,255,.40);
  --gold: #f5c542;
  --gold2: #ffd980;
  --silver: #b0bec5;
  --cyan: #00d4ff;
  --green: #4ade80;
  --red: #f87171;
  --orange: #fb923c;
  --purple: #a78bfa;
  --shadow-deep: 0 24px 80px rgba(0,0,0,.7);
  --shadow-card: 0 8px 32px rgba(0,0,0,.45);
  --r: 18px;
  --r-sm: 12px;
  --font: "Space Grotesk", system-ui, -apple-system, sans-serif;
  --mono: "Share Tech Mono", "Courier New", monospace;
}

*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== BACKGROUND ===== */
.bg {
  position: fixed; inset: 0; z-index: -1; overflow: hidden;
}
.bg-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 30%, black, transparent);
}
.bg-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: .45;
  pointer-events: none;
}
.bg-glow-1 { width: 600px; height: 600px; top: -150px; left: -100px; background: radial-gradient(circle, rgba(245,197,66,.22), transparent 70%); }
.bg-glow-2 { width: 500px; height: 500px; bottom: 5%; right: -100px; background: radial-gradient(circle, rgba(0,212,255,.18), transparent 70%); }
.bg-glow-3 { width: 400px; height: 400px; top: 40%; left: 40%; background: radial-gradient(circle, rgba(167,139,250,.15), transparent 70%); }

/* ===== TOPBAR ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: rgba(0,0,0,.55);
  border-bottom: 1px solid var(--stroke);
  backdrop-filter: blur(18px);
  position: sticky; top: 0; z-index: 100;
}
.topbar-brand { display: flex; align-items: center; gap: 12px; }
.topbar-icon {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #f5c542, #e67e00);
  border-radius: 12px;
  font-size: 22px;
  box-shadow: 0 4px 16px rgba(245,197,66,.4);
}
.topbar-kicker { font-size: 11px; color: var(--muted2); letter-spacing: .1em; text-transform: uppercase; }
.topbar-name { font-weight: 800; font-size: 17px; }
.topbar-link {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: var(--card);
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  transition: background .15s, transform .15s;
}
.topbar-link:hover { background: var(--card-hover); transform: translateY(-1px); }

/* ===== MAIN ===== */
.main {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

/* ===== HERO ===== */
.hero { padding: 20px 4px 14px; }
.hero-title { font-size: 38px; font-weight: 900; letter-spacing: -.5px; line-height: 1.1; }
.hero-sub { margin-top: 8px; color: var(--muted); font-size: 16px; max-width: 700px; }

/* ===== PANELS ===== */
.panel {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: var(--r);
  margin: 16px 0;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  background: rgba(255,255,255,.03);
  border-bottom: 1px solid var(--stroke);
}
.panel-title { font-weight: 800; font-size: 15px; }
.panel-hint { color: var(--muted2); font-size: 12px; }
.panel-body { padding: 16px; }

/* ===== FORM ===== */
.form-grid {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 10px 14px;
  align-items: center;
}
.form-label { color: var(--muted); font-weight: 600; font-size: 14px; }
.form-input {
  padding: 11px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--stroke);
  background: rgba(0,0,0,.3);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.form-input:focus {
  border-color: rgba(0,212,255,.5);
  box-shadow: 0 0 0 3px rgba(0,212,255,.12);
}
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.repo-link-row { margin-top: 10px; }
.repo-link { color: var(--accent, #00b4ff); font-size: 13px; text-decoration: none; opacity: .85; }
.repo-link:hover { opacity: 1; text-decoration: underline; }

/* ===== BUTTONS ===== */
.btn {
  padding: 11px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--stroke);
  background: linear-gradient(135deg, rgba(0,180,255,.28), rgba(255,255,255,.06));
  color: var(--text);
  font-family: var(--font);
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  transition: transform .14s, filter .14s, background .14s;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.06); }
.btn:active { transform: translateY(0); }
.btn-ghost { background: rgba(255,255,255,.05); font-weight: 700; }
.btn-xs { font-size: 12px; padding: 6px 10px; border-radius: 8px; }

.security-note {
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}
.security-note summary { cursor: pointer; font-weight: 700; color: rgba(255,255,255,.7); }
.security-note ul { margin: 10px 0 0 16px; line-height: 1.7; }
.security-note code { color: var(--gold); }

/* ===== MACHINE WRAPPER ===== */
.machine-wrap {
  position: relative;
  display: flex;
  justify-content: center;
  margin: 20px 0;
}

/* ===== MACHINE ===== */
.machine {
  position: relative;
  width: 100%;
  max-width: 820px;
  background: linear-gradient(160deg, #1a1a2e 0%, #12121c 60%, #0f0f18 100%);
  border: 2px solid rgba(245,197,66,.45);
  border-radius: 28px;
  box-shadow:
    0 0 0 1px rgba(0,0,0,.8),
    0 0 40px rgba(245,197,66,.12),
    var(--shadow-deep);
  overflow: hidden;
  padding: 0 0 28px;
}

/* Top of machine */
.machine-top {
  background: linear-gradient(135deg, #1f1b00, #2a2200);
  border-bottom: 2px solid rgba(245,197,66,.4);
  padding: 10px 16px 8px;
}
.machine-title-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 6px;
}
.machine-title-text {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: .15em;
  color: var(--gold);
  text-shadow: 0 0 18px rgba(245,197,66,.55);
}
.machine-jackpot-light {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 12px var(--gold), 0 0 6px var(--gold);
  animation: blink 1.2s ease-in-out infinite;
}
.machine-jackpot-light:nth-child(2) { animation-delay: .6s; }
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: .2; }
}
.machine-ticker {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--gold2);
  opacity: .8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: .08em;
}

/* Reels outer area */
.reels-outer {
  padding: 20px 20px 10px;
}
.reels-window {
  position: relative;
  background: rgba(0,0,0,.6);
  border: 2px solid rgba(245,197,66,.35);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: inset 0 4px 24px rgba(0,0,0,.8), 0 0 30px rgba(245,197,66,.08);
}
.reels {
  display: flex;
  align-items: stretch;
  height: 160px;
  padding: 0 10px;
}
.reel {
  flex: 1;
  overflow: hidden;
  position: relative;
  height: 160px;
}
.reel-separator {
  width: 2px;
  background: rgba(245,197,66,.2);
  align-self: stretch;
  margin: 12px 4px;
  border-radius: 2px;
}
.reel-strip {
  display: flex;
  flex-direction: column;
  align-items: center;
  will-change: transform;
  transition: transform 0.05s linear;
}
.reel-symbol {
  width: 100%;
  height: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 52px;
  line-height: 1;
  user-select: none;
}
.reel-symbol .sym-label {
  font-size: 9px;
  font-family: var(--mono);
  color: rgba(255,255,255,.45);
  margin-top: 4px;
  letter-spacing: .06em;
}

/* Shine overlay */
.reels-shine {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom,
    rgba(255,255,255,.06) 0%,
    transparent 30%,
    transparent 70%,
    rgba(0,0,0,.18) 100%
  );
  pointer-events: none;
}
.reels-scanline {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 3px,
    rgba(0,0,0,.04) 3px,
    rgba(0,0,0,.04) 4px
  );
  pointer-events: none;
}

/* Payline indicator */
.reels-window::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  transform: translateY(-50%);
  opacity: .5;
  pointer-events: none;
  z-index: 3;
}
.reels-window::after {
  content: '';
  position: absolute;
  top: calc(50% - 80px);
  bottom: calc(50% - 80px);
  left: 0; right: 0;
  border-top: 1px dashed rgba(245,197,66,.15);
  border-bottom: 1px dashed rgba(245,197,66,.15);
  pointer-events: none;
  z-index: 3;
}

/* Result bar */
.result-bar {
  margin: 12px 20px 8px;
  padding: 12px 16px;
  background: rgba(0,0,0,.45);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  text-align: center;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .3s, border-color .3s;
}
.result-text {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--muted);
  letter-spacing: .05em;
}

.result-bar.win-small { background: rgba(74,222,128,.1); border-color: rgba(74,222,128,.4); }
.result-bar.win-small .result-text { color: var(--green); }
.result-bar.win-medium { background: rgba(0,212,255,.1); border-color: rgba(0,212,255,.4); }
.result-bar.win-medium .result-text { color: var(--cyan); }
.result-bar.win-big { background: rgba(245,197,66,.14); border-color: rgba(245,197,66,.6); }
.result-bar.win-big .result-text { color: var(--gold); text-shadow: 0 0 14px rgba(245,197,66,.6); }
.result-bar.jackpot {
  background: linear-gradient(90deg, rgba(245,197,66,.18), rgba(255,255,255,.08), rgba(245,197,66,.18));
  border-color: var(--gold);
  animation: jackpot-pulse 0.5s ease-in-out infinite alternate;
}
.result-bar.jackpot .result-text {
  color: var(--gold);
  font-size: 18px;
  font-weight: 900;
  text-shadow: 0 0 28px rgba(245,197,66,.9);
}
@keyframes jackpot-pulse {
  from { box-shadow: 0 0 10px rgba(245,197,66,.3); }
  to { box-shadow: 0 0 40px rgba(245,197,66,.7); }
}

/* Controls */
.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 8px 20px;
  margin-top: 4px;
}
.bet-area { text-align: center; min-width: 80px; }
.bet-label {
  display: block;
  font-size: 10px;
  letter-spacing: .12em;
  color: var(--muted2);
  margin-bottom: 4px;
}
.spin-counter {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--gold);
}

.spin-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 32px;
  border-radius: 16px;
  border: 2px solid rgba(245,197,66,.55);
  background: linear-gradient(160deg, rgba(245,197,66,.3), rgba(245,130,0,.2));
  color: var(--gold);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 900;
  letter-spacing: .1em;
  cursor: pointer;
  transition: transform .14s, box-shadow .14s, filter .14s;
  box-shadow: 0 0 20px rgba(245,197,66,.2), inset 0 1px 0 rgba(255,255,255,.1);
}
.spin-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 35px rgba(245,197,66,.4), inset 0 1px 0 rgba(255,255,255,.15);
  filter: brightness(1.08);
}
.spin-btn:active { transform: translateY(1px); }
.spin-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
  transform: none;
}
.spin-btn-icon { font-size: 24px; }
.spin-btn-label { font-size: 13px; letter-spacing: .12em; }

/* Lever */
.lever-wrap {
  position: absolute;
  right: -22px;
  top: 50%;
  transform: translateY(-60%);
}
.lever-track {
  width: 20px;
  height: 140px;
  background: linear-gradient(180deg, #3a3a3a, #1a1a1a);
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.15);
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 4px;
}
.lever {
  position: relative;
  width: 10px;
  cursor: pointer;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1);
}
.lever.pulled { transform: translateY(90px); }
.lever::before {
  content: '';
  display: block;
  width: 4px;
  height: 70px;
  background: linear-gradient(to right, #888, #ccc, #888);
  border-radius: 2px;
  margin: 0 auto;
}
.lever-ball {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff6b6b, #c0392b);
  border: 1px solid rgba(255,255,255,.2);
  box-shadow: 0 0 12px rgba(255,80,80,.5), inset 0 1px 2px rgba(255,255,255,.3);
  position: absolute;
  top: -2px;
  left: -4px;
}

/* Win overlay */
.win-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 28px;
  pointer-events: none;
  z-index: 20;
  opacity: 0;
  transition: opacity .3s;
  font-size: 52px;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 0 40px rgba(245,197,66,.9);
  background: transparent;
}
.win-overlay.show { opacity: 1; }

/* Spinning animation */
.reel.spinning .reel-strip {
  animation: reel-spin 0.12s linear infinite;
}
@keyframes reel-spin {
  0% { transform: translateY(0); }
  100% { transform: translateY(-160px); }
}

/* ===== CONSOLE ===== */
.console-log {
  font-family: var(--mono);
  font-size: 12px;
  color: rgba(0,255,180,.85);
  background: rgba(0,0,0,.35);
  padding: 14px 16px;
  min-height: 130px;
  max-height: 260px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.7;
}
.console-log .log-err { color: var(--red); }
.console-log .log-ok { color: var(--green); }
.console-log .log-warn { color: var(--gold); }

/* ===== HISTORY ===== */
.history {
  padding: 12px 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
  max-height: 400px;
  overflow-y: auto;
}
.hist-item {
  background: rgba(0,0,0,.25);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 12px;
  transition: border-color .2s;
}
.hist-item:hover { border-color: rgba(245,197,66,.35); }
.hist-item.jackpot-item { border-color: rgba(245,197,66,.5); background: rgba(245,197,66,.06); }
.hist-symbols { font-size: 22px; letter-spacing: 4px; margin-bottom: 4px; }
.hist-result { font-weight: 700; color: var(--muted); }
.hist-result.win { color: var(--green); }
.hist-result.jackpot { color: var(--gold); }
.hist-time { color: var(--muted2); font-family: var(--mono); font-size: 11px; margin-top: 3px; }
.hist-commit { font-family: var(--mono); font-size: 10px; color: var(--cyan); margin-top: 2px; word-break: break-all; }
.hist-commit a { color: inherit; }
.hist-receipt-btn { margin-top: 6px; }

/* ===== FOOTER ===== */
.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 20px 28px;
  color: var(--muted2);
  font-size: 13px;
  font-weight: 600;
  max-width: 900px;
  margin: 0 auto;
}

/* ===== ANIMATIONS ===== */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes coin-burst {
  0% { transform: scale(0) rotate(-15deg); opacity: 1; }
  80% { transform: scale(1.3) rotate(5deg); opacity: .9; }
  100% { transform: scale(1) rotate(0deg); opacity: 0; }
}
.coin-burst {
  position: absolute;
  font-size: 36px;
  animation: coin-burst .6s ease-out forwards;
  pointer-events: none;
  z-index: 30;
}

/* ===== DEVICE IDENTITY ===== */
.identity-display {
  background: rgba(0,0,0,.45);
  border: 1px solid var(--stroke-bright);
  border-radius: var(--r-sm);
  padding: 18px 20px;
  text-align: center;
  margin-bottom: 12px;
  cursor: pointer;
  transition: border-color .2s;
}
.identity-display:hover { border-color: var(--cyan); }
.identity-blocks {
  font-family: var(--mono);
  font-size: 36px;
  letter-spacing: .12em;
  display: block;
  line-height: 1.4;
  word-break: break-all;
}
.identity-meta {
  font-size: 12px;
  color: var(--muted2);
  margin-bottom: 12px;
  font-family: var(--mono);
  letter-spacing: .05em;
}

/* ===== AI SIGNAL ANALYSIS ===== */
.ai-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--muted);
  font-family: var(--mono);
}
.ai-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--muted2);
  flex-shrink: 0;
  transition: background .3s;
}
.ai-dot.active { background: var(--green); box-shadow: 0 0 8px var(--green); animation: ai-pulse 1.4s ease-in-out infinite; }
.ai-dot.thinking { background: var(--gold); box-shadow: 0 0 8px var(--gold); animation: ai-pulse .7s ease-in-out infinite; }
.ai-log {
  max-height: 200px;
  overflow-y: auto;
  font-size: 12px;
}
.ai-prediction {
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-family: var(--mono);
  background: rgba(0,212,255,.07);
  border: 1px solid rgba(0,212,255,.18);
  color: var(--cyan);
  min-height: 36px;
  white-space: pre-wrap;
  display: none;
}
.ai-prediction.visible { display: block; }

@keyframes ai-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .3; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .hero-title { font-size: 26px; }
  .machine-title-text { font-size: 13px; letter-spacing: .06em; }
  .reel-symbol { font-size: 36px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-label { font-size: 12px; color: var(--muted2); }
  .footer { flex-direction: column; gap: 6px; text-align: center; }
  .identity-blocks { font-size: 26px; }
}

/* ===== TOPBAR LAYOUT UPDATE ===== */
.topbar-left  { display: flex; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ===== TOKEN FLOW ===== */
.token-flow {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}
.tf-step {
  background: rgba(245,197,66,.12);
  border: 1px solid rgba(245,197,66,.25);
  border-radius: 999px;
  padding: 4px 12px;
  color: var(--gold);
  font-size: 12px;
}
.tf-arrow { color: var(--muted2); font-size: 16px; }

/* ===== HAMBURGER BUTTON ===== */
.ham-btn {
  background: rgba(255,255,255,.07);
  border: 1px solid var(--stroke);
  border-radius: 10px;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  cursor: pointer;
  color: var(--text);
  font-size: 18px;
  transition: background .14s, transform .14s;
  flex-shrink: 0;
}
.ham-btn:hover { background: rgba(255,255,255,.14); transform: scale(1.04); }
.ham-icon { line-height: 1; }

/* ===== HAMBURGER OVERLAY ===== */
.ham-overlay {
  position: fixed; inset: 0; z-index: 199;
  background: rgba(0,0,0,.55);
  opacity: 0; pointer-events: none;
  transition: opacity .25s;
}
.ham-overlay.visible { opacity: 1; pointer-events: auto; }

/* ===== HAMBURGER DRAWER ===== */
.ham-drawer {
  position: fixed;
  left: -300px; top: 0; bottom: 0;
  width: 280px;
  background: #0c0c18;
  border-right: 1px solid var(--stroke-bright);
  z-index: 200;
  display: flex;
  flex-direction: column;
  padding: 0 0 24px;
  transition: left .28s cubic-bezier(.4,0,.2,1);
  overflow-y: auto;
}
.ham-drawer.open { left: 0; }
.ham-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--stroke);
  background: rgba(245,197,66,.07);
}
.ham-brand { font-weight: 900; font-size: 15px; color: var(--gold); }
.ham-close {
  background: transparent; border: none; color: var(--muted);
  font-size: 18px; cursor: pointer; padding: 4px 8px;
  border-radius: 8px; transition: background .14s, color .14s;
}
.ham-close:hover { background: rgba(255,255,255,.1); color: var(--text); }
.ham-section-label {
  font-size: 10px; font-weight: 800; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted2);
  padding: 14px 16px 4px;
}
.ham-link {
  display: block;
  padding: 10px 16px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: background .14s, color .14s;
  border-left: 2px solid transparent;
}
.ham-link:hover { background: rgba(255,255,255,.06); border-left-color: var(--gold); color: var(--gold2); }
.ham-coming-soon { opacity: .4; cursor: default; pointer-events: none; }
.ham-divider { height: 1px; background: var(--stroke); margin: 6px 0; }
.ham-footer { margin-top: auto; padding: 14px 16px; font-size: 11px; color: var(--muted2); }

/* ===== MODAL OVERLAY ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,.7);
  display: none;
  align-items: center; justify-content: center;
  padding: 16px;
}
.modal-overlay[aria-hidden="true"] { display: none !important; }

/* ===== MODAL ===== */
.modal {
  background: #10101e;
  border: 1px solid var(--stroke-bright);
  border-radius: var(--r);
  width: 100%; max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 32px 80px rgba(0,0,0,.8);
  animation: modal-in .2s ease-out;
}
@keyframes modal-in {
  from { opacity: 0; transform: scale(.95) translateY(-10px); }
  to   { opacity: 1; transform: scale(1)   translateY(0);     }
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--stroke);
  background: rgba(255,255,255,.03);
}
.modal-title { font-weight: 800; font-size: 16px; }
.modal-close {
  background: transparent; border: none; color: var(--muted);
  font-size: 18px; cursor: pointer; padding: 4px 8px;
  border-radius: 8px; transition: background .14s, color .14s;
}
.modal-close:hover { background: rgba(255,255,255,.1); color: var(--text); }
.modal-tabs {
  display: flex; border-bottom: 1px solid var(--stroke);
}
.modal-tab {
  flex: 1; padding: 11px 0; background: transparent;
  border: none; color: var(--muted); cursor: pointer;
  font-family: var(--font); font-weight: 700; font-size: 14px;
  transition: color .14s, background .14s; border-bottom: 2px solid transparent;
}
.modal-tab.active { color: var(--text); border-bottom-color: var(--gold); }
.modal-tab:hover:not(.active) { background: rgba(255,255,255,.04); }
.modal-body { padding: 16px; }

/* Auth messages */
.auth-msg { margin-top: 12px; font-size: 13px; color: var(--muted); min-height: 20px; }
.auth-msg.ok  { color: var(--green); }
.auth-msg.err { color: var(--red);   }

/* User badge in topbar */
.user-badge { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-badge-name { font-weight: 800; font-size: 14px; }
.user-badge-role { font-size: 11px; color: var(--gold); background: rgba(245,197,66,.12); padding: 2px 8px; border-radius: 999px; }

/* ===== PANEL HEAD ACTIONS ===== */
.panel-head-actions { display: flex; align-items: center; gap: 8px; }

/* ===== RESEARCH PANEL ===== */
.research-preview { padding: 0; }
.res-title {
  font-size: 14px; font-weight: 800; color: var(--cyan);
  margin-bottom: 8px; line-height: 1.4;
  padding: 16px 16px 0;
}
.res-meta {
  display: flex; gap: 12px; flex-wrap: wrap;
  font-size: 11px; color: var(--muted2); font-family: var(--mono);
  padding: 0 16px 8px;
}
.res-keywords {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding: 0 16px 10px;
}
.res-kw {
  background: rgba(0,212,255,.1); border: 1px solid rgba(0,212,255,.22);
  border-radius: 999px; padding: 2px 9px;
  font-size: 11px; color: var(--cyan); font-family: var(--mono);
}
.res-abstract {
  padding: 10px 16px 16px;
  font-size: 13px; color: var(--muted); line-height: 1.65;
  border-top: 1px solid var(--stroke);
}

/* ===== RESEARCH MODAL ===== */
.research-overlay { z-index: 310; }
.research-modal { max-width: 740px; }
.research-body { padding: 16px; }
.res-title-big {
  font-size: 17px; font-weight: 900; color: var(--cyan);
  line-height: 1.35; margin-bottom: 12px;
}
.res-meta-big {
  display: flex; gap: 10px; flex-wrap: wrap;
  font-size: 12px; color: var(--muted2); font-family: var(--mono);
  margin-bottom: 10px;
}
.res-badge {
  padding: 2px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 700;
}
.res-badge.enriched { background: rgba(74,222,128,.15); color: var(--green); }
.res-section { margin: 16px 0; }
.res-section h4 { font-size: 13px; font-weight: 800; color: var(--gold); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .06em; }
.res-section p  { font-size: 13px; color: var(--muted); line-height: 1.7; }
.res-source { color: var(--muted2); font-size: 11px; font-weight: 400; }
.res-related { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.res-link { color: var(--cyan); text-decoration: none; font-size: 13px; }
.res-link:hover { text-decoration: underline; }
.res-refs { padding-left: 18px; margin: 0; }
.res-refs li { font-size: 12px; font-family: var(--mono); color: var(--muted2); line-height: 1.8; }

/* ===== HISTORY — research snippet ===== */
.hist-research {
  font-size: 11px; color: var(--cyan); font-family: var(--mono);
  margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ===== AI CHAT ===== */
.chat-log {
  min-height: 180px; max-height: 340px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px;
  padding: 4px 0 8px;
  margin-bottom: 10px;
}
.chat-msg {
  display: flex; align-items: flex-start; gap: 8px; max-width: 100%;
}
.chat-msg.user { flex-direction: row-reverse; }
.chat-avatar {
  font-size: 20px; flex-shrink: 0; line-height: 1;
  margin-top: 2px;
}
.chat-bubble {
  max-width: calc(100% - 40px);
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.6;
}
.chat-msg.ai   .chat-bubble { background: rgba(0,212,255,.1); border: 1px solid rgba(0,212,255,.18); color: var(--text); border-bottom-left-radius: 4px; }
.chat-msg.user .chat-bubble { background: rgba(245,197,66,.13); border: 1px solid rgba(245,197,66,.25); color: var(--gold2); border-bottom-right-radius: 4px; }
.chat-thinking .chat-bubble { opacity: .7; }
.chat-link { color: var(--cyan); text-decoration: none; }
.chat-link:hover { text-decoration: underline; }
.chat-input-row { display: flex; gap: 8px; }
.chat-input { flex: 1; }
.chat-send-btn { flex-shrink: 0; white-space: nowrap; }

/* ===== ADMIN PANEL ===== */
.admin-panel { border-color: rgba(245,197,66,.35); }
.admin-panel .panel-head { background: rgba(245,197,66,.06); }

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .token-flow { gap: 4px; font-size: 11px; }
  .tf-step { padding: 3px 8px; font-size: 11px; }
  .ham-drawer { width: 260px; }
  .topbar-right { gap: 6px; }
  .user-badge-role { display: none; }
  .chat-send-btn { padding: 11px 10px; font-size: 13px; }
  .res-title-big { font-size: 15px; }
}
