/* ── UI Patch — brighter text + footer + share ─────────────────────────────────
   Drop this after main.css. Overrides only what needs changing.
   ──────────────────────────────────────────────────────────────────────────── */

/* Boost base text brightness + readability across the board */
:root {
  --text:       #F7F2E6;   /* near-white warm — primary text must pop */
  --text-dim:   #D4C9A8;   /* was #9A8E78 — now clearly readable */
  --text-faint: #9A8E78;   /* was #5A5244 — labels visible without squinting */
  --gold:       #D4AC52;   /* slightly brighter gold */
  --gold-light: #F0D080;   /* more luminous */
  --gold-dim:   #A07830;   /* warmer, more visible */
}

/* Switch body text from italic serif to clean sans-serif for readability */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ══════════════════════════════════════════════════════════════════════════════
   LANDING PAGE
   ══════════════════════════════════════════════════════════════════════════════ */

@import url('https://unpkg.com/@fontsource/bebas-neue@5.0.0/index.css');

.landing {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: #080808;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.landing-container {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: landingAppear 1.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  opacity: 0;
}

@keyframes landingAppear {
  0%   { opacity: 0; transform: scale(0.92) translateY(12px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.landing-mark {
  position: relative;
  width: 280px;
  height: 280px;
}
.landing-mark svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* Keys spin with accelerating easing */
.landing-keys {
  animation: landingSpin 8s cubic-bezier(0.2, 0, 0.8, 1) infinite;
  transform-origin: center;
}

@keyframes landingSpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.landing-wordmark {
  font-family: 'Bebas Neue', Impact, 'Arial Black', sans-serif;
  font-size: clamp(72px, 18vw, 108px);
  color: #EDD040;
  letter-spacing: 10px;
  line-height: 1;
  margin-top: 10px;
  text-shadow: 0 0 40px rgba(237,208,64,.15);
}

.landing-divider {
  width: 260px;
  height: 1px;
  background: #1A1A12;
  margin: 14px auto;
}

.landing-tagline {
  font-family: 'Courier New', Courier, monospace;
  font-size: 10px;
  color: #A09878;
  letter-spacing: 5px;
  text-transform: uppercase;
  margin-bottom: 2rem;
}

.landing-enter {
  font-family: 'Cinzel', serif;
  font-size: 14px;
  letter-spacing: .12em;
  padding: 14px 36px;
  background: rgba(237,208,64,.08);
  border: 1px solid #EDD040;
  color: #EDD040;
  border-radius: 4px;
  cursor: pointer;
  min-height: 48px;
  transition: all .3s;
  animation: enterPulse 3s ease-in-out infinite;
}
.landing-enter:hover {
  background: rgba(237,208,64,.18);
  text-shadow: 0 0 12px rgba(237,208,64,.4);
  box-shadow: 0 0 20px rgba(237,208,64,.15);
}

@keyframes enterPulse {
  0%, 100% { box-shadow: 0 0 0 rgba(237,208,64,0); }
  50%      { box-shadow: 0 0 16px rgba(237,208,64,.12); }
}

/* Exit animation — zoom + fade */
.landing.landing-exit {
  animation: landingExit .6s ease-in forwards;
}
@keyframes landingExit {
  0%   { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.1); }
}

/* Accelerating spin — starts slow, gets faster */
.landing-keys {
  animation: landingAccelSpin 12s ease-in infinite;
}
@keyframes landingAccelSpin {
  0%   { transform: rotate(0deg); }
  25%  { transform: rotate(30deg); }
  50%  { transform: rotate(90deg); }
  75%  { transform: rotate(210deg); }
  100% { transform: rotate(360deg); }
}

/* Mobile landing */
@media (max-width: 480px) {
  .landing-mark { width: 200px; height: 200px; }
  .landing-enter { font-size: 12px; padding: 12px 28px; }
}

/* Logo */
.logo {
  display: flex;
  justify-content: center;
  margin-bottom: .8rem;
}
.logo-img {
  width: 64px;
  height: auto;
}

/* Bolder headings */
h1 {
  font-size: 23px;
  font-weight: 600;
  letter-spacing: .12em;
  color: var(--gold-light);
  text-shadow: 0 0 40px rgba(240,208,128,.15);
}

.subtitle {
  font-size: 15px;
  color: var(--text-dim);
}

/* World description — most important text in the game */
.world-desc {
  font-size: 16px;
  line-height: 1.85;
  color: var(--text);
  font-weight: 400;
  font-style: normal;
}

/* World era badge — more visible */
.world-era-badge {
  font-size: 11px;
  letter-spacing: .16em;
  color: var(--gold);
  border-color: rgba(212,172,82,.45);
  padding: 3px 10px;
}

/* Wish text in storyboard */
.wish-txt {
  font-size: 15px;
  font-style: normal;
  color: var(--text-dim);
}

/* Genie reply text */
.genie-reply {
  font-size: 15px;
  font-style: normal;
  line-height: 1.85;
  color: var(--text);
  border-left-color: var(--gold-dim);
}

/* Ripple tag */
.ripple-tag {
  font-size: 12px;
  color: var(--gold);
  border-color: rgba(212,172,82,.45);
}

/* Physics text — should be readable, not ghostly */
.world-physics-text {
  font-size: 14px;
  font-style: normal;
  color: var(--text-dim);
  line-height: 1.75;
}

/* Physics label */
.world-physics-label {
  font-size: 10px;
  color: var(--text-faint);
}

/* Chaos status line */
.chaos-status {
  font-size: 14px;
  font-style: normal;
  color: var(--gold);
}

/* Collapse reading */
.collapse-reading {
  font-size: 14px;
  font-style: normal;
  color: var(--text-dim);
}

/* Echo items */
.echo-item {
  font-size: 14px;
  font-style: normal;
  color: var(--gold);
}

/* Butterfly effect labels */
.b-label {
  font-size: 11px;
  color: var(--text-faint);
}
.wish-count {
  font-size: 12px;
  color: var(--text-faint);
}

/* Form label */
.form-label {
  font-size: 11px;
  color: var(--text-faint);
}

/* Collapse labels */
.collapse-label {
  font-size: 10px;
  color: var(--text-faint);
}

/* Subtitle — keep italic but readable */
.subtitle {
  font-style: italic;
  font-size: 15px;
  color: var(--text-dim);
}

/* Sign-in gate text */
.signin-gate-text {
  font-style: normal;
  font-size: 15px;
  color: var(--text-dim);
}

/* Textarea placeholder — more visible */
textarea::placeholder { color: var(--text-faint); font-style: italic; }
textarea { font-size: 17px; color: var(--text); }

/* Button text brighter */
button {
  color: var(--gold);
  border-color: var(--gold);
  font-size: 12px;
}

/* Graph header label — BUTTERFLY NETWORK must be visible */
.graph-hdr {
  font-size: 12px;
  font-weight: 600;
  color: var(--gold-light);
  letter-spacing: .15em;
  text-shadow: 0 0 14px rgba(212,172,82,.4);
}
.legend-item { font-size: 12px; color: var(--text-dim); }

/* Zoom / nav controls on right side of graph */
#ng-zoom-in, #ng-zoom-out, #ng-fit {
  color: var(--gold) !important;
  border-color: var(--gold-dim) !important;
  background: rgba(26,22,38,.85) !important;
  text-shadow: 0 0 8px rgba(212,172,82,.25);
}
#ng-zoom-in:hover, #ng-zoom-out:hover, #ng-fit:hover {
  background: rgba(201,168,76,.12) !important;
  border-color: var(--gold) !important;
}

/* ── Footer ─────────────────────────────────────────────────────────────────── */

.root {
  grid-template-rows: 1fr auto;   /* add row for footer */
  grid-template-columns: minmax(320px, 400px) 1fr;
  transition: grid-template-columns .3s ease;
}
@media (max-width: 860px) {
  .root { grid-template-rows: 55vh 40vh auto; }
}

.footer {
  grid-column: 1 / -1;
  border-top: 1px solid rgba(122,94,40,.3);
  background: rgba(13,11,20,.92);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  height: 38px;
  z-index: 10;
  gap: 0;
}

/* Each direct child gets equal spacing via auto margins */
.footer > * {
  flex-shrink: 0;
}

.footer-stat {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: 'Cinzel', serif;
  font-size: 11px;
  letter-spacing: .1em;
  color: var(--text-dim);
  white-space: nowrap;
}

.footer-stat-num {
  color: var(--gold-light);
  font-weight: 600;
  font-size: 12px;
  min-width: 16px;
  text-align: right;
  text-shadow: 0 0 10px rgba(240,208,128,.35);
  transition: color .3s, text-shadow .3s;
}

.footer-stat-num.bump {
  color: #FFF;
  text-shadow: 0 0 14px rgba(240,208,128,.6);
}

.footer-dot-human {
  width: 7px; height: 7px; border-radius: 50%;
  background: #D4AC52; flex-shrink: 0;
  box-shadow: 0 0 6px rgba(212,172,82,.5);
}
.footer-dot-agent {
  width: 7px; height: 7px; border-radius: 50%;
  background: #5AA0C0; flex-shrink: 0;
  box-shadow: 0 0 6px rgba(74,141,171,.5);
}
.footer-dot-live {
  width: 7px; height: 7px; border-radius: 50%;
  background: #5CDB95;
  box-shadow: 0 0 8px rgba(92,219,149,.5);
  animation: footerpulse 2s ease infinite;
  flex-shrink: 0;
}
@keyframes footerpulse { 0%,100%{opacity:1} 50%{opacity:.3} }

.footer-divider {
  width: 1px; height: 16px;
  background: rgba(122,94,40,.3);
  flex-shrink: 0;
  margin: 0 clamp(.5rem, 1.5vw, 1.25rem); /* evenly space based on viewport */
}

/* Ticker fills remaining space */
.footer-ticker {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
}

.footer-ticker-inner {
  font-size: 11px;
  font-style: italic;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity .4s;
}

.footer-ticker-inner .ticker-name {
  color: var(--text-dim);
  font-style: normal;
  font-family: 'Cinzel', serif;
  font-size: 9px;
  letter-spacing: .08em;
}

.footer-ticker-inner .ticker-wish {
  color: var(--text-faint);
}

/* Social link */
.footer-social {
  flex-shrink: 0;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  transition: color .2s;
}
.footer-social:hover {
  color: var(--gold);
}

/* Share button */
.footer-share {
  flex-shrink: 0;
  font-family: 'Cinzel', serif;
  font-size: 10px;
  letter-spacing: .08em;
  padding: 4px 10px;
  background: rgba(26,22,38,.6);
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  border-radius: 2px;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
  min-height: auto;
}
.footer-share:hover {
  border-color: var(--gold);
  color: var(--gold-light);
  background: rgba(201,168,76,.1);
}

/* Toast notification for copy feedback */
.copy-toast {
  position: fixed;
  bottom: 48px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--ink-mid);
  border: 1px solid var(--gold-dim);
  border-radius: 4px;
  padding: 7px 16px;
  font-family: 'Cinzel', serif;
  font-size: 11px;
  letter-spacing: .08em;
  color: var(--gold);
  z-index: 100;
  opacity: 0;
  transition: opacity .25s, transform .25s;
  pointer-events: none;
}
.copy-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Era age in header ──────────────────────────────────────────────────────── */
.world-era-age {
  font-size: 10px;
  color: var(--text-faint);
  font-style: italic;
}

/* ══════════════════════════════════════════════════════════════════════════════
   PANEL COLLAPSE / EXPAND TOGGLE
   ══════════════════════════════════════════════════════════════════════════════ */

.panel-toggle {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 15;
  width: 32px;
  height: 32px;
  min-height: auto;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink-mid);
  border: 1px solid var(--gold-dim);
  border-radius: 4px;
  color: var(--gold);
  cursor: pointer;
  transition: all .3s ease;
}
.panel-toggle:hover {
  background: rgba(201,168,76,.1);
  border-color: var(--gold);
}
.panel-toggle svg {
  transition: transform .3s ease;
}

/* Storyboard needs relative positioning for the toggle button */
.storyboard {
  position: relative;
}

/* ── Collapsed state (desktop) ───────────────────────────────────────────── */
.root.panel-collapsed {
  grid-template-columns: 48px 1fr;
}
.root.panel-collapsed .storyboard {
  overflow: hidden;
  padding: 12px 8px;
}
.root.panel-collapsed .storyboard > *:not(.panel-toggle) {
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.root.panel-collapsed .panel-toggle {
  position: static;
  margin: 0 auto;
}
.root.panel-collapsed .panel-toggle svg {
  transform: rotate(180deg);
}

/* ══════════════════════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE
   ══════════════════════════════════════════════════════════════════════════════ */

/* Ensure proper viewport behaviour on mobile */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* ── Tablet (≤860px): stack panels vertically ─────────────────────────────── */
@media (max-width: 860px) {
  .root {
    grid-template-columns: 1fr !important; /* override collapsed state too */
    grid-template-rows: auto 1fr auto;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  /* Hide collapse toggle on mobile — use scroll instead */
  .panel-toggle { display: none; }

  .storyboard {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1.5rem 1.25rem 2rem;
    border-right: none;
    border-bottom: 1px solid rgba(122,94,40,.35);
    max-height: 55vh;
    max-height: 55dvh;
  }

  .graph-panel {
    min-height: 180px;
  }

  /* Footer: single row, tighter spacing */
  .footer {
    height: 38px;
    padding: 0 .75rem;
  }
  .footer-divider {
    margin: 0 .4rem;
  }
}

/* ── Phone (≤480px): optimized for small screens ──────────────────────────── */
@media (max-width: 480px) {
  .root {
    grid-template-rows: auto 1fr auto;
    height: 100dvh;
  }

  .storyboard {
    padding: 1.25rem 1rem 1.5rem;
    max-height: 60vh;
    max-height: 60dvh;
  }

  /* Title smaller on phone */
  h1 {
    font-size: 19px;
    letter-spacing: .08em;
  }
  .subtitle {
    font-size: 13px;
    margin-bottom: 1rem;
  }

  /* Lamp icon smaller */
  .lamp svg {
    width: 30px;
    height: 30px;
  }

  /* World panel tighter */
  .world-panel {
    padding: .9rem;
    margin-bottom: 1rem;
  }
  .world-desc {
    font-size: 14px;
    line-height: 1.7;
  }

  /* Physics text */
  .world-physics-text {
    font-size: 13px;
  }

  /* Dots smaller */
  .dots { gap: 8px; margin-bottom: 1rem; }
  .dot { width: 24px; height: 24px; font-size: 10px; }

  /* Wish form — larger touch targets */
  textarea {
    font-size: 16px; /* prevents iOS zoom on focus */
    min-height: 70px;
    padding: 12px;
    border-radius: 6px;
  }
  button {
    font-size: 12px;
    padding: 10px 20px;
    min-height: 44px; /* iOS minimum touch target */
    border-radius: 4px;
  }

  /* Auth button touch-friendly */
  .auth-signin-btn {
    min-height: 44px;
    font-size: 12px;
    border-radius: 6px;
  }
  .auth-user {
    min-height: 44px;
    padding: 8px 12px;
    border-radius: 6px;
  }

  /* Wish log entries */
  .wish-entry { margin-bottom: 1.25rem; }
  .genie-reply {
    padding: .6rem .75rem;
    font-size: 14px;
    line-height: 1.75;
  }

  /* Graph controls — bigger touch targets */
  #ng-zoom-in, #ng-zoom-out, #ng-fit {
    width: 36px !important;
    height: 36px !important;
    font-size: 18px !important;
    min-height: 44px;
  }

  /* Graph header */
  .graph-hdr {
    font-size: 10px;
    top: 8px; left: 10px;
  }
  .graph-legend {
    bottom: 8px; left: 10px;
  }
  .legend-item { font-size: 11px; }

  /* Footer — compact on phone */
  .footer {
    padding: 0 .5rem;
    height: 36px;
  }
  .footer-divider {
    margin: 0 .25rem;
    height: 12px;
  }
  .footer-stat {
    font-size: 9px;
    gap: 3px;
  }
  .footer-stat-num {
    font-size: 10px;
    min-width: 12px;
  }
  .footer-ticker-inner {
    font-size: 10px;
  }
  .footer-share {
    font-size: 9px;
    padding: 3px 6px;
  }

  /* Sign-in gate */
  .signin-gate {
    padding: 1.5rem 1rem;
  }
  .signin-gate-icon {
    width: 44px; height: 44px;
  }
  .signin-gate-text {
    font-size: 14px;
  }

  /* Done panel */
  .done-panel {
    padding: 1.25rem 1rem;
  }
  .done-panel h2 { font-size: 15px; }
  .done-panel p { font-size: 13px; }

  /* Era collapse */
  .era-collapse-notice { padding: 1rem; }
  .era-collapse-reason { font-size: 13px; }

  /* Wishes exhausted */
  .wishes-exhausted { padding: 1.25rem; }
  .exhausted-title { font-size: 13px; }
  .exhausted-sub { font-size: 12px; }
}

/* ── Very small phones (≤360px) ───────────────────────────────────────────── */
@media (max-width: 360px) {
  .storyboard {
    padding: 1rem .75rem 1.25rem;
  }
  h1 { font-size: 17px; }
  .world-desc { font-size: 13px; }
  .footer-ticker { display: none; }
}

/* ── Landscape phone ──────────────────────────────────────────────────────── */
@media (max-width: 860px) and (max-height: 500px) and (orientation: landscape) {
  .root {
    grid-template-columns: 1fr 1fr !important;
    grid-template-rows: 1fr auto;
    height: 100dvh;
  }
  .storyboard {
    max-height: none;
    border-right: 1px solid rgba(122,94,40,.35);
    border-bottom: none;
  }
  .footer {
    grid-column: 1 / -1;
    height: 32px;
  }
}

/* ── Safe areas for notched phones (iPhone X+) ────────────────────────────── */
@supports (padding: env(safe-area-inset-bottom)) {
  .footer {
    padding-bottom: max(5px, env(safe-area-inset-bottom));
    padding-left: calc(.75rem + env(safe-area-inset-left));
    padding-right: calc(.75rem + env(safe-area-inset-right));
  }
  .storyboard {
    padding-left: calc(1rem + env(safe-area-inset-left));
    padding-right: calc(1rem + env(safe-area-inset-right));
  }
}

/* ══════════════════════════════════════════════════════════════════════════════
   PANEL TABS — Wishes / Profile / Settings
   ══════════════════════════════════════════════════════════════════════════════ */

.panel-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid rgba(122,94,40,.25);
}

.panel-tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-family: 'Cinzel', serif;
  font-size: 11px;
  letter-spacing: .1em;
  color: var(--text-faint);
  padding: 8px 0 10px;
  cursor: pointer;
  min-height: auto;
  transition: all .2s;
}
.panel-tab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}
.panel-tab:hover:not(.active) {
  color: var(--text-dim);
}

.tab-content {
  animation: fadeIn .25s ease;
}

.profile-tab-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-faint);
  font-size: 14px;
}

.profile-tab-content {
  padding: .25rem 0;
}

/* ══════════════════════════════════════════════════════════════════════════════
   KEY PANEL — user-provided API key
   ══════════════════════════════════════════════════════════════════════════════ */

.key-panel {
  border: 1px solid rgba(122,94,40,.35);
  border-radius: 4px;
  padding: .75rem .9rem;
  margin-bottom: 1.25rem;
  background: var(--ink-mid);
  position: relative;
}
.key-panel::before {
  content: 'API Key';
  position: absolute;
  top: -9px; left: 14px;
  background: var(--ink-mid);
  padding: 0 6px;
  font-family: 'Cinzel', serif;
  font-size: 10px;
  letter-spacing: .12em;
  color: var(--gold-dim);
}

.key-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.key-active {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #80c880;
}

.key-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #5CDB95;
  box-shadow: 0 0 6px rgba(92,219,149,.5);
}

.key-inactive {
  font-size: 12px;
  color: var(--text-faint);
}

.key-masked {
  font-size: 11px;
  color: var(--text-faint);
  font-family: monospace;
  margin-bottom: 6px;
}

.key-row {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
}

.key-input {
  flex: 1;
  background: var(--ink);
  border: 1px solid rgba(122,94,40,.4);
  border-radius: 3px;
  padding: 8px 10px;
  font-family: monospace;
  font-size: 13px;
  color: var(--text);
}
.key-input::placeholder { color: var(--text-faint); }
.key-input:focus { outline: none; border-color: var(--gold); }

.key-save {
  padding: 6px 14px;
  font-family: 'Cinzel', serif;
  font-size: 10px;
  letter-spacing: .08em;
  background: rgba(201,168,76,.08);
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  border-radius: 3px;
  cursor: pointer;
  min-height: auto;
}
.key-save:hover { background: rgba(201,168,76,.15); }

.key-remove-btn {
  padding: 3px 10px;
  font-family: 'Cinzel', serif;
  font-size: 9px;
  letter-spacing: .08em;
  background: transparent;
  border: 1px solid rgba(180,40,40,.3);
  color: #c87070;
  border-radius: 3px;
  cursor: pointer;
  min-height: auto;
}
.key-remove-btn:hover { background: rgba(180,40,40,.1); }

.key-note {
  font-size: 11px;
  color: var(--text-faint);
  line-height: 1.5;
}
.key-note a {
  color: var(--gold-dim);
  text-decoration: none;
}
.key-note a:hover { color: var(--gold); }

/* ══════════════════════════════════════════════════════════════════════════════
   AUTH MODAL + PROFILE PANEL
   ══════════════════════════════════════════════════════════════════════════════ */

.auth-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn .2s ease;
}

.auth-modal {
  background: var(--ink-mid);
  border: 1px solid var(--gold-dim);
  border-radius: 8px;
  padding: 2rem 1.75rem;
  width: 90%;
  max-width: 380px;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

.auth-modal-close {
  position: absolute;
  top: 10px; right: 12px;
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 22px;
  cursor: pointer;
  width: auto; height: auto;
  min-height: auto;
  padding: 4px 8px;
  line-height: 1;
}
.auth-modal-close:hover { color: var(--text); }

.auth-modal-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid rgba(122,94,40,.3);
}

.auth-tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-family: 'Cinzel', serif;
  font-size: 12px;
  letter-spacing: .1em;
  color: var(--text-faint);
  padding: 8px 0 10px;
  cursor: pointer;
  min-height: auto;
  transition: all .2s;
}
.auth-tab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}
.auth-tab:hover { color: var(--text-dim); }

.auth-label {
  display: block;
  font-family: 'Cinzel', serif;
  font-size: 10px;
  letter-spacing: .1em;
  color: var(--text-faint);
  margin-bottom: 5px;
  margin-top: 12px;
}
.auth-label:first-of-type { margin-top: 0; }

.auth-input {
  width: 100%;
  background: var(--ink);
  border: 1px solid rgba(122,94,40,.4);
  border-radius: 4px;
  padding: 10px 12px;
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  color: var(--text);
  transition: border-color .2s;
}
.auth-input::placeholder { color: var(--text-faint); }
.auth-input:focus { outline: none; border-color: var(--gold); }
.auth-input:disabled { opacity: .5; cursor: not-allowed; }

.auth-error {
  color: #e08080;
  font-size: 13px;
  margin-top: 8px;
  min-height: 18px;
}

.auth-submit-btn {
  width: 100%;
  margin-top: 16px;
  padding: 11px;
  background: rgba(201,168,76,.1);
  border: 1px solid var(--gold);
  border-radius: 4px;
  color: var(--gold);
  font-family: 'Cinzel', serif;
  font-size: 12px;
  letter-spacing: .08em;
  cursor: pointer;
  min-height: 44px;
  transition: all .2s;
}
.auth-submit-btn:hover {
  background: rgba(201,168,76,.18);
  color: var(--gold-light);
}

.auth-divider {
  display: flex;
  align-items: center;
  margin: 16px 0;
  gap: 12px;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(122,94,40,.3);
}
.auth-divider span {
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: .1em;
}

.auth-google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  background: var(--ink);
  border: 1px solid rgba(122,94,40,.35);
  border-radius: 4px;
  color: var(--text-dim);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  text-decoration: none;
  min-height: 44px;
  transition: all .2s;
}
.auth-google-btn:hover {
  border-color: var(--gold-dim);
  color: var(--text);
}

/* ── Auth in Profile tab ──────────────────────────────────────────────────── */

.auth-tab-logged-out {
  text-align: center;
  padding: .5rem 0 1rem;
}
.auth-tab-prompt {
  font-size: 13px;
  color: var(--text-faint);
  margin-bottom: 8px;
}

.auth-tab-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: .5rem 0 1rem;
  border-bottom: 1px solid rgba(122,94,40,.2);
  margin-bottom: 1rem;
}
.auth-tab-user-name {
  font-size: 15px;
  color: var(--text);
  font-weight: 500;
}
.auth-tab-user-email {
  font-size: 12px;
  color: var(--text-faint);
}

/* ── Auth dropdown additions ──────────────────────────────────────────────── */

.auth-dropdown-link {
  display: block;
  font-family: 'Cinzel', serif;
  font-size: 10px;
  letter-spacing: .08em;
  color: var(--gold-dim);
  text-decoration: none;
  padding: 6px 0;
  transition: color .2s;
}
.auth-dropdown-link:hover { color: var(--gold); }

/* ── Profile Panel ────────────────────────────────────────────────────────── */

.profile-modal { max-width: 400px; }

.profile-title {
  font-family: 'Cinzel', serif;
  font-size: 16px;
  font-weight: 400;
  letter-spacing: .1em;
  color: var(--gold-light);
  margin-bottom: 1.25rem;
  text-align: center;
}

.profile-avatar-area {
  display: flex;
  justify-content: center;
  margin-bottom: .75rem;
  position: relative;
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
}

.profile-avatar-img, .profile-avatar-placeholder {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
}

.profile-avatar-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gold-dim);
  color: var(--ink);
  font-family: 'Cinzel', serif;
  font-size: 28px;
  font-weight: 600;
}

.profile-avatar-upload-btn {
  position: absolute;
  bottom: 0; right: 0;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--ink-mid);
  border: 1px solid var(--gold-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  cursor: pointer;
  transition: all .2s;
}
.profile-avatar-upload-btn:hover {
  background: rgba(201,168,76,.15);
  border-color: var(--gold);
}

.profile-avatar-status, .profile-name-status {
  text-align: center;
  font-size: 12px;
  min-height: 18px;
  margin-bottom: 4px;
  color: var(--text-faint);
}
.profile-avatar-status.success, .profile-name-status.success { color: #80c880; }
.profile-avatar-status.error, .profile-name-status.error { color: #e08080; }

.profile-name-row {
  display: flex;
  gap: 8px;
}
.profile-name-row .auth-input { flex: 1; }

.profile-save-btn {
  font-family: 'Cinzel', serif;
  font-size: 10px;
  letter-spacing: .08em;
  padding: 8px 14px;
  min-height: auto;
  background: transparent;
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}
.profile-save-btn:hover { background: rgba(201,168,76,.1); }

/* ── Cluster node image ────────────────────────────────────────────────────── */

.profile-cluster-hint {
  font-size: 12px;
  color: var(--text-faint);
  margin-bottom: 10px;
  line-height: 1.5;
}

.profile-cluster-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.profile-cluster-preview {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid var(--gold-dim);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  flex-shrink: 0;
}

.profile-cluster-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-cluster-empty {
  font-size: 9px;
  color: var(--text-faint);
  text-align: center;
}

.profile-cluster-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.profile-cluster-status {
  font-size: 12px;
  min-height: 16px;
  margin-top: 4px;
  margin-bottom: 8px;
  color: var(--text-faint);
}
.profile-cluster-status.success { color: #80c880; }
.profile-cluster-status.error { color: #e08080; }

.profile-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(122,94,40,.2);
}

.profile-signout-btn {
  display: block;
  text-align: center;
  margin-top: 16px;
  padding: 10px;
  background: transparent;
  border: 1px solid rgba(122,94,40,.35);
  border-radius: 4px;
  color: var(--text-dim);
  font-family: 'Cinzel', serif;
  font-size: 11px;
  letter-spacing: .08em;
  text-decoration: none;
  transition: all .2s;
}
.profile-signout-btn:hover {
  border-color: var(--text-faint);
  color: var(--text);
}

.profile-danger-zone {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(180,40,40,.2);
}

.profile-delete-btn {
  width: 100%;
  padding: 10px;
  background: rgba(180,40,40,.08);
  border: 1px solid rgba(180,40,40,.35);
  border-radius: 4px;
  color: #c87070;
  font-family: 'Cinzel', serif;
  font-size: 11px;
  letter-spacing: .08em;
  cursor: pointer;
  min-height: auto;
  transition: all .2s;
}
.profile-delete-btn:hover {
  background: rgba(180,40,40,.15);
  color: #e08080;
}

.profile-confirm-dialog {
  margin-top: 12px;
  padding: 12px;
  background: rgba(180,40,40,.06);
  border: 1px solid rgba(180,40,40,.25);
  border-radius: 4px;
}
.profile-confirm-dialog p {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 10px;
  line-height: 1.5;
}

.profile-confirm-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.profile-cancel-btn {
  flex: 1;
  padding: 8px;
  background: transparent;
  border: 1px solid rgba(122,94,40,.35);
  border-radius: 4px;
  color: var(--text-dim);
  font-family: 'Cinzel', serif;
  font-size: 10px;
  letter-spacing: .08em;
  cursor: pointer;
  min-height: auto;
}

.profile-delete-confirm-btn {
  flex: 1;
  padding: 8px;
  background: rgba(180,40,40,.15);
  border: 1px solid rgba(180,40,40,.4);
  border-radius: 4px;
  color: #e08080;
  font-family: 'Cinzel', serif;
  font-size: 10px;
  letter-spacing: .08em;
  cursor: pointer;
  min-height: auto;
}
.profile-delete-confirm-btn:hover {
  background: rgba(180,40,40,.25);
}

/* ── Mobile adjustments for auth/profile ──────────────────────────────────── */
@media (max-width: 480px) {
  .auth-modal {
    width: 95%;
    padding: 1.5rem 1.25rem;
    max-height: 85vh;
  }
}
