/* DUX Locate & Dig field demo. Phone-first; a desktop iPhone-style frame appears on large viewports only. */
:root {
  --primary: #1f55c9;          /* DUX office blue (locate-and-dig-ui.css); 6.6:1 with white */
  --brand: #3a71ff;            /* DUX logo blue; decorative only */
  --ink: #1c2430;
  --muted: #5b6676;
  --line: #e3e8ef;
  --bg: #f2f5fb;
  --card: #fff;
  --danger: #b02a37;
  --danger-bg: #fbe9eb;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 16px/1.4 var(--font); color: var(--ink); background: var(--bg); -webkit-text-size-adjust: 100%; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
/* Headings are focused by script after each screen change. Ring them only once the keyboard (Tab) has been used, and only around the text. */
h2[tabindex="-1"]:focus, .nav-title:focus { outline: none; }
body.kbd h2[tabindex="-1"]:focus-visible, body.kbd .nav-title:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.content h2:not(.sr-only) { width: fit-content; max-width: 100%; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: -999px; top: 0; z-index: 10; background: #fff; padding: 8px 12px; }
.skip-link:focus { left: 8px; top: 8px; }
.noscript { padding: 24px; }

/* Layout: edge-to-edge on phones */
.stage { height: 100%; }
.device { height: 100%; }
.app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; background: var(--bg); overflow: hidden; position: relative; }
.statusbar { display: none; }
.navbar { flex: none; display: grid; grid-template-columns: minmax(64px, 1fr) auto minmax(64px, 1fr); align-items: center; min-height: 48px; padding: env(safe-area-inset-top) calc(8px + env(safe-area-inset-right)) 0 calc(4px + env(safe-area-inset-left)); background: rgba(255, 255, 255, .96); border-bottom: 1px solid var(--line); }
.nav-title { grid-column: 2; font-size: 17px; font-weight: 600; text-align: center; max-width: 52vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; outline-offset: 0; }
.nav-back { grid-column: 1; justify-self: start; display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 10px; background: none; border: 0; color: var(--primary); font-size: 17px; }
.nav-action { grid-column: 3; justify-self: end; }
.nav-action button { min-height: 44px; padding: 0 10px; background: none; border: 0; color: var(--primary); font-size: 16px; }
.content { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px calc(16px + env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left)); outline: none; }
.content:has(> .auth) { padding: 0; }

/* Auth screens */
/* Mirrors OTPRequestView.xib / OTPValidateView.xib: systemGray5 page, logo above, white 16pt-radius card at the bottom with 16pt side and 37pt bottom margins. */
.app:has(.auth) { background: #e5e5ea; }
.auth { min-height: 100%; display: flex; flex-direction: column; align-items: center; gap: 32px; padding: calc(clamp(24px, 10vh, 104px) + env(safe-area-inset-top)) 16px calc(37px + env(safe-area-inset-bottom)); background: #e5e5ea; }
.auth-logo { flex: none; display: block; width: 38.4%; max-width: 159px; min-width: 120px; height: auto; aspect-ratio: 329 / 142; }
.auth-card { width: 100%; margin-top: auto; padding: 32px 16px 37px; border-radius: 16px; background: #fff; }
.auth-card h2 { font-size: 20px; line-height: 24px; font-weight: 700; }
.auth-card .lede { margin-top: 16px; font-size: 14px; line-height: 17px; color: #555; }
.auth-card .field { margin-top: 35px; }
.auth-card .field label { margin-bottom: 3px; font-size: 14px; line-height: 17px; color: var(--ink); }
.auth-card .field input { min-height: 44px; padding: 0 10px; border: 1px solid #c7c7cc; border-radius: 8px; font-size: 16px; }
.auth-card .field input.code { letter-spacing: normal; font-size: 16px; text-align: left; }
.auth-card .btn { min-height: 48px; margin-top: 28px; border-radius: 0; background: #007aff; font-size: 15px; }
.auth-card .btn.link { width: auto; min-height: 44px; margin: 0; padding: 0 4px; background: none; color: #007aff; font-size: 17px; font-weight: 400; }
.auth-card .form-error, .auth-card .notice { margin-top: 16px; }
.auth-card .again { display: flex; align-items: center; flex-wrap: wrap; margin-top: 16px; font-size: 14px; line-height: 17px; color: #555; }
.auth-card .again .btn.link { font-size: 14px; margin-left: 5px; }
.auth-card .btn.link.alt { margin-top: 12px; margin-left: 0; font-size: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--muted); }
.field input { width: 100%; min-height: 52px; padding: 0 14px; border: 1px solid #b9c3d3; border-radius: 12px; background: #fff; font-size: 18px; }
.field input.code { letter-spacing: .4em; font-size: 24px; text-align: center; font-variant-numeric: tabular-nums; }
.field input[aria-invalid="true"] { border-color: var(--danger); }
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 52px; padding: 0 18px; border: 0; border-radius: 12px; background: var(--primary); color: #fff; font-weight: 600; font-size: 17px; }
.btn[disabled] { opacity: .6; cursor: default; }
.btn.secondary { background: #fff; color: var(--primary); border: 1px solid #b9c3d3; }
.btn.link { background: none; color: var(--primary); min-height: 44px; font-weight: 500; }
.btn.inline { width: auto; min-height: 44px; }
.form-error, .notice { padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.form-error { background: var(--danger-bg); color: #7a1c26; }
.notice { background: #e8f0fb; color: #123b8c; }
.foot { font-size: 12px; color: var(--muted); text-align: center; }

/* Lists and cards */
.title-row { margin: 4px 0 12px; }
.title-row h2 { font-size: 26px; }
.sub { color: var(--muted); font-size: 14px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); min-height: 64px; }
.row:active { background: #f4f7fd; }
.row .grow { flex: 1 1 auto; min-width: 0; }
.row .name { display: block; font-weight: 600; overflow-wrap: anywhere; }
.row .meta { display: block; font-size: 13px; color: var(--muted); }
.row .chev { flex: none; color: #8a96a8; }
.badge { flex: none; display: inline-grid; place-items: center; min-width: 32px; height: 32px; padding: 0 6px; border-radius: 16px; background: #e8f0fb; color: var(--primary); font-weight: 700; font-size: 14px; }
.avatar { flex: none; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--primary); color: #fff; font-weight: 700; }

/* States */
.state { text-align: center; padding: 40px 16px; color: var(--muted); }
.state h3 { color: var(--ink); font-size: 18px; margin-bottom: 6px; }
.state .btn { margin-top: 16px; max-width: 220px; margin-inline: auto; }
.state.error h3 { color: var(--danger); }
.spinner { width: 28px; height: 28px; margin: 0 auto 12px; border: 3px solid #cfd9ee; border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Project view */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 3px; background: #e2e8f3; border-radius: 10px; }
.seg button { min-height: 38px; border: 0; border-radius: 8px; background: transparent; font-weight: 500; }
.seg button[aria-pressed="true"] { background: #fff; font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }
.toolbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.toolbar select { width: 100%; min-height: 44px; padding: 0 10px; border: 1px solid #b9c3d3; border-radius: 10px; background: #fff; }
.map-wrap { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background-color: #eef2f8; background-image: linear-gradient(#dfe6f1 1px, transparent 1px), linear-gradient(90deg, #dfe6f1 1px, transparent 1px); background-size: 32px 32px; }
/* Street-context tiles sit under the route layer and never take input. The chained selector beats maplibre-gl.css's `.maplibregl-map { position: relative }`. */
.map-wrap .map-base { position: absolute; inset: 0; pointer-events: none; }
.map-svg { position: relative; display: block; width: 100%; height: auto; aspect-ratio: 6 / 5; touch-action: none; user-select: none; -webkit-user-select: none; }
.map-svg text { font: 600 11px var(--font); fill: var(--ink); paint-order: stroke; stroke: #fff; stroke-width: 3px; stroke-linejoin: round; pointer-events: none; }
.map-sec { cursor: pointer; }
.map-sec .hit { fill: none; stroke: transparent; stroke-width: 24px; stroke-linecap: round; }
.map-sec .cas { fill: none; stroke: #fff; stroke-width: 9px; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.map-sec.sel .cas { stroke-width: 12px; }
.map-sec .vis { fill: none; stroke: #51627f; stroke-width: 5px; stroke-linecap: round; stroke-linejoin: round; }
.map-sec.sel .vis { stroke: var(--primary); stroke-width: 8px; }
.map-sec:focus { outline: none; }
.map-sec:focus-visible .vis { stroke: var(--brand); stroke-width: 9px; }
.map-node { fill: #fff; stroke: #51627f; stroke-width: 2.5px; pointer-events: none; }
.map-zoom { position: absolute; top: 8px; right: 8px; display: flex; flex-direction: column; gap: 6px; }
.map-zoom button { width: 44px; height: 44px; border-radius: 10px; border: 1px solid #b9c3d3; background: rgba(255, 255, 255, .95); font-size: 20px; line-height: 1; }
.map-note { position: absolute; left: 8px; bottom: 8px; right: 60px; padding: 4px 8px; border-radius: 6px; background: rgba(255, 255, 255, .92); font-size: 11px; color: var(--muted); }
.map-note a { color: inherit; text-decoration: underline; }
.map-scale path { fill: none; stroke: var(--ink); stroke-width: 2px; }
.row.sel { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.section-title { margin: 20px 0 8px; font-size: 18px; }
.detail { margin-top: 12px; padding: 14px; }
.detail h3 { font-size: 18px; }
.detail dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 10px 0 14px; font-size: 14px; }
.detail dt { color: var(--muted); }
.detail dd { margin: 0; }
.caveat { margin-top: 12px; font-size: 12px; color: var(--muted); }
details.tickets { margin-top: 16px; padding: 4px 14px; }
details.tickets summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 600; }
.tkt { padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.tkt b { display: block; }
.run-root { min-height: 100%; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.hint { margin-top: 6px; }
.more { margin-top: 12px; }
.caveat.in-card { margin: 4px 0 12px; }

/* Desktop: iPhone-style frame */
/* Every laptop width gets the frame (1280x720 included). Height adapts to the window, width follows it between 340 and 414px, and the screen scrolls inside. */
/* Width alone is not a desktop signal: a phone in landscape is 660-930px wide. The frame needs a primary mouse/trackpad (hover + fine pointer) and
   room for the 420px-tall frame plus padding (500px); phones in landscape are at most ~430px tall, so they stay edge to edge in both orientations. */
@media (min-width: 700px) and (min-height: 500px) and (hover: hover) and (pointer: fine) {
  body { background: radial-gradient(1200px 700px at 50% -10%, #dfe8ff, #b9c6e4 70%); }
  .stage { --dh: min(880px, calc(100vh - 48px)); display: grid; place-items: center; padding: 24px; min-height: 100%; height: auto; }
  @supports (height: 100dvh) { .stage { --dh: min(880px, calc(100dvh - 48px)); } }
  .device { position: relative; flex: none; width: clamp(340px, calc(var(--dh) * .47), 414px); height: var(--dh); min-height: 420px; padding: 12px; border-radius: 62px; background: #0f1115; box-shadow: 0 0 0 2px #3a3f4a, 0 40px 80px rgba(18, 30, 70, .45); }
  .device::before { content: ""; position: absolute; z-index: 5; top: 22px; left: 50%; width: 112px; height: 32px; margin-left: -56px; border-radius: 16px; background: #000; }
  .app { height: 100%; border-radius: 50px; }
  .statusbar { display: flex; flex: none; align-items: center; justify-content: space-between; height: 54px; padding: 8px 32px 0 36px; font-weight: 600; font-size: 15px; background: rgba(255, 255, 255, .96); }
  .statusbar-icons { display: inline-flex; gap: 6px; align-items: center; }
  .statusbar-icons i { display: block; background: var(--ink); border-radius: 2px; }
  .sb-signal { width: 17px; height: 11px; clip-path: polygon(0 100%, 0 70%, 25% 70%, 25% 100%, 37% 100%, 37% 45%, 62% 45%, 62% 100%, 75% 100%, 75% 0, 100% 0, 100% 100%); }
  .sb-wifi { width: 16px; height: 11px; border-radius: 8px 8px 2px 2px !important; clip-path: polygon(50% 100%, 0 25%, 20% 0, 80% 0, 100% 25%); }
  .sb-battery { width: 25px; height: 12px; border-radius: 4px !important; }
  .navbar { padding-top: 0; }
  .app:has(.auth) .statusbar { background: transparent; }
  .auth { padding-top: clamp(16px, 8vh, 72px); }
}
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } * { scroll-behavior: auto !important; } }
@media (forced-colors: active) { .map-sec .cas { stroke: Canvas; } .map-sec .vis { stroke: CanvasText; } .map-sec.sel .vis { stroke: Highlight; } .map-scale path { stroke: CanvasText; } .row.sel { border-color: Highlight; } }
