/* 3deee tools: graphite workspace, PEI-sheet amber as the only accent. */

:root {
  --bg: #17191d;
  --surface: #1f2227;
  --surface-2: #272b31;
  --line: #333840;
  --text: #e6e8eb;
  --muted: #9ba2ac;
  --accent: #e2a640;          /* PEI build sheet */
  --accent-ink: #1a1408;
  --danger: #f07a6a;
  --ok: #7fc8a0;

  --model: #c9cdd2;           /* grey PLA */
  --model-edge: #4a5059;
  --plate: #5e4318;
  --plate-line: #a07530;
  --viewport: radial-gradient(120% 90% at 50% 20%, #2a2e35 0%, #17191d 70%);

  --font: "Archivo", system-ui, sans-serif;
  --radius-s: 6px;
  --radius-l: 14px;
  --gutter: clamp(16px, 4vw, 40px);
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #eef0f2;
    --surface: #ffffff;
    --surface-2: #f4f5f7;
    --line: #d8dce1;
    --text: #1c1f23;
    --muted: #5d6570;
    --accent: #b9801a;
    --accent-ink: #ffffff;
    --danger: #b9402f;
    --ok: #2d7a50;
    --model: #a9aeb5;
    --model-edge: #5b616a;
    --plate: #c9974a;
    --plate-line: #a47630;
    --viewport: radial-gradient(120% 90% at 50% 20%, #ffffff 0%, #e3e6ea 75%);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #eef0f2;
  --surface: #ffffff;
  --surface-2: #f4f5f7;
  --line: #d8dce1;
  --text: #1c1f23;
  --muted: #5d6570;
  --accent: #b9801a;
  --accent-ink: #ffffff;
  --danger: #b9402f;
  --ok: #2d7a50;
  --model: #a9aeb5;
  --model-edge: #5b616a;
  --plate: #c9974a;
  --plate-line: #a47630;
  --viewport: radial-gradient(120% 90% at 50% 20%, #ffffff 0%, #e3e6ea 75%);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 1rem/1.55 var(--font);
  font-variant-numeric: tabular-nums;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-underline-offset: 3px; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* type: Archivo expanded for headlines, normal width for everything else */
h1, h2, h3 { font-stretch: 125%; line-height: 1.08; margin: 0 0 .5em; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 5vw, 3.5rem); font-weight: 800; }
h2 { font-size: clamp(1.35rem, 2.6vw, 1.85rem); font-weight: 700; }
h3 { font-size: 1.1rem; font-weight: 700; }
p { margin: 0 0 1em; max-width: 68ch; }
.lead { font-size: 1.15rem; color: var(--muted); }
.muted { color: var(--muted); }
small, .small { font-size: .85rem; }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1320px; margin: 0 auto; padding: 10px var(--gutter);
  display: flex; align-items: center; gap: 24px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand img { width: 34px; height: 34px; }
.brand span { font-weight: 800; font-stretch: 125%; font-size: 1.05rem; }
.brand span b { color: var(--muted); font-weight: 500; }
.nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.nav a {
  text-decoration: none; padding: 6px 12px; border-radius: var(--radius-s);
  color: var(--muted); font-weight: 500;
}
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }
.theme-toggle {
  border: 1px solid var(--line); background: none; color: var(--muted);
  width: 36px; height: 36px; border-radius: var(--radius-s); cursor: pointer;
  display: grid; place-items: center;
}
.theme-toggle:hover { color: var(--text); }
.menu-toggle { display: none; }

@media (max-width: 760px) {
  .topbar-inner { flex-wrap: wrap; gap: 12px; }
  .menu-toggle {
    display: grid; place-items: center; margin-left: auto;
    border: 1px solid var(--line); background: none; color: var(--text);
    width: 36px; height: 36px; border-radius: var(--radius-s);
  }
  .nav { display: none; width: 100%; flex-direction: column; margin: 0; }
  .topbar.is-open .nav { display: flex; }
}

/* page frame */
main { max-width: 1320px; margin: 0 auto; padding: 32px var(--gutter) 64px; }
.page-head { margin-bottom: 28px; }
.page-head p { color: var(--muted); }

.flash {
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  background: var(--surface); padding: 10px 14px; border-radius: var(--radius-s);
  margin-bottom: 16px;
}
.flash.error { border-left-color: var(--danger); }

/* workspace: controls left, viewport right */
.workspace {
  display: grid; gap: 20px;
  grid-template-columns: minmax(300px, 400px) minmax(0, 1fr);
  align-items: start;
}
.workspace > .viewport { position: sticky; top: 76px; }
@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .workspace > .viewport { position: static; order: -1; height: 360px; min-height: 0; }
  /* no model yet: don't push the form below the fold */
  .workspace > .viewport:has(> [data-empty]:not([hidden])) { display: none; }
}

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-l); padding: 20px;
}
.panel + .panel { margin-top: 16px; }
.panel h2 { font-size: 1.15rem; }

/* viewport */
.viewport {
  position: relative; overflow: hidden;
  min-height: 420px; height: min(72vh, 680px);
  border: 1px solid var(--line); border-radius: var(--radius-l);
  background: var(--viewport);
}
.viewport canvas { display: block; width: 100% !important; height: 100% !important; touch-action: none; }
.viewport-tools {
  position: absolute; top: 12px; right: 12px; display: flex; gap: 6px;
}
.viewport-tools button {
  font: 500 .8rem var(--font); color: var(--text);
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: 6px 10px; cursor: pointer;
}
.viewport-tools button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.viewport-readout {
  position: absolute; left: 14px; bottom: 12px; right: 14px;
  display: flex; flex-wrap: wrap; gap: 6px; font-size: .85rem; color: var(--muted);
  pointer-events: none;
}
.viewport-readout > span {
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  border: 1px solid var(--line); border-radius: var(--radius-s); padding: 3px 8px;
}
.viewport-readout strong { color: var(--text); font-weight: 600; }
.viewport-empty {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  color: var(--muted); padding: 24px;
}

/* dropzone */
.dropzone {
  position: relative; display: block; cursor: pointer;
  border: 1.5px dashed var(--line); border-radius: var(--radius-l);
  padding: 22px 18px; text-align: center; background: var(--surface-2);
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.is-over, .dropzone:focus-within { border-color: var(--accent); }
.dropzone.is-over { background: color-mix(in srgb, var(--accent) 10%, var(--surface-2)); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone strong { display: block; font-size: 1.05rem; }
.dropzone .muted { font-size: .9rem; }
.dropzone [data-upload-status] { display: block; font-size: .9rem; }
.dropzone [data-upload-status]:not(:empty) { margin-top: 8px; }
.dropzone[data-state="error"] [data-upload-status] { color: var(--danger); }
.dropzone [data-upload-bar] {
  --progress: 0;
  position: absolute; left: 0; bottom: 0; height: 3px; width: 100%;
  transform-origin: left; transform: scaleX(var(--progress));
  background: var(--accent); border-radius: 0 0 var(--radius-l) var(--radius-l);
  transition: transform .1s linear;
}

/* forms */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label, .label { font-size: .875rem; font-weight: 600; color: var(--muted); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-unit { display: grid; grid-template-columns: 1fr 110px; gap: 8px; }
input[type=text], input[type=number], select {
  width: 100%; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: 9px 11px;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
fieldset { border: 0; padding: 0; margin: 0 0 14px; }

.segmented {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 3px;
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
  text-align: center; padding: 6px 4px; border-radius: 4px; cursor: pointer;
  font-size: .875rem; font-weight: 600; color: var(--muted);
}
.segmented input:checked + label { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.segmented input:focus-visible + label { outline: 2px solid var(--accent); }

.check { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 14px; cursor: pointer; }
.check input { accent-color: var(--accent); width: 18px; height: 18px; margin-top: 2px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 700 1rem var(--font); text-decoration: none; cursor: pointer;
  padding: 11px 18px; border-radius: var(--radius-s); border: 1px solid transparent;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { color: var(--accent-ink); filter: brightness(1.08); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.btn-ghost { background: none; border-color: var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); color: var(--text); }
.btn-block { width: 100%; }

/* key/value readouts */
.specs { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; }
.specs dt { color: var(--muted); font-size: .9rem; }
.specs dd { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.warn { color: var(--danger); font-size: .9rem; margin-top: 10px; }

.figures { display: grid; gap: 14px; margin: 4px 0 18px; }
.figure + .figure { border-top: 1px solid var(--line); padding-top: 12px; }
.figure .value { font-size: clamp(1.8rem, 3.5vw, 2.4rem); font-weight: 800; font-stretch: 112%; line-height: 1.1; }
.figure .value small { font-size: .5em; font-weight: 600; color: var(--muted); margin-left: 4px; }
.figure .sub { color: var(--muted); font-size: .9rem; }
.figure.is-input .value { color: var(--muted); }

/* home */
.hero {
  display: grid; gap: 32px; align-items: center;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  margin-bottom: 56px;
}
.hero h1 { max-width: 12ch; }
.hero .viewport { height: min(66vh, 560px); }
.hero .dropzone { margin-top: 20px; max-width: 440px; }
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .hero .viewport { height: 360px; min-height: 0; }
}

.tool-list { list-style: none; margin: 0 0 56px; padding: 0; border-top: 1px solid var(--line); }
.tool-list li { border-bottom: 1px solid var(--line); }
.tool-list a {
  display: grid; grid-template-columns: 280px minmax(0, 1fr) 190px; gap: 8px 32px;
  align-items: baseline; padding: 22px 4px; text-decoration: none;
}
.tool-list a:hover h2 { color: var(--accent); }
.tool-list h2 { margin: 0; font-size: 1.3rem; }
.tool-list p { margin: 0; color: var(--muted); }
.tool-list .formats { font-size: .85rem; color: var(--muted); text-align: right; }
@media (max-width: 700px) {
  .tool-list a { grid-template-columns: 1fr; }
  .tool-list .formats { text-align: left; }
}

.changelog { display: grid; grid-template-columns: max-content 1fr; gap: 6px 24px; margin: 0; }
.changelog dt { color: var(--muted); }
.changelog dd { margin: 0; }

/* spool tables */
.spool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); gap: 16px; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { color: var(--muted); font-weight: 600; font-size: .8rem; }
tbody tr:hover { background: var(--surface-2); }
.table-scroll { overflow-x: auto; }

.ad-slot { margin: 32px 0; min-height: 90px; }
.section { margin-top: 48px; }

/* footer */
.footer { border-top: 1px solid var(--line); }
.footer-inner {
  max-width: 1320px; margin: 0 auto; padding: 24px var(--gutter);
  display: flex; flex-wrap: wrap; gap: 12px 32px; justify-content: space-between; color: var(--muted); font-size: .9rem;
}

/* converter */
.result-box { border: 1px solid var(--line); border-radius: var(--radius-s); padding: 14px; margin-top: 14px; }
.result-box.is-error { border-color: var(--danger); color: var(--danger); }
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
