:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #16202b;
  --muted: #5c6b7a;
  --primary: #1b3a5c;
  --accent: #00a6b8;
  --line: #d9e0e6;
  --soft: #e8eef1;
  --radius: 8px;
  --max: 1380px;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI Variable", "Segoe UI", Tahoma, sans-serif;
  line-height: 1.55;
}
button, a { font: inherit; }
button { cursor: pointer; }
.wrap { width: min(calc(100% - 40px), var(--max)); margin-inline: auto; }

.topbar {
  height: 76px;
  display: flex;
  align-items: center;
  background: rgba(255,255,255,.94);
  border-bottom: 1px solid rgba(217,224,230,.86);
  backdrop-filter: blur(14px);
}
.topbar__inner { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: inline-flex; min-height: 44px; align-items: center; }
.brand img { display: block; width: auto; height: 34px; object-fit: contain; }
.prototype-badge {
  padding: 6px 9px;
  border: 1px solid rgba(0,166,184,.34);
  border-radius: 4px;
  background: rgba(0,166,184,.06);
  color: #007f8c;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr);
  gap: 60px;
  align-items: end;
  padding: 64px 0 38px;
}
.kicker {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 13px;
  color: #008f9f;
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.kicker::before { content: ""; width: 34px; height: 1px; background: currentColor; }
h1 { margin: 0; font-size: clamp(2.7rem, 5vw, 5.1rem); font-weight: 300; line-height: .98; letter-spacing: -.052em; }
.intro__copy { max-width: 580px; margin: 0 0 5px; color: var(--muted); font-size: 1rem; }

.calculator { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: stretch; }
.stage-card, .estimate-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.stage-card { min-width: 0; overflow: hidden; box-shadow: 0 18px 45px rgba(27,58,92,.075); }
.stage {
  position: relative;
  min-height: clamp(510px, 63vh, 760px);
  overflow: hidden;
  background: linear-gradient(180deg, #edf2f4 0%, #dfe7ea 72%, #d5dfe2 100%);
  cursor: grab;
  isolation: isolate;
}
.stage:active { cursor: grabbing; }
.stage canvas { position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; display: block; outline: 0; }
.stage__wash {
  position: absolute;
  z-index: 1;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 52% 32%, rgba(255,255,255,.95), transparent 39%),
    linear-gradient(115deg, transparent 0 70%, rgba(255,255,255,.34) 70.1% 70.3%, transparent 70.4%);
}
.stage__wash::after {
  content: "";
  position: absolute;
  width: 62%;
  aspect-ratio: 1;
  right: -27%;
  top: -34%;
  border: 1px solid rgba(0,166,184,.12);
  border-radius: 50%;
  box-shadow: 0 0 0 76px rgba(0,166,184,.022), 0 0 0 152px rgba(0,166,184,.018);
}
.loading {
  position: absolute;
  z-index: 5;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 14px;
  color: var(--muted);
  font-size: .82rem;
  letter-spacing: .04em;
  text-align: center;
  background: #e9eef1;
  transition: opacity .28s ease, visibility .28s ease;
}
.loading.is-done { opacity: 0; visibility: hidden; }
.loading strong { color: var(--primary); font-size: .9rem; font-weight: 600; }
.loading__retry { min-height: 42px; padding: 0 18px; border: 1px solid var(--primary); border-radius: 6px; background: white; color: var(--primary); font: inherit; font-weight: 600; cursor: pointer; }
.loading__retry:hover { background: var(--primary); color: white; }
.loading__line { width: 180px; height: 2px; overflow: hidden; background: rgba(27,58,92,.12); }
.loading__line::after { content: ""; display: block; width: 45%; height: 100%; background: var(--accent); animation: load 1.2s ease-in-out infinite alternate; }
@keyframes load { from { transform: translateX(-10%); } to { transform: translateX(135%); } }
.stage__hint {
  position: absolute;
  z-index: 4;
  left: 20px;
  bottom: 18px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: #445463;
  font-size: .76rem;
  pointer-events: none;
}
.mouse-icon { width: 17px; height: 24px; border: 1px solid #657684; border-radius: 9px; position: relative; }
.mouse-icon::after { content: ""; position: absolute; width: 2px; height: 5px; left: 7px; top: 4px; border-radius: 2px; background: var(--accent); }
.icon-button {
  position: absolute;
  z-index: 4;
  top: 18px;
  right: 18px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid rgba(27,58,92,.24);
  border-radius: 6px;
  background: rgba(255,255,255,.82);
  color: var(--primary);
  font-size: .78rem;
  backdrop-filter: blur(10px);
}
.icon-button:hover { border-color: var(--accent); background: white; }
.stage-meta { min-height: 52px; padding: 0 20px; display: flex; align-items: center; gap: 24px; color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; }
.stage-meta span { display: inline-flex; align-items: center; gap: 8px; }
.stage-meta span::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }

.estimate-card { padding: 30px; display: flex; flex-direction: column; min-height: 100%; box-shadow: inset 3px 0 0 var(--accent); }
.step-label { color: #008290; font-size: .7rem; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; }
.estimate-card h2 { margin: 11px 0 7px; font-size: 1.75rem; font-weight: 400; letter-spacing: -.035em; }
.muted, .fine-print { color: var(--muted); }
.muted { margin: 0; font-size: .88rem; }
.selection-empty { flex: 1; min-height: 190px; display: grid; place-content: center; text-align: center; color: #87939e; font-size: .78rem; }
.selection-empty[hidden] { display: none; }
.selection-empty__number { color: #c8d0d6; font-size: 4.4rem; font-weight: 200; line-height: 1; }
.selection-list { flex: 1; list-style: none; margin: 28px 0 12px; padding: 0; }
.selection-list:empty { display: none; }
.selection-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 15px 0; border-top: 1px solid var(--line); }
.part-info { min-width: 0; display: grid; gap: 3px; }
.part-name { color: var(--ink); font-size: .86rem; line-height: 1.35; }
.part-cost { color: var(--primary); font-size: .82rem; font-weight: 650; }
.remove-part { min-width: 88px; min-height: 44px; padding: 0 10px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: #65727d; font-size: .72rem; }
.remove-part svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.45; stroke-linecap: round; stroke-linejoin: round; }
.remove-part:hover { border-color: #d4a29e; background: #fff8f7; color: #a6342b; }
.estimate-total { display: flex; justify-content: space-between; align-items: baseline; gap: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.estimate-total span { color: var(--muted); font-size: .76rem; }
.estimate-total strong { color: var(--primary); font-size: 1.45rem; font-weight: 500; white-space: nowrap; }
.fine-print { margin: 16px 0 20px; font-size: .74rem; line-height: 1.5; }
.secondary { min-height: 48px; border: 1px solid var(--primary); border-radius: 6px; background: white; color: var(--primary); font-size: .82rem; font-weight: 600; }
.secondary:hover:not(:disabled) { background: var(--primary); color: white; }
.secondary:disabled { opacity: .4; cursor: default; }
.model-credit { display: flex; justify-content: space-between; gap: 24px; padding: 18px 2px 54px; color: #778590; font-size: .7rem; }
.model-credit a { color: var(--primary); text-underline-offset: 3px; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

@media (max-width: 1050px) {
  .calculator { grid-template-columns: 1fr; }
  .estimate-card { min-height: auto; }
  .selection-empty { min-height: 100px; }
}
@media (max-width: 760px) {
  .wrap { width: min(calc(100% - 24px), var(--max)); }
  .intro { grid-template-columns: 1fr; gap: 18px; padding: 44px 0 28px; }
  h1 { font-size: clamp(2.7rem, 13vw, 4rem); }
  .stage { min-height: 440px; }
  .stage-meta { gap: 13px; overflow-x: auto; white-space: nowrap; }
  .stage-meta span:last-child { display: none; }
  .estimate-card { padding: 24px; }
  .model-credit { flex-direction: column; gap: 4px; }
}
@media (max-width: 480px) {
  .prototype-badge { max-width: 145px; text-align: center; }
  .brand img { height: 28px; }
  .stage { min-height: 370px; }
  .stage__hint { display: none; }
  .icon-button { top: 12px; right: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
