/* ============================================================================
   外观：主题 / 字号 / 密度 / 布局
   ========================================================================== */

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f9fc;
  --panel: #ffffff;
  --panel-2: #eef2f8;
  --panel-3: #e4eaf3;
  --line: #dde4ee;
  --line-2: #c6d0de;
  --text: #1a2330;
  --text-dim: #4b5a6e;
  --muted: #77869a;
  --accent: #1f6feb;
  --accent-dim: #7ba7ee;
  --struct: #1f6feb;
  --union: #7048e8;
  --enum: #a85b00;
  --added: #0f8b4c;
  --removed: #c8302b;
  --moved: #a85b00;
  --zebra: rgba(16, 32, 56, .028);
  --hover: rgba(31, 111, 235, .08);
  --code-bg: #f4f7fc;
  --code-fg: #23303f;
  --code-cm: #7c8b9e;
  --scroll: #c3cddb;
  --scroll-hover: #a8b6c8;
  --sel: rgba(31, 111, 235, .18);
  --boot-1: #e6eefc;
  --boot-2: #f7f9fc;
}

html[data-theme="contrast"] {
  --bg: #000000;
  --panel: #0a0a0a;
  --panel-2: #141414;
  --panel-3: #1c1c1c;
  --line: #333333;
  --line-2: #4a4a4a;
  --text: #ffffff;
  --text-dim: #d0d6de;
  --muted: #9aa4b0;
  --accent: #4dc3ff;
  --accent-dim: #2a7fb3;
  --struct: #4dc3ff;
  --union: #c9a0ff;
  --enum: #ffd166;
  --added: #4ade80;
  --removed: #ff7b7b;
  --moved: #ffd166;
  --zebra: rgba(255, 255, 255, .05);
  --hover: rgba(77, 195, 255, .16);
  --code-bg: #050505;
  --code-fg: #f2f6fa;
  --code-cm: #9aa4b0;
  --scroll: #444444;
  --scroll-hover: #5c5c5c;
  --sel: rgba(77, 195, 255, .35);
  --boot-1: #06202e;
  --boot-2: #000000;
}

html[data-theme="sepia"] {
  color-scheme: light;
  --bg: #f4ecdc;
  --panel: #fbf6ea;
  --panel-2: #f0e7d4;
  --panel-3: #e7dcc6;
  --line: #ddd0b6;
  --line-2: #cbb99a;
  --text: #3a3128;
  --text-dim: #635647;
  --muted: #8b7c67;
  --accent: #9a6b1f;
  --accent-dim: #c49a54;
  --struct: #9a6b1f;
  --union: #7a5aa8;
  --enum: #a34f16;
  --added: #4d7c2a;
  --removed: #b03a2e;
  --moved: #a34f16;
  --zebra: rgba(90, 70, 40, .05);
  --hover: rgba(154, 107, 31, .1);
  --code-bg: #f3ead8;
  --code-fg: #3a3128;
  --code-cm: #8b7c67;
  --scroll: #cdbc9e;
  --scroll-hover: #b8a382;
  --sel: rgba(154, 107, 31, .2);
  --boot-1: #efe2c8;
  --boot-2: #f4ecdc;
}

/* 密度 */
html[data-density="compact"] { --row-py: 3px; }
html[data-density="relaxed"] { --row-py: 8px; }

/* 布局：全宽（隐藏侧栏） */
html[data-wide="1"] .sidebar { display: none; }
html[data-wide="1"] .layout { grid-template-columns: minmax(0, 1fr); }
html[data-wide="1"] .tablewrap,
html[data-wide="1"] .cmp,
html[data-wide="1"] .codeblock,
html[data-wide="1"] .tablebar { max-width: 1400px; }

/* ------------------------------------------------------------ 设置面板 */
.iconbtn {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text-dim);
  cursor: pointer;
}
.iconbtn:hover { color: var(--accent); border-color: var(--accent-dim); }
.iconbtn svg { width: 16px; height: 16px; fill: currentColor; }
.iconbtn[aria-expanded="true"] { color: var(--accent); border-color: var(--accent-dim); }

.prefs {
  position: absolute;
  top: 50px;
  right: 14px;
  z-index: 50;
  width: 268px;
  padding: 12px;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 18px 40px rgba(0, 0, 0, .35);
}

.prefs__group + .prefs__group { margin-top: 14px; }

.prefs__label {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.prefs__row { display: flex; gap: 6px; flex-wrap: wrap; }

.prefs__row button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
}

.prefs__row button:hover { border-color: var(--accent-dim); color: var(--text); }

.prefs__row button[aria-pressed="true"] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--text);
}

.prefs__row button i {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  border: 1px solid rgba(128, 128, 128, .45);
  background: linear-gradient(135deg, var(--c1), var(--c2));
}
