:root {
  --bg: #040407;
  --bg-2: #0d0c12;
  --panel: rgba(12, 11, 16, 0.84);
  --line: rgba(227, 176, 98, 0.18);
  --text: #ece6da;
  --muted: #9b958a;
  --gold: #e3b062;
  --gold-dim: #8c6a35;
  --red-dwarf: #ff5a2a;
  --radius: 6px;
  --dock-h: 0px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: radial-gradient(120% 90% at 30% 25%, var(--bg-2) 0%, var(--bg) 70%);
  color: var(--text);
  font-size: 14px;
  -webkit-tap-highlight-color: transparent;
}

#stage { position: fixed; inset: 0; }
#stage canvas { display: block; }

.mark { width: 22px; height: 22px; color: var(--gold); vertical-align: -5px; margin-right: 8px; overflow: visible; }
.mark circle { filter: drop-shadow(0 0 3px var(--red-dwarf)); }
.mark.big { width: 64px; height: 64px; margin: 0 0 14px; animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.55; transform: scale(0.94); } }

.brand { position: fixed; top: 18px; left: 22px; z-index: 5; }
.brand-name { font-weight: 700; letter-spacing: 0.32em; font-size: 13px; color: var(--gold); white-space: nowrap; }
.brand-name span { color: var(--text); font-weight: 400; }
.models { display: flex; gap: 6px; margin-top: 12px; }
.models button { min-width: 92px; }
.models button[aria-pressed="true"] { background: var(--gold); color: #111; border-color: var(--gold); }

button {
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 12px;
  cursor: pointer;
  touch-action: manipulation;
  white-space: nowrap;
}
button:hover { border-color: var(--gold-dim); }
button[aria-pressed="true"] { border-color: var(--gold); color: var(--gold); }

/* side panel (desktop) */
.panel {
  position: fixed; top: 16px; right: 16px; bottom: 16px; width: 340px; z-index: 5;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  overflow-y: auto; padding: 18px 18px 8px;
}
.peek { display: none; }
.panel h2 { font-size: 17px; margin: 0 0 8px; color: var(--gold); font-weight: 600; }
.panel h3 { font-size: 12px; margin: 18px 0 8px; color: var(--muted); font-weight: 600; letter-spacing: 0.08em; }
.panel p { margin: 0; line-height: 1.55; }

.spec h1 { font-size: 22px; margin: 0; font-weight: 600; }
.spec .tier { color: var(--muted); margin: 2px 0 12px; }
.spec dl { display: grid; grid-template-columns: auto 1fr; gap: 5px 14px; margin: 0 0 16px; }
.spec dt { color: var(--muted); }
.spec dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.spec .price { color: var(--gold); font-weight: 600; }
.part { border-top: 1px solid var(--line); padding-top: 14px; min-height: 110px; }
.origin { border-top: 1px solid var(--line); margin-top: 14px; }
.origin p { color: var(--muted); font-size: 13px; }

.list .group { margin-bottom: 10px; }
.list .group-name { font-size: 12px; color: var(--gold-dim); margin-bottom: 4px; }
.list button {
  display: block; width: 100%; text-align: left; border: 0; background: none; padding: 5px 6px;
  color: var(--text); border-radius: 4px; white-space: normal;
}
.list button:hover { background: rgba(227, 176, 98, 0.08); }
.list button[aria-pressed="true"] { background: rgba(227, 176, 98, 0.16); color: var(--gold); }

/* control dock */
.controls {
  position: fixed; left: 16px; right: 372px; bottom: 16px; z-index: 5;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding: 12px 16px; display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center;
}
.explode { display: flex; align-items: center; gap: 10px; flex: 1 1 260px; }
.explode span { color: var(--gold); font-weight: 600; }
.explode input { flex: 1; accent-color: var(--gold); height: 28px; }
.explode output { width: 40px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.layers { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
.layers button { font-size: 12px; padding: 4px 9px; }
.layers button[aria-pressed="false"] { opacity: 0.45; }

/* floating bits */
.tip {
  position: fixed; z-index: 6; pointer-events: none; padding: 4px 8px; border-radius: 4px;
  background: rgba(0, 0, 0, 0.8); border: 1px solid var(--line); color: var(--gold); font-size: 12px;
  display: none; white-space: nowrap;
}
.layer-label {
  font-size: 11px; letter-spacing: 0.12em; color: var(--gold); background: rgba(0, 0, 0, 0.55);
  padding: 2px 7px; border-radius: 3px; border: 1px solid var(--line); pointer-events: none; white-space: nowrap;
}
.star-label {
  pointer-events: auto; cursor: pointer; font-size: 11px; letter-spacing: 0.14em; color: #ffb08a;
  background: none; border: 0; padding: 4px 0 0 28px; text-transform: uppercase; opacity: 0.85; transition: opacity 0.3s;
}
.star-label small { display: block; letter-spacing: 0.06em; color: var(--muted); text-transform: none; }
.loading {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 8; color: var(--muted); background: var(--bg); transition: opacity 0.6s; letter-spacing: 0.08em;
}
.loading.hidden { opacity: 0; pointer-events: none; }


/* part callout: a dot on the part, an elbowed leader, a card cut like the shroud's chamfered corners */
.callout { position: fixed; inset: 0; z-index: 4; pointer-events: none; }
.callout[hidden] { display: none; }
.leader { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
#leader-line { fill: none; stroke: var(--gold); stroke-width: 1.5; stroke-dasharray: 1; stroke-dashoffset: 0; }
#leader-dot { fill: var(--bg); stroke: var(--gold); stroke-width: 2; }
.callout.drawing #leader-line { animation: draw 0.32s ease-out both; }
@keyframes draw { from { stroke-dashoffset: 1; } }
.callout-card {
  --c: 16px;
  position: absolute; top: 100px; left: 16px; width: 300px; pointer-events: auto;
  background: var(--gold); padding: 1px;
  clip-path: polygon(var(--c) 0, calc(100% - var(--c)) 0, 100% var(--c), 100% calc(100% - var(--c)),
    calc(100% - var(--c)) 100%, 0 100%, 0 var(--c));
}
.callout.drawing .callout-card { animation: cardin 0.2s 0.18s ease-out both; }
@keyframes cardin { from { opacity: 0; } }
.callout-inner {
  --c: 15.6px;
  background: rgba(9, 8, 13, 0.95); padding: 14px 42px 15px 18px; max-height: 52vh; overflow-y: auto;
  clip-path: polygon(var(--c) 0, calc(100% - var(--c)) 0, 100% var(--c), 100% calc(100% - var(--c)),
    calc(100% - var(--c)) 100%, 0 100%, 0 var(--c));
}
.callout-layer { font-size: 12px; color: var(--muted); margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.callout-layer b { color: var(--red-dwarf); font-weight: 600; }
.callout-inner h2 { margin: 0 0 8px; font-size: 18px; font-weight: 600; color: var(--gold); }
.callout-inner p { margin: 0; line-height: 1.55; font-size: 14px;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.callout-more { display: block; margin-top: 6px; font-size: 12px; color: var(--muted); }
.callout-close {
  position: absolute; top: 8px; right: 12px; border: 0; background: none; color: var(--muted);
  font-size: 22px; line-height: 1; padding: 4px 6px;
}
.callout-close:hover { color: var(--text); }

/* ---------------------------------------------------------------- phone */
@media (max-width: 760px) {
  :root { --dock-h: 128px; }
  body { font-size: 15px; }
  .brand { top: calc(10px + env(safe-area-inset-top)); left: 12px; right: 12px; }
  .brand-name { font-size: 12px; letter-spacing: 0.26em; text-align: center; }
  .models { margin-top: 10px; gap: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
  .models button { flex: 1; min-width: 0; border: 0; border-radius: 0; padding: 9px 0; background: rgba(12, 11, 16, 0.7); }
  .models button + button { border-left: 1px solid var(--line); }

  .controls {
    left: 0; right: 0; bottom: 0; border-radius: 0; border-width: 1px 0 0;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); gap: 6px; flex-wrap: nowrap; flex-direction: column;
    align-items: stretch; height: auto;
  }
  .explode { flex: none; }
  .scroll-row { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .scroll-row::-webkit-scrollbar { display: none; }
  .buttons button { padding: 8px 11px; }
  .layers button { padding: 5px 9px; }

  .panel {
    top: auto; left: 0; right: 0; width: auto; bottom: var(--dock-h); max-height: calc(100% - var(--dock-h) - 120px);
    border-radius: 14px 14px 0 0; border-width: 1px 1px 0; padding: 0 16px; overflow: hidden;
    display: flex; flex-direction: column; transition: max-height 0.3s ease;
  }
  .peek {
    display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%;
    border: 0; background: none; padding: 13px 2px; font-size: 15px; color: var(--gold); text-align: left;
  }
  .peek #peek-text { overflow: hidden; text-overflow: ellipsis; }
  .chev { width: 10px; height: 10px; border: solid var(--gold); border-width: 2px 2px 0 0; transform: rotate(-45deg);
    transition: transform 0.25s; flex: none; margin-top: 4px; }
  .panel.open .chev { transform: rotate(135deg); margin-top: -4px; }
  .sheet-body { display: none; overflow-y: auto; padding-bottom: 12px; -webkit-overflow-scrolling: touch; }
  .panel.open .sheet-body { display: block; }
  .spec h1 { font-size: 19px; }

  .tip { display: none !important; }
  .callout-card { top: auto; right: 12px; left: 12px; width: auto; bottom: calc(var(--dock-h) + 12px); }
  .callout-inner { max-height: 36vh; padding: 13px 42px 14px 16px; }
  .callout-inner p { display: block; }
  .callout-more { display: none; }
  .callout-inner h2 { font-size: 17px; }
  body.callout-on .panel { display: none; }
  .star-label { padding: 22px 0 0; text-align: center; }
  body.callout-on .star-label { opacity: 0 !important; pointer-events: none !important; }
}
