:root {
  --bg: #fbf5ee;
  --bg-elev: rgba(255, 252, 247, 0.88);
  --bg-card: rgba(255, 253, 249, 0.94);
  --border: rgba(206, 168, 138, 0.36);
  --border-glow: rgba(224, 122, 95, 0.45);
  --text: #362621;
  --muted: #7c6358;
  --emerald: #3d7a64;
  --cyan: #d97742;
  --rose: #e05a6d;
  --amber: #d97706;
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.55;
  overflow-x: hidden;
}

.hidden {
  display: none !important;
}

.lab-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(circle at 12% 10%, rgba(244, 162, 97, 0.22), transparent 46%),
    radial-gradient(circle at 88% 20%, rgba(231, 111, 81, 0.14), transparent 45%),
    radial-gradient(circle at 50% 88%, rgba(246, 189, 96, 0.18), transparent 50%),
    linear-gradient(to right, rgba(194, 152, 120, 0.06) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(194, 152, 120, 0.06) 1px, transparent 1px);
  background-size: auto, auto, auto, 28px 28px, 28px 28px;
}

code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  color: #b4532a;
  background: rgba(224, 122, 95, 0.12);
  padding: 1px 6px;
  border-radius: 6px;
}

/* ---------------- Lock Screen ---------------- */
.lock-screen {
  position: relative;
  z-index: 2;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
}

.lock-shell {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.signal-pill {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 252, 247, 0.92);
  font-family: var(--font-mono);
  font-size: 11px;
  color: #b4532a;
  letter-spacing: 0.04em;
  box-shadow: 0 4px 14px rgba(120, 72, 42, 0.06);
}

.dot-live {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #e07a5f;
  box-shadow: 0 0 8px rgba(224, 122, 95, 0.65);
  animation: pulseDot 1.8s infinite;
}

@keyframes pulseDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.45); opacity: 0.55; }
}

.handshake-canvas-wrap {
  position: relative;
  height: 196px;
  border-radius: 22px;
  border: 1px solid var(--border);
  background: linear-gradient(155deg, #fff6ea, #fce8d5);
  overflow: hidden;
  box-shadow: 0 14px 32px rgba(135, 82, 48, 0.1);
}

#handshake-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.canvas-hud {
  position: absolute;
  inset: auto 12px 12px 12px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}

.hud-node {
  display: flex;
  flex-direction: column;
  padding: 6px 10px;
  border-radius: 12px;
  background: rgba(255, 252, 247, 0.86);
  border: 1px solid rgba(206, 168, 138, 0.45);
  backdrop-filter: blur(8px);
}

.hud-city {
  font-size: 12px;
  font-weight: 700;
}

.hud-left .hud-city { color: #c85a32; }
.hud-right .hud-city { color: #3d7a64; }

.hud-node small,
.hud-distance small {
  font-size: 10px;
  color: var(--muted);
}

.hud-distance {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hud-distance span {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: #9a4021;
  background: rgba(255, 250, 244, 0.92);
  border: 1px solid rgba(224, 122, 95, 0.4);
  padding: 2px 9px;
  border-radius: 999px;
}

.lock-card {
  border-radius: 22px;
  padding: 22px 18px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  backdrop-filter: blur(18px);
  box-shadow: 0 14px 34px rgba(130, 78, 45, 0.08);
}

.lock-title {
  margin: 0 0 8px;
  font-size: 24px;
  letter-spacing: 0.02em;
  color: var(--text);
}

.lock-title span {
  background: linear-gradient(120deg, #d96b43, #d99326);
  -webkit-background-clip: text;
  color: transparent;
}

.lock-epigraph {
  margin: 0 0 18px;
  font-size: 13px;
  color: var(--muted);
}

.prompt-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: #b4532a;
  margin-bottom: 8px;
}

.input-row {
  display: flex;
  gap: 8px;
}

input[type="text"],
input[type="password"],
input[type="url"] {
  width: 100%;
  min-width: 0;
  padding: 11px 13px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fffdf9;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus {
  border-color: #e07a5f;
  box-shadow: 0 0 0 3px rgba(224, 122, 95, 0.16);
}

.btn-primary {
  border: 0;
  border-radius: 12px;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
  background: linear-gradient(135deg, #e07a5f, #ea9a53);
  box-shadow: 0 6px 16px rgba(224, 122, 95, 0.25);
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.15s, opacity 0.2s;
}

.btn-primary:active {
  transform: scale(0.97);
}

.btn-primary.small {
  padding: 9px 13px;
  font-size: 12.5px;
}

.btn-ghost {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  background: rgba(255, 252, 247, 0.8);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}

.lock-error {
  margin: 8px 0 0;
  min-height: 18px;
  font-size: 12px;
  color: var(--rose);
}

.demo-hint {
  margin: 6px 0 0;
  font-size: 11px;
  color: var(--muted);
  background: rgba(244, 162, 97, 0.12);
  border: 1px dashed rgba(224, 122, 95, 0.35);
  padding: 7px 10px;
  border-radius: 10px;
}

/* ---------------- Main App Shell ---------------- */
.app-shell {
  position: relative;
  z-index: 2;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: 12px 14px calc(88px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  margin: 0 -4px 12px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(255, 251, 246, 0.9);
  backdrop-filter: blur(14px);
  box-shadow: 0 8px 20px rgba(130, 78, 45, 0.06);
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-badge {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 15px;
  background: linear-gradient(135deg, rgba(246, 189, 96, 0.25), rgba(224, 122, 95, 0.22));
  border: 1px solid rgba(224, 122, 95, 0.32);
  flex-shrink: 0;
}

.brand-title {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.brand-sub {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  color: #b4532a;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fffaf3;
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.pulse-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid rgba(224, 90, 109, 0.35);
  background: rgba(224, 90, 109, 0.1);
  color: #b83b4d;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.pulse-btn b {
  font-family: var(--font-mono);
  font-size: 11px;
  color: #fff;
  background: #e05a6d;
  padding: 1px 6px;
  border-radius: 999px;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #e05a6d;
  box-shadow: 0 0 6px rgba(224, 90, 109, 0.6);
}

.demo-banner {
  margin-bottom: 10px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px dashed rgba(217, 119, 6, 0.38);
  background: rgba(251, 191, 36, 0.12);
  color: #92400e;
  font-size: 11px;
}

.telemetry-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.tele-item {
  padding: 10px 10px;
  border-radius: 15px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  text-align: center;
  box-shadow: 0 4px 12px rgba(130, 78, 45, 0.04);
}

.tele-label {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.tele-value {
  display: block;
  margin-top: 2px;
  font-family: var(--font-mono);
  font-size: 15px;
  color: #c85a32;
}

/* ---------------- Views & Cards ---------------- */
.view {
  display: none;
  flex-direction: column;
  gap: 12px;
  animation: fadeUp 0.25s ease;
}

.view.active {
  display: flex;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  border-radius: 18px;
  padding: 15px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  box-shadow: 0 8px 22px rgba(130, 78, 45, 0.05);
}

.hero-quote-card {
  background: linear-gradient(145deg, #fff9f2, #fdeee0);
  border-color: rgba(224, 122, 95, 0.3);
}

.card-kicker {
  font-family: var(--font-mono);
  font-size: 10px;
  color: #b4532a;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.hero-quote {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--text);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.card-title {
  margin: 0;
  font-size: 16px;
  color: var(--text);
}

.card-hint {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--muted);
}

.badge-emerald,
.badge-cyan {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.badge-emerald {
  color: #2c6e58;
  background: rgba(61, 122, 100, 0.12);
  border: 1px solid rgba(61, 122, 100, 0.3);
}

.badge-cyan {
  color: #b4532a;
  background: rgba(224, 122, 95, 0.12);
  border: 1px solid rgba(224, 122, 95, 0.3);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.metric-box {
  padding: 13px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  box-shadow: 0 4px 14px rgba(130, 78, 45, 0.04);
}

.metric-label {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.metric-num {
  display: block;
  margin: 4px 0 2px;
  font-family: var(--font-mono);
  font-size: 21px;
  background: linear-gradient(120deg, #b84b27, #d9822b);
  -webkit-background-clip: text;
  color: transparent;
}

.metric-box small {
  font-size: 11px;
  color: var(--muted);
}

.paradox-card {
  border-color: rgba(224, 122, 95, 0.32);
  background: linear-gradient(155deg, #fffaf4, #fdf0e4);
}

.paradox-insight {
  margin: 2px 0 10px;
  font-size: 13px;
  color: #4b362f;
}

.paradox-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.paradox-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--muted);
}

.paradox-pill.peak {
  color: #a15208;
  border-color: rgba(217, 119, 6, 0.38);
  background: rgba(251, 191, 36, 0.16);
}

.paradox-pill.quiet {
  color: #2c6e58;
  border-color: rgba(61, 122, 100, 0.35);
  background: rgba(61, 122, 100, 0.1);
}

.chart-wrap {
  position: relative;
  height: 175px;
  border-radius: 14px;
  background: #fff9f2;
  border: 1px solid rgba(206, 168, 138, 0.3);
  overflow: hidden;
}

.chart-wrap.short {
  height: 145px;
}

.chart-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.milestone-box {
  margin-top: 10px;
  padding: 11px 12px;
  border-radius: 12px;
  background: rgba(61, 122, 100, 0.08);
  border: 1px solid rgba(61, 122, 100, 0.24);
  font-size: 12.5px;
  color: var(--text);
}

.milestone-box strong {
  color: #2c6e58;
}

.milestone-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: #b4532a;
  margin-bottom: 4px;
}

/* ---------------- Token Cloud & Bubbles ---------------- */
.token-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 12px;
}

.token-chip {
  border: 1px solid var(--border);
  background: #fffaf3;
  color: var(--text);
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 12.5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.16s;
}

.token-chip small {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
}

.token-chip.active {
  border-color: #e07a5f;
  background: rgba(224, 122, 95, 0.14);
  color: #9a3b1f;
  font-weight: 600;
}

.quote-panel {
  border-radius: 14px;
  padding: 12px;
  background: #fff8f0;
  border: 1px solid rgba(206, 168, 138, 0.32);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quote-panel-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
}

.bubble-row {
  display: flex;
}

.bubble-row.him { justify-content: flex-end; }
.bubble-row.her { justify-content: flex-start; }

.bubble {
  max-width: 85%;
  padding: 8px 11px;
  border-radius: 14px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text);
}

.bubble-row.him .bubble {
  background: rgba(244, 162, 97, 0.22);
  border: 1px solid rgba(224, 122, 95, 0.32);
  border-bottom-right-radius: 4px;
}

.bubble-row.her .bubble {
  background: #ffffff;
  border: 1px solid rgba(61, 122, 100, 0.28);
  border-bottom-left-radius: 4px;
}

.legend-inline {
  display: flex;
  gap: 10px;
  font-size: 11px;
  color: var(--muted);
}

.lg-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
}

.lg-dot.him { background: #e07a5f; }
.lg-dot.her { background: #3d7a64; }

/* ---------------- Memories & Map ---------------- */
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chip-btn {
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fffaf3;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.chip-btn.active {
  color: #9a3b1f;
  border-color: #e07a5f;
  background: rgba(224, 122, 95, 0.14);
  font-weight: 600;
}

.memory-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.memory-card {
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  overflow: hidden;
  box-shadow: 0 8px 22px rgba(130, 78, 45, 0.06);
}

.memory-media {
  position: relative;
  background: #f6ebe0;
  min-height: 170px;
  display: grid;
  place-items: center;
  border-bottom: 1px solid var(--border);
}

.memory-media img,
.memory-media video {
  width: 100%;
  max-height: 360px;
  object-fit: cover;
  object-position: center 24%;
  display: block;
}

.media-placeholder {
  padding: 28px 18px;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
}

.media-placeholder span {
  display: block;
  font-size: 26px;
  margin-bottom: 6px;
}

.media-tag {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: #362621;
  background: rgba(255, 251, 245, 0.88);
  border: 1px solid rgba(206, 168, 138, 0.45);
  backdrop-filter: blur(6px);
}

.video-switch-btn {
  position: absolute;
  bottom: 10px;
  right: 10px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(61, 122, 100, 0.45);
  background: rgba(255, 251, 245, 0.92);
  color: #2c6e58;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.memory-body {
  padding: 14px;
}

.memory-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
}

.memory-head h3 {
  margin: 0;
  font-size: 15px;
  color: var(--text);
}

.memory-head time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}

.dual-perspective {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cv-box,
.gt-box {
  padding: 9px 11px;
  border-radius: 12px;
  font-size: 12.5px;
}

.cv-box {
  background: rgba(244, 162, 97, 0.12);
  border: 1px solid rgba(224, 122, 95, 0.25);
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: #7c4028;
}

.gt-box {
  background: rgba(61, 122, 100, 0.08);
  border: 1px solid rgba(61, 122, 100, 0.25);
  color: #28463b;
}

.gt-box strong,
.cv-box strong {
  display: block;
  font-size: 10.5px;
  margin-bottom: 3px;
  opacity: 0.9;
}

.memory-quote {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--muted);
}

/* ---------------- Mini RAG AI Chat ---------------- */
.ai-head-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ai-mode-desc {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.chat-messages {
  min-height: 210px;
  max-height: 36dvh;
  overflow-y: auto;
  padding: 12px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: #fff9f3;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-msg {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 15px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text);
}

.ai-msg.user {
  align-self: flex-end;
  background: rgba(244, 162, 97, 0.24);
  border: 1px solid rgba(224, 122, 95, 0.35);
  border-bottom-right-radius: 4px;
}

.ai-msg.bot {
  align-self: flex-start;
  background: #ffffff;
  border: 1px solid rgba(206, 168, 138, 0.4);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(130, 78, 45, 0.04);
}

.rag-sources {
  margin-top: 7px;
  padding-top: 6px;
  border-top: 1px dashed rgba(206, 168, 138, 0.45);
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: #3d7a64;
}

.quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.quick-chip {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fffaf3;
  color: #b4532a;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
}

.rag-form {
  display: flex;
  gap: 8px;
}

/* ---------------- Bottom Nav ---------------- */
.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: calc(10px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: calc(100% - 24px);
  max-width: 456px;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 6px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(255, 251, 246, 0.94);
  backdrop-filter: blur(18px);
  box-shadow: 0 10px 28px rgba(120, 72, 42, 0.12);
}

.nav-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 7px 6px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  cursor: pointer;
}

.nav-btn.active {
  background: rgba(224, 122, 95, 0.14);
  color: #b84b27;
  font-weight: 700;
}

.nav-ico {
  font-size: 16px;
}

/* ---------------- Dialog & Toast ---------------- */
.lab-dialog {
  width: min(92vw, 420px);
  border: 1px solid var(--border);
  border-radius: 20px;
  background: #fffaf3;
  color: var(--text);
  padding: 16px;
  box-shadow: 0 20px 50px rgba(90, 50, 28, 0.18);
}

.lab-dialog::backdrop {
  background: rgba(54, 38, 33, 0.42);
  backdrop-filter: blur(5px);
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.dialog-head h3 {
  margin: 0;
  font-size: 16px;
  color: var(--text);
}

.dialog-tip {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--muted);
}

.dialog-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dialog-form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.toast {
  position: fixed;
  left: 50%;
  top: 72px;
  transform: translateX(-50%) translateY(-10px);
  padding: 9px 14px;
  border-radius: 999px;
  background: rgba(255, 252, 247, 0.98);
  border: 1px solid var(--border-glow);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  box-shadow: 0 8px 20px rgba(120, 72, 42, 0.14);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 50;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------------- 1.5s Boot Calibration Overlay ---------------- */
.boot-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(251, 245, 238, 0.94);
  backdrop-filter: blur(18px);
}

.boot-card {
  width: 100%;
  max-width: 390px;
  padding: 24px 18px;
  border-radius: 22px;
  border: 1px solid var(--border-glow);
  background: #fffdf9;
  text-align: center;
  box-shadow: 0 18px 40px rgba(130, 78, 45, 0.1);
}

.boot-kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: #3d7a64;
  margin-bottom: 10px;
}

.boot-route {
  font-size: 13px;
  font-weight: 700;
  color: #c85a32;
  margin-bottom: 14px;
}

.boot-bar {
  height: 7px;
  border-radius: 999px;
  background: rgba(206, 168, 138, 0.25);
  overflow: hidden;
  margin-bottom: 10px;
}

.boot-bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #e07a5f, #f4a261, #3d7a64);
  transition: width 1.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.boot-sub {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

/* ---------------- Compact Memory Quiz ---------------- */
.quiz-head-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.quiz-body {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed rgba(206, 168, 138, 0.4);
}

.quiz-progress {
  font-family: var(--font-mono);
  font-size: 11px;
  color: #b4532a;
  margin-bottom: 6px;
}

.quiz-q {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.quiz-opt {
  text-align: left;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fffaf3;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.quiz-opt.correct {
  border-color: #3d7a64;
  background: rgba(61, 122, 100, 0.14);
  color: #1f4d3c;
  font-weight: 600;
}

.quiz-opt.wrong {
  border-color: var(--rose);
  background: rgba(224, 90, 109, 0.12);
}

.quiz-feedback {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(244, 162, 97, 0.12);
  border: 1px solid rgba(224, 122, 95, 0.3);
  font-size: 12.5px;
  color: #5a382b;
}

.quiz-next-row {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.quiz-report {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(244, 162, 97, 0.15), rgba(61, 122, 100, 0.1));
  border: 1px solid rgba(224, 122, 95, 0.35);
}

.quiz-report-title {
  color: #2c6e58;
  font-size: 14px;
}

.quiz-report-sub {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.quiz-report-sticker {
  width: 58px;
  height: 58px;
  border-radius: 12px;
  object-fit: cover;
  flex-shrink: 0;
}

/* ---------------- 5-City Stamp Bar & Card Reactions ---------------- */
.stamp-bar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin: 8px 0 10px;
}

.stamp-pill {
  padding: 6px 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fffaf3;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  cursor: pointer;
  transition: all 0.18s;
}

.stamp-pill.stamped {
  border-color: #3d7a64;
  background: rgba(61, 122, 100, 0.13);
  color: #265947;
  font-weight: 700;
}

.stamp-pill.active {
  box-shadow: 0 0 0 2px rgba(224, 122, 95, 0.45);
}

.reaction-row {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed rgba(206, 168, 138, 0.38);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.react-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fffaf3;
  color: var(--muted);
  font-size: 11.5px;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.15s, color 0.15s;
}

.react-btn:active {
  transform: scale(0.94);
}

.react-btn.active {
  border-color: rgba(224, 90, 109, 0.5);
  background: rgba(224, 90, 109, 0.1);
  color: #a83344;
  font-weight: 600;
}

/* ---------------- Finale Secret Vault ---------------- */
.finale-vault {
  border-color: rgba(224, 122, 95, 0.4);
  background: linear-gradient(155deg, #fff9f2, #fceee4);
}

.finale-locked {
  text-align: center;
  padding: 12px 6px;
}

.finale-locked h3 {
  margin: 6px 0;
  font-size: 15px;
  color: var(--text);
}

.finale-locked p {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
}

.finale-unlocked-letter {
  margin: 10px 0 12px;
  padding: 13px;
  border-radius: 14px;
  background: #fffdf9;
  border: 1px solid rgba(206, 168, 138, 0.4);
  font-size: 13px;
  line-height: 1.65;
  color: var(--text);
  white-space: pre-line;
}

.finale-letter-title {
  color: #b4532a;
  display: block;
  margin-bottom: 6px;
}

/* ---------------- Gacha Modal & Floating Stickers ---------------- */
.ai-btn-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.gacha-trigger-btn {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(217, 119, 6, 0.4);
  background: rgba(251, 191, 36, 0.18);
  color: #92400e;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.gacha-stage {
  margin: 10px 0 14px;
  padding: 16px 14px;
  border-radius: 14px;
  background: #fff4e8;
  border: 1px solid var(--border);
  text-align: center;
}

.gacha-sticker {
  width: 72px;
  height: 72px;
  border-radius: 14px;
  object-fit: cover;
  margin-bottom: 8px;
}

.gacha-placeholder {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.gacha-coupon-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: #9a4021;
  background: rgba(224, 122, 95, 0.16);
  border: 1px solid rgba(224, 122, 95, 0.35);
  padding: 2px 9px;
  border-radius: 999px;
  margin-bottom: 6px;
}

.gacha-coupon-title {
  margin: 2px 0 6px;
  font-size: 16px;
  color: var(--text);
}

.gacha-coupon-desc {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
}

.gacha-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.sticker-burst {
  position: fixed;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  object-fit: cover;
  pointer-events: none;
  z-index: 80;
  box-shadow: 0 4px 12px rgba(90, 50, 28, 0.25);
  animation: floatSticker 1.1s ease-out forwards;
}

@keyframes floatSticker {
  0% {
    opacity: 0;
    transform: translate(-50%, 0) scale(0.6) rotate(-8deg);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -18px) scale(1.06) rotate(4deg);
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx, 0px)), -96px) scale(0.88) rotate(10deg);
  }
}
