/* ArchAngle Web — single-file CSS, mirrors iOS app palette */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #06060A;
  --surface: #111118;
  --surface-2: #1a1a24;
  --border: rgba(232, 52, 26, 0.18);
  --border-soft: rgba(255,255,255,0.08);
  --accent: #E8341A;
  --accent2: #FF6B2B;
  --text: #F0F0F5;
  --muted: #8888a0;
  --ok: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;

  --lm-M: #ef4444;
  --lm-N: #10b981;
  --lm-H: #3b82f6;
  --lm-F: #f59e0b;

  --max-w: 720px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* PREVIEW BANNER */
.preview-banner {
  background: rgba(245, 158, 11, 0.16);
  color: #fcd34d;
  font-size: 12px;
  font-weight: 500;
  text-align: center;
  padding: calc(6px + var(--safe-top)) 12px 6px;
  border-bottom: 1px solid rgba(245, 158, 11, 0.35);
  letter-spacing: 0.01em;
  line-height: 1.35;
}
.preview-banner + .top-bar {
  padding-top: 8px;
}

/* TOP BAR */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  padding: calc(8px + var(--safe-top)) 12px 8px;
  background: rgba(6,6,10,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
}

.icon-btn {
  background: transparent;
  color: var(--text);
  border: none;
  font-size: 22px;
  font-weight: 300;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn[hidden] { visibility: hidden; display: inline-block; }

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.brand-mark {
  color: var(--accent);
  font-size: 22px;
  font-weight: 600;
}
.brand-name {
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.01em;
}

/* ── MAIN ───────────────────────────── */
main {
  flex: 1;
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 20px 16px calc(24px + var(--safe-bot));
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: fadeIn .25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
h2 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-top: 4px;
}
h3 { font-size: 16px; font-weight: 600; margin-top: 8px; }

p { color: var(--text); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny  { font-size: 11px; }
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── BUTTONS ─────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: transform .08s, background .15s, opacity .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.05); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
}
.btn-ghost:hover { color: var(--text); }

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-block { width: 100%; }
.btn-row { display: flex; gap: 12px; }
.btn-row .btn { flex: 1; }

/* ── INPUTS ─────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.field input {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
}
.field input:focus { border-color: var(--accent); }

/* ── CARDS ─────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  padding: 16px;
}
.card-accent { border-color: var(--border); }

.disclaimer {
  border-left: 3px solid var(--accent);
  padding: 10px 12px;
  background: rgba(232, 52, 26, 0.06);
  font-size: 13px;
  color: var(--muted);
  border-radius: 6px;
}

/* ── STEP INDICATOR ─────────────────── */
.step-strip {
  display: flex;
  gap: 6px;
  margin: 0 0 4px 0;
}
.step-strip .pip {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--surface-2);
}
.step-strip .pip.done { background: var(--ok); }
.step-strip .pip.active { background: var(--accent); }

/* ── CAPTURE / LANDMARK CANVAS ─────── */
.capture-area {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  background: #000;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: center;
}
.capture-area video,
.capture-area img,
.capture-area canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.capture-empty {
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.foot-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.foot-overlay svg {
  width: 60%;
  height: 70%;
  opacity: 0.22;
  stroke: var(--accent);
  fill: none;
  stroke-width: 2;
}

.capture-actions {
  display: flex;
  gap: 12px;
  margin-top: 4px;
}

.capture-hint {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 12px 14px;
}

.capture-hint b { color: var(--accent2); }

/* ── LANDMARK PANEL ────────────────── */
.landmark-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  background: #000;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border-soft);
  touch-action: none;
}
.landmark-stage img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}
.landmark-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.landmark-legend {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  font-size: 13px;
}
.landmark-legend .item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
}
.landmark-legend .dot {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid white;
}
.landmark-legend .dot.placed { box-shadow: 0 0 0 2px var(--ok); }
.landmark-legend .label {
  font-weight: 700;
  width: 14px;
}
.landmark-legend .desc {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.angle-readout {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  background: var(--surface);
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
}
.angle-readout .num {
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent2);
}
.angle-readout .label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.warning {
  font-size: 13px;
  color: var(--warn);
  background: rgba(245, 158, 11, 0.08);
  border-left: 3px solid var(--warn);
  padding: 8px 12px;
  border-radius: 6px;
}

/* ── REPORT ─────────────────────────── */
.foot-summary {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  text-align: center;
}
.foot-summary .col .v {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.foot-summary .col .l {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 2px;
}

.foot-summary .col.delta .v { color: var(--accent2); }

.report-thumbs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}
.report-thumbs img {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
}
.report-thumbs .cap {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

/* INTERPRETATION PANEL */
.interp-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.interp-foot {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.interp-foot-label {
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.interp-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.interp-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.interp-pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}
.interp-pill.arch-high    { background: rgba(168, 85, 247, 0.15); color: #c4a5fa; border-color: rgba(168, 85, 247, 0.35); }
.interp-pill.arch-typical { background: rgba(16, 185, 129, 0.15); color: #6ee7b7; border-color: rgba(16, 185, 129, 0.35); }
.interp-pill.arch-low     { background: rgba(59, 130, 246, 0.15); color: #93c5fd; border-color: rgba(59, 130, 246, 0.35); }
.interp-pill.mob-limited     { background: rgba(245, 158, 11, 0.15); color: #fcd34d; border-color: rgba(245, 158, 11, 0.35); }
.interp-pill.mob-moderate    { background: rgba(232, 52, 26, 0.13); color: #ffa07c; border-color: rgba(232, 52, 26, 0.30); }
.interp-pill.mob-substantial { background: rgba(16, 185, 129, 0.15); color: #6ee7b7; border-color: rgba(16, 185, 129, 0.35); }
.interp-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
  flex: 1;
  min-width: 200px;
}
.interp-asym {
  background: rgba(245, 158, 11, 0.08);
  border-left: 3px solid var(--warn);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.5;
}
.interp-cta {
  background: rgba(232, 52, 26, 0.06);
  border-left: 3px solid var(--accent);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.5;
}

/* MODAL */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn .15s ease;
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 24px;
  max-width: 480px;
  width: 100%;
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
  flex-wrap: wrap;
}

/* ── TOAST ──────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(20px + var(--safe-bot));
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  z-index: 300;
  font-size: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  animation: toastIn .2s ease;
}
.toast[hidden] { display: none; }
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ── UTILS ──────────────────────────── */
.row { display: flex; gap: 10px; align-items: center; }
.spacer { flex: 1; }
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }

ul { padding-left: 18px; }
ol { padding-left: 22px; }
li { margin: 4px 0; }

@media (max-width: 480px) {
  h1 { font-size: 24px; }
  h2 { font-size: 18px; }
  .landmark-legend { grid-template-columns: 1fr; }
}
