* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
:root {
  --bg: #171411;
  --bg2: #1f1b17;
  --panel: #241f1a;
  --line: #3a332b;
  --text: #e9e2d8;
  --muted: #9c9184;
  --accent: #d1683a;
  --accent2: #e08a5c;
  --danger: #c14b3f;
  --full: #b4633a;
  --half: #c98a5a;
  --channel: #5f8a96;
  --channelhalf: #8fb3bd;
}
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Segoe UI", system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 14px;
  height: 50px;
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; white-space: nowrap; color: var(--text); text-decoration: none; }
.brand img { display: block; }
.brand:hover span { color: var(--text); }
.brand span { color: var(--muted); font-weight: 400; font-size: 12px; }
.tabs { display: flex; gap: 4px; }
button {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  font: inherit;
}
button:hover { border-color: var(--muted); }
button.accent, .tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
button.accent:hover { background: var(--accent2); }
button.ghost { border-color: transparent; color: var(--muted); }
button.ghost:hover { color: var(--text); border-color: var(--line); }
button.ghost.danger:hover { color: var(--danger); }
button.danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.header-actions { margin-left: auto; display: flex; gap: 4px; }
main { flex: 1; display: flex; min-height: 0; }
#viewport { flex: 1; position: relative; min-width: 0; background: var(--bg); }
#viewport canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
#hint-bar {
  position: absolute;
  left: 12px;
  bottom: 12px;
  background: rgba(31, 27, 23, 0.92);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12.5px;
  color: var(--muted);
  pointer-events: none;
  max-width: 70%;
}
#hint-bar b { color: var(--text); }
#coords {
  position: absolute;
  right: 12px;
  bottom: 12px;
  font-size: 12px;
  color: var(--muted);
  background: rgba(31, 27, 23, 0.85);
  border-radius: 6px;
  padding: 4px 10px;
  pointer-events: none;
}
#iso-controls {
  position: absolute;
  left: 12px;
  top: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(31, 27, 23, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  flex-wrap: wrap;
}
#iso-controls .sep { width: 1px; height: 22px; background: var(--line); }
#iso-controls .speed { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
#iso-controls input[type="range"] { width: 110px; accent-color: var(--accent); }
#iso-progress { font-size: 12.5px; color: var(--muted); min-width: 150px; }
#confirm-pop {
  position: absolute;
  top: 60px;
  right: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  width: 260px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  z-index: 20;
}
.pop-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
#toast {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 13px;
  z-index: 30;
}
#panel {
  width: 350px;
  flex-shrink: 0;
  background: var(--panel);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
#panel h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 8px; }
.tools { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tool { display: flex; justify-content: space-between; align-items: center; }
.tool.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tool kbd {
  font: 11px monospace;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 3px;
  padding: 1px 5px;
  color: inherit;
  opacity: 0.75;
}
details.cfg { border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
details.cfg summary { cursor: pointer; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
details.cfg[open] summary { margin-bottom: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
input[type="number"], select {
  background: var(--bg2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 5px;
  padding: 5px 8px;
  font: inherit;
  width: 100%;
}
input[type="number"]:focus, select:focus { outline: none; border-color: var(--accent); }
label.row { flex-direction: row; align-items: center; gap: 8px; margin-top: 8px; color: var(--text); font-size: 13px; }
label.row input[type="checkbox"] { accent-color: var(--accent); }
label.row.sel { justify-content: space-between; }
label.row.sel select { width: auto; }
.note { font-size: 11.5px; color: var(--muted); margin-top: 8px; }
#selection-box { border: 1px solid var(--accent); border-radius: 8px; padding: 10px; }
#selection-body .grid2 { margin-bottom: 8px; }
#selection-body .actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 6px; }
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
.card {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
}
.card b { font-size: 20px; }
.card span { font-size: 11.5px; color: var(--muted); }
.totals { display: flex; flex-direction: column; gap: 2px; font-size: 13.5px; margin-bottom: 6px; }
.totals b { color: var(--accent2); }
.meta { font-size: 12px; color: var(--muted); margin-bottom: 8px; white-space: pre-line; }
button.wide { width: 100%; margin-bottom: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { text-align: right; padding: 4px 6px; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 500; }
#notes-box ul { list-style: none; display: flex; flex-direction: column; gap: 5px; }
#notes-box li { font-size: 12px; color: var(--muted); padding-left: 10px; border-left: 2px solid var(--accent); }
#notes-box li.warn { border-left-color: var(--danger); color: var(--text); }
.legend div { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.sw { width: 14px; height: 10px; border-radius: 2px; display: inline-block; flex-shrink: 0; }
.sw-full { background: var(--full); }
.sw-half { background: var(--half); }
.sw-channel { background: var(--channel); }
.sw-channelhalf { background: var(--channelhalf); }
@media (max-width: 900px) {
  header { flex-wrap: wrap; height: auto; min-height: 50px; padding: 8px 14px; row-gap: 6px; }
  .header-actions { margin-left: 0; }
  main { flex-direction: column; }
  #panel { width: 100%; height: 45%; border-left: none; border-top: 1px solid var(--line); }
  #hint-bar { max-width: 90%; font-size: 11.5px; }
}
