:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #e6e9eb;
  background: #0d0f10;
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: #0d0f10; }
button, input { font: inherit; }
button, .upload-button, .view-presets summary {
  min-height: 34px;
  border: 1px solid #3a4045;
  border-radius: 4px;
  background: #202428;
  color: #e8ebed;
  padding: .45rem .7rem;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
button:hover:not(:disabled), .view-presets summary:hover { background: #292e32; border-color: #626b72; }
button:focus-visible, input:focus-visible, .upload-button:focus-visible, .view-presets summary:focus-visible {
  outline: 2px solid #d4a84f;
  outline-offset: 2px;
}
button:disabled { opacity: .4; cursor: not-allowed; }

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 264px;
  grid-template-rows: 56px minmax(420px, 1fr);
}
.topbar {
  grid-column: 1 / -1;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 8px 16px;
  border-bottom: 1px solid #303438;
  background: #171a1d;
}
.home-brand {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: inherit;
  text-decoration: none;
}
.home-brand:focus-visible, .legal-brand:focus-visible { outline: 2px solid #d4a84f; outline-offset: 3px; border-radius: 3px; }
.brand-mark { display: block; flex: 0 0 auto; border-radius: 5px; }
.brand-copy { min-width: 0; display: grid; }
.brand-name { font-size: 1rem; font-weight: 650; white-space: nowrap; }
.brand-subtitle { margin-top: 1px; color: #858d93; font-size: .68rem; white-space: nowrap; }
.upload-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-color: #35a999;
  background: #168c7d;
  color: #fff;
  font-size: .8rem;
  font-weight: 650;
  white-space: nowrap;
}
.upload-button:hover { background: #1b9c8c; border-color: #51c2b2; }

.upload-dialog {
  width: min(500px, calc(100% - 28px));
  padding: 0;
  border: 1px solid #464c51;
  border-radius: 6px;
  background: #1a1e21;
  color: #e6e9eb;
  box-shadow: 0 20px 60px rgb(0 0 0 / 55%);
}
.upload-dialog::backdrop { background: rgb(5 7 8 / 74%); }
.upload-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 20px 16px;
  border-bottom: 1px solid #303438;
}
.upload-kicker { margin: 0 0 4px; color: #29b8a6; font-size: .66rem; font-weight: 650; text-transform: uppercase; }
.upload-dialog h2 { margin: 0; color: #f0f2f3; font-size: 1rem; font-weight: 650; letter-spacing: 0; }
.dialog-close {
  width: 30px;
  min-height: 30px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #90989d;
  font-size: 1.4rem;
  line-height: 1;
}
.dialog-close:hover:not(:disabled) { background: #292e32; color: #fff; }
.upload-drop-zone {
  min-height: 250px;
  margin: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px;
  border: 1px dashed #596269;
  border-radius: 5px;
  background: #141719;
  text-align: center;
  transition: border-color .12s, background .12s;
}
.upload-drop-zone.dragging { border-color: #45c3b2; background: #152321; }
.upload-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  margin-bottom: 16px;
  border: 1px solid #3b847b;
  border-radius: 5px;
  background: #18322f;
  color: #8fe1d6;
  font: 700 .72rem ui-monospace, SFMono-Regular, Consolas, monospace;
}
.upload-prompt { margin: 0; color: #d8dcdf; font-size: .86rem; font-weight: 600; }
.upload-or { margin: 8px 0; color: #747c81; font-size: .72rem; }
.upload-choose { border-color: #35a999; background: #168c7d; color: #fff; font-size: .78rem; font-weight: 650; }
.upload-choose:hover:not(:disabled) { background: #1b9c8c; border-color: #51c2b2; }
.upload-disclosure { padding: 0 20px 18px; color: #a8afb3; font-size: .72rem; line-height: 1.5; }

.viewer { position: relative; min-width: 0; overflow: hidden; background: #111315; }
#canvas { width: 100%; height: 100%; display: block; touch-action: none; }
.viewer.dragging { outline: 2px solid #36b6a5; outline-offset: -2px; }
.viewer.dragging::after {
  content: "Drop STL to open";
  position: absolute;
  inset: 16px;
  z-index: 3;
  display: grid;
  place-items: center;
  border: 1px dashed #48beae;
  background: rgb(16 24 23 / 88%);
  color: #e9fffb;
  font-size: .9rem;
  font-weight: 650;
  pointer-events: none;
}
.empty-state {
  position: absolute;
  inset: 0 0 30px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 24px;
  text-align: center;
  pointer-events: none;
}
.empty-state[hidden] { display: none; }
.empty-state h2 { margin: 0 0 6px; color: #d7dcdf; font-size: 1rem; font-weight: 600; letter-spacing: 0; }
.empty-state p { margin: 0; color: #7d858b; font-size: .8rem; line-height: 1.45; }
.status {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 4;
  width: min(300px, calc(100% - 32px));
  padding: 14px;
  transform: translate(-50%, -50%);
  border: 1px solid #464d52;
  border-radius: 4px;
  background: rgb(29 33 36 / 96%);
  text-align: left;
}
.status-message { font-size: .78rem; font-weight: 600; }
.status progress { display: block; width: 100%; height: 7px; margin-top: 10px; accent-color: #29b8a6; }
.status progress[hidden] { display: none; }
.status.error { border-color: #a95757; color: #ffd7d7; background: rgb(57 30 30 / 97%); }
.view-help {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  min-height: 30px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 7px 12px;
  border-top: 1px solid #292d30;
  background: rgb(18 20 22 / 92%);
  color: #737b80;
  font-size: .68rem;
  line-height: 1rem;
}
.view-help a { color: #8cbeb7; text-decoration: none; pointer-events: auto; }
.view-help a:hover { color: #b8e7df; text-decoration: underline; }
.footer-links { display: flex; gap: 14px; }

.legal-body { min-height: 100vh; background: #111315; color: #d8dcdf; }
.legal-header {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  border-bottom: 1px solid #303438;
  background: #171a1d;
}
.legal-brand { display: inline-flex; align-items: center; gap: 8px; color: #f0f2f3; font-size: .9rem; font-weight: 700; text-decoration: none; }
.legal-back { color: #8cbeb7; font-size: .76rem; text-decoration: none; }
.legal-back:hover { color: #b8e7df; text-decoration: underline; }
.legal-content { width: min(760px, calc(100% - 32px)); margin: 0 auto; padding: 48px 0 72px; }
.legal-title { padding-bottom: 28px; border-bottom: 1px solid #303438; }
.legal-kicker { margin: 0 0 10px; color: #29b8a6; font-size: .7rem; font-weight: 650; text-transform: uppercase; }
.legal-title h1 { margin: 0; color: #f0f2f3; font-size: clamp(1.7rem, 4vw, 2.4rem); font-weight: 650; letter-spacing: 0; }
.legal-title > p:last-child { margin: 12px 0 0; color: #939ba0; line-height: 1.55; }
.legal-title .api-spec-link { margin-top: 8px; font-size: .76rem; }
.legal-content section { padding: 24px 0; border-bottom: 1px solid #292d30; }
.legal-content section h2 { margin: 0 0 10px; color: #e3e6e8; font-size: .92rem; font-weight: 650; letter-spacing: 0; }
.legal-content section p { margin: 0; color: #adb3b7; font-size: .82rem; line-height: 1.7; }
.legal-content section p + p { margin-top: 10px; }
.legal-content a { color: #8ccfc5; }
.legal-content code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.endpoint-heading { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.endpoint-method {
  display: inline-block;
  padding: 3px 6px;
  border: 1px solid #329e90;
  border-radius: 3px;
  color: #8de0d4;
  font-size: .65rem;
  line-height: 1;
}
.endpoint-path { color: #f0f2f3; font-size: .86rem; }
.code-block {
  margin: 14px 0 0;
  padding: 13px 14px;
  overflow-x: auto;
  border: 1px solid #303438;
  border-radius: 4px;
  background: #0d0f10;
  color: #cdd3d6;
  font-size: .74rem;
  line-height: 1.65;
  white-space: pre;
}
.api-table-wrap { margin-top: 14px; overflow-x: auto; }
.api-table { width: 100%; border-collapse: collapse; font-size: .76rem; }
.api-table th, .api-table td { padding: 9px 10px; border-bottom: 1px solid #303438; text-align: left; vertical-align: top; }
.api-table th { color: #8d959a; font-size: .66rem; font-weight: 650; text-transform: uppercase; }
.api-table td { color: #b9bec1; line-height: 1.5; }
.api-table td:first-child { color: #e1e5e7; white-space: nowrap; }
.api-note { margin-top: 14px !important; padding-left: 12px; border-left: 2px solid #329e90; }
.code-example { margin-top: 14px; }
.code-tabs { display: inline-flex; border: 1px solid #3a4045; border-radius: 4px; overflow: hidden; }
.code-tabs button {
  min-width: 72px;
  min-height: 30px;
  padding: 5px 12px;
  border: 0;
  border-radius: 0;
  background: #171a1d;
  color: #929a9f;
  font-size: .7rem;
  font-weight: 650;
}
.code-tabs button + button { border-left: 1px solid #3a4045; }
.code-tabs button[aria-selected="true"] { background: #247f73; color: #fff; }
.code-tabs button:hover:not(:disabled) { background: #292e32; border-color: transparent; }
.code-tabs button[aria-selected="true"]:hover { background: #2b9183; }
.code-example .code-block { margin-top: 8px; }
.code-example .code-block[hidden] { display: none; }

.panel {
  border-left: 1px solid #303438;
  background: #171a1d;
  padding: 14px;
  overflow-y: auto;
}
.panel section + section { margin-top: 18px; padding-top: 12px; border-top: 1px solid #303438; }
.panel h2 {
  margin: 0 0 10px;
  color: #969da2;
  font-size: .68rem;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: uppercase;
}
.control-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.control-grid button { min-width: 0; padding-inline: .45rem; font-size: .76rem; }
.toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 5px 7px;
  border: 1px solid #353a3e;
  border-radius: 4px;
  color: #c7cccf;
  font-size: .76rem;
}
.toggle input { width: 15px; height: 15px; margin: 0; accent-color: #29b8a6; }
.color-control {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 34px;
  margin-top: 6px;
  padding: 5px 7px;
  border: 1px solid #353a3e;
  border-radius: 4px;
  color: #c7cccf;
  font-size: .76rem;
}
.color-control input { width: 34px; height: 22px; border: 0; padding: 0; background: none; cursor: pointer; }
.details { margin: 0; display: grid; }
.details div {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  padding: 7px 0;
  border-bottom: 1px solid #282c2f;
}
.details dt { color: #777f84; font-size: .68rem; }
.details dd {
  margin: 0;
  color: #d8dcdf;
  font-size: .74rem;
  text-align: right;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.view-presets { position: relative; width: 128px; margin-left: auto; }
.view-presets summary { list-style: none; font-size: .8rem; }
.view-presets summary::-webkit-details-marker { display: none; }
.view-presets summary::after { content: "▾"; float: right; color: #90979c; }
.view-presets[open] summary { border-color: #36ad9d; }
.preset-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 6;
  width: 176px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 5px;
  border: 1px solid #444a4f;
  border-radius: 4px;
  background: #1b1f22;
  box-shadow: 0 8px 18px rgb(0 0 0 / 35%);
}
.preset-menu button { min-width: 0; min-height: 30px; border-radius: 3px; font-size: .74rem; }

.seo-content {
  width: min(920px, calc(100% - 40px));
  margin: 0 auto;
  padding: 64px 0 72px;
  color: #b7bdc1;
  line-height: 1.75;
}
.seo-content header { max-width: 760px; margin-bottom: 38px; }
.seo-content h1 { margin: 0 0 14px; color: #f1f3f4; font-size: clamp(1.8rem, 4vw, 2.7rem); line-height: 1.15; }
.seo-content h2 { margin: 0 0 8px; color: #e3e6e8; font-size: 1.08rem; }
.seo-content p { margin: 0; }
.seo-content section { padding: 24px 0; border-top: 1px solid #292e32; }
.seo-content a { color: #79d2c6; }

@media (max-width: 760px) {
  .app { display: flex; flex-direction: column; min-height: 100vh; }
  .topbar { min-height: 54px; }
  .viewer { height: 62vh; min-height: 360px; }
  .panel { border-top: 1px solid #303438; border-left: 0; }
  .panel section + section { margin-top: 14px; }
  .details { grid-template-columns: 1fr 1fr; column-gap: 16px; }
}

@media (max-width: 430px) {
  .topbar { gap: 6px; padding-inline: 10px; }
  .brand-name { font-size: .9rem; }
  .brand-subtitle { display: none; }
  .home-brand { gap: 7px; }
  .home-brand .brand-mark { width: 28px; height: 28px; }
  .view-presets { width: 94px; }
  .view-presets summary { padding-inline: .5rem; font-size: .75rem; }
  .upload-button { padding-inline: .6rem; font-size: .75rem; }
  .upload-dialog-header { padding: 16px; }
  .upload-drop-zone { min-height: 220px; margin: 16px; padding: 20px; }
  .upload-disclosure { padding: 0 16px 16px; }
  .viewer { min-height: 340px; }
  .view-help { font-size: .66rem; }
  .view-help span { display: none; }
  .legal-header { padding-inline: 14px; }
  .legal-content { width: calc(100% - 28px); padding-top: 32px; }
  .details { grid-template-columns: 1fr; }
}
