/* Seamless Slicer Web App – Orca-inspired layout, Seamless Slicer identity (light & dark) */
:root {
  --bg: #f1f2f5;
  --page: #ffffff;
  --panel: #f7f8fa;
  --text: #181c24;
  --sub: #5f6675;
  --line: #d8dce4;
  --line-soft: #e6e9ef;
  --input-bg: #ffffff;
  --input-border: #c9ced8;
  --btn-bg: #ffffff;
  --btn-hover: #eef2f8;
  --btn-border: #c5cbd6;
  --accent: #f2a11f;
  --accent-strong: #d4860a;
  --accent-ink: #1a1200;
  --accent-soft: #fef3dc;
  --teal: #009688;
  --warn: #b85300;
  --warn-bg: #fff5e6;
  --warn-border: #f3d2a2;
  --view-bg: #ffffff;
  --wall: #d72323;
  --rib: #dea800;
  --fill: #3ca05a;
  --brim: #3c78d7;
  --bridge: #ffc85a;
  --guide: #b43cb4;
  --shadow: 0 2px 10px rgba(15, 20, 30, 0.08);
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --mono: "Cascadia Code", "Cascadia Mono", ui-monospace, Consolas, Menlo, monospace;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #1e2024;
  --page: #26292e;
  --panel: #22252a;
  --text: #e6e8ee;
  --sub: #98a0ae;
  --line: #3b4049;
  --line-soft: #31353e;
  --input-bg: #31343b;
  --input-border: #4e535e;
  --btn-bg: #32363e;
  --btn-hover: #3e434d;
  --btn-border: #515763;
  --accent: #f5aa2a;
  --accent-strong: #ffb940;
  --accent-ink: #151000;
  --accent-soft: rgba(245, 170, 42, 0.16);
  --teal: #1db5a6;
  --warn: #f5a654;
  --warn-bg: rgba(245, 166, 84, 0.13);
  --warn-border: rgba(245, 166, 84, 0.35);
  --view-bg: #1e1f22;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
}

/* ================================================================ Layout */
.app {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100vh;
  height: 100dvh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--page);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  z-index: 20;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14.5px;
  color: var(--text);
  text-decoration: none;
  margin-right: 4px;
  white-space: nowrap;
}
.brand img { width: 24px; height: 24px; border-radius: 6px; display: block; }
.brand span b { color: var(--accent-strong); }

.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border-radius: 6px;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--text);
  font: 600 12.5px/1 var(--font);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s, opacity 0.12s;
}
.btn:hover:not(:disabled) { background: var(--btn-hover); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn svg { width: 14px; height: 14px; flex: 0 0 auto; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent-strong);
  color: var(--accent-ink);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.sample-select {
  height: 30px;
  padding: 0 7px;
  border-radius: 6px;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--text);
  font: 500 12px/1 var(--font);
  cursor: pointer;
  max-width: 165px;
}

.status-wrap {
  flex: 1 1 120px;
  min-width: 90px;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.status-text {
  font-size: 12.5px;
  color: var(--sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.status-text.busy { color: var(--text); font-weight: 500; }

.progress-bar {
  width: 90px;
  height: 5px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
  flex: 0 0 auto;
  display: none;
}
.progress-bar.active { display: block; }
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.1s linear;
}

.top-right {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.seg-group {
  display: inline-flex;
  border: 1px solid var(--btn-border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--panel);
}
.seg-group button {
  height: 28px;
  padding: 0 9px;
  border: 0;
  background: transparent;
  color: var(--sub);
  font: 600 11.5px/1 var(--font);
  cursor: pointer;
}
.seg-group button + button { border-left: 1px solid var(--line); }
.seg-group button.active {
  background: var(--accent);
  color: var(--accent-ink);
}

.icon-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}
.icon-btn:hover { background: var(--btn-hover); }
.icon-btn svg { width: 15px; height: 15px; }

.top-link {
  font-size: 12px;
  color: var(--sub);
  text-decoration: none;
  padding: 4px 6px;
  border-radius: 5px;
  white-space: nowrap;
}
.top-link:hover { color: var(--text); background: var(--btn-hover); }

/* ================================================================ Workspace */
.workspace {
  display: grid;
  grid-template-columns: 360px 1fr;
  min-height: 0;
  position: relative;
}

/* ================================================================ Left Sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--page);
  border-right: 1px solid var(--line);
}

.sidebar-tabs {
  display: flex;
  gap: 2px;
  padding: 6px 8px 0;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.tab-btn {
  padding: 6px 12px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: var(--sub);
  font: 600 12.5px/1.2 var(--font);
  cursor: pointer;
  position: relative;
  top: 1px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  background: var(--page);
  color: var(--text);
  border-color: var(--line);
  border-bottom-color: var(--page);
}

.tab-page {
  display: none;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 10px 14px;
}
.tab-page.active { display: block; }

.tab-page.gcode-page.active {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
}

/* Orca-style categories */
.cat-block { margin-bottom: 4px; }
.cat-hdr {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 7px 2px 5px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: 700 13px/1.2 var(--font);
  cursor: pointer;
  text-align: left;
}
.cat-hdr .arrow {
  width: 12px;
  font-size: 10px;
  color: var(--sub);
  display: inline-block;
  transition: transform 0.12s;
}
.cat-block.collapsed .cat-hdr .arrow { transform: rotate(-90deg); }
.cat-hdr .line {
  flex: 1;
  height: 1px;
  background: var(--line-soft);
  margin-left: 4px;
}

.cat-body {
  padding: 2px 0 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.cat-block.collapsed .cat-body { display: none; }

.field-row {
  display: grid;
  grid-template-columns: 1fr 118px;
  align-items: center;
  gap: 8px;
  min-height: 26px;
}
.field-label {
  font-size: 12.5px;
  color: var(--text);
  line-height: 1.25;
  user-select: none;
}
.field-row.bool-row .field-label { cursor: pointer; }

.num-box {
  display: flex;
  align-items: center;
  height: 26px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 5px;
  padding: 0 7px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.num-box:hover { border-color: var(--teal); }
.num-box:focus-within {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(0, 150, 136, 0.18);
}
.num-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: 500 12.5px/1 var(--font);
  font-variant-numeric: tabular-nums;
}
.num-box .unit {
  font-size: 11px;
  color: var(--sub);
  margin-left: 4px;
  white-space: nowrap;
  user-select: none;
  pointer-events: none;
}

.chk-wrap {
  display: flex;
  align-items: center;
  height: 26px;
}
.chk-wrap input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--teal);
  cursor: pointer;
}

.cat-note {
  font-size: 11.5px;
  color: var(--sub);
  line-height: 1.4;
  white-space: pre-line;
  padding: 4px 2px 2px;
}

.sidebar-hint {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
  font-size: 11.5px;
  color: var(--sub);
  line-height: 1.45;
  white-space: pre-line;
}

.sidebar-tools {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  flex-wrap: wrap;
}
.sidebar-tools .btn { height: 26px; padding: 0 9px; font-size: 11.5px; }

.gcode-page label {
  font-size: 12px;
  font-weight: 600;
  color: var(--sub);
}
.gcode-page textarea {
  width: 100%;
  flex: 1 1 120px;
  min-height: 110px;
  resize: none;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  font: 12px/1.4 var(--mono);
  white-space: pre;
  overflow: auto;
}
.gcode-page textarea:focus {
  outline: 0;
  border-color: var(--teal);
}

/* ================================================================ Right Views Area */
.main-area {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
  padding: 6px;
  gap: 6px;
}

.warnings-bar {
  display: none;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn);
  font-size: 12px;
  line-height: 1.4;
}
.warnings-bar.visible { display: block; }
.warnings-bar ul { margin: 0; padding-left: 16px; }

.views-stage {
  display: grid;
  grid-template-columns: 1fr 1fr 34px;
  gap: 6px;
  min-height: 0;
  min-width: 0;
}
.views-stage.mode-2d { grid-template-columns: 1fr 34px; }
.views-stage.mode-2d .pane-3d { display: none; }
.views-stage.mode-3d { grid-template-columns: 1fr 34px; }
.views-stage.mode-3d .pane-2d { display: none; }

.view-pane {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: var(--view-bg);
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}
.view-pane canvas {
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
  touch-action: none;
}

.view-overlay-hint {
  position: absolute;
  left: 10px;
  bottom: 8px;
  font-size: 11.5px;
  color: var(--sub);
  pointer-events: none;
  user-select: none;
  text-shadow: 0 1px 2px var(--view-bg);
}

.view-presets {
  position: absolute;
  right: 8px;
  top: 8px;
  display: flex;
  gap: 3px;
  opacity: 0.72;
  transition: opacity 0.15s;
}
.view-presets:hover { opacity: 1; }
.view-presets button {
  height: 22px;
  min-width: 24px;
  padding: 0 5px;
  border: 1px solid var(--btn-border);
  border-radius: 4px;
  background: var(--page);
  color: var(--text);
  font: 600 10.5px/1 var(--font);
  cursor: pointer;
}
.view-presets button:hover { background: var(--btn-hover); }

.empty-cta {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  background: transparent;
  pointer-events: none;
}
.empty-cta.hidden { display: none; }
.empty-card {
  pointer-events: auto;
  max-width: 380px;
  padding: 20px 22px;
  border-radius: 12px;
  background: var(--page);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.empty-card h2 {
  margin: 0 0 6px;
  font-size: 15px;
}
.empty-card p {
  margin: 0 0 12px;
  font-size: 12.5px;
  color: var(--sub);
}
.empty-card .quick-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}
.privacy-note {
  margin-top: 10px !important;
  margin-bottom: 0 !important;
  font-size: 11px !important;
  color: var(--sub);
}

/* Vertical layer slider (Orca/Cura style, top = highest layer) */
.slider-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 0;
  min-height: 0;
}
.vslider-wrap {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
  position: relative;
}
#layerSlider {
  writing-mode: vertical-lr;
  direction: rtl;
  height: 100%;
  width: 24px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Bottom bar: layer controls + legend + totals */
.bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 6px 10px;
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.layer-ctrl {
  display: flex;
  align-items: center;
  gap: 6px;
}
.step-btn {
  width: 28px;
  height: 26px;
  border-radius: 5px;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--text);
  font-size: 11px;
  cursor: pointer;
}
.step-btn:hover:not(:disabled) { background: var(--btn-hover); }
.step-btn:disabled { opacity: 0.4; cursor: default; }

.layer-label {
  font-weight: 700;
  font-size: 12.5px;
  margin-left: 4px;
  font-variant-numeric: tabular-nums;
}

.legend {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--sub);
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
}

.totals {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
  text-align: right;
}
.totals-main {
  display: flex;
  gap: 14px;
  font-weight: 700;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.totals-parts {
  font-size: 11px;
  color: var(--sub);
  line-height: 1.3;
}

/* Drag & Drop Overlay */
.drop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(242, 161, 31, 0.16);
  backdrop-filter: blur(3px);
  border: 3px dashed var(--accent);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  pointer-events: none;
}
.drop-overlay.active { display: flex; }
.drop-pill {
  padding: 16px 26px;
  border-radius: 12px;
  background: var(--page);
  border: 1px solid var(--accent);
  box-shadow: var(--shadow);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

/* Mobile / narrow screens */
.sidebar-toggle { display: none; }
@media (max-width: 960px) {
  .workspace { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 46px;
    bottom: 0;
    width: min(360px, 90vw);
    z-index: 40;
    box-shadow: var(--shadow);
    transform: translateX(-105%);
    transition: transform 0.18s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: inline-flex; }
  .views-stage { grid-template-columns: 1fr 34px; }
  .views-stage .pane-2d { display: none; }
  .views-stage.mode-2d { grid-template-columns: 1fr 34px; }
  .views-stage.mode-2d .pane-2d { display: block; }
  .views-stage.mode-2d .pane-3d { display: none; }
  .views-stage.mode-split { grid-template-columns: 1fr 34px; grid-template-rows: 1fr 1fr; }
  .views-stage.mode-split .pane-2d { display: block; grid-column: 1; grid-row: 1; }
  .views-stage.mode-split .pane-3d { display: block; grid-column: 1; grid-row: 2; }
  .views-stage.mode-split .slider-col { grid-column: 2; grid-row: 1 / 3; }
}
