:root {
  --bg: #1a1a1d;
  --panel-bg: #212124;
  --border: #35353a;
  --text: #e8e8ea;
  --text-dim: #9aa0ab;
  --accent: #2f8f4e;
  --accent-hover: #256e3c;
  --btn-bg: #2c2c31;
  --btn-hover: #38383e;
  --canvas-bg: #141416;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
}

#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ---- Settings panel ---- */
#panel {
  width: 320px;
  min-width: 320px;
  background: var(--panel-bg);
  border-right: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
}

#panel h1 {
  font-size: 18px;
  margin: 0 0 16px;
}

#panel label {
  display: block;
  margin: 14px 0 4px;
  color: var(--text-dim);
  font-size: 12.5px;
}

#panel label.sub-label {
  margin-top: 8px;
}

.hint-inline { font-weight: normal; }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  font-size: 12.5px;
  margin: 10px 0;
}
.checkbox-label input { margin: 0; }

.hint {
  color: var(--text-dim);
  font-size: 12px;
  margin: 4px 0 8px;
  line-height: 1.4;
}

.footer-note {
  color: #55565c;
  font-size: 11px;
  text-align: center;
  margin-top: 24px;
}

/* ---- Drop zone ---- */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 10px;
  margin-bottom: 10px;
  transition: border-color 0.15s, background 0.15s;
}
.drop-zone.dragover {
  border-color: var(--accent);
  background: rgba(47, 143, 78, 0.08);
}
.drop-zone p { margin: 0; color: var(--text-dim); font-size: 12.5px; line-height: 1.5; }

/* ---- Buttons ---- */
button {
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--btn-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.12s;
}
button:hover:not(:disabled) { background: var(--btn-hover); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); font-weight: 600; }
button.primary:hover:not(:disabled) { background: var(--accent-hover); }

.button-row { margin: 6px 0; }
.button-row button { width: 100%; }

/* ---- Sliders ---- */
.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.slider-row input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}
.slider-val {
  width: 34px;
  text-align: right;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
}

/* ---- Segmented control ---- */
.segmented {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin: 4px 0;
}
.segmented button {
  flex: 1;
  border: none;
  border-radius: 0;
  border-right: 1px solid var(--border);
  background: var(--btn-bg);
  font-size: 12px;
  padding: 7px 4px;
}
.segmented button:last-child { border-right: none; }
.segmented button.active { background: var(--accent); font-weight: 600; }

/* ---- Color swatch buttons ---- */
.color-swatch-btn {
  width: 100%;
  text-align: left;
  font-family: monospace;
  font-weight: 600;
}

/* ---- Preview pane ---- */
#previewPane {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
  min-width: 0;
}

.top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 12px;
}
.top-row .segmented { flex: 0 0 auto; width: 280px; margin: 0; }

.zoom-controls { display: flex; gap: 6px; }
.zoom-controls button { width: 40px; padding: 6px 0; }

#canvasWrap {
  flex: 1;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--canvas-bg);
  position: relative;
}
#previewCanvas {
  display: block;
  cursor: crosshair;
}

.sample-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.swatch {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: #26262b;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
#sampleInfo {
  flex: 1;
  font-size: 12.5px;
  color: var(--text-dim);
  white-space: pre-line;
  line-height: 1.4;
}

#statusLine {
  color: var(--text-dim);
  font-size: 12.5px;
  margin: 8px 0 0;
  min-height: 16px;
}

/* ---- Dialogs ---- */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.dialog-overlay.hidden { display: none; }

.dialog-box {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 420px;
  max-width: 92vw;
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  padding: 18px;
}
.dialog-box h2 {
  font-size: 16px;
  margin: 0 0 8px;
}
.dialog-box .dialog-desc {
  color: var(--text-dim);
  font-size: 12.5px;
  line-height: 1.5;
  margin: 0 0 12px;
}
.dialog-body {
  overflow-y: auto;
  flex: 1;
  min-height: 60px;
  margin-bottom: 12px;
}
.dialog-actions {
  display: flex;
  gap: 8px;
}
.dialog-actions button { flex: 1; }

.swatch-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
}
.swatch-row .mini-swatch {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  cursor: pointer;
}
.swatch-row input[type="text"] {
  flex: 1;
  background: var(--btn-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 12.5px;
  padding: 5px 7px;
  min-width: 0;
}
.swatch-row .idx-label {
  width: 26px;
  color: var(--text-dim);
  font-size: 11.5px;
  flex-shrink: 0;
}

.checklist-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
}
.checklist-grid label {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--text);
  font-size: 12.5px;
  width: 70px;
  margin: 0;
}

@media (max-width: 760px) {
  #app { flex-direction: column; }
  #panel { width: 100%; min-width: 0; height: 45vh; border-right: none; border-bottom: 1px solid var(--border); }
  #previewPane { height: 55vh; }
}
