/* Apple-style and minimal: the system font, a plain white (or black) page, one blue action.
   The camera screen is pure black, like the iPhone Camera: frosted controls, a white shutter,
   yellow while working and green when the shot is right. */
:root {
  --bg: #ffffff;
  --bg-grouped: #f2f2f7;
  --surface: #ffffff;
  --label: #1d1d1f;
  --label-2: #6e6e73;
  --separator: rgba(60, 60, 67, 0.2);
  --fill: rgba(120, 120, 128, 0.12);
  --blue: #007aff;
  --green: #34c759;
  --orange: #ff9500;
  --red: #ff3b30;
  --cam-yellow: #ffd60a;
  --cam-green: #30d158;
  --cam-glass: rgba(28, 28, 30, 0.58);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Arabic", "Helvetica Neue", "Segoe UI", Roboto, "Noto Sans Arabic", "Geeza Pro", Tahoma, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-grouped: #000000;
    --surface: #1c1c1e;
    --label: #f5f5f7;
    --label-2: #98989d;
    --separator: rgba(84, 84, 88, 0.65);
    --fill: rgba(120, 120, 128, 0.24);
    --blue: #0a84ff;
    --green: #30d158;
    --orange: #ff9f0a;
    --red: #ff453a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--label);
  font: 400 17px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
body:has(#screen-done:not([hidden])) { background: var(--bg-grouped); }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 8px; }
h1, h2, h3, p { margin: 0; }
h1 { text-wrap: balance; }

/* ---------- Pages (start and done) ---------- */
.page {
  min-height: 100%; width: 100%; max-width: 480px; margin: 0 auto; display: flex; flex-direction: column;
  padding-block: max(8px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-bottom));
  padding-left: max(24px, env(safe-area-inset-left)); padding-right: max(24px, env(safe-area-inset-right));
}
.page-top { display: flex; justify-content: flex-end; min-height: 44px; align-items: center; }
.text-btn { color: var(--blue); font-size: 17px; padding: 10px 6px; border-radius: 8px; text-align: center; }
.text-btn.strong { font-weight: 600; }
.subtitle { font-size: 17px; line-height: 1.42; color: var(--label-2); text-wrap: pretty; }
.footnote { font-size: 13px; line-height: 1.4; color: var(--label-2); text-align: center; }
.btn-primary {
  width: 100%; min-height: 50px; padding: 14px 20px; border-radius: 14px;
  background: var(--blue); color: #fff; font-size: 17px; font-weight: 600;
  transition: opacity 0.15s, transform 0.15s;
}
.btn-primary:active { opacity: 0.82; transform: scale(0.985); }
.btn-primary:disabled { opacity: 0.5; cursor: progress; }

/* Start */
.start-main { flex: 1; display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 28px; }
.app-icon {
  width: 84px; height: 84px; border-radius: 19px; display: grid; place-items: center; margin-bottom: 26px;
  background: linear-gradient(180deg, #3a3a3c, #111113); box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
}
.app-icon svg { width: 62px; height: 62px; }
.start h1, .done h1 { font-size: 34px; line-height: 1.12; font-weight: 700; letter-spacing: -0.022em; }
[dir="rtl"] h1 { letter-spacing: 0; line-height: 1.3; }
.start .subtitle { margin-top: 12px; max-width: 24em; }
.features { list-style: none; margin: 44px 0 0; padding: 0; width: 100%; display: flex; flex-direction: column; gap: 26px; text-align: start; }
.features li { display: flex; gap: 16px; align-items: flex-start; }
.f-icon { flex: none; width: 38px; height: 38px; display: grid; place-items: center; color: var(--blue); }
.f-icon svg { width: 32px; height: 32px; }
.features h3 { font-size: 16px; font-weight: 600; line-height: 1.3; }
.features p { margin-top: 2px; font-size: 15px; line-height: 1.38; color: var(--label-2); }
.start-bottom { display: flex; flex-direction: column; gap: 4px; padding-top: 36px; }
.status { font-size: 15px; color: var(--label-2); text-align: center; padding-bottom: 8px; }
.status:empty { display: none; }
.status.error { color: var(--red); }
.start-bottom .footnote { margin-top: 4px; }

@media (min-width: 700px) and (min-height: 820px) {
  .page.start { min-height: 0; padding-top: 6vh; }
  .start-main { flex: none; }
}

/* Done */
.done-hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 16px 0 32px; }
.done-icon { width: 64px; height: 64px; color: var(--green); }
.done-icon.partial { color: var(--label-2); }
.done-icon svg { width: 100%; height: 100%; }
.done h1 { font-size: 28px; }
.section-label { font-size: 13px; font-weight: 400; color: var(--label-2); text-transform: uppercase; letter-spacing: 0.02em; padding: 0 16px 7px; }
[dir="rtl"] .section-label { letter-spacing: 0; }
.group { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: 12px; overflow: hidden; }
.group li { position: relative; }
.group li + li::before {
  content: ""; position: absolute; top: 0; inset-inline-start: 72px; inset-inline-end: 0; height: 1px;
  background: var(--separator); transform: scaleY(0.5);
}
.row { width: 100%; display: flex; align-items: center; gap: 12px; padding: 9px 16px; text-align: start; }
.row:active { background: var(--fill); }
.row-thumb { flex: none; width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--fill); display: grid; place-items: center; color: var(--label-2); }
.row-thumb svg { width: 22px; height: 22px; }
.row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-title { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 13px; color: var(--label-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-end { flex: none; display: flex; align-items: center; gap: 6px; font-size: 15px; color: var(--label-2); font-variant-numeric: tabular-nums; }
.row-end .i { width: 22px; height: 22px; display: grid; place-items: center; }
.row-end svg { width: 22px; height: 22px; }
.row-end .ok { color: var(--green); }
.row-end .warn { color: var(--orange); }
.row-end .chev { color: var(--label-2); opacity: 0.6; }
.row-end .chev svg { width: 18px; height: 18px; }
[dir="rtl"] .row-end .chev svg { transform: scaleX(-1); }
.group-foot { margin-top: 8px; }
.done-bottom {
  position: sticky; bottom: 0; margin-top: auto; display: flex; flex-direction: column; gap: 2px;
  padding: 24px 0 max(4px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg-grouped) 75%, transparent);
}
.toast {
  position: fixed; left: 50%; bottom: calc(110px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 48px); padding: 12px 18px; border-radius: 14px;
  background: rgba(30, 30, 32, 0.92); color: #fff; font-size: 15px; text-align: center; z-index: 40;
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
}

/* ---------- Camera ---------- */
.capture {
  position: fixed; inset: 0; background: #000; color: #fff;
  display: grid; grid-template-rows: minmax(0, 1fr) auto;
}
.stage { position: relative; overflow: hidden; background: #000; min-height: 0; min-width: 0; }
.stage video, .stage img.src { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
#overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.flash.go { animation: flash 0.3s ease-out; }
@keyframes flash { from { opacity: 0.8; } to { opacity: 0; } }

.glass, .round-btn, .title-pill, .instruction, .hint, .checks li, .hud {
  background: var(--cam-glass);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
}
.cam-top {
  position: absolute; top: 0; left: 0; right: 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) max(12px, env(safe-area-inset-right, 0px)) 0 max(12px, env(safe-area-inset-left, 0px));
}
.cam-top > .round-btn { justify-self: start; }
.cam-top-end { display: flex; gap: 8px; justify-content: flex-end; }
.round-btn { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.round-btn svg { width: 19px; height: 19px; }
#btn-aiview[aria-pressed="true"] { color: var(--cam-yellow); }
#btn-voice .off, #btn-voice[aria-pressed="false"] .on { display: none; }
#btn-voice[aria-pressed="false"] .off { display: block; }
.title-pill {
  min-width: 0; max-width: min(60vw, 340px); display: flex; flex-direction: column; align-items: center;
  padding: 6px 16px 7px; border-radius: 19px; line-height: 1.25;
}
.shot-name { max-width: 100%; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shot-count { font-size: 12px; color: rgba(255, 255, 255, 0.7); font-variant-numeric: tabular-nums; }
.shot-tip {
  position: absolute; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 64px); transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 48px); text-align: center; font-size: 13px; line-height: 1.35;
  color: rgba(255, 255, 255, 0.9); text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
}

.instruction {
  --dot: rgba(255, 255, 255, 0.6);
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 32px); display: flex; align-items: center; gap: 9px;
  padding: 10px 18px; border-radius: 999px; font-size: 15px; font-weight: 600; line-height: 1.3; text-align: center;
}
.instruction::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--dot); transition: background 0.2s; }
.instruction[data-state="bad"] { --dot: var(--cam-yellow); }
.instruction[data-state="ok"] { --dot: var(--cam-green); }
.instruction.nudge { animation: nudge 0.36s; }
@keyframes nudge {
  0%, 100% { transform: translateX(-50%); }
  25% { transform: translateX(calc(-50% - 6px)); }
  75% { transform: translateX(calc(-50% + 6px)); }
}
.hint {
  position: absolute; left: 50%; bottom: 64px; transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px);
  padding: 6px 12px; border-radius: 999px; font-size: 13px; color: var(--cam-yellow); text-align: center;
}
.ai-panel {
  position: absolute; left: max(12px, env(safe-area-inset-left, 0px)); bottom: 64px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px; max-width: calc(100% - 24px);
}
.capture:has(.hint:not([hidden])) .ai-panel { bottom: 104px; }
.checks { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.checks li {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 500; color: rgba(255, 255, 255, 0.65);
}
.checks li::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: rgba(255, 255, 255, 0.45); }
.checks li.ok { color: #fff; }
.checks li.ok::before { background: var(--cam-green); }
.checks li.bad::before { background: var(--cam-yellow); }
.checks li.na { opacity: 0.5; }
.hud { direction: ltr; padding: 7px 10px; border-radius: 10px; font: 11px/1.55 var(--mono); white-space: pre; font-variant-numeric: tabular-nums; }

/* Controls under the picture (beside it in landscape), like the iPhone Camera */
.controls {
  background: #000; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 14px max(22px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(22px, env(safe-area-inset-left, 0px));
}
.control-row { width: 100%; max-width: 420px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.map-slot { justify-self: start; }
.mini-map { width: 56px; height: auto; display: block; }
.thumb-btn {
  justify-self: end; width: 50px; height: 50px; border-radius: 10px; overflow: hidden;
  background: #1c1c1e; border: 1.5px solid rgba(255, 255, 255, 0.22);
}
.thumb-btn img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shutter { width: 76px; height: 76px; position: relative; display: grid; place-items: center; }
.shutter svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.shutter .ring-bg { fill: none; stroke: #fff; stroke-width: 4; }
.shutter .ring { fill: none; stroke: var(--cam-green); stroke-width: 4.5; stroke-linecap: round; stroke-dasharray: 226.2; stroke-dashoffset: 226.2; }
.shutter .core { width: 62px; height: 62px; border-radius: 50%; background: rgba(255, 255, 255, 0.32); transition: background 0.2s, transform 0.15s; }
.shutter.ready .core { background: #fff; }
.shutter:active .core { transform: scale(0.92); }
.control-links { display: flex; gap: 22px; align-items: center; min-height: 40px; }
.control-links .text-btn { color: rgba(255, 255, 255, 0.78); font-size: 15px; padding: 8px 4px; }
.control-links .accent, #btn-torch[aria-pressed="true"] { color: var(--cam-yellow); }

/* Mini map of where to stand */
.map { display: block; direction: ltr; }
.map .body { fill: rgba(255, 255, 255, 0.1); stroke: rgba(255, 255, 255, 0.5); stroke-width: 2.5; }
.map .glass { fill: none; stroke: rgba(255, 255, 255, 0.4); stroke-width: 2.5; stroke-linecap: round; }
.map .wheel { fill: rgba(255, 255, 255, 0.6); }
.map .lamp { fill: var(--cam-yellow); }
.map .tail { fill: #ff453a; }
.map .spot { fill: #000; stroke: rgba(255, 255, 255, 0.55); stroke-width: 2.5; }
.map .spot.done { fill: var(--cam-green); stroke: none; }
.map .spot.cur { fill: var(--cam-yellow); stroke: none; }
.map .pulse { fill: none; stroke: var(--cam-yellow); stroke-width: 3; transform-box: fill-box; transform-origin: center; animation: pulse 1.6s ease-out infinite; }
.map .aim { stroke: var(--cam-yellow); stroke-width: 3; stroke-dasharray: 5 5; }
.map .tick { fill: none; stroke: #000; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.map .you-halo { fill: rgba(10, 132, 255, 0.28); }
.map .you-core { fill: #0a84ff; stroke: #fff; stroke-width: 2.5; }
@keyframes pulse { from { transform: scale(1); opacity: 0.9; } to { transform: scale(2.4); opacity: 0; } }

/* Review after each photo: "Retake" / "Use Photo", as on iPhone */
.review { position: absolute; inset: 0; z-index: 20; background: #000; display: grid; grid-template-rows: minmax(0, 1fr) auto; }
.review img { width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.review-bar {
  position: relative; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
  padding: 14px max(16px, env(safe-area-inset-right, 0px)) calc(14px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
.review-bar .text-btn { color: #fff; }
#btn-retake { justify-self: start; }
#btn-next { justify-self: end; color: var(--cam-yellow); }
.review-count { position: absolute; top: 0; left: 0; right: 0; height: 2px; background: var(--cam-green); transform: scaleX(0); transform-origin: left center; }
[dir="rtl"] .review-count { transform-origin: right center; }
.review-count.counting { animation: count 1.8s linear forwards; }
@keyframes count { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.review-status { display: flex; flex-direction: column; align-items: center; gap: 1px; text-align: center; min-width: 0; }
.review-title { display: flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 600; color: #fff; }
.review-title svg { width: 18px; height: 18px; color: var(--cam-green); flex: none; }
.review-title.warn svg { color: var(--cam-yellow); }
.review-meta { font-size: 12px; color: rgba(255, 255, 255, 0.6); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }

/* All-photos sheet */
.sheet { position: absolute; inset: 0; z-index: 30; background: rgba(0, 0, 0, 0.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet-inner {
  width: min(520px, 100%); max-height: 86%; overflow: auto; background: #1c1c1e; color: #fff; border-radius: 14px 14px 0 0;
  padding: 7px max(16px, env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
.grabber { display: block; width: 36px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.3); margin: 0 auto 6px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 0 0 8px 4px; }
.sheet-head h2 { font-size: 17px; font-weight: 600; }
.sheet-head .text-btn { color: #0a84ff; }
.sheet-list { list-style: none; margin: 0; padding: 0; background: #2c2c2e; border-radius: 12px; overflow: hidden; }
.sheet-list li + li { border-top: 0.5px solid rgba(84, 84, 88, 0.65); }
.sheet-list button { width: 100%; min-height: 46px; display: flex; align-items: center; gap: 12px; padding: 10px 16px; text-align: start; }
.sheet-list button:active { background: rgba(255, 255, 255, 0.08); }
.sheet-list .n { width: 20px; flex: none; color: rgba(255, 255, 255, 0.5); font-variant-numeric: tabular-nums; }
.sheet-list .nm { flex: 1; min-width: 0; font-size: 16px; }
.sheet-list .st { flex: none; font-size: 13px; color: var(--cam-yellow); display: grid; place-items: center; }
.sheet-list .st svg { width: 20px; height: 20px; color: var(--cam-green); }

@media (orientation: landscape) {
  .capture { grid-template-rows: none; grid-template-columns: minmax(0, 1fr) auto; }
  .controls {
    flex-direction: column; justify-content: center; gap: 10px; width: 118px;
    padding: calc(10px + env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) 12px;
  }
  .control-row { display: flex; flex-direction: column; align-items: center; gap: 22px; width: auto; }
  .thumb-btn { order: 1; }
  .shutter { order: 2; }
  .map-slot { order: 3; }
  .control-links { flex-direction: column; gap: 0; min-height: 0; }
  .review-meta { max-width: 30vw; }
}
@media (orientation: landscape) and (max-height: 430px) {
  .control-row { gap: 14px; }
  .mini-map { width: 46px; }
  .thumb-btn { width: 42px; height: 42px; }
  .shot-tip { display: none; }
  .instruction { bottom: 10px; padding: 8px 14px; }
  .hint { bottom: 54px; }
  .ai-panel { bottom: 54px; }
}

@media (prefers-reduced-motion: reduce) {
  .map .pulse, .instruction.nudge, .flash.go { animation: none; }
  .review-count.counting { animation-duration: 0.01s; }
}
