:root {
  color-scheme: dark;
  --panel: rgba(18, 20, 26, 0.92);
  --line: rgba(255, 255, 255, 0.12);
  --text: #e8e9ee;
  --muted: #9aa0ae;
  --accent: #7db8ff;
}
* { box-sizing: border-box; }
/* An id rule like #drop-hint{display:grid} outranks the browser's [hidden]{display:none},
   which silently leaves "hidden" elements on screen. Make hidden win everywhere. */
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font: 13px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  background: #16181d;
  color: var(--text);
  overflow: hidden;
}
/* touch-action: none is what makes touch work at all. Without it the browser treats a drag
   as a page scroll, swallows the gesture and fires pointercancel, so the camera freezes
   after a few pixels. */
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: grab;
        touch-action: none; }
#view:active { cursor: grabbing; }

#panel {
  position: fixed; top: 16px; left: 16px; width: 344px; max-height: calc(100vh - 32px);
  overflow-y: auto; overflow-x: hidden; scrollbar-width: thin;
  padding: 16px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
h1 { margin: 0; font-size: 14px; letter-spacing: .02em; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
#panel-hide {
  padding: 0; width: 24px; height: 24px; line-height: 1; font-size: 16px;
  color: var(--muted); background: none; border-color: transparent;
}
#panel-hide:hover { color: var(--text); border-color: var(--line); }
#panel-show {
  position: fixed; top: 16px; left: 16px; z-index: 2;
  width: 34px; height: 34px; padding: 0; font-size: 15px;
  background: var(--panel); backdrop-filter: blur(12px);
}
#fps {
  position: fixed; top: 16px; right: 16px; z-index: 2; padding: 4px 9px; border-radius: 8px;
  background: var(--panel); color: var(--text); font: 12px/1.4 ui-monospace, monospace;
  font-variant-numeric: tabular-nums; pointer-events: none;
}

.file input { display: none; }
.file span {
  display: block; padding: 9px 12px; text-align: center; cursor: pointer;
  border: 1px dashed var(--line); border-radius: 8px; color: var(--muted);
}
.file span:hover { border-color: var(--accent); color: var(--text); }
.toggle { display: flex; gap: 8px; align-items: center; margin-top: 8px; color: var(--muted); cursor: pointer; }
.toggle:hover { color: var(--text); }
.toggle input { accent-color: var(--accent); margin: 0; }
.toggle a { color: var(--accent); }
.toggle:has(input:disabled) { opacity: .5; cursor: default; }
.toggle small { color: var(--muted); opacity: .75; font-size: 11.5px; margin-left: 4px; }

/* A titled block of the panel, separated by a rule. */
.section { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.section-head {
  display: flex; justify-content: space-between; margin-bottom: 2px;
  color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
}
.section-head output { color: var(--text); font-weight: 400; letter-spacing: 0; text-transform: none;
                       font-variant-numeric: tabular-nums; }

/* Shader settings: labels in one column, controls lined up in the next, under the toggle. */
.settings {
  display: grid; grid-template-columns: 56px 1fr; gap: 6px 10px; align-items: center;
  margin: 6px 0 2px 24px; color: var(--muted);
}
.settings input[type=range] { width: 100%; margin: 0; accent-color: var(--accent); }
.settings select { justify-self: start; }
.fly-settings { grid-template-columns: 64px 1fr 36px; margin: 10px 0 0; }
.fly-settings output { font-variant-numeric: tabular-nums; text-align: right; }
select {
  padding: 4px 8px; border-radius: 6px; border: 1px solid var(--line);
  background: #11131a; color: var(--text); font: inherit;
}
select:focus { outline: none; border-color: var(--accent); }

#link-form { display: flex; gap: 6px; margin-top: 8px; }
#link {
  flex: 1; min-width: 0; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: #11131a; color: var(--text); font: inherit;
}
#link:focus { outline: none; border-color: var(--accent); }
button {
  padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: #232734; color: var(--text); font: inherit; cursor: pointer;
}
button:hover { border-color: var(--accent); }

#status { margin: 10px 0 0; color: var(--muted); }
#status.error { color: #ff8f8f; }

dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 12px 0 0;
     border-top: 1px solid var(--line); padding-top: 10px; }
dt { color: var(--muted); }
dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

details { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
summary { cursor: pointer; color: var(--muted); }
summary:hover { color: var(--text); }
ol, ul { margin: 8px 0 0; padding-left: 20px; max-height: 240px; overflow-y: auto; }
li { font-variant-numeric: tabular-nums; }
li span { color: var(--muted); }

#drop-hint {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: rgba(10, 12, 16, .78); font-size: 20px; pointer-events: none;
  border: 3px dashed var(--accent);
}

#layers input[type=range] { width: 100%; margin: 6px 0 0; accent-color: var(--accent); }
#layer-reset { width: 100%; margin-top: 8px; padding: 5px; }

.hint { margin: 12px 0 0; border-top: 1px solid var(--line); padding-top: 10px; }
.hint p {
  margin: 0 0 6px; color: var(--muted); font-size: 11.5px; line-height: 1.9;
  white-space: nowrap;                 /* each line of controls must stay on one line */
}
.hint p:last-child { margin-bottom: 0; }
.hint b { display: inline-block; min-width: 40px; color: var(--text); font-weight: 600; }
kbd {
  display: inline-block; margin: 0 1px; padding: 0 4px; border-radius: 4px;
  border: 1px solid var(--line); background: #11131a; color: var(--text);
  font: inherit; font-size: 11px;
}


/* Two buttons side by side, filling the panel. */
.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.button-row button { padding: 6px; }
#filter-bar { display: flex; align-items: center; gap: 8px; margin-top: 8px; padding: 6px 8px; border-radius: 8px;
              background: #11131a; color: var(--text); font-size: 12px; }
#filter-bar span { flex: 1; overflow-wrap: anywhere; }
#filter-bar button { padding: 3px 8px; flex: none; }
#materials li { display: flex; align-items: center; gap: 4px; }
.row-actions { margin-left: auto; display: flex; gap: 2px; opacity: 0; }
#materials li:hover .row-actions, #materials li:focus-within .row-actions { opacity: 1; }
.row-actions button { padding: 0 5px; font-size: 11px; line-height: 18px; color: var(--muted); }
@media (pointer: coarse) { .row-actions { opacity: 1; } }

/* Block inspector card. */
#inspect {
  /* Top, under the FPS box: at the bottom it sat against the taskbar when the window filled the screen. */
  position: fixed; right: 16px; top: 52px; z-index: 2; width: 360px; max-height: calc(100vh - 68px);
  overflow-y: auto; scrollbar-width: thin; padding: 12px 14px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(12px);
}
.inspect-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.inspect-head strong { font-size: 14px; overflow-wrap: anywhere; }
#inspect-close { padding: 0; width: 24px; height: 24px; line-height: 1; font-size: 16px; color: var(--muted);
                 background: none; border-color: transparent; flex: none; }
#inspect-close:hover { color: var(--text); border-color: var(--line); }
.inspect-where { margin: 2px 0 0; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums;
                 overflow-wrap: anywhere; }
.inspect-props { margin-top: 8px; }
.inspect-actions { margin-top: 10px; display: flex; gap: 6px; }
.inspect-label { margin: 10px 0 4px; color: var(--muted); font-size: 11px; font-weight: 600;
                 letter-spacing: .06em; text-transform: uppercase; }
.inspect-sign { margin-top: 8px; padding: 6px 8px; border-radius: 8px; background: #11131a; text-align: center; }
.inspect-sign .inspect-label { display: block; margin: 0 0 2px; text-align: left; }
.slots { display: grid; gap: 2px; }
.slot {
  position: relative; width: 36px; height: 36px; display: grid; place-items: center;
  background: #11131a; border: 1px solid var(--line); border-radius: 4px;
}
.slot canvas { width: 32px; height: 32px; image-rendering: pixelated; }
.slot .count {
  position: absolute; right: 2px; bottom: 0; font-size: 11px; font-weight: 600;
  text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
}
.slot.has-contents { cursor: pointer; border-color: var(--accent); }
.nested { margin-top: 6px; }

/* ------------------------------------------------------------------- walk mode */
#crosshair { position: fixed; left: 50%; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px;
             pointer-events: none; z-index: 2; mix-blend-mode: difference; }
#crosshair::before, #crosshair::after { content: ''; position: absolute; background: #fff; }
#crosshair::before { left: 7px; top: 0; width: 2px; height: 16px; }
#crosshair::after { top: 7px; left: 0; width: 16px; height: 2px; }
#walk-hint {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 2; max-width: calc(100vw - 32px);
  padding: 6px 12px; border-radius: 8px; background: var(--panel); color: var(--muted); font-size: 12px;
  text-align: center; pointer-events: none;
}
#walk-hint span.touch-only, #walk-hint span.pointer-only { display: inline; }
@media (pointer: coarse) { #walk-hint span.pointer-only { display: none; } #walk-hint { bottom: auto; top: 16px; } }
@media not (pointer: coarse) { #walk-hint span.touch-only { display: none; } }
#walk-touch { position: fixed; inset: 0; z-index: 2; pointer-events: none; }
#walk-touch > * { pointer-events: auto; touch-action: none; position: absolute; }
#walk-stick { left: 24px; bottom: calc(24px + env(safe-area-inset-bottom)); width: 120px; height: 120px; border-radius: 50%;
              background: rgba(18, 20, 26, 0.45); border: 1px solid var(--line); }
#walk-knob { position: absolute; left: 40px; top: 40px; width: 40px; height: 40px; border-radius: 50%;
             background: rgba(232, 233, 238, 0.6); pointer-events: none; }
#walk-jump, #walk-down { right: 24px; width: 64px; height: 64px; border-radius: 50%; font-size: 20px;
                         background: rgba(18, 20, 26, 0.55); }
#walk-jump { bottom: calc(104px + env(safe-area-inset-bottom)); }
#walk-down { bottom: calc(24px + env(safe-area-inset-bottom)); }
#walk-exit { right: 16px; top: 16px; width: 40px; height: 40px; background: var(--panel); }

/* ---------------------------------------------------------------- small screens
   The panel is a fixed 344px, which is most of a phone. Below that it becomes a sheet
   along the bottom, leaving the build visible above it, and the hints swap to the
   gestures that actually exist on a touch device. */
.touch-only { display: none; }

@media (pointer: coarse) {
  .touch-only { display: block; }
  .pointer-only { display: none; }
}

@media (max-width: 520px) {
  #panel {
    top: auto; bottom: 0; left: 0; right: 0;
    width: auto; max-width: none;
    max-height: 62vh;
    border-radius: 12px 12px 0 0;
    border-left: none; border-right: none; border-bottom: none;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }
  #panel-show { top: auto; bottom: 16px; left: 16px; }
  #inspect { left: 8px; right: 8px; bottom: auto; top: 56px; width: auto; max-height: 50vh; }
  /* Comfortably tappable rather than mouse-sized. */
  #panel input[type=range] { height: 28px; }
  #panel select { min-height: 36px; }
  #panel button, #panel .file span { min-height: 40px; }
}
