/* Cityeye citizen app. Tokens from "Cityeye visuella riktlinjer" v1.0 (Oct 2026).
   Use the token names below; never hex codes in components. */

:root {
  /* Color: light theme */
  --surface: #F5F9FA;
  --surface-raised: #FFFFFF;
  --surface-sunken: #E8F2F2;
  --line: #D3E2E6;
  --line-strong: #6A8396;
  --ink: #0E2A47;
  --ink-muted: #4A6380;
  --navy: #0E2A47;
  --teal: #0D9488;
  --teal-strong: #0B7A70;
  --teal-soft: #CCF1EB;
  --teal-ink: #0B6B62;
  --on-teal: #FFFFFF;
  --iris-light: #2DD4BF;
  --sun: #FFC145;
  --sun-soft: #FFF1CF;
  --sun-ink: #8A5D00;
  --alert: #D9483B;
  --alert-soft: #FBE1DD;
  --alert-ink: #A3281E;
  --status-new: var(--alert);
  --status-progress: var(--sun);
  --status-done: var(--teal);
  --focus-ring: var(--teal-strong);
  --scrim: rgba(14, 42, 71, 0.45);

  /* Type */
  --font-display: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-body: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Space (4px grid) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-12: 3rem;

  /* Sizes */
  --tap-target: 48px;
  --icon-md: 24px;
  --icon-sm: 16px;
  --tabbar-height: 64px;
  --fab-size: 64px;
  --thumb-size: 72px;

  /* Shape */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-pill: 999px;
  --shadow-card: 0 4px 16px rgba(14, 42, 71, 0.14);
  --shadow-sheet: 0 -8px 32px rgba(14, 42, 71, 0.2);

  /* Motion */
  --ease: ease-out;
  --dur: 200ms;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --surface: #0A1828;
    --surface-raised: #11253A;
    --surface-sunken: #163049;
    --line: #22405C;
    --line-strong: #58799A;
    --ink: #EAF2F8;
    --ink-muted: #9FB6CB;
    --navy: #0F2E4A;
    --teal: #2DD4BF;
    --teal-strong: #5EE6D3;
    --teal-soft: #0F3F45;
    --teal-ink: #5EE6D3;
    --on-teal: #062421;
    --sun-soft: #3A3115;
    --sun-ink: #FFC145;
    --alert: #FF7A6B;
    --alert-soft: #43201E;
    --alert-ink: #FF9A8D;
    --scrim: rgba(0, 0, 0, 0.6);
    --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.45);
    --shadow-sheet: 0 -8px 32px rgba(0, 0, 0, 0.5);
  }
}

/* ---------- Base ---------- */

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  display: flex; flex-direction: column; height: 100dvh;
  background: var(--surface); color: var(--ink);
  font: 400 0.9375rem/1.375rem var(--font-body); /* body 15/22 */
  -webkit-font-smoothing: antialiased;
}
p { margin: 0; }
button { font: inherit; color: inherit; }
.list-reset { list-style: none; margin: 0; padding: 0; }
.pad { padding-left: var(--space-4); padding-right: var(--space-4); }
.stack { display: flex; flex-direction: column; gap: var(--space-4); }
/* The hidden attribute must always win over a class display rule (review MR !2, B1). */
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* ---------- Typography ---------- */

.display { font: 800 2.125rem/2.375rem var(--font-display); letter-spacing: -0.02em; }
.title-1 { font: 700 1.75rem/2.125rem var(--font-display); letter-spacing: -0.015em; margin: 0; }
.title-2 { font: 600 1.375rem/1.75rem var(--font-display); margin: 0 0 var(--space-3); }
.title-3 { font: 600 1.125rem/1.5rem var(--font-display); margin: 0; }
.eyebrow { font: 600 0.75rem/1rem var(--font-display); letter-spacing: 0.08em; text-transform: uppercase; color: var(--teal-strong); }
.body-lg { font: 400 1.0625rem/1.625rem var(--font-body); }
.body { font: 400 0.9375rem/1.375rem var(--font-body); }
.body-strong { font: 700 0.9375rem/1.375rem var(--font-body); }
.caption { font: 400 0.8125rem/1.125rem var(--font-body); color: var(--ink-muted); }
.data { font: 500 0.8125rem/1.125rem var(--font-mono); }

/* ---------- Icons (Lucide, inherit currentColor) ---------- */

.ic {
  display: inline-block; flex: none; width: var(--icon-md); height: var(--icon-md);
  background-color: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat;
}
.ic-sm { width: var(--icon-sm); height: var(--icon-sm); }
.ic-lg { width: 40px; height: 40px; }

/* ---------- Layout ---------- */

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(var(--space-2) + env(safe-area-inset-top)) var(--space-4) var(--space-2);
  background: var(--surface-raised); border-bottom: 1px solid var(--line);
}
.brand { width: 32px; height: 32px; }
.points-pill {
  display: inline-flex; align-items: center; gap: var(--space-1);
  background: var(--sun-soft); color: var(--sun-ink);
  font: 700 0.8125rem/1rem var(--font-body); padding: var(--space-1) var(--space-3); border-radius: var(--radius-pill);
}

main { flex: 1; position: relative; overflow: hidden; }
.view {
  display: none; position: absolute; inset: 0; overflow-y: auto;
  padding-bottom: calc(var(--tabbar-height) + var(--space-12) + env(safe-area-inset-bottom));
}
.view.active { display: block; animation: fade 200ms var(--ease); }
.view-head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); padding: var(--space-4) var(--space-4) var(--space-3); }

#view-map.active { display: flex; flex-direction: column; padding-bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom)); }
#map { flex: 1; min-height: 200px; background: var(--surface-sunken); }

.card { background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-lg); margin: 0 var(--space-4) var(--space-6); }
.pad-card { padding: var(--space-4); }
.empty { margin-top: var(--space-8); color: var(--ink-muted); }

/* ---------- Buttons ---------- */

.ce-btn-primary, .ce-btn-secondary, .ce-btn-text {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--tap-target); padding: 0 var(--space-5); border-radius: var(--radius-pill);
  font: 600 1rem/1.25rem var(--font-display); cursor: pointer; text-decoration: none;
  transition: filter var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.ce-btn-primary { background: var(--teal-strong); color: var(--on-teal); border: 0; }
.ce-btn-primary:hover { filter: brightness(1.08); }
.ce-btn-secondary { background: transparent; color: var(--ink); border: 1.5px solid var(--line-strong); }
.ce-btn-text { background: transparent; color: var(--teal-strong); border: 0; padding: 0 var(--space-2); }
.ce-btn-block { display: flex; width: 100%; }
.ce-btn-primary:disabled { background: var(--surface-sunken); color: var(--ink-muted); cursor: not-allowed; filter: none; }
.back { margin: var(--space-3) var(--space-2) 0; }
@media (min-width: 640px) { .view:not(#view-map) > .back { display: flex; width: 100%; justify-content: flex-start; } }

.icon-btn {
  flex: none; width: var(--tap-target); height: var(--tap-target); border: 0; border-radius: 50%;
  display: grid; place-items: center; background: var(--teal-strong); color: var(--on-teal); cursor: pointer;
}
.icon-btn:disabled { background: var(--surface-sunken); color: var(--ink-muted); }

/* ---------- Fields ---------- */

.field { display: flex; flex-direction: column; gap: var(--space-2); }
.field-label { font: 700 0.9375rem/1.375rem var(--font-body); }
textarea, input:not([type="file"]) {
  width: 100%; min-height: var(--tap-target); padding: var(--space-3);
  font: 400 1rem/1.5rem var(--font-body); /* 16px: iPhone does not zoom */
  color: var(--ink); background: var(--surface-raised);
  border: 1.5px solid var(--line-strong); border-radius: var(--radius-md);
}
textarea { resize: vertical; }
[aria-invalid="true"] { border-color: var(--alert); }
[aria-invalid="true"] + .caption { color: var(--alert-ink); }
.error-box { background: var(--alert-soft); color: var(--alert-ink); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); }

.photo-pick {
  display: grid; place-items: center; aspect-ratio: 4 / 3; overflow: hidden; cursor: pointer;
  background: var(--surface-sunken); border: 1.5px dashed var(--line-strong); border-radius: var(--radius-lg);
}
.photo-pick:focus-within { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.photo-pick img { width: 100%; height: 100%; object-fit: cover; }
.photo-hint { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); color: var(--teal-strong); font: 600 1rem/1.25rem var(--font-display); }
#mini-map { height: 180px; border-radius: var(--radius-md); border: 1px solid var(--line); background: var(--surface-sunken); }

/* ---------- Chips ---------- */

.ce-chip {
  display: inline-flex; align-items: center; gap: var(--space-1);
  font: 700 0.75rem/1rem var(--font-body); padding: var(--space-1) var(--space-3); border-radius: var(--radius-pill);
  white-space: nowrap; border: 0;
}
.ce-chip-new { background: var(--alert-soft); color: var(--alert-ink); }
.ce-chip-progress { background: var(--sun-soft); color: var(--sun-ink); }
.ce-chip-done { background: var(--teal-soft); color: var(--teal-ink); }
.ce-chip-neutral { background: var(--surface-sunken); color: var(--ink); }
.chip-row { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-2); }
/* A tappable chip: 32px visible, tap area extended to tap-target. */
.chip-btn { position: relative; cursor: pointer; min-height: 32px; font-size: 0.8125rem; }
.chip-btn::after { content: ""; position: absolute; inset: -8px -4px; }

.category-group { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: var(--space-3) 0; }
.ce-category-chip {
  position: relative; display: inline-flex; align-items: center; gap: var(--space-2); min-height: 32px;
  padding: var(--space-1) var(--space-3) var(--space-1) var(--space-1);
  background: var(--surface-raised); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius-pill);
  font: 400 0.9375rem/1.25rem var(--font-body); cursor: pointer;
}
.ce-category-chip::after { content: ""; position: absolute; inset: -8px -2px; }
.ce-category-chip .well { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--teal-soft); color: var(--teal-ink); }
.ce-category-chip[aria-pressed="true"] { background: var(--teal-soft); border-color: var(--teal-strong); color: var(--teal-ink); }

/* ---------- Report card ---------- */

.ce-report-card {
  display: grid; grid-template-columns: var(--thumb-size) 1fr auto; gap: var(--space-3); align-items: start;
  padding: var(--space-3); background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-lg);
  cursor: pointer; min-height: var(--tap-target);
}
.thumb {
  width: var(--thumb-size); height: var(--thumb-size); border-radius: var(--radius-sm); overflow: hidden;
  display: grid; place-items: center; background: var(--surface-sunken); color: var(--ink-muted);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.ce-report-card .meta { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ce-report-card .desc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.due { color: var(--ink-muted); }
.due.late { color: var(--alert-ink); font-weight: 700; }
.unread { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; margin-left: var(--space-1); border-radius: var(--radius-pill); background: var(--alert-soft); color: var(--alert-ink); font: 700 0.75rem/1 var(--font-body); }

/* ---------- Detail ---------- */

.detail-img {
  aspect-ratio: 4 / 3; border-radius: var(--radius-lg); background: var(--surface-sunken); color: var(--ink-muted);
  display: grid; place-items: center; align-content: center; gap: var(--space-2); margin: var(--space-3) 0;
}
.detail-meta { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-6); }
.feedback-msg { background: var(--teal-soft); color: var(--teal-ink); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); margin-bottom: var(--space-2); }
.due-box { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); }
.due-box .days { text-align: center; color: var(--teal-strong); font: 700 1.75rem/2rem var(--font-display); }
.due-box .days small { display: block; font: 400 0.8125rem/1.125rem var(--font-body); color: var(--ink-muted); }
.due-box.late .days { color: var(--alert-ink); }

/* ---------- Chat ---------- */

.chat-list { display: flex; flex-direction: column; gap: var(--space-2); max-height: 320px; overflow-y: auto; margin: var(--space-3) 0; }
.chat-list li { max-width: 85%; padding: var(--space-2) var(--space-3); border-radius: var(--radius-lg); }
.chat-list li.citizen { align-self: flex-end; background: var(--teal-strong); color: var(--on-teal); border-bottom-right-radius: var(--space-1); }
.chat-list li.municipality { align-self: flex-start; background: var(--surface-sunken); color: var(--ink); border-bottom-left-radius: var(--space-1); }
.chat-list small { display: block; font: 400 0.75rem/1rem var(--font-body); opacity: 0.85; margin-top: 2px; }
.chat-form { display: flex; gap: var(--space-2); align-items: center; }
.chat-form input { border-radius: var(--radius-pill); padding: 0 var(--space-4); }

/* ---------- Missions ---------- */

.ce-mission-card { margin: 0 var(--space-4); padding: var(--space-4); background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-lg); display: flex; flex-direction: column; gap: var(--space-2); }
.ce-mission-card .text { color: var(--ink-muted); }
.progress { height: 8px; background: var(--surface-sunken); border-radius: var(--radius-pill); overflow: hidden; margin: var(--space-2) 0; }
.progress > div { height: 100%; width: 0; background: var(--teal); border-radius: var(--radius-pill); transition: width 250ms var(--ease); }
.mission-foot { display: flex; justify-content: space-between; align-items: center; }
.reward { display: inline-flex; align-items: center; gap: var(--space-2); font-weight: 700; color: var(--ink); }
.sun-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--sun); }

/* ---------- Profile badges ---------- */

.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--space-3); margin-bottom: var(--space-6); }
.badges li { background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-3); text-align: center; display: flex; flex-direction: column; align-items: center; gap: var(--space-1); }
.badge-ic { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--sun); color: var(--navy); }
.badges li.locked .badge-ic { background: var(--surface-sunken); color: var(--ink-muted); }
.badges li.locked .title-3 { color: var(--ink-muted); }

/* ---------- Tab bar ---------- */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000;
  height: calc(var(--tabbar-height) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  background: var(--surface-raised); border-top: 1px solid var(--line);
}
.tabbar button {
  min-height: var(--tap-target); background: none; border: 0; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--ink-muted); font: 400 0.6875rem/0.875rem var(--font-body);
}
.tabbar button[aria-current="page"] { color: var(--teal-strong); font-weight: 700; }
.tabbar .fab {
  justify-self: center; width: var(--fab-size); height: var(--fab-size); margin-top: -28px; border-radius: 50%;
  display: grid; place-items: center; background: var(--teal-strong); color: var(--on-teal);
  box-shadow: var(--shadow-card), 0 0 0 6px var(--surface-raised);
}
.tabbar .fab[aria-current="page"] { color: var(--on-teal); }

/* ---------- Sheets and dialogs ---------- */

dialog.sheet {
  position: fixed; inset: auto 0 0 0; margin: 0; width: 100%; max-width: 560px; margin-inline: auto;
  max-height: 90dvh; overflow-y: auto; border: 0; color: var(--ink); background: var(--surface-raised);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0; box-shadow: var(--shadow-sheet);
  padding: var(--space-3) var(--space-5) calc(var(--space-5) + env(safe-area-inset-bottom));
}
dialog.sheet[open] { animation: sheet-up 250ms var(--ease); display: flex; flex-direction: column; gap: var(--space-2); }
dialog.sheet::backdrop { background: var(--scrim); }
.sheet-handle { width: 40px; height: 4px; border-radius: var(--radius-pill); background: var(--line-strong); margin: 0 auto var(--space-3); }
.report-no { font-size: 1.125rem; color: var(--ink); margin-bottom: var(--space-3); }

/* ---------- Toasts (PointsToast) ---------- */

.toasts {
  position: fixed; z-index: 2000; left: var(--space-4); right: var(--space-4);
  top: calc(env(safe-area-inset-top) + var(--space-3)); display: flex; flex-direction: column; gap: var(--space-2); pointer-events: none;
}
.ce-toast {
  pointer-events: auto; display: flex; gap: var(--space-3); align-items: center; cursor: pointer;
  padding: var(--space-3); background: var(--surface-raised); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-card);
  animation: toast-in 200ms var(--ease);
}
.ce-toast .tile { flex: none; width: 44px; height: 44px; border-radius: var(--radius-md); display: grid; place-items: center; background: var(--surface-sunken); color: var(--ink); }
.ce-toast-points .tile { background: var(--sun); color: var(--navy); }
.ce-toast-done .tile { background: var(--teal-soft); color: var(--teal-ink); }
.ce-toast-info .tile { background: var(--teal-soft); color: var(--teal-ink); }
.ce-toast .t { font: 600 1rem/1.25rem var(--font-display); }
.ce-toast.leaving { opacity: 0; transform: translateY(-8px); transition: opacity 200ms var(--ease), transform 200ms var(--ease); }

/* The one celebration: a short bounce on the badge and a sun pulse. */
.celebrate .tile { animation: bounce 600ms var(--ease), pulse 900ms var(--ease); }

/* ---------- Map pins ---------- */

.pin { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: var(--on-teal); border: 2px solid var(--surface-raised); box-shadow: var(--shadow-card); }
.pin.s-received { background: var(--status-new); }
.pin.s-in_progress { background: var(--status-progress); color: var(--navy); }
.pin.s-fixed { background: var(--status-done); }
.pin.s-rejected { background: var(--line-strong); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface-raised); color: var(--ink); border-radius: var(--radius-lg); }
.leaflet-popup-content { font: 400 0.9375rem/1.375rem var(--font-body); margin: var(--space-3) var(--space-4); }
.leaflet-container { font-family: var(--font-body); }

/* ---------- Motion ---------- */

@keyframes fade { from { opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }
@keyframes bounce { 0%, 100% { transform: scale(1); } 40% { transform: scale(1.18); } 70% { transform: scale(0.95); } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 var(--sun); } 100% { box-shadow: 0 0 0 14px transparent; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}

/* "Du är här" dot on the map (CSS wins over Leaflet's SVG attributes). */
.you-dot { stroke: var(--surface-raised); fill: var(--teal-strong); }

/* Toast container as a manual popover (top layer). Reset the UA popover style. */
.toasts[popover] {
  inset: auto; top: calc(env(safe-area-inset-top) + var(--space-3)); left: var(--space-4); right: var(--space-4);
  width: auto; height: auto; margin: 0; padding: 0; border: 0; background: transparent; overflow: visible; color: inherit;
}
.toasts[popover]:not(:popover-open) { display: none; }
.toasts[popover]:popover-open { display: flex; }

/* ---------- GDPR and safety parts ---------- */

.safety { display: flex; align-items: flex-start; gap: var(--space-2); color: var(--ink); background: var(--sun-soft); padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); }
.safety .ic { color: var(--sun-ink); margin-top: 1px; }
.btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.photo-canvas { display: block; width: 100%; height: auto; border-radius: var(--radius-lg); background: var(--surface-sunken); cursor: crosshair; touch-action: manipulation; }
.photo-edit[hidden], .photo-pick[hidden] { display: none; }

.sheet-tall { gap: var(--space-3) !important; }
.privacy-list { margin: 0; padding-left: var(--space-5); display: flex; flex-direction: column; gap: var(--space-2); }
.check-row { display: flex; align-items: center; gap: var(--space-3); min-height: var(--tap-target); cursor: pointer; }
.check-row input { width: 24px; height: 24px; min-height: 0; accent-color: var(--teal-strong); }

.danger { color: var(--alert-ink); }
.ce-btn-primary.danger-fill { background: var(--alert-ink); color: var(--surface-raised); }

/* ---------- Phone layouts (F1) ---------- */

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
img, canvas, svg { max-width: 100%; }
.title-1, .title-2, .title-3, .body, .body-lg, .data { overflow-wrap: anywhere; }

/* Map pins: 48 px tap area (tap-target), the visible pin is 32 px. */
.pin-hit { display: grid; place-items: center; }
.place-pin { color: var(--teal-strong); filter: drop-shadow(0 2px 2px rgba(14, 42, 71, 0.35)); }
.place-pin .ic { width: 40px; height: 40px; }

/* Notch and rounded corners in landscape. */
.topbar, .tabbar { padding-left: max(var(--space-4), env(safe-area-inset-left)); padding-right: max(var(--space-4), env(safe-area-inset-right)); }
.view { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }

/* On-screen keyboard open (touch screen + focused text field): hide the tab bar. */
body.kb-open .tabbar { display: none; }
body.kb-open .view { padding-bottom: var(--space-4); }

/* Wide screens (large phones in landscape, tablets): one readable column.
   The map view keeps the full width. */
@media (min-width: 640px) {
  .view:not(#view-map) > * { max-width: 600px; margin-left: auto; margin-right: auto; }
}

/* Small phones (320-359 px). */
@media (max-width: 359px) {
  .tabbar { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
  .tabbar button { font-size: 0.625rem; }
  .pad, .view-head { padding-left: var(--space-3); padding-right: var(--space-3); }
  .ce-report-card { grid-template-columns: 56px 1fr; }
  .ce-report-card .thumb { width: 56px; height: 56px; }
  .ce-report-card > .ce-chip { grid-column: 2; justify-self: start; }
}

/* Landscape on a phone: little height. The tokens change on :root, so the views
   reserve the same height as the lower tab bar. */
@media (orientation: landscape) and (max-height: 500px) {
  :root { --tabbar-height: 52px; --fab-size: 52px; }
  .view-head { padding-top: var(--space-2); padding-bottom: var(--space-2); }
  .photo-pick { aspect-ratio: auto; height: 50dvh; }
  .photo-canvas { max-height: 60dvh; width: auto; margin: 0 auto; }
  .detail-img { aspect-ratio: auto; height: 40dvh; }
  #mini-map { height: 45dvh; }
  .tabbar button { flex-direction: row; gap: var(--space-2); }
  .tabbar .fab { margin-top: -12px; }
  dialog.sheet { max-height: 96dvh; }
  .display { font-size: 1.75rem; line-height: 2rem; }
}

/* ---------- Findings F2-F16 ---------- */

.topbar-end { display: flex; align-items: center; gap: var(--space-2); }

/* Map with the "near you" card and the tile message (F3, F14). */
.map-wrap { position: relative; flex: 1; min-height: 200px; }
.map-wrap #map { position: absolute; inset: 0; }
.near-card {
  position: absolute; z-index: 500; top: var(--space-3); left: var(--space-4); right: var(--space-4);
  display: flex; gap: var(--space-3); align-items: center; padding: var(--space-3);
  background: var(--surface-raised); border-radius: var(--radius-lg); box-shadow: var(--shadow-card);
}
.near-ic { flex: none; width: 40px; height: 40px; border-radius: var(--radius-md); display: grid; place-items: center; background: var(--teal-soft); color: var(--teal-ink); }
.map-msg {
  position: absolute; z-index: 500; bottom: var(--space-4); left: var(--space-4); right: var(--space-4);
  padding: var(--space-3) var(--space-4); background: var(--alert-soft); color: var(--alert-ink);
  border-radius: var(--radius-md); box-shadow: var(--shadow-card);
}
.map-fail { display: grid; place-items: center; height: 100%; padding: var(--space-6); text-align: center; color: var(--ink-muted); }
.pin.own { outline: 3px solid var(--teal-strong); outline-offset: 1px; }
.pin.s-verified { background: var(--line-strong); }

/* Photo quality (F4). */
.quality-box { display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-3) var(--space-4); background: var(--sun-soft); color: var(--sun-ink); border-radius: var(--radius-md); }
.quality-box .body { color: var(--ink); }

/* Follow-up questions (F5) and the duplicate question (F2) in the confirm sheet. */
.followups { display: flex; flex-direction: column; gap: var(--space-3); margin: var(--space-2) 0; }
.followup .chip-row { margin-top: var(--space-2); }
.ce-category-chip.answer, .ce-category-chip.quick { padding: var(--space-1) var(--space-3); }
.dup-box { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-4); background: var(--teal-soft); color: var(--teal-ink); border-radius: var(--radius-lg); }
.dup-box .body { color: var(--ink); }
.dup-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }

/* Reminders and the tab dot (F8). */
.reminders { margin-bottom: var(--space-4); }
.reminders:empty { display: none; }
.reminder { display: flex; gap: var(--space-3); align-items: center; padding: var(--space-3); border-radius: var(--radius-lg); cursor: pointer; min-height: var(--tap-target); }
.reminder .tile { flex: none; width: 40px; height: 40px; border-radius: var(--radius-md); display: grid; place-items: center; }
.reminder.late { background: var(--alert-soft); color: var(--alert-ink); }
.reminder.late .tile { background: var(--surface-raised); color: var(--alert-ink); }
.reminder.done { background: var(--teal-soft); color: var(--teal-ink); }
.reminder.done .tile { background: var(--surface-raised); color: var(--teal-ink); }
.reminder .caption { color: inherit; }
.tabbar button { position: relative; }
.tab-dot { position: absolute; top: 6px; left: calc(50% + 8px); width: 10px; height: 10px; border-radius: 50%; background: var(--alert); border: 2px solid var(--surface-raised); }

/* Detail: answers, verify card, timeline, place map (F5, F6, F7, F10). */
.answers { margin: 0; display: grid; gap: var(--space-2); }
.answers dd { margin: 0; }
.verify-card { border-color: var(--teal-strong); }
.verify-done { margin: 0 var(--space-4) var(--space-6); }
.timeline { display: flex; flex-direction: column; }
.timeline .step { display: grid; grid-template-columns: 28px 1fr; gap: var(--space-3); position: relative; padding-bottom: var(--space-4); }
.timeline .step:not(:last-child)::before { content: ""; position: absolute; left: 13px; top: 28px; bottom: 0; width: 2px; background: var(--line); }
.timeline .step.done:not(:last-child)::before { background: var(--teal); }
.timeline .dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--line-strong); background: var(--surface-raised); color: var(--on-teal); }
.timeline .step.done .dot { background: var(--teal-strong); border-color: var(--teal-strong); }
.timeline .step.current .body-strong { color: var(--teal-strong); }
.detail-map { height: 160px; border-radius: var(--radius-md); border: 1px solid var(--line); background: var(--surface-sunken); margin-bottom: var(--space-3); }

/* Profile statistics and points table (F13). */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-2); margin-bottom: var(--space-6); }
.stats li { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: var(--space-3) var(--space-1); background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-lg); text-align: center; }
.stat-n { font: 700 1.375rem/1.75rem var(--font-display); color: var(--ink); }
@media (max-width: 359px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.points-table { width: 100%; border-collapse: collapse; }
.points-table td { padding: var(--space-2) 0; border-bottom: 1px solid var(--line); }
.points-table td:last-child { text-align: right; white-space: nowrap; color: var(--sun-ink); }

/* Live API: photo after the repair (from the municipality). */
.resolved-photo { margin: var(--space-3) 0 0; }
.resolved-photo img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius-md); background: var(--surface-sunken); }
