@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-cyrillic.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

:root {
  --ink: #0a0a0b;
  --glass: rgba(32, 32, 35, 0.56);
  --card: rgba(255, 255, 255, 0.045);
  --line: rgba(255, 255, 255, 0.085);
  --field: rgba(255, 255, 255, 0.07);
  --raise: rgba(255, 255, 255, 0.17);
  --text: #f4f4f5;
  --soft: rgba(244, 244, 245, 0.76);
  --muted: rgba(244, 244, 245, 0.5);
  --accent: #ffffff;
  --accent-ink: #111113;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--ink);
  color: var(--text);
  font: 13px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
/* a still haze behind the glass: warm lamp on one side, aquarium light on the other */
#amb {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(55% 55% at 18% 16%, rgba(88, 240, 208, 0.10), transparent 70%),
    radial-gradient(55% 60% at 84% 80%, rgba(255, 176, 96, 0.11), transparent 70%),
    radial-gradient(45% 40% at 68% 10%, rgba(255, 255, 255, 0.05), transparent 70%);
}
[hidden] { display: none !important; }

.app {
  position: relative;
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 348px;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px 14px;
  padding: 12px max(16px, env(safe-area-inset-right, 0px)) 12px max(16px, env(safe-area-inset-left, 0px));
}

/* top bar */
.top { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; margin-right: auto; }
.brand h1 { font-size: 16px; font-weight: 600; margin: 0; letter-spacing: -0.01em; white-space: nowrap; }
.brand .lede { margin: 0 0 0 6px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mark { width: 34px; height: 34px; flex: none; border-radius: 10px; border: 1px solid var(--line); image-rendering: pixelated; }

button, select, .pill {
  font: inherit;
  color: var(--text);
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 32px;
  padding: 0 12px;
  cursor: pointer;
}
button:hover, select:hover { border-color: var(--raise); }
button:disabled { opacity: 0.45; cursor: default; }
button:disabled:hover { border-color: var(--line); }
select { appearance: none; -webkit-appearance: none; padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%23a0a0a8' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; background-size: 12px; }
select option { background: #1c1c1f; color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 12px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.pill svg { width: 17px; height: 17px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
button.ghost { background: none; border-color: transparent; color: var(--soft); }
button.ghost:hover { background: var(--field); color: var(--text); border-color: transparent; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.primary:hover { background: #e9e9ec; border-color: #e9e9ec; }
a.star { color: var(--soft); padding: 0 12px; }
a.star:hover { color: var(--text); border-color: var(--raise); }
a.star svg { fill: currentColor; stroke: none; width: 15px; height: 15px; }
a.star b {
  font-size: 11.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  padding-left: 9px;
  margin-left: 2px;
  border-left: 1px solid var(--line);
}

/* stage */
.view { min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
#stage {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.34);
  overflow: hidden;
}
#view { image-rendering: pixelated; display: block; cursor: grab; touch-action: none; }
#view:active { cursor: grabbing; }
#view.placing, #view.placing:active { cursor: crosshair; }
#stage.drag::after {
  content: "Drop to open";
  position: absolute;
  inset: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--raise);
  border-radius: 14px;
  background: rgba(10, 10, 11, 0.8);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  pointer-events: none;
}
#marks { position: absolute; inset: 0; pointer-events: none; }
.mark-ring {
  position: absolute;
  width: 14px;
  height: 14px;
  min-height: 0;
  margin: -7px 0 0 -7px;
  padding: 0;
  border: 2px solid var(--c, #fff);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  pointer-events: auto;
  cursor: move;
  touch-action: none;
}
.mark-ring.on { box-shadow: 0 0 0 2px var(--text); }

#empty { max-width: 440px; padding: 24px; text-align: center; }
#empty h2 { margin: 0 0 10px; font-size: 26px; font-weight: 600; letter-spacing: -0.02em; }
#empty p { margin: 0 0 20px; color: var(--soft); font-size: 14px; }
#empty .start { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
#empty .start button { min-height: 38px; padding: 0 18px; border-radius: 12px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
#empty .tiles { display: flex; justify-content: center; flex-wrap: wrap; margin-bottom: 14px; }
#empty .tiles { flex-wrap: nowrap; gap: 6px; }
#empty .tiles .tile { flex: 1 1 0; min-width: 0; max-width: 120px; }
#empty .tiles:empty, #empty .tiles:empty + .or { display: none; }
#empty p.or { margin-bottom: 14px; font-size: 13px; color: var(--muted); }
.tile { display: flex; flex-direction: column; gap: 6px; min-height: 0; padding: 5px 5px 7px; border-radius: 12px; font-size: 12px; color: var(--soft); }
.tile:hover { color: var(--text); }
.tile img { width: 100%; height: auto; aspect-ratio: 1; border-radius: 8px; image-rendering: pixelated; display: block; background: #000; }
#empty .hint { margin: 18px 0 0; font-size: 12px; line-height: 1.7; color: var(--muted); }
#empty a { color: var(--soft); text-underline-offset: 3px; }
#toast {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 14px;
  border-radius: 12px;
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  max-width: calc(100% - 28px);
  text-align: center;
}

/* the line under the scene carries the model's credit: when there is no room beside the
   transport it moves to a row of its own instead of being cut */
.deck { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; min-height: 40px; }
.deck .meta { flex: 1 1 240px; min-width: 0; margin: 0; padding-left: 6px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.transport {
  flex: 1 1 260px;
  max-width: 420px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 3px 14px 3px 3px;
  border-radius: 14px;
  background: var(--glass);
  border: 1px solid var(--line);
}
.transport button { width: 68px; flex: none; background: none; border-color: transparent; color: var(--soft); }
.transport button:hover { background: var(--field); color: var(--text); border-color: transparent; }
.transport input { flex: 1; }

/* inspector */
#panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  border-radius: 22px;
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
}
.seg { display: flex; gap: 2px; padding: 3px; background: rgba(0, 0, 0, 0.25); border: 1px solid var(--line); border-radius: 13px; flex: none; }
.seg button { flex: 1; border: 0; border-radius: 9px; background: none; min-height: 30px; padding: 0 4px; color: var(--muted); }
.seg button:hover { color: var(--text); }
.seg button[aria-selected="true"] { color: var(--text); background: var(--raise); }
#controls { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--raise) transparent; }
.pane { display: flex; flex-direction: column; gap: 10px; }
.card { padding: 14px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); }
.card h2 { margin: 0 0 12px; font-size: 13px; font-weight: 600; }
.muted { color: var(--muted); }

.group { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; flex-direction: column; gap: 5px; }
.row label { color: var(--soft); }
.row .top { display: flex; justify-content: space-between; gap: 8px; }
.row .val { color: var(--muted); font-variant-numeric: tabular-nums; }
.row.inline { flex-direction: row; align-items: center; justify-content: space-between; }
.row select { width: 156px; }
.item { display: flex; flex-direction: column; gap: 12px; }
.itemhead { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; }
.itemhead[aria-expanded="true"] { background: var(--raise); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.buttons { display: flex; gap: 8px; }
.buttons button { flex: 1; padding: 0; }
#status { min-height: 18px; font-size: 12px; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 16px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track { height: 2px; background: var(--raise); border-radius: 1px; }
input[type="range"]::-moz-range-track { height: 2px; background: var(--raise); border-radius: 1px; }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--text);
  border: none;
}
input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--text); border: none; }
input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 34px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: none;
  cursor: pointer;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 5px; }
input[type="color"]::-moz-color-swatch { border: none; border-radius: 5px; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--text); cursor: pointer; }

@media (max-width: 820px) {
  body { overflow: auto; }
  .app { height: auto; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto; }
  .brand .lede, .pill.ghost span, a.star span { display: none; }
  .brand h1 { overflow: hidden; text-overflow: ellipsis; }
  .deck .meta { flex-basis: 100%; white-space: normal; }
  .transport { max-width: none; }
  #stage { flex: none; height: 58vh; }
  #controls { overflow: visible; }
}
