:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #242836;
  --border: #2e3346;
  --accent: #6c72ff;
  --accent-hover: #8186ff;
  --text: #e4e6ef;
  --text-muted: #8b8fa7;
  --danger: #ff5c5c;
  --success: #4ccc6e;
  --radius: 10px;
  /* Theme-dependent helpers (overlays, shadows) */
  --overlay-bg: rgba(15, 17, 23, 0.32);
  --chip-bg: rgba(20, 22, 34, 0.85);
  --shadow-strong: rgba(0, 0, 0, 0.55);
  --shadow-soft: rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

body.light {
  --bg: #f3f4f8;
  --surface: #ffffff;
  --surface2: #eceef4;
  --border: #d4d8e3;
  --accent: #5359f0;
  --accent-hover: #4248e0;
  --text: #1b1e2a;
  --text-muted: #61667c;
  --danger: #d83b3b;
  --success: #1f9d52;
  --overlay-bg: rgba(255, 255, 255, 0.45);
  --chip-bg: rgba(40, 44, 60, 0.82);
  --shadow-strong: rgba(60, 66, 90, 0.22);
  --shadow-soft: rgba(60, 66, 90, 0.16);
  color-scheme: light;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100vh;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

/* ---- Header ---- */
header {
  width: 100%;
  padding: 8px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

header h1 { font-size: 16px; font-weight: 600; }
header .header-tagline { color: var(--text-muted); font-size: 12px; }

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.hamburger {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 6px;
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
}
.hamburger:hover { border-color: var(--accent); color: var(--accent); }

.header-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.header-nav a {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s;
}

.header-nav a:hover,
.header-nav a.active {
  color: var(--accent);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* ---- Container ---- */
.container {
  display: flex;
  gap: 16px;
  padding: 12px 16px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ---- Left column ---- */
.left {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  min-width: 0;
}

/* ---- Welcome / empty state (lives inside the preview area) ---- */
.welcome {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  padding: 24px 16px;
}

.welcome-inner {
  width: 100%;
  max-width: 1040px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  margin: auto;
}

.welcome-hero {
  text-align: center;
}
.welcome-hero h2,
.welcome-lead {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 10px;
}
.welcome-sub {
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.55;
  max-width: 660px;
  margin: 0 auto;
}

.welcome-steps {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  width: 100%;
}

.welcome-step {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px 24px;
  transition: border-color 0.2s, transform 0.2s;
}
.welcome-step:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.welcome-step-body { min-width: 0; }

.welcome-step strong {
  font-size: 17px;
  display: block;
  margin-bottom: 6px;
}

.welcome-step p {
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.55;
  margin: 0;
}

.welcome-feats {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.welcome-feats li {
  position: relative;
  padding-left: 18px;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.4;
}
.welcome-feats li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.welcome-feats b { color: var(--text); font-weight: 600; }

.step-num {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---- Drop zone ---- */
.dropzone {
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: 14px;
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: rgba(108, 114, 255, 0.06);
}

.dropzone-icon { color: var(--accent); margin-bottom: 8px; }
.dropzone p { color: var(--text-muted); font-size: 13px; margin-top: 2px; }
.dropzone .label { font-size: 18px; font-weight: 600; color: var(--text); }
.dropzone input { display: none; }

@media (max-width: 720px) {
  .welcome-steps { grid-template-columns: 1fr; }
  .welcome-hero h2 { font-size: 24px; }
}

/* ---- Toolbar ---- */
.toolbar {
  display: flex;
  align-items: stretch;
  gap: 10px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* ---- Named toolbar sections ---- */
.tool-section {
  display: inline-flex;
  flex-direction: column;
  gap: 5px;
  padding: 4px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.tool-section.hidden {
  display: none;
}

/* Suggestions sub-group lives inside the Cutouts section */
.detect-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.detect-group.hidden {
  display: none;
}

/* 3D-only view-angle buttons live inside the always-visible View section */
.stl-view-tools {
  display: contents;
}
.stl-view-tools.hidden {
  display: none;
}

/* Build section — Convert button in the toolbar */
.btn-tool.btn-convert-tool {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  line-height: 1;
  border-color: var(--accent);
  color: var(--accent);
}
.btn-convert-tool:hover:not(:disabled) {
  background: rgba(108, 114, 255, 0.12);
  color: var(--accent);
}
.btn-convert-tool:disabled {
  opacity: 0.45;
  cursor: default;
}

/* Attention state: a setting changed, a (re)convert is needed */
.btn-convert-tool.needs-convert {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  animation: convert-pulse 1.6s ease-in-out infinite;
}
.btn-convert-tool.needs-convert:hover:not(:disabled) {
  background: var(--accent-hover);
  color: #fff;
}
@keyframes convert-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(108, 114, 255, 0.55); }
  50% { box-shadow: 0 0 0 6px rgba(108, 114, 255, 0); }
}

/* Options section in the toolbar */
.options-section {
  position: relative;
}
.tool-section-row.option-toggles {
  flex-wrap: nowrap;
  margin-bottom: 0;
}
.options-section .opt-chip {
  font-size: 12px;
  padding: 6px 11px;
  border-radius: 8px;
}
.options-section .sub-options {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 60;
  min-width: 240px;
  width: max-content;
  margin-top: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 8px 28px var(--shadow-strong);
}

.tool-section-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding-left: 2px;
  user-select: none;
}

.tool-section-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
}

.btn-new {
  border-color: var(--accent) !important;
  color: var(--accent) !important;
}

.btn-tool svg {
  display: block;
  pointer-events: none;
}

.btn-tool:not(.btn-xs) svg {
  width: 17px;
  height: 17px;
}

.btn-tool:has(svg) {
  padding: 7px 9px;
  line-height: 0;
}

/* stl-tools wraps several named sections */
.stl-tools {
  display: inline-flex;
  align-items: stretch;
  gap: 10px;
}
.pdf-tools.hidden, .stl-tools.hidden {
  display: none;
}

.file-badge {
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-badge:hover { border-color: var(--accent); color: var(--text); }

.toolbar-select {
  padding: 7px 10px;
  font-size: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  outline: none;
  width: auto;
  min-width: 80px;
}

.toolbar-select:focus { border-color: var(--accent); }

.toolbar-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  flex-shrink: 0;
}

/* ---- Compact slider control for the toolbar (Model group) ---- */
/* ---- Model layer / scale steppers (compact, slider-free) ---- */
.model-row { gap: 12px; }

.layer-ctl {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

/* Swatch communicates white paper base vs. raised text, with layer lines */
.layer-swatch {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border-radius: 5px;
  border: 1px solid var(--border);
}
.layer-swatch-base {
  background-color: #f2f3f5;
  background-image: repeating-linear-gradient(
    to top, rgba(0, 0, 0, 0.16) 0 1px, transparent 1px 4px
  );
}
.layer-swatch-text {
  background-color: #2a2d36;
  background-image: repeating-linear-gradient(
    to top, rgba(255, 255, 255, 0.18) 0 1px, transparent 1px 4px
  );
}

.layer-ctl-body {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  line-height: 1;
}
.layer-ctl-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}
.layer-ctl-sub {
  font-weight: 400;
  color: var(--text-muted);
}

.layer-ctl-stepper {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.step-btn {
  width: 21px;
  height: 21px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 5px;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  user-select: none;
}
.step-btn:hover { border-color: var(--accent); color: var(--accent); }
.step-btn:active { background: var(--surface2); }

.layer-ctl-count {
  font-size: 12px;
  min-width: 56px;
  text-align: center;
  color: var(--text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.layer-ctl-count b,
.layer-ctl-count > span { color: var(--accent); font-weight: 700; }

.layer-ctl-mm {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}
.layer-ctl-mm span { color: var(--text); font-weight: 600; }

.scale-ctl .layer-ctl-count { min-width: 40px; }

.model-size-readout {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ---- Final printed-size readout (right panel) ---- */
.size-readout {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: -2px 0 10px;
  padding: 7px 9px;
  background: rgba(108, 114, 255, 0.10);
  border: 1px solid rgba(108, 114, 255, 0.35);
  border-radius: 7px;
  font-size: 12px;
}
.size-readout svg { color: var(--accent); flex-shrink: 0; opacity: 0.9; }
.size-readout-label { color: var(--text-muted); }
.size-readout-val {
  margin-left: auto;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.btn-tool {
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-tool:hover { border-color: var(--accent); color: var(--text); }

.btn-tool.active {
  border-color: var(--accent);
  background: rgba(108, 114, 255, 0.15);
  color: var(--accent);
}

.btn-icon {
  min-width: 34px;
  text-align: center;
  font-size: 17px;
  line-height: 1;
  padding: 6px 10px;
}

.selection-info {
  font-size: 11px;
  color: var(--text-muted);
}

.zoom-level {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 36px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ---- Warning ---- */
.warning {
  font-size: 11px;
  color: #e0a040;
  background: rgba(224, 160, 64, 0.1);
  border: 1px solid rgba(224, 160, 64, 0.25);
  padding: 5px 10px;
  border-radius: 6px;
  flex-shrink: 0;
}

/* ---- Preview ---- */
.preview-area {
  flex: 1;
  min-height: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
}

.preview-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  line-height: 0;
  transform-origin: 0 0;
  will-change: transform;
}
.image-overlays-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.preview-area img {
  display: block;
  pointer-events: none;
  user-select: none;
}

.preview-area .placeholder {
  color: var(--text-muted);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 200px;
}

.preview-area.selecting { cursor: crosshair; }
.preview-area.erasing { cursor: crosshair; }
.preview-area.panning { cursor: grab; }
.preview-area.panning:active { cursor: grabbing; }

.exclusion-zone {
  position: absolute;
  background: rgba(255, 60, 60, 0.25);
  border: 1.5px dashed #f44;
  pointer-events: auto;
  border-radius: 2px;
  z-index: 3;
}
.image-overlay {
  position: absolute;
  border: 2px solid rgba(100, 180, 255, 0.8);
  background: rgba(100, 180, 255, 0.12);
  pointer-events: none;
  border-radius: 2px;
  z-index: 2;
  box-sizing: border-box;
  transition: opacity 0.2s;
}
.image-overlay .img-label {
  position: absolute;
  bottom: 2px;
  left: 2px;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  background: rgba(50, 130, 220, 0.85);
  padding: 1px 5px;
  border-radius: 3px;
  white-space: nowrap;
  line-height: 1.4;
}
.image-overlay.included {
  border-color: rgba(80, 200, 120, 0.8);
  background: rgba(80, 200, 120, 0.12);
}
.image-overlay.included .img-label {
  background: rgba(40, 160, 80, 0.85);
}
.excl-close {
  position: absolute;
  top: -8px; right: -8px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #f44;
  color: #fff;
  font-size: 11px;
  line-height: 14px;
  text-align: center;
  cursor: pointer;
  z-index: 5;
}
.excl-close:hover { background: #d22; }

.eraser-info {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}
.btn-tool.btn-xs,
.btn-tool.btn-xs:has(svg) {
  font-size: 11px;
  padding: 3px 6px;
  min-width: 0;
}

.selection-overlay {
  position: absolute;
  border: 2px solid var(--accent);
  background: rgba(108, 114, 255, 0.12);
  pointer-events: none;
  border-radius: 2px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.35);
}
.selection-overlay.interactive {
  pointer-events: auto;
  cursor: move;
}
.sel-close {
  position: absolute;
  top: -12px; right: -12px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: 2px solid var(--surface);
  font-size: 13px;
  line-height: 18px;
  text-align: center;
  cursor: pointer;
  pointer-events: auto;
  z-index: 5;
}
.sel-close:hover { background: #f44; }
.sel-handle {
  position: absolute;
  background: transparent;
  pointer-events: auto;
  z-index: 4;
}
.sel-handle-n, .sel-handle-s { left: 0; right: 0; height: 8px; cursor: ns-resize; }
.sel-handle-e, .sel-handle-w { top: 0; bottom: 0; width: 8px; cursor: ew-resize; }
.sel-handle-n { top: -4px; }
.sel-handle-s { bottom: -4px; }
.sel-handle-e { right: -4px; }
.sel-handle-w { left: -4px; }
.sel-handle-ne, .sel-handle-nw, .sel-handle-se, .sel-handle-sw {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent);
  pointer-events: auto; z-index: 5;
}
.sel-handle-ne { top: -6px; right: -6px; cursor: nesw-resize; }
.sel-handle-nw { top: -6px; left: -6px; cursor: nwse-resize; }
.sel-handle-se { bottom: -6px; right: -6px; cursor: nwse-resize; }
.sel-handle-sw { bottom: -6px; left: -6px; cursor: nesw-resize; }

/* ---- 3D Preview ---- */
#preview-3d {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: var(--radius);
}

.btn-tool.active-3d {
  border-color: var(--success);
  background: rgba(76, 204, 110, 0.15);
  color: var(--success);
}

.btn-tool.active-eraser {
  border-color: #f44;
  background: rgba(255, 60, 60, 0.15);
  color: #f44;
}

.btn-tool.active-cutout {
  border-color: #e05555;
  background: rgba(224, 85, 85, 0.15);
  color: #e05555;
}
.btn-tool.active-tool {
  border-color: #64b4ff;
  background: rgba(100, 180, 255, 0.15);
  color: #64b4ff;
}

.btn-apply {
  border-color: var(--success) !important;
  color: var(--success) !important;
}

.cutout-controls {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.cutout-controls .num-input {
  width: 50px;
}

.cutout-controls select {
  min-width: 38px;
  width: auto;
}

#cutout-circle-dims, #cutout-rect-dims {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.cutout-label {
  font-size: 0.8em;
  color: var(--muted);
}

/* ---- Detection badges (in toolbar) ---- */
.detect-label {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.detect-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
  white-space: nowrap;
}

.detect-badge input[type="checkbox"] { display: none; }
.detect-badge svg { flex-shrink: 0; }

.circle-badge:has(input:checked) {
  background: rgba(102, 187, 255, 0.18);
  border-color: #66bbff;
  color: #88ddff;
}

.rect-badge:has(input:checked) {
  background: rgba(102, 238, 136, 0.18);
  border-color: #66ee88;
  color: #88ffaa;
}

/* ---- Filter popover ---- */
.filter-popover {
  position: fixed;
  z-index: 50;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: 0 6px 24px var(--shadow-strong);
  min-width: 220px;
}

.pop-head {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.pop-body {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pop-range {
  min-width: 100px;
}

.pop-vals {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  margin-top: 6px;
  font-size: 12px;
}

.step-btn {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.step-btn:hover { border-color: var(--accent); color: var(--text); }

.range-wrap {
  position: relative;
  flex: 1;
  min-width: 120px;
  height: 26px;
}

.range-wrap input[type="range"] {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
  background: none;
  pointer-events: none;
}

.range-wrap input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: transparent;
}

.range-wrap .range-lo::-webkit-slider-runnable-track {
  background: var(--border);
}

.range-wrap input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: var(--surface);
  margin-top: -6px;
  pointer-events: auto;
  cursor: pointer;
  position: relative;
  z-index: 2;
}

.range-wrap input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: transparent;
}

.range-wrap .range-lo::-moz-range-track {
  background: var(--border);
}

.range-wrap input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: var(--surface);
  pointer-events: auto;
  cursor: pointer;
}

.range-dash {
  font-size: 0.85em;
  color: var(--text-muted);
  flex-shrink: 0;
}

.filter-value {
  font-size: 0.85em;
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
  flex-shrink: 0;
}

#preview-3d.cutout-cursor {
  cursor: crosshair;
}

.view-label {
  position: absolute;
  bottom: 10px;
  left: 10px;
  color: #e0e0e0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.4px;
  pointer-events: none;
  z-index: 100;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
  background: var(--chip-bg);
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.1);
}

.cutout-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--chip-bg);
  color: #e0e0e0;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  z-index: 10;
  border: 1px solid rgba(255,255,255,0.12);
}

.sel-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 10px 10px;
  margin-bottom: 6px;
}
.sel-panel h3 { margin-top: 8px; }
.sel-panel .popup-detected { margin-bottom: 6px; }

.cutout-size-popup {
  position: absolute;
  z-index: 20;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: 0 6px 24px var(--shadow-strong);
  min-width: 240px;
}
.popup-title {
  font-weight: 600;
  font-size: 12px;
  margin-bottom: 4px;
  color: var(--fg);
}
.popup-detected {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 8px;
}
.popup-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 10px;
}
.popup-input {
  width: 60px;
  text-align: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--fg);
  padding: 4px 6px;
  font-size: 13px;
}
.popup-unit {
  font-size: 11px;
  color: var(--muted);
}
.popup-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--fg);
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
}
.popup-btn:hover { background: var(--border); }
.popup-btn-sm { padding: 4px 5px; font-size: 11px; }
.popup-actions {
  display: flex;
  gap: 6px;
}
.popup-ok {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  flex: 1;
}
.popup-ok:hover { filter: brightness(1.15); }
.popup-cancel {
  color: var(--muted);
}
.popup-dim-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  min-width: 14px;
  text-align: right;
}
.popup-lock-label {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.popup-lock-label input {
  margin: 0;
}

/* ---- Minimap ---- */
.minimap {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px;
  opacity: 0.9;
  cursor: pointer;
  z-index: 10;
  box-shadow: 0 2px 8px var(--shadow-soft);
}

.minimap canvas {
  display: block;
  border-radius: 4px;
}

.minimap-viewport {
  position: absolute;
  border: 2px solid var(--accent);
  background: rgba(108, 114, 255, 0.1);
  border-radius: 2px;
  pointer-events: none;
}

/* ---- Right panel ---- */
.right {
  width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.right-scroll {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 12px;
  display: flex;
  flex-direction: column;
}

.right-scroll > * {
  flex-shrink: 0;
}

.right-scroll > .progress-panel {
  flex-shrink: 1;
}

.right-scroll h3 {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin: 12px 0 6px 0;
  display: flex;
  align-items: center;
  gap: 5px;
}

.right-scroll h3 svg {
  flex-shrink: 0;
  opacity: 0.6;
}

.control-group label svg,
.inline-field label svg {
  vertical-align: -1px;
  opacity: 0.5;
  margin-right: 2px;
}

.right-scroll h3:first-child { margin-top: 0; }

.opt-block {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.opt-block + .opt-block {
  margin-top: 6px;
}

.section-desc {
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-muted);
  margin: -2px 0 8px;
}

.control-hint {
  font-size: 10px;
  line-height: 1.35;
  color: var(--text-muted);
  margin: 0 0 2px;
  opacity: 0.9;
}

.control-group { margin-bottom: 10px; }

.control-group label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text);
  margin-bottom: 3px;
}

.control-group label .value {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.layers-hint {
  color: var(--muted);
  font-size: 0.8em;
  font-weight: 400;
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--surface2);
  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);
  cursor: pointer;
}

/* ---- Segmented buttons ---- */
.seg-group {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.seg-btn {
  flex: 1;
  padding: 4px 0;
  font-size: 11px;
  font-weight: 500;
  text-align: center;
  background: var(--surface2);
  color: var(--text-muted);
  border: none;
  border-right: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
}

.seg-btn:last-child { border-right: none; }

.seg-btn:hover { color: var(--text); }

.seg-btn.active {
  background: rgba(108, 114, 255, 0.2);
  color: var(--accent);
  font-weight: 600;
}

.right-scroll select {
  width: 100%;
  padding: 5px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  outline: none;
}

.right-scroll select:focus { border-color: var(--accent); }

.num-input {
  width: 52px;
  padding: 4px 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  font-size: 11px;
  outline: none;
  text-align: right;
}

.num-input:focus { border-color: var(--accent); }

.custom-size-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.custom-size-row label {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  margin-bottom: 0;
}

/* ---- Inline rows (side-by-side controls) ---- */
.inline-row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.inline-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.inline-field label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 0;
}

.inline-field .unit {
  font-size: 10px;
  color: var(--text-muted);
}

/* ---- Option toggles (icon chips) ---- */
.option-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.opt-toggle {
  cursor: pointer;
}

.opt-toggle input[type="checkbox"] { display: none; }

.opt-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 14px;
  border: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
  transition: all 0.15s;
  user-select: none;
  white-space: nowrap;
}

.opt-chip svg { flex-shrink: 0; }

.opt-toggle input:checked + .opt-chip {
  background: rgba(108, 114, 255, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}

.opt-chip:hover {
  border-color: var(--accent);
  color: var(--text);
}

.opt-disabled {
  opacity: 0.35;
  pointer-events: none;
}

.badge-beta {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 170, 50, 0.2);
  color: #e0a030;
  vertical-align: middle;
  margin-left: 4px;
}

.opt-group-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  align-self: center;
}

/* ---- Image mode sub-options ---- */
.sub-options {
  width: 100%;
  padding: 8px 10px;
  margin-top: 4px;
  background: rgba(108, 114, 255, 0.04);
  border: 1px solid rgba(108, 114, 255, 0.12);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.opt-label {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.opt-select, .opt-input {
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
}

.opt-input {
  width: 70px;
}

/* ---- Convert button ---- */
.btn {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-convert {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}
.btn-convert:hover:not(:disabled) { background: rgba(108, 114, 255, 0.12); }
.btn-download {
  background: transparent;
  color: var(--success);
  border: 1px solid var(--success);
}
.btn-download:hover:not(:disabled) { background: rgba(76, 204, 110, 0.12); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn svg {
  vertical-align: -2px;
  margin-right: 4px;
}

/* ---- Status ---- */
.status {
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 6px;
  margin-top: 6px;
  display: none;
  word-break: break-all;
  overflow-wrap: anywhere;
}

.status.error {
  display: block;
  background: rgba(255, 92, 92, 0.1);
  border: 1px solid rgba(255, 92, 92, 0.3);
  color: var(--danger);
}

.status.info {
  display: block;
  background: rgba(108, 114, 255, 0.1);
  border: 1px solid rgba(108, 114, 255, 0.3);
  color: var(--accent);
}

.status.success {
  display: block;
  background: rgba(76, 204, 110, 0.1);
  border: 1px solid rgba(76, 204, 110, 0.3);
  color: var(--success);
}

/* ---- Spinner ---- */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Preview loader (non-blocking overlay) ---- */
.preview-loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  pointer-events: none;
  background: var(--overlay-bg);
}
.preview-loader.hidden { display: none; }

.preview-loader-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 22px;
  width: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 30px var(--shadow-strong);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  box-sizing: border-box;
}

.preview-loader-head {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.preview-loader-track {
  position: relative;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--surface2);
  overflow: hidden;
}
.preview-loader-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.25s ease;
}
.preview-loader-track.indeterminate .preview-loader-fill {
  width: 40% !important;
  position: absolute;
  left: 0;
  animation: loader-indeterminate 1.1s ease-in-out infinite;
}
@keyframes loader-indeterminate {
  0%   { left: -40%; }
  100% { left: 100%; }
}

.spinner-lg {
  width: 22px;
  height: 22px;
  border-width: 3px;
  margin-right: 0;
  flex-shrink: 0;
}

/* ---- Progress panel ---- */
.progress-panel {
  margin-top: 8px;
  padding: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  min-height: 60px;
  overflow: hidden;
}

.progress-bar-track {
  width: 100%;
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  border-radius: 3px;
  transition: width 0.3s ease;
}

.progress-percent {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  text-align: right;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.progress-steps {
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.progress-steps::-webkit-scrollbar { width: 4px; }
.progress-steps::-webkit-scrollbar-track { background: transparent; }
.progress-steps::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.progress-steps::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

.progress-step {
  font-size: 10px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  line-height: 1.3;
}

.progress-step .step-icon {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.progress-step.done .step-icon::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}

.progress-step.active .step-icon { animation: pulse 1s ease-in-out infinite; }

.progress-step.active .step-icon::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.progress-step.active { color: var(--text); font-weight: 500; }

.progress-step.error .step-icon::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--danger);
}

.progress-step.error { color: var(--danger); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ---- Color mapping modal ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 9000;
}
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 420px; max-width: 92vw; max-height: 80vh;
  display: flex; flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.modal-header { padding: 16px 20px 8px; }
.modal-header h3 { margin: 0; display: flex; align-items: center; gap: 6px; font-size: 15px; }
.modal-subtitle { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.modal-body { padding: 0 20px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 12px 20px;
  display: flex; gap: 8px; justify-content: flex-end;
  border-top: 1px solid var(--border);
}

.color-tolerance { margin-bottom: 12px; }
.color-tolerance label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.color-tolerance input[type="range"] { width: 100%; margin-top: 4px; }

.color-list { display: flex; flex-direction: column; gap: 6px; padding-bottom: 8px; }

.color-row {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: 6px;
  background: var(--bg);
}
.color-swatch {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--border); flex-shrink: 0;
}
.color-hex { font-family: monospace; font-size: 12px; min-width: 70px; }
.color-count { font-size: 11px; color: var(--muted); min-width: 40px; }
.color-extruder {
  margin-left: auto;
  display: flex; align-items: center; gap: 4px;
}
.color-extruder select {
  font-size: 12px; padding: 2px 4px; border-radius: 4px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.color-extruder label { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 3px; }

/* ---- Header spacer + buy button ---- */
.header-spacer { flex: 1; }

.btn-header {
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-header:hover {
  background: rgba(108, 114, 255, 0.12);
}

/* ---- Theme toggle ---- */
.btn-theme {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface2);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}
.btn-theme:hover {
  border-color: var(--accent);
  color: var(--text);
}
.btn-theme svg { display: block; }
.btn-theme .icon-sun { display: none; }
.btn-theme .icon-moon { display: block; }
body.light .btn-theme .icon-sun { display: block; }
body.light .btn-theme .icon-moon { display: none; }

.admin-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
}
.admin-label {
  font-size: 11px;
  font-weight: 600;
  color: #4ccc6e;
  background: rgba(76, 204, 110, 0.1);
  border: 1px solid rgba(76, 204, 110, 0.25);
  border-radius: 4px;
  padding: 2px 8px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.btn-admin-logout {
  background: none;
  border: none;
  color: #888;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
}
.btn-admin-logout:hover {
  color: #ff5c5c;
  background: rgba(255, 92, 92, 0.1);
}

.btn-admin-audit {
  font-size: 11px;
  padding: 4px 10px;
  margin-right: 2px;
}

.admin-audit-modal-box {
  max-width: 920px;
  width: min(92vw, 920px);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.admin-audit-tabs {
  display: flex;
  gap: 4px;
  padding: 0 16px 8px;
  border-bottom: 1px solid var(--border);
}

.admin-audit-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 6px 6px 0 0;
}

.admin-audit-tab:hover {
  color: var(--text);
}

.admin-audit-tab.active {
  color: var(--accent);
  background: var(--surface2);
}

.admin-audit-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.admin-audit-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.admin-audit-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

.admin-audit-meta {
  flex: 1;
}

.admin-table-wrap {
  flex: 1;
  min-height: 200px;
  max-height: 50vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.admin-table th,
.admin-table td {
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.admin-table th {
  position: sticky;
  top: 0;
  background: var(--surface2);
  font-weight: 600;
  color: var(--text-muted);
  z-index: 1;
}

.admin-table tbody tr:hover {
  background: var(--surface2);
}

.admin-table .event-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(108, 114, 255, 0.15);
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}

.admin-table .credits-left {
  font-weight: 600;
  color: #4ccc6e;
}

.admin-table .credits-left.zero {
  color: #ff5c5c;
}

.admin-table .status-suspended {
  color: #ff5c5c;
}

/* ---- Paywall panel ---- */
.paywall-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-top: 8px;
}

.paywall-panel h3 {
  margin-top: 0;
}

.btn-sample {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  background: var(--surface2);
  color: var(--text-muted);
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-sample:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--text);
}
.btn-sample:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-sample svg {
  flex-shrink: 0;
}

.paywall-divider {
  display: flex;
  align-items: center;
  margin: 10px 0;
  gap: 8px;
}
.paywall-divider::before,
.paywall-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.paywall-divider span {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.btn-buy-single {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  transition: all 0.15s;
}
.btn-buy-single:hover:not(:disabled) {
  filter: brightness(1.15);
}
.btn-buy-single:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.purchase-done {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--success);
  background: rgba(76, 204, 110, 0.1);
  border: 1px solid rgba(76, 204, 110, 0.3);
}
.purchase-done svg { flex-shrink: 0; }

.btn-key-dl.purchase-redownload {
  width: 100%;
  margin-top: 8px;
}

.btn-key-dl.key-download-full {
  width: 100%;
  margin-top: 8px;
}

.key-entry {
  display: flex;
  gap: 6px;
}

.key-input {
  flex: 1;
  padding: 7px 10px;
  font-size: 12px;
  font-family: monospace;
  letter-spacing: 1px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  outline: none;
}
.key-input:focus {
  border-color: var(--accent);
}

.btn-key-dl {
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--success);
  border-radius: 6px;
  background: transparent;
  color: var(--success);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.btn-key-dl:hover:not(:disabled) {
  background: rgba(76, 204, 110, 0.12);
}
.btn-key-dl:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.key-balance {
  font-size: 11px;
  color: var(--success);
  margin-top: 4px;
  padding: 4px 8px;
  background: rgba(76, 204, 110, 0.08);
  border-radius: 4px;
}

.key-error {
  font-size: 11px;
  color: var(--danger);
  margin-top: 4px;
  padding: 4px 8px;
  background: rgba(255, 92, 92, 0.08);
  border-radius: 4px;
}

/* ---- Package modal ---- */
.package-modal-box {
  width: 480px;
}

.tier-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.tier-card {
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.tier-card:hover {
  border-color: var(--accent);
}
.tier-card.selected {
  border-color: var(--accent);
  background: rgba(108, 114, 255, 0.1);
}
.tier-card .tier-size {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}
.tier-card .tier-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.tier-card .tier-price {
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
}
.tier-card .tier-unit {
  font-size: 10px;
  color: var(--text-muted);
}
.tier-card .tier-discount {
  display: inline-block;
  margin-top: 4px;
  font-size: 10px;
  font-weight: 600;
  color: var(--success);
  background: rgba(76, 204, 110, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
}

.pkg-email-row {
  margin-bottom: 4px;
}
.pkg-email-row label {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 4px;
}
.pkg-email-row .key-input {
  width: 100%;
  font-family: inherit;
  letter-spacing: normal;
}

.pkg-success {
  text-align: center;
  padding: 16px 0;
}
.pkg-success-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}
.pkg-key-display {
  font-family: monospace;
  font-size: 18px;
  letter-spacing: 2px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  margin: 8px 0;
  word-break: break-all;
  user-select: all;
}
.btn-copy-key {
  padding: 6px 16px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-copy-key:hover {
  background: rgba(108, 114, 255, 0.12);
}
.pkg-success-note {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ---- Responsive ---- */
.mobile-notice,
.mobile-landing {
  display: none;
}

@media (max-width: 860px) {
  html, body {
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }

  header {
    flex-wrap: wrap;
    padding: 10px 14px;
    gap: 8px;
  }

  header h1 { font-size: 15px; }
  .header-tagline { display: none; }
  .hamburger { display: inline-flex; }
  .header-nav {
    display: none;
    width: 100%;
    flex-direction: column;
    gap: 2px;
    order: 99;
    padding-top: 6px;
    border-top: 1px solid var(--border);
    margin-top: 4px;
  }
  .header-nav.nav-open { display: flex; }
  .header-nav a {
    padding: 8px 4px;
    font-size: 14px;
  }
  .header-spacer { display: none; }
  .header-actions { margin-left: auto; }

  .mobile-notice {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    background: rgba(108, 114, 255, 0.12);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }

  .mobile-notice svg {
    flex-shrink: 0;
    color: var(--accent);
    margin-top: 2px;
  }

  .mobile-notice-text strong {
    display: block;
    font-size: 13px;
    margin-bottom: 4px;
  }

  .mobile-notice-text p {
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-muted);
    margin: 0;
  }

  .mobile-landing {
    display: block;
    flex: 1;
    padding: 16px 14px 32px;
  }

  .container {
    display: none !important;
  }

  .mobile-hero {
    text-align: center;
    margin-bottom: 28px;
  }

  .mobile-hero h2 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.25;
    margin-bottom: 10px;
  }

  .mobile-hero-sub {
    font-size: 14px;
    line-height: 1.55;
    color: var(--text-muted);
    margin-bottom: 18px;
  }

  .mobile-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin: 0 0 12px;
  }

  .mobile-features {
    margin-bottom: 28px;
  }

  .mobile-feature-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .mobile-feature {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
  }

  .mobile-feature-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(108, 114, 255, 0.12);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .mobile-feature strong {
    display: block;
    font-size: 14px;
    margin-bottom: 4px;
  }

  .mobile-feature p {
    font-size: 12.5px;
    line-height: 1.45;
    color: var(--text-muted);
    margin: 0;
  }

  .mobile-pricing {
    margin-bottom: 28px;
  }

  .mobile-pricing-note,
  .mobile-single-note,
  .mobile-key-note p {
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--text-muted);
    margin: 0 0 14px;
  }

  .mobile-tier-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
  }

  .mobile-tier-card {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    width: 100%;
    padding: 14px 16px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    text-align: left;
    color: inherit;
    font: inherit;
    transition: border-color 0.15s, background 0.15s;
  }

  .mobile-tier-card:hover,
  .mobile-tier-card:active {
    border-color: var(--accent);
    background: rgba(108, 114, 255, 0.08);
  }

  .mobile-tier-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .mobile-tier-size {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
  }

  .mobile-tier-badge {
    font-size: 10px;
    font-weight: 600;
    color: var(--success);
    background: rgba(76, 204, 110, 0.15);
    padding: 3px 8px;
    border-radius: 999px;
  }

  .mobile-tier-price {
    font-size: 22px;
    font-weight: 700;
    color: var(--accent);
  }

  .mobile-tier-unit {
    font-size: 11px;
    color: var(--text-muted);
  }

  .btn-mobile-primary {
    display: block;
    width: 100%;
    padding: 14px 18px;
    border: none;
    border-radius: 10px;
    background: var(--accent);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
  }

  .btn-mobile-primary:hover {
    background: var(--accent-hover);
  }

  .mobile-steps {
    margin-bottom: 28px;
  }

  .mobile-step-list {
    margin: 0;
    padding: 0 0 0 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .mobile-step-list li {
    font-size: 13px;
    line-height: 1.45;
    color: var(--text-muted);
  }

  .mobile-step-list strong {
    color: var(--text);
  }

  .mobile-key-note {
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
  }

  .modal-overlay {
    padding: 0;
    align-items: stretch;
  }

  .package-modal-box {
    width: 100%;
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }

  .tier-grid {
    grid-template-columns: 1fr;
  }
}

/* ---- Content pages (FAQ, How it works, Use cases) ---- */
html.content-page,
html.content-page body {
  height: auto;
  min-height: 100vh;
  overflow: auto;
}

html.content-page body {
  display: flex;
  flex-direction: column;
}

.content-header {
  width: 100%;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.content-header .logo {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.content-header nav {
  display: flex;
  gap: 16px;
  margin-left: auto;
}

.content-header nav a {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
  white-space: nowrap;
}

.content-header nav a:hover,
.content-header nav a.active {
  color: var(--accent);
}

.content-main {
  flex: 1;
  max-width: 800px;
  margin: 0 auto;
  padding: 32px 20px 48px;
  width: 100%;
}

.content-main h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
}

.content-main .lead {
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 32px;
}

.content-main h2 {
  font-size: 20px;
  font-weight: 600;
  margin: 32px 0 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.content-main h2:first-of-type {
  border-top: none;
  padding-top: 0;
}

.content-main p {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.content-main strong {
  color: var(--text);
}

.content-main code {
  font-size: 12px;
  background: var(--surface2);
  padding: 2px 5px;
  border-radius: 3px;
}

.content-main a {
  color: var(--accent);
  text-decoration: none;
}

.content-main a:hover {
  text-decoration: underline;
}

.content-main ul,
.content-main ol {
  padding-left: 20px;
  margin-bottom: 16px;
}

.content-main li {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.content-main table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
  font-size: 13px;
}

.content-main th,
.content-main td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  text-align: left;
}

.content-main th {
  background: var(--surface2);
  font-weight: 600;
  color: var(--text);
}

.content-main td {
  color: var(--text-muted);
}

.faq-item {
  margin-bottom: 24px;
}

.faq-item h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  text-transform: none;
  letter-spacing: normal;
}

.faq-item p {
  margin-bottom: 8px;
}

.pipeline-diagram {
  font-family: monospace;
  font-size: 13px;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 20px;
  overflow-x: auto;
  white-space: pre;
}

.cta-link {
  display: inline-block;
  margin-top: 8px;
  padding: 8px 20px;
  background: var(--accent);
  color: #fff !important;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  text-decoration: none !important;
  transition: filter 0.15s;
}

.cta-link:hover {
  filter: brightness(1.15);
}

@media (max-width: 600px) {
  .content-header {
    flex-wrap: wrap;
    gap: 8px;
  }
  .content-header .hamburger { display: inline-flex; margin-left: auto; }
  .content-header nav {
    display: none;
    width: 100%;
    flex-direction: column;
    gap: 2px;
    margin-left: 0;
    padding-top: 6px;
    border-top: 1px solid var(--border);
    margin-top: 4px;
  }
  .content-header nav.nav-open { display: flex; }
  .content-header nav a {
    padding: 8px 4px;
    font-size: 14px;
  }
  .content-main h1 {
    font-size: 22px;
  }
  .content-main h2 {
    font-size: 18px;
  }
}
