:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --surface-2: #f1ece3;
  --text: #2d3142;
  --text-dim: #8a8f9e;
  --accent: #2fb380;
  --accent-dark: #1f8f65;
  --accent-soft: #e3f5ec;
  --warn: #e9a13b;
  --danger: #e2606f;
  --radius: 18px;
  --shadow: 0 2px 14px rgba(45, 49, 66, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  /* dvh tracks iOS chrome in Safari. In an INSTALLED PWA there is no chrome,
     and iOS can report a dvh taller than the visible area, leaving a gap
     under the dock — so JS pins --app-h to the real innerHeight and that
     wins wherever it's available. */
  height: 100dvh;
  max-height: 100dvh;
  height: var(--app-h, 100dvh);
  max-height: var(--app-h, 100dvh);
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: ui-rounded, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  touch-action: pan-y; /* app-like: no pinch/double-tap page zoom */
  -webkit-text-size-adjust: 100%;
}

body {
  display: flex;
  flex-direction: column;
  /* NOTE: no bottom inset here — bottom-anchored elements (the camera dock,
     result panel, history list) apply it themselves. Applying it at both
     levels doubled the gap above the home indicator in installed PWA mode. */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 19px;
  letter-spacing: 0.2px;
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-family: inherit;
  cursor: pointer;
}
.brand:active { opacity: 0.6; }

.brand-icon { width: 28px; height: 28px; border-radius: 8px; }

.build-tag {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: var(--text-dim);
  align-self: flex-end;
  padding-bottom: 3px;
  font-variant-numeric: tabular-nums;
}

.engine-status {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-dim);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 5px 12px;
  border-radius: 999px;
  transition: opacity 0.6s;
}
.engine-status.ready { color: var(--accent-dark); background: var(--accent-soft); }
.engine-status.fade { opacity: 0; }

/* ---------- shared controls ---------- */

.icon-btn {
  background: var(--surface);
  color: var(--text);
  border: none;
  border-radius: 14px;
  box-shadow: var(--shadow);
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 18px;
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn.big { width: 54px; height: 54px; font-size: 26px; border-radius: 999px; }

.pill-btn {
  background: var(--surface);
  color: var(--text);
  border: none;
  border-radius: 999px;
  box-shadow: var(--shadow);
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.pill-btn:active { background: var(--surface-2); }
.pill-btn.primary { background: var(--accent); color: #fff; }
.pill-btn.primary:active { background: var(--accent-dark); }
.pill-btn.danger { background: transparent; box-shadow: none; color: var(--danger); }
.pill-btn.subtle { background: transparent; box-shadow: none; color: var(--text-dim); font-weight: 600; }
.pill-btn.active { outline: 2.5px solid var(--accent); color: var(--accent-dark); }
.pill-btn:disabled { opacity: 0.4; cursor: default; }

/* ---------- camera screen ---------- */

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.screen[hidden] { display: none; }

.viewport {
  position: relative;
  flex: 1;
  min-height: 0;
  margin: 0 14px;
  border-radius: var(--radius);
  overflow: hidden;
  background: #1c1f2b;
  box-shadow: var(--shadow);
}

#viewfinder {
  /* Frame SOURCE only — iOS sometimes refuses to render the element while
     still delivering frames to canvas. The preview canvas is the display. */
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  pointer-events: none;
}

.preview-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  /* Must sit ABOVE the (opaque) fallback panel: when the camera works but
     the panel lingers, the user could see badges but not the camera image. */
  z-index: 3;
}

/* Square capture guide: everything outside the square is dimmed, so the user
   naturally centers the tray and leaves a margin. Only the square is
   analyzed, which also guarantees no pill is cut by the frame edge. */
.capture-guide {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5; /* framing guide sits above preview + badges */
}
.guide-dim { position: absolute; background: rgba(12, 16, 24, 0.55); }
.guide-square {
  position: absolute;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 14px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
}

/* The only thing allowed over the camera image: a compact, translucent HUD
   chip in the corner, so the framing area itself stays unobstructed. */
.live-count {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--accent-dark);
  font-size: 20px;
  font-weight: 800;
  padding: 3px 14px;
  border-radius: 999px;
  backdrop-filter: blur(6px);
  z-index: 6;
  transition: background 0.3s, color 0.3s;
}
.live-count.stable {
  background: var(--accent);
  color: #fff;
}
.live-count.unsure {
  background: rgba(255, 255, 255, 0.92);
  color: var(--warn);
}

.live-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 4; /* badges draw on top of the preview */
}

/* Full-width primary action at the top of the dock — never over the camera. */
.use-count {
  display: block;
  width: calc(100% - 52px);
  margin: 14px 26px 0;
  font-size: 15px;
}

/* ---------- goldendoodle helper ---------- */

.helper {
  position: absolute;
  left: 10px;
  bottom: 10px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  z-index: 3;
  pointer-events: none;
  max-width: 88%;
}
.helper-dog {
  width: 64px;
  height: 64px;
  filter: drop-shadow(0 2px 6px rgba(45, 49, 66, 0.25));
  animation: doodle-bob 3.2s ease-in-out infinite;
}
.helper-dog.small { width: 48px; height: 48px; }
@keyframes doodle-bob {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-4px) rotate(2deg); }
}
.helper-bubble {
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  padding: 9px 13px;
  border-radius: 14px 14px 14px 4px;
  box-shadow: var(--shadow);
  margin-bottom: 8px;
}
.helper-inline {
  position: static;
  pointer-events: auto;
  align-self: flex-start;
  margin: 0 auto;
}

/* Below the viewfinder, never over it — the camera preview stays clear. */
.helper-below {
  position: static;
  pointer-events: auto;
  margin: 10px 14px 0;
  max-width: none;
}
.helper-below .helper-dog { width: 44px; height: 44px; }
.helper-below .helper-bubble { margin-bottom: 0; font-size: 12.5px; }

.camera-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 6px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  z-index: 1; /* strictly below the preview canvas */
}
.camera-fallback .sub { color: var(--text-dim); font-size: 13px; font-weight: 400; max-width: 260px; }

/* Paused is a normal, chosen state — calm and inviting, not an error. */
.camera-paused {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  text-align: center;
  background: var(--surface-2);
  color: var(--accent-dark);
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  z-index: 2;
}
.camera-paused .sub { color: var(--text-dim); font-size: 13px; font-weight: 500; }

/* Anchored bottom bar: the controls own the bottom of the screen instead of
   floating mid-page with dead space beneath them. */
.camera-dock {
  margin-top: auto;
  background: var(--surface);
  border-radius: 26px 26px 0 0;
  box-shadow: 0 -3px 20px rgba(45, 49, 66, 0.07);
  /* Home-indicator clearance only — capped so installed PWA mode (where
     there is no browser toolbar) doesn't leave a large dead strip. */
  padding-bottom: min(env(safe-area-inset-bottom), 12px);
}
@media (display-mode: standalone) {
  /* Installed app: the dock is already flush with the screen edge, and iOS
     draws the home indicator over it harmlessly. Extra inset here just
     creates a dead strip, so keep it minimal. */
  .camera-dock { padding-bottom: 4px; }
}

.controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  justify-items: center;
  padding: 16px 26px 8px;
  gap: 12px;
}

.control-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}
.control-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-dim);
}

.round-btn {
  width: 52px;
  height: 52px;
  border-radius: 999px;
  border: none;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.round-btn:active { background: var(--surface-2); }
.round-btn:disabled { opacity: 0.4; }
/* One icon shows at a time: pause while live, play while paused. */
.round-btn .icon-play { display: none; }
.round-btn.paused { color: var(--accent-dark); }
.round-btn.paused .icon-play { display: block; }
.round-btn.paused .icon-pause { display: none; }

.target-input {
  width: 62px;
  height: 52px;
  background: var(--surface);
  border: 1.5px solid var(--surface-2);
  box-shadow: var(--shadow);
  color: var(--text);
  font: inherit;
  font-size: 19px;
  font-weight: 800;
  text-align: center;
  border-radius: 16px;
  -moz-appearance: textfield;
}
.target-input::-webkit-outer-spin-button,
.target-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.target-input:focus { outline: 2.5px solid var(--accent); border-color: transparent; }

.shutter {
  width: 74px;
  height: 74px;
  border-radius: 999px;
  border: 4px solid var(--surface);
  box-shadow: var(--shadow);
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.shutter-ring {
  width: 58px;
  height: 58px;
  border-radius: 999px;
  background: var(--accent);
  transition: transform 0.12s;
}
.shutter:active .shutter-ring { transform: scale(0.88); }
.shutter:disabled { opacity: 0.35; }
.shutter.working .shutter-ring { animation: pulse 0.8s infinite; }

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.8); opacity: 0.6; }
}

/* Secondary row: quiet, evenly spaced, never competing with the shutter. */
.control-extras {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 2px 18px 10px;
  border-top: 1px solid var(--surface-2);
  margin: 6px 18px 0;
}

.more-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 4px 22px rgba(45, 49, 66, 0.16);
  padding: 6px;
  min-width: 210px;
  z-index: 8;
}
.more-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
}
.more-row:active { background: var(--surface-2); }

.fps-select {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 2px;
  cursor: pointer;
}

/* ---------- result screen ---------- */

.result-photo {
  position: relative;
  margin: 0 10px;
  border-radius: var(--radius);
  overflow: hidden;
  background: #1c1f2b;
  box-shadow: var(--shadow);
  display: grid;
  /* Top-left, NOT center: the zoom system owns centering via clampPan()'s
     translate. With place-items:center both mechanisms centered the photo,
     summing to a double offset that pinned it to the right edge (reported
     from the field on a wide window). One owner for positioning. */
  place-items: start;
  /* THE PHOTO IS THE APP (field report: "most of the UI should be the
     image"). It claims every pixel the compact panel doesn't need; the
     panel below is fixed-size and never scrolls off. */
  flex: 1 1 auto;
  min-height: 0;
}
.result-photo { touch-action: none; } /* pinch/pan belongs to the photo */

/* Alignment contract: .zoom-wrap is sized by JS to the photo's exact
   displayed box (aspect-correct). BOTH canvases fill that box at 100%/100%
   with no independent max-* rules and no auto-centering, so the overlay can
   never drift from the photo — they are the same rectangle by construction. */
.zoom-wrap {
  position: relative;
  transform-origin: 0 0;
  will-change: transform;
  line-height: 0;
}
.zoom-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}
#photo-canvas { position: relative; }
#overlay-canvas {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

/* The panel must always be fully reachable: the page height is fixed and
   body overflow is hidden, so without its own scroll the Save/Adjust row
   was sliced off the bottom on tall photos (user-reported). */
.result-panel.compact {
  padding: 8px 12px calc(8px + min(env(safe-area-inset-bottom), 10px));
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex: 0 0 auto;   /* fixed-size bar; the photo takes the rest */
}

.panel-main {
  display: flex;
  align-items: center;
  gap: 10px;
}
.panel-main .icon-btn.big { width: 42px; height: 42px; font-size: 22px; flex: 0 0 auto; }
.panel-main #save-btn { margin-left: auto; padding: 11px 22px; }

.count-display { display: flex; align-items: baseline; gap: 6px; }
.count-value {
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
  color: var(--accent-dark);
  font-variant-numeric: tabular-nums;
}
.count-label {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.panel-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;          /* belt-and-suspenders on very narrow phones */
  scrollbar-width: none;
}
.panel-tools::-webkit-scrollbar { display: none; }
.pill-btn.mini {
  padding: 7px 10px;
  font-size: 12.5px;
  border-radius: 10px;
  white-space: nowrap;
}
.panel-tools #med-name { flex: 1 1 60px; min-width: 0; }

.helper-strip {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 0;
}
.helper-strip .helper-dog.small { width: 24px; height: 24px; }
.helper-bubble.slim {
  font-size: 12px;
  padding: 4px 10px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.target-info { font-size: 12.5px; font-weight: 700; }
.target-info:empty { display: none; }
.target-info.ok { color: var(--accent-dark); }
.target-info.over { color: var(--warn); }
.target-info.short { color: var(--danger); }

#med-name {
  background: var(--surface);
  border: 1.5px solid var(--surface-2);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 10px;
}
#med-name:focus { outline: 2.5px solid var(--accent); border-color: transparent; }
#med-name::placeholder { color: var(--text-dim); }

.result-actions { display: flex; gap: 12px; }

/* ---------- crop editor ---------- */

.crop-box {
  position: absolute;
  border: 2px solid #fff;
  border-radius: 6px;
  box-shadow: 0 0 0 9999px rgba(12, 16, 24, 0.5); /* dims everything outside */
  cursor: move;
  touch-action: none;
}
.crop-handle {
  position: absolute;
  width: 34px;
  height: 34px;
  background: transparent;
  touch-action: none;
}
.crop-handle::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border: 3px solid #fff;
  border-radius: 3px;
}
.crop-handle.tl { left: -17px; top: -17px; cursor: nwse-resize; }
.crop-handle.tl::after { left: 8px; top: 8px; border-right: none; border-bottom: none; }
.crop-handle.tr { right: -17px; top: -17px; cursor: nesw-resize; }
.crop-handle.tr::after { right: 8px; top: 8px; border-left: none; border-bottom: none; }
.crop-handle.bl { left: -17px; bottom: -17px; cursor: nesw-resize; }
.crop-handle.bl::after { left: 8px; bottom: 8px; border-right: none; border-top: none; }
.crop-handle.br { right: -17px; bottom: -17px; cursor: nwse-resize; }
.crop-handle.br::after { right: 8px; bottom: 8px; border-left: none; border-top: none; }

.pill-btn.adjusting { outline: 2.5px solid var(--accent); color: var(--accent-dark); }

/* ---------- report sheet ---------- */

.sheet-scrim {
  position: fixed;
  inset: 0;
  background: rgba(12, 16, 24, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
  animation: scrim-in 0.18s ease;
}
.sheet-scrim[hidden] { display: none; }
@keyframes scrim-in { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  width: 100%;
  max-width: 520px;
  background: var(--bg);
  border-radius: 22px 22px 0 0;
  padding: 10px 22px calc(22px + env(safe-area-inset-bottom));
  box-shadow: 0 -6px 30px rgba(45, 49, 66, 0.18);
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: sheet-up 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes sheet-up { from { transform: translateY(18px); } to { transform: none; } }

.sheet-grab {
  width: 40px; height: 4px; border-radius: 99px;
  background: var(--surface-2); margin: 2px auto 4px;
}
.sheet-title { font-size: 18px; font-weight: 800; text-align: center; }
.sheet-sub { font-size: 13px; color: var(--text-dim); text-align: center; margin: -6px 0 2px; }

.stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 26px;
}
.stepper-value {
  font-size: 48px;
  font-weight: 800;
  color: var(--accent-dark);
  min-width: 90px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.sheet-note {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--surface-2);
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  resize: none;
}
.sheet-note:focus { outline: 2.5px solid var(--accent); border-color: transparent; }

.sheet-actions { display: flex; gap: 12px; }
.sheet-actions .pill-btn { flex: 1; }

.report-btn { }
.debug-btn { }

/* Debug sheet: the pipeline's intermediate images. Deliberately a dark,
   instrument-panel look — these are machine-vision masks, and white pills on
   black read far better than the app's warm paper palette. */
.debug-sheet { background: #0e120e; color: #cfe8cf; max-height: 88vh; overflow-y: auto; }
.debug-sheet .sheet-title { color: #eafbe8; }
.debug-sheet .sheet-sub { color: #7fa87f; }
.debug-sheet .sheet-grab { background: #33452f; }

.debug-toggle {
  display: flex; align-items: center; gap: 9px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px; color: #8fd18f; margin: 2px 0 10px; cursor: pointer;
}
.debug-toggle input { width: 17px; height: 17px; accent-color: #3ddc84; }

/* Per-stage blob counts. Each arrow should move toward the final answer;
   a ⚠ marks a stage that jumped away from it — where a wrong count is born. */
.debug-progress {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; line-height: 1.6; color: #8fd18f;
  background: #071008; border: 1px solid #26331f; border-left: 3px solid #3ddc84;
  border-radius: 8px; padding: 9px 11px; margin-bottom: 4px;
}
.debug-progress.warn { color: #f0c674; border-left-color: #e9a13b; }

.debug-stages { display: flex; flex-direction: column; gap: 14px; margin: 4px 0 12px; }
.debug-stage { display: flex; flex-direction: column; gap: 6px; }
.debug-stage canvas {
  width: 100%;
  /* Cap the height so all seven stages can be compared by scrolling a
     little, rather than one full-bleed image per screen. */
  max-height: 34vh;
  object-fit: contain;
  border-radius: 8px;
  display: block;
  background: #000;
  border: 1px solid #26331f;
  image-rendering: crisp-edges;
}
.debug-stage figcaption {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  line-height: 1.45;
  color: #8fd18f;
}
.debug-stage .stage-name { color: #d7ffd0; font-weight: 700; }

/* Per-pill geometry. Row N is badge N on the photo. */
.debug-pilltable { margin: 2px 0 12px; }
.debug-pilltable summary {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; color: #8fd18f; cursor: pointer; user-select: none;
}
table.debug-pills {
  width: 100%; border-collapse: collapse; margin-top: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px;
}
table.debug-pills th {
  text-align: right; font-weight: 700; color: #6ea86e;
  padding: 3px 7px; border-bottom: 1px solid #26331f;
}
table.debug-pills th:first-child, table.debug-pills td:first-child { text-align: left; }
table.debug-pills td {
  text-align: right; padding: 3px 7px; color: #cfe8cf;
  border-bottom: 1px solid #16200f; font-variant-numeric: tabular-nums;
}
/* A region covering several pills, or one far off the unit size, is where a
   wrong count is born — surface those instead of making the eye scan. */
table.debug-pills tr.odd td { color: #f0c674; }
table.debug-pills tr.lowc td { color: #e8896b; }

.debug-trace {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  line-height: 1.5;
  color: #7ae07a;
  background: #060906;
  border: 1px solid #26331f;
  border-radius: 8px;
  padding: 10px 12px;
  margin: 0 0 14px;
  max-height: 30vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.rating {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 10px 16px;
  background: var(--surface);
  border-radius: 999px;
  box-shadow: var(--shadow);
  animation: sheet-up 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.rating[hidden] { display: none; }
.rating-q { font-size: 13.5px; font-weight: 700; color: var(--text); }
.rating-btns { display: flex; gap: 8px; }
.rate-btn {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: none;
  background: var(--surface-2);
  font-size: 19px;
  cursor: pointer;
  line-height: 1;
}
.rate-btn:active { transform: scale(0.92); }
.report-btn.sent { color: var(--accent-dark); }

.contribute {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
}
.contribute input { accent-color: var(--accent); width: 16px; height: 16px; }

/* ---------- history screen ---------- */

.history-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 16px 12px;
}
.history-header h2 { font-size: 19px; flex: 1; }

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 16px calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 12px;
}
.history-item img {
  width: 54px;
  height: 54px;
  object-fit: cover;
  border-radius: 10px;
  background: var(--surface-2);
}
.history-meta { flex: 1; min-width: 0; }
.history-count { font-weight: 800; font-size: 16px; }
.history-sub {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-del { width: 34px; height: 34px; font-size: 13px; color: var(--text-dim); box-shadow: none; background: transparent; }

.empty { color: var(--text-dim); text-align: center; padding: 48px 0; }

.history-fix { font-size: 12px; font-weight: 600; color: var(--text-dim); }
.history-nothumb {
  width: 54px; height: 54px; border-radius: 10px;
  background: var(--surface-2); flex: 0 0 54px;
}
