/*
 * Copyright (c) 2026 CNCKitchen (Stefan Hermann) and contributors
 * SPDX-License-Identifier: AGPL-3.0-only
 */

/* ── Reset & tokens ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #111114;
  --surface:      #1a1a1f;
  --surface2:     #222228;
  --border:       #2e2e38;
  --accent:       #7c6aff;
  --accent-hover: #9b8dff;
  --text:         #e0e0e8;
  --text-muted:   #888899;
  --danger:       #ff5f5f;
  --success:      #4ade80;
  --radius:       8px;
  --sidebar-w:    380px;
  --header-h:     48px;
}

[data-theme="light"] {
  --bg:           #f0f0f5;
  --surface:      #ffffff;
  --surface2:     #eaeaf2;
  --border:       #d0d0df;
  --accent:       #6355e0;
  --accent-hover: #7c6aff;
  --text:         #1a1a2e;
  --text-muted:   #66667a;
  --danger:       #d93025;
  --success:      #1a7f3c;
}

/* ── Header actions (language selector + theme toggle) ──────────────── */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.lang-seg {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  flex-shrink: 0;
}

.lang-dropdown {
  height: 28px;
  padding: 0 24px 0 10px; /* Add right padding for default select arrow if present */
  background: var(--surface2);
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  cursor: pointer;
  appearance: none; /* Attempt to remove default styling */
  -moz-appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath fill='%2366667a' d='M0 0l4 4 4-4H0z'/%3E%3C/svg%3E"); /* Custom arrow */
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: background 0.15s, color 0.15s;
}

.lang-dropdown:hover {
  color: var(--accent);
}

.lang-dropdown:focus {
  outline: none;
}

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

/* Header + main fill the body exactly. 100vh would overshoot the visible area on phones (it assumes
   the browser toolbar is hidden), and the browser then scrolls that overflow to lift a focused input
   above the on-screen keyboard — with no way for the user to scroll back. */
body {
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────────────────────────────────── */
header {
  flex-shrink: 0;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  position: relative;
  z-index: 10;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.02em;
}

.app-version {
  opacity: 0.45;
  font-weight: 400;
  font-size: 11px;
}

.header-note {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
}

/* ── Menu bar (js/menuBar.js) ───────────────────────────────────────── */
.menubar {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: -8px;
}

/* The logo is the Info menu's title */
.menu-btn.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 8px;
  font-size: 14px;
  letter-spacing: 0.02em;
}

.menu { position: relative; }

.menu-btn {
  height: 28px;
  padding: 0 10px;
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.menu-btn:hover,
.menu.open .menu-btn { background: var(--surface2); }
.menu.open .menu-btn { border-color: var(--border); }

.menu-pop {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 250px;
  max-height: calc(100vh - var(--header-h) - 16px);
  overflow-y: auto;
  padding: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  z-index: 200;
}
.menu.open .menu-pop { display: block; }

.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 10px;
  background: none;
  border: none;
  border-radius: 5px;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.menu-item:hover,
.menu-item:focus-visible { background: var(--accent); color: #fff; outline: none; }
.menu-item[hidden] { display: none; }
.menu-item--muted { color: var(--text-muted); font-size: 12px; }
.menu-item svg { flex-shrink: 0; opacity: 0.8; }

.menu-kbd {
  margin-left: auto;
  padding-left: 16px;
  font: inherit;
  font-size: 11px;
  color: var(--text-muted);
}
.menu-item:hover .menu-kbd { color: rgba(255, 255, 255, 0.8); }

.menu-sep { height: 1px; margin: 5px 4px; background: var(--border); }

.menu-label {
  padding: 4px 10px 2px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.menu-empty { padding: 5px 10px; font-size: 12px; color: var(--text-muted); font-style: italic; }

.menu-recent-item { max-width: 340px; }
.menu-recent-kind {
  flex-shrink: 0;
  min-width: 46px;
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-align: center;
  color: var(--text-muted);
}
.menu-recent-item:hover .menu-recent-kind { color: #fff; border-color: rgba(255, 255, 255, 0.5); }
.menu-recent-name { overflow: hidden; text-overflow: ellipsis; }

.menu-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 5px 10px;
  font-size: 13px;
}

.theme-seg {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.theme-opt {
  height: 28px;
  padding: 0 12px;
  background: var(--surface2);
  border: none;
  color: var(--text-muted);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.theme-opt + .theme-opt { border-left: 1px solid var(--border); }
.theme-opt:hover { color: var(--accent); }
.theme-opt.active { background: var(--accent); color: #fff; }

/* Save/load project popovers open under the File menu */
.menu .export-dialog { left: 0; right: auto; top: calc(100% + 4px); }

/* ── About popup ─────────────────────────────────────────────────────── */
.about-head { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.about-head h2 { margin: 0; }
.about-tagline { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.about-links { margin-top: 14px; }
.about-links a { color: var(--accent); }

/* ── Tool rail (js/toolRail.js) ─────────────────────────────────────── */
.tool-rail {
  flex-shrink: 0;
  width: 68px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  padding: 8px 6px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  scrollbar-width: none;
  z-index: 5;
}

.rail-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 2px 6px;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text-muted);
  font: inherit;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.rail-btn svg { width: 24px; height: 24px; }
.rail-btn span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-btn:hover { background: var(--surface2); color: var(--text); }
.rail-btn.active { background: var(--surface2); border-color: var(--border); color: var(--accent); }
main.sidebar-collapsed .rail-btn.active { background: none; border-color: transparent; }
.rail-btn:disabled { opacity: 0.35; cursor: default; background: none; color: var(--text-muted); }
.rail-sep { height: 1px; margin: 4px 8px; background: var(--border); flex-shrink: 0; }

/* Only the active step's sections show (data-step on each section) */
#settings-panel .step-off { display: none; }

/* Export buttons stay visible under every step */
#settings-panel { display: flex; flex-direction: column; }
#settings-panel > .panel-section { flex-shrink: 0; }
.panel-footer {
  position: sticky;
  bottom: 0;
  margin-top: auto;
  padding: 12px 16px 14px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 2;
}
.panel-footer .export-progress { margin-bottom: 10px; }
.panel-footer .export-buttons { display: flex; gap: 8px; }
.panel-footer #export-3mf-btn { flex: 1; }
.export-buttons .export-btn.export-btn--secondary {
  flex: 0 0 auto;
  width: auto;
  padding-left: 14px;
  padding-right: 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.export-buttons .export-btn.export-btn--secondary:hover:not(:disabled) { color: var(--text); border-color: var(--accent); background: var(--surface2); }
.color-stl-note { margin-top: 10px; }
/* Ornaments step */
.orn-tools { margin-top: 10px; }
.orn-border-box { margin-top: 6px; }
.orn-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }
.orn-load { display: inline-block; }
/* In-app confirm (main.js _confirmDialog) */
.confirm-modal { max-width: 400px; }
.confirm-text { font-size: 14px; line-height: 1.5; color: var(--text); }
.confirm-buttons { display: flex; justify-content: flex-end; gap: 10px; }
.confirm-buttons .export-go-btn { margin-top: 0; }
.confirm-buttons .scale-reset-btn { font-size: 12px; padding: 6px 12px; }
/* Explanations live in the tooltip; the ⓘ marks that one is there */
.panel-subsection-heading.has-tip { cursor: help; }
.panel-subsection-heading.has-tip::after { content: " ⓘ"; }
.export-buttons #bake-btn { flex: 1 1 auto; }

/* ── Model ▸ Scale ───────────────────────────────────────────────────── */
.scale-model { margin-top: 14px; }
.scale-grid {
  display: grid;
  grid-template-columns: 48px repeat(3, minmax(0, 1fr)) 26px;
  align-items: center;
  gap: 6px;
}
.scale-grid label { font-size: 12px; color: var(--text); }
.scale-grid .val { width: 100%; min-width: 0; text-align: right; }
.scale-axis { text-align: center; font-size: 11px; font-weight: 700; }
.scale-axis--x { color: #e5484d; }
.scale-axis--y { color: #46a758; }
.scale-axis--z { color: #3e8ef7; }
.scale-unit { font-size: 11px; color: var(--text-muted); }
.scale-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.scale-reset-btn {
  padding: 4px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}
.scale-reset-btn:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); }
.scale-reset-btn:disabled { opacity: 0.4; cursor: default; }

/* ── View gizmo (js/viewer.js _buildViewGizmo) ───────────────────────── */
.view-gizmo {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 4;
  border-radius: 50%;
  background: color-mix(in srgb, var(--surface) 55%, transparent);
  transition: background 0.15s;
  user-select: none;
}
.view-gizmo:hover { background: color-mix(in srgb, var(--surface) 85%, transparent); }
.view-gizmo .vg-end,
.view-gizmo .vg-home { cursor: pointer; }
.view-gizmo .vg-end text {
  font: 700 11px system-ui, sans-serif;
  fill: #111;
  pointer-events: none;
}
.view-gizmo .vg-end:hover circle { stroke: #fff; stroke-width: 2; }
.view-gizmo .vg-home { fill: var(--text-muted); opacity: 0.7; }
.view-gizmo .vg-home:hover { fill: var(--accent); opacity: 1; }

/* ── Colors ▸ Paint filaments ────────────────────────────────────────── */
.fpaint-heading { margin-top: 16px; }
.fpaint-chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 8px; }
.fpaint-chip {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer;
}
.fpaint-chip:hover:not(:disabled) { border-color: var(--accent); }
.fpaint-chip.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.fpaint-chip:disabled { opacity: 0.4; cursor: default; }
.fpaint-swatch { width: 16px; height: 16px; border-radius: 4px; border: 1px solid rgba(255,255,255,0.25); }
.fpaint-tools { margin-bottom: 8px; }
.fpaint-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 4px; }
.fpaint-hint { font-size: 11px; color: var(--text-muted); }

/* ── Main layout ─────────────────────────────────────────────────────── */
main {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

/* ── 3-D Viewport section ────────────────────────────────────────────── */
#brush-cursor {
  display: none;
  position: fixed;
  pointer-events: none;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.5);
  z-index: 1000;
  transform: translate(0, 0);
}

/* Soft brush: the dashed ring marks the hardness core — full strength inside,
   fading out toward the outer rim. */
#brush-cursor.soft::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(var(--brush-hardness, 1) * 100%);
  height: calc(var(--brush-hardness, 1) * 100%);
  transform: translate(-50%, -50%);
  border: 1px dashed rgba(255, 255, 255, 0.75);
  border-radius: 50%;
}

#viewport-section {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.drop-zone {
  flex: 1 1 0;
  position: relative;
  overflow: hidden;
}

.drop-zone.drag-over::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  pointer-events: none;
  background: rgba(124, 106, 255, 0.06);
}

.drop-hint {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.6;
  pointer-events: none;
  transition: opacity 0.2s;
}

.drop-hint.hidden { opacity: 0; pointer-events: none; }

.link-label {
  color: var(--accent);
  cursor: pointer;
  pointer-events: all;
  text-decoration: underline;
}

#viewport {
  display: block;
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
}

#viewport-footer {
  min-height: 34px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;   /* a narrow viewport gets a second row instead of clipped text */
  align-items: center;
  padding: 5px 12px;
  gap: 4px 18px;
  flex-shrink: 0;
}

.mesh-info {
  font-size: 13px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.viewport-controls-hint {
  margin-left: auto;
  font-size: 13px;
  color: var(--text-muted);
}

/* Mouse controls mean nothing on a touch screen. */
@media (hover: none) {
  .viewport-controls-hint { display: none; }
}

.wireframe-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

/* Section view: axis snaps + flip beside the toggle while it is on. The axis
   letters wear the colours of the viewport's axes indicator. */
.section-controls {
  display: flex;
  align-items: center;
  margin-left: -10px;   /* reads as part of the toggle, not a new footer item */
}
.section-controls.hidden { display: none; }
.section-btn {
  height: 24px;
  min-width: 28px;
  padding: 0 7px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.section-btn:first-child {
  border-left: 1px solid var(--border);
  border-radius: var(--radius) 0 0 var(--radius);
}
.section-btn:last-child {
  border-radius: 0 var(--radius) var(--radius) 0;
  font-weight: 400;
}
.section-btn:hover { background: var(--border); color: var(--text); }
.section-btn[data-section-axis="x"] { color: #ff5f5f; }
.section-btn[data-section-axis="y"] { color: #4ade80; }
.section-btn[data-section-axis="z"] { color: #5b9bff; }
[data-theme="light"] .section-btn[data-section-axis="x"] { color: #d93025; }
[data-theme="light"] .section-btn[data-section-axis="y"] { color: #1a7f3c; }
[data-theme="light"] .section-btn[data-section-axis="z"] { color: #2563eb; }

/* SpaceMouse speed and reversed axes: a footer button (once a puck has been
   seen in this browser) that opens a small panel above the footer. */
.spacemouse-wrap { position: relative; display: flex; align-items: center; }
.spacemouse-wrap.hidden { display: none; }
.spacemouse-btn {
  height: 20px;
  padding: 0 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.spacemouse-btn:hover,
.spacemouse-btn[aria-expanded="true"] { background: var(--border); color: var(--text); }
.spacemouse-panel {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  width: 280px;
  max-width: calc(100vw - 32px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  font-size: 12px;
  color: var(--text);
}
.spacemouse-panel.hidden { display: none; }
.spacemouse-row { display: flex; align-items: center; gap: 8px; }
.spacemouse-row input[type="range"] { flex: 1; min-width: 0; accent-color: var(--accent); }
.spacemouse-row output { min-width: 42px; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-muted); }
.spacemouse-label { font-weight: 600; }
.spacemouse-axes { display: flex; flex-wrap: wrap; gap: 4px; margin-top: -4px; }
.spacemouse-axes button {
  padding: 3px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
}
.spacemouse-axes button:hover { color: var(--text); }
.spacemouse-axes button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.spacemouse-note { margin: 0; font-size: 11px; line-height: 1.4; color: var(--text-muted); }

.place-on-face-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  padding: 6px 10px;
  user-select: none;
  font-family: inherit;
  white-space: nowrap;
}
.place-on-face-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}
.place-on-face-btn.active {
  color: var(--accent);
  border-color: var(--accent);
}

/* ── Rotate controls ──────────────────────────────────────────────────── */
.rotate-controls {
  margin-top: 6px;
}
.rotate-controls.hidden {
  display: none;
}
.rotate-inputs-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.rotate-input-group {
  display: flex;
  align-items: center;
  gap: 3px;
}
.rotate-input-group label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  min-width: 16px;
}
.rotate-input-group input {
  width: 52px;
  font-size: 11px;
}
.rotate-apply-btn,
.rotate-reset-btn {
  font-size: 11px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.rotate-apply-btn:hover,
.rotate-reset-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

.load-stl-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
  flex-wrap: wrap;
}

/* ── Settings panel ──────────────────────────────────────────────────── */
/* The settings panel and the gallery that replaces it share one width, so opening the gallery never
   shifts the viewport. */
#settings-panel,
.gallery-panel {
  width: var(--sidebar-w);
}

/* Collapse tab on the sidebar's left edge; with the sidebar collapsed it sits on the window's edge. */
.sidebar-toggle {
  position: absolute;
  top: 50%;
  right: var(--sidebar-w);
  z-index: 5;
  width: 22px;
  height: 52px;
  margin-top: -26px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-right: 0;
  border-radius: var(--radius) 0 0 var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s;
}

.sidebar-toggle:hover { color: var(--accent); }
.sidebar-toggle svg { transition: transform 0.2s; }

main.sidebar-collapsed .sidebar-toggle { right: 0; }
main.sidebar-collapsed .sidebar-toggle svg { transform: rotate(180deg); }
main.sidebar-collapsed #settings-panel,
main.sidebar-collapsed .gallery-panel { display: none; }

#settings-panel {
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

#settings-panel::-webkit-scrollbar { width: 5px; }
#settings-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.panel-section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.panel-section h2 {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.panel-subsection-heading {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 14px 0 8px;
}

/* ── Advanced / Beta Features (collapsible) ──────────────────────────── */
.advanced-toggle {
  cursor: pointer;
  user-select: none;
  margin-bottom: 0 !important;
  display: flex;
  align-items: center;
  gap: 4px;
}

.advanced-chevron {
  display: inline-block;
  transition: transform 0.15s ease;
  font-size: 9px;
  line-height: 1;
}

.advanced-section:not(.collapsed) .advanced-chevron {
  transform: rotate(90deg);
}

.advanced-section:not(.collapsed) .advanced-toggle {
  margin-bottom: 10px !important;
}

.advanced-section.collapsed .advanced-content {
  display: none;
}

.advanced-blurb {
  font-size: 11px;
  color: var(--text-muted);
  margin: 0 0 10px;
  line-height: 1.4;
}

/* Outline wrap: the note that it maps as cylindrical where it cannot follow the outline. */
.projection-note.hidden { display: none; }

/* Lit while the mouse wheel resizes the stamp instead of zooming. */
.stamp-hint.armed {
  color: var(--accent);
}

.advanced-section .panel-subsection-heading:first-of-type {
  margin-top: 6px;
}

.bake-mask-row {
  margin-bottom: 10px;
}

.bake-mask-row .checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
}

/* ── Preset grid (favourites, 4 wide, grows by rows) ─────────────────── */
.preset-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-bottom: 10px;
}

.preset-grid-empty {
  grid-column: 1 / -1;
  margin: 0;
  padding: 14px 10px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}

.preset-swatch {
  aspect-ratio: 1;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s, transform 0.1s;
  position: relative;
}

.preset-swatch:hover { border-color: var(--text-muted); transform: scale(1.04); }
.preset-swatch.active { border-color: var(--accent); }
.preset-swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.preset-swatch canvas,
.preset-swatch img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.preset-swatch .preset-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 10px;
  text-align: center;
  padding: 2px 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transition: opacity 0.15s;
}

.preset-swatch:hover .preset-label { opacity: 1; }

/* ── Preset loading states ────────────────────────────────────────────── */

@keyframes preset-swatch-shimmer {
  0%   { opacity: .15; }
  50%  { opacity: .30; }
  100% { opacity: .15; }
}

.preset-swatch.preset-loading {
  background: var(--border);
  animation: preset-swatch-shimmer 1.2s ease-in-out infinite;
}

.preset-swatch.preset-loading-full::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.35);
  border-radius: var(--radius);
  pointer-events: none;
}

@keyframes spin-loader {
  to { transform: translate(-50%,-50%) rotate(360deg); }
}

.preset-swatch.preset-loading-full::before {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  transform: translate(-50%,-50%);
  animation: spin-loader .6s linear infinite;
  z-index: 1;
}

/* ── Custom upload button ─────────────────────────────────────────────── */
.upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  transition: background 0.15s, border-color 0.15s;
}

.upload-btn:hover {
  background: var(--border);
  border-color: var(--accent);
}

.map-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.gallery-open-btn { font: inherit; font-size: 12px; }

.gallery-open-count {
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  background: var(--bg);
  border-radius: 999px;
  padding: 1px 6px;
}

/* ── Texture layers strip ─────────────────────────────────────────────── */
.layer-strip {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.layer-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.layer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 6px 3px 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}

.layer-row:hover { border-color: var(--text-muted); }
.layer-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.layer-row.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--surface2));
}

.layer-row.hidden-layer .layer-thumb,
.layer-row.hidden-layer .layer-name { opacity: 0.45; }

.layer-thumb {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 5px;
  background: var(--bg);
  image-rendering: auto;
}

.layer-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 22px;
  min-width: 22px;
  padding: 0 4px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-muted);
  font: inherit;
  font-size: 10px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.layer-btn:hover {
  color: var(--text);
  background: var(--bg);
  border-color: var(--border);
}

.layer-btn.layer-del:hover { color: var(--danger); }

.layer-btn.layer-blend {
  padding: 0 7px;
  border-color: var(--border);
  letter-spacing: 0.02em;
}

.layer-btn.layer-blend.add {
  color: var(--accent);
  border-color: var(--accent);
}

.layer-add-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  align-self: flex-start;
  padding: 4px 10px;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.layer-add-btn:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--accent);
  background: var(--surface2);
}

.layer-add-btn:disabled { opacity: 0.45; cursor: default; }

/* ── Texture gallery side panel ──────────────────────────────────────── */
/* Non-modal: it takes the settings panel's slot (and width, see #settings-panel), so the viewport
   stays put and orbitable while picks apply live. */
main.gallery-open #settings-panel { display: none; }

.gallery-panel {
  position: relative;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px 12px;
  background: var(--surface);
  border-left: 1px solid var(--border);
}

.gallery-panel.hidden { display: none; }
.gallery-panel:focus { outline: none; }   /* focused on open where the search box would pop a keyboard */

.gallery-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.gallery-header h2 {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gallery-turntable-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.gallery-turntable-btn:hover { color: var(--text); border-color: var(--text-muted); }

.gallery-turntable-btn[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.gallery-turntable-btn[aria-pressed="true"] svg { animation: gallery-spin 2.4s linear infinite; }

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

.gallery-done-btn {
  padding: 5px 14px;
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s;
}

.gallery-done-btn:hover { filter: brightness(1.12); }

.gallery-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.gallery-search {
  flex: 1 1 200px;
  min-width: 0;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--text);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.gallery-search:focus { outline: none; border-color: var(--accent); }

.gallery-chips { display: flex; flex-wrap: wrap; gap: 4px; }

.gallery-chip {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.gallery-chip:hover { color: var(--text); border-color: var(--text-muted); }

.gallery-chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.gallery-status {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.gallery-fav-tools {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-variant-numeric: tabular-nums;
}

.gallery-link-btn {
  font: inherit;
  color: var(--accent);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.gallery-link-btn:hover { text-decoration: underline; }

.gallery-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.gallery-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 14px 0 6px;
}

.gallery-section-title:first-child { margin-top: 2px; }

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px 8px;
}

.gallery-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.gallery-name {
  font-size: 11px;
  color: var(--text);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gallery-star {
  position: absolute;
  top: 5px;
  right: 5px;
  z-index: 2;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 14px;
  line-height: 24px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

.gallery-star:hover { transform: scale(1.12); }
.gallery-star[aria-pressed="true"] { color: #ffc940; }

/* Download / delete on the user's own textures, stacked in the top-left corner opposite the star. */
.gallery-tool {
  position: absolute;
  left: 5px;
  z-index: 2;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: #fff;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s, background 0.15s;
}

.gallery-tool-download { top: 5px; }
.gallery-tool-delete { top: 33px; }
.gallery-tool:hover { transform: scale(1.12); }
.gallery-tool-delete:hover { background: var(--danger); }

/* Unstarred stars and tile tools only appear on hover/focus where hovering exists; touch keeps them visible. */
@media (hover: hover) {
  .gallery-star[aria-pressed="false"],
  .gallery-tool { opacity: 0; }
  .gallery-tile:hover .gallery-star,
  .gallery-star:focus-visible,
  .gallery-tile:hover .gallery-tool,
  .gallery-tool:focus-visible { opacity: 1; }
}

.gallery-badge {
  position: absolute;
  left: 4px;
  bottom: 4px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  pointer-events: none;
}

.gallery-empty {
  margin: 24px 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Your textures (uploads kept in this browser, js/customTextures.js) ── */
.gallery-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 14px 0 6px;
}

.gallery-section-head:first-child { margin-top: 2px; }
.gallery-section-head .gallery-section-title { margin: 0; min-width: 0; }

.gallery-danger-link {
  font-size: 11px;
  color: var(--danger);
  white-space: nowrap;
}

.gallery-custom-note {
  margin: 0 0 10px;
  padding: 6px 10px;
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-muted);
  background: color-mix(in srgb, #f59e0b 8%, var(--surface2));
  border-left: 3px solid #f59e0b;
  border-radius: 4px;
}

.gallery-custom-note-warn {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, var(--surface2));
  border-left-color: var(--danger);
}

.gallery-custom-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

.gallery-custom-empty p { margin: 0; line-height: 1.5; }

.gallery-credits {
  margin: 0;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-muted);
}

.gallery-credits strong { color: var(--text); }
.gallery-credits a { color: var(--accent); text-decoration: none; }
.gallery-credits a:hover { text-decoration: underline; }

@media (max-width: 520px) {
  .gallery-panel { padding: 12px 10px 10px; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); }
}

/* Too short for a fixed toolbar over a scrolling grid (landscape phones, the stacked phone layout):
   the whole panel scrolls, and only the header with Done stays put. */
@media (max-height: 560px), (max-width: 699px) and (orientation: portrait) {
  .gallery-panel { overflow-y: auto; padding-top: 0; }
  .gallery-header {
    position: sticky;
    top: 0;
    z-index: 3;
    padding-top: 12px;
    padding-bottom: 6px;
    background: var(--surface);
  }
  .gallery-body { flex: none; overflow: visible; }
}

/* ── Phones ──────────────────────────────────────────────────────────── */
@media (max-width: 699px) {
  header {
    height: auto;
    min-height: var(--header-h);
    flex-wrap: wrap;
    row-gap: 6px;
    padding: 8px 12px;
  }
  .header-actions { flex-wrap: wrap; justify-content: flex-end; row-gap: 6px; }
  .app-version { display: none; }
}

/* Portrait: the viewport on top, the sidebar below it at full width. */
@media (max-width: 699px) and (orientation: portrait) {
  main { flex-direction: column; }
  /* The rail becomes a row of icons between the viewport and the settings */
  .tool-rail {
    order: 1;
    width: auto;
    flex-direction: row;
    padding: 4px 6px;
    border-right: 0;
    border-top: 1px solid var(--border);
    overflow-x: auto;
  }
  .rail-btn { flex: 1 0 52px; padding: 5px 2px 4px; }
  .rail-btn svg { width: 20px; height: 20px; }
  .rail-sep { width: 1px; height: auto; margin: 6px 2px; }
  .sidebar-toggle, #settings-panel, .gallery-panel { order: 2; }
  #settings-panel,
  .gallery-panel {
    width: auto;
    height: 52%;
    border-left: 0;
  }
  /* The collapse tab becomes a bar across the top of the panel; collapsed, it rests at the bottom. */
  .sidebar-toggle {
    position: static;
    flex-shrink: 0;
    width: auto;
    height: 28px;
    margin: 0;
    border: 0;
    border-top: 1px solid var(--border);
    border-radius: 0;
  }
  .sidebar-toggle svg { transform: rotate(90deg); }
  main.sidebar-collapsed .sidebar-toggle svg { transform: rotate(-90deg); }
}

.invert-texture-row {
  margin-top: 12px;
}

/* ── Form rows ───────────────────────────────────────────────────────── */
.form-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.form-row:last-child { margin-bottom: 0; }

.form-row label,
.form-row .form-row-label {
  flex: 0 0 80px;
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
}

.form-row select {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 5px 8px;
  font-size: 12px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  cursor: pointer;
}

.form-row select:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── Sliders ─────────────────────────────────────────────────────────── */
.slider-row { align-items: center; }

.slider-row input[type="range"] {
  flex: 1;
  /* Firefox won't shrink a range below its 12em intrinsic width, so rows with
     long labels pushed the value box out of the panel (#16). */
  min-width: 0;
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  cursor: pointer;
  outline: none;
}

.slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: grab;
  transition: background 0.15s;
}

.slider-row input[type="range"]::-webkit-slider-thumb:active { cursor: grabbing; background: var(--accent-hover); }
.slider-row input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); border: none; cursor: grab;
}

/* Resolution slider runs coarse → fine left-to-right, so the mm value (where
   smaller = finer) decreases as you drag right. The coarse/fine captions below
   carry the direction; the descending number is intentional. */
.slider-stack {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.slider-stack input[type="range"] {
  flex: 0 0 auto;
  width: 100%;
}
/* Resolution only: min (0.01 mm, fine) on the right, max (2 mm, coarse) on the left. */
#refine-length { direction: rtl; }
.slider-captions {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted, #888);
  line-height: 1;
}

.val {
  flex: 0 0 52px;
  text-align: right;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}
input[type="number"].val {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 2px 6px;
  cursor: text;
  box-sizing: border-box;
  min-width: 0;
  -moz-appearance: textfield;
}
input[type="number"].val::-webkit-inner-spin-button,
input[type="number"].val::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"].val:focus { outline: none; border-color: var(--accent); }

/* ── Hint text ───────────────────────────────────────────────────────── */
.hint {
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 6px;
  margin-bottom: 10px;
}

/* ── Export progress ─────────────────────────────────────────────────── */
.export-progress {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  margin-bottom: 10px;
  font-size: 11px;
  color: var(--text-muted);
}

.export-progress.hidden { display: none; }

.export-progress-track {
  position: relative;
  height: 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}

.export-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0%;
}

.export-progress-pct {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  mix-blend-mode: difference;
  pointer-events: none;
}

[data-theme="light"] .export-progress-pct {
  mix-blend-mode: normal;
  color: #fff;
  text-shadow: 0 0 4px rgba(0,0,0,0.5);
}

/* ── Export button ───────────────────────────────────────────────────── */
.export-btn {
  width: 100%;
  padding: 9px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.export-btn:hover:not(:disabled) { background: var(--accent-hover); }
.export-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.export-btn.busy { opacity: 0.7; pointer-events: none; }

/* Row containing Export STL and Export 3MF side-by-side */
.export-buttons {
  display: flex;
  gap: 8px;
}
.export-buttons .export-btn {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
}
/* ── Lock / proportional-scale button ───────────────────────────────────── */
.lock-btn {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.lock-btn.active {
  background: color-mix(in srgb, var(--accent) 18%, var(--surface2));
  border-color: var(--accent);
  color: var(--accent);
}

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

/* ── Lock row connector ───────────────────────────────────────────────────────── */
.lock-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 2px 0;
}

.lock-line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Triangle limit warning ──────────────────────────────────────────────── */
.tri-limit-warning {
  background: color-mix(in srgb, #f59e0b 15%, var(--surface2));
  border: 1px solid #f59e0b;
  color: #f59e0b;
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 11px;
  line-height: 1.4;
  margin-bottom: 8px;
}

.tri-limit-warning.hidden { display: none; }

/* ── Amplitude overlap warning ────────────────────────────────────────────────────────────── */
.amplitude-warning {
  background: color-mix(in srgb, var(--danger) 12%, var(--surface2));
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 11px;
  line-height: 1.4;
  margin-top: 4px;
  margin-bottom: 2px;
}

.amplitude-warning.hidden { display: none; }

/* Red highlight on slider + number input when amplitude is dangerously high */
#amplitude.amp-danger, #amplitude-val.amp-danger {
  accent-color: var(--danger);
  border-color: var(--danger);
  outline: 1px solid var(--danger);
  color: var(--danger);
}

/* ── Resolution too coarse warning ────────────────────────────────────────── */
.resolution-warning {
  background: color-mix(in srgb, #f59e0b 15%, var(--surface2));
  border: 1px solid #f59e0b;
  color: #f59e0b;
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 11px;
  line-height: 1.4;
  margin-top: 4px;
  margin-bottom: 8px;
}

.resolution-warning.hidden { display: none; }

/* Orange highlight on slider + number input when resolution is too coarse */
#refine-length.res-warn, #refine-length-val.res-warn {
  accent-color: #f59e0b;
  border-color: #f59e0b;
  outline: 1px solid #f59e0b;
  color: #f59e0b;
}

/* ── Smart-resolution button + diagnostic ──────────────────────────────────── */
.smart-res-btn {
  display: block;
  width: 100%;
  margin-bottom: 6px;
  padding: 7px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.smart-res-btn:hover:not(:disabled) {
  border-color: var(--accent-hover);
  color: var(--text);
}
.smart-res-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.smart-res-info {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  margin-bottom: 6px;
  line-height: 1.45;
}
.smart-res-info.hidden { display: none; }
.smart-res-info .clamped {
  color: #f59e0b;
}

/* ── Cylinder axis inset panel ─────────────────────────────────────────── */

.cylinder-panel {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 240px;
  height: 276px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  z-index: 22;
  pointer-events: all;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  user-select: none;
  display: flex;
  flex-direction: column;
}

.cylinder-panel.hidden { display: none; }

.cylinder-panel canvas {
  display: block;
  width: 240px;
  height: 240px;
  cursor: grab;
  touch-action: none;
}

/* Width stays the same when minimized; only the canvas collapses away. */
.cylinder-panel.minimized { height: auto; }
.cylinder-panel.minimized canvas { display: none; }

.cylinder-panel-label {
  font-size: 10px;
  color: var(--text-muted);
  padding: 6px 8px;
  flex: 1;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 24px;
}

.cylinder-panel-minimize {
  width: 18px;
  height: 18px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
}
.cylinder-panel-minimize:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
/* Toggle which icon is visible based on the panel's minimized state. */
.cylinder-panel-minimize .icon-expand   { display: none; }
.cylinder-panel.minimized .cylinder-panel-minimize .icon-minimize { display: none; }
.cylinder-panel.minimized .cylinder-panel-minimize .icon-expand   { display: inline-block; }

.cylinder-axis-controls {
  display: flex;
  gap: 6px;
  flex: 1;
}

.cylinder-axis-btn {
  flex: 1;
  padding: 4px 8px;
  font-size: 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  cursor: pointer;
}
.cylinder-axis-btn:hover,
.cylinder-axis-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ── Mesh diagnostics popup ────────────────────────────────────────────── */

.mesh-diagnostics {
  position: absolute;
  bottom: 14px;
  left: 14px;
  z-index: 20;
  max-width: 380px;
  border-radius: var(--radius);
  padding: 10px 28px 10px 14px;
  font-size: 12px;
  line-height: 1.5;
  pointer-events: all;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
  transition: top 0.2s, bottom 0.2s, left 0.2s, right 0.2s;
}

.mesh-diagnostics.diag-corner-tr {
  bottom: auto;
  left: auto;
  top: 14px;
  right: 14px;
}

.mesh-diagnostics.hidden { display: none; }

/* Software-WebGL notice (#75) */
.gpu-warning {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  width: max-content;
  max-width: min(560px, calc(100% - 28px));
  border-radius: var(--radius);
  padding: 10px 30px 10px 14px;
  font-size: 12px;
  line-height: 1.5;
  background: color-mix(in srgb, #f59e0b 15%, var(--surface2));
  border: 1px solid #f59e0b;
  color: #f59e0b;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}
.gpu-warning.hidden { display: none; }
.gpu-warning-dismiss {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  color: inherit;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.7;
}
.gpu-warning-dismiss:hover { opacity: 1; }

/* Severity themes — applied directly to the popup container */
.mesh-diagnostics.diag-ok {
  background: color-mix(in srgb, #22c55e 12%, var(--surface2));
  border: 1px solid #22c55e;
  color: #22c55e;
}

.mesh-diagnostics.diag-warn {
  background: color-mix(in srgb, #f59e0b 15%, var(--surface2));
  border: 1px solid #f59e0b;
  color: #f59e0b;
}

.mesh-diagnostics.diag-error {
  background: color-mix(in srgb, var(--danger) 12%, var(--surface2));
  border: 1px solid var(--danger);
  color: var(--danger);
}

.mesh-diag-results { white-space: pre-line; }
.mesh-diag-results.hidden { display: none; }

.mesh-diag-dismiss {
  position: absolute;
  top: 4px;
  right: 6px;
  background: none;
  border: none;
  color: inherit;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.6;
  padding: 2px 4px;
}

.mesh-diag-dismiss:hover { opacity: 1; }

.mesh-diagnostics a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.mesh-diagnostics a:hover { opacity: 0.8; }

.mesh-diag-advanced-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.mesh-diag-run-btn {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: var(--radius);
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
  cursor: pointer;
  opacity: 0.8;
}

.mesh-diag-run-btn:hover { opacity: 1; }

.diag-show-btn {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: var(--radius);
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
  cursor: pointer;
  opacity: 0.7;
  white-space: nowrap;
  flex-shrink: 0;
}

.diag-show-btn:hover { opacity: 1; }

.mesh-diag-run-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.mesh-diag-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: diag-spin 0.6s linear infinite;
  opacity: 0.6;
}

.mesh-diag-spinner.hidden { display: none; }

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

/* ── Surface Exclusions panel ────────────────────────────────────────────── */

/* Tool button row */
.excl-tools {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.excl-mode-row {
  margin-bottom: 10px;
}
.excl-mode-row .excl-seg {
  flex: 1;
}
.excl-mode-row .excl-seg-btn { white-space: normal; line-height: 1.2; padding: 5px 6px; }

.excl-tool-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

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

.excl-tool-btn svg { width: 16px; height: 16px; }

.excl-tool-btn.active {
  background: color-mix(in srgb, var(--accent) 18%, var(--surface2));
  border-color: var(--accent);
  color: var(--accent);
}

.excl-shift-hint {
  font-size: 10px;
  color: var(--text-muted);
  margin: -4px 0 8px;
  text-align: center;
}

/* Segmented button group (Single / Radius) */
.excl-seg {
  display: flex;
  flex: 1;
}

.excl-seg-btn {
  flex: 1;
  padding: 4px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.excl-seg-btn:first-child {
  border-radius: var(--radius) 0 0 var(--radius);
}

.excl-seg-btn:last-child {
  border-radius: 0 var(--radius) var(--radius) 0;
  border-left: none;
}

.excl-seg-btn.active {
  background: color-mix(in srgb, var(--accent) 18%, var(--surface2));
  border-color: var(--accent);
  color: var(--accent);
}

/* Green active state for the Include Only mode button */
#excl-mode-include.active {
  background: color-mix(in srgb, #00cc66 18%, var(--surface2));
  border-color: #00cc66;
  color: #00cc66;
}

.excl-seg-btn:hover:not(.active) {
  background: var(--border);
  color: var(--text);
}

/* Footer row: count + clear */
.excl-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 10px;
}

.excl-footer .excl-shift-hint {
  margin: 0;
}

.excl-count {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.excl-clear-btn {
  padding: 4px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.excl-clear-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, var(--surface2));
}

/* Hide utility (used by JS to show/hide exclusion sub-rows) */
.form-row.hidden { display: none; }

#harvest-tol-row.disabled,
#smooth-bottom-row.disabled {
  opacity: 0.45;
  pointer-events: none;
}

/* Debug stats for last picked triangle in masking mode */
.masking-tri-debug {
  margin: 8px 0 0 0;
  padding: 6px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.35;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre;
  overflow-x: auto;
}

/* ── Precision masking ───────────────────────────────────────────────── */
.precision-masking-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}

.precision-masking-row.hidden { display: none; }

.precision-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.precision-label input[type="checkbox"] {
  margin: 0;
}

.precision-status {
  font-size: 10px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.precision-outdated {
  font-size: 10px;
  color: #f59e0b;
  white-space: nowrap;
}

.precision-outdated.hidden { display: none; }

.precision-refresh-btn {
  padding: 2px 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  line-height: 1;
}

.precision-refresh-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.precision-refresh-btn.hidden { display: none; }

.precision-warning {
  background: color-mix(in srgb, #f59e0b 15%, var(--surface2));
  border: 1px solid #f59e0b;
  color: #f59e0b;
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 11px;
  line-height: 1.4;
  margin-bottom: 8px;
}

.precision-warning.hidden { display: none; }

/* ── Sponsor / popup overlay ─────────────────────────────────────────── */
.sponsor-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(3px);
}

.sponsor-overlay.hidden { display: none; }

.sponsor-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 32px;
  max-width: 420px;
  width: calc(100% - 40px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.sponsor-modal h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  margin: 0;
}

.sponsor-modal p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0;
}

/* Inline store link in the body text — deliberately not named sponsor-*,
   since adblocker cosmetic filters hide those and take the buttons with them. */
.modal-text-link {
  color: var(--accent);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.modal-text-link:hover { color: var(--accent-hover); }

.sponsor-link {
  display: block;
  text-align: center;
  padding: 10px 16px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s;
}

.sponsor-link:hover { background: var(--accent-hover); }

.sponsor-link--paypal {
  background: #009cde;
}
.sponsor-link--paypal:hover { background: #007bb5; }

.sponsor-link--kofi {
  background: #ff5e5b;
}
.sponsor-link--kofi:hover { background: #e04e4b; }

.sponsor-link--star {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
}
.sponsor-link--star:hover { background: var(--surface2); border-color: var(--accent); color: var(--accent); }

.sponsor-no-show {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.sponsor-no-show input { cursor: pointer; accent-color: var(--accent); }

.sponsor-close-btn {
  padding: 8px 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  align-self: flex-end;
}

.sponsor-close-btn:hover {
  background: var(--border);
  border-color: var(--accent);
}

/* ── License popup overlay ───────────────────────────────────────────────── */
.license-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(3px);
}

.license-overlay.hidden { display: none; }

.license-modal {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 32px;
  max-width: 460px;
  width: calc(100% - 40px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.license-modal h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  margin: 0;
}

.license-list {
  margin: 0;
  padding-left: 1.2em;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.license-list li strong {
  color: var(--text);
}

.license-list li a {
  color: var(--accent);
  text-decoration: none;
}

.license-list li a:hover {
  text-decoration: underline;
}

/* ── Imprint modal extras ────────────────────────────────────────────────── */
.imprint-modal {
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
}

.imprint-section-heading {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 6px 0 0;
}

.imprint-text {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0;
}

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

.imprint-text a:hover {
  text-decoration: underline;
}

/* ── Welcome / What's New popup ──────────────────────────────────────────── */
.welcome-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(3px);
}

.welcome-overlay.hidden { display: none; }

.welcome-modal {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 32px;
  max-width: 480px;
  width: calc(100% - 40px);
  max-height: 85vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.welcome-modal h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  margin: 0;
}

.welcome-tagline {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0;
}

.welcome-heading {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 8px 0 0;
}

.welcome-date {
  color: var(--text-muted);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}

.welcome-steps,
.welcome-changelog {
  margin: 0;
  padding-left: 1.2em;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.welcome-steps li,
.welcome-changelog li {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

.welcome-changelog li strong {
  color: var(--text);
}

.welcome-changelog li code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  background: var(--surface2);
  padding: 1px 5px;
  border-radius: 3px;
}

.welcome-history-link {
  align-self: flex-start;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.welcome-history-link:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.license-close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 26px;
  height: 26px;
  padding: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.license-close-btn:hover {
  background: var(--border);
  border-color: var(--accent);
  color: var(--text);
}

/* ── STEP import dialog ─────────────────────────────────────────────────── */
.step-modal { max-width: 360px; gap: 12px; }

.step-model-size {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
  min-height: 15px;
}

.step-preset-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 13px;
  color: var(--text);
}

.step-preset-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.step-field-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.step-field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--text);
}

.step-field-row input[type="number"] {
  width: 84px;
  padding: 4px 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 12px;
}

.step-field-row input[type="number"]:disabled { opacity: 0.55; }

.step-dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.step-dialog-actions .export-go-btn { margin-top: 0; padding: 7px 18px; }

.step-cancel-btn {
  padding: 7px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.step-cancel-btn:hover { border-color: var(--accent); }

/* ── Project save/load (header) ──────────────────────────────────────────── */
.project-io {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.project-io-gap {
  width: 8px;
  flex: 0 0 8px;
}

.project-io .icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  padding: 0;
}

.project-io .icon-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.project-io .icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.project-io .icon-btn.text-btn {
  width: auto;
  padding: 0 10px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.export-dialog {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 180px;
  z-index: 100;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.export-dialog.hidden { display: none; }

.export-dialog label.hidden { display: none; }

.export-dialog label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.export-dialog label input[type="checkbox"],
.export-dialog label input[type="radio"] {
  accent-color: var(--accent);
  cursor: pointer;
}

.export-dialog-title {
  margin: 0 0 2px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim, var(--text));
  max-width: 200px;
}

.export-dialog label input:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.export-go-btn {
  margin-top: 4px;
  padding: 6px 12px;
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s;
}

.export-go-btn:hover { filter: brightness(1.12); }

/* ── Custom-map thumbnail row ────────────────────────────────────────────── */
.custom-map-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.custom-map-row.hidden { display: none; }

.custom-map-row .custom-map-swatch {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  aspect-ratio: 1;
}

.custom-map-row .custom-map-swatch .preset-label {
  font-size: 7px;
}

.custom-map-remove {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.custom-map-remove:hover {
  background: var(--border);
  border-color: var(--accent);
  color: var(--text);
}
/* ── Filament colors (3MF) ───────────────────────────────────────────── */
.filament-row { flex-wrap: nowrap; }
.filament-swatch {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: none;
  cursor: pointer;
}
.filament-swatch::-webkit-color-swatch-wrapper { padding: 2px; }
.filament-swatch::-webkit-color-swatch { border: none; border-radius: 2px; }
.filament-swatch::-moz-color-swatch { border: none; border-radius: 2px; }
.filament-label {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
}
.filament-from {
  flex: 0 0 auto;
  margin-left: 4px;
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}
.filament-share {
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.color-result-btn {
  width: 100%;
  margin: 4px 0 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
}
.color-result-btn:hover:not(:disabled) { background: var(--surface2); border-color: var(--accent); color: var(--accent); }
.color-result-slot:not(:empty) { margin: 0 0 10px; }
.color-histogram {
  display: block;
  width: 100%;
  height: 44px;
  margin-top: 2px;
  border-bottom: 1px solid var(--border);
}
.color-share-note {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Unfold: fit seams ───────────────────────────────────────────────── */
.unfold-fit-btn { flex: 0 0 auto; width: auto; margin: 0; padding: 4px 12px; }
.unfold-fit-info { flex: 1 1 auto; font-size: 11px; color: var(--text-muted); }

/* Ornaments ▸ own color next to the filament select */
.orn-color { margin-left: 6px; }
.orn-hint { margin: 2px 0 6px; font-size: 11px; color: var(--text-muted, #9aa0aa); line-height: 1.35; }

/* Ornaments ▸ list of stamp / border cards (main.js _renderOrnamentList) */
.orn-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.orn-card { border: 1px solid var(--border); border-radius: var(--radius); background: rgba(255,255,255,0.02); }
.orn-card.active:not(.orn-texture) { border-color: var(--accent, #7c6cf0); }
.orn-card.orn-texture { opacity: 0.6; border-style: dashed; }
.orn-card.hidden-layer { opacity: 0.45; }
.orn-card-head { display: flex; align-items: center; gap: 6px; padding: 5px 6px; cursor: pointer; min-height: 30px; }
.orn-card-head:focus-visible { outline: 2px solid var(--accent, #7c6cf0); outline-offset: -2px; }
.orn-chev { display: inline-flex; transition: transform 0.15s; transform: rotate(-90deg); opacity: 0.7; }
.orn-chev.open { transform: rotate(0deg); }
.orn-card-icon { display: inline-flex; width: 16px; height: 16px; flex: 0 0 16px; }
.orn-card-icon svg { width: 16px; height: 16px; }
.orn-card-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.orn-card-dot { width: 12px; height: 12px; border-radius: 3px; flex: 0 0 12px; border: 1px solid rgba(255,255,255,0.25); }
.orn-card .layer-btn:disabled { opacity: 0.25; cursor: default; }
.orn-card .orn-editor { padding: 0 8px 8px; border-top: 1px solid var(--border); }
.orn-add-row { display: flex; gap: 8px; margin-top: 8px; }
.orn-add-btn { flex: 1 1 0; }
.layer-btn.orn-del:hover { color: var(--danger); }

/* Texture ▸ Rotate 90° next to Invert texture */
.texture-rotate-btn { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.texture-rotate-btn .texture-rotate-deg { opacity: 0.7; font-variant-numeric: tabular-nums; }
.texture-rotate-btn.active { color: var(--accent, #7c6cf0); border-color: var(--accent, #7c6cf0); }
.orn-bowl-row { justify-content: space-between; }

/* Export ▸ Print (printProfile.js) */
.print-box { margin-bottom: 8px; display: flex; flex-direction: column; gap: 10px; }
/* Label on its own line, the field below it across the panel. */
.print-box .form-row { flex-direction: column; align-items: stretch; gap: 4px; margin: 0; }
.print-box .form-row > label,
.print-box .form-row > .form-row-label { width: auto; flex: none; font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted); }
.print-box .excl-seg { display: flex; width: 100%; }
.print-box .excl-seg-btn { flex: 1; padding-top: 7px; padding-bottom: 7px; font-size: 13px; }
.print-box select { width: 100%; min-width: 0; padding: 7px 8px; font-size: 13px; }
.export-manual { margin: 4px 0 10px; }
.export-manual > summary {
  cursor: pointer;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted, #8a8a99);
  padding: 4px 0;
}
.export-manual[open] > summary { margin-bottom: 6px; }

/* Export summary above the export buttons: one value per line, label on top. */
.print-summary { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.print-summary.hidden, .ps-note.hidden, .print-manual-state.hidden { display: none; }
.ps-item { display: flex; flex-direction: column; line-height: 1.15; }
.ps-label { font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted); }
.ps-value { font-size: 20px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.ps-note { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.print-manual-state { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--text-muted); }
