:root {
  --bg: #f4f4f0;
  --ink: #111418;
  --muted: #6b7079;
  --line: #dcded9;
  --panel: #ffffff;
  --glass: rgba(246, 246, 242, 0.86);
  --accent: #e39b2d;
  --ok: #1f8f4e;
  --bad: #cf3535;
  --stage: #e7e9e6;
  --radius: 14px;
  --gutter: 20px;
  --shadow: 0 8px 28px rgba(17, 20, 24, 0.08);
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Space Grotesk', var(--sans);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: var(--stage);
  color: var(--ink);
  font: 15px/1.45 var(--sans);
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

/* full-window 3D stage; everything else floats above it */
.stage {
  position: fixed;
  inset: 0;
  background: var(--stage);
}
.stage canvas { display: block; width: 100%; height: 100%; outline: none; touch-action: none; }
.noscript { padding: 120px var(--gutter); color: var(--muted); }

.top, .panel, .tools, .hint, .foot { position: fixed; z-index: 2; }

/* header */
.top {
  top: 16px;
  left: var(--gutter);
  right: var(--gutter);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  pointer-events: none;
}
.top a { pointer-events: auto; }
.logo {
  font: 700 30px/1 var(--display);
  letter-spacing: -0.03em;
  color: var(--ink);
  text-decoration: none;
}
.logo span {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--muted);
  margin-left: 1px;
}
.lang {
  font: 600 12px/1 var(--sans);
  letter-spacing: 0.08em;
  color: var(--muted);
  text-decoration: none;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 11px;
}
.lang:hover { color: var(--ink); border-color: var(--ink); }

/* question + verdict card */
.panel {
  top: 60px;
  left: var(--gutter);
  max-width: min(760px, calc(100vw - 2 * var(--gutter)));
  padding: 14px 18px 12px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.ask {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  font: 500 clamp(19px, 2vw, 26px)/1.2 var(--display);
  letter-spacing: -0.02em;
}
.word { color: var(--muted); }
.word.q { margin-left: -10px; }
.pick {
  font: inherit;
  letter-spacing: inherit;
  width: 8em;
  min-width: 6em;
  border: 0;
  border-bottom: 2px solid var(--line);
  background: transparent;
  padding: 0 2px 4px;
  outline: none;
  transition: border-color .15s;
}
.pick::placeholder { color: #b0b3ad; }
.pick:focus { border-bottom-color: var(--ink); }
#cargo:not(:placeholder-shown) { border-bottom-color: var(--accent); }
#host:not(:placeholder-shown) { border-bottom-color: #8d98a3; }
.swap {
  align-self: center;
  flex: none;
  margin-left: 4px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 999px;
  width: 34px;
  height: 34px;
  font-size: 16px;
  color: var(--muted);
}
.swap:hover { color: var(--ink); border-color: var(--ink); }

.verdict {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 10px;
  margin-top: 10px;
}
.verdict strong {
  font: 600 16px/1.3 var(--sans);
  padding-left: 14px;
  position: relative;
}
.verdict strong::before {
  content: '';
  position: absolute;
  left: 0;
  top: .42em;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line);
}
.verdict span { color: var(--muted); font-size: 14px; }
.verdict[data-state="fits"] strong { color: var(--ok); }
.verdict[data-state="fits"] strong::before { background: var(--ok); }
.verdict[data-state="too_big"] strong,
.verdict[data-state="touching"] strong,
.verdict[data-state="error"] strong { color: var(--bad); }
.verdict[data-state="too_big"] strong::before,
.verdict[data-state="touching"] strong::before,
.verdict[data-state="error"] strong::before { background: var(--bad); }
.verdict[data-state="outside"] strong::before { background: var(--accent); }
.verdict[data-state="loading"] strong::before { background: var(--accent); animation: pulse 1s infinite alternate; }
@keyframes pulse { to { opacity: .2; } }

.live { margin: 4px 0 0 14px; font-size: 12.5px; color: var(--muted); }
.live:empty { display: none; }

.add {
  align-self: center;
  flex: none;
  margin-left: -6px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 999px;
  width: 28px;
  height: 28px;
  font: 500 18px/1 var(--sans);
  color: var(--accent);
}
.add:hover { border-color: var(--accent); }

.items { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 999px;
  font-size: 12.5px;
  overflow: hidden;
}
.chip button { border: 0; background: transparent; padding: 4px 4px 4px 10px; }
.chip .x { padding: 4px 9px 4px 4px; color: var(--muted); }
.chip .x:hover { color: var(--bad); }
.chip::before { content: ''; width: 7px; height: 7px; border-radius: 50%; margin-left: 9px; background: var(--accent); }
.chip.in::before { background: var(--ok); }
.chip.hit::before { background: var(--bad); }
.chip.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }

.dims {
  font: 500 12px/1.6 var(--sans);
  color: var(--muted);
}
.dims:not(:empty) { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.dims b { color: var(--ink); font-weight: 600; }
.dims i { font-style: normal; display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }

/* tool bar */
.tools {
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-size: 13px;
  white-space: nowrap;
  max-width: calc(100vw - 24px);
  overflow-x: auto;
}
.tools button,
.tools .switch,
.tools .cut {
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 7px 12px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.tools button:hover,
.tools .switch:hover { background: var(--bg); }
.seg { display: inline-flex; background: var(--bg); border-radius: 999px; padding: 2px; }
.seg button { padding: 5px 12px; }
.seg button.on { background: var(--ink); color: #fff; }
.switch { cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch i {
  width: 26px;
  height: 15px;
  border-radius: 999px;
  background: var(--line);
  position: relative;
  transition: background .15s;
}
.switch i::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #fff;
  transition: transform .15s;
}
.switch input:checked + i { background: var(--ink); }
.switch input:checked + i::after { transform: translateX(11px); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.cut input { width: 90px; accent-color: var(--ink); }

.hint {
  right: var(--gutter);
  top: 62px;
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  pointer-events: none;
}
.toast {
  position: absolute;
  left: 50%;
  bottom: 80px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s;
}
.toast.show { opacity: 1; }

/* referral + legal, bottom corners */
.foot {
  left: var(--gutter);
  bottom: 18px;
  max-width: calc(50vw - 260px);
  pointer-events: none;
}
.ref {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  font-size: 12px;
  color: var(--muted);
}
.ref > * { pointer-events: auto; }
.ref strong { color: var(--ink); font-weight: 600; }
.code {
  font: 600 12px/1 ui-monospace, 'SFMono-Regular', Consolas, monospace;
  letter-spacing: .04em;
  background: var(--panel);
  border: 1px dashed #b9bcb6;
  border-radius: 6px;
  padding: 6px 9px;
}
.code em { font: 500 11px/1 var(--sans); font-style: normal; color: var(--muted); margin-left: 6px; letter-spacing: 0; }
.code:hover { border-color: var(--ink); }
.cta { color: var(--ink); font-weight: 600; text-decoration: none; border-bottom: 2px solid var(--accent); }
.legal { margin: 8px 0 0; font-size: 10.5px; line-height: 1.4; color: #9a9e98; }

@media (max-width: 1100px) {
  .foot { max-width: none; right: var(--gutter); bottom: 70px; }
  .ref-text, .legal { display: none; }
  .hint { display: none; }
}

@media (max-width: 720px) {
  :root { --gutter: 12px; }
  .top { top: 12px; }
  .logo { font-size: 26px; }
  .panel { top: 48px; right: var(--gutter); padding: 10px 12px; }
  .pick { width: 100%; }
  .word.q { display: none; }
  .verdict span { display: none; }
  .tools { bottom: 10px; }
  .foot { bottom: 62px; }
  .toast { bottom: 110px; }
}
