
/* ── Layout shell ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  color: var(--fg-default);
  background: var(--bg-default);
  -webkit-font-smoothing: antialiased;
}

/* ── Sidebar nav ──────────────────────────────────────────── */
#sidebar {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: 240px; background: #fff;
  border-right: 1px solid var(--border-default);
  overflow-y: auto; z-index: 100;
  display: flex; flex-direction: column;
}
#sidebar .logo-row {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border-default);
}
#sidebar .logo-row img { width: 32px; height: 32px; border-radius: 6px; }
#sidebar .logo-row span { font-weight: 700; font-size: 15px; letter-spacing: -.015em; }
#sidebar nav { padding: 12px 0; flex: 1; }
#sidebar .section-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .08em; color: var(--fg-tertiary);
  padding: 14px 20px 4px;
}
#sidebar a {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 20px; font-size: 14px; color: var(--fg-secondary);
  text-decoration: none; border-left: 2px solid transparent;
  transition: color 120ms, background 120ms;
}
#sidebar a:hover, #sidebar a.active {
  color: var(--fg-default); background: var(--bg-secondary);
}
#sidebar a.active { border-left-color: #7f00ff; color: #7f00ff; font-weight: 500; }
#sidebar a svg { flex-shrink: 0; }
#sidebar .version {
  padding: 16px 20px; font-family: var(--font-mono);
  font-size: 11px; color: var(--fg-tertiary);
  border-top: 1px solid var(--border-default);
}

/* ── Main content ─────────────────────────────────────────── */
#main {
  margin-left: 240px;
  min-height: 100vh;
}

/* ── Section containers ───────────────────────────────────── */
.ds-section {
  padding: 64px 56px;
  border-bottom: 1px solid var(--border-default);
}
.ds-section:last-child { border-bottom: none; }
.section-hero {
  margin-bottom: 48px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border-default);
}
.section-hero h1 {
  font-size: 40px; font-weight: 700; letter-spacing: -.025em;
  margin: 0 0 8px; line-height: 1.1;
}
.section-hero p {
  font-size: 17px; color: var(--fg-secondary); margin: 0; line-height: 1.55;
}

/* ── Subsection headers ───────────────────────────────────── */
.sub-heading {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .08em; color: var(--fg-tertiary);
  margin: 48px 0 16px; display: flex; align-items: center; gap: 8px;
}
.sub-heading::after {
  content: ""; flex: 1; height: 1px; background: var(--border-default);
}
h3.block-title {
  font-size: 16px; font-weight: 600; margin: 0 0 12px; letter-spacing: -.01em;
}

/* ── Component demo boxes ─────────────────────────────────── */
.demo-box {
  border: 1px solid var(--border-default);
  border-radius: 12px; overflow: hidden;
}
.demo-box .demo-canvas {
  padding: 32px 24px;
  background: var(--bg-secondary);
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
}
.demo-box .demo-canvas.dark { background: #2b0057; }
.demo-box .demo-canvas.white { background: #fff; }
.demo-box .demo-label {
  padding: 8px 14px;
  background: #fff;
  border-top: 1px solid var(--border-default);
  font-family: var(--font-mono); font-size: 11px;
  color: var(--fg-tertiary); display: flex; gap: 12px;
}
.demo-label b { color: var(--fg-secondary); font-weight: 600; font-family: var(--font-sans); font-size: 11px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 24px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ── Tokens table ─────────────────────────────────────────── */
.token-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.token-table th {
  text-align: left; font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--fg-secondary); padding: 8px 12px;
  border-bottom: 1px solid var(--border-default);
}
.token-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-default);
  vertical-align: middle;
}
.token-table tr:last-child td { border-bottom: none; }
.token-table code {
  font-family: var(--font-mono); font-size: 12px;
  background: var(--bg-secondary);
  padding: 2px 6px; border-radius: 4px;
  color: #7f00ff;
}
.swatch-dot {
  width: 24px; height: 24px; border-radius: 6px;
  border: 1px solid rgba(0,0,0,.1); display: inline-block;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  font-family: var(--font-sans); font-size: 16px; line-height: 1;
  padding: 12px 16px; border-radius: 8px; border: 1px solid transparent;
  cursor: pointer; display: inline-flex; gap: 8px;
  align-items: center; justify-content: center;
  transition: background 120ms ease, border-color 120ms ease;
  text-decoration: none; user-select: none; white-space: nowrap;
}
.btn--primary { background: #7f00ff; border-color: #7f00ff; color: #fff; }
.btn--primary:hover { background: #51158c; }
.btn--neutral { background: #e3e3e3; border-color: #767676; color: #1e1e1e; }
.btn--neutral:hover { background: #d9d9d9; }
.btn--subtle  { background: transparent; color: #303030; }
.btn--subtle:hover { background: #ececec; }
.btn--danger  { background: #c00f0c; border-color: #c00f0c; color: #fff; }
.btn--danger:hover { background: #900b09; }
.btn--sm { padding: 8px 12px; font-size: 14px; }
.btn--lg { padding: 14px 20px; }
.btn:disabled { background: #d9d9d9; border-color: #d9d9d9; color: #b3b3b3; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; stroke: currentColor; flex-shrink: 0; }

/* ── Inputs ───────────────────────────────────────────────── */
.field-group { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 14px; font-weight: 500; color: var(--fg-default); }
.field {
  font-family: var(--font-sans); font-size: 16px; line-height: 1;
  padding: 12px 14px; border-radius: 8px;
  border: 1px solid #767676; background: #fff;
  color: var(--fg-default); outline: none; width: 100%;
}
.field:focus { border-color: #7f00ff; box-shadow: 0 0 0 2px rgba(127,0,255,.15); }
.field::placeholder { color: var(--fg-tertiary); }
.field--error { border-color: #ec221f; }
.field--disabled { background: var(--bg-secondary); color: var(--fg-disabled); cursor: not-allowed; }
.field-hint { font-size: 12px; color: var(--fg-tertiary); }
.field-hint--error { color: #c00f0c; }

/* ── Tags ─────────────────────────────────────────────────── */
.tag {
  font-size: 12px; line-height: 1; padding: 6px 10px;
  border-radius: 9999px; border: 1px solid;
  display: inline-flex; gap: 6px; align-items: center;
}
.tag svg { width: 12px; height: 12px; stroke: currentColor; }
.tag--neutral { background: #f5f5f5; border-color: #d9d9d9; color: #1e1e1e; }
.tag--brand   { background: #f2e6ff; border-color: #b163ff; color: #51158c; }
.tag--danger  { background: #fee9e7; border-color: #ec221f; color: #900b09; }
.tag--warning { background: #fffbeb; border-color: #bf6a02; color: #522504; }
.tag--success { background: #e6f4ea; border-color: #2f9e44; color: #15803d; }
.tag--solid   { background: #7f00ff; border-color: #7f00ff; color: #fff; }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: #fff; border: 1px solid var(--border-default);
  border-radius: 8px; padding: 20px;
}
.card--elevated { box-shadow: var(--shadow-300); }

/* ── Notification/alert ───────────────────────────────────── */
.alert {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px; border: 1px solid; border-radius: 8px;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert .alert-body { flex: 1; font-size: 14px; line-height: 1.4; }
.alert .alert-body b { display: block; font-weight: 600; margin-bottom: 2px; }
.alert--info    { background: #f5f5f5; border-color: #d9d9d9; color: #1e1e1e; }
.alert--success { background: #e6f4ea; border-color: #2f9e44; color: #15803d; }
.alert--warning { background: #fffbeb; border-color: #bf6a02; color: #522504; }
.alert--danger  { background: #fee9e7; border-color: #ec221f; color: #900b09; }

/* ── Avatar ───────────────────────────────────────────────── */
.ava {
  border-radius: 9999px; background: #d9d9d9;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; color: #303030;
  border: 1px solid rgba(0,0,0,.08); flex-shrink: 0;
}
.ava--dark  { background: #2c2c2c; color: #f5f5f5; border-color: #2c2c2c; }
.ava--brand { background: #f2e6ff; color: #51158c; border-color: #b163ff; }
.ava-stack  { display: inline-flex; }
.ava-stack .ava { margin-left: -8px; border: 2px solid #fff; }
.ava-stack .ava:first-child { margin-left: 0; }

/* ── Tabs ─────────────────────────────────────────────────── */
.tab-bar {
  display: flex; border-bottom: 1px solid var(--border-default); gap: 0;
}
.tab-bar button {
  background: none; border: none; cursor: pointer;
  font-family: var(--font-sans); font-size: 14px;
  padding: 10px 16px; color: var(--fg-secondary);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color 120ms;
}
.tab-bar button:hover { color: var(--fg-default); }
.tab-bar button.active { color: #7f00ff; border-bottom-color: #7f00ff; font-weight: 500; }

/* ── Accordion ────────────────────────────────────────────── */
.accordion { border: 1px solid var(--border-default); border-radius: 8px; overflow: hidden; }
.accordion summary {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; font-size: 15px; font-weight: 500;
  cursor: pointer; list-style: none; background: #fff;
  border-bottom: 1px solid var(--border-default);
}
.accordion summary::-webkit-details-marker { display: none; }
details[open] > summary { background: var(--bg-secondary); }
.accordion .accordion-body {
  padding: 14px 16px; font-size: 14px; line-height: 1.55;
  color: var(--fg-secondary); border-bottom: 1px solid var(--border-default);
}
details:last-child > summary { border-bottom: none; }
details[open]:last-child > summary { border-bottom: 1px solid var(--border-default); }
details:last-child .accordion-body { border-bottom: none; }

/* ── Menu ─────────────────────────────────────────────────── */
.menu {
  background: #fff; border: 1px solid var(--border-default);
  border-radius: 8px; box-shadow: var(--shadow-300);
  overflow: hidden; min-width: 180px;
}
.menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; font-size: 14px; color: var(--fg-default);
  cursor: pointer;
}
.menu-item:hover { background: var(--bg-secondary); }
.menu-item svg { width: 16px; height: 16px; color: var(--fg-secondary); }
.menu-sep { height: 1px; background: var(--border-default); margin: 4px 0; }
.menu-item--danger { color: #c00f0c; }
.menu-item--danger:hover { background: #fee9e7; }

/* ── Tooltip ──────────────────────────────────────────────── */
.tooltip-wrap { position: relative; display: inline-block; }
.tooltip {
  position: absolute; bottom: calc(100% + 8px); left: 50%;
  transform: translateX(-50%);
  background: #1e1e1e; color: #f5f5f5;
  font-size: 12px; padding: 6px 10px; border-radius: 6px;
  white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity 120ms;
}
.tooltip::after {
  content: ""; position: absolute; top: 100%; left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: #1e1e1e;
}
.tooltip-wrap:hover .tooltip { opacity: 1; }

/* ── Pagination ───────────────────────────────────────────── */
.pagination { display: flex; gap: 4px; align-items: center; }
.page-btn {
  width: 36px; height: 36px; border-radius: 8px;
  border: 1px solid var(--border-default); background: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-sans); font-size: 14px; cursor: pointer;
  color: var(--fg-default); transition: all 120ms;
}
.page-btn:hover { background: var(--bg-secondary); }
.page-btn.active { background: #7f00ff; border-color: #7f00ff; color: #fff; }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Dialog ───────────────────────────────────────────────── */
.dialog-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; opacity: 0; pointer-events: none; transition: opacity 200ms;
}
.dialog-backdrop.open { opacity: 1; pointer-events: all; }
.dialog {
  background: #fff; border-radius: 12px; padding: 28px;
  max-width: 480px; width: calc(100% - 40px);
  box-shadow: var(--shadow-600);
  transform: translateY(12px); transition: transform 200ms;
}
.dialog-backdrop.open .dialog { transform: translateY(0); }
.dialog h3 { margin: 0 0 8px; font-size: 20px; font-weight: 600; }
.dialog p  { margin: 0 0 24px; font-size: 15px; color: var(--fg-secondary); line-height: 1.5; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ── Color palette cards ──────────────────────────────────── */
.color-ramp { display: flex; border-radius: 10px; overflow: hidden; border: 1px solid var(--border-default); }
.color-chip {
  flex: 1; aspect-ratio: 3/4;
  display: flex; flex-direction: column;
  justify-content: flex-end; padding: 8px;
  font-family: var(--font-mono); font-size: 10px; line-height: 1.3;
}
.color-chip .cn { font-weight: 600; }
.color-chip .ch { opacity: .75; }

/* ── Type specimen ────────────────────────────────────────── */
.type-row {
  display: grid; grid-template-columns: 200px 1fr;
  gap: 24px; align-items: baseline;
  padding: 14px 0; border-bottom: 1px solid var(--border-default);
}
.type-row:last-child { border-bottom: none; }
.type-meta { font-family: var(--font-mono); font-size: 11px; color: var(--fg-tertiary); line-height: 1.5; }
.type-meta b { display: block; font-family: var(--font-sans); font-size: 12px; font-weight: 600; color: var(--fg-secondary); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }

/* ── Spacing scale ────────────────────────────────────────── */
.space-row { display: grid; grid-template-columns: 120px 60px 1fr; gap: 12px; align-items: center; margin-bottom: 10px; }
.space-bar { height: 10px; background: #7f00ff; border-radius: 2px; }

/* ── Changelog ────────────────────────────────────────────── */
.cl-entry { display: grid; grid-template-columns: 120px 1fr; gap: 24px; padding: 24px 0; border-bottom: 1px solid var(--border-default); }
.cl-entry:last-child { border-bottom: none; }
.cl-date { font-family: var(--font-mono); font-size: 12px; color: var(--fg-tertiary); padding-top: 4px; }
.cl-title { font-size: 18px; font-weight: 600; margin: 0 0 8px; }
.cl-body { font-size: 14px; color: var(--fg-secondary); line-height: 1.55; }
.cl-body ul { margin: 8px 0; padding-left: 20px; }
.cl-body li { margin-bottom: 4px; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  #sidebar { width: 100%; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--border-default); }
  #main { margin-left: 0; }
  .ds-section { padding: 40px 24px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .type-row { grid-template-columns: 1fr; }
  .cl-entry { grid-template-columns: 1fr; gap: 8px; }
}
