:root {
  color-scheme: light dark;
  --surface: #f6f6f8;
  --text: #191a1e;
  --secondary: #595c67;
  --accent: #245bc5;
  --active-track: #3976e9;
  --track: #c8cbd3;
  --divider: #d9dbe1;
  --pressed: #e4e8f0;
  --map-cell: #aab4c4;
  --gutter: clamp(16px, 2.4vw, 44px);
  font-family: "One UI Sans", SamsungOne, Roboto, system-ui, sans-serif;
  background: var(--surface);
  color: var(--text);
}
@media (prefers-color-scheme: dark) {
  :root {
    --surface: #191a1e;
    --text: #f4f4f7;
    --secondary: #babdc9;
    --accent: #a7c4ff;
    --active-track: #8fafff;
    --track: #50545e;
    --divider: #35373d;
    --pressed: #30343e;
    --map-cell: #6d7582;
  }
}
* { box-sizing: border-box; }
body, h1, h2 { margin: 0; }
button, input { font: inherit; }
button, summary { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button { border: 0; background: transparent; color: inherit; }
:where(button, summary, input, #stage):focus-visible { outline: 3px solid var(--active-track); outline-offset: -3px; }
[hidden] { display: none !important; }
main {
  min-height: 100svh;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
}
.stage {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: min(52svh, 70vw);
  background: #070910;
  color: white;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.stage.dragging { cursor: grabbing; }
.stage img {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  visibility: hidden;
  pointer-events: none;
}
.stage img.ready { visibility: visible; }
.stage:fullscreen img { object-fit: contain; }
.photo-bar, .photo-caption {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  padding-inline: var(--gutter);
  pointer-events: none;
}
.photo-bar {
  top: 0;
  gap: 3px;
  padding-top: max(8px, env(safe-area-inset-top));
  padding-bottom: 18px;
  background: linear-gradient(#060812b0, transparent);
}
h1 { margin-right: auto; font-size: clamp(1.3rem, 2vw, 1.85rem); font-weight: 600; letter-spacing: -.035em; }
.icon-button { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; pointer-events: auto; }
.info span { border: 1.8px solid; border-radius: 50%; width: 20px; height: 20px; font-weight: 650; font-size: .85rem; line-height: 17px; }
.expand span {
  width: 18px;
  height: 18px;
  border: 2px solid;
  mask: linear-gradient(90deg, black 6px, transparent 6px 12px, black 12px),
        linear-gradient(black 6px, transparent 6px 12px, black 12px);
  mask-composite: intersect;
}
.photo-caption {
  bottom: 0;
  justify-content: space-between;
  gap: 12px;
  padding-block: 18px 10px;
  font-size: .8125rem;
  color: #f0f1f5;
  text-shadow: 0 1px 3px #000;
  background: linear-gradient(transparent, #070910ae);
}
#frameCoords, output, #address { font-variant-numeric: tabular-nums; }
#loading { position: absolute; inset: 30% 12%; display: grid; place-content: center; text-align: center; }
.camera {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(18px, 3vw, 56px);
  padding: 8px var(--gutter) 4px;
}
.transport, .reset {
  min-height: 44px;
  border-radius: 22px;
  padding-inline: 16px;
  font-weight: 600;
}
.transport { display: inline-flex; align-items: center; justify-content: center; gap: 10px; color: var(--surface); background: var(--text); }
.transport[aria-pressed="true"] { background: var(--accent); }
.play-icon { width: 0; height: 0; border-block: 6px solid transparent; border-left: 10px solid currentColor; }
.transport[aria-pressed="true"] .play-icon { width: 10px; height: 12px; border: solid currentColor; border-width: 0 3px; }
.reset { color: var(--accent); white-space: nowrap; }
.angle { display: grid; grid-template-columns: 1fr auto; align-items: baseline; min-width: 0; padding-top: 5px; }
.angle label { font-size: .9375rem; font-weight: 550; }
.angle output { font-size: .875rem; color: var(--accent); }
input[type="range"] {
  grid-column: 1 / -1;
  width: 100%; min-width: 0; height: 44px; margin: 0; padding: 0;
  appearance: none; cursor: pointer; accent-color: var(--active-track); background: transparent;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 5px; border-radius: 8px;
  background: linear-gradient(to right, var(--active-track) var(--pct, 0%), var(--track) var(--pct, 0%));
}
input[type="range"]::-moz-range-track { height: 5px; border-radius: 8px; background: var(--track); }
input[type="range"]::-moz-range-progress { height: 5px; border-radius: 8px; background: var(--active-track); }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 17px; height: 17px; margin-top: -6px; border-radius: 50%; background: var(--active-track); }
input[type="range"]::-moz-range-thumb { width: 17px; height: 17px; border: 0; border-radius: 50%; background: var(--active-track); }
#trace { border-top: 1px solid var(--divider); }
summary {
  min-height: 48px; padding: 4px var(--gutter) max(4px, env(safe-area-inset-bottom));
  display: flex; gap: 14px; align-items: center; list-style: none;
}
summary::-webkit-details-marker { display: none; }
summary strong { font-weight: 600; font-size: .9375rem; }
summary small, .range-preview { font-size: .8125rem; color: var(--secondary); }
.range-preview { margin-left: auto; }
.chevron { flex: none; width: 9px; height: 9px; margin: -3px 3px 0 0; border: solid var(--secondary); border-width: 0 2px 2px 0; transform: rotate(45deg); }
details[open] .chevron { transform: rotate(225deg); }
.trace-content {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px;
  padding: 4px var(--gutter) max(16px, env(safe-area-inset-bottom));
}
.trace-content h2 { margin: 0 0 6px; font-size: .8125rem; color: var(--secondary); font-weight: 550; }
#byteMap { width: 100%; height: 32px; display: block; }
.map-scale { display: flex; justify-content: space-between; color: var(--secondary); font-size: .75rem; margin-top: 3px; }
pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: .8125rem/1.45 ui-monospace, monospace; }
dialog { width: min(440px, calc(100% - 32px)); max-height: 85dvh; border: 0; padding: 24px; border-radius: 24px; color: var(--text); background: var(--surface); }
dialog::backdrop { background: #0008; }
dialog h2 { font-size: 1.375rem; }
dialog p { line-height: 1.5; margin: 12px 0; }
#closeGuide { width: 100%; border-radius: 22px; min-height: 44px; color: var(--accent); font-weight: 650; }
@media (hover: hover) {
  .reset:hover, summary:hover, #closeGuide:hover { background: var(--pressed); }
  .icon-button:hover { background: #ffffff20; }
  .transport:hover { filter: brightness(.9); }
}
@media (max-width: 650px) {
  .camera { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; padding-block: 8px 0; }
  .transport { grid-column: 1; grid-row: 1; justify-self: start; }
  .reset { grid-column: 2; grid-row: 1; justify-self: end; }
  .angle { padding-top: 8px; }
  summary { display: grid; grid-template-columns: 1fr auto auto; gap: 2px 10px; padding-block: 8px max(8px, env(safe-area-inset-bottom)); }
  .range-preview { grid-column: 1 / 3; grid-row: 2; margin: 0; }
  .chevron { grid-column: 3; grid-row: 1 / 3; }
  .trace-content { grid-template-columns: 1fr; gap: 14px; }
  dialog { margin: auto auto max(12px, env(safe-area-inset-bottom)); }
}
@media (orientation: landscape) and (max-height: 480px) and (min-width: 540px) {
  main { grid-template-columns: minmax(0, 1fr) clamp(196px, 27vw, 270px); grid-template-rows: 1fr auto; }
  .stage { grid-row: 1 / -1; position: sticky; top: 0; height: 100svh; }
  .camera { grid-column: 2; grid-template-columns: 1fr; gap: 0; align-self: center; padding: 4px 16px; }
  .transport, .reset { grid-column: auto; grid-row: auto; justify-self: start; }
  .reset { padding-inline: 0; }
  #trace { grid-column: 2; }
  summary { display: grid; grid-template-columns: 1fr auto; gap: 3px 8px; padding: 8px 16px; }
  summary small, .range-preview { grid-column: 1; grid-row: auto; margin: 0; }
  .chevron { grid-column: 2; grid-row: 1 / 4; }
  .trace-content { grid-template-columns: 1fr; gap: 12px; padding: 8px 16px; }
}
