/* MatterBench 在线体验:全屏工具界面。默认深色;html[data-theme=light] 切浅色。 */
:root, html[data-theme="dark"]{
  --bg: #0F1013;
  --view: #141519;
  --side: #1A1B20;
  --raise: #23252B;
  --raise-2: #2C2F36;
  --line: #2C2F36;
  --text: #E6E7EA;
  --text-2: #8C9099;
  --accent: #2BB0C9;          /* OriginFab 青蓝,深色底上提亮一档 */
  --accent-2: #1F8FA6;
  --accent-soft: rgba(43, 176, 201, .14);
  --lime: #C6F04A;
  --warn: #F28B2E;
  --bad: #E5484D;
  --board: #1D1F24;
  --dot: #34373F;
  --grid: rgba(255, 255, 255, .06);
  --font: "Inter", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, Menlo, monospace;
  color-scheme: dark;
}
html[data-theme="light"]{
  --bg: #F6F6F2;
  --view: #ECECE6;
  --side: #FFFFFF;
  --raise: #F3F3EF;
  --raise-2: #E7E7E1;
  --line: #E5E6E8;
  --text: #16181D;
  --text-2: #747982;
  --accent: #1F8FA6;
  --accent-2: #187488;
  --accent-soft: rgba(31, 143, 166, .10);
  --board: #FFFFFF;
  --dot: #DADAD3;
  --grid: rgba(22, 24, 29, .07);
  color-scheme: light;
}

*{ box-sizing: border-box; }
html, body{ height: 100%; }
body{
  margin: 0; display: flex; flex-direction: column; overflow: hidden;
  background: var(--bg); color: var(--text); font: 13px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, select{ font: inherit; color: inherit; }
button{ cursor: pointer; }
a{ color: inherit; }
svg{ width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden]{ display: none !important; }

/* ---- 顶栏 ---- */
.bar{
  height: 48px; flex: none; display: flex; align-items: center; gap: 12px; padding: 0 12px;
  background: var(--side); border-bottom: 1px solid var(--line);
}
.logo{ display: flex; align-items: center; gap: 8px; text-decoration: none; white-space: nowrap; }
.logo img{ width: 26px; height: 26px; }
.logo b{ font-size: 15px; }
.ver{ color: var(--text-2); font-size: 11px; }
.bar-mid{ display: flex; gap: 2px; margin-left: auto; }
.bar-right{ display: flex; align-items: center; gap: 4px; margin-left: 16px; }
.icon{
  width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 6px;
  background: transparent; color: var(--text-2);
}
.icon:hover:not(:disabled){ background: var(--raise); color: var(--text); }
.icon:disabled{ opacity: .35; cursor: default; }
.txt{
  height: 30px; padding: 0 12px; border: 0; border-radius: 6px; background: var(--raise);
  font-weight: 600; font-size: 12px; text-decoration: none; display: inline-flex; align-items: center; white-space: nowrap;
}
.txt:hover{ background: var(--raise-2); }

/* ---- 主区 ---- */
.app{ flex: 1; min-height: 0; display: flex; }
.view{ position: relative; flex: 1; min-width: 0; background: var(--view); overflow: hidden; }
.stage2d, .stage3d{ position: absolute; inset: 0; }
.stage2d{ display: grid; place-items: center; }
.stage2d canvas{ display: block; touch-action: none; }
#board{ cursor: crosshair; }
.stage3d canvas{ display: block; outline: none; }
.view-tabs{
  position: absolute; top: 12px; left: 12px; z-index: 3; display: flex; padding: 3px; gap: 2px;
  background: var(--side); border: 1px solid var(--line); border-radius: 8px;
}
.view-tabs button{ border: 0; background: transparent; padding: 5px 12px; border-radius: 6px; color: var(--text-2); font-weight: 600; font-size: 12px; }
.view-tabs button[aria-selected="true"]{ background: var(--raise-2); color: var(--text); }
.view-msg{
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 2;
  background: var(--side); border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; color: var(--text-2); max-width: 320px; text-align: center;
}
.collapse{
  position: absolute; right: 0; top: 50%; transform: translateY(-50%); z-index: 3;
  width: 18px; height: 48px; border: 1px solid var(--line); border-right: 0; border-radius: 6px 0 0 6px;
  background: var(--side); color: var(--text-2); display: grid; place-items: center; padding: 0;
}
.collapse svg{ width: 14px; height: 14px; }
.app.side-off .side{ display: none; }
.app.side-off .collapse svg{ transform: rotate(180deg); }

/* ---- 侧栏 ---- */
.side{
  width: 340px; flex: none; overflow-y: auto; background: var(--side); border-left: 1px solid var(--line);
  scrollbar-width: thin; scrollbar-color: var(--raise-2) transparent;
}
.side-top{ padding: 14px 16px 10px; border-bottom: 1px solid var(--line); display: grid; gap: 10px; }
.fine{ margin: 0; font-size: 11px; color: var(--text-2); text-align: center; }
.grp{ padding: 14px 16px; border-bottom: 1px solid var(--line); }
.grp h4{
  margin: 0 0 10px; font-size: 11px; font-weight: 600; letter-spacing: .08em; color: var(--text-2);
  display: flex; align-items: center; gap: 6px;
}
.tip{
  display: inline-grid; place-items: center; width: 13px; height: 13px; border-radius: 50%;
  border: 1px solid var(--text-2); font: 600 9px/1 var(--font); cursor: help; letter-spacing: 0;
}
.grp > * + *{ margin-top: 10px; }
.grp > h4 + *{ margin-top: 0; }

.seg{ display: flex; gap: 2px; padding: 3px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
.seg button{ flex: 1; border: 0; background: transparent; padding: 6px 4px; border-radius: 6px; color: var(--text-2); font-weight: 600; font-size: 12px; }
.seg button[aria-selected="true"], .seg button[aria-pressed="true"]{ background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

.btn-main{
  height: 36px; display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--raise); border-radius: 8px; font-weight: 600;
}
.btn-main:hover{ background: var(--raise-2); }
.btn-sub{
  height: 32px; width: 100%; border: 1px solid var(--line); background: var(--raise); border-radius: 6px; font-weight: 600; font-size: 12px;
}
.btn-sub:hover{ background: var(--raise-2); }
.btn-go{
  height: 38px; width: 100%; border: 0; border-radius: 8px; background: var(--accent-2); color: #fff; font-weight: 700; font-size: 14px;
}
.btn-go:hover{ background: var(--accent); }
.row{ display: flex; gap: 8px; align-items: center; }
.row2{ display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grow{ flex: 1; }
input[type="color"]{ width: 40px; height: 32px; border: 1px solid var(--line); border-radius: 6px; padding: 2px; background: var(--raise); }

.swatches{ display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 6px; }
.swatch{
  aspect-ratio: 1; border-radius: 6px; border: 0; padding: 0; position: relative;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08), inset 0 0 0 1px rgba(0, 0, 0, .25);
}
.swatch::after{ /* 管段的孔 */
  content: ""; position: absolute; inset: 34%; border-radius: 50%; background: rgba(0, 0, 0, .18);
}
.swatch[aria-pressed="true"]{ outline: 2px solid var(--accent); outline-offset: 2px; }
select, input[type="number"]{
  height: 30px; border: 1px solid var(--line); border-radius: 6px; background: var(--raise); padding: 0 8px; min-width: 0;
}
.slider{ display: grid; grid-template-columns: 82px 1fr 56px; align-items: center; gap: 10px; }
.slider label{ color: var(--text-2); }
.slider output, .slider input[type="number"]{
  height: 26px; border: 1px solid var(--line); border-radius: 6px; background: var(--raise);
  font: 12px/24px var(--mono); text-align: right; padding: 0 6px; width: 100%;
}
input[type="range"]{ width: 100%; accent-color: var(--accent); }
.check{ display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.check input{ accent-color: var(--accent); margin: 0; }

.stats{ display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.stats div{ background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 7px 8px; }
.stats b{ display: block; font: 700 15px var(--mono); }
.stats span{ font-size: 11px; color: var(--text-2); }

.bom{ width: 100%; border-collapse: collapse; font-size: 12px; }
.bom td, .bom th{ padding: 6px 2px; border-bottom: 1px solid var(--line); text-align: left; }
.bom th{ color: var(--text-2); font-weight: 500; }
.bom .num{ text-align: right; font-family: var(--mono); }
.dot{ display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 6px; box-shadow: inset 0 0 0 1px rgba(127, 127, 127, .4); }

.side-foot{ display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; padding: 16px; font-size: 12px; color: var(--text-2); }
.side-foot a, .side-foot button{ color: var(--text-2); text-decoration: none; background: none; border: 0; padding: 0; }
.side-foot a:hover, .side-foot button:hover{ color: var(--text); }

/* ---- 状态栏 ---- */
.status{
  height: 30px; flex: none; display: flex; align-items: center; gap: 16px; padding: 0 12px;
  background: var(--side); border-top: 1px solid var(--line); font-size: 11px; color: var(--text-2); white-space: nowrap; overflow: hidden;
}
.status .hint{ margin-left: auto; }

/* ---- 弹窗 ---- */
.modal-back{ position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .55); display: grid; place-items: center; padding: 16px; }
.modal{
  position: relative; width: min(540px, 100%); max-height: calc(100dvh - 32px); overflow: auto;
  background: var(--side); border: 1px solid var(--line); border-radius: 12px; padding: 24px 26px; box-shadow: 0 20px 60px rgba(0, 0, 0, .4);
}
.modal h2{ margin: 0 0 8px; font-size: 18px; }
.modal h5{ margin: 18px 0 6px; font-size: 12px; letter-spacing: .06em; color: var(--accent); }
.modal p{ color: var(--text-2); margin: 0 0 8px; }
.modal ol, .modal ul{ margin: 0; padding-left: 20px; color: var(--text-2); display: grid; gap: 4px; }
.modal b{ color: var(--text); }
.modal .fine{ text-align: left; margin: 16px 0 14px; }
.modal-x{ position: absolute; right: 12px; top: 12px; }

/* ---- 窄屏:视窗在上,侧栏在下 ---- */
@media (max-width: 820px) {
  body{ overflow: auto; height: auto; }
  .app{ flex-direction: column; }
  .view{ flex: none; height: 62vh; }
  .side{ width: auto; border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  .collapse, .hide-sm, .ver, .status .hint{ display: none; }
  .app.side-off .side{ display: block; }
  .bar{ gap: 6px; padding: 0 8px; }
  .bar-right{ margin-left: 4px; }
  .bar-right .txt{ padding: 0 8px; }
  .status{ position: sticky; bottom: 0; }
}
@media (max-width: 480px) {
  .logo b{ display: none; }
  #clear{ display: none; }
}

/* ---- 宣传页体验版补充 ---- */
.txt-go{ background: #C6F04A; color: #16181D; }
.txt-go:hover{ background: #d6f87a; }
.stats-2{ grid-template-columns: repeat(2, 1fr); }
.cta-box{ display: grid; gap: 8px; background: var(--accent-soft); }
.cta-box b{ font-size: 14px; }
.cta-box p{ margin: 0; color: var(--text-2); }
.cta-box .btn-go{ display: grid; place-items: center; text-decoration: none; }

/* ---- 拼豆灯罩 ---- */
.lamp-switch{
  position: absolute; top: 12px; right: 30px; z-index: 3; display: flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 14px 0 10px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--side); color: var(--text); font-weight: 700; font-size: 12px;
}
.lamp-switch[aria-pressed="true"]{ background: #FFB65C; border-color: #FFB65C; color: #16181D; box-shadow: 0 0 24px rgba(255, 182, 92, .55); }
.view.night{ background: #07080A; }
.tpl-row{ display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.tpl{
  display: grid; justify-items: center; gap: 4px; padding: 6px 2px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--raise); font-size: 11px; font-weight: 600; color: var(--text-2);
}
.tpl:hover{ color: var(--text); border-color: var(--accent); }
.tpl i{ width: 34px; height: 34px; border-radius: 6px; display: block; box-shadow: inset 0 0 0 1px rgba(127, 127, 127, .3); }
.chips-s{ display: flex; flex-wrap: wrap; gap: 6px; }
.chips-s button{
  border: 1px solid var(--line); background: var(--raise); border-radius: 999px; padding: 5px 10px;
  font-size: 12px; font-weight: 600; color: var(--text-2);
}
.chips-s button:hover{ color: var(--text); }
.chips-s button[aria-pressed="true"]{ background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.bom + .bom{ margin-top: 8px; }
.row2 .btn-sub{ width: 100%; }
@media (max-width: 820px) { .lamp-switch{ right: 12px; } }
