:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #1d2329;
  --muted: #5f6b76;
  --line: #dde3e8;
  --accent: #1f6feb;
  --accent-text: #ffffff;
  --err: #c62828;
  --input: #ffffff;
  --warn-bg: #fff6e0;
  --warn-line: #e8c879;
  --warn-text: #6b4a00;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15191d;
    --panel: #1e2328;
    --text: #e6e9ec;
    --muted: #9aa5b0;
    --line: #333b43;
    --accent: #4d8ff5;
    --input: #262c32;
    --err: #ef6b6b;
    --warn-bg: #392f15;
    --warn-line: #6b5520;
    --warn-text: #f2d89c;
  }
}
:root[data-theme="dark"] {
  --bg: #15191d; --panel: #1e2328; --text: #e6e9ec; --muted: #9aa5b0;
  --line: #333b43; --accent: #4d8ff5; --input: #262c32; --err: #ef6b6b;
  --warn-bg: #392f15; --warn-line: #6b5520; --warn-text: #f2d89c;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
}
.topbar {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px;
  padding: 14px 20px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.topbar h1 { margin: 0; font-size: 20px; }
.topbar .sub { color: var(--muted); font-size: 13px; }

.notice {
  display: flex; align-items: flex-start; gap: 10px; padding: 9px 20px; font-size: 13px;
  background: var(--warn-bg); color: var(--warn-text); border-bottom: 1px solid var(--warn-line);
}
.notice p { margin: 0; flex: 1; min-width: 0; }
.notice code { background: rgba(127, 127, 127, .22); color: inherit; }
.notice .ico {
  flex: none; width: 18px; height: 18px; border-radius: 50%; margin-top: 1px;
  background: var(--warn-line); color: var(--warn-text);
  font-size: 12px; font-weight: 700; line-height: 18px; text-align: center;
}
.notice button {
  flex: none; padding: 3px 10px; font-size: 12px;
  background: transparent; color: inherit; border-color: var(--warn-line);
}
.notice button:hover { border-color: var(--warn-text); }

.layout { display: grid; grid-template-columns: 340px 1fr; min-height: calc(100vh - var(--chrome, 56px)); }
.panel { background: var(--panel); border-right: 1px solid var(--line); padding: 8px 16px 32px; overflow-y: auto; max-height: calc(100vh - var(--chrome, 56px)); position: sticky; top: 0; }
.panel section { padding: 12px 0; border-bottom: 1px solid var(--line); }
.panel h2 { font-size: 15px; margin: 0 0 10px; }
.panel h3 { font-size: 13px; margin: 14px 0 8px; color: var(--muted); }

label { display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; color: var(--muted); }
label.chk { flex-direction: row; align-items: center; gap: 6px; color: var(--text); font-size: 13px; }
label.full { margin: 8px 0; }
input[type="text"], input[type="number"], select {
  width: 100%; padding: 5px 7px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--input); color: var(--text); font: inherit; font-size: 13px;
}
input[type="color"] { width: 36px; height: 26px; padding: 0 2px; border: 1px solid var(--line); border-radius: 5px; background: var(--input); cursor: pointer; }

.row { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 8px 0; }
.row > label:not(.chk) { flex: 1 1 130px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; margin: 8px 0; }

.btns { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
button {
  font: inherit; font-size: 13px; padding: 6px 10px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--line); background: var(--input); color: var(--text);
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.ghost { background: transparent; }
button:disabled { opacity: .6; cursor: wait; }
.btns.small button { padding: 3px 8px; font-size: 12px; }

.drop {
  display: block; border: 2px dashed var(--line); border-radius: 8px; padding: 18px 10px;
  text-align: center; cursor: pointer; color: var(--muted); font-size: 13px;
}
.drop:hover, .drop.over { border-color: var(--accent); color: var(--text); }
.drop input { display: none; }

.status { font-size: 12.5px; color: var(--muted); margin: 6px 0; }
.status.err { color: var(--err); }
.hint { font-size: 12px; color: var(--muted); margin: 4px 0 8px; }
.help { font-size: 12.5px; color: var(--muted); }
.help summary { cursor: pointer; }
code { font-size: 12px; background: var(--bg); padding: 1px 4px; border-radius: 4px; }

.checklist { display: flex; flex-direction: column; gap: 3px; max-height: 180px; overflow-y: auto; padding: 4px 0; }
.countColors { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 6px 0; }
.countColors label { flex-direction: row; align-items: center; gap: 6px; color: var(--text); }

table.markers { width: 100%; border-collapse: collapse; }
table.markers th { font-size: 12px; color: var(--muted); font-weight: 500; text-align: left; padding: 2px 4px; }
table.markers td { padding: 2px 4px; }
table.markers td:first-child, table.markers td:last-child { width: 40px; }

.preview { padding: 20px; min-width: 0; }
.statsPanel { margin-top: 18px; }
.statsPanel .canvasWrap { min-height: 0; }
.statsPanel table.data { margin-top: 4px; }
.canvasWrap {
  background: #ffffff; border: 1px solid var(--line); border-radius: 8px; padding: 12px;
  overflow: auto; min-height: 300px; display: flex; align-items: flex-start; justify-content: center;
}
.canvasWrap svg { max-width: 100%; height: auto; }
.cards { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; width: 100%; }
.card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  border: 1px solid #e3e7eb; border-radius: 8px; padding: 8px 8px 10px; background: #ffffff;
  max-width: 100%;
}
.card svg { width: 340px; max-width: 100%; height: auto; }
.card button { background: #ffffff; color: #1d2329; border-color: #d0d6dc; font-size: 12px; padding: 3px 10px; }
.empty { color: #7a8590; margin: auto; padding: 40px; text-align: center; }

.tableWrap { margin-top: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; }
.tableWrap summary { cursor: pointer; font-weight: 600; }
#table { overflow-x: auto; }
table.data { border-collapse: collapse; margin-top: 10px; font-size: 12.5px; }
table.data th, table.data td { padding: 4px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
table.data th:first-child, table.data td:first-child { text-align: left; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .panel { position: static; max-height: none; border-right: 0; border-bottom: 1px solid var(--line); }
  .preview { padding: 16px; }
}
