/* ProScope Live: practical field UI. Light utility surfaces for planning
   screens, dark chrome around the viewfinder. High contrast, big targets. */

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --ink: #17202a;
  --ink-soft: #5b6770;
  --paper: #f7f8f9;
  --card: #ffffff;
  --line: #e3e7ea;
  --accent: #e8641b;
  --accent-dark: #c94f0e;
  --ok: #1f9d55;
  --warn: #e6a817;
  --bad: #d64545;
  --dark: #101418;
  --dark-2: #1b222a;
  font-size: 16px;
}

html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--paper);
  color: var(--ink);
  overscroll-behavior: none;
}

.hidden { display: none !important; }
.empty { color: var(--ink-soft); padding: 24px 8px; text-align: center; }
.hint { color: var(--ink-soft); font-size: 0.9rem; margin: 6px 0; }

.screen { min-height: 100vh; min-height: 100dvh; padding: env(safe-area-inset-top) 16px calc(env(safe-area-inset-bottom) + 16px); max-width: 900px; margin: 0 auto; }

/* ---------- buttons ---------- */
.btn-primary, .btn-secondary, .btn-mini {
  border: 0; border-radius: 12px; font-weight: 600; cursor: pointer;
  font-size: 1rem; padding: 12px 18px; text-decoration: none; display: inline-block; text-align: center;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:active { background: var(--accent-dark); }
.btn-secondary { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.btn-mini { padding: 6px 12px; font-size: 0.85rem; background: var(--accent); color: #fff; border-radius: 8px; }
.btn-big { width: 100%; padding: 18px; font-size: 1.15rem; }
button:disabled { opacity: 0.5; }

/* ---------- S1 home ---------- */
.home-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 0; }
.brand { font-weight: 800; font-size: 1.25rem; letter-spacing: -0.02em; }
.brand-mark { color: var(--accent); }
.sync-chip { font-size: 0.8rem; padding: 5px 10px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--ink-soft); }
.sync-chip.ok { color: var(--ok); border-color: #cdeeda; background: #effaf3; }
.sync-chip.off { color: var(--warn); border-color: #f4e3b6; background: #fdf6e4; }
.session-list { margin-top: 20px; display: flex; flex-direction: column; gap: 10px; }
.session-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; text-decoration: none; color: var(--ink); }
.sc-name { font-weight: 700; }
.sc-addr { color: var(--ink-soft); font-size: 0.9rem; margin-top: 2px; }
.sc-status { font-size: 0.78rem; margin-top: 8px; font-weight: 600; }
.st-in_progress { color: var(--accent); }
.st-review { color: var(--warn); }
.st-scoped { color: var(--ok); }

/* ---------- S2 setup ---------- */
.screen-head { display: flex; align-items: center; gap: 12px; padding: 14px 0; }
.screen-head h1 { font-size: 1.2rem; flex: 1; }
.back { font-size: 1.6rem; color: var(--ink); text-decoration: none; padding: 0 8px; }
.form { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.form label, .advanced label { display: flex; flex-direction: column; gap: 5px; font-size: 0.85rem; font-weight: 600; color: var(--ink-soft); }
input, select { padding: 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 1rem; background: var(--card); color: var(--ink); }
h2 { font-size: 1rem; margin: 14px 0 10px; }
.mode-cards { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 640px) { .mode-cards { grid-template-columns: repeat(3, 1fr); } }
.mode-card { background: var(--card); border: 1.5px solid var(--line); border-radius: 16px; padding: 18px 14px; text-align: left; cursor: pointer; }
.mode-card:active { border-color: var(--accent); }
.mc-icon { font-size: 1.6rem; }
.mc-name { font-weight: 800; margin: 6px 0 4px; }
.mc-desc { font-size: 0.85rem; color: var(--ink-soft); line-height: 1.35; }
.advanced { margin-top: 18px; color: var(--ink-soft); }
.advanced summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.advanced label { margin-top: 10px; }

/* ---------- S3 capture ---------- */
.screen.capture { padding: 0; max-width: none; background: var(--dark); position: fixed; inset: 0; overflow: hidden; }
#viewfinder { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.no-camera { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 14px; align-items: center; justify-content: center; color: #cfd6dc; padding: 30px; text-align: center; }
.cap-top { position: absolute; top: 0; left: 0; right: 0; padding: calc(env(safe-area-inset-top) + 12px) 12px 0; display: flex; flex-direction: column; gap: 8px; }
.instruction-card {
  background: rgba(16, 20, 24, 0.82); color: #fff; border-radius: 14px; padding: 14px 16px;
  font-size: 1.1rem; font-weight: 650; line-height: 1.35; backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.08);
}
.offline-banner { background: var(--warn); color: #3a2c00; font-weight: 700; font-size: 0.85rem; text-align: center; padding: 6px; border-radius: 8px; }
.hold-banner { background: var(--bad); color: #fff; font-weight: 700; font-size: 0.85rem; text-align: center; padding: 6px; border-radius: 8px; }
.cap-bottom {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 0 24px calc(env(safe-area-inset-bottom) + 22px);
  display: flex; align-items: center; justify-content: space-between;
}
.shutter {
  width: 76px; height: 76px; border-radius: 50%; border: 5px solid #fff;
  background: rgba(255,255,255,0.25); cursor: pointer;
}
.shutter:active { background: var(--accent); }
.mic-btn { width: 54px; height: 54px; border-radius: 50%; border: 0; font-size: 1.4rem; background: rgba(255,255,255,0.15); color: #fff; cursor: pointer; }
.mic-listening { background: var(--ok) !important; }
.mic-speaking { background: var(--accent) !important; }
.mic-muted { background: rgba(255,255,255,0.15); opacity: 0.7; }
.chip, .next-btn {
  background: rgba(255,255,255,0.15); color: #fff; border: 0; border-radius: 999px;
  padding: 12px 16px; font-size: 0.85rem; font-weight: 600; max-width: 130px; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.next-btn { background: var(--accent); font-size: 1rem; padding: 14px 22px; max-width: none; }
.filmstrip {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 6px; max-height: 55vh; overflow-y: auto;
}
.fs-item { position: relative; width: 52px; height: 52px; border-radius: 8px; overflow: hidden; border: 2px solid rgba(255,255,255,0.4); }
.fs-item img { width: 100%; height: 100%; object-fit: cover; }
.fs-badge {
  position: absolute; right: 2px; bottom: 2px; width: 16px; height: 16px; border-radius: 50%;
  font-size: 11px; line-height: 16px; text-align: center; color: #fff; background: var(--ink-soft);
}
.fs-item.v-pass .fs-badge { background: var(--ok); }
.fs-item.v-retake { border-color: var(--warn); }
.fs-item.v-retake .fs-badge { background: var(--warn); color: #3a2c00; }
.transcript-peek {
  position: absolute; bottom: 130px; left: 12px; right: 80px;
  background: rgba(16,20,24,0.85); border-radius: 12px; padding: 10px 12px; color: #dbe2e8;
  font-size: 0.82rem; max-height: 30vh; overflow-y: auto; backdrop-filter: blur(6px);
}
.tp-line { margin: 3px 0; }
.tp-assistant b { color: var(--accent); }
.tp-inspector b { color: var(--ok); }
.peek-toggle {
  position: absolute; bottom: 116px; left: 50%; transform: translateX(-50%);
  background: rgba(255,255,255,0.12); color: #fff; border: 0; border-radius: 999px;
  font-size: 0.7rem; padding: 4px 14px; cursor: pointer;
}
.cap-corner { position: absolute; top: calc(env(safe-area-inset-top) + 12px); right: 12px; display: flex; gap: 8px; z-index: 5; }
.corner-link { color: rgba(255,255,255,0.85); font-size: 0.75rem; text-decoration: none; background: rgba(16,20,24,0.6); padding: 5px 10px; border-radius: 999px; }
.screen.capture .cap-top { padding-right: 190px; }
.screen.capture.guided .filmstrip, .screen.capture.guided .peek-toggle { display: none; }
.screen.capture.guided .cap-top { padding-right: 12px; padding-top: calc(env(safe-area-inset-top) + 52px); }

/* ---------- S4 tree ---------- */
.tree-layout { display: flex; flex-direction: column; gap: 14px; }
.mode-b .tree-layout { display: grid; grid-template-columns: minmax(240px, 1fr) 2fr; gap: 16px; align-items: start; }
.tree-panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px; }
.detail-panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; min-height: 200px; }
.tree-node { padding: 9px 10px; border-radius: 8px; cursor: pointer; font-size: 0.95rem; }
.tree-node:hover { background: var(--paper); }
.tree-node.stage { margin-left: 20px; font-size: 0.88rem; color: var(--ink-soft); }
.tree-room summary { padding: 9px 10px; font-weight: 700; cursor: pointer; border-radius: 8px; list-style: none; }
.tree-room summary::-webkit-details-marker { display: none; }
.mark { display: inline-block; width: 20px; text-align: center; font-weight: 800; margin-right: 4px; }
.mark.done { color: var(--ok); }
.mark.issue { color: var(--warn); }
.mark.pending { color: var(--ink-soft); }
.mark.partial { color: var(--accent); }
.mark.skipped { color: var(--ink-soft); }
.mark.todo { color: #b9c2c9; }
.detail-status { font-size: 0.85rem; font-weight: 700; margin: 6px 0 12px; }
.detail-status.st-done { color: var(--ok); }
.detail-status.st-issue { color: var(--warn); }
.detail-status.st-partial, .detail-status.st-pending { color: var(--accent); }
.detail-status.st-todo, .detail-status.st-skipped { color: var(--ink-soft); }
.detail-thumbs, .acc-thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.acc-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 2px solid var(--line); }
.acc-thumb.v-pass { border-color: var(--ok); }
.acc-thumb.v-retake { border-color: var(--warn); }
.detail-narr { font-style: italic; color: var(--ink-soft); margin: 8px 0; }
.needed li { color: var(--warn); font-weight: 600; }
.detail-panel ul { padding-left: 20px; margin: 8px 0; }
.detail-panel h4 { margin-top: 12px; }
#jump-camera { margin-top: 14px; }
.tree-actions { display: flex; gap: 10px; margin-top: 16px; }
.tree-actions > * { flex: 1; }
#mode-switch { max-width: 150px; font-size: 0.85rem; padding: 8px; }

/* ---------- S5 review ---------- */
.review section { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 14px; }
.gap-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 0.92rem; }
.gap-item:last-child { border-bottom: 0; }
.gap-item.resolved { opacity: 0.55; }
.gap-done { color: var(--ok); font-weight: 800; }
.room-acc { border-bottom: 1px solid var(--line); padding: 6px 0; }
.room-acc summary { font-weight: 700; cursor: pointer; padding: 8px 0; }
.acc-meta { font-weight: 400; color: var(--ink-soft); font-size: 0.82rem; }
.acc-body { padding: 6px 0 12px; font-size: 0.92rem; }
.acc-body ul { padding-left: 20px; }
.scope-render { margin-top: 16px; line-height: 1.55; font-size: 0.95rem; }
.scope-render h2 { font-size: 1.2rem; margin: 18px 0 8px; }
.scope-render h3 { font-size: 1.05rem; margin: 14px 0 6px; }
.scope-render h4 { margin: 10px 0 4px; }
.scope-render ul { padding-left: 22px; margin: 6px 0; }
.scope-render .cite { color: var(--accent); font-weight: 600; font-size: 0.85em; }
.scope-actions { display: flex; gap: 10px; margin-top: 14px; }
#scope-status { margin-top: 10px; }

/* ---------- landing + auth ---------- */
.landing { display: flex; flex-direction: column; justify-content: center; min-height: 100dvh; gap: 40px; max-width: 460px; }
.landing-hero { text-align: center; }
.brand-lg { font-size: 2rem; }
.landing-tag { color: var(--ink-soft); margin-top: 10px; line-height: 1.45; }
.landing-actions { display: flex; flex-direction: column; gap: 12px; }
.center { text-align: center; display: block; }
.auth { max-width: 460px; }
.err { background: #fdecec; color: var(--bad); border-radius: 10px; padding: 10px 12px; font-size: 0.9rem; }

/* ---------- dashboard ---------- */
.dash-user { font-size: 0.85rem; color: var(--ink-soft); display: flex; align-items: center; gap: 8px; }
.btn-ghost { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; text-align: center; }
.stat-n { font-size: 1.5rem; font-weight: 800; color: var(--accent); }
.stat-l { font-size: 0.72rem; color: var(--ink-soft); font-weight: 600; margin-top: 2px; }
.dash-actions { display: flex; gap: 10px; margin-bottom: 6px; }
.dash-section { margin-top: 22px; }
.dash-section h2 { margin-bottom: 10px; }
.job-list { display: flex; flex-direction: column; gap: 8px; }
.tag-guest { font-size: 0.65rem; background: #eef4fb; color: #3568a8; padding: 2px 7px; border-radius: 999px; vertical-align: middle; font-weight: 700; }
.req-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin-bottom: 8px; font-size: 0.9rem; flex-wrap: wrap; }
.req-item .hint { display: block; }
.req-right { display: flex; align-items: center; gap: 10px; }
.req-code { font-family: ui-monospace, monospace; font-weight: 800; letter-spacing: 0.12em; background: var(--paper); border: 1px dashed var(--line); padding: 3px 8px; border-radius: 8px; }
.req-status { font-size: 0.75rem; font-weight: 700; }
.rs-sent { color: var(--ink-soft); }
.rs-opened { color: var(--warn); }
.rs-in_progress { color: var(--accent); }
.rs-complete { color: var(--ok); }
.code-banner { font-family: ui-monospace, monospace; font-size: 2rem; font-weight: 800; letter-spacing: 0.2em; text-align: center; padding: 18px; background: var(--paper); border: 2px dashed var(--accent); border-radius: 14px; margin: 12px 0; }

/* ---------- overlay ---------- */
.overlay { position: fixed; inset: 0; background: rgba(16,20,24,0.5); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.overlay-card { background: var(--card); border-radius: 18px; padding: 20px; width: 100%; max-width: 440px; max-height: 88vh; overflow-y: auto; }
.overlay-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.overlay-x { border: 0; background: transparent; font-size: 1.1rem; cursor: pointer; color: var(--ink-soft); }

/* ---------- floor plan ---------- */
.fp-wrap { margin: 10px 0; }
.floorplan { max-width: 100%; height: auto; }
.fp-room { fill: #f2ece2; stroke: var(--ink); stroke-width: 0.35; stroke-linejoin: round; }
.fp-dim { font-size: 1.4px; fill: var(--ink-soft); font-family: ui-monospace, monospace; }
.fp-name { font-size: 1.8px; fill: var(--ink); font-weight: 700; }
.fp-door { stroke: var(--card); stroke-width: 0.5; }
.fp-window { stroke: #3568a8; stroke-width: 0.55; }
.fp-opening { stroke: var(--card); stroke-width: 0.5; stroke-dasharray: 0.5 0.3; }
.fp-meta { font-size: 0.82rem; color: var(--ink-soft); margin-top: 6px; }

/* ---------- markdown tables ---------- */
.tbl-wrap { overflow-x: auto; margin: 10px 0; }
.scope-render table { border-collapse: collapse; font-size: 0.85rem; min-width: 480px; }
.scope-render th, .scope-render td { border: 1px solid var(--line); padding: 6px 9px; text-align: left; }
.scope-render th { background: var(--paper); }

@media print {
  body * { visibility: hidden; }
  .scope-render, .scope-render * { visibility: visible; }
  .scope-render { position: absolute; left: 0; top: 0; width: 100%; }
}
