/* A2NK Site Explorer - brand styling
   UI palette (brand guidelines):
     Deep Steel Blue #0F2D3D | Neutral Gray #4D4D4D
     Medium Light Gray #999999 | White #FFFFFF
   Render area is solid black by explicit decision (2026-07-01) so the data
   reads clearly against the blue panel; point cloud DATA coloring is not
   brand-constrained (standard survey ramps).
   Fonts: Montserrat (headings), Aeonik (subheadings), Inter (body/UI).
   TODO(WP reconciliation): Aeonik is a licensed font loaded on the live
   WordPress site via Elementor Custom Fonts; falls back to Montserrat here
   until the woff2 files are self-hosted alongside this viewer. */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --steel: #0F2D3D;
  --gray: #4D4D4D;
  --light: #999999;
  --white: #FFFFFF;
  --font-heading: 'Montserrat', sans-serif;
  --font-subhead: 'Aeonik', 'Montserrat', sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
}

html, body {
  width: 100%;
  height: 100%;
  background: var(--steel);
  overflow: hidden;
  font-family: var(--font-body);
}

#potree_render_area {
  position: absolute;
  inset: 0;
  background: #000000; /* explicit decision: black canvas, blue panel */
}
#potree_sidebar_container { display: none; }

/* Stock potree map window stays dormant; our own inset is #a2nk_minimap */
#potree_map { display: none !important; }
/* Stock hamburger + map toggle appended by loadGUI - superseded by our panel */
#potree_quick_buttons { display: none !important; }

/* ---- Loading overlay ---- */
#a2nk_loading {
  position: absolute;
  inset: 0;
  z-index: 300;
  background: var(--steel);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  transition: opacity 0.5s ease;
}
#a2nk_loading.hidden { opacity: 0; pointer-events: none; }
#a2nk_loading img { width: 220px; }
#a2nk_loading p { color: var(--light); font-size: 14px; }
#a2nk_loading .bar { width: 180px; height: 2px; background: var(--gray); overflow: hidden; }
#a2nk_loading .bar span {
  display: block; width: 40%; height: 100%; background: var(--white);
  animation: a2nk-slide 1.2s ease-in-out infinite;
}
@keyframes a2nk-slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* ---- No-WebGL fallback ---- */
#no-webgl {
  display: none; position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  color: var(--white); text-align: center; z-index: 400; max-width: 420px;
}
#no-webgl img { width: 200px; margin-bottom: 16px; }
#no-webgl p { margin: 6px 0; color: var(--light); }
#no-webgl a { color: var(--white); }

/* ---- Control panel ---- */
#a2nk_panel {
  position: absolute; top: 0; left: 0; bottom: 0; width: 300px; z-index: 200;
  background: var(--steel);
  border-right: 1px solid var(--gray);
  color: var(--white);
  display: flex; flex-direction: column;
  transition: transform 0.25s ease;
}
#a2nk_panel.collapsed { transform: translateX(-300px); }

#a2nk_panel_header { padding: 16px 16px 12px; border-bottom: 1px solid var(--gray); }
#a2nk_panel_header img { width: 170px; display: block; }
#a2nk_panel_header .tagline {
  margin-top: 8px;
  font-family: var(--font-subhead);
  font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--light);
}

#a2nk_panel_body {
  flex: 1; overflow-y: auto; padding: 6px 16px 16px;
  scrollbar-width: thin; scrollbar-color: var(--gray) var(--steel);
}

.panel-section { padding: 10px 0; border-bottom: 1px solid var(--gray); }
.panel-section:last-child { border-bottom: none; }
.panel-section h2 {
  font-family: var(--font-heading);
  font-size: 11px; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--light);
  display: inline;
}
.panel-section summary {
  list-style: none;
  cursor: pointer;
  display: flex; align-items: center;
  user-select: none;
}
.panel-section summary::-webkit-details-marker { display: none; }
.panel-section summary::after {
  content: '\203A'; /* single right chevron */
  margin-left: auto;
  color: var(--light);
  font-size: 14px;
  transition: transform 0.15s ease;
}
.panel-section[open] summary::after { transform: rotate(90deg); }
.panel-section[open] summary { margin-bottom: 10px; }
.panel-section summary:hover h2 { color: var(--white); }

.hint-line { font-size: 10px; color: var(--light); margin: 8px 0 4px; line-height: 1.4; }

.dataset-label { font-size: 13px; line-height: 1.4; color: var(--white); }

/* ---- Tool buttons: white at rest, Deep Steel Blue when active ---- */
.tool-row { display: flex; gap: 6px; flex-wrap: wrap; }
.tool-btn {
  flex: 1 1 46px; min-width: 46px;
  background: var(--white);
  border: 1px solid var(--white);
  border-radius: 4px;
  padding: 7px 4px 5px;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: var(--steel);
  font-family: var(--font-body);
  font-size: 9px; font-weight: 600; letter-spacing: 0.04em;
}
.tool-btn img { height: 20px; }
.tool-btn .ic-light { display: none; }
.tool-btn .ic-dark { display: block; }
.tool-btn:hover { border-color: var(--light); background: #e8e8e8; }
.tool-btn.active {
  background: var(--steel);
  border-color: var(--white);
  color: var(--white);
}
.tool-btn.active .ic-dark { display: none; }
.tool-btn.active .ic-light { display: block; }

.text-btn {
  margin-top: 8px; width: 100%;
  background: transparent;
  border: 1px solid var(--gray); border-radius: 4px;
  color: var(--light); font-family: var(--font-body); font-size: 11px;
  padding: 6px 8px; cursor: pointer;
}
.text-btn:hover { border-color: var(--light); color: var(--white); }

/* Segmented controls */
.segmented { display: flex; border: 1px solid var(--gray); border-radius: 4px; overflow: hidden; }
.segmented button {
  flex: 1; background: transparent; border: none;
  border-right: 1px solid var(--gray);
  color: var(--light); font-family: var(--font-body); font-size: 11px;
  padding: 7px 4px; cursor: pointer; white-space: nowrap;
}
.segmented button:last-child { border-right: none; }
.segmented button:hover { color: var(--white); }
.segmented button.active { background: var(--white); color: var(--steel); font-weight: 600; }
.segmented.wrap { flex-wrap: wrap; }
.segmented.wrap button { flex: 1 1 30%; border-bottom: 1px solid var(--gray); }

/* Style section */
#gradient_row { margin-top: 8px; }
#gradient_row .seg-label, .sub-label {
  font-size: 10px; color: var(--light); margin: 8px 0 4px;
  letter-spacing: 0.06em; text-transform: uppercase;
}

/* Classification list */
#class_rows { margin-top: 8px; }
.class-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 0; font-size: 12px; color: var(--white);
}
.class-row .swatch {
  width: 12px; height: 12px; border-radius: 2px; flex: 0 0 auto;
  border: 1px solid rgba(255,255,255,0.25);
}
.class-row .cname { flex: 1; line-height: 1.2; }
.class-row .count { font-size: 10px; color: var(--light); }
.class-row .eye-btn { background: none; border: none; cursor: pointer; padding: 2px; }
.class-row .eye-btn img { height: 16px; display: block; }
.class-row.off .eye-btn img { opacity: 0.3; }
.class-row.off .cname, .class-row.off .count { color: var(--gray); }

/* Layer + CRS rows */
.layer-row {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 0; font-size: 12px; line-height: 1.35; color: var(--white);
}
.layer-row .eye-btn { flex: 0 0 auto; background: transparent; border: none; cursor: pointer; padding: 2px; }
.layer-row .eye-btn img { height: 18px; display: block; }
.layer-row.off .eye-btn img { opacity: 0.3; }
.layer-row.off span { color: var(--light); }
.layer-row .row-icon { height: 16px; opacity: 0.7; }
.layer-row .doc-btn { background: none; border: 1px solid var(--gray); border-radius: 3px; cursor: pointer; padding: 3px 5px; }
.layer-row .doc-btn img { height: 13px; display: block; }
.layer-row .doc-btn:hover { border-color: var(--light); }
.layer-sub { padding: 0 0 6px 30px; display: flex; align-items: center; gap: 8px; }
.layer-sub label { font-size: 10px; color: var(--light); }
.layer-sub input[type=range] { flex: 1; accent-color: #ffffff; height: 3px; }

.crs-readout { font-size: 12px; line-height: 1.45; color: var(--white); }
.crs-readout .sub { color: var(--light); font-size: 11px; }
.crs-readout.hidden-readout { display: none; }

/* Sliders (display section) */
.slider-row { display: flex; align-items: center; gap: 10px; padding: 5px 0; }
.slider-row label { font-size: 11px; color: var(--light); flex: 0 0 84px; }
.slider-row input[type=range] { flex: 1; accent-color: #ffffff; height: 3px; }
.slider-row .val { font-size: 10px; color: var(--white); flex: 0 0 44px; text-align: right; }

/* Share / export */
#share_btn, .action-btn {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--white); border: 1px solid var(--white); border-radius: 4px;
  color: var(--steel);
  font-family: var(--font-heading);
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 9px 8px; cursor: pointer;
  margin-bottom: 8px;
}
#share_btn img, .action-btn img { height: 16px; }
#share_btn:hover, .action-btn:hover { background: #e8e8e8; }
.action-row { display: flex; gap: 6px; }
.action-row .action-btn { margin-bottom: 0; font-size: 10px; padding: 8px 4px; }
#share_url_out {
  margin-top: 8px; width: 100%;
  background: transparent; border: 1px solid var(--gray); border-radius: 4px;
  color: var(--light); font-family: var(--font-body); font-size: 10px;
  padding: 5px 6px; display: none;
}
#share_url_out.visible { display: block; }
.share-note { margin-top: 6px; font-size: 10px; color: var(--light); display: none; }
.share-note.visible { display: block; }

/* Panel collapse handle */
#panel_toggle {
  position: absolute; top: 12px; left: 300px; z-index: 210;
  background: var(--steel);
  border: 1px solid var(--gray); border-left: none;
  border-radius: 0 4px 4px 0;
  color: var(--white); width: 24px; height: 40px; cursor: pointer; font-size: 13px;
  transition: left 0.25s ease;
}
#a2nk_panel.collapsed ~ #panel_toggle { left: 0; }

/* ---- Touch action bar (BUG-01) ----
   A phone has no right-click and no Escape key, so the two gestures that end
   an entity (right-click) and put the tool away (Esc) need real targets.
   Hidden entirely until viewer.js sees a touchstart, so desktop is unchanged
   and the existing verification screenshots stay valid. */
#a2nk_toolbar {
  position: absolute; z-index: 220;
  left: 50%; transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  display: none; align-items: center; gap: 8px;
  padding: 8px 10px;
  background: var(--steel);
  border: 1px solid var(--gray); border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.55);
  max-width: calc(100vw - 24px);
}
#a2nk_toolbar.visible { display: flex; }
#toolbar_status {
  font-size: 12px; color: var(--light);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 40vw;
}
#a2nk_toolbar button {
  /* 44px minimum touch target (Apple HIG / WCAG 2.5.5) */
  min-height: 44px; min-width: 88px;
  padding: 0 14px;
  font-family: var(--font-body); font-size: 13px; font-weight: 600;
  border-radius: 6px; cursor: pointer;
  border: 1px solid var(--gray);
  background: var(--white); color: var(--steel);
}
#toolbar_done { background: var(--white); color: var(--steel); }
#toolbar_cancel { background: transparent; color: var(--white); }

/* Stop iOS page pinch-zoom and double-tap-zoom from eating tool gestures.
   Matters most inside the Capabilities-page iframe. Potree's own touch
   navigation calls preventDefault itself, so it is unaffected. */
#potree_render_area canvas { touch-action: none; }

/* ---- Corner mark + caption ---- */
#a2nk_caption {
  position: absolute; right: 12px; bottom: 10px; z-index: 150;
  display: flex; align-items: center; gap: 10px; max-width: 55vw;
}
#a2nk_caption img { height: 26px; }
#a2nk_caption p {
  font-size: 11px; color: var(--light); text-align: right;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

/* ---- PDF panel ---- */
#pdf_panel {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: 42%; min-width: 320px; z-index: 220;
  background: var(--steel);
  border-left: 1px solid var(--gray);
  display: none; flex-direction: column;
}
#pdf_panel.visible { display: flex; }
#pdf_panel_header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-bottom: 1px solid var(--gray);
}
#pdf_panel_header img { height: 22px; }
#pdf_panel_header .title {
  flex: 1; font-family: var(--font-subhead);
  font-size: 12px; letter-spacing: 0.06em; color: var(--white);
}
#pdf_panel_header button {
  background: transparent; border: 1px solid var(--gray); border-radius: 4px;
  color: var(--light); width: 26px; height: 26px; cursor: pointer; font-size: 13px;
}
#pdf_panel_header button:hover { color: var(--white); border-color: var(--light); }
#pdf_panel iframe { flex: 1; border: none; background: var(--white); }

/* ---- Mini-map inset ---- */
#a2nk_minimap {
  position: absolute; left: 312px; bottom: 12px; z-index: 180;
  width: 230px; height: 170px;
  border: 1px solid var(--gray); border-radius: 4px;
  overflow: hidden;
  background: var(--steel);
  transition: left 0.25s ease;
}
#a2nk_panel.collapsed ~ #a2nk_minimap { left: 12px; }
#a2nk_minimap .ol-viewport { border-radius: 3px; }
#a2nk_minimap.collapsed { height: 26px; width: 130px; }
#a2nk_minimap.collapsed #minimap_map { display: none; }
#minimap_bar {
  position: absolute; top: 0; left: 0; right: 0; height: 26px; z-index: 5;
  display: flex; align-items: center; gap: 6px;
  background: var(--steel);
  padding: 0 8px; cursor: pointer;
  border-bottom: 1px solid var(--gray);
}
#minimap_bar img { height: 13px; }
#minimap_bar span {
  font-family: var(--font-heading);
  font-size: 9px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--light); flex: 1;
}
#minimap_map { position: absolute; top: 26px; left: 0; right: 0; bottom: 0; }
#a2nk_minimap .ol-attribution { font-size: 8px; }
#a2nk_minimap .ol-zoom { display: none; }

/* ---- Potree overrides: annotations, compass, measurement labels ---- */
.annotation {
  font-family: var(--font-body) !important;
}
.annotation-titlebar {
  background: rgba(15, 45, 61, 0.88) !important;
  border: 1px solid #999999 !important;
  border-radius: 3px !important;
  font-size: 12px !important;
  color: #FFFFFF !important;
}
.annotation-description {
  background: rgba(15, 45, 61, 0.92) !important;
  border: 1px solid #999999 !important;
  color: #FFFFFF !important;
  font-size: 11px !important;
}

#potree_compass {
  right: 12px !important;
  top: 12px !important;
}

/* ---- Profile window restyle (stock potree DOM, brand chrome) ---- */
#profile_window {
  background: var(--steel) !important;
  border: 1px solid var(--gray) !important;
  color: var(--white) !important;
  font-family: var(--font-body) !important;
  z-index: 250 !important;
}
#profile_titlebar {
  background: var(--steel) !important;
  color: var(--white) !important;
  font-family: var(--font-heading) !important;
  font-size: 12px !important;
  border-bottom: 1px solid var(--gray) !important;
}
#profile_window .pv-menu-list, #profileInfo { color: var(--white) !important; }
#profileSVG text { fill: #cccccc !important; }

/* ---- Iteration 3: lists, probe, modals ---- */
.probe-readout {
  font-size: 11px; color: var(--white); padding: 2px 0 6px;
  font-variant-numeric: tabular-nums;
}
.curb-row { display: flex; gap: 10px; padding: 4px 0; }
.curb-row label { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--white); }
.curb-row .desc-in {
  width: 34px; background: transparent; border: 1px solid var(--gray);
  border-radius: 3px; color: var(--white); font-size: 10px; padding: 2px 4px;
}
#grid_spacing_row input[type=number] {
  background: transparent; border: 1px solid var(--gray); border-radius: 3px;
  color: var(--white); font-size: 11px; padding: 3px 5px;
}

/* Entity / point / annotation list rows */
.item-row {
  display: flex; align-items: center; gap: 7px;
  padding: 4px 0; font-size: 11px; color: var(--white);
}
.item-row .iname { flex: 1; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-row .imeta { font-size: 9px; color: var(--light); }
.item-row .mini-btn {
  background: transparent; border: 1px solid var(--gray); border-radius: 3px;
  color: var(--light); font-size: 10px; padding: 2px 6px; cursor: pointer; line-height: 1.3;
}
.item-row .mini-btn:hover { color: var(--white); border-color: var(--light); }
.item-row .eye-btn { background: none; border: none; cursor: pointer; padding: 1px; }
.item-row .eye-btn img { height: 15px; display: block; }
.item-row.off .eye-btn img { opacity: 0.3; }
.item-row.off .iname { color: var(--gray); }
.item-row input.inline-edit {
  background: transparent; border: 1px solid var(--gray); border-radius: 3px;
  color: var(--white); font-size: 10px; padding: 2px 4px; width: 70px;
}
.item-row.selected .iname { color: var(--white); font-weight: 600; }
.item-row.selected { outline: 1px solid var(--light); outline-offset: 2px; border-radius: 2px; }
#point_rows, #draw_rows, #ann_rows { max-height: 180px; overflow-y: auto; scrollbar-width: thin; }

/* Modals */
.a2nk-modal {
  display: none; position: absolute; inset: 0; z-index: 500;
  background: rgba(0, 0, 0, 0.55);
  align-items: center; justify-content: center;
}
.a2nk-modal.visible { display: flex; }
.modal-box {
  width: 360px; max-width: 92vw; max-height: 86vh; overflow-y: auto;
  background: var(--steel);
  border: 1px solid var(--light); border-radius: 6px;
  padding: 16px;
  color: var(--white);
}
.modal-box h3 {
  font-family: var(--font-heading); font-size: 13px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 12px;
}
.modal-box label { display: block; font-size: 11px; color: var(--light); margin-bottom: 10px; }
.modal-box input[type=text], .modal-box textarea, .modal-box select {
  display: block; width: 100%; margin-top: 4px;
  background: transparent; border: 1px solid var(--gray); border-radius: 4px;
  color: var(--white); font-family: var(--font-body); font-size: 12px; padding: 6px 8px;
}
.modal-box select option { background: var(--steel); }
.modal-actions { display: flex; gap: 8px; margin-top: 12px; }
.modal-actions .action-btn { flex: 1; margin-bottom: 0; }
.modal-actions .text-btn { flex: 1; margin-top: 0; }
.fmt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; }
.fmt-grid .fmt-check { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
#pnezd_file_row { margin: 8px 0; font-size: 11px; }
#pnezd_file_row input { color: var(--light); font-size: 11px; }
#pnezd_preview { font-size: 10px; font-variant-numeric: tabular-nums; }
#pnezd_preview table { width: 100%; border-collapse: collapse; margin-top: 6px; }
#pnezd_preview td, #pnezd_preview th {
  border: 1px solid var(--gray); padding: 2px 4px; text-align: right;
  color: var(--white); white-space: nowrap; overflow: hidden; max-width: 90px; text-overflow: ellipsis;
}
#pnezd_preview th { color: var(--light); font-weight: 600; }
#pnezd_preview .err { color: #ff8080; margin-top: 4px; }

/* ---- Iteration 4/5: attract bounce, CAD layers ---- */
/* Horizontal nudge; the collapsed panel peeks out in sync (same timing) so
   the tab visibly "could" open. Amplitudes match: 10px then 5px. */
@keyframes a2nk-bounce {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(10px); }
  40% { transform: translateX(0); }
  60% { transform: translateX(5px); }
  80% { transform: translateX(0); }
}
@keyframes a2nk-peek {
  0%, 100% { transform: translateX(-300px); }
  20% { transform: translateX(-290px); }
  40% { transform: translateX(-300px); }
  60% { transform: translateX(-295px); }
  80% { transform: translateX(-300px); }
}
.attract { animation: a2nk-bounce 0.9s ease 2; }
#panel_toggle.attract { animation: a2nk-bounce 0.9s ease 2; }
#a2nk_panel.collapsed.attract { animation: a2nk-peek 0.9s ease 2; }

.layer-pick-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.layer-pick-row label { font-size: 10px; color: var(--light); letter-spacing: 0.06em; text-transform: uppercase; }
.layer-pick-row select {
  flex: 1; background: var(--steel); border: 1px solid var(--gray); border-radius: 4px;
  color: var(--white); font-family: var(--font-body); font-size: 11px; padding: 4px 6px;
}

#cad_layer_rows { max-height: 200px; overflow-y: auto; margin-top: 4px; padding-right: 4px; }
.cad-layer-row {
  display: flex; align-items: center; gap: 7px;
  padding: 4px 0; font-size: 11px; color: var(--white);
}
.cad-layer-row .eye-btn { background: none; border: none; cursor: pointer; padding: 1px; }
.cad-layer-row .eye-btn img { height: 15px; display: block; }
.cad-layer-row.off .eye-btn img { opacity: 0.3; }
.cad-layer-row.off .lname { color: var(--gray); }
.cad-layer-row .lswatch {
  width: 14px; height: 14px; border-radius: 3px; flex: 0 0 auto; cursor: pointer;
  border: 1px solid rgba(255,255,255,0.35);
}
.cad-layer-row input.lname {
  flex: 1; min-width: 0; background: transparent; border: 1px solid transparent; border-radius: 3px;
  color: var(--white); font-size: 10px; font-family: var(--font-body); padding: 2px 4px;
}
.cad-layer-row input.lname:focus { border-color: var(--gray); outline: none; }
.cad-layer-row .mini-btn {
  background: transparent; border: 1px solid var(--gray); border-radius: 3px;
  color: var(--light); font-size: 10px; padding: 2px 6px; cursor: pointer;
}
.cad-layer-row .mini-btn:hover { color: var(--white); border-color: var(--light); }
.aci-pop {
  display: none; position: absolute; z-index: 300;
  background: var(--steel); border: 1px solid var(--light); border-radius: 4px;
  padding: 6px; grid-template-columns: repeat(5, 18px); gap: 5px;
}
.aci-pop.visible { display: grid; }
.aci-pop .aci-swatch { width: 18px; height: 18px; border-radius: 3px; cursor: pointer; border: 1px solid rgba(255,255,255,0.3); }

/* Compact embeds (iframe ~600px tall) */
@media (max-height: 700px) {
  #a2nk_panel_header img { width: 140px; }
  .panel-section { padding: 9px 0; }
  #a2nk_minimap { width: 180px; height: 130px; }
}

/* ---- Phone layout (Task #263, revised per field test) ----
   The bottom-sheet panel variant was reverted: on phones the panel stays the
   desktop left sidebar (Alfonso field-tested the bottom sheet and it caused
   more problems than it solved). The panel auto-collapse-on-tool-tap behavior
   (in viewer.js, deployed earlier) already keeps the sidebar from swamping a
   phone screen, so no width override is needed here.
   The one phone-specific rule kept: the PDF panel goes full-width in portrait,
   which tested well. Landscape PDF is handled in its own block below. */
@media (max-width: 600px) {
  #pdf_panel { width: 100%; min-width: 0; }
  #pdf_panel_header button { width: 44px; height: 44px; font-size: 16px; }
}

/* ---- PDF panel in landscape on a phone (Task #263 follow-up) ----
   A landscape phone is wider than 600px, so the portrait rule above does not
   apply and the panel was falling back to the narrow 42% (min 320px) desktop
   sidebar with tiny 26px controls, which field-tested as cramped, hard to tap,
   and running off the short screen. Give it a readable width, real 44px touch
   targets, and keep it fully inside the short visible height. Gated on a coarse
   pointer + short landscape height so desktop windows are never affected. */
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  #pdf_panel {
    width: 68%; min-width: 0;
    top: 0; bottom: 0; max-height: 100%;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  #pdf_panel_header { padding: 8px 12px; }
  #pdf_panel_header button { width: 44px; height: 44px; font-size: 16px; }
  #pdf_panel iframe { min-height: 0; }
}
