  html, body { margin: 0; height: 100%; background: #111; overflow: hidden;
               font: 13px/1.5 system-ui, sans-serif; color: #eee; }
  canvas { display: block; width: 100%; height: 100%; touch-action: none; }
  /* The readout and the flip button stack in one corner, so the button always sits
     just below the readout however many lines it has. The stack is click-through,
     like the readout, and only the button takes input. */
  #topleft { position: fixed; top: 8px; left: 8px; display: flex; flex-direction: column;
             align-items: flex-start; gap: 6px; pointer-events: none; z-index: 2; }
  #flip { padding: 6px 12px; border: 0; border-radius: 6px; background: rgba(0,0,0,.6);
          color: inherit; font: inherit; cursor: pointer; pointer-events: auto; }
  #flip:hover { background: rgba(0,0,0,.8); }
  #flip:focus-visible { outline: 2px solid #7fd4ff; outline-offset: 2px; }
  #flip[hidden] { display: none; }
  #hud { padding: 6px 10px; border-radius: 6px;
         background: rgba(0,0,0,.55); pointer-events: none; white-space: pre; }
  /* The box stays click-through so dragging over it still orbits; only the
     control itself accepts input. Without this the slider is unusable, and
     with it applied to the whole box the camera stops responding near it. */
  #hud[hidden] { display: none; }
  #note { opacity: .75; }
  /* Its own box rather than inside the HUD: the HUD rewrites its text twice a
     second and is pointer-events: none so drags reach the canvas. A control
     living there would be destroyed on every update and unclickable besides. */
  #panel { position: fixed; top: 52px; right: 8px; padding: 8px 10px;
           border-radius: 6px; background: rgba(0,0,0,.6); font: inherit;
           display: grid; gap: 3px; min-width: 236px; }
  #panel[hidden] { display: none; }
  #panel b { opacity: .8; font-weight: 600; }
  #panel .row { display: grid; grid-template-columns: 82px 1fr 42px;
                align-items: center; gap: 6px; white-space: nowrap; }
  #panel .grp { margin-top: 5px; opacity: .55; font-size: .92em; }
  #panel .hint { opacity: .4; font-size: .85em; margin: 2px 0 1px; }
  #panel input[type=range] { width: 100%; accent-color: #7fd4ff; }
  #panel .val { text-align: right; font-variant-numeric: tabular-nums; }
  #panel button { margin-top: 6px; padding: 3px; cursor: pointer; }
  /* Bottom-left, clear of the readout (top-left) and the panel (top-right). It
     takes input, so unlike the readout it is not click-through. */
  #view { position: fixed; left: 8px; bottom: 8px; padding: 6px 12px; border: 0;
          border-radius: 6px; background: rgba(0,0,0,.6); color: inherit;
          font: inherit; cursor: pointer; }
  #view:hover { background: rgba(0,0,0,.8); }
  #view:focus-visible { outline: 2px solid #7fd4ff; outline-offset: 2px; }
  #view[hidden] { display: none; }
  /* A fingertip needs more than a mouse pointer does. */
  @media (pointer: coarse) { #view, #flip { padding: 13px 18px; } }
  /* The cog sits in the corner the floaters panel used to have; the panel and
     the menu open below it. Both sit above the drop-a-model screen, so options
     can be set before a model is loaded. */
  #options-btn { position: fixed; top: 8px; right: 8px; z-index: 5; width: 36px; height: 36px;
                 display: grid; place-items: center; padding: 0; border: 0; border-radius: 6px;
                 background: rgba(0,0,0,.6); color: inherit; cursor: pointer; }
  #options-btn:hover, #options-btn[aria-expanded=true] { background: rgba(0,0,0,.85); }
  #options-btn:focus-visible { outline: 2px solid #7fd4ff; outline-offset: 2px; }
  /* Scrolls rather than running off the bottom of a phone screen: the height left
     under it, less its 22px of padding and an 8px margin. */
  #options { position: fixed; top: 52px; right: 8px; z-index: 5; width: min(280px, calc(100vw - 16px));
             max-height: calc(100vh - 82px); max-height: calc(100dvh - 82px); overflow-y: auto;
             overscroll-behavior: contain;
             padding: 10px 12px 12px; border-radius: 8px; background: rgba(18,18,20,.96);
             box-shadow: 0 6px 24px rgba(0,0,0,.5); }
  #options[hidden] { display: none; }
  #options h3 { margin: 0 0 8px; font-size: 1.05em; font-weight: 600; }
  #options .sect { margin-top: 10px; opacity: .55; font-size: .85em;
                   text-transform: uppercase; letter-spacing: .06em; }
  #options .opt { display: flex; align-items: center; justify-content: space-between; gap: 12px;
                  padding: 7px 0; cursor: pointer; }
  #options .opt-hint { display: block; opacity: .55; font-size: .9em; }
  #options input[type=checkbox] { width: 18px; height: 18px; margin: 0; flex: none;
                                  accent-color: #7fd4ff; cursor: pointer; }
  /* A choice: label and a segmented control on one line, the chosen value's hint
     under both. A control too wide to share the line (four choices) moves under
     its label. The radios stay in the page, transparent over their labels, so
     the keyboard and screen readers still treat them as radios. */
  #options .opt-choice { padding: 7px 0; }
  #options .opt-line { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
                       gap: 6px 12px; }
  #options .seg { display: inline-flex; flex: none; padding: 2px; border-radius: 6px;
                  background: rgba(255,255,255,.08); }
  #options .seg label { position: relative; cursor: pointer; }
  #options .seg input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0;
                        opacity: 0; cursor: pointer; }
  #options .seg span { display: block; padding: 3px 12px; border-radius: 4px; }
  #options .seg input:checked + span { background: #7fd4ff; color: #111; }
  #options .seg input:focus-visible + span { outline: 2px solid #7fd4ff; outline-offset: 1px; }
  #options .opt-choice .opt-hint { margin-top: 4px; }
  @media (pointer: coarse) {
    #options-btn { width: 44px; height: 44px; }
    #options, #panel { top: 60px; }
    #options { max-height: calc(100vh - 90px); max-height: calc(100dvh - 90px); }
    #options .opt { padding: 11px 0; }
    #options .opt-choice { padding: 11px 0; }
    #options .seg span { padding: 8px 13px; }
  }
  /* Marks: points of interest from `?marks=`. A ring on the point, a stem up from
     it and the id on top, so a mark stays readable over any ground. The layer is
     click-through; the list in the bottom-right corner takes input. */
  #marks { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 1; }
  #marks .mark { position: absolute; left: 0; top: 0; width: 0; height: 0; }
  #marks .mark[hidden] { display: none; }
  #marks .mark::after { content: ""; position: absolute; left: -6px; top: -6px; width: 8px; height: 8px;
                        border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 3px #000; }
  #marks .mark::before { content: ""; position: absolute; left: -1px; bottom: 6px; width: 2px; height: 30px;
                         background: #fff; box-shadow: 0 0 3px #000; }
  #marks .mark span { position: absolute; left: -12px; bottom: 36px; width: 24px; height: 24px;
                      display: grid; place-items: center; border-radius: 50%; font-weight: 700;
                      background: #fff; color: #111; box-shadow: 0 0 0 2px rgba(0,0,0,.55); }
  #marks .mark-red span { background: #ff3b30; color: #fff; }
  #marks .mark-blue span { background: #2f7bff; color: #fff; }
  #marks-list { position: fixed; right: 8px; bottom: 8px; z-index: 2; display: grid; gap: 4px;
                max-width: min(380px, calc(100vw - 16px)); }
  #marks-list[hidden] { display: none; }
  #marks-list button { text-align: left; padding: 6px 10px; border: 0; border-radius: 6px;
                       background: rgba(0,0,0,.65); color: inherit; font: inherit; cursor: pointer; }
  #marks-list button:hover { background: rgba(0,0,0,.85); }
  #marks-list button:focus-visible { outline: 2px solid #7fd4ff; outline-offset: 2px; }
  #marks-list b { margin-right: 6px; }
  @media (pointer: coarse) { #marks-list button { padding: 11px 14px; } }
  /* Planning tools. The drawing is an SVG layer over the canvas, click-through
     like the marks; the toolbar sits at the bottom in the middle, with the
     current tool's hint above it. */
  #annot { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none;
           overflow: hidden; z-index: 1; }
  #annot text { font: 600 12px system-ui, sans-serif; }
  #tools { position: fixed; left: 50%; bottom: 8px; transform: translateX(-50%); z-index: 2;
           display: grid; justify-items: center; gap: 6px; width: max-content;
           max-width: calc(100vw - 16px); }
  #tools[hidden] { display: none; }
  #tools .bar { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 2px;
                padding: 4px; border-radius: 8px; background: rgba(0,0,0,.6); }
  #tools button { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px;
                  border: 0; border-radius: 6px; background: transparent; color: inherit; font: inherit;
                  cursor: pointer; }
  #tools button:hover { background: rgba(255,255,255,.1); }
  #tools button:focus-visible { outline: 2px solid #7fd4ff; outline-offset: 1px; }
  #tools button:disabled { opacity: .35; cursor: default; background: transparent; }
  #tools button[data-tool][aria-pressed=true] { background: #7fd4ff; color: #111; }
  #tools button svg { width: 18px; height: 18px; flex: none; }
  #tools-hide .eye-off, #tools-hide[aria-pressed=true] .eye-on { display: none; }
  #tools-hide[aria-pressed=true] .eye-off { display: block; }
  #tools-hide[aria-pressed=true] { color: #7fd4ff; }
  #tools .sep { width: 1px; height: 22px; margin: 0 4px; background: rgba(255,255,255,.18); }
  #swatches { display: flex; gap: 2px; }
  #tools .swatch { width: 30px; padding: 0; justify-content: center; }
  #tools .swatch i { width: 16px; height: 16px; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0,0,0,.7); }
  #tools .swatch[aria-pressed=true] { background: rgba(255,255,255,.16); }
  #tools .swatch[aria-pressed=true] i { box-shadow: 0 0 0 2px #111, 0 0 0 4px #fff; }
  #tool-hint { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px 14px;
               padding: 5px 12px; border-radius: 6px; background: rgba(0,0,0,.6); text-align: center; }
  #tool-hint[hidden], #sight-height[hidden], #sight-mode[hidden], #cone-width[hidden] { display: none; }
  #sight-height, #cone-width { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
  #sight-height input { width: 150px; accent-color: #7fd4ff; }
  #cone-width input { width: 110px; accent-color: #7fd4ff; }
  #cone-width output { min-width: 3em; text-align: right; font-variant-numeric: tabular-nums; }
  /* Line or cone: a segmented control, its radios transparent over their
     labels, as in the options menu. */
  #sight-mode { display: inline-flex; padding: 2px; border-radius: 6px; background: rgba(255,255,255,.1); }
  #sight-mode label { position: relative; cursor: pointer; }
  #sight-mode input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
  #sight-mode span { display: block; padding: 2px 11px; border-radius: 4px; }
  #sight-mode input:checked + span { background: #7fd4ff; color: #111; }
  #sight-mode input:focus-visible + span { outline: 2px solid #7fd4ff; outline-offset: 1px; }
  @media (pointer: coarse) { #sight-mode span { padding: 8px 14px; } }
  /* Labels go where the bar would not fit on one line. */
  @media (max-width: 960px) { #tools .lbl { display: none; } #tools button { padding: 0 9px; } }
  /* On a phone the bar takes the bottom, so the point-cloud button moves up to
     the top-right corner, under the cog. */
  @media (max-width: 640px) { #view { left: auto; right: 8px; bottom: auto; top: 52px; } }
  @media (pointer: coarse) {
    #tools button { height: 44px; }
    #tools .swatch { width: 38px; }
    #tools .swatch i { width: 20px; height: 20px; }
  }
  @media (pointer: coarse) and (max-width: 640px) { #view { top: 60px; } }
  /* Under the map scheme the scene is something to take hold of. */
  canvas.map { cursor: grab; }
  canvas.map.grabbing { cursor: grabbing; }
  /* With a planning tool chosen a click places something, and a drag still
     moves the map. */
  canvas.tool { cursor: crosshair; }
  canvas.tool.grabbing { cursor: grabbing; }
  /* Over a placed point, and while dragging one: it can be moved. */
  canvas.handle { cursor: move; }
  #drop { position: fixed; inset: 0; display: grid; place-items: center;
          background: rgba(0,0,0,.75); text-align: center; padding: 2em;
          /* Above everything, including the corner stack, as it was when stacking
             followed page order. */
          z-index: 3; }
  #drop.hidden { display: none; }
  input[type=file] { margin-top: 1em; }
