:root {
  --bg: #f6f5f1;
  --panel: #ffffff;
  --ink: #1f2420;
  --muted: #6b726c;
  --line: #e2e0d8;
  --accent: #2f6b4f;
  --accent-ink: #ffffff;
  --path: #d2502b;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161917;
    --panel: #1e2220;
    --ink: #e6e9e6;
    --muted: #98a09a;
    --line: #313733;
    --accent: #5aa883;
    --accent-ink: #0d1410;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: flex;
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}
#panel {
  width: 340px;
  flex: none;
  overflow-y: auto;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 16px 18px 40px;
}
header h1 { margin: 0; font-size: 20px; letter-spacing: -0.01em; }
header .sub { margin: 2px 0 8px; color: var(--muted); }
section { border-top: 1px solid var(--line); padding: 14px 0 6px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
h2 .n { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 11px; }
h2 .opt { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--muted); }
label { display: block; margin: 0 0 8px; color: var(--muted); font-size: 12px; }
label.inline { display: flex; align-items: center; gap: 6px; color: var(--ink); font-size: 13px; }
label.inline input[type=number] { width: 64px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
input[type=number], input[type=text], select {
  display: block; width: 100%; margin-top: 3px; padding: 6px 8px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--ink); font: inherit;
}
label.inline input { display: inline-block; margin: 0; }
input[type=file] { font-size: 12px; max-width: 100%; }
button {
  font: inherit; padding: 7px 12px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); width: 100%; font-weight: 600; }
button.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.row { display: flex; gap: 8px; margin-bottom: 8px; }
.row button { flex: 1; }
.hint { color: var(--muted); font-size: 12px; margin: 6px 0; white-space: pre-line; }
.hint.error { color: #c0392b; }
.progress { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin: 8px 0; }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
.hidden { display: none !important; }
table.types { width: 100%; border-collapse: collapse; margin: 4px 0 10px; font-size: 13px; }
table.types th { text-align: left; font-weight: 500; color: var(--muted); font-size: 11px; padding: 0 4px 4px 0; }
table.types td { padding: 3px 4px 3px 0; }
table.types select { margin: 0; padding: 4px 6px; }
table.types input[type=color] { width: 40px; height: 26px; padding: 0; border: 1px solid var(--line); border-radius: 4px; background: none; }
.no-colors table.types, .no-colors #typeInfo { opacity: 0.4; pointer-events: none; }
.sep-hidden .sep { display: none; }

main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.tabs { display: flex; gap: 6px; padding: 8px; background: var(--panel); border-bottom: 1px solid var(--line); align-items: center; }
.tabs .toggle { margin: 0 0 0 10px; font-size: 12px; }
#status { margin-left: auto; color: var(--muted); font-size: 12px; padding-right: 6px; }
.view { flex: 1; display: none; min-height: 0; }
.view.active { display: block; }
#map.drawing { cursor: crosshair; }
#paint { position: relative; background: #202422; overflow: hidden; }
#paint.active { display: flex; flex-direction: column; }
.editor-canvas { flex: 1; min-height: 0; width: 100%; display: block; cursor: crosshair; touch-action: none; }
.paint-bar {
  display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; padding: 8px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.paint-bar .seg { display: flex; }
.paint-bar .seg button { border-radius: 0; margin-left: -1px; padding: 5px 10px; font-size: 13px; }
.paint-bar .seg button:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
.paint-bar .seg button:last-child { border-radius: 0 6px 6px 0; }
.paint-bar .seg button.active { position: relative; z-index: 1; }
.paint-bar i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; border: 1px solid rgba(0,0,0,0.25); }
.paint-bar i.auto { background: repeating-linear-gradient(45deg, #bbb 0 2px, #fff 2px 4px); }
.paint-bar .brush-size { margin: 0; gap: 8px; }
.paint-bar .brush-size input { width: 110px; }
.paint-bar .brush-size span { min-width: 44px; color: var(--muted); font-size: 12px; }
.paint-bar.lasso .brush-size { opacity: 0.4; }
.paint-help { position: absolute; bottom: 0; left: 0; right: 0; margin: 0; padding: 6px 10px; font-size: 11px; color: #c9cec9; background: rgba(20,24,22,0.7); pointer-events: none; }
#preview { position: relative; background: #202422; }
#preview canvas { display: block; }

@media (max-width: 760px) {
  body { flex-direction: column-reverse; }
  #panel { width: 100%; height: 55%; border-right: none; border-top: 1px solid var(--line); padding: 12px 16px 40px; }
  main { height: 45%; flex: none; }
}
input[type=range] { display: block; width: 100%; margin-top: 4px; accent-color: var(--accent); }
.no-label #labelSection > :not(h2):not(label.inline:first-of-type) { opacity: 0.4; pointer-events: none; }
.letter-color { display: flex; gap: 8px; align-items: flex-end; margin-bottom: 8px; }
.letter-color label { flex: 1; margin: 0; }
.letter-color input[type=color] { width: 40px; height: 32px; padding: 0; border: 1px solid var(--line); border-radius: 4px; background: none; }
.letter-color select[data-slot] { width: auto; }
.letter-color.linked input, .letter-color.linked select[data-slot] { opacity: 0.5; pointer-events: none; }
#appVersion { font-size: 11px; }

.linkish { background: none; border: 0; padding: 0; margin-top: 6px; color: inherit; text-decoration: underline; cursor: pointer; font: inherit; font-size: 12px; opacity: 0.75; }
.linkish:hover { opacity: 1; }
