:root {
  /* 绿色系（UI设计规范）：主色 #2E7D32 / 辅助 #4CAF50 / 强调 #81C784 */
  --bg: #101511;
  --panel: #161d18;
  --panel-2: #1c251e;
  --line: #26332a;
  --text: #dbe7dd;
  --text-dim: #8da294;
  --accent: #81c784;        /* 强调：高亮/数值/链接 */
  --accent-2: #2e7d32;      /* 主色：主按钮/选中态 */
  --accent-2-hover: #43a047;
  --ok: #81c784;
  --warn: #e8b04b;
  --err: #ef6b6b;
  --overlay: rgba(16, 21, 17, 0.55);
  --primary-text: #f2f8f3;
}

html[data-theme="light"] {
  --bg: #f3f7f3;
  --panel: #ffffff;
  --panel-2: #ecf3ed;
  --line: #d6e2d8;
  --text: #1c2a20;
  --text-dim: #5f7263;
  --accent: #2e7d32;
  --accent-2: #2e7d32;
  --accent-2-hover: #1b5e20;
  --ok: #2e7d32;
  --warn: #a06d10;
  --err: #cc3d3d;
  --overlay: rgba(243, 247, 243, 0.6);
  --primary-text: #ffffff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: background-color 0.25s, color 0.25s;
}

#canvas { width: 100%; height: 100%; display: block; opacity: 1; transition: opacity 0.35s ease; }
#canvas.fading { opacity: 0; }

header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex: none;
  transition: background-color 0.25s, border-color 0.25s;
}

.drawer-toggle { display: none !important; font-size: 16px; }

.cascade {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.cascade-sep { color: var(--text-dim); font-size: 12px; }
.cascade select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 13px;
  max-width: 180px;
  cursor: pointer;
}
.cascade select:focus { outline: 1px solid var(--accent); }

.crumb {
  flex: none;
  padding: 8px 18px;
  font-size: 12px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  transition: background-color 0.25s;
}
.crumb b { color: var(--text); font-weight: 600; }

#scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 40;
}

@media (max-width: 959px) {
  .drawer-toggle { display: inline-flex !important; }
  .cascade select { max-width: 130px; }
  .brand .sub { display: none; }

  aside {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 50;
    width: min(330px, 86vw);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.35);
  }
  body.drawer-open aside { transform: translateX(0); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation-duration: 0.01ms !important; }
}

.brand { font-weight: 700; letter-spacing: 0.5px; color: var(--accent); }
.brand .sub { color: var(--text-dim); font-weight: 400; font-size: 12px; margin-left: 8px; }

.header-actions { display: flex; align-items: center; gap: 8px; }
.downloads { display: flex; align-items: center; gap: 6px; }
.dl-label { color: var(--text-dim); font-size: 12px; margin-right: 2px; }

#layout { flex: 1; display: flex; min-height: 0; }

aside {
  width: 330px;
  flex: none;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

aside h2 { font-size: 12px; color: var(--text-dim); font-weight: 600; letter-spacing: 1px; margin-bottom: 8px; }

.category { margin-bottom: 4px; }

button.category-title {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  border: none;
  background: none;
  padding: 0;
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 600;
  letter-spacing: 1px;
  text-align: left;
  cursor: pointer;
  margin: 14px 0 8px;
}
.category:first-child .category-title { margin-top: 0; }
.category-title:hover { color: var(--text); }
.category-title .chevron::before {
  content: '▾';
  display: inline-block;
  transition: transform 0.15s;
}
.category.collapsed .category-title .chevron::before { transform: rotate(-90deg); }
.category-title .cat-count {
  margin-left: auto;
  font-weight: 400;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}
.category.collapsed .category-items { display: none; }

.category-empty {
  color: var(--text-dim);
  font-size: 12px;
  opacity: 0.7;
  padding: 2px 0 4px;
}

.model-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  margin-bottom: 8px;
  background: var(--panel-2);
  transition: border-color 0.15s, transform 0.15s, background-color 0.25s;
}
.model-card:hover { border-color: var(--accent-2); transform: translateY(-1px); }
.model-card.active { border-color: var(--accent); }
.model-card .name { font-weight: 600; }
.model-card .desc { color: var(--text-dim); font-size: 12px; margin-top: 2px; }

#model-title { font-size: 16px; color: var(--text); margin-bottom: 4px; }
#model-desc { color: var(--text-dim); font-size: 12px; margin-bottom: 12px; }

.param { margin-bottom: 14px; }
.param .row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}
.param label { font-size: 13px; }
.param .value { font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 600; }
.param .value .unit { color: var(--text-dim); font-weight: 400; font-size: 11px; margin-left: 2px; }

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  background: transparent;
  height: 22px;
}

.panel-label { font-size: 12px; color: var(--text-dim); margin: 10px 0 6px; }
.hint-inline { opacity: 0.7; }

.derived { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.chip b { color: var(--text); font-weight: 600; }

.notes { margin-top: 8px; font-size: 12px; color: var(--warn); }
.notes:empty { display: none; }

.errors {
  margin-top: 10px;
  border: 1px solid rgba(239, 107, 107, 0.4);
  background: rgba(239, 107, 107, 0.08);
  color: var(--err);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  white-space: pre-line;
}

.build-row { display: flex; align-items: center; gap: 10px; margin-top: 16px; }

.confirm {
  border: 1px solid rgba(232, 176, 75, 0.4);
  background: rgba(232, 176, 75, 0.1);
  color: var(--warn);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  margin-bottom: 12px;
}
.confirm-actions { display: flex; gap: 8px; margin-top: 8px; }

.crumb-sep { margin: 0 4px; opacity: 0.6; }

.help {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-dim);
}
.help summary {
  cursor: pointer;
  color: var(--accent);
}
.help p {
  margin-top: 6px;
  line-height: 1.6;
}

.btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.btn:hover { border-color: var(--accent-2); }
.btn.primary {
  background: var(--accent-2);
  border-color: transparent;
  color: var(--primary-text);
  font-weight: 600;
  min-width: 96px;
  justify-content: center;
}
.btn.primary:hover:not(:disabled) { background: var(--accent-2-hover); }
.btn.primary:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.ghost { background: transparent; font-size: 12px; padding: 5px 10px; }

.badge {
  background: rgba(232, 176, 75, 0.15);
  color: var(--warn);
  border: 1px solid rgba(232, 176, 75, 0.4);
  border-radius: 999px;
  font-size: 11px;
  padding: 2px 10px;
}

main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

#viewport { position: relative; flex: 1; min-height: 0; }
#canvas { width: 100%; height: 100%; display: block; }

#hint {
  position: absolute;
  right: 12px;
  bottom: 10px;
  color: var(--text-dim);
  font-size: 11px;
  pointer-events: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--overlay);
  backdrop-filter: blur(2px);
}
.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#status {
  flex: none;
  border-top: 1px solid var(--line);
  background: var(--panel);
  padding: 7px 18px;
  font: 11px/1.5 "SF Mono", Menlo, Consolas, monospace;
  color: var(--text-dim);
  white-space: pre-wrap;
  max-height: 88px;
  overflow-y: auto;
}
