: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);
}

.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); }

#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: 12px 0 0; color: var(--muted); }
#status.error { color: #ff8f8f; }

dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 12px 0 0; }
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 { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
#layers label { display: flex; justify-content: space-between; color: var(--muted); }
#layers output { color: var(--text); font-variant-numeric: tabular-nums; }
#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; }
.hint p:last-child { margin-bottom: 0; }
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;
}


/* ---------------------------------------------------------------- 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; }
  /* Comfortably tappable rather than mouse-sized. */
  #panel input[type=range] { height: 28px; }
  #panel button, #panel .file span { min-height: 40px; }
}
