/* ═══════════════════════════════════════════════════════════════════
   OSRS Assistant — Design System
   Standardized tokens, components, and utilities.
   ═══════════════════════════════════════════════════════════════════ */

/* ─── Design Tokens ───────────────────────────────────────────────── */
:root {
  color-scheme: dark;
  /* Colors */
  --bg-dark: #1a1410;
  --bg-panel: #231e17;
  --bg-card: #2a231b;
  --bg-input: #1a1410;
  --bg-hover: #2e2720;
  --border: #3d3226;
  --border-light: #4a3d2e;
  --gold: #c8aa6e;
  --gold-bright: #f0d678;
  --gold-dim: #8b7648;
  --text: #c4b998;
  --text-dim: #7a6f5a;
  --text-bright: #e8dcc8;
  --green: #4caf50;
  --green-dim: #2d5a2f;
  --red: #d45050;
  --red-dim: #5a2d2d;
  --orange: #e89830;
  --blue: #5090d0;
  --blue-dim: #1a2a3a;

  /* Spacing scale */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;

  /* Typography */
  --font-body: 'Inter', sans-serif;
  --font-heading: 'Cinzel', serif;
  --fs-xs: 10px;
  --fs-sm: 11px;
  --fs-md: 12px;
  --fs-base: 13px;
  --fs-lg: 14px;
  --fs-xl: 16px;
  --fs-2xl: 18px;
  --fs-3xl: 22px;

  /* Border radius */
  --radius-sm: 3px;
  --radius-md: 4px;
  --radius-lg: 6px;
  --radius-xl: 8px;
  --radius-2xl: 10px;
  --radius-round: 50%;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.6);
  --shadow-xl: 0 16px 48px rgba(0,0,0,0.6);

  /* Transitions */
  --transition-fast: 0.1s ease;
  --transition-base: 0.15s ease;
  --transition-slow: 0.2s ease;
}

/* ─── Reset ───────────────────────────────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--bg-dark); }
body { font-family: var(--font-body); background: var(--bg-dark); color: var(--text); }

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--radius-md); }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dim); }

h1, h2, h3, h4 { font-family: var(--font-heading); }

/* ─── Buttons ─────────────────────────────────────────────────────── */
/* Base button — all buttons inherit this */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  font-family: var(--font-body);
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: all var(--transition-base);
  white-space: nowrap;
  line-height: 1;
}
.btn:hover { filter: brightness(1.1); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; filter: none; }

/* Size variants */
.btn-xs  { padding: 2px 6px;   font-size: var(--fs-xs); }
.btn-sm  { padding: 4px 10px;  font-size: var(--fs-sm); }
.btn-md  { padding: 6px 14px;  font-size: var(--fs-md); }
.btn-lg  { padding: 8px 18px;  font-size: var(--fs-base); }
.btn-xl  { padding: 10px 24px; font-size: var(--fs-lg); }

/* Color variants */
.btn-gold {
  background: linear-gradient(180deg, #c8aa6e 0%, #a08040 100%);
  color: var(--bg-dark); border-color: #a08040;
}
.btn-gold:hover { background: linear-gradient(180deg, #d4b878 0%, #b09050 100%); }

.btn-ghost {
  background: transparent; color: var(--text-dim); border-color: var(--border);
}
.btn-ghost:hover { color: var(--gold); border-color: var(--gold-dim); }

.btn-danger { background: var(--red-dim); color: var(--red); border-color: #6a3535; }
.btn-success { background: var(--green-dim); color: var(--green); border-color: #3a6a3a; }
.btn-orange {
  background: linear-gradient(180deg, #e89830 0%, #c07020 100%);
  color: var(--bg-dark); border-color: #c07020; font-weight: 700;
}
.btn-outline {
  background: var(--bg-dark); color: var(--text); border-color: var(--border);
}
.btn-outline:hover { border-color: var(--gold-dim); color: var(--gold); }
.btn-outline-warn {
  background: var(--bg-dark); color: var(--orange); border-color: var(--orange);
}

/* Icon-only button */
.btn-icon {
  padding: var(--sp-1); min-width: 28px; min-height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
}

/* ─── Inputs ──────────────────────────────────────────────────────── */
.input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-body);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-slow);
}
.input:focus { outline: none; border-color: var(--gold-dim); }

.input-xs  { padding: 3px 6px;   font-size: var(--fs-xs); }
.input-sm  { padding: 4px 8px;   font-size: var(--fs-sm); }
.input-md  { padding: 6px 10px;  font-size: var(--fs-md); }
.input-lg  { padding: 8px 12px;  font-size: var(--fs-base); }
.input-xl  { padding: 10px 16px; font-size: var(--fs-lg); }

/* ─── Cards & Panels ──────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--sp-4) var(--sp-5);
}

.card-header {
  color: var(--gold);
  font-family: var(--font-heading);
  font-size: var(--fs-lg);
  font-weight: 700;
  margin-bottom: var(--sp-2);
}

.card-desc {
  font-size: var(--fs-sm);
  color: var(--text-dim);
  margin-bottom: var(--sp-2);
  line-height: 1.5;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-2) var(--sp-3);
  box-shadow: var(--shadow-md);
}

/* Floating panel (map overlays, tooltips) */
.floating-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

/* ─── Labels & Badges ─────────────────────────────────────────────── */
.label {
  font-size: var(--fs-xs);
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-dim);
}

.badge-gold { color: var(--gold); }
.badge-green { background: var(--green-dim); border-color: #3a6a3a; color: var(--green); }
.badge-red { background: var(--red-dim); border-color: #6a3535; color: var(--red); }
.badge-orange { background: #3d3020; border-color: #6a5a2a; color: var(--orange); }
.badge-blue { background: var(--blue-dim); border-color: #2a5a8a; color: #6ab4ff; }

/* ─── Progress Bar ────────────────────────────────────────────────── */
.progress {
  height: 8px;
  background: var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  flex: 1;
}
.progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: var(--radius-md);
  transition: width 0.3s;
}

.progress-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}

.progress-pct {
  font-size: var(--fs-md);
  color: var(--gold);
  font-weight: 600;
  min-width: 40px;
}

/* ─── Stats Grid ──────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  color: var(--text-dim);
}

/* ─── Toolbar ─────────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
  margin-bottom: var(--sp-3);
  flex-wrap: wrap;
}

/* ─── Dropdown / Popover ──────────────────────────────────────────── */
.dropdown {
  position: absolute;
  top: calc(100% + var(--sp-1));
  left: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-2);
  box-shadow: var(--shadow-lg);
  z-index: 1002;
  min-width: 150px;
}

.dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 6px;
  font-size: var(--fs-xs);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-body);
  font-weight: 600;
}
.dropdown-item:hover { background: var(--bg-card); }

.dropdown-divider {
  border-top: 1px solid var(--border);
  margin: var(--sp-1) 0;
}

/* ─── Status Text ─────────────────────────────────────────────────── */
.status      { font-size: var(--fs-md); color: var(--text-dim); }
.status-ok   { color: var(--green); }
.status-warn { color: var(--orange); }
.status-err  { color: var(--red); }

/* ─── Detail Text ─────────────────────────────────────────────────── */
.detail { font-size: var(--fs-sm); color: var(--text-dim); }

/* ─── Layout Utilities ────────────────────────────────────────────── */
.flex        { display: flex; }
.flex-col    { display: flex; flex-direction: column; }
.flex-wrap   { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.flex-1 { flex: 1; }
.w-full { width: 100%; }
.mb-1 { margin-bottom: var(--sp-1); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); }
.mt-auto { margin-top: auto; }
.ml-auto { margin-left: auto; }
.relative { position: relative; }
.text-right { text-align: right; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none; }

/* ─── Key / Monospace ─────────────────────────────────────────────── */
.mono {
  font-family: 'Courier New', monospace;
  font-size: var(--fs-sm);
  color: var(--gold-dim);
  background: var(--bg-dark);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

/* ─── GP / Currency ───────────────────────────────────────────────── */
.gp { color: var(--gold-bright); font-weight: 600; }
.positive { color: var(--green); }
.negative { color: var(--red); }

/* ─── Progression Sub-tabs ─────────────────────────────────────────── */
.prog-subtab { display: none; }
.prog-subtab.active { display: block; }

/* ─── Tier Gating ─────────────────────────────────────────────────── */
.rail-lock {
  pointer-events: none;
}

/* ─── Scroll Animations ───────────────────────────────────────────── */
.fade-in {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* FAQ details styling */
details summary {
  list-style: none;
}
details summary::-webkit-details-marker {
  display: none;
}
details summary::after {
  content: '+';
  float: right;
  font-size: 16px;
  color: var(--gold-dim);
  transition: transform 0.2s;
}
details[open] summary::after {
  content: '−';
}

/* ─── Landing Demo Dots ───────────────────────────────────────────── */
.landing-dot {
  animation: landingBlink 1s infinite;
  font-size: 18px;
}
.landing-dot:nth-child(2) { animation-delay: 0.2s; }
.landing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes landingBlink {
  0%, 50% { opacity: 0.3; }
  25% { opacity: 1; }
}

/* ─── Chat Feedback Buttons ────────────────────────────────────────── */
.chat-feedback {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}
/* ─── Chat Prompt Chips ───────────────────────────────────────────── */
.chat-prompt-chips {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 400px; margin: 0 auto;
}
.chat-prompt-chip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  text-align: left;
  line-height: 1.3;
}
.chat-prompt-chip:hover {
  border-color: var(--gold-dim);
  background: rgba(212,175,55,0.06);
  color: var(--text-bright);
}

.chat-fb-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 2px 8px;
  font-size: 12px;
  cursor: pointer;
  opacity: 0.4;
  transition: opacity 0.15s, border-color 0.15s;
}
.chat-fb-btn:hover {
  opacity: 1;
  border-color: var(--gold-dim);
}

/* ─── Feedback Message Boxes (Admin) ──────────────────────────────── */
.fb-msg-box { transition: max-height 0.2s ease; }
.fb-msg-box:not(.expanded)::after {
  content: 'click to expand';
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 24px; display: flex; align-items: flex-end; justify-content: center;
  font-size: 9px; color: var(--text-dim);
  background: linear-gradient(transparent, var(--bg-dark));
}
.fb-msg-box.expanded { max-height: none !important; overflow-y: auto; }

/* ─── Chat Scroll Button ──────────────────────────────────────────── */
.chat-scroll-btn {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-round);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--gold);
  font-size: 14px;
  cursor: pointer;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  transition: opacity var(--transition-base), transform var(--transition-base);
}
.chat-scroll-btn:hover {
  background: var(--bg-card);
  border-color: var(--gold-dim);
}
.chat-scroll-btn.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(10px);
}

/* ─── OSRS Skill Grid ─────────────────────────────────────────────── */
.skill-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  max-width: 480px;
  width: 100%;
  overflow: hidden;
}

@media (max-width: 600px) {
  .skill-grid {
    grid-template-columns: repeat(2, 1fr);
    max-width: 100%;
  }
}

.skill-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-height: 28px;
}
.skill-cell:hover { background: var(--bg-hover); border-color: var(--gold-dim); }
.skill-cell img { width: 18px; height: 18px; image-rendering: pixelated; }
.skill-cell .skill-name {
  font-size: var(--fs-xs);
  color: var(--text-dim);
  flex: 1;
}
.skill-cell .skill-level {
  font-size: var(--fs-md);
  font-weight: 700;
  min-width: 20px;
  text-align: right;
}
.skill-cell .skill-level.l99 { color: var(--gold-bright); }
.skill-cell .skill-level.l70 { color: var(--green); }
.skill-cell .skill-level.l40 { color: var(--text); }
.skill-cell .skill-level.l1  { color: var(--text-dim); }

/* ═══════════════════════════════════════════════════════════════════
   App Layout: Icon Rail + Tool Panel + Chat Panel
   ═══════════════════════════════════════════════════════════════════ */

/* ─── Top Bar (simplified) ────────────────────────────────────────── */
.app-topbar {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 8px var(--sp-6);
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  height: 48px;
  flex-shrink: 0;
}
.app-topbar .logo {
  display: flex; align-items: center; gap: var(--sp-2);
  font-family: var(--font-heading); color: var(--gold);
  font-size: var(--fs-xl); letter-spacing: 1px; font-weight: 700;
  flex-shrink: 0;
}
.app-topbar .logo img { width: 22px; height: 22px; border-radius: var(--radius-md); }
@media (max-width: 768px) {
  .app-topbar .logo span { display: none; }
}

/* ─── Global Search ───────────────────────────────────────────────── */
.global-search {
  position: relative;
  flex: 1;
  max-width: 420px;
  margin: 0 16px;
}
.global-search-input-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 10px;
  height: 32px;
  transition: border-color 0.15s;
}
.global-search-input-wrap:focus-within {
  border-color: var(--gold-dim);
}
.global-search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 12px;
  font-family: var(--font-body);
  min-width: 0;
}
.global-search-input::placeholder { color: var(--text-dim); }
.global-search-kbd {
  font-size: 10px;
  color: var(--text-dim);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  line-height: 1;
  font-family: var(--font-body);
}
.global-search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-height: 420px;
  overflow-y: auto;
  z-index: 200;
}
.gs-result {
  display: flex;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.gs-result:last-child { border-bottom: none; }
.gs-result:hover, .gs-result.active { background: rgba(212,175,55,0.06); }
.gs-result-title {
  font-size: 13px;
  color: var(--text-bright);
  font-weight: 600;
  margin-bottom: 2px;
}
.gs-result-meta {
  font-size: 10px;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.gs-result-snippet {
  font-size: 11px;
  color: var(--text);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.gs-actions {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}
.gs-empty {
  padding: 24px;
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
}

/* ─── Wiki Page Transition & Skeleton ─────────────────────────────── */
#wikiPageContent {
  transition: opacity 0.25s ease;
}
.wiki-skeleton {
  padding: 24px;
}
.wiki-sk-block {
  background: linear-gradient(90deg, var(--bg-card) 25%, rgba(212,175,55,0.04) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: wiki-sk-shimmer 1.5s ease infinite;
  border-radius: 4px;
}
@keyframes wiki-sk-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.wiki-table-wrap {
  overflow-x: auto;
  margin: 8px 0;
}
.wiki-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.wiki-table th, .wiki-table td {
  padding: 6px 10px;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  min-width: 40px;
}
.wiki-table th {
  background: var(--bg-dark);
  color: var(--text-bright);
  font-weight: 600;
  font-size: 11px;
  white-space: nowrap;
  position: sticky;
  top: 0;
  cursor: pointer;
  user-select: none;
}
.wiki-table th:hover { background: rgba(212,175,55,0.08); }
.wiki-table tr:hover td {
  background: rgba(212,175,55,0.03);
}
.wiki-table td:empty {
  color: var(--text-dim);
}
.wiki-table-caption {
  caption-side: top;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-bright);
  text-align: center;
}
.wiki-table tfoot th {
  background: var(--bg-dark);
  color: var(--gold);
  font-weight: 700;
  font-size: 12px;
  border-top: 2px solid var(--border);
}
.wiki-img {
  vertical-align: middle;
  image-rendering: pixelated;
  margin: 0 2px;
  max-height: 50px;
  max-width: 50px;
  width: auto;
  height: auto;
}
.wiki-table .wiki-img {
  max-height: 36px;
  max-width: 36px;
}

/* ─── Wiki Infobox Card ──────────────────────────────────────────── */
.wiki-infobox {
  float: right;
  width: 260px;
  margin: 0 0 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  font-size: 12px;
}
.wiki-ib-img {
  text-align: center;
  padding: 16px;
  background: var(--bg-dark);
}
.wiki-ib-img img {
  max-width: 120px;
  max-height: 120px;
  image-rendering: pixelated;
}
.wiki-ib-name {
  text-align: center;
  padding: 10px 14px 2px;
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 700;
  color: var(--gold);
}
.wiki-ib-type {
  text-align: center;
  padding: 0 14px 10px;
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.wiki-ib-version {
  display: block;
  width: calc(100% - 20px);
  margin: 0 10px 8px;
  padding: 4px 8px;
  font-size: 11px;
  background: var(--bg-dark);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  cursor: pointer;
}
.wiki-ib-version:hover { border-color: var(--gold-dim); }
.wiki-ib-table {
  width: 100%;
  border-collapse: collapse;
}
.wiki-ib-table tr { border-top: 1px solid var(--border); }
.wiki-ib-key {
  padding: 5px 10px;
  color: var(--text-dim);
  font-weight: 600;
  white-space: nowrap;
  width: 1%;
  text-transform: capitalize;
}
.wiki-ib-val {
  padding: 5px 10px;
  color: var(--text);
}
@media (max-width: 600px) {
  .wiki-infobox { float: none; width: 100%; margin: 0 0 16px 0; }
}
/* ─── Wiki Thumbnails ─────────────────────────────────────────────── */
.wiki-thumb {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 12px;
}
.wiki-thumb-right { float: right; margin-left: 16px; }
.wiki-thumb-left { float: left; margin-right: 16px; }
.wiki-thumb img { display: block; }
.wiki-thumb-caption {
  padding: 6px 10px;
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.4;
  border-top: 1px solid var(--border);
}
@media (max-width: 600px) {
  .wiki-thumb { float: none !important; margin: 8px 0 !important; max-width: 100% !important; }
}

.wiki-link {
  color: var(--gold-dim);
  text-decoration: none;
  border-bottom: 1px dotted var(--gold-dim);
  transition: color 0.1s, border-color 0.1s;
}
.wiki-link:hover {
  color: var(--gold);
  border-color: var(--gold);
}

/* ─── Wiki Typography ────────────────────────────────────────────── */
.wiki-content {
  max-width: 720px;
  font-size: 14px;
  color: var(--text);
  line-height: 1.75;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.wiki-content::after { content: ''; display: table; clear: both; }

.wiki-title {
  font-size: 26px;
  color: var(--gold);
  font-family: var(--font-heading);
  font-weight: 700;
  margin-bottom: 4px;
  line-height: 1.3;
}
.wiki-category { font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }

.wiki-section { margin-bottom: 24px; }
.wiki-section:last-child { margin-bottom: 0; }

.wiki-h2 {
  font-size: 20px; color: var(--text-bright); font-weight: 700;
  font-family: var(--font-heading);
  margin: 32px 0 12px; padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  line-height: 1.3; clear: both;
}
.wiki-h3 {
  font-size: 16px; color: var(--text-bright); font-weight: 600;
  margin: 24px 0 8px; line-height: 1.4;
}
.wiki-h4 {
  font-size: 14px; color: var(--text-bright); font-weight: 600;
  margin: 16px 0 6px; line-height: 1.4;
}
.wiki-section:first-child .wiki-h2,
.wiki-section:first-child .wiki-h3 { margin-top: 0; }

.wiki-body {
  font-size: 14px; color: var(--text); line-height: 1.75;
}
.wiki-body ul, .wiki-body ol { margin: 8px 0 12px; padding-left: 24px; }
.wiki-body li { margin-bottom: 4px; line-height: 1.65; }
.wiki-body hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.wiki-body b, .wiki-body strong { color: var(--text-bright); font-weight: 600; }
.wiki-body blockquote {
  border-left: 3px solid var(--gold-dim);
  padding: 8px 16px; margin: 12px 0;
  color: var(--text-dim); font-style: italic;
  background: rgba(200,170,110,0.03);
  border-radius: 0 6px 6px 0;
}

/* ─── Wiki Page Layout (TOC left + content right) ───────────────── */
.wiki-page-layout {
  position: relative;
}

.wiki-toc {
  position: fixed;
  top: 72px;
  width: 180px;
  max-height: calc(100vh - 120px);
  padding: 14px 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2), 0 0 40px rgba(0,0,0,0.05);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 5;
}
.wiki-toc::-webkit-scrollbar { width: 4px; }
.wiki-toc::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.wiki-toc-title {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  padding: 0 14px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.wiki-toc-item {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  text-decoration: none;
  padding: 4px 14px;
  line-height: 1.4;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: 0;
}
.wiki-toc-item:hover {
  color: var(--text);
  background: rgba(255,255,255,0.03);
}
.wiki-toc-item.active {
  color: var(--gold);
  background: rgba(200,170,110,0.08);
  border-right: none;
  position: relative;
}
.wiki-toc-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  background: var(--gold);
  border-radius: 0 2px 2px 0;
}
.wiki-toc-h3 { padding-left: 26px; font-size: 11px; }
.wiki-toc-h3.active::before { left: 12px; }

/* Wiki Gallery */
.wiki-gallery-item {
  display: inline-block;
  vertical-align: top;
  text-align: center;
  margin: 4px 8px 8px 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px;
  max-width: 140px;
}
.wiki-gallery-item img { display: block; margin: 0 auto 4px; }
.wiki-gallery-caption { font-size: 10px; color: var(--text-dim); line-height: 1.3; }

/* Wiki Quick Links */
.wiki-quick-link {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  font-family: 'Inter', sans-serif;
}
.wiki-quick-link:hover {
  border-color: var(--gold-dim);
  color: var(--gold);
  background: rgba(200,170,110,0.05);
}

/* Wiki History Item */
.wiki-history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-decoration: none;
}
.wiki-history-item:hover {
  border-color: var(--gold-dim);
  background: rgba(200,170,110,0.03);
}

/* Wiki Home Search Results */
.wiki-home-result {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.1s;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text);
}
.wiki-home-result:last-child { border-bottom: none; }
.wiki-home-result:hover, .wiki-home-result.active { background: rgba(200,170,110,0.06); }
.wiki-home-result-cat { font-size: 10px; color: var(--text-dim); margin-left: auto; }

/* Wiki Peek (inline page split) */
.wiki-link-peeked {
  color: var(--gold) !important;
  border-bottom-color: var(--gold) !important;
}
.wiki-peek {
  margin: 16px -9999px;
  padding-left: 9999px;
  padding-right: 9999px;
  background: var(--bg-dark);
  position: relative;
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.3s ease, opacity 0.3s ease;
  opacity: 0;
  clear: both;
  z-index: 10;
}
.wiki-peek.open {
  grid-template-rows: 1fr;
  opacity: 1;
}
.wiki-peek-inner {
  overflow: hidden;
  margin-left: -9999px;
  margin-right: -9999px;
  padding-left: 9999px;
  padding-right: 9999px;
}
.wiki-peek::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  bottom: 0;
  height: 12px;
  pointer-events: none;
  background: linear-gradient(to top, rgba(0,0,0,0.4), transparent);
}
@keyframes peekFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.wiki-peek-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 24px;
  gap: 8px;
  position: relative;
  background: var(--bg-dark);
  box-shadow: 0 6px 12px -2px rgba(0,0,0,0.5);
  margin-left: -9999px;
  margin-right: -9999px;
  padding-left: 9999px;
  padding-right: 9999px;
  border-bottom: 1px solid var(--border);
}
.wiki-peek-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--gold);
  font-family: var(--font-heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wiki-peek-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 3px;
  transition: color 0.1s, background 0.1s;
}
.wiki-peek-btn:hover {
  color: var(--text-bright);
  background: rgba(255,255,255,0.05);
}
.wiki-peek-body {
  padding: 16px 24px;
  max-height: 500px;
  overflow-y: auto;
  font-size: 13px;
  color: var(--text);
  line-height: 1.7;
  margin-left: -9999px;
  margin-right: -9999px;
  padding-left: 9999px;
  padding-right: 9999px;
  border-bottom: 1px solid var(--border);
}
.wiki-peek-body::-webkit-scrollbar { width: 4px; }
.wiki-peek-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Nested peeks indent slightly */
.wiki-peek .wiki-peek {
  margin-left: 0;
  margin-right: 0;
  background: var(--bg-panel);
}

/* Wiki Quest Details Table */
.wiki-quest-details {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  font-size: 13px;
  margin-bottom: 16px;
}
.wiki-quest-details tr {
  border-bottom: 1px solid var(--border);
}
.wiki-quest-details tr:last-child {
  border-bottom: none;
}
.wiki-quest-details th {
  background: var(--bg-dark);
  color: var(--text-bright);
  font-weight: 600;
  font-size: 12px;
  padding: 10px 14px;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
  width: 140px;
  border-right: 1px solid var(--border);
}
.wiki-quest-details td {
  padding: 10px 14px;
  color: var(--text);
  line-height: 1.6;
  vertical-align: top;
}
.wiki-quest-details td ul {
  margin: 4px 0;
  padding-left: 20px;
}
.wiki-quest-details td li {
  margin-bottom: 2px;
}
/* Requirement status colors */
.wiki-quest-details .req-met {
  color: var(--green);
}
.wiki-quest-details .req-unmet {
  color: var(--red);
}
.wiki-quest-details .req-met::marker { color: var(--green); }
.wiki-quest-details .req-unmet::marker { color: var(--red); }

@media (max-width: 600px) {
  .wiki-quest-details th {
    display: block;
    width: auto;
    border-right: none;
    border-bottom: none;
    padding: 8px 12px 2px;
  }
  .wiki-quest-details td {
    display: block;
    padding: 2px 12px 10px;
  }
}

@media (max-width: 900px) {
  .wiki-toc { display: none !important; }
  #wikiPageContent { padding-left: 24px !important; }
}
@media (max-width: 600px) {
  .wiki-content { font-size: 14px; }
  .wiki-title { font-size: 22px; }
  .wiki-h2 { font-size: 18px; margin-top: 24px; }
  .wiki-h3 { font-size: 15px; }
}

@media (max-width: 768px) {
  .global-search { max-width: none; margin: 0 8px; }
}

/* ─── Main Layout ─────────────────────────────────────────────────── */
.app-body {
  display: flex;
  height: calc(100vh - 48px);
  overflow: hidden;
}

/* ─── Icon Rail ───────────────────────────────────────────────────── */
.icon-rail {
  width: 56px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--sp-2) 0;
  gap: var(--sp-1);
  flex-shrink: 0;
  overflow: visible;
  position: relative;
  z-index: 10;
}

.rail-item {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 18px;
  transition: all var(--transition-base);
  position: relative;
}
.rail-item:hover {
  background: var(--bg-card);
  color: var(--text);
}
.rail-item.active {
  background: var(--bg-card);
  color: var(--gold);
}
.rail-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 25%;
  height: 50%;
  width: 3px;
  background: var(--gold);
  border-radius: 0 3px 3px 0;
}
.rail-item img {
  width: 20px; height: 20px;
  image-rendering: pixelated;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}
.rail-item.active img { filter: brightness(1.3) drop-shadow(0 1px 2px rgba(0,0,0,0.5)); }

/* Rail tooltip */
.rail-item .rail-tooltip {
  display: none;
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-dark);
  border: 1px solid var(--border);
  color: var(--text-bright);
  padding: 4px 10px;
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  font-family: var(--font-body);
  font-weight: 500;
  white-space: nowrap;
  z-index: 100;
  box-shadow: var(--shadow-md);
  pointer-events: none;
}
.rail-item:hover .rail-tooltip { display: block; }

.rail-divider {
  width: 28px;
  height: 1px;
  background: var(--border);
  margin: var(--sp-1) 0;
}

.rail-spacer { margin-top: auto; }

.rail-tier-badge {
  text-align: center;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 3px 0;
  margin: 0 8px 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: opacity 0.15s;
}
.rail-tier-badge:hover { opacity: 0.8; }
.rail-tier-badge.tier-free {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.rail-tier-badge.tier-pro {
  background: linear-gradient(135deg, rgba(212,175,55,0.2), rgba(212,175,55,0.1));
  border: 1px solid var(--gold-dim);
  color: var(--gold);
}
.rail-tier-badge.tier-max {
  background: linear-gradient(135deg, rgba(192,144,224,0.2), rgba(192,144,224,0.1));
  border: 1px solid rgba(192,144,224,0.4);
  color: #c090e0;
}

/* ─── Tool Panel (center) ─────────────────────────────────────────── */
.tool-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
  position: relative;
}

.tool-area > .tool-panel {
  display: none;
  padding: var(--sp-6);
}
.tool-area > .tool-panel.active {
  display: block;
}

/* Admin panel — flex column so tabs stay fixed, content scrolls */
.tool-area > .tool-panel.tool-admin-panel {
  padding: 0;
  height: 100%;
  overflow: hidden;
}
.tool-area > .tool-panel.tool-admin-panel.active {
  display: flex;
  flex-direction: column;
}

/* Full-bleed tools (map, graph) override padding */
.tool-area > .tool-panel.tool-fullbleed {
  padding: 0;
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  overflow: hidden;
}
.tool-area > .tool-panel.tool-fullbleed.active {
  display: block;
}

/* ─── Chat Panel (right side, persistent) ─────────────────────────── */
.chat-panel {
  width: 440px;
  min-width: 340px;
  max-width: 600px;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: relative;
}

.chat-panel.collapsed {
  width: 0;
  min-width: 0;
  overflow: hidden;
  border-left: none;
}

/* Chat toggle button (visible when collapsed) */
.chat-toggle {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%) translateX(100%);
  width: 24px;
  height: 48px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--gold);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  z-index: 10;
}
.chat-panel:not(.collapsed) .chat-toggle { display: none; }

/* ─── Resize Handle ───────────────────────────────────────────────── */
.chat-resize-handle {
  position: absolute;
  left: -4px;
  top: 0;
  bottom: 0;
  width: 8px;
  cursor: col-resize;
  z-index: 10;
}
.chat-resize-handle::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 0;
  bottom: 0;
  width: 2px;
  transition: background 0.15s;
}
.chat-resize-handle:hover::after,
.chat-resize-handle.dragging::after {
  background: var(--gold-dim);
}

/* ─── Responsive / Mobile ─────────────────────────────────────────── */
@media (max-width: 900px) {
  .icon-rail { display: none; }
  .chat-panel { display: none; }
  .chat-panel.mobile-open {
    display: flex;
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 0;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    z-index: 200;
    border-left: none;
  }
  .mobile-chat-fab {
    display: flex !important;
  }
}

.mobile-chat-close {
  display: none;
  position: absolute;
  top: 56px;
  right: 8px;
  width: 32px;
  height: 32px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-round);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  z-index: 201;
  align-items: center;
  justify-content: center;
}

@media (max-width: 900px) {
  .chat-panel.mobile-open .mobile-chat-close {
    display: flex !important;
  }
}

/* Mobile chat FAB */
.mobile-chat-fab {
  display: none;
  position: fixed;
  bottom: 68px;
  right: 16px;
  width: 52px;
  height: 52px;
  background: linear-gradient(180deg, #c8aa6e 0%, #a08040 100%);
  border: none;
  border-radius: var(--radius-round);
  color: var(--bg-dark);
  font-size: 22px;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

/* Mobile bottom nav */
.mobile-nav {
  display: none;
}
@media (max-width: 900px) {
  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
    z-index: 100;
    justify-content: space-around;
    padding: var(--sp-1) 0 calc(var(--sp-1) + env(safe-area-inset-bottom, 0px));
  }
  .mobile-nav button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 9px;
    font-family: var(--font-body);
    cursor: pointer;
    padding: var(--sp-1) var(--sp-2);
    min-height: 44px;
    justify-content: center;
  }
  .mobile-nav button img { width: 20px; height: 20px; }
  .mobile-nav button.active { color: var(--gold); }
  .app-body { height: calc(100vh - 48px - 52px); }
  .mobile-more-menu {
    position: fixed;
    bottom: 52px;
    right: 8px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: var(--sp-2);
    box-shadow: var(--shadow-lg);
    z-index: 101;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
  .mobile-more-menu.hidden { display: none; }
  .mobile-more-menu button {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 10px 16px;
    background: none;
    border: none;
    color: var(--text);
    font-size: var(--fs-base);
    font-family: var(--font-body);
    cursor: pointer;
    border-radius: var(--radius-md);
    white-space: nowrap;
    min-height: 44px;
  }
  .mobile-more-menu button:hover { background: var(--bg-card); }
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* === App-specific styles (moved from index.html) === */
/* ═══ Landing / Login ═══ */
#login {
  background: radial-gradient(ellipse at top, #2a221a 0%, #1a1410 70%);
}
.login-box {
  text-align: center; padding: 48px; background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.login-box h1 {
  font-family: 'Cinzel', serif; color: var(--gold); font-size: 28px; margin-bottom: 6px;
  text-shadow: 0 2px 8px rgba(200,170,110,0.2);
}
.login-box .subtitle { color: var(--text-dim); font-size: 13px; margin-bottom: 24px; }
.login-box input { width: 280px; margin-right: 8px; padding: 10px 16px; font-size: 14px; }
.login-box button { padding: 10px 24px; font-size: 14px; }
.modal-overlay { position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.6);z-index:9000;display:flex;align-items:center;justify-content:center; }
.modal-box { background:var(--bg-panel);border:1px solid var(--border);border-radius:10px;padding:24px;min-width:320px;box-shadow:0 16px 48px rgba(0,0,0,0.6); }
.modal-box h3 { font-family:'Cinzel',serif;color:var(--gold);margin-bottom:12px;font-size:16px; }
.modal-box input { width:100%;margin-bottom:12px; }
.modal-box .modal-actions { display:flex;gap:8px;justify-content:flex-end; }
/* Map tooltips */
.osrs-map-tooltip {
  background: var(--bg-panel) !important; color: var(--text-bright) !important;
  border: 1px solid var(--border) !important; border-radius: 4px !important;
  font-family: 'Inter', sans-serif !important; font-size: 11px !important;
  padding: 4px 8px !important; box-shadow: 0 4px 12px rgba(0,0,0,0.5) !important;
}
.osrs-map-tooltip::before { border-top-color: var(--border) !important; }
.osrs-map-marker { background: none !important; border: none !important; }
.osrs-map-icon { image-rendering: pixelated; filter: drop-shadow(0 1px 3px rgba(0,0,0,0.8)); }
.map-filter { transition: opacity 0.15s; }
.map-filter:not(.active) { opacity: 0.35; text-decoration: line-through; }
/* Contain Leaflet z-indexes so map doesn't overlay modals/popups */
#osrsMap { isolation: isolate; position: relative; z-index: 0; }
.tool-fullbleed { isolation: isolate; }
.modal-overlay { z-index: 9000 !important; }
#osrsMap .leaflet-control-zoom a {
  background: var(--bg-panel) !important; color: var(--gold) !important;
  border-color: var(--border) !important;
}
#osrsMap .leaflet-control-zoom a:hover { background: var(--bg-card) !important; }
.graph-filter { opacity: 0.4; text-decoration: line-through; }
.graph-filter.active { opacity: 1; text-decoration: none; }
.admin-tab { display: none; }
.admin-tab.active { display: block; }
#section-admin[style*="block"] { display: flex !important; flex-direction: column; }
.admin-tabs {
  display: flex; gap: 0; padding: 0 24px; border-bottom: 1px solid var(--border);
  background: var(--bg-panel); flex-shrink: 0;
}
.admin-tabs button {
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text-dim); padding: 12px 20px; font-size: 13px; font-weight: 600;
  font-family: 'Inter', sans-serif; cursor: pointer; transition: all 0.15s;
}
.admin-tabs button:hover { color: var(--text); }
.admin-tabs button.active { color: var(--gold); border-bottom-color: var(--gold); }
.admin-tabs-divider { width:1px; background:var(--border); margin:8px 4px; flex-shrink:0; }

/* Tier cards */
.tier-card {
  perspective: 800px;
  cursor: default;
}
.tier-card-inner {
  position: relative;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.3s;
  transform-style: preserve-3d;
  overflow: hidden;
}
.tier-card:hover .tier-card-inner {
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.tier-card-pro-inner {
  border-color: rgba(200,170,110,0.4);
  background: linear-gradient(175deg, var(--bg-card) 0%, rgba(200,170,110,0.05) 100%);
}
.tier-card:hover .tier-card-pro-inner {
  border-color: var(--gold-dim);
  box-shadow: 0 8px 40px rgba(200,170,110,0.15), 0 0 60px rgba(200,170,110,0.05);
}
.tier-card-max-inner {
  border-color: rgba(192,144,224,0.3);
  background: linear-gradient(175deg, var(--bg-card) 0%, rgba(192,144,224,0.05) 100%);
}
.tier-card:hover .tier-card-max-inner {
  border-color: rgba(192,144,224,0.5);
  box-shadow: 0 8px 40px rgba(192,144,224,0.12), 0 0 60px rgba(192,144,224,0.04);
}
/* Shine sweep */
.tier-card-shine {
  position: absolute; top: 0; left: -100%; width: 60%; height: 100%;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.03) 45%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.03) 55%, transparent 60%);
  transition: none; pointer-events: none;
}
.tier-card:hover .tier-card-shine {
  left: 150%;
  transition: left 0.6s ease;
}
/* Badge */
.tier-card-badge {
  position: absolute; top: -1px; right: 20px;
  background: var(--gold); color: #1a1410;
  font-size: 9px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase;
  padding: 4px 10px; border-radius: 0 0 6px 6px;
}
.tier-card-btn {
  transition: transform 0.1s, box-shadow 0.1s;
}
.tier-card-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(200,170,110,0.3);
}
.tier-card-featured {
  transform: scale(1.03);
  z-index: 1;
}
@media (max-width: 768px) {
  #tierCardsGrid { grid-template-columns: 1fr !important; max-width: 360px; margin: 0 auto 24px; }
  .tier-card-featured { transform: none; }
}

/* Dashboard */
.dash-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px;
  padding: 18px; display: flex; gap: 14px; cursor: pointer;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
}
.dash-card:hover {
  border-color: var(--gold-dim); transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.dash-card-icon {
  flex-shrink: 0; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center;
  background: var(--bg-dark); border-radius: 8px; border: 1px solid var(--border);
}
.dash-card-body { flex: 1; }
.dash-card-title { font-family: 'Cinzel', serif; color: var(--gold); font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.dash-card-desc { font-size: 12px; color: var(--text-dim); line-height: 1.5; }
.dash-skill-badge {
  display: inline-flex; align-items: center; gap: 4px; background: var(--bg-dark);
  border: 1px solid var(--border); border-radius: 4px; padding: 2px 6px; font-size: 10px; color: var(--text-dim);
}
.dash-skill-badge img { vertical-align: middle; }
.dash-skill-badge .lvl { color: var(--gold); font-weight: 600; }
.login-icon { font-size: 48px; margin-bottom: 16px; display: block; }

/* ═══ App Layout — handled by styles.css ═══ */
/* Legacy compat classes kept for any remaining references */
.desktop-only {}
@media (max-width: 900px) { .desktop-only { display: none !important; } }
.tool-controls { display: flex; gap: 8px; margin-bottom: 16px; align-items: center; flex-wrap: wrap; }
.tool-loading { color: var(--text-dim); padding: 16px 0; display: none; }
.tool-desc { font-size: 12px; color: var(--text-dim); margin-bottom: 14px; line-height: 1.5; }

/* ═══ Widget System ═══ */
.widget-toolbar {
  display: flex; align-items: center; gap: 2px; margin-left: auto;
}
.widget-toolbar .wt-btn {
  background: var(--bg-card); color: var(--text-dim); border: 1px solid var(--border);
  padding: 4px 8px; font-size: 14px; line-height: 1; cursor: pointer; border-radius: 3px;
  min-width: 28px; text-align: center; transition: all 0.15s;
}
.widget-toolbar .wt-btn:hover { color: var(--text); border-color: var(--gold-dim); }
.widget-toolbar .wt-btn.active { background: var(--gold-dim); color: var(--bg-dark); border-color: var(--gold); }

/* ── List view: dense, no border, compact rows ── */
.widget-list { display: flex; flex-direction: column; gap: 0; }
.widget-list .widget-item {
  background: transparent; border: none; border-bottom: 1px solid var(--border);
  border-radius: 0; cursor: pointer; transition: background 0.1s;
}
.widget-list .widget-item:first-child { border-top: 1px solid var(--border); }
.widget-list .widget-item:hover { background: var(--bg-card); }
.widget-list .widget-item.expanded { background: var(--bg-card); }
.widget-list .widget-item-header { display: flex; align-items: center; padding: 6px 10px; gap: 8px; }
.widget-list .widget-item-body { display: none; padding: 0 10px 10px 10px; }
.widget-list .widget-item.expanded .widget-item-body { display: block; }

/* ── Cards view: rich cards, body always visible, chart shown ── */
.widget-card-grid.view-cards { display: flex; flex-direction: column; gap: 10px; }
.widget-card-grid .widget-item {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px;
  cursor: pointer; transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.widget-card-grid .widget-item:hover { border-color: var(--gold-dim); box-shadow: 0 4px 16px rgba(0,0,0,0.25); }
.widget-card-grid .widget-item.expanded { border-color: var(--gold); }
.widget-card-grid .widget-item-header {
  display: flex; align-items: center; padding: 14px 16px; gap: 14px;
}
/* Cards always show the body (chart/details) — no expand needed */
.widget-card-grid .widget-item-body { display: block; padding: 0 16px 14px; border-top: 1px solid #2a231b; }
.widget-card-grid .widget-item .widget-chevron { display: none; }

/* ── Grid view: multi-column tiles ── */
.widget-card-grid.view-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px;
}
.view-grid .widget-item {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer; transition: border-color 0.15s;
}
.view-grid .widget-item:hover { border-color: var(--gold-dim); }
.view-grid .widget-item.expanded { border-color: var(--gold); }
.view-grid .widget-item-header {
  flex-direction: column; align-items: flex-start; gap: 6px;
  padding: 12px; min-height: 110px; display: flex;
}
.view-grid .widget-item-body { display: none; padding: 0 12px 12px; }
.view-grid .widget-item.expanded .widget-item-body { display: block; }
.view-grid .widget-chevron { display: none; }

.widget-chevron { color: var(--border-light); font-size: 12px; min-width: 14px; transition: transform 0.15s; }
.widget-item.expanded .widget-chevron { transform: rotate(90deg); color: var(--gold-dim); }

/* ═══ Flip cards ═══ */
.flip-list { display: flex; flex-direction: column; gap: 6px; }
.flip-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 6px;
  padding: 14px; display: flex; gap: 14px; align-items: center; transition: border-color 0.15s;
}
.flip-card:hover { border-color: var(--gold-dim); }
.flip-info { min-width: 180px; }
.flip-name { font-size: 14px; font-weight: 700; color: var(--text-bright); margin-bottom: 3px; }
.flip-meta { font-size: 11px; color: var(--text-dim); line-height: 1.5; }
.flip-chart { flex: 1; min-width: 280px; }
.flip-profit { text-align: right; min-width: 110px; }
.flip-profit .big { font-family: 'Cinzel', serif; font-size: 18px; font-weight: 700; color: var(--green); }
.flip-profit .sub { font-size: 10px; color: var(--text-dim); margin-top: 2px; }
.flip-rank { font-family: 'Cinzel', serif; font-size: 16px; font-weight: 900; color: var(--border); min-width: 26px; text-align: center; }

/* ═══ Charts ═══ */
.chart-label { font-size: 10px; fill: var(--text-dim); font-family: 'Inter', sans-serif; }
.chart-grid { stroke: #2a231b; stroke-width: 0.5; }

/* ═══ AI Picks ═══ */
.advisor-summary {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 16px; margin-bottom: 12px; font-size: 13px; color: var(--text); line-height: 1.5;
  border-left: 3px solid var(--gold-dim);
}
.pick-row {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 6px;
  margin-bottom: 3px; cursor: pointer; transition: border-color 0.15s;
}
.pick-row:hover { border-color: var(--gold-dim); }
.pick-row.expanded { border-color: var(--gold); }
.pick-header { display: flex; align-items: center; padding: 8px 12px; gap: 10px; }
.pick-num { font-family: 'Cinzel', serif; font-size: 13px; font-weight: 900; min-width: 20px; text-align: center; }
.pick-num.high { color: var(--green); }
.pick-num.medium { color: var(--orange); }
.pick-num.low { color: var(--red); }
.pick-name { font-size: 13px; font-weight: 600; color: var(--text-bright); flex: 1; }
.pick-prices { font-size: 11px; color: var(--text-dim); min-width: 140px; }
.pick-margin { font-size: 12px; font-weight: 700; color: var(--green); min-width: 60px; text-align: right; }
.pick-profit { font-size: 12px; font-weight: 700; color: var(--green); min-width: 70px; text-align: right; }
.pick-conf {
  font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 3px; text-transform: uppercase;
}
.pick-conf.high { background: var(--green-dim); color: var(--green); }
.pick-conf.medium { background: #3d3020; color: var(--orange); }
.pick-conf.low { background: var(--red-dim); color: var(--red); }
.pick-expand { display: none; padding: 0 12px 14px 42px; }
.pick-row.expanded .pick-expand { display: block; }
.pick-reason { font-size: 12px; color: var(--text); line-height: 1.5; margin-bottom: 8px; }
.pick-details { font-size: 11px; color: var(--text-dim); margin-bottom: 8px; line-height: 1.6; }
.pick-chevron { color: var(--border-light); font-size: 12px; min-width: 14px; transition: transform 0.15s; }
.pick-row.expanded .pick-chevron { transform: rotate(90deg); color: var(--gold-dim); }

/* ═══ Cycles ═══ */
.cycle-row { background: var(--bg-card); border: 1px solid var(--border); border-radius: 6px; margin-bottom: 3px; cursor: pointer; transition: border-color 0.15s; }
.cycle-row:hover { border-color: var(--gold-dim); }
.cycle-row.expanded { border-color: var(--gold); }
.cycle-header { display: flex; align-items: center; padding: 8px 12px; gap: 10px; }
.cycle-name { font-size: 13px; font-weight: 600; color: var(--text-bright); flex: 1; }
.cycle-tag { font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 3px; text-transform: uppercase; }
.cycle-tag.buy { background: var(--green-dim); color: var(--green); }
.cycle-tag.sell { background: #3d3020; color: var(--orange); }
.cycle-tag.wait { background: var(--bg-dark); color: var(--text-dim); }
.cycle-metric { font-size: 11px; color: var(--text-dim); min-width: 60px; text-align: right; }
.cycle-metric strong { color: var(--text); }
.cycle-expand { display: none; padding: 0 12px 14px 12px; }
.cycle-row.expanded .cycle-expand { display: block; }
.cycle-details { font-size: 11px; color: var(--text-dim); line-height: 1.6; margin-bottom: 8px; }
.cycle-chevron { color: var(--border-light); font-size: 12px; min-width: 14px; transition: transform 0.15s; }
.cycle-row.expanded .cycle-chevron { transform: rotate(90deg); color: var(--gold-dim); }
.phase-bar { display: inline-block; height: 6px; border-radius: 3px; background: var(--bg-dark); width: 60px; vertical-align: middle; margin-left: 4px; overflow: hidden; }
.phase-fill { height: 100%; border-radius: 3px; }
.phase-fill.rising { background: var(--green); }
.phase-fill.falling { background: var(--red); }

/* ═══ Pagination ═══ */
.pagination { display: flex; align-items: center; justify-content: center; gap: 4px; margin-top: 14px; }
.pagination button { min-width: 32px; padding: 5px 8px; font-size: 11px; }
.page-btn { background: var(--bg-card); color: var(--text-dim); border: 1px solid var(--border); }
.page-btn.active { background: var(--gold); color: var(--bg-dark); border-color: var(--gold); }
.page-btn:hover { border-color: var(--gold-dim); }
.page-info { font-size: 11px; color: var(--text-dim); margin: 0 6px; }

.auto-bar { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-dim); }
.auto-bar .countdown { color: var(--gold); font-weight: 600; }

/* ═══ Chat ═══ */
.chat-inner {
  display: flex; flex-direction: column; height: 100%;
}
/* Legacy compat */
.tool-chat-panel.active {
  display: flex !important; flex-direction: column; height: calc(100vh - 49px);
  margin: -24px; padding: 0;
}
.chat-messages {
  flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 16px;
}
.chat-welcome {
  text-align: center; padding: 60px 24px; max-width: 480px; margin: auto;
}
.chat-msg {
  display: flex; gap: 12px; max-width: 100%; line-height: 1.6; font-size: 14px;
  min-width: 0;
}
.chat-msg.user { flex-direction: row-reverse; margin-left: auto; }
.chat-msg.assistant { margin-right: auto; }
.chat-avatar {
  width: 32px; height: 32px; border-radius: 4px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 14px;
}
.chat-msg.user .chat-avatar { background: var(--gold-dim); color: var(--bg-dark); }
.chat-msg.assistant .chat-avatar { background: var(--bg-card); border: 1px solid var(--border); }
.chat-bubble {
  padding: 10px 16px; border-radius: 12px; color: var(--text-bright);
  min-width: 0; overflow-x: auto; max-width: 100%;
}
.chat-msg.user .chat-bubble {
  background: #3d3520; border: 1px solid var(--gold-dim); border-top-right-radius: 2px;
}
.chat-msg.assistant .chat-bubble {
  background: var(--bg-card); border: 1px solid var(--border); border-top-left-radius: 2px;
}
.chat-bubble p { margin: 0 0 6px; line-height: 1.6; }
.chat-bubble p:last-child { margin-bottom: 0; }
.chat-bubble code { background: var(--bg-dark); padding: 1px 5px; border-radius: 3px; font-size: 13px; color: var(--gold); }
.chat-bubble strong { color: var(--gold); }
/* Numbered/bulleted lists in chat */
.chat-bubble ol, .chat-bubble ul {
  margin: 6px 0; padding-left: 20px;
}
.chat-bubble li {
  margin-bottom: 8px; line-height: 1.5;
}
.chat-bubble li .chat-embed { margin: 6px 0 2px; }
/* Item embeds should be block-level when in lists */
.chat-bubble li .chat-embed-item { display: flex; margin: 4px 0; }
.chat-bubble li .chat-embed-node { display: flex; margin: 4px 0; }
/* Headings in chat */
.chat-bubble h3, .chat-bubble h4 {
  font-family: 'Cinzel', serif; color: var(--gold); font-size: 13px; margin: 12px 0 6px; font-weight: 700;
}
.chat-bubble h3:first-child, .chat-bubble h4:first-child { margin-top: 0; }
.chat-typing {
  display: inline-flex; gap: 4px; padding: 4px 0;
}
.chat-typing span {
  width: 6px; height: 6px; background: var(--text-dim); border-radius: 50%;
  animation: chatBounce 1.2s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chatBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}
@keyframes skeletonShimmer {
  0% { background-position: -200px 0; }
  100% { background-position: 200px 0; }
}
.skeleton-line {
  height: 14px; border-radius: 6px; margin-bottom: 8px;
  background: linear-gradient(90deg, var(--bg-dark) 25%, rgba(200,170,110,0.06) 50%, var(--bg-dark) 75%);
  background-size: 400px 100%;
  animation: skeletonShimmer 1.5s ease-in-out infinite;
}
.chat-main-area .chat-messages {
  flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 16px;
}
.chat-input-area {
  padding: 12px 24px 16px; border-top: 1px solid var(--border); background: var(--bg-panel);
}
.chat-input-wrap {
  display: flex; align-items: center; gap: 8px; max-width: 720px; margin: 0 auto;
  background: var(--bg-input); border: 1px solid var(--border); border-radius: 12px;
  padding: 8px 12px; transition: border-color 0.2s;
}
.chat-input-wrap:focus-within { border-color: var(--gold-dim); }
.chat-input-wrap textarea {
  flex: 1; background: none; border: none; color: var(--text-bright); font-size: 14px;
  font-family: 'Inter', sans-serif; resize: none; outline: none; max-height: 120px;
  line-height: 1.5; padding: 4px 0;
}
.chat-input-wrap textarea::placeholder { color: var(--text-dim); }
.chat-send-btn {
  background: var(--gold); color: var(--bg-dark); border: none; border-radius: 8px;
  width: 32px; height: 32px; min-width: 32px; min-height: 32px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; transition: opacity 0.15s;
}
.chat-send-btn svg { display: block; }
.chat-send-btn:hover { opacity: 0.85; }
.chat-send-btn:disabled { opacity: 0.3; cursor: default; }

/* ═══ Conversation Sidebar ═══ */
.chat-body { display: flex; flex: 1; overflow: hidden; }
.convo-sidebar {
  width: 240px; min-width: 240px; background: var(--bg-dark); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden; transition: width 0.2s, min-width 0.2s;
}
.convo-sidebar.collapsed { width: 0; min-width: 0; border-right: none; }
.convo-sidebar-header {
  padding: 10px 12px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
.convo-new-btn {
  flex: 1; display: flex; align-items: center; gap: 6px; padding: 7px 12px; font-size: 12px; font-weight: 600;
  background: var(--bg-card); color: var(--gold); border: 1px solid var(--border); border-radius: 6px;
  cursor: pointer; transition: border-color 0.15s, background 0.15s; font-family: 'Inter', sans-serif;
}
.convo-new-btn:hover { border-color: var(--gold-dim); background: var(--bg-panel); }
.convo-toggle-btn {
  background: none; border: 1px solid var(--border); border-radius: 6px; color: var(--text-dim);
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 14px; flex-shrink: 0; transition: color 0.15s;
}
.convo-toggle-btn:hover { color: var(--gold); }
.convo-list { flex: 1; overflow-y: auto; padding: 6px; }
.convo-item {
  display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 6px;
  cursor: pointer; transition: background 0.15s; position: relative; margin-bottom: 2px;
}
.convo-item:hover { background: var(--bg-card); }
.convo-item.active { background: var(--bg-card); border: 1px solid var(--border); }
.convo-item-text { flex: 1; overflow: hidden; }
.convo-item-title {
  font-size: 12px; color: var(--text-bright); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; line-height: 1.4;
}
.convo-item-time { font-size: 10px; color: var(--text-dim); }
.convo-item-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--gold); flex-shrink: 0;
  opacity: 0; transition: opacity 0.15s;
}
.convo-item.active .convo-item-dot { opacity: 1; }
.convo-item-delete {
  opacity: 0; background: none; border: none; color: var(--text-dim); cursor: pointer;
  font-size: 14px; padding: 2px 4px; transition: opacity 0.15s, color 0.15s; flex-shrink: 0;
}
.convo-item:hover .convo-item-delete { opacity: 1; }
.convo-item-delete:hover { color: var(--red); }
.convo-sidebar-collapsed-toggle {
  display: none; position: absolute; left: 8px; top: 8px; z-index: 10;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text-dim); width: 30px; height: 30px; align-items: center; justify-content: center;
  cursor: pointer; font-size: 14px;
}
.convo-sidebar.collapsed ~ .chat-main-area .convo-sidebar-collapsed-toggle { display: flex; }
@media (max-width: 768px) {
  .convo-sidebar { width: 200px; min-width: 200px; }
  .convo-sidebar:not(.collapsed) { position: absolute; z-index: 20; height: 100%; }
}

/* Chat embeds */
.chat-embed { margin: 8px 0; border-radius: 8px; overflow: hidden; }
.chat-embed-chart {
  background: var(--bg-dark); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px; min-height: 100px;
}
.chat-embed-chart .chart-title {
  font-size: 11px; color: var(--text-dim); margin-bottom: 4px; display: flex; align-items: center; gap: 6px;
}
.chat-embed-item {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 14px; display: inline-flex; align-items: center; gap: 10px; cursor: default;
}
.chat-embed-item img { border-radius: 2px; }
.chat-embed-item .item-name { font-size: 13px; font-weight: 600; color: var(--gold); }
.chat-embed-item .item-prices { font-size: 11px; color: var(--text-dim); }
.chat-embed-item .item-prices .gp { color: var(--gold-bright); font-weight: 600; }
.chat-embed-node {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  transition: border-color 0.15s;
}
.chat-embed-node:hover { border-color: var(--gold-dim); }
.chat-embed-node .node-type {
  font-size: 9px; text-transform: uppercase; font-weight: 700; padding: 1px 5px;
  border-radius: 3px; letter-spacing: 0.5px;
}
.chat-embed-node .node-name { font-size: 13px; font-weight: 600; color: var(--text-bright); }
.chat-embed-node .node-arrow { color: var(--text-dim); font-size: 11px; }
.chat-embed-skill {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px 2px 4px;
  border-radius: 4px; font-size: 12px; font-weight: 600; vertical-align: middle;
  border: 1px solid;
}
.chat-embed-skill.met { background: var(--green-dim); border-color: #3a6a3a; color: var(--green); }
.chat-embed-skill.unmet { background: var(--red-dim); border-color: #6a3535; color: var(--red); }
.chat-embed-skill.unknown { background: var(--bg-card); border-color: var(--border); color: var(--text); }
.chat-embed-skill img { vertical-align: middle; }
.chat-embed-quest {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px 2px 4px;
  border-radius: 4px; font-size: 12px; font-weight: 600; vertical-align: middle;
  background: var(--green-dim); border: 1px solid #3a6a3a; color: var(--green); cursor: pointer;
  transition: border-color 0.15s;
}
.chat-embed-quest:hover { filter: brightness(1.2); }
.chat-embed-quest img { vertical-align: middle; }
.chat-embed-quest { position: relative; }
.chat-embed-quest.q-done { background: var(--green-dim); border-color: #3a6a3a; color: var(--green); }
.chat-embed-quest.q-progress { background: #3d3020; border-color: #6a5a2a; color: var(--orange); }
.chat-embed-quest.q-locked { background: var(--red-dim); border-color: #6a3535; color: var(--red); }
.chat-embed-quest.q-unknown { background: var(--bg-card); border-color: var(--border); color: var(--text); }
.quest-hover-tooltip {
  display: none; position: fixed; width: 300px; height: 160px;
  background: var(--bg-dark); border: 1px solid var(--border);
  border-radius: 8px; overflow: hidden; z-index: 200; box-shadow: 0 8px 24px rgba(0,0,0,0.6);
  cursor: grab; user-select: none; pointer-events: none;
}
/* Location embed with minimap hover */
.chat-embed-location {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px 2px 4px;
  border-radius: 4px; font-size: 12px; font-weight: 600; vertical-align: middle;
  background: #1a2a3a; border: 1px solid #2a5a8a; color: #6ab4ff; cursor: pointer;
  transition: border-color 0.15s; position: relative;
}
.chat-embed-location:hover { border-color: #4a8aca; filter: brightness(1.2); }
.chat-embed-location img { vertical-align: middle; }
.location-minimap {
  display: none; position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); width: 260px; height: 200px;
  background: var(--bg-dark); border: 1px solid var(--border);
  border-radius: 8px; overflow: hidden; z-index: 200; box-shadow: 0 8px 24px rgba(0,0,0,0.6);
  pointer-events: none;
}
.location-minimap .minimap-map { width: 100%; height: 100%; }
.location-minimap .minimap-label {
  position: absolute; bottom: 0; left: 0; right: 0; padding: 4px 8px;
  background: rgba(0,0,0,0.75); font-size: 10px; color: var(--text); text-align: center;
  z-index: 201;
}
.location-minimap .minimap-coords {
  font-size: 9px; color: var(--text-dim);
}
.location-minimap .leaflet-control-zoom { display: none !important; }
.location-minimap .leaflet-control-attribution { display: none !important; }
.minimap-pin {
  width: 12px; height: 12px; background: #ff4444; border: 2px solid #fff;
  border-radius: 50%; box-shadow: 0 0 6px rgba(255,0,0,0.6);
}
/* Checklist widget */
.chat-checklist {
  background: var(--bg-dark); border: 1px solid var(--border); border-radius: 8px;
  margin: 8px 0; overflow: hidden; max-width: 100%;
}
.chat-checklist-header { border-radius: 8px 8px 0 0; }
.chat-checklist-header {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  background: var(--bg-panel); border-bottom: 1px solid var(--border);
  font-family: 'Cinzel', serif; font-size: 13px; font-weight: 700; color: var(--gold);
}
.chat-checklist-header .progress-bar {
  flex: 1; height: 4px; background: var(--border); border-radius: 2px; margin-left: 8px; max-width: 120px;
}
.chat-checklist-header .progress-fill { height: 100%; background: var(--green); border-radius: 2px; transition: width 0.3s; }
.chat-checklist-header .progress-text { font-size: 10px; color: var(--text-dim); font-family: 'Inter', sans-serif; font-weight: 500; }
.chat-step {
  display: flex; align-items: flex-start; gap: 10px; padding: 8px 14px;
  border-bottom: 1px solid #1e1a15; font-size: 13px; line-height: 1.5;
}
.chat-step:last-child { border-bottom: none; }
.chat-step-icon { flex-shrink: 0; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.chat-step.done { color: var(--text-dim); }
.chat-step.done .chat-step-icon { color: var(--green); }
.chat-step.done .chat-step-text { text-decoration: line-through; color: var(--text-dim); }
.chat-step.current { color: var(--text-bright); background: #2a2518; }
.chat-step.current .chat-step-icon { color: var(--gold-bright); }
.chat-step.locked { color: var(--text-dim); opacity: 0.6; }
.chat-step.locked .chat-step-icon { color: var(--red); }
.chat-step-text { flex: 1; min-width: 0; word-wrap: break-word; overflow-wrap: break-word; }
.chat-embed-tree {
  background: var(--bg-dark); border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden; position: relative; height: 180px; cursor: grab; user-select: none;
  -webkit-user-select: none; transform: translateZ(0); contain: strict;
  margin: 8px 0; transition: height 0.25s ease;
}
.chat-embed-tree.expanded { height: 400px; }
.chat-embed-tree svg { display: block; transform: translateZ(0); overflow: hidden; shape-rendering: optimizeSpeed; }
.chat-embed-tree .tree-label {
  position: absolute; top: 4px; left: 6px; font-size: 9px; color: var(--text-dim);
  display: flex; align-items: center; gap: 3px; pointer-events: none; z-index: 1;
}
.chat-embed-tree .tree-toolbar {
  position: absolute; top: 4px; right: 6px; z-index: 1; display: flex; gap: 4px;
}

/* Graph tooltip (positioned over canvas container) */
#graph-tooltip {
  position: absolute; pointer-events: none; z-index: 20;
  background: #1b1710; border: 1px solid #645545; border-radius: 3px;
  padding: 4px 8px; font-size: 11px; color: #ff981f; font-family: Inter, sans-serif;
  white-space: nowrap; box-shadow: 0 2px 8px rgba(0,0,0,0.6); display: none;
}

/* ═══ Unlock Tree ═══ */
.tree-search-wrap, .item-search-wrap {
  position: relative; width: 100%; max-width: 400px;
}
.tree-search-wrap input, .item-search-wrap input {
  width: 100%; padding-right: 36px;
}
.tree-search-results, .item-search-results {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 20;
  background: var(--bg-panel); border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 6px 6px; max-height: 260px; overflow-y: auto; display: none;
}
.tree-search-results.open, .item-search-results.open { display: block; }
.tree-search-result, .item-search-result {
  padding: 8px 12px; cursor: pointer; font-size: 13px; color: var(--text);
  border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px;
}
.tree-search-result:hover, .item-search-result:hover { background: var(--bg-card); color: var(--gold); }
.tree-search-result:last-child, .item-search-result:last-child { border-bottom: none; }

/* ═══ Recipe Flow ═══ */
.recipe-flow {
  display: flex; align-items: flex-start; gap: 16px; padding: 12px 0; flex-wrap: wrap; justify-content: center;
}
.recipe-side {
  display: flex; flex-direction: column; gap: 8px; min-width: 120px;
}
.recipe-item {
  display: flex; align-items: center; gap: 8px; background: var(--bg-dark); border: 1px solid var(--border);
  border-radius: 6px; padding: 8px 12px;
}
.recipe-item img { border-radius: 2px; flex-shrink: 0; }
.recipe-item-info { font-size: 12px; }
.recipe-item-name { color: var(--text-bright); font-weight: 600; }
.recipe-item-price { color: var(--text-dim); font-size: 11px; margin-top: 2px; }
.recipe-item-total { font-size: 11px; margin-top: 1px; }
.recipe-arrow {
  font-size: 28px; color: var(--gold-dim); display: flex; align-items: center; padding-top: 8px;
  font-family: 'Cinzel', serif; font-weight: 900;
}
.recipe-profit-summary {
  text-align: center; padding: 8px 0; font-size: 14px; font-weight: 700;
  font-family: 'Cinzel', serif;
}
.recipe-profit-summary .roi { font-size: 11px; color: var(--text-dim); font-family: 'Inter', sans-serif; font-weight: 500; }

/* ═══ Trending Items Grid ═══ */
.trending-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px;
}
.trending-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 6px;
  padding: 12px; cursor: pointer; transition: border-color 0.15s;
  display: flex; align-items: center; gap: 10px;
}
.trending-card:hover { border-color: var(--gold-dim); }
.trending-card img { border-radius: 2px; flex-shrink: 0; }
.trending-card-info { flex: 1; min-width: 0; }
.trending-card-name { font-size: 13px; font-weight: 600; color: var(--text-bright); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trending-card-prices { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.trending-card-vol { font-size: 10px; color: var(--text-dim); margin-top: 1px; }
.tree-node-type {
  font-size: 9px; text-transform: uppercase; font-weight: 700; padding: 1px 5px;
  border-radius: 3px; letter-spacing: 0.5px;
}
.tree-node-type.quest { background: var(--green-dim); color: var(--green); }
.tree-node-type.item { background: #3d3020; color: var(--orange); }
.tree-node-type.boss { background: var(--red-dim); color: var(--red); }
.tree-node-type.diary { background: #1e2a3d; color: var(--blue); }
.tree-node-type.skill { background: #2d2d1e; color: var(--gold); }
.tree-node-type.other { background: var(--bg-dark); color: var(--text-dim); }

.tree-node-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
  padding: 18px; margin-bottom: 16px;
}
.tree-node-card h3 {
  color: var(--gold); font-size: 16px; margin-bottom: 8px; display: flex; align-items: center; gap: 10px;
}
.tree-node-props {
  font-size: 12px; color: var(--text-dim); line-height: 1.8;
}
.tree-node-props strong { color: var(--text); }

.tree-section { margin-bottom: 16px; }
.tree-section h3 { color: var(--gold-dim); font-size: 14px; margin-bottom: 8px; }

.req-tree { list-style: none; padding-left: 0; }
.req-tree ul { list-style: none; padding-left: 20px; border-left: 1px solid var(--border); margin-left: 8px; }
.req-tree li { padding: 4px 0; font-size: 12px; color: var(--text); }
.req-tree li .req-icon { margin-right: 6px; font-size: 11px; }
.req-tree li .req-name { cursor: pointer; }
.req-tree li .req-name:hover { color: var(--gold); text-decoration: underline; }
.req-tree li .req-type { margin-left: 6px; }

.unlock-list { display: flex; flex-direction: column; gap: 3px; }
.unlock-item {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 4px;
  padding: 6px 10px; font-size: 12px; color: var(--text); display: flex; align-items: center; gap: 8px;
  cursor: pointer; transition: border-color 0.15s;
}
.unlock-item:hover { border-color: var(--gold-dim); color: var(--gold); }

.tree-path-section {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
  padding: 16px; margin-top: 16px;
}
.tree-path-section h3 { color: var(--gold); font-size: 14px; margin-bottom: 10px; }
.path-step {
  display: flex; align-items: flex-start; gap: 10px; padding: 6px 0;
  border-bottom: 1px solid var(--border); font-size: 12px;
}
.path-step:last-child { border-bottom: none; }
.path-step-num {
  font-family: 'Cinzel', serif; font-weight: 900; color: var(--gold-dim);
  min-width: 22px; text-align: center; font-size: 11px;
}
.path-step-info { flex: 1; color: var(--text); line-height: 1.5; }
.path-step-info strong { color: var(--text-bright); }

/* Hamburger + mobile menu (hidden on desktop) */
.hamburger {
  display: none; background: none; border: none; color: var(--gold); font-size: 22px;
  padding: 4px 8px; cursor: pointer;
}
.mobile-menu {
  display: none; position: absolute; top: 49px; left: 0; right: 0; z-index: 100;
  background: var(--bg-panel); border-bottom: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.mobile-menu.open { display: block; }
.mobile-menu-section { padding: 8px 0; }
.mobile-menu-section button {
  display: block; width: 100%; text-align: left; background: none; border: none;
  color: var(--text); padding: 10px 20px; font-size: 14px; cursor: pointer;
  font-family: 'Inter', sans-serif;
}
.mobile-menu-section button:hover { background: var(--bg-card); color: var(--gold); }
.desktop-only { }

/* ═══ Responsive: Tablet ═══ */
@media (max-width: 1024px) {
  .sidebar { width: 160px; }
  .sidebar-item { padding: 8px 12px; font-size: 12px; }
  .sidebar-label { padding: 14px 12px 4px; font-size: 8px; }
  .main-panel { padding: 16px; }
  .top-tab { padding: 6px 12px; font-size: 12px; }
  .flip-card { flex-wrap: wrap; }
  .flip-chart { min-width: 200px; }
  .trending-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  .convo-sidebar { width: 200px; min-width: 200px; }
  .chat-msg { max-width: 600px; }
  .admin-tabs button { padding: 10px 14px; font-size: 12px; }
  #treeInspector { width: 320px !important; }
}

/* ═══ Responsive: Mobile ═══ */
@media (max-width: 768px) {
  /* Top bar — only logo + hamburger */
  .top-bar { padding: 8px 12px; gap: 8px; }
  .top-bar h1 { display: none; }
  .top-tabs { display: none !important; }
  .hamburger { display: block; }
  .desktop-only { display: none !important; }
  #userInfo button { display: none; }
  #userBar { margin-left: auto; }

  /* Sidebar hidden — tools accessed via hamburger menu */
  .app-layout { flex-direction: column; }
  .sidebar { display: none !important; }

  /* Main panel full width */
  .main-panel { padding: 12px; }

  /* Inputs — prevent iOS zoom on focus (requires 16px+) */
  .input, input, select, textarea { font-size: 16px; }
  .input-xs, .input-sm { font-size: 14px; }

  /* Tool controls stack */
  .tool-controls { flex-direction: column; align-items: stretch; gap: 8px; }
  .tool-controls input, .tool-controls select { width: 100%; min-height: 40px; }
  .tool-controls button { width: 100%; min-height: 40px; }

  /* Stats cards wrap smaller */
  .stats { gap: 6px; }
  .stat-card { min-width: 80px; padding: 10px 12px; }
  .stat-card .value { font-size: 18px; }
  .stat-card .label { font-size: 9px; }

  /* Tables scroll horizontally */
  table { display: block; overflow-x: auto; white-space: nowrap; }

  /* Dashboard cards */
  .dash-card { padding: 12px; gap: 10px; }
  .dash-card-icon { width: 36px; height: 36px; }
  .dash-card-title { font-size: 13px; }
  .dash-card-desc { font-size: 11px; }

  /* Chat sidebar hidden by default on mobile */
  .convo-sidebar:not(.collapsed) { position: absolute; z-index: 20; height: 100%; }
  .convo-sidebar { width: 220px; min-width: 220px; }
  .chat-msg { max-width: 100%; }
  .chat-input-wrap { max-width: 100%; }
  .chat-welcome { padding: 32px 16px; }
  .chat-bubble { padding: 10px 14px; font-size: 14px; line-height: 1.5; }
  .chat-input-area { padding: 8px 12px calc(12px + env(safe-area-inset-bottom, 0px)); }
  .chat-input-area textarea { font-size: 16px; min-height: 40px; }
  .tool-chat-panel.active { height: calc(100vh - 49px); margin: -12px; }
  .chat-toolbar { padding: 8px 12px !important; font-size: 12px; }
  .chat-toolbar button { min-height: 36px; }

  /* Inspector fullscreen overlay on mobile */
  #treeInspector {
    width: 100% !important; left: 0 !important; right: 0 !important;
    top: 48px !important; bottom: 0 !important; max-height: none !important;
    border-radius: 0 !important; position: fixed !important; z-index: 30 !important;
  }

  /* Tree floating toolbar wraps */
  #tool-tree > div[style*="position:absolute;top:12px"] {
    flex-wrap: wrap; gap: 6px;
  }
  #treeSearchInput { width: 180px !important; }

  /* Flip cards stack */
  .flip-card { flex-direction: column; gap: 10px; }
  .flip-info { min-width: auto; }
  .flip-chart { min-width: auto; width: 100%; }
  .flip-profit { text-align: left; min-width: auto; display: flex; gap: 12px; align-items: center; }

  /* Widget items — larger touch targets on mobile */
  .widget-list .widget-item-header { padding: 10px 12px; gap: 8px; min-height: 44px; }
  .widget-card-grid .widget-item-header { padding: 12px; gap: 10px; }

  /* Pick rows — 2-row layout on mobile */
  .pick-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto auto;
    gap: 2px 8px;
    padding: 10px 12px;
    align-items: center;
  }
  .pick-num { grid-row: 1 / 3; align-self: center; }
  .pick-name { grid-column: 2; font-size: 14px; }
  .pick-prices { grid-column: 2; font-size: 11px; min-width: auto; }
  .pick-margin { display: none; }
  .pick-profit { grid-column: 3; grid-row: 1 / 3; font-size: 13px; min-width: auto; text-align: right; }
  .pick-conf { grid-column: 3; grid-row: 1; display: none; }
  .widget-chevron { display: none; }

  /* Cycle rows — compact mobile */
  .cycle-header { flex-wrap: wrap; gap: 6px; padding: 10px 12px; min-height: 44px; }

  /* Admin tabs scroll */
  .admin-tabs { overflow-x: auto; padding: 0 12px; }
  .admin-tabs button { padding: 10px 14px; font-size: 12px; white-space: nowrap; }

  /* Recipe flow stack */
  .recipe-flow { flex-direction: column; align-items: center; }
  .recipe-arrow { transform: rotate(90deg); }

  /* Trending grid */
  .trending-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 6px; }

  /* Login box */
  .login-box { padding: 24px 16px; max-width: 90vw; }
  .login-box h1 { font-size: 22px; }
  .login-box input { width: 100%; margin-right: 0; margin-bottom: 8px; }
  .login-box button { width: 100%; }

  /* Modal */
  .modal-box { min-width: auto; width: 90vw; max-width: 360px; }

  /* Toast — above bottom nav */
  .toast { left: 12px; right: 12px; bottom: 64px; }

  /* Widget grid view */
  .widget-card-grid.view-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }

  /* Auto bar */
  .auto-bar { font-size: 11px; flex-wrap: wrap; }

  /* Pagination */
  .pagination { flex-wrap: wrap; }

  /* Browse list on tree */
  #treeBrowseList { max-width: calc(100% - 24px) !important; }
}

/* ═══ Responsive: Small Mobile ═══ */
@media (max-width: 480px) {
  .top-bar { padding: 6px 8px; gap: 6px; }
  .top-bar h1 { font-size: 12px; letter-spacing: 0.5px; }
  .top-tabs { gap: 0; }
  .top-tab { padding: 5px 8px; font-size: 10px; }

  .sidebar-item { padding: 5px 10px; font-size: 11px; gap: 4px; }

  .main-panel { padding: 8px; }
  h2 { font-size: 15px; }

  .stat-card { min-width: 70px; padding: 8px 10px; }
  .stat-card .value { font-size: 16px; }

  .dash-card-icon { width: 32px; height: 32px; }
  .dash-card-title { font-size: 12px; }

  .chat-bubble { padding: 6px 10px; font-size: 12px; }
  .chat-avatar { width: 26px; height: 26px; font-size: 12px; }
  .chat-msg { gap: 8px; }

  .flip-name { font-size: 13px; }
  .flip-profit .big { font-size: 15px; }

  .admin-tabs button { padding: 8px 10px; font-size: 11px; }

  .trending-grid { grid-template-columns: 1fr; }
  .widget-card-grid.view-grid { grid-template-columns: 1fr 1fr; }

  .login-box { padding: 20px 12px; }
  .login-box h1 { font-size: 20px; }

  #treeSearchInput { width: 140px !important; font-size: 11px !important; }

  /* Stack tree toolbar items vertically on very small screens */
  #tool-tree > div[style*="position:absolute;top:12px"] {
    flex-direction: column; align-items: flex-start;
  }

  .pick-header { padding: 8px 10px; gap: 2px 6px; }
  .pick-name { font-size: 13px; }
  .pick-profit { font-size: 12px; }
  .pick-expand { padding: 0 10px 10px; }
  .cycle-header { padding: 8px 10px; gap: 6px; min-height: 44px; }
  .widget-list .widget-item-header { padding: 8px 10px; }

  /* Tool controls — better spacing on small mobile */
  .tool-controls { gap: 8px; }
  .tool-controls .btn, .tool-controls button { min-height: 40px; font-size: 13px; }

  table { font-size: 12px; }
  th { padding: 6px 8px; font-size: 9px; }
  td { padding: 6px 8px; font-size: 12px; }
}

/* ═══════════════════════════════════════════════════════════════════
   MOBILE APP FEEL
   ═══════════════════════════════════════════════════════════════════ */

/* 1. Prevent iOS overscroll bounce — feels more native */
html, body {
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
}

/* 2. Tab switch animation — fade+slide in when panel becomes active */
@keyframes toolPanelIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.tool-area > .tool-panel.active {
  animation: toolPanelIn 0.18s ease;
}
/* Full-bleed panels (map, graph) skip the transform to avoid glitches */
.tool-area > .tool-panel.tool-fullbleed.active {
  animation: none;
}

/* 3. Tap feedback — press scale on all interactive elements */
@media (max-width: 900px) {
  button:active,
  .btn:active,
  .rail-item:active,
  .mobile-nav button:active,
  .mobile-chat-fab:active,
  .card[onclick]:active,
  [onclick]:active {
    transform: scale(0.96);
    opacity: 0.85;
    transition: transform 0.08s ease, opacity 0.08s ease;
  }

  /* Bottom nav active state — gold pop */
  .mobile-nav button:active {
    color: var(--gold);
    transform: scale(0.92);
  }

  /* Prevent transform on map/graph containers */
  .leaflet-container:active,
  canvas:active {
    transform: none !important;
  }

  /* Mobile nav active tab indicator — top bar like iOS */
  .mobile-nav button.active {
    color: var(--gold);
    position: relative;
  }
  .mobile-nav button.active::before {
    content: '';
    position: absolute;
    top: 0; left: 20%; right: 20%;
    height: 2px;
    background: var(--gold);
    border-radius: 0 0 2px 2px;
  }

  /* FAB pulse animation when chat has unread messages */
  .mobile-chat-fab.has-unread {
    animation: fabPulse 2s ease-in-out infinite;
  }
  @keyframes fabPulse {
    0%, 100% { box-shadow: 0 4px 16px rgba(200,170,110,0.3); }
    50%       { box-shadow: 0 4px 28px rgba(200,170,110,0.7); }
  }
}
