/* ── RESET ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #0b0c0e;
  --surface:     #111318;
  --elevated:    #181b22;
  --overlay:     #1e222c;
  --card:        #14161d;
  --card-hover:  #1a1e28;

  --accent:      #c8ff57;
  --accent-dim:  #9ecf2d;
  --accent-glow: rgba(200,255,87,0.12);
  --accent-alt:  #57d4ff;

  --text:        #f0f2f5;
  --text-2:      #8c92a4;
  --text-3:      #555c6e;
  --text-inv:    #0b0c0e;

  --border:      rgba(255,255,255,0.07);
  --border-acc:  rgba(200,255,87,0.35);

  --radius:      6px;
  --radius-lg:   10px;
  --ff:          'Syne', sans-serif;
  --ff-mono:     'Space Mono', monospace;

  --nav-h:       56px;
  --sidebar-w:   292px;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--ff);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── NAV ──────────────────────────────────────────────────────── */
.nav {
  display: flex; align-items: center; justify-content: space-between;
  height: var(--nav-h); padding: 0 28px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  background: rgba(11,12,14,0.9); backdrop-filter: blur(16px);
}
.nav-logo {
  font-size: 12px; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--text);
  text-decoration: none; border: 1px solid var(--border);
  padding: 5px 12px; border-radius: var(--radius);
  transition: border-color .2s, background .2s;
}
.nav-logo:hover { border-color: var(--accent); background: var(--accent-glow); }
.nav-links { display: flex; gap: 28px; }
.nav-links a {
  font-size: 12px; color: var(--text-2); text-decoration: none;
  letter-spacing: .04em; transition: color .2s;
}
.nav-links a:hover { color: var(--text); }

/* ── APP LAYOUT ───────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: calc(100vh - var(--nav-h) - 52px);
}

/* ── SIDEBAR ──────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: 28px 20px 32px;
  position: sticky;
  top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar-header { margin-bottom: 28px; }
.sidebar-title {
  font-size: 20px; font-weight: 700; line-height: 1.2; margin-bottom: 6px;
}
.sidebar-title em { font-style: normal; color: var(--accent); }
.sidebar-sub { font-size: 12px; color: var(--text-2); line-height: 1.5; }

/* ── CONTROL BLOCKS ───────────────────────────────────────────── */
.ctrl-block {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.ctrl-block:last-of-type { border-bottom: none; }

.ctrl-label {
  display: block; font-size: 11px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-2); margin-bottom: 10px;
}
.ctrl-label-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.ctrl-label-row .ctrl-label { margin-bottom: 0; }
.ctrl-value {
  font-size: 11px; font-family: var(--ff-mono);
  color: var(--accent); font-weight: 700;
}

/* ── TOGGLE GROUP ─────────────────────────────────────────────── */
.toggle-group {
  display: flex; gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
}
.toggle {
  flex: 1; border: none; background: transparent;
  color: var(--text-2); font-family: var(--ff);
  font-size: 12px; font-weight: 500;
  padding: 6px 4px; border-radius: 4px;
  cursor: pointer; transition: background .15s, color .15s;
}
.toggle:hover { color: var(--text); }
.toggle.active {
  background: var(--accent); color: var(--text-inv);
  font-weight: 700;
}

/* ── CUSTOM INPUT ─────────────────────────────────────────────── */
.custom-input-wrap {
  display: flex; align-items: center; gap: 8px;
  margin-top: 10px;
}
.custom-input-wrap.hidden { display: none; }
.custom-input {
  width: 80px; background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text); font-family: var(--ff-mono);
  font-size: 14px; font-weight: 700;
  padding: 7px 10px;
  outline: none; transition: border-color .15s;
  -moz-appearance: textfield;
}
.custom-input::-webkit-inner-spin-button,
.custom-input::-webkit-outer-spin-button { -webkit-appearance: none; }
.custom-input:focus { border-color: var(--accent); }
.custom-input-unit { font-size: 11px; color: var(--text-3); font-family: var(--ff-mono); }

/* ── TOOLTIP "?" ──────────────────────────────────────────────── */
.tip-q {
  position: absolute;
  top: 7px; right: 7px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--border);
  color: var(--text-3);
  font-size: 9px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  cursor: help;
  line-height: 1;
  z-index: 2;
  transition: background .15s, color .15s;
}
.tip-q:hover {
  background: rgba(255,255,255,0.12);
  color: var(--text);
}
.tip-q::after {
  content: attr(data-tip);
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  width: 190px;
  background: var(--elevated);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-lg);
  color: var(--text-2);
  font-size: 10px; font-weight: 400;
  line-height: 1.55;
  padding: 8px 10px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.15s, transform 0.15s;
  white-space: normal;
  letter-spacing: 0;
  text-transform: none;
  z-index: 20;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.tip-q:hover::after {
  opacity: 1;
  transform: translateY(0);
}
/* Density buttons: show ABOVE to avoid sidebar overflow-x clipping */
.tip-q--density::after {
  right: auto;
  left: 50%;
  top: auto;
  bottom: calc(100% + 6px);
  transform: translateX(-50%) translateY(4px);
  width: 160px;
}
.tip-q--density:hover::after {
  transform: translateX(-50%) translateY(0);
}

/* ── SCALE CARDS ──────────────────────────────────────────────── */
.scale-cards { display: flex; flex-direction: column; gap: 6px; }
.scale-card {
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer; text-align: left;
  position: relative;
  transition: border-color .15s, background .15s;
  color: var(--text-2);
}
.scale-card:hover { border-color: rgba(255,255,255,0.14); color: var(--text); }
.scale-card.active {
  border-color: var(--border-acc);
  background: linear-gradient(135deg, rgba(200,255,87,0.06), transparent);
  color: var(--text);
}
.scale-card-name {
  font-size: 13px; font-weight: 600; line-height: 1;
}
.scale-card.active .scale-card-name { color: var(--accent); }
.scale-card-desc {
  font-size: 10px; color: var(--text-3); letter-spacing: .03em;
  margin-bottom: 8px;
}
.scale-card.active .scale-card-desc { color: var(--text-2); }
.scale-preview {
  width: 64px; height: 20px;
  color: var(--text-3);
}
.scale-card.active .scale-preview { color: var(--accent-dim); }

/* ── SLIDER ───────────────────────────────────────────────────── */
.slider {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 3px;
  background: var(--elevated);
  border-radius: 99px;
  outline: none; cursor: pointer;
  transition: background .2s;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 0 3px rgba(200,255,87,0.2);
  transition: box-shadow .2s;
}
.slider::-webkit-slider-thumb:hover { box-shadow: 0 0 0 5px rgba(200,255,87,0.25); }
.slider::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); border: none; cursor: pointer;
}
.slider-marks {
  display: flex; justify-content: space-between;
  margin-top: 6px;
}
.slider-marks span { font-size: 10px; color: var(--text-3); font-family: var(--ff-mono); }

/* ── DENSITY BUTTONS ──────────────────────────────────────────── */
.density-group { display: flex; gap: 6px; }
.density-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  gap: 6px; padding: 10px 6px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer;
  color: var(--text-3); font-family: var(--ff);
  font-size: 10px; font-weight: 500; letter-spacing: .04em;
  position: relative;
  transition: border-color .15s, color .15s, background .15s;
}
.density-btn svg { width: 20px; height: 16px; }
.density-btn:hover { border-color: rgba(255,255,255,0.14); color: var(--text-2); }
.density-btn.active {
  border-color: var(--border-acc);
  background: var(--accent-glow);
  color: var(--accent);
}

/* ── GENERATE BUTTON ──────────────────────────────────────────── */
.btn-generate {
  width: 100%; display: flex; align-items: center; justify-content: center;
  gap: 8px;
  background: var(--accent); color: var(--text-inv);
  border: none; border-radius: var(--radius-lg);
  font-family: var(--ff); font-size: 13px; font-weight: 700;
  padding: 13px 20px; cursor: pointer;
  letter-spacing: .04em;
  transition: opacity .15s, transform .1s;
  margin-top: 8px;
}
.btn-generate:hover { opacity: .92; }
.btn-generate:active { transform: scale(.98); }

/* ── SPACING AREA ─────────────────────────────────────────────── */
.spacing-area {
  flex: 1; padding: 32px 36px;
  overflow-y: auto;
}

/* ── EMPTY STATE ──────────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 14px;
  min-height: 420px; text-align: center;
}
.empty-icon { margin-bottom: 4px; }
.empty-title { font-size: 15px; font-weight: 600; color: var(--text-2); }
.empty-sub { font-size: 12px; color: var(--text-3); line-height: 1.6; }
.empty-sub strong { color: var(--text-2); font-weight: 600; }

/* ── RESULTS ──────────────────────────────────────────────────── */
.results.hidden { display: none; }

.results-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.results-label {
  font-size: 16px; font-weight: 700;
}
.results-desc {
  font-size: 12px; color: var(--text-2);
  margin-left: 10px;
  font-family: var(--ff-mono);
}

.btn-figma {
  display: flex; align-items: center; gap: 7px;
  background: var(--elevated); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-2);
  font-family: var(--ff); font-size: 12px; font-weight: 600;
  padding: 8px 16px; cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.btn-figma:hover {
  border-color: var(--border-acc);
  color: var(--accent);
  background: var(--accent-glow);
}
.btn-figma.copied {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

/* ── SECTIONS ─────────────────────────────────────────────────── */
.section {
  margin-bottom: 40px;
  padding-block: inherit !important;
}
.section-header {
  display: flex; align-items: baseline; gap: 12px;
  margin-bottom: 16px;
}
.section-title {
  font-size: 11px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-2);
}
.section-hint {
  font-size: 11px; font-family: var(--ff-mono);
  color: var(--text-3);
}

/* ── TOKEN LIST ───────────────────────────────────────────────── */
.token-list {
  display: flex; flex-direction: column; gap: 6px;
}
.token-row {
  display: grid;
  grid-template-columns: 100px 54px 1fr 54px;
  align-items: center; gap: 14px;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: background .15s, border-color .15s;
  animation: row-in .35s ease both;
}
.token-row:hover {
  background: var(--card-hover);
  border-color: rgba(255,255,255,0.1);
}
@keyframes row-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.token-name {
  font-family: var(--ff-mono); font-size: 12px; font-weight: 700;
  color: var(--text);
}
.token-size {
  font-family: var(--ff-mono); font-size: 11px;
  color: var(--accent); font-weight: 700;
  text-align: right;
}
.token-bar-wrap {
  background: var(--elevated); border-radius: 99px;
  height: 6px; overflow: hidden;
}
.token-bar {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  transform-origin: left;
  animation: bar-in .5s cubic-bezier(.22,1,.36,1) both;
}
@keyframes bar-in {
  from { transform: scaleX(0); opacity: 0; }
  to   { transform: scaleX(1); opacity: 1; }
}
.token-px {
  font-family: var(--ff-mono); font-size: 11px;
  color: var(--text-3); text-align: right;
}

/* ── FIGMA VARIABLES GRID ─────────────────────────────────────── */
.var-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.var-group {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.var-group-label {
  display: flex; flex-direction: column; gap: 1px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--elevated);
}
.var-group-path {
  font-size: 10px; color: var(--text-3); font-family: var(--ff-mono);
}
.var-group-name {
  font-size: 13px; font-weight: 700; color: var(--text);
}
.var-rows { padding: 8px 0; }
.var-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 16px;
  transition: background .12s;
}
.var-row:hover { background: var(--card-hover); }
.var-row-name {
  font-size: 12px; color: var(--text-2); font-family: var(--ff-mono);
}
.var-row-val {
  font-size: 11px; font-family: var(--ff-mono);
  color: var(--accent-alt); font-weight: 700;
}

/* ── TOAST ────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(12px);
  background: var(--elevated); border: 1px solid var(--border);
  border-radius: 99px; padding: 9px 18px;
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600;
  opacity: 0 !important; transition: opacity .25s, transform .25s;
  pointer-events: none; z-index: 999;
}
.toast.show { opacity: 1 !important; transform: translateX(-50%) translateY(0) !important; }

/* ── FOOTER ───────────────────────────────────────────────────── */
.footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px;
  border-top: 1px solid var(--border);
  font-size: 11px; color: var(--text-3);
}
.footer-links { display: flex; gap: 20px; }
.footer-links a { color: var(--text-3); text-decoration: none; transition: color .2s; }
.footer-links a:hover { color: var(--text-2); }

/* ── HIDDEN UTIL ──────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── RESPONSIVE ───────────────────────────────────────────────── */
@media (max-width: 900px) {
  .var-grid { grid-template-columns: 1fr; }
  .spacing-area { padding: 24px 20px; }
}
@media (max-width: 720px) {
  .app-layout { flex-direction: column; }
  .results-meta { display: none; }
  .btn-figma {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .sidebar {
    width: 100%; position: static; height: auto;
    border-right: none; border-bottom: 1px solid var(--border);
  }
  .token-row { grid-template-columns: 90px 48px 1fr 48px; }
}
