/* =========================================================
   BrickMosaic · 乐高分布图工坊
   ========================================================= */

:root {
  --bg: #0b0e13;
  --panel: #11161e;
  --panel-2: #161d27;
  --line: #232d3b;
  --line-strong: #33415a;
  --text: #e8edf5;
  --muted: #8a97a8;
  --dim: #66748a;
  --accent: #f2cd37;
  --accent-strong: #ffd83d;
  --red: #e4402b;
  --blue: #3d7dff;
  --radius: 14px;
  --shadow: 0 18px 46px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: radial-gradient(1200px 700px at 18% -10%, #17202c 0%, var(--bg) 62%) fixed;
  color: var(--text);
  font: 13px/1.5 "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

h1, h2, h3, p { margin: 0; }
button { font-family: inherit; }
button:focus-visible, summary:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------------- 顶栏 ---------------- */

.topbar {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 16px;
  border-bottom: 1px solid #1b2431;
  background: rgba(11, 14, 19, .82);
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { display: grid; place-items: center; filter: drop-shadow(0 4px 10px rgba(242, 205, 55, .25)); }
.brand-text { display: flex; align-items: baseline; gap: 9px; white-space: nowrap; }
.brand-text strong { font-size: 16px; letter-spacing: .01em; }
.brand-text span { font-size: 12px; color: var(--muted); }

.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-sep { width: 1px; height: 20px; background: var(--line); margin: 0 2px; }

/* ---------------- 通用控件 ---------------- */

.btn {
  height: 34px;
  padding: 0 13px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 12.5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: background .16s, border-color .16s, transform .16s;
  white-space: nowrap;
}
.btn:hover { background: #1b2431; border-color: var(--line-strong); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(180deg, #ffd83d, #efb800);
  border-color: #d8a700;
  color: #14181d;
  font-weight: 700;
  box-shadow: 0 6px 16px rgba(242, 205, 55, .22);
}
.btn.primary:hover { background: linear-gradient(180deg, #ffe066, #f6c313); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.tiny { height: 28px; padding: 0 10px; font-size: 11.5px; border-radius: 8px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }

.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background .16s, border-color .16s;
}
.icon-btn:hover { background: #1b2431; border-color: var(--line-strong); }

/* ---------------- 布局 ---------------- */

.layout {
  height: calc(100vh - 58px);
  display: grid;
  grid-template-columns: 316px minmax(0, 1fr) 318px;
  gap: 12px;
  padding: 12px;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  min-height: 0;
}

/* ---------------- 卡片 ---------------- */

.card {
  background: linear-gradient(180deg, rgba(22, 29, 39, .96), rgba(17, 22, 30, .96));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 13px 12px;
  flex: none;
}

.card h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .1em;
  color: #a9b6c8;
  margin-bottom: 9px;
}

.step {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  background: rgba(242, 205, 55, .14);
  color: var(--accent);
  font-size: 11px;
  display: grid;
  place-items: center;
  letter-spacing: 0;
  flex: none;
}

/* 可折叠卡片（画面微调） */
.card-collapse { padding: 10px 13px; }
.card-collapse > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .1em;
  color: #a9b6c8;
}
.card-collapse > summary::-webkit-details-marker { display: none; }
.card-collapse > summary::after {
  content: "▾";
  margin-left: auto;
  color: var(--dim);
  transition: transform .16s;
}
.card-collapse[open] > summary::after { transform: rotate(180deg); }
.card-collapse .sub { letter-spacing: 0; font-weight: 400; margin-left: 2px; }
.card-body { padding-top: 11px; }

.sub { font-size: 11px; font-weight: 400; color: var(--dim); letter-spacing: 0; }
.hint { font-size: 11px; color: var(--dim); line-height: 1.65; margin-top: 7px; }
.hint.warn { color: #f0a35e; }

/* ---------------- 上传区 ---------------- */

.dropzone {
  border: 1.5px dashed #2c3a4f;
  border-radius: 12px;
  padding: 12px 12px;
  text-align: center;
  cursor: pointer;
  color: var(--muted);
  background: rgba(255, 255, 255, .014);
  transition: border-color .18s, background .18s, color .18s;
}
.dropzone:hover, .dropzone.drag {
  border-color: var(--accent);
  background: rgba(242, 205, 55, .06);
  color: var(--accent);
}
.dz-icon { opacity: .85; }
.dz-title { font-size: 12.5px; font-weight: 600; color: var(--text); margin-top: 7px; }
.dz-sub { font-size: 11px; color: var(--dim); margin-top: 3px; }
.dropzone.drag .dz-title { color: var(--accent); }

.file-info { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.file-info[hidden] { display: none; }
.file-info img {
  width: 46px; height: 46px; object-fit: cover;
  border-radius: 9px; border: 1px solid var(--line); background: #000;
  flex: none;
}
.file-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.file-meta strong { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta span { font-size: 10.5px; color: var(--dim); }

/* ---------------- 表单 ---------------- */

.field { display: block; margin-bottom: 10px; }
.field:last-of-type { margin-bottom: 6px; }
.field-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11.5px;
  color: #a9b6c8;
  margin-bottom: 6px;
}
.field-label b { color: var(--accent); font-size: 12.5px; font-variant-numeric: tabular-nums; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: #2a3546;
  outline: none;
  margin: 6px 0 2px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #0b0e13;
  box-shadow: 0 0 0 1px rgba(242, 205, 55, .45), 0 2px 6px rgba(0, 0, 0, .5);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #0b0e13;
  cursor: pointer;
}

select {
  width: 100%;
  height: 32px;
  padding: 0 9px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #0f141c;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}

.pill-row { display: flex; gap: 5px; }
.pill-row button {
  flex: 1;
  min-width: 0;
  height: 25px;
  padding: 0;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #0f141c;
  color: #9fb0c6;
  font-size: 11px;
  cursor: pointer;
  transition: .16s;
}
.pill-row button:hover { border-color: var(--line-strong); color: var(--text); }
.pill-row button.active {
  background: rgba(242, 205, 55, .15);
  border-color: rgba(242, 205, 55, .55);
  color: var(--accent);
}

.preset-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 8px 0 0; }
.preset-row button {
  height: 37px;
  padding: 0 9px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #0f141c;
  color: #a9b6c8;
  font-size: 11.5px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  transition: .16s;
}
.preset-row button small { font-size: 9.5px; color: var(--dim); }
.preset-row button:hover { border-color: var(--line-strong); }
.preset-row button.active {
  border-color: rgba(242, 205, 55, .55);
  background: rgba(242, 205, 55, .09);
  color: var(--accent);
}
.preset-row button.active small { color: #c9a92e; }

.palette-details { margin-top: 11px; border-top: 1px solid var(--line); padding-top: 9px; }
.palette-details summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  color: #9fb0c6;
  cursor: pointer;
  list-style: none;
}
.palette-details summary::-webkit-details-marker { display: none; }
.palette-details summary::before {
  content: "▸";
  color: var(--dim);
  margin-right: 5px;
  transition: transform .16s;
  display: inline-block;
}
.palette-details[open] summary::before { transform: rotate(90deg); }
.palette-details summary span { margin-left: auto; }

.swatch-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin-top: 10px;
}
.swatch {
  position: relative;
  aspect-ratio: 1;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, .16);
  cursor: pointer;
  padding: 0;
  background: var(--sw);
  transition: transform .14s, opacity .14s, filter .14s;
}
.swatch:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0, 0, 0, .45); }
.swatch.off { opacity: .25; filter: grayscale(1); }
.swatch.off::after {
  content: "×";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 14px;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .8);
}

.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.seg button {
  height: 42px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0f141c;
  color: #a9b6c8;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  transition: .16s;
}
.seg button small { font-size: 9.5px; font-weight: 400; color: var(--dim); }
.seg button:hover { border-color: var(--line-strong); }
.seg button.active {
  background: linear-gradient(180deg, rgba(242, 205, 55, .2), rgba(242, 205, 55, .05));
  border-color: rgba(242, 205, 55, .6);
  color: var(--accent-strong);
}

.switch-row { display: flex; flex-direction: column; gap: 8px; margin-top: 11px; }

/* 大颗粒规格开关 */
.size-chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin-top: 8px; }
.size-chips.off { opacity: .38; pointer-events: none; }
.size-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 27px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0f141c;
  color: #a9b6c8;
  font-size: 11px;
  cursor: pointer;
  user-select: none;
  transition: border-color .16s, color .16s, background .16s;
}
.size-chip:hover { border-color: var(--line-strong); }
.size-chip input {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  margin: 0;
  border-radius: 4px;
  border: 1px solid #3a4a60;
  background: #131a23;
  position: relative;
  cursor: pointer;
  flex: none;
}
.size-chip input:checked { background: var(--accent); border-color: var(--accent); }
.size-chip input:checked::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 3px;
  height: 7px;
  border: solid #14181d;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.size-chip.on { border-color: rgba(242, 205, 55, .45); color: var(--accent); }
.switch { display: flex; align-items: center; gap: 9px; font-size: 11.5px; color: #a9b6c8; cursor: pointer; user-select: none; }
.switch input {
  appearance: none;
  -webkit-appearance: none;
  width: 32px; height: 18px;
  border-radius: 9px;
  background: #26313f;
  position: relative;
  cursor: pointer;
  transition: background .18s;
  flex: none;
  margin: 0;
}
.switch input::after {
  content: "";
  position: absolute;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #8fa0b4;
  top: 2px; left: 2px;
  transition: left .18s, background .18s;
}
.switch input:checked { background: rgba(242, 205, 55, .32); }
.switch input:checked::after { left: 16px; background: var(--accent); }

/* ---------------- 画布区 ---------------- */

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; height: 30px; padding: 0 2px; }
.toolbar-group { display: flex; align-items: center; gap: 7px; }
.toolbar-right { min-width: 0; }
.zoom-label {
  font-size: 11.5px;
  color: #9fb0c6;
  min-width: 44px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.focus-tip { font-size: 11.5px; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  border-radius: 16px;
  border: 1px solid var(--line);
  overflow: hidden;
  background-color: #0d1117;
  background-image: radial-gradient(circle at 1px 1px, rgba(255, 255, 255, .05) 1px, transparent 0);
  background-size: 22px 22px;
  box-shadow: inset 0 0 90px rgba(0, 0, 0, .5);
}

#mosaicCanvas {
  position: absolute;
  inset: 0;
  display: block;
  cursor: grab;
  touch-action: none;
}
.stage.panning #mosaicCanvas { cursor: grabbing; }
.stage.busy #mosaicCanvas { opacity: .45; }
.stage.busy::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(11, 14, 19, .25);
}

.tooltip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  background: rgba(10, 14, 20, .95);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 11.5px;
  color: #dbe4f0;
  white-space: nowrap;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .55);
}
.tooltip[hidden] { display: none; }
.tooltip b { color: #fff; }
.tooltip .dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  margin-right: 5px;
  vertical-align: -1px;
  border: 1px solid rgba(255, 255, 255, .35);
}
.tooltip .row { display: flex; align-items: center; gap: 6px; }
.tooltip .tip-meta { color: #93a1b4; font-size: 10.5px; margin-top: 2px; }

.stage-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 4;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  color: var(--accent);
  background: rgba(242, 205, 55, .13);
  border: 1px solid rgba(242, 205, 55, .5);
}
.stage-badge[hidden] { display: none; }

.empty {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: 26px;
  background: radial-gradient(60% 60% at 50% 38%, rgba(18, 24, 33, .8), rgba(11, 14, 19, .94));
  backdrop-filter: blur(2px);
}
.empty[hidden] { display: none; }
.empty-card { max-width: 620px; text-align: center; }
.empty-card h3 { font-size: 21px; letter-spacing: -.01em; margin-bottom: 8px; }
.empty-card p { font-size: 12.5px; color: #93a1b4; line-height: 1.7; }
.sample-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 11px; margin: 20px 0 13px; }
.sample-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #0f141c;
  cursor: pointer;
  padding: 0;
  text-align: left;
  color: var(--text);
  transition: transform .16s, border-color .16s;
}
.sample-card:hover { transform: translateY(-2px); border-color: rgba(242, 205, 55, .55); }
.sample-card img { width: 100%; height: 96px; object-fit: cover; display: block; }
.sample-card .sc-body { padding: 8px 10px 9px; }
.sample-card strong { display: block; font-size: 12px; }
.sample-card span { display: block; font-size: 10px; color: var(--dim); margin-top: 2px; line-height: 1.45; }
.empty-tip { font-size: 10.5px; color: var(--dim); }

.statusbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  height: 15px;
  padding: 0 5px;
  font-size: 11px;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
}
.statusbar span { overflow: hidden; text-overflow: ellipsis; }

/* ---------------- 右侧数据 ---------------- */

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.stat {
  min-width: 0;
  padding: 7px 9px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #0e131a;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat span { font-size: 10px; color: var(--dim); letter-spacing: .03em; }
.stat b {
  font-size: 13px;
  font-weight: 700;
  color: #eef3fb;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.size-summary { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.size-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 3px 7px;
  border-radius: 7px;
  background: #0e131a;
  border: 1px solid var(--line);
  font-size: 10.5px;
  color: #9fb0c6;
}
.size-pill b { color: #eef3fb; font-size: 11px; font-variant-numeric: tabular-nums; }
.size-pill i { color: var(--dim); font-style: normal; font-size: 9.5px; }

.part-mix { font-size: 9.5px; color: #7f8da0; line-height: 1.6; display: flex; flex-wrap: wrap; gap: 2px 8px; }
.mix-item { white-space: nowrap; }

.parts-tabs { display: flex; gap: 5px; margin: 2px 0 9px; }
.tab {
  flex: 1;
  height: 26px;
  padding: 0 6px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #0f141c;
  color: #9fb0c6;
  font-size: 11px;
  cursor: pointer;
  transition: border-color .16s, color .16s, background .16s;
}
.tab:hover { border-color: var(--line-strong); color: var(--text); }
.tab.active { background: rgba(242, 205, 55, .14); border-color: rgba(242, 205, 55, .55); color: var(--accent); }
#btnMatrix { flex: none; padding: 0 9px; }

.size-box {
  width: 40px;
  height: 30px;
  border-radius: 7px;
  background: #0f141c;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-size: 10.5px;
  font-weight: 800;
  color: #dfe7f2;
}
.size-row .part-mix { font-size: 10px; }
.mini-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  margin: 0 3px 0 7px;
  vertical-align: -1px;
  border: 1px solid rgba(255, 255, 255, .25);
}
.mini-dot:first-child { margin-left: 0; }

.matrix-sub { font-size: 11px; color: var(--dim); margin: -6px 0 10px; }
.matrix-wrap { max-height: 62vh; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
table.matrix { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 11.5px; }
table.matrix th, table.matrix td {
  padding: 6px 9px;
  border-bottom: 1px solid #1d2633;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
table.matrix thead th { position: sticky; top: 0; background: #131a23; color: #a9b6c8; font-weight: 600; z-index: 2; }
table.matrix thead th:first-child { z-index: 3; background: #131a23; text-align: left; }
table.matrix tbody td:first-child, table.matrix tfoot td:first-child {
  position: sticky; left: 0; background: #0f141c; text-align: left; z-index: 1;
}
table.matrix tfoot td { font-weight: 800; background: #10161f; color: #eef3fb; border-top: 1px solid var(--line-strong); }
table.matrix .sw {
  display: inline-block; width: 9px; height: 9px; border-radius: 2px;
  margin-right: 4px; vertical-align: -1px; border: 1px solid rgba(255, 255, 255, .3);
}
table.matrix td.zero { color: #3c4a5e; }
.modal-actions { display: flex; justify-content: flex-end; margin-top: 12px; }
.modal-card.wide { width: min(1040px, 100%); }

.parts-card { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 170px; }
.parts-list { display: flex; flex-direction: column; gap: 5px; overflow-y: auto; flex: 1; min-height: 0; padding-right: 2px; }
.part-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: start;
  padding: 6px 8px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #0e131a;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color .14s, background .14s;
}
.part-row:hover { border-color: var(--line-strong); background: #101722; }
.part-row.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px rgba(242, 205, 55, .3); }
.chip {
  position: relative;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--sw);
  border: 1px solid rgba(255, 255, 255, .2);
  display: grid;
  place-items: center;
  font-size: 10.5px;
  font-weight: 800;
  color: var(--chip-ink, #14181d);
}
.part-name { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.part-name b { font-size: 11.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.part-name span { font-size: 10px; color: #718096; }
.part-count { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.part-count b { font-size: 12px; font-variant-numeric: tabular-nums; }
.part-count span { font-size: 10px; color: #718096; }
.placeholder { font-size: 11px; color: var(--dim); line-height: 1.7; }

.export-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.export-grid .btn { width: 100%; }

/* ---------------- 弹窗 / 提示 ---------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(5, 8, 12, .74);
  backdrop-filter: blur(4px);
}
.modal[hidden] { display: none; }
.modal-card {
  position: relative;
  width: min(720px, 100%);
  max-height: 86vh;
  overflow: auto;
  padding: 22px 22px 18px;
  border-radius: 16px;
  border: 1px solid #2a3546;
  background: #131922;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .65);
}
.modal-card h3 { font-size: 16px; margin-bottom: 14px; }
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0f141c;
  color: #a9b6c8;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover { background: #1b2431; color: #fff; }
.modal-samples { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.help-list { margin: 0 0 12px 18px; font-size: 12.5px; line-height: 1.95; color: #b9c5d6; }
.help-list b { color: #fff; }
.help-note { font-size: 11px; color: var(--dim); }

.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 9px 14px;
  border-radius: 9px;
  border: 1px solid #33415a;
  border-left: 3px solid var(--accent);
  background: #1a2230;
  color: #e8edf5;
  font-size: 12px;
  box-shadow: var(--shadow);
  animation: toast-in .18s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #26313f; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #33415a; }
::-webkit-scrollbar-track { background: transparent; }

::selection { background: rgba(242, 205, 55, .28); }

/* ---------------- 响应式 ---------------- */

@media (max-width: 1400px) {
  .layout { grid-template-columns: 288px minmax(0, 1fr) 292px; }
  .swatch-grid { grid-template-columns: repeat(5, 1fr); }
}

@media (max-width: 1180px) {
  body { overflow: auto; }
  .layout {
    height: auto;
    grid-template-columns: 1fr;
    padding: 10px;
  }
  .panel { overflow: visible; }
  .workspace { order: -1; height: 68vh; min-height: 460px; }
  .panel-left, .panel-right { display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
  .panel-right .parts-card { grid-column: span 1; max-height: 320px; }
  .sample-grid { grid-template-columns: repeat(3, 1fr); }
  .empty-card h3 { font-size: 18px; }
}

@media (max-width: 720px) {
  .topbar { padding: 0 10px; }
  .brand-text span { display: none; }
  .brand-text strong { font-size: 14px; }
  .btn.ghost { display: none; }
  .panel-left, .panel-right { grid-template-columns: 1fr; }
  .sample-grid { grid-template-columns: 1fr; }
  .sample-card img { height: 84px; }
  .modal-samples { grid-template-columns: 1fr; }
  .empty-card p { font-size: 11.5px; }
}
