:root {
  --accent-1: #63DEE6;
  --accent-2: #5485E0;
  --bg: #14161f;
  --bg-elevated: #1b1e2b;
  --bg-card: #20232f;
  --border: #2c2f3d;
  --text: #e7e9f2;
  --text-dim: #9a9dae;
  --text-faint: #6b6e7f;
  --radius: 10px;
  --sidebar-w: 250px;
  --topbar-h: 60px;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f5fa;
    --bg-elevated: #ffffff;
    --bg-card: #ffffff;
    --border: #e1e3ee;
    --text: #1c1e2a;
    --text-dim: #565a6e;
    --text-faint: #8a8ea3;
    color-scheme: light;
  }
}

:root[data-theme="dark"] {
  --bg: #14161f;
  --bg-elevated: #1b1e2b;
  --bg-card: #20232f;
  --border: #2c2f3d;
  --text: #e7e9f2;
  --text-dim: #9a9dae;
  --text-faint: #6b6e7f;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f4f5fa;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --border: #e1e3ee;
  --text: #1c1e2a;
  --text-dim: #565a6e;
  --text-faint: #8a8ea3;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  overflow-x: hidden;
}

a { color: inherit; }

code {
  font-family: "Cascadia Code", "Consolas", monospace;
  background: rgba(120, 130, 170, 0.15);
  padding: 0.1em 0.4em;
  border-radius: 5px;
  font-size: 0.92em;
}

.app { min-height: 100vh; display: flex; flex-direction: column; }

/* Topbar */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.burger {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
}

.brand { display: flex; align-items: baseline; gap: 8px; white-space: nowrap; }
.brand-gem {
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 22px;
}
.brand-text {
  font-weight: 700;
  font-size: 18px;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-sub { color: var(--text-faint); font-size: 13px; }

.topbar-search { flex: 1; display: flex; justify-content: flex-end; }
.topbar-search input {
  width: min(360px, 100%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
}
.topbar-search input:focus { outline: 1px solid var(--accent-2); }

/* Layout */
.layout { display: flex; flex: 1; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  padding: 18px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
}

.nav-link {
  text-decoration: none;
  color: var(--text-dim);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14.5px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.nav-link:hover { background: rgba(120, 130, 170, 0.12); color: var(--text); }
.nav-link.active {
  background: linear-gradient(135deg, rgba(99,222,230,0.16), rgba(84,133,224,0.16));
  color: var(--text);
  box-shadow: inset 3px 0 0 var(--accent-2);
}

.sidebar-footer {
  margin-top: auto;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text-faint);
}

.content {
  flex: 1;
  padding: 32px 40px 80px;
  max-width: 980px;
  width: 100%;
}

.page { display: none; }
.page.active { display: block; animation: fadein 0.2s ease; }

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

h1 {
  font-size: 28px;
  margin: 0 0 20px;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  display: inline-block;
}

h2 { font-size: 18px; margin: 0 0 14px; }
h3 { font-size: 16px; margin: 0 0 8px; }

.page-intro { color: var(--text-dim); margin: -8px 0 22px; line-height: 1.6; max-width: 70ch; }

/* Hero */
.hero {
  padding: 28px;
  border-radius: var(--radius);
  background: radial-gradient(circle at 20% 20%, rgba(99,222,230,0.14), transparent 60%),
              radial-gradient(circle at 80% 80%, rgba(84,133,224,0.14), transparent 60%),
              var(--bg-card);
  border: 1px solid var(--border);
  margin-bottom: 26px;
}
.hero h1 { font-size: 34px; margin-bottom: 10px; }
.hero-tagline { color: var(--text-dim); line-height: 1.7; max-width: 65ch; margin: 0 0 16px; }
.hero-badges { display: flex; gap: 8px; flex-wrap: wrap; }
.badge {
  font-size: 12.5px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(120,130,170,0.14);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.badge-accent {
  background: linear-gradient(135deg, rgba(99,222,230,0.2), rgba(84,133,224,0.2));
  color: var(--text);
  border-color: transparent;
}

/* Cards grid */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: transform 0.15s, border-color 0.15s;
}
.card:hover { transform: translateY(-2px); border-color: var(--accent-2); }
.card p { color: var(--text-dim); font-size: 13.5px; line-height: 1.6; margin: 0 0 10px; }
.card-link {
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--accent-2);
}

/* Panels */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 18px;
}

.steps { margin: 0; padding-left: 20px; color: var(--text-dim); line-height: 2; }
.steps strong { color: var(--text); }

.check-list { margin: 0; padding-left: 20px; line-height: 2; color: var(--text-dim); }

.code-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 13.5px;
}
.code-block code { background: none; padding: 0; }

.alias { color: var(--text-faint); font-size: 13px; font-weight: 400; }

/* Tables */
.cmd-table, .rarity-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.cmd-table th, .cmd-table td,
.rarity-table th, .rarity-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.cmd-table th, .rarity-table th {
  color: var(--text-faint);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.cmd-table tr:last-child td, .rarity-table tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; margin-bottom: 18px; }

.rarity-swatch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}
.rarity-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 8px currentColor;
}

.weight-bars { display: flex; flex-direction: column; gap: 8px; }
.weight-row { display: grid; grid-template-columns: 110px 1fr 70px; align-items: center; gap: 10px; font-size: 13px; }
.weight-track { background: var(--bg); border-radius: 6px; height: 10px; overflow: hidden; border: 1px solid var(--border); }
.weight-fill { height: 100%; border-radius: 6px; }
.weight-pct { text-align: right; color: var(--text-dim); font-variant-numeric: tabular-nums; }

/* Toolbar / search / chips */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}
#gem-search {
  flex: 1;
  min-width: 220px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 14px;
}
#gem-search:focus { outline: 1px solid var(--accent-2); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s;
}
.chip:hover { color: var(--text); }
.chip.active {
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  color: #0c1220;
  border-color: transparent;
}

/* Gem cards */
.grid-gems {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}
.gem-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--gem-color, var(--accent-2));
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}
.gem-card:hover { transform: translateY(-2px); }
.gem-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.gem-card-name { font-weight: 700; font-size: 14.5px; color: var(--gem-color, var(--text)); }
.gem-card-cat { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
.gem-card-lore { font-size: 12.5px; color: var(--text-dim); line-height: 1.5; margin: 0 0 10px; min-height: 38px; }
.gem-card-meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 11.5px; }
.tag {
  background: rgba(120,130,170,0.14);
  border-radius: 6px;
  padding: 3px 7px;
  color: var(--text-dim);
}

.empty-state { color: var(--text-faint); text-align: center; padding: 40px 0; }
.hidden { display: none !important; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(6,8,14,0.6);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  padding: 20px;
}
.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 14px;
  max-width: 520px;
  width: 100%;
  padding: 26px;
  position: relative;
  max-height: 85vh;
  overflow-y: auto;
}
.modal-close {
  position: absolute; top: 14px; right: 14px;
  background: none; border: none;
  color: var(--text-dim); font-size: 20px;
  cursor: pointer;
}
.modal h2 { font-size: 20px; margin-bottom: 4px; }
.modal .modal-id { color: var(--text-faint); font-size: 12.5px; margin-bottom: 16px; }
.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  font-size: 13px;
  margin-top: 16px;
}
.modal-grid div { background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.modal-grid .label { color: var(--text-faint); font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 4px; }
.modal-grid .value { font-weight: 600; }
.modal-hint { font-size: 12.5px; color: var(--text-faint); margin: 14px 0 0; }
.modal-hint a { color: var(--accent-2); font-weight: 600; text-decoration: none; }

/* Calculator */
.calc-panel { max-width: 640px; }
.calc-controls { display: flex; flex-direction: column; gap: 16px; margin-bottom: 20px; }
.calc-controls label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-dim); font-weight: 600; }
.calc-controls select, .calc-controls input[type="range"] {
  font-family: inherit;
}
.calc-controls select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 14px;
}
.calc-controls input[type="range"] { accent-color: var(--accent-2); }

.calc-result { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.calc-stat {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  text-align: center;
}
.calc-stat-label { font-size: 12px; color: var(--text-faint); margin-bottom: 8px; }
.calc-stat-value {
  font-size: 26px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.calc-formula { font-size: 12.5px; color: var(--text-faint); text-align: center; }

/* FAQ */
.faq-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 10px;
}
.faq-item summary { cursor: pointer; font-weight: 600; font-size: 14.5px; }
.faq-item p { color: var(--text-dim); line-height: 1.7; margin: 10px 0 0; font-size: 13.5px; }

/* Responsive */
@media (max-width: 860px) {
  .burger { display: block; }
  .sidebar {
    position: fixed;
    left: 0;
    top: var(--topbar-h);
    height: calc(100vh - var(--topbar-h));
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 60;
    box-shadow: 4px 0 16px rgba(0,0,0,0.3);
  }
  .sidebar.open { transform: translateX(0); }
  .content { padding: 22px 18px 60px; }
  .topbar-search input { width: 100%; }
  .topbar { gap: 10px; }
  .brand-sub { display: none; }
  .modal-grid { grid-template-columns: 1fr; }
}
