:root {
  --page: #05080a;
  --surface: #11161c;
  --surface-subtle: #151b22;
  --surface-muted: #1c232c;
  --line: #252d36;
  --line-strong: #343f4b;
  --text: #eef3f7;
  --text-soft: #a8b2bd;
  --text-muted: #687480;
  --primary: #3366ff;
  --primary-weak: #edf2ff;
  --success: #16a36f;
  --warning: #d98312;
  --danger: #d93025;
  --ink: #f6fafc;
  --canvas-tint: rgba(17, 22, 28, 0.76);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-pop: 0 16px 48px rgba(30, 41, 59, 0.10);
  --local-font: "Avenir Next", "SF Pro Text", "PingFang SC", sans-serif;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: var(--local-font);
  font-size: 14px;
  letter-spacing: 0;
}

body[data-default-mode="light"] {
  --page: #f4f5f3;
  --surface: #ffffff;
  --surface-subtle: #fafbfc;
  --surface-muted: #f0f2f5;
  --line: #e3e6eb;
  --line-strong: #cfd5de;
  --text: #171a1f;
  --text-soft: #5d6675;
  --text-muted: #8892a2;
  --ink: #101418;
  color-scheme: light;
  background: var(--page);
}

body[data-default-mode="light"] .sidebar {
  border-right: 1px solid rgba(20, 26, 33, 0.12);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.96), rgba(248,249,250,0.94)),
    var(--surface);
  box-shadow: 10px 0 30px rgba(24, 32, 43, 0.04);
}

body[data-default-mode="light"] .hero-band {
  border-color: rgba(20, 26, 33, 0.10);
  background:
    linear-gradient(135deg, rgba(255,255,255,0.94), rgba(255,255,255,0.68)),
    radial-gradient(circle at 84% 16%, var(--primary-weak), transparent 34%);
  box-shadow: var(--shadow-pop);
}

body[data-default-mode="light"] .history-panel {
  border: 0;
  background: transparent;
  box-shadow: none;
}

body[data-default-mode="light"] .doc-section,
body[data-default-mode="light"] .doc-heading {
  border-color: #ececef;
  background: #ffffff;
}

body[data-default-mode="light"] .timeline-item {
  border-color: rgba(20, 26, 33, 0.08);
}

body[data-default-mode="light"] .timeline-item.active {
  background: rgba(var(--primary-rgb, 101, 51, 232), 0.06);
}

body[data-default-mode="light"] .history-divider {
  background: rgba(20, 26, 33, 0.08);
}

body[data-default-mode="light"] .panel,
body[data-default-mode="light"] .font-card,
body[data-default-mode="light"] .type-scale-card,
body[data-default-mode="light"] .color-category,
body[data-default-mode="light"] .shape-item,
body[data-default-mode="light"] .spacing-item,
body[data-default-mode="light"] .figma-var {
  border-color: rgba(20, 26, 33, 0.10);
  background: #ffffff;
}

body[data-default-mode="light"] input[type="text"],
body[data-default-mode="light"] select,
body[data-default-mode="light"] textarea {
  border-color: #dfe4ea;
  background-color: rgba(255,255,255,0.88);
  color: var(--text);
}

body[data-default-mode="light"] input[type="color"] {
  border-color: #dfe4ea;
  background: #ffffff;
}

body[data-default-mode="light"] .pipeline span,
body[data-default-mode="light"] .action-button {
  background: #fff;
}

body[data-default-mode="light"] .font-card > strong,
body[data-default-mode="light"] .weight-grid b,
body[data-default-mode="light"] .type-scale-row strong {
  color: #111827;
}

body[data-default-mode="light"] .token-row.header {
  background: #f3f5f7;
  color: #697586;
}

body[data-default-mode="light"] .category-heading,
body[data-default-mode="light"] .type-scale-head {
  border-color: #e3e6eb;
}

body[data-default-mode="light"] .type-spec {
  color: #111827;
}

body[data-default-mode="light"] .type-scale-head span,
body[data-default-mode="light"] .type-level {
  color: #8390a2;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  min-height: 100vh;
  /* sidebar width kept in sync with the .app-shell override below */
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 22px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(13,18,23,0.98), rgba(8,12,15,0.96)),
    var(--surface);
  box-shadow: 10px 0 30px rgba(0, 0, 0, 0.22);
  scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
  scrollbar-width: thin;
}

.sidebar::-webkit-scrollbar {
  width: 12px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  border: 4px solid transparent;
  border-radius: 999px;
  background-clip: content-box;
  background-color: rgba(255, 255, 255, 0.22);
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background-color: rgba(255, 255, 255, 0.34);
}

body[data-default-mode="light"] .sidebar {
  scrollbar-color: rgba(17, 24, 39, 0.18) transparent;
}

body[data-default-mode="light"] .sidebar::-webkit-scrollbar-thumb {
  background-color: rgba(17, 24, 39, 0.18);
}

body[data-default-mode="light"] .sidebar::-webkit-scrollbar-thumb:hover {
  background-color: rgba(17, 24, 39, 0.28);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
}

.brand h1 {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
}

.brand p {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 12px;
}

.action-button,
.ghost-button,
.primary-button {
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-soft);
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.panel {
  padding: 16px;
  margin-bottom: 14px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-lg);
  background: rgba(18, 24, 31, 0.72);
  backdrop-filter: blur(12px);
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  color: var(--text-soft);
  font-size: 13px;
}

.panel-title strong {
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 700;
}

.project-list,
.version-list {
  display: grid;
  gap: 8px;
}

.project-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(8,12,16,0.50);
}

.project-item > button:first-child {
  display: grid;
  gap: 5px;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.project-item.active {
  border-color: rgba(78,255,175,0.38);
  background: rgba(78,255,175,0.08);
}

.project-delete {
  height: 28px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
}

.project-delete:hover {
  border-color: rgba(217,48,37,0.28);
  background: rgba(217,48,37,0.10);
  color: #ff6b61;
}

.project-item span,
.version-item span,
.version-item p,
.empty-state {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
}

.import-button {
  display: grid;
  place-items: center;
  height: 34px;
  margin-top: 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  color: var(--text-soft);
  cursor: pointer;
}

.import-button input {
  display: none;
}

.version-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(8,12,16,0.42);
  cursor: pointer;
  transition: border-color 0.15s;
}

.version-item.active {
  border: 1px solid var(--primary);
  background: rgba(var(--primary-rgb, 101, 51, 232), 0.06);
}

.version-delete {
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  opacity: 0;
  transition: opacity 160ms ease, background 160ms ease, color 160ms ease;
}

.version-item:hover .version-delete {
  opacity: 1;
}

.version-delete:hover {
  background: rgba(217, 48, 37, 0.12);
  color: var(--danger);
}

body[data-default-mode="light"] .project-item,
body[data-default-mode="light"] .version-item {
  background: rgba(255,255,255,0.72);
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field:last-child {
  margin-bottom: 0;
}

.field span {
  color: var(--text-soft);
  font-size: 13px;
}

.field-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.field em {
  color: var(--text-muted);
  font-size: 12px;
  font-style: normal;
}

input[type="text"],
select,
textarea {
  width: 100%;
  border: 1px solid #2a3440;
  border-radius: var(--radius-md);
  background: rgba(8, 12, 16, 0.72);
  color: var(--text);
  outline: none;
}

input[type="text"],
select {
  height: 36px;
  padding: 0 10px;
}

select {
  appearance: none;
  padding-right: 38px;
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 12px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

input[type="text"]:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(51, 102, 255, 0.12);
}

/* ===== Custom dropdown (progressive enhancement over native <select>) ===== */
.cs-field {
  position: relative;
  width: 100%;
}

.cs-native {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}

.cs-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

body[data-default-mode="light"] .cs-trigger {
  border-color: #dfe4ea;
  background: rgba(255, 255, 255, 0.9);
}

.cs-trigger:hover {
  border-color: var(--line-strong);
}

.cs-field.cs-open .cs-trigger,
.cs-trigger:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb, 51,102,255), 0.12);
  outline: none;
}

.cs-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cs-arrow {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--text-muted);
  border-bottom: 1.5px solid var(--text-muted);
  transform: rotate(45deg) translate(-1px, -1px);
  transition: transform 0.18s ease;
}

.cs-field.cs-open .cs-arrow {
  transform: rotate(-135deg);
}

.cs-panel {
  position: fixed;
  z-index: 1000;
  max-height: 260px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.28);
  animation: csPanelIn 0.14s ease;
}

body[data-default-mode="light"] .cs-panel {
  border-color: #e4e7ec;
  background: #ffffff;
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.14);
}

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

.cs-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

.cs-opt-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cs-option:hover,
.cs-option.cs-active {
  background: var(--surface-muted);
}

.cs-option.selected {
  color: var(--primary);
  font-weight: 700;
}

.cs-check {
  margin-left: auto;
  color: var(--primary);
  font-size: 16px;
  line-height: 1;
}

.color-input {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 8px;
}

.auxiliary-list {
  display: grid;
  gap: 8px;
}

.auxiliary-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) minmax(0, 1fr) 28px;
  gap: 6px;
  align-items: center;
}

.auxiliary-item input[type="color"] {
  width: 34px;
  height: 34px;
  border-radius: 10px;
}

.auxiliary-item input[type="text"] {
  height: 34px;
  min-width: 0;
  font-size: 12px;
}

.auxiliary-delete {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
}

input[type="color"] {
  width: 48px;
  height: 36px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #0b1015;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
}

.export-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.export-file-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.action-button {
  height: 32px;
  border-color: var(--line);
  background: #0b1015;
  font-size: 12px;
}

/* 导出框「下载 / 复制」：默认灰 → 悬停有色线框 → 按下/成功为色块 */
.download-button {
  width: 100%;
  height: 34px;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-soft);
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s, transform 0.1s;
}

.download-button:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: transparent;
  transform: translateY(-1px);
}

.download-button:active,
.download-button.is-success {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  transform: translateY(0);
}

.btn-check {
  width: 15px;
  height: 15px;
  flex: none;
  vertical-align: -2px;
  margin-right: 5px;
}

.download-button .btn-check {
  margin-right: 0; /* flex gap 已处理间距 */
}

.action-button.active,
.action-button:hover {
  border-color: var(--primary);
  background: rgba(var(--primary-rgb, 101, 51, 232), 0.12);
  color: var(--primary);
}

textarea {
  min-height: 220px;
  resize: vertical;
  padding: 12px;
  color: #b8c2cc;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.6;
}

.figma-guide {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, rgba(51,102,255,0.10), transparent 54%),
    var(--surface-subtle);
}

.figma-guide-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.figma-guide-heading span {
  color: var(--text);
  font-weight: 800;
}

.figma-guide-heading strong {
  color: var(--primary);
  font-size: 12px;
}

.figma-guide ol {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.5;
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.hero-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 22px;
  align-items: stretch;
  margin-bottom: 18px;
  padding: 22px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(17,22,28,0.98), rgba(10,14,18,0.86)),
    radial-gradient(circle at 84% 16%, rgba(78,255,175,0.10), transparent 34%);
  box-shadow: 0 24px 80px rgba(0,0,0,0.22);
}

.hero-copy h2 {
  margin: 0;
  max-width: 760px;
  color: var(--ink);
  font-size: 40px;
  line-height: 1.12;
  letter-spacing: 0;
}

.hero-copy p:last-child {
  max-width: 760px;
  margin: 10px 0 0;
  color: var(--text-soft);
  line-height: 1.75;
}

.hero-spectrum {
  display: grid;
  gap: 14px;
  align-content: center;
  padding: 14px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  background: rgba(255,255,255,0.035);
}

.spectrum-rail {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 5px;
  min-height: 86px;
}

.spectrum-cell {
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 8px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.38);
}

.pipeline {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
}

.pipeline span {
  display: grid;
  place-items: center;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #0c1116;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 700;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--page);
  padding: 16px 0;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.topbar h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.designer-tag {
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 10px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  white-space: nowrap;
}

.ghost-button,
.primary-button {
  height: 38px;
  padding: 0 14px;
  font-weight: 600;
}

.ghost-button {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--text-soft);
}

.primary-button {
  border-color: transparent;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.18), transparent),
    var(--primary);
  color: #fff;
  box-shadow: 0 10px 24px rgba(51, 102, 255, 0.22);
}

.ghost-button:hover,
.primary-button:hover {
  transform: translateY(-1px);
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  overflow: hidden;
  margin-bottom: 18px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-lg);
  background: var(--line);
}

.status-strip div {
  padding: 14px 16px;
  background: var(--surface);
}

.status-strip span {
  display: block;
  margin-bottom: 5px;
  color: var(--text-muted);
  font-size: 12px;
}

.status-strip strong {
  font-size: 14px;
}

.preview-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 18px;
  align-items: start;
}

.workspace-main {
  min-width: 0;
}

.preview-document {
  /* No wrapper background — each section is its own card */
  padding: 0;
}

.doc-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 28px;
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.doc-heading h3 {
  margin: 0;
  font-size: 34px;
  line-height: 1.1;
}

.doc-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.doc-meta span,
.mode-tags span {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-soft);
  font-size: 12px;
}

/* Each section is an independent card */
.doc-section {
  padding: 28px;
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.doc-section h4 {
  margin: 0 0 8px;
  font-size: 24px;
  line-height: 1.25;
}

.section-intro {
  max-width: 980px;
  margin: 0 0 18px;
  color: var(--text-soft);
  font-size: 15px;
  line-height: 1.75;
}

.color-category {
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  background: #111820;
}

.category-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.category-heading span {
  color: var(--primary);
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.category-heading strong {
  font-size: 14px;
}

.type-showcase {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.font-card,
.type-scale-card {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  background: #111820;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}

.font-card {
  min-height: 252px;
  padding: 28px;
}

.font-card > span {
  display: block;
  margin-bottom: 22px;
  color: var(--text-muted);
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.font-card > strong {
  display: block;
  margin-bottom: 28px;
  color: #fff;
  font-size: 72px;
  line-height: 0.95;
  letter-spacing: 0;
}

.latin-card > strong {
  font-size: 66px;
}

.weight-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.latin-card .weight-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.weight-grid b {
  display: block;
  margin-bottom: 8px;
  color: #f7fafc;
  font-size: 17px;
}

.weight-grid em {
  display: block;
  color: var(--text-muted);
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  font-style: normal;
}

.type-scale-card {
  padding: 0 28px;
  margin-bottom: 18px;
}

.type-scale-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  border-bottom: 1px solid var(--line);
}

.type-scale-head strong {
  font-size: 16px;
}

.type-scale-head span {
  color: var(--text-muted);
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  text-transform: uppercase;
}

.type-scale-preview {
  display: grid;
}

.type-scale-row {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr) 220px;
  gap: 24px;
  align-items: center;
  min-height: 96px;
  border-bottom: 1px solid var(--line);
}

.type-scale-row:last-child {
  border-bottom: 0;
}

.type-level,
.type-spec {
  color: var(--text-muted);
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
}

.type-scale-row strong {
  color: #f8fbfd;
}

.type-spec {
  color: var(--primary);
  text-align: right;
}

.palette-summary {
  display: grid;
  grid-template-columns: 1.2fr repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.summary-card {
  min-height: 76px;
  padding: 12px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 12px;
  background: var(--surface-subtle);
}

.summary-card strong {
  display: block;
  margin-bottom: 8px;
  color: var(--summary-text, var(--text));
  font-size: 13px;
}

.summary-card span {
  display: block;
  color: var(--summary-muted, var(--text-soft));
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
}

.summary-card.primary-summary {
  color: #fff;
  background:
    linear-gradient(135deg, rgba(0,0,0,0.06), rgba(255,255,255,0.12)),
    var(--primary);
}

.summary-card.primary-summary strong,
.summary-card.primary-summary span {
  color: var(--summary-text, #fff);
}

/* two-columns is now a doc-section card, grid is inside */
.two-columns {
  /* inherits card styles from doc-section */
}

.palette-grid {
  display: grid;
  gap: 9px;
}

.palette-row {
  display: grid;
  grid-template-columns: 84px repeat(10, minmax(0, 1fr));
  gap: 4px;
  align-items: center;
}

.palette-name {
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 600;
}

.swatch {
  min-height: 30px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 4px;
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.swatch:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(20, 30, 55, 0.14);
}

.mode-preview {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.light-mode {
  background: #f7f8fa;
  color: #1f2329;
}

.dark-mode {
  background: #101216;
  color: #f5f6f7;
}

.preview-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.preview-chip {
  height: 40px;
  border-radius: 6px;
  border: 1px solid rgba(128, 128, 128, 0.24);
}

.preview-name {
  font-size: 10px;
  opacity: 0.6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.token-table {
  overflow: hidden;
  border: 0;
  border-radius: 0;
}

.token-row {
  display: grid;
  grid-template-columns: 40px minmax(210px, 1.1fr) minmax(150px, 0.9fr) minmax(130px, 0.8fr) minmax(130px, 0.8fr) minmax(170px, 1fr);
  align-items: center;
  min-height: 54px;
  border-bottom: 1px solid var(--line);
}

.token-row:last-child {
  border-bottom: 0;
}

.token-row.header {
  min-height: 44px;
  background: #0d1218;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 600;
}

.token-row > * {
  padding: 8px 10px;
}

.token-dot {
  width: 22px;
  height: 22px;
  margin-left: 12px;
  padding: 0;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 6px;
}

.token-name {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.token-value {
  color: var(--text-soft);
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
}

.default-value {
  color: var(--text);
  font-weight: 700;
}

.token-usage {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
}

.shape-list,
.spacing-list {
  display: grid;
  gap: 8px;
}

.shape-item,
.spacing-item {
  display: grid;
  grid-template-columns: 170px 1fr 110px;
  align-items: center;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  background: #111820;
}

.radius-demo {
  width: 48px;
  height: 28px;
  border: 1px solid var(--primary);
  background: var(--primary-weak);
}

.shadow-demo {
  width: 72px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #151c24;
}

body[data-default-mode="light"] .shadow-demo {
  background: #ffffff;
}

.shadow-item {
  grid-template-columns: 170px 120px minmax(0, 1fr);
  align-items: start;
  min-height: 110px;
  background: #111820;
}

.shadow-item small {
  display: block;
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 12px;
}

body[data-default-mode="light"] .shadow-item {
  background: #ffffff;
}

.shadow-breakdown {
  display: grid;
  gap: 8px;
}

.shadow-layer-row {
  display: grid;
  grid-template-columns: 64px repeat(6, minmax(70px, 1fr));
  gap: 8px;
  align-items: center;
  min-width: 760px;
  color: var(--text-soft);
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
}

.shadow-layer-row strong {
  color: var(--text);
  font-family: var(--local-font);
  font-size: 12px;
}

.shadow-layer-row span {
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(0,0,0,0.12);
  white-space: nowrap;
}

.shadow-layer-row.empty {
  min-width: 0;
  display: block;
  color: var(--text-muted);
}

body[data-default-mode="light"] .shadow-layer-row span {
  background: #f7f8fa;
}

.shadow-value {
  display: block;
  min-width: 0;
  padding: 10px 12px;
  overflow-x: auto;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0,0,0,0.14);
  color: var(--text-soft);
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.4;
}

body[data-default-mode="light"] .shadow-value {
  background: #f7f8fa;
}

.spacing-demo {
  height: 12px;
  border-radius: 999px;
  background: var(--primary);
}

/* ===== Left Sidebar: Project Selector ===== */
.project-selector {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}

.project-select {
  flex: 1;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--primary);
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.icon-button:hover {
  background: rgba(255,255,255,0.06);
}

.import-link {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s;
}

.import-link:hover {
  color: var(--primary);
}

.import-link input {
  display: none;
}

/* ===== Right Panel: History ===== */
.history-panel {
  position: sticky;
  top: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.history-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 600;
}

.history-panel-header strong {
  color: var(--text-muted);
  font-size: 11px;
}

.history-divider {
  height: 1px;
  background: rgba(255,255,255,0.06);
  margin: 16px 0;
}

.project-timeline {
  display: grid;
  gap: 6px;
  max-height: 480px;
  overflow-y: auto;
  margin-bottom: 12px;
}

.timeline-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.timeline-item:hover {
  background: rgba(255,255,255,0.04);
}

.timeline-item.active {
  border-color: var(--primary);
  background: rgba(var(--primary-rgb, 101, 51, 232), 0.08);
}

.timeline-color {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.1);
}

.timeline-info {
  flex: 1;
  min-width: 0;
}

.timeline-info strong {
  display: block;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.timeline-info span {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

.timeline-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  opacity: 0;
  padding: 2px 4px;
  transition: opacity 0.15s;
}

.timeline-item:hover .timeline-delete {
  opacity: 1;
}

.timeline-delete:hover {
  color: #ef4444;
}

  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
}

.figma-var span:last-child {
  color: var(--text-muted);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  max-width: 320px;
  padding: 12px 14px;
  border: 1px solid rgba(78,255,175,0.28);
  border-radius: 12px;
  background: rgba(13,18,23,0.92);
  color: #eef3f7;
  box-shadow: 0 18px 42px rgba(0,0,0,0.28);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

body[data-default-mode="light"] .toast {
  border-color: rgba(20,26,33,0.12);
  background: rgba(255,255,255,0.96);
  color: #171a1f;
}

.modal {
  width: min(520px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 28px 80px rgba(0,0,0,0.36);
}

.modal::backdrop {
  background: rgba(0,0,0,0.48);
}

.modal h3 {
  margin: 0 0 8px;
  font-size: 22px;
}

.modal p {
  margin: 0 0 18px;
  color: var(--text-soft);
}

.modal textarea {
  min-height: 120px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* 自定义确认框（替代原生 confirm，居中显示、风格统一） */
.confirm-modal {
  width: min(420px, calc(100vw - 32px));
  padding: 24px;
}

.confirm-modal h3 {
  font-size: 18px;
  margin-bottom: 10px;
}

.confirm-modal p {
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 22px;
}

.confirm-modal .modal-actions button {
  white-space: nowrap;
  min-width: 72px;
  padding-left: 16px;
  padding-right: 16px;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 320px minmax(0, 1fr);
  }

  .preview-layout,
  .two-columns,
  .type-showcase,
  .status-strip,
  .hero-band {
    grid-template-columns: 1fr;
  }

  .palette-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .figma-card {
    position: static;
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .workspace {
    padding: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .preview-document {
    padding: 22px;
  }

  .hero-copy h2 {
    font-size: 24px;
  }

  .palette-summary {
    grid-template-columns: 1fr;
  }

  .palette-row {
    grid-template-columns: 1fr repeat(5, minmax(0, 1fr));
  }

  .palette-row .swatch:nth-of-type(n + 7) {
    display: none;
  }

  .token-row {
    grid-template-columns: 30px 1fr;
  }

  .type-scale-row {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 18px 0;
  }

  .type-spec {
    text-align: left;
  }

  .weight-grid,
  .latin-card .weight-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .font-card > strong,
  .latin-card > strong {
    font-size: 48px;
  }

  .token-row > .token-value:nth-child(n + 4),
  .token-row > .token-usage,
  .token-row.header > span:nth-child(n + 4) {
    display: none;
  }

  .shape-item,
  .spacing-item {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

/* ===== v2: Contrast Grid ===== */
/* Contrast grid — Figma replica */
.contrast-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.contrast-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

body[data-default-mode="dark"] .contrast-item {
  background: var(--surface-subtle);
}

.contrast-item {
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.contrast-fix-btn {
  height: 28px;
  padding: 0 12px;
  border: 1px solid rgba(var(--primary-rgb, 51,102,255), 0.28);
  border-radius: 8px;
  background: rgba(var(--primary-rgb, 51,102,255), 0.08);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.contrast-fix-btn:hover {
  background: rgba(var(--primary-rgb, 51,102,255), 0.14);
}

.contrast-suggestion {
  display: none;
  flex-basis: 100%;
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface-muted);
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.6;
}

.contrast-suggestion b {
  color: var(--text);
  font-weight: 700;
}

.contrast-suggestion .suggest-color {
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(var(--primary-rgb, 51,102,255), 0.12);
  color: var(--primary);
}

.contrast-item.show-suggestion {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb, 51,102,255), 0.16);
}

.contrast-item.show-suggestion .contrast-suggestion {
  display: block;
}

.contrast-item.show-suggestion .contrast-colors {
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(var(--primary-rgb, 51,102,255), 0.12);
  color: var(--primary);
  font-weight: 700;
}

.contrast-item.show-suggestion .contrast-fix-btn {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.contrast-preview {
  width: 56px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
}

.contrast-info {
  flex: 1;
  min-width: 0;
}

.contrast-label {
  font-size: 13px;
  color: var(--text);
  display: block;
  font-weight: 500;
  margin-bottom: 2px;
}

.contrast-colors {
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'SF Mono', Menlo, monospace;
}

.contrast-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.contrast-ratio {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.contrast-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.contrast-badge.aaa {
  background: #dcfce7;
  color: #166534;
}

.contrast-badge.aa {
  background: #dbeafe;
  color: #1e40af;
}

.contrast-badge.aa-large {
  background: #fef3c7;
  color: #92400e;
}

.contrast-badge.fail {
  background: #fee2e2;
  color: #991b1b;
}

/* ===== v2: Opacity List ===== */
/* Opacity: card row — Figma replica */
.opacity-list {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
}

@media (max-width: 900px) {
  .opacity-list {
    grid-template-columns: repeat(3, 1fr);
  }
}

.opacity-card {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-subtle);
  text-align: center;
  min-height: 144px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.opacity-card .opacity-preview {
  width: 100%;
  height: 60px;
  border-radius: 8px;
  margin-bottom: 12px;
  position: relative;
  background: repeating-conic-gradient(var(--line) 0% 25%, transparent 0% 50%) 50% / 10px 10px;
  overflow: hidden;
}

.opacity-card .opacity-fill {
  position: absolute;
  inset: 0;
  border-radius: 8px;
  background: var(--primary);
}

.opacity-card .opacity-name {
  font-size: 11px;
  color: var(--text-muted);
  padding: 3px 7px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: 'SF Mono', Menlo, monospace;
  margin-bottom: 6px;
}

.opacity-card .opacity-value {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-soft);
}

/* ===== v3: Motion Grid ===== */
.motion-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.motion-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.motion-preview {
  height: 40px;
  background: var(--surface-muted);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}

.motion-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  position: absolute;
  top: 14px;
  left: 8px;
  animation: motionSlide 2s infinite alternate;
}

@keyframes motionSlide {
  0% { left: 8px; }
  100% { left: calc(100% - 20px); }
}

.motion-name {
  font-size: 11px;
  font-family: 'SF Mono', Menlo, monospace;
  color: var(--text-muted);
  padding: 3px 7px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: inline-block;
  align-self: flex-start;
}

.motion-value {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.motion-usage {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* AI Prompt button */
.ai-prompt-button {
  width: 100%;
  height: 34px;
  margin-top: 10px;
  border: none;
  border-radius: var(--radius-md);
  background: #fff;
  color: #000;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.ai-prompt-button:hover {
  opacity: 0.85;
}

body[data-default-mode="light"] .ai-prompt-button {
  background: #000;
  color: #fff;
}

.ai-prompt-button.secondary {
  margin-top: 8px;
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.ai-prompt-button.secondary:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.08);
}

body[data-default-mode="light"] .ai-prompt-button.secondary {
  background: transparent;
  color: #000;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

body[data-default-mode="light"] .ai-prompt-button.secondary:hover {
  background: rgba(0, 0, 0, 0.05);
}

.ai-json-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.ai-json-actions .ai-prompt-button.secondary {
  margin-top: 0;
  flex: 1;
}

/* ===== v2: Export tabs overflow ===== */
.export-actions {
  flex-wrap: wrap;
}

/* =============================================
   v3: Sidebar Tabs + TOC + Section Headers
   ============================================= */

/* Sidebar Tabs */
.sidebar-tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  margin: 0 12px 8px;
  background: var(--surface-muted);
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
}

.sidebar-tab {
  flex: 1;
  height: 32px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.sidebar-tab.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.sidebar-tab:hover:not(.active) {
  color: var(--text);
  background: rgba(255,255,255,0.06);
}

body[data-default-mode="light"] .sidebar-tab:hover:not(.active) {
  background: rgba(0,0,0,0.04);
}

.sidebar-tab-content {
  display: none;
}

.sidebar-tab-content.active {
  display: block;
}

/* TOC Navigation */
.toc-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
}

.toc-link {
  display: flex;
  align-items: center;
  height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  border-left: 3px solid transparent;
  color: var(--text-soft);
  text-decoration: none;
  font-size: 13px;
  transition: all 0.15s;
  cursor: pointer;
}

.toc-link:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border-left-color: rgba(255,255,255,0.2);
}

.toc-link.active {
  background: rgba(var(--primary-rgb, 101, 51, 232), 0.15);
  color: var(--primary);
  font-weight: 600;
  border-left-color: var(--primary);
}

body[data-default-mode="light"] .toc-link:hover {
  background: rgba(0,0,0,0.05);
  border-left-color: rgba(0,0,0,0.15);
}

body[data-default-mode="light"] .toc-link.active {
  background: rgba(var(--primary-rgb, 101, 51, 232), 0.1);
  border-left-color: var(--primary);
}

/* Section Header: kicker + title + desc */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}

.section-header-full {
  display: block;
  margin-bottom: 20px;
}

/* Kicker: pill badge — exact replica from Figma */
.section-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 22px;
  padding: 0 10px 0 8px;
  margin-bottom: 10px;
  border-radius: 999px;
  background: rgba(var(--primary-rgb, 101, 51, 232), 0.12);
  font-family: 'SF Mono', 'JetBrains Mono', Menlo, monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.kicker-dot {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: var(--primary);
  flex-shrink: 0;
}

.section-header h4 {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
}

.section-desc {
  margin: 0;
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-soft);
  max-width: none;
}

.section-badge {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  margin-top: 28px;
}

/* Override old doc-section h4 for new structure */
.doc-section .section-header + .token-table,
.doc-section .section-header + .palette-summary,
.doc-section .section-header + .contrast-grid {
  margin-top: 0;
}

/* Remove old h4 margin when inside section-header */
.section-header h4 + .section-desc {
  margin-top: 0;
}

/* Two columns grid for theme preview */
.two-columns-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.two-columns-grid h5 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* =============================================
   v3: Font Family Cards (large)
   ============================================= */
.font-family-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.font-family-card {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-subtle);
}

.font-card-label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
  letter-spacing: 0.02em;
}

.font-card-display {
  display: block;
  font-size: 56px;
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: 8px;
}

.font-card-latin {
  font-family: 'Inter', system-ui, sans-serif;
}

.font-card-stack {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 24px;
  font-family: 'SF Mono', Menlo, monospace;
  background: none;
  padding: 0;
}

.font-card-weights {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.weight-specimen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 48px;
}

.weight-specimen b {
  font-size: 32px;
  line-height: 1.2;
}

.weight-specimen span {
  font-size: 11px;
  color: var(--text-soft);
}

.weight-specimen em {
  font-size: 11px;
  font-style: normal;
  color: var(--text-muted);
}

/* =============================================
   v3: Type Scale Table (new layout)
   ============================================= */
/* Type Scale: three-column table rows */
.type-scale-table {
  display: flex;
  flex-direction: column;
}

.type-scale-row {
  display: grid;
  grid-template-columns: 220px 1fr auto;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
  min-height: 56px;
}

.type-scale-row:last-child {
  border-bottom: none;
}

.type-scale-row.large {
  min-height: 85px;
}

.type-scale-token {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.type-scale-token strong {
  font-size: 13px;
  font-weight: 600;
}

.type-scale-token span {
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'SF Mono', Menlo, monospace;
}

.type-scale-sample {
  line-height: 1.3;
  color: var(--text);
}

.type-scale-group {
  margin-bottom: 8px;
}

.type-scale-group-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  padding: 12px 0 8px;
  border-bottom: 2px solid var(--primary);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.type-scale-size {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-soft);
  padding: 3px 9px;
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: 6px;
  white-space: nowrap;
  font-family: 'SF Mono', Menlo, monospace;
}

/* =============================================
   v3: Radius Grid (card layout)
   ============================================= */
/* Radius: 4-col card grid — Figma replica */
.radius-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.radius-card {
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-subtle);
  display: flex;
  align-items: flex-start;
  gap: 16px;
  min-height: 130px;
}

.radius-preview {
  width: 64px;
  height: 64px;
  background: rgba(var(--primary-rgb, 101, 51, 232), 0.06);
  border: 1.5px dashed rgba(var(--primary-rgb, 101, 51, 232), 0.4);
  flex-shrink: 0;
}

.radius-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 4px;
}

.radius-info .radius-value {
  font-size: 14px;
  font-weight: 600;
}

.radius-info .radius-name {
  font-size: 11px;
  color: var(--text-muted);
  padding: 3px 7px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: inline-block;
  font-family: 'SF Mono', Menlo, monospace;
}

/* =============================================
   v3: Shadow Grid (card layout)
   ============================================= */
/* Shadow: 3-col card grid — Figma replica */
.shadow-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.shadow-card {
  padding: 19px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-subtle);
  min-height: 144px;
}

.shadow-preview-box {
  width: 100%;
  height: 64px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  margin-bottom: 16px;
}

.shadow-card-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.shadow-card-name {
  font-size: 11px;
  color: var(--text-muted);
  padding: 3px 7px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: 'SF Mono', Menlo, monospace;
}

.shadow-card-label {
  font-size: 10px;
  color: var(--text-muted);
  font-family: 'SF Mono', Menlo, monospace;
}

.shadow-layers {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.shadow-layer-item {
  font-size: 10px;
  color: var(--text-muted);
  font-family: 'SF Mono', Menlo, monospace;
  line-height: 1.5;
}

/* =============================================
   v3: Spacing Bar List (horizontal bars)
   ============================================= */
.spacing-bar-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.spacing-bar-row {
  display: grid;
  grid-template-columns: 100px 1fr 60px;
  align-items: center;
  gap: 12px;
  height: 40px;
}

/* Spacing bars — Figma replica */
.spacing-bar-name {
  font-size: 11px;
  color: var(--text-muted);
  padding: 3px 7px;
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: inline-block;
  text-align: center;
  font-family: 'SF Mono', Menlo, monospace;
  white-space: nowrap;
}

.spacing-bar-track {
  height: 24px;
  background: var(--surface-subtle);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.spacing-bar-fill {
  height: 12px;
  margin: 6px 0 6px 0;
  border-radius: 4px;
  background: var(--primary);
  opacity: 0.45;
  transition: width 0.3s;
}

.spacing-bar-value {
  font-size: 12px;
  color: var(--text-soft);
  text-align: right;
  font-weight: 500;
  font-family: 'SF Mono', Menlo, monospace;
}

/* =============================================
   v4: Quick Export Buttons (topbar)
   ============================================= */
.quick-export-btn {
  padding: 0 12px;
  height: 32px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

/* =============================================
   v4: Section Collapse
   ============================================= */
.doc-section .section-header {
  position: relative;
}

.doc-section .section-body {
  max-height: none;
  opacity: 1;
}

/* =============================================
   v4: Auxiliary Color Suggestions
   ============================================= */
.aux-suggestions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 6px 0 2px;
}

.aux-suggestions:empty {
  display: none;
}

.aux-suggest-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--line);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease;
  position: relative;
}

.aux-suggest-dot:hover {
  transform: scale(1.2);
  border-color: var(--text-soft);
}

.aux-suggest-dot::after {
  content: '+';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: white;
  opacity: 0;
  transition: opacity 160ms ease;
}

.aux-suggest-dot:hover::after {
  opacity: 0.9;
}

.aux-suggest-label {
  font-size: 10px;
  color: var(--text-muted);
  line-height: 22px;
  margin-right: 2px;
}

/* =============================================
   v4: A11y Badge in Status Strip
   ============================================= */
.a11y-badge {
  font-size: 11px !important;
}

.a11y-badge.pass {
  color: var(--success) !important;
}

.a11y-badge.warn {
  color: var(--warning) !important;
}

/* =============================================
   v4: Version Diff Indicators
   ============================================= */
.version-diff {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.diff-tag {
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--surface-muted);
  color: var(--text-soft);
  white-space: nowrap;
}

.diff-tag.changed {
  background: rgba(var(--primary-rgb, 51,102,255), 0.15);
  color: var(--primary);
}

/* =============================================
   v4: Export Change Indicator
   ============================================= */
.export-dirty-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warning);
  margin-left: 6px;
  vertical-align: middle;
  opacity: 0;
  transition: opacity 200ms ease;
}

.export-dirty-dot.show {
  opacity: 1;
}

/* =============================================
   v5: 保留式体验增强
   ============================================= */
.topbar-main {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.topbar-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--text-muted);
  font-size: 12px;
}

.topbar-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-subtle);
}

.global-search {
  position: relative;
  width: min(220px, 24vw);
}

.global-search span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.global-search input {
  -webkit-appearance: none;
  appearance: none;
  height: 38px;
  padding-left: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  outline: 0;
  box-shadow: none;
}

.global-search input:focus,
.global-search input:focus-visible {
  border-width: 1px;
  border-color: var(--primary);
  outline: 0;
  box-shadow: none;
}

.global-search::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 50%;
  width: 12px;
  height: 12px;
  border: 1px solid var(--text-muted);
  border-radius: 999px;
  transform: translateY(-55%);
  pointer-events: none;
}

.global-search::after {
  content: "";
  position: absolute;
  left: 24px;
  top: 24px;
  width: 7px;
  height: 2px;
  border-radius: 999px;
  background: var(--text-muted);
  transform: rotate(45deg);
  pointer-events: none;
}

.export-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.export-actions [data-export="figmaPlugin"] {
  grid-column: span 2;
}

.export-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 28px;
  margin-bottom: 8px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  color: var(--text-muted);
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
}

.toc-tools {
  padding: 8px 12px 4px;
}

.toc-search {
  display: grid;
  gap: 6px;
}

.toc-search span,
.toc-helper {
  color: var(--text-muted);
  font-size: 12px;
}

.toc-helper {
  margin-top: 8px;
}

.toc-link {
  counter-increment: toc;
  gap: 10px;
}

.toc-link::before {
  content: counter(toc, decimal-leading-zero);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 20px;
  border-radius: 6px;
  background: var(--surface-subtle);
  color: var(--text-muted);
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 10px;
  flex-shrink: 0;
}

.toc-nav {
  counter-reset: toc;
}

.toc-link.active::before {
  background: rgba(var(--primary-rgb, 51,102,255), 0.15);
  color: var(--primary);
}

.toc-link.toc-hidden {
  display: none;
}

.section-header {
  gap: 16px;
}

.is-searching .search-hidden {
  display: none !important;
}

.component-preview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.component-card {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 146px;
  padding: 14px;
  border: 1px solid var(--cp-border);
  border-radius: 10px;
  background: var(--cp-surface);
  color: var(--cp-text);
  font-size: var(--cp-font);
}

.component-card:hover {
  border-color: rgba(var(--primary-rgb, 51,102,255), 0.22);
  box-shadow: var(--cp-shadow);
}

.component-card-title {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 22px;
}

.component-card-title strong {
  color: var(--cp-text);
  font-size: 13px;
  line-height: 1;
}

.component-card-title span {
  color: var(--cp-muted);
  font-size: 11px;
}

.demo-button {
  width: 100%;
  height: 28px;
  padding: 0 10px;
  border-radius: 7px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 700;
}

.demo-button.primary {
  background: var(--cp-primary);
  color: #fff;
}

.demo-button.primary:hover {
  background: var(--cp-primary-hover);
}

.demo-button.secondary {
  border-color: var(--cp-border);
  background: var(--cp-surface);
  color: var(--cp-muted);
}

.demo-field {
  width: 100%;
  height: 30px;
  padding: 0 10px;
  border-color: var(--cp-border);
  border-radius: 7px;
  background: var(--cp-surface);
  color: var(--cp-text);
  font-size: 12px;
}

.component-input-card .demo-field.focused {
  border: 1px solid var(--cp-primary);
  box-shadow: none;
}

.component-tags {
  display: grid;
  grid-template-columns: repeat(2, max-content);
  grid-template-rows: 24px 24px;
  align-self: start;
  align-content: start;
  justify-content: start;
  justify-items: start;
  align-items: start;
  gap: 8px;
}

.demo-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.demo-tag.brand {
  background: var(--cp-soft);
  color: var(--cp-primary);
}

.demo-tag.success {
  background: var(--cp-success-bg);
  color: var(--cp-success);
}

.demo-tag.aux {
  background: rgba(139, 92, 246, 0.12);
  color: #8B5CF6;
}

.demo-tag.warning {
  background: var(--cp-warning-bg);
  color: var(--cp-warning);
}

.demo-alert {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 700;
}

.demo-alert span {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  flex-shrink: 0;
}

.demo-alert.success {
  border: 1px solid rgba(22, 163, 111, 0.24);
  background: var(--cp-success-bg);
  color: var(--cp-success);
}

.demo-alert.success span {
  background: var(--cp-success);
}

.demo-alert.danger {
  border: 1px solid rgba(217, 48, 37, 0.24);
  background: var(--cp-danger-bg);
  color: var(--cp-danger);
}

.demo-alert.danger span {
  background: var(--cp-danger);
}

.demo-nested-card {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-radius);
  background: var(--cp-surface);
}

.demo-nested-card strong {
  color: var(--cp-text);
  font-size: 12px;
}

.demo-nested-card p {
  margin: 0;
  color: var(--cp-muted);
  font-size: 11px;
  line-height: 1.45;
}

@media (max-width: 1180px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-right {
    width: 100%;
    flex-wrap: wrap;
  }

  .global-search {
    width: min(100%, 280px);
  }

  .component-preview {
    grid-template-columns: 1fr;
  }
}

/* =============================================
   v6: 效果图结构补全
   ============================================= */
.app-shell {
  grid-template-columns: 300px minmax(0, 1fr);
}

.workspace {
  padding: 0 20px 24px;
}

.topbar {
  min-height: 70px;
  margin: 0 -20px 18px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 245, 243, 0.86);
}

body[data-default-mode="dark"] .topbar {
  background: rgba(5, 8, 10, 0.86);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 210px;
}

.topbar-logo {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  object-fit: cover;
}

.topbar-brand strong {
  display: block;
  color: var(--text);
  font-size: 13px;
  line-height: 1.1;
}

.topbar-brand h2 {
  margin-top: 3px;
  max-width: 220px;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-byline {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.02em;
  opacity: 0.75;
  white-space: nowrap;
}

.topbar-project {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--text-muted);
  font-size: 12px;
}

.top-project-name {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  max-width: 210px;
  padding: 0 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.save-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(22, 163, 111, 0.12);
}

.topbar-project #platformMeta,
.topbar-project #primaryMeta,
.topbar-project #defaultModeMeta {
  display: none;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-muted);
}

.mode-switch-button {
  height: 28px;
  min-width: 64px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
}

.mode-switch-button.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 6px rgba(15, 23, 42, 0.08);
}

.topbar-right {
  margin-left: auto;
}

.global-search {
  width: min(260px, 22vw);
}

.global-search input {
  height: 32px;
}

.quick-export-btn,
.primary-button {
  height: 32px;
}

.status-strip {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.status-strip div.status-card {
  position: relative;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  grid-template-areas:
    "icon value"
    "icon label";
  gap: 2px 12px;
  min-height: 78px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.04);
}

.status-card::before {
  content: none;
}

.status-icon {
  grid-area: icon;
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.45), transparent),
    rgba(var(--primary-rgb, 51,102,255), 0.12);
  color: var(--primary);
  font-size: 22px;
  line-height: 1;
}

.status-icon i {
  display: block;
}

.status-a11y .status-icon {
  background:
    linear-gradient(135deg, rgba(255,255,255,0.45), transparent),
    rgba(22, 163, 111, 0.12);
  color: var(--success);
}

.status-version .status-icon {
  background:
    linear-gradient(135deg, rgba(255,255,255,0.45), transparent),
    rgba(139, 92, 246, 0.12);
  color: #8b5cf6;
}

.status-export .status-icon {
  background:
    linear-gradient(135deg, rgba(255,255,255,0.45), transparent),
    rgba(245, 158, 11, 0.13);
  color: #f59e0b;
}

/* Dark mode: drop the light-white sheen so the colored glyph stays readable */
body[data-default-mode="dark"] .status-icon {
  background: rgba(var(--primary-rgb, 51,102,255), 0.18);
}

body[data-default-mode="dark"] .status-a11y .status-icon {
  background: rgba(22, 163, 111, 0.18);
}

body[data-default-mode="dark"] .status-version .status-icon {
  background: rgba(139, 92, 246, 0.20);
}

body[data-default-mode="dark"] .status-export .status-icon {
  background: rgba(245, 158, 11, 0.18);
}

.status-strip .status-card span {
  grid-area: label;
  margin: 0;
}

.status-strip .status-card .status-icon {
  grid-area: icon;
  display: grid;
  place-items: center;
  align-self: center;
  justify-self: start;
  margin: 0;
  font-size: 22px;
  line-height: 1;
  overflow: hidden;
}

.status-strip .status-card .status-icon i,
.status-strip .status-card .status-icon i::before {
  display: block;
  width: 22px;
  height: 22px;
  line-height: 22px;
  text-align: center;
}

.status-strip .status-card strong {
  grid-area: value;
  align-self: end;
  color: var(--text);
  font-size: 22px;
  line-height: 1;
}

.status-strip .status-card em {
  display: none;
}

.preview-layout {
  grid-template-columns: minmax(0, 1fr) 360px;
}

.history-panel {
  top: 88px;
  display: grid;
  gap: 16px;
  max-height: calc(100vh - 104px);
  overflow: auto;
  padding: 0;
  background: transparent;
}

body[data-default-mode="dark"] .history-panel {
  background: transparent;
}

.right-tool-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  background: rgba(14, 19, 25, 0.92);
}

body[data-default-mode="light"] .right-tool-panel {
  border-color: rgba(20, 26, 33, 0.10);
  background: #ffffff;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.04);
}

.history-panel-header a {
  color: var(--primary);
  font-size: 12px;
  text-decoration: none;
}

.history-panel .export-actions {
  display: flex;
  flex-wrap: nowrap;
  grid-template-columns: none;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.history-panel .action-button {
  flex: 0 0 auto;
  height: 28px;
  padding: 0 10px;
  border-radius: 8px;
}

.export-source-textarea {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.export-code-window {
  position: relative;
  min-height: 260px;
  max-height: 360px;
  overflow: hidden;
  border: 1px solid #1c2938;
  border-radius: 12px;
  background:
    radial-gradient(circle at 15% 0%, rgba(var(--primary-rgb, 51,102,255), 0.18), transparent 34%),
    linear-gradient(180deg, rgba(255,255,255,0.045), transparent 42px),
    #0b1118;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.07),
    0 18px 42px rgba(15, 23, 42, 0.12);
}

.export-code-window pre {
  height: 100%;
  min-height: 260px;
  max-height: 360px;
  margin: 0;
  overflow: auto;
  padding: 22px 18px 24px;
  color: #d7e5f0;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.62;
  tab-size: 2;
  white-space: pre;
}

.export-code-window pre::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.export-code-window pre::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.42);
  background-clip: padding-box;
}

.export-code-copy {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 10px;
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.86);
  font-size: 20px;
  backdrop-filter: blur(10px);
}

.export-code-copy:hover,
.export-code-copy.copied {
  border-color: rgba(255,255,255,0.28);
  background: rgba(255,255,255,0.14);
  color: #ffffff;
}

.export-code-window .code-key {
  color: #d28a68;
}

.export-code-window .code-string {
  color: #b9d97a;
}

.export-code-window .code-number {
  color: #80c8ff;
}

.export-code-window .code-keyword {
  color: #bda5ff;
}

.export-code-window .code-comment {
  color: #718198;
}

.export-code-window .code-color {
  color: #7dd3fc;
}

@media (max-width: 1320px) {
  .preview-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .history-panel {
    position: static;
    max-height: none;
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .status-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Browser comment fix: top navigation spans the full app */
.app-shell {
  grid-template-columns: 360px minmax(0, 1fr);
  grid-template-rows: 70px minmax(0, 1fr);
  grid-template-areas:
    "topbar topbar"
    "sidebar workspace";
}

.topbar {
  grid-area: topbar;
  margin: 0;
  padding: 12px 20px;
}

.sidebar {
  grid-area: sidebar;
  top: 70px;
  height: calc(100vh - 70px);
  padding-top: 18px;
}

.workspace {
  grid-area: workspace;
  padding: 18px 20px 24px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    grid-template-areas:
      "topbar"
      "sidebar"
      "workspace";
  }

  .topbar {
    position: sticky;
    top: 0;
  }

  .sidebar {
    top: 0;
    height: auto;
  }
}
