:root {
  --coal: #100d0c;
  --char: #1b1411;
  --soot: #3c2d26;
  --ash: #bcada2;
  --bone: #f4e8de;
  --ember: #e0702e;
  --flame: #ffb37a;
  --display: "Unbounded", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--bone);
  background: radial-gradient(ellipse at 50% 0, #281810 0, transparent 39rem), var(--coal);
  font: 400 1rem/1.55 "IBM Plex Sans", system-ui, sans-serif;
}
a { color: var(--flame); }
p { margin: 0; color: var(--ash); }
h1, h2 { margin: 0; font-family: var(--display); line-height: 1.18; letter-spacing: -.035em; }
:focus-visible { outline: 2px solid var(--flame); outline-offset: 4px; }
[hidden] { display: none !important; }

.tools-wrap { width: min(100% - 40px, 1120px); margin-inline: auto; padding-block: 46px 76px; }
.tool-intro { display: grid; gap: 12px; margin-bottom: 30px; }
.tool-intro h1 { font-size: clamp(2rem, 6vw, 3.5rem); }
.tool-intro p { max-width: 62ch; font-size: 1.12rem; }
.tool-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.tool-card {
  display: flex;
  flex-direction: column;
  color: var(--bone);
  background: var(--char);
  border: 1px solid var(--soot);
  border-radius: 16px;
  overflow: hidden;
  text-decoration: none;
}
.tool-card:hover { border-color: var(--ember); }
.tool-art { height: clamp(160px, 26vw, 262px); overflow: hidden; background: var(--char); }
.tool-art img { display: block; width: 100%; height: 100%; object-fit: cover; }
.tool-art-viewer img { object-fit: contain; }
.tool-art-converter img { object-position: 50% 42%; }
.tool-card-copy { display: grid; flex: 1; gap: 10px; padding: 24px; border-top: 1px solid var(--soot); }
.tool-card h2 { font-size: clamp(1.13rem, 3vw, 1.5rem); }
.tool-card-action { align-self: end; margin-top: 8px; color: var(--flame); font-weight: 600; }
.tool-card-action span { margin-left: 4px; }

.tool-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 330px);
  gap: 16px;
  align-items: stretch;
}
.tool-stage, .tool-panel { border: 1px solid var(--soot); border-radius: 16px; background: var(--char); }
.tool-stage {
  position: relative;
  min-height: clamp(350px, 48vw, 515px);
  overflow: hidden;
  background: radial-gradient(ellipse at center, #32231c, var(--char) 70%);
}
.tool-stage model-viewer, .tool-stage-empty, .tool-floor { position: absolute; inset: 0; width: 100%; height: 100%; }
.tool-stage model-viewer { --poster-color: transparent; }
.tool-floor, .tool-gizmo canvas { pointer-events: none; }
.tool-view-actions { position: absolute; top: 12px; left: 12px; display: flex; gap: 6px; }
.tool-view-actions .tool-button { min-height: 34px; padding: 5px 10px; font-size: .84rem; }
.tool-view-actions [aria-pressed="true"] { border-color: #986341; color: var(--flame); }
.tool-gizmo {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 106px;
  height: 106px;
  border: 1px solid var(--soot);
  border-radius: 50%;
  background: rgb(16 13 12 / .84);
  isolation: isolate;
  pointer-events: none;
}
.tool-gizmo canvas { position: absolute; inset: -1px; }
.tool-gizmo button {
  position: absolute;
  width: 26px;
  height: 26px;
  transform: translate(-50%, -50%);
  padding: 0;
  border: 1px solid var(--axis);
  border-radius: 50%;
  color: var(--coal);
  background: var(--axis);
  font: 700 .75rem var(--mono);
  cursor: pointer;
  pointer-events: auto;
}
.tool-gizmo button[data-axis$="x"] { --axis: #eb7772; }
.tool-gizmo button[data-axis$="y"] { --axis: #8bc184; }
.tool-gizmo button[data-axis$="z"] { --axis: #81a4ff; }
.tool-gizmo button[data-axis^="-"] { color: var(--axis); background: var(--coal); font-size: .66rem; }
.tool-gizmo button:hover, .tool-gizmo button:focus-visible { filter: brightness(1.25); z-index: 201 !important; }
.tool-stage-empty { display: grid; align-content: center; justify-items: center; gap: 10px; padding: 24px; }
.tool-stage-empty img { width: auto; height: min(32vw, 345px); max-width: 100%; object-fit: contain; mix-blend-mode: lighten; }
.tool-stage-hint { position: absolute; bottom: 12px; inset-inline: 14px; text-align: center; font-size: .86rem; pointer-events: none; }
.tool-panel { display: flex; flex-direction: column; gap: 16px; padding: 18px; min-width: 0; }
.tool-drop {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 18px 12px;
  border: 1px dashed #77503b;
  border-radius: 12px;
  color: var(--ash);
  text-align: center;
  cursor: pointer;
}
.tool-drop:hover, .tool-workspace.is-dragging .tool-drop { border-color: var(--flame); background: #2a1d16; }
.tool-drop:focus-within { outline: 2px solid var(--flame); outline-offset: 3px; }
.tool-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.tool-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 42px;
  padding: 8px 14px;
  border: 1px solid var(--soot);
  border-radius: 8px;
  color: var(--bone);
  background: var(--coal);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.tool-button:hover { border-color: var(--flame); }
.tool-primary { color: #1a0d06; background: var(--flame); border-color: var(--flame); }
.tool-primary:hover { background: var(--bone); }
.tool-button:disabled { opacity: .55; cursor: default; }
.tool-status { font-size: .93rem; overflow-wrap: anywhere; }
.tool-status:empty { display: none; }
.tool-status[data-error] { color: var(--flame); }
.tool-display { margin: 0; padding: 0; border: 0; min-inline-size: 0; }
.tool-display legend { margin-bottom: 7px; color: var(--ash); font-size: .85rem; }
.tool-display-buttons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
.tool-display button {
  min-height: 34px;
  padding: 5px 9px;
  border: 1px solid var(--soot);
  border-radius: 7px;
  color: var(--bone);
  background: var(--coal);
  font-family: inherit;
  font-size: .84rem;
  font-weight: 600;
  cursor: pointer;
}
.tool-display button[aria-pressed="true"] { border-color: #986341; color: var(--flame); }
.tool-display button:hover:enabled { border-color: var(--flame); }
.tool-display:disabled { opacity: .58; }
.tool-display button:disabled { cursor: default; }
.tool-data { display: grid; gap: 10px; margin: 0; overflow-wrap: anywhere; }
.tool-data dt, .tool-controls label { color: var(--ash); font-size: .85rem; }
.tool-data dd { margin: 1px 0 0; }
.tool-controls { display: grid; gap: 8px; border-top: 1px solid var(--soot); padding-top: 16px; }
.tool-controls select {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--soot);
  border-radius: 8px;
  color: var(--bone);
  background: var(--coal);
  font: inherit;
}
.tool-timeline { display: flex; align-items: center; gap: 10px; }
.tool-timeline input { flex: 1; min-width: 0; accent-color: var(--flame); }
.tool-timeline output { flex: none; font: .78rem var(--mono); font-variant-numeric: tabular-nums; }
.tool-footnote { margin-top: 16px; }
.tool-panel-heading { font-size: 1.15rem; }
.tool-converter-empty img { opacity: .5; border-radius: 8px; }
.tool-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.tool-input-help { margin-top: -7px; font-size: .9rem; }
.tool-actions .tool-file-button { min-height: 38px; padding: 6px 10px; font-size: .88rem; }
.tool-sample-link { align-self: start; }
.tool-file-button { position: relative; }
.tool-file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.tool-file-button:focus-within { outline: 2px solid var(--flame); outline-offset: 4px; }
.tool-selection { padding: 10px 12px; border-radius: 8px; background: var(--coal); font-size: .88rem; }
.tool-selection ul { margin: 6px 0 0; padding-left: 16px; color: var(--ash); max-height: 105px; overflow: auto; overflow-wrap: anywhere; }
.tool-link { padding: 6px 0 6px 8px; border: 0; color: var(--flame); background: transparent; font: inherit; cursor: pointer; }
.tool-link:hover { text-decoration: underline; }
.model-stats { margin-top: 16px; }
.model-stats-grid { grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); gap: 12px 16px; }
.model-stats-grid div { padding-block: 7px; border-top: 1px solid var(--soot); }
.model-stats-grid dd { font: 500 1.08rem/1.5 var(--mono); }
.model-stats p { font-size: .88rem; }
.tool-guide { display: grid; gap: 28px; margin-top: 38px; }
.tool-guide section { display: grid; gap: 12px; border-top: 1px solid var(--soot); padding-top: 26px; scroll-margin-top: 68px; }
.tool-guide h2 { font-size: clamp(1.06rem, 3.4vw, 1.4rem); text-wrap: balance; }
.tool-guide p, .tool-guide ol { max-width: 75ch; }
.tool-guide ol { display: grid; gap: 8px; margin: 0; padding-left: 22px; color: var(--ash); }
.tool-guide a { text-underline-offset: 3px; }
.tool-guide code { font: .9em var(--mono); color: var(--bone); }
.tool-guide-list { display: grid; gap: 10px; max-width: 75ch; margin: 0; }
.tool-guide-list dt { font-weight: 600; }
.tool-guide-list dd { margin-inline-start: 0; color: var(--ash); }
.tool-guide-table { width: 100%; max-width: 75ch; border-collapse: collapse; text-align: left; }
.tool-guide-table th, .tool-guide-table td { padding: 9px 12px 9px 0; vertical-align: top; border-bottom: 1px solid var(--soot); }
.tool-guide-table th:first-child { width: 8.3rem; }
.tool-guide-table td { color: var(--ash); }

@media (max-width: 740px) {
  .tool-workspace { grid-template-columns: 1fr; }
  .tool-stage { min-height: 320px; }
  .tool-stage-empty img { height: 215px; }
}

@media (max-width: 640px) {
  .tools-wrap { width: calc(100% - 32px); padding-block: 36px 54px; }
  .tool-grid { grid-template-columns: 1fr; gap: 14px; }
  .tool-art { height: 180px; }
  .tool-card-copy { padding: 20px; }
  .tool-guide-table th:first-child { width: 6rem; }
}
