﻿:root {
  --bg: #0a0c0f;
  --panel: #11141a;
  --panel-2: #171b22;
  --border: #252b34;
  --text: #e7ebef;
  --text-mid: #a4acb8;
  --text-dim: #6c7482;
  --accent: #7cf7c4;
  --accent-dim: rgba(124, 247, 196, 0.18);
  --danger: #ff7c87;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(circle at 20% 0%, #10141b 0%, var(--bg) 55%);
  color: var(--text);
  font-family: "Space Grotesk", system-ui, sans-serif;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--panel) 92%, black);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 13px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 10px color-mix(in oklab, var(--accent) 70%, black);
}

.top-meta {
  color: var(--text-dim);
  font-size: 12px;
}

.workspace {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr) 300px;
  min-height: calc(100vh - 52px);
}

.panel {
  background: linear-gradient(180deg, #12161d 0%, #0f1319 100%);
  border-right: 1px solid var(--border);
  overflow: auto;
}

.panel-right {
  border-right: none;
  border-left: 1px solid var(--border);
}

.panel h2 {
  margin: 0;
  padding: 16px 16px 10px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.group {
  margin: 0 12px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: color-mix(in oklab, var(--panel-2) 88%, black);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.group.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 5px;
  font-size: 12px;
  color: var(--text-mid);
}

.inline-toggle {
  align-content: center;
}

input,
select,
button {
  font: inherit;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  border: 1px solid #303847;
  border-radius: 8px;
  background: #0f1319;
  color: var(--text);
  padding: 8px 10px;
}

input[type="number"] {
  font-family: "JetBrains Mono", ui-monospace, monospace;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

input[type="checkbox"] {
  accent-color: var(--accent);
}

.field-row {
  display: grid;
  gap: 5px;
}

.field-row label {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.field-row span {
  color: var(--text);
  font-family: "JetBrains Mono", ui-monospace, monospace;
}

.canvas-panel {
  display: grid;
  grid-template-rows: 44px minmax(0, 1fr) 30px;
  min-width: 0;
}

.canvas-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  background: #0f141b;
  font-size: 12px;
  color: var(--text-mid);
}

.canvas-toolbar label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
}

.spacer {
  flex: 1;
}

.segmented {
  display: inline-flex;
  border: 1px solid #2f3948;
  border-radius: 8px;
  overflow: hidden;
}

.segmented button {
  border: 0;
  background: transparent;
  color: var(--text-dim);
  padding: 6px 10px;
  cursor: pointer;
}

.segmented button.active {
  background: var(--accent-dim);
  color: var(--accent);
}

.preview-stage {
  position: relative;
  background: repeating-linear-gradient(
    0deg,
    rgba(255, 255, 255, 0.01),
    rgba(255, 255, 255, 0.01) 1px,
    transparent 1px,
    transparent 36px
  ),
  repeating-linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.01),
    rgba(255, 255, 255, 0.01) 1px,
    transparent 1px,
    transparent 36px
  );
}

.preview-wrap {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 30px;
}

.preview-wrap.hidden {
  display: none;
}

#preview2d,
#preview3d {
  width: min(90%, 980px);
  height: min(88%, 620px);
}

.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-top: 1px solid var(--border);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
  color: var(--text-mid);
  background: #0f141b;
}

.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 600;
}

.btn-primary {
  background: var(--accent);
  color: #07271c;
}

.btn-primary[disabled] {
  opacity: 0.5;
  cursor: wait;
}

.btn-ghost {
  background: transparent;
  border-color: #303847;
  color: var(--text-mid);
}

.btn-ghost:hover {
  border-color: #435065;
  color: var(--text);
}

.panel-right {
  padding: 16px;
}

.panel-right p.small {
  margin-top: 6px;
  color: var(--text-mid);
  font-size: 12px;
  line-height: 1.45;
}

.result-box {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: #0f1319;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
  color: var(--text-mid);
  display: grid;
  gap: 8px;
}

#resultFilename,
#resultJob {
  color: var(--text);
}

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 8, 12, 0.72);
  backdrop-filter: blur(2px);
}

.modal-panel {
  position: relative;
  width: min(980px, 100%);
  border: 1px solid #2d3744;
  border-radius: 14px;
  background: linear-gradient(180deg, #11161e 0%, #0d1218 100%);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-head h3 {
  margin: 0;
  font-size: 15px;
  color: var(--text);
}

.modal-meta {
  margin: 3px 0 0;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
  color: var(--text-mid);
}

.dot-sep {
  margin: 0 4px;
  color: var(--text-dim);
}

.modal-body {
  padding: 14px 16px 10px;
}

.stl-canvas {
  width: 100%;
  height: min(62vh, 560px);
  border: 1px solid #29313d;
  border-radius: 10px;
  background: radial-gradient(circle at 20% 12%, #1b2430 0%, #0c1015 60%);
  overflow: hidden;
}

.stl-canvas canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.stl-hint {
  margin: 8px 2px 0;
  font-size: 12px;
  color: var(--text-mid);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 10px 16px 16px;
  border-top: 1px solid var(--border);
}

@media (max-width: 1300px) {
  .workspace {
    grid-template-columns: 320px minmax(0, 1fr);
  }

  .panel-right {
    grid-column: 1 / -1;
    border-left: none;
    border-top: 1px solid var(--border);
  }
}

@media (max-width: 960px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .panel,
  .panel-right {
    border-left: none;
    border-right: none;
    border-top: 1px solid var(--border);
    min-height: auto;
  }

  .canvas-panel {
    min-height: 520px;
  }

  .topbar {
    flex-wrap: wrap;
    height: auto;
    padding: 10px 12px;
  }

  .stl-canvas {
    height: min(48vh, 420px);
  }
}
