:root {
  --magenta: #e20074;
  --magenta-dark: #b3005c;
  --ink: #16161a;
  --ink-soft: #5b5b66;
  --line: #e4e4ea;
  --bg: #f6f6f9;
  --card: #ffffff;
  --ok: #17864a;
  --ok-bg: #e8f6ee;
  --bad: #c8102e;
  --bad-bg: #fdecef;
  --ai: #6b4bd6;
  --ai-bg: #f0ecfd;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 16, 25, .06), 0 4px 16px rgba(16, 16, 25, .05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 58px;
  background: var(--magenta);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: baseline; gap: 12px; }
.dots { font-weight: 800; letter-spacing: 1px; font-size: 20px; }
.dots b { font-size: 24px; }
.title { font-weight: 600; font-size: 16px; opacity: .95; }

.pill {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  background: rgba(255, 255, 255, .18);
}
.pill-ok { background: rgba(255, 255, 255, .95); color: var(--ok); }
.pill-bad { background: #fff; color: var(--bad); }

.topbar-right { display: flex; align-items: center; gap: 12px; }
.who { font-size: 13px; opacity: .92; }
.btn-signout {
  background: rgba(255, 255, 255, .16); color: #fff; border: none;
  border-radius: 8px; padding: 5px 12px; font: inherit; font-size: 13px;
  cursor: pointer;
}
.btn-signout:hover { background: rgba(255, 255, 255, .28); }

/* ---------- sign in ---------- */
.login {
  min-height: calc(100vh - 58px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 64px 24px;
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 30px 30px 26px;
}
.login-card h1 { margin: 0 0 8px; font-size: 24px; }
.login-sub { margin: 0 0 22px; color: var(--ink-soft); font-size: 14px; line-height: 1.5; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.field { display: block; margin-bottom: 16px; }
.field span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field input {
  width: 100%; padding: 10px 13px; font: inherit;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.field input:focus {
  outline: none; border-color: var(--magenta);
  box-shadow: 0 0 0 3px rgba(226, 0, 116, .12);
}
.login-btn { width: 100%; padding: 11px; margin-top: 4px; }
.login-btn:disabled { background: #d9d9e0; color: #8b8b96; cursor: progress; }
.login-error {
  margin-top: 14px; padding: 10px 13px; border-radius: 8px;
  background: var(--bad-bg); color: var(--bad); font-size: 13.5px;
}
.login-note {
  margin: 20px 0 0; padding-top: 16px; border-top: 1px solid var(--line);
  color: var(--ink-soft); font-size: 12.5px; line-height: 1.55;
}

/* ---------- layout ---------- */
main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 24px 80px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.panel-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.panel-actions { display: flex; gap: 8px; }

.hidden { display: none !important; }

/* ---------- controls ---------- */
.controls {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.search-wrap { flex: 1 1 320px; display: flex; align-items: center; gap: 10px; }

input[type="search"], input[type="text"], textarea {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}
input[type="search"]:focus, textarea:focus {
  outline: none;
  border-color: var(--magenta);
  box-shadow: 0 0 0 3px rgba(226, 0, 116, .12);
}
textarea { resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }

.btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn-sm { padding: 6px 12px; font-size: 13.5px; }
.btn-primary { background: var(--magenta); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--magenta-dark); }
.btn-primary:disabled { background: #d9d9e0; color: #8b8b96; cursor: not-allowed; }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: #c7c7d1; background: #fafafc; }

.linkbtn {
  background: none; border: none; padding: 0;
  color: var(--magenta); font: inherit; cursor: pointer; text-decoration: underline;
}
.hint { color: var(--ink-soft); font-size: 13px; white-space: nowrap; }

.check-inline { display: flex; align-items: center; gap: 7px; font-size: 14px; cursor: pointer; }
.check-inline input { accent-color: var(--magenta); width: 16px; height: 16px; cursor: pointer; }

.paste-box {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 14px;
  background: #fbfbfd;
}
.paste-actions { display: flex; align-items: center; gap: 12px; margin-top: 10px; }

/* ---------- reviewer feedback ---------- */
.feedback-box {
  border: 1px dashed var(--line); border-radius: 8px;
  padding: 12px; margin-bottom: 14px; background: #fbfbfd;
}
.feedback-list { max-height: 300px; overflow-y: auto; }
.fb-row {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 6px; border-bottom: 1px solid #f0f0f4; font-size: 14px;
}
.fb-row:last-child { border-bottom: none; }
.fb-site { flex: 1; min-width: 0; }
.fb-site .code { font-weight: 700; }
.fb-site .full {
  font-size: 12.5px; color: var(--ink-soft);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fb-who { flex: none; font-size: 13px; color: var(--ink); }
.fb-when { flex: none; font-size: 12.5px; color: var(--ink-soft); width: 92px; text-align: right; }

.feedback-note {
  display: flex; gap: 8px; align-items: center;
  padding: 9px 16px; background: #f4f8ff;
  border-bottom: 1px solid var(--line);
  font-size: 13px; color: #244a86;
}

.reviewer-note {
  padding: 11px 16px 12px; background: #f7f9fd;
  border-bottom: 1px solid var(--line);
}
.reviewer-note-head {
  font-size: 11.5px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--ink-soft); margin-bottom: 7px;
}
.reviewer-line {
  display: flex; align-items: center; gap: 10px;
  font-size: 13.5px; padding: 2px 0;
}
.rv-name { font-weight: 650; min-width: 130px; }
.rv-ok { color: var(--ok); }
.rv-bad { color: var(--bad); font-weight: 650; }
.rv-when { color: var(--ink-soft); font-size: 12.5px; margin-left: auto; }
.reviewer-foot {
  margin-top: 8px; padding-top: 8px; border-top: 1px solid #e6ebf5;
  font-size: 12.5px; color: #4a5a76; line-height: 1.45;
}

.selection-bar {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 0; border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line); margin-bottom: 4px;
}

/* ---------- site list ---------- */
.site-list { max-height: 420px; overflow-y: auto; margin: 0 -6px; padding: 0 6px; }
.site-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 8px; border-bottom: 1px solid #f0f0f4;
  cursor: pointer; border-radius: 6px;
}
.site-row:hover { background: #fafafc; }
.site-row input { accent-color: var(--magenta); width: 16px; height: 16px; flex: none; cursor: pointer; }
.site-main { flex: 1; min-width: 0; }
.site-code { font-weight: 700; }
.site-name {
  color: var(--ink-soft); font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.site-meta { display: flex; gap: 12px; font-size: 12.5px; color: var(--ink-soft); flex: none; }

.empty { padding: 28px; text-align: center; color: var(--ink-soft); }
.list-foot { display: flex; justify-content: center; padding-top: 12px; }

/* ---------- progress ---------- */
.bar { height: 8px; background: #ececf1; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--magenta); transition: width .25s; }
.log {
  margin: 14px 0 0; max-height: 190px; overflow-y: auto;
  background: #16161a; color: #d8d8e0; border-radius: 8px;
  padding: 12px 14px; font: 12.5px/1.6 ui-monospace, Consolas, monospace;
  white-space: pre-wrap;
}

/* ---------- climber loader ---------- */
.cl-root { margin: -4px 0 0; }
.cl-stage {
  position: relative; width: 100%; aspect-ratio: 16 / 7;
  background: var(--paper, #f7f5f0);
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
}
.cl-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.cl-flash {
  position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none;
}
.cl-caption {
  position: absolute; left: 22px; top: 16px; max-width: 70%;
  font: 500 30px Caveat, 'Segoe UI', cursive; color: #25231f;
  opacity: 0; transition: opacity .3s; pointer-events: none;
}
.cl-caption.bottom {
  top: auto; bottom: 14px; left: 0; right: 0; max-width: none; text-align: center;
}

.cl-cards {
  position: absolute; inset: 0; padding: 46px 22px 22px;
  display: none; grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: min-content; gap: 12px; align-content: center;
}
.cl-cards.show { display: grid; }
.cl-cards-title {
  position: absolute; left: 22px; top: 16px;
  font: 600 13px 'IBM Plex Mono', ui-monospace, monospace;
  color: var(--ink-soft); letter-spacing: .14em;
}
.cl-card {
  background: #fff; border: 1px solid #e5e1d8; border-radius: 10px;
  box-shadow: 0 8px 22px rgba(37, 35, 31, .10);
  padding: 12px 14px; display: flex; flex-direction: column; gap: 7px;
  opacity: 0;
}
.cl-card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.cl-card-id {
  font: 600 15px 'IBM Plex Mono', ui-monospace, monospace; color: #25231f;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cl-card-badge {
  font: 600 11px 'IBM Plex Mono', ui-monospace, monospace; color: #fff;
  background: var(--magenta); padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.cl-card-sub { font: 400 12.5px 'IBM Plex Mono', ui-monospace, monospace; color: var(--ink-soft); }
.cl-card-bars { display: flex; gap: 5px; margin-top: 2px; }
.cl-card-bars i { height: 5px; flex: 1; border-radius: 3px; background: #ece8df; }
.cl-card-bars i.on { background: var(--magenta); }

.cl-foot { padding: 14px 2px 0; display: flex; flex-direction: column; gap: 10px; }
.cl-foot-top { display: flex; align-items: baseline; gap: 14px; }
.cl-stage-label {
  font: 700 13px 'IBM Plex Sans', system-ui, sans-serif;
  letter-spacing: .12em; color: var(--ink);
}
.cl-stage-label.done { color: var(--ok); }
.cl-count { margin-left: auto; font-size: 13px; color: var(--ink-soft); }
.cl-bar { height: 8px; background: #e2ded4; border-radius: 999px; overflow: hidden; }
.cl-bar-fill {
  height: 100%; width: 0; background: var(--magenta);
  border-radius: 999px; transition: width .3s;
}
.cl-bar-fill.done { background: var(--ok); }
.cl-log { display: flex; flex-direction: column; gap: 2px; min-height: 42px; }
.cl-log-line {
  font: 400 12px ui-monospace, Consolas, monospace; color: var(--ink-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

@media (max-width: 720px) {
  .cl-stage { aspect-ratio: 4 / 5; border-radius: 10px; }
  .cl-caption { font-size: 22px; left: 14px; top: 10px; }
  .cl-cards { grid-template-columns: 1fr; padding: 38px 12px 12px; gap: 8px; overflow-y: auto; }
  .cl-cards-title { left: 14px; top: 12px; font-size: 11px; }
  .cl-card { padding: 9px 11px; gap: 5px; }
  .cl-card-id { font-size: 13px; }
  .cl-card-badge { font-size: 10px; padding: 2px 7px; }
  .cl-card-sub { font-size: 11px; }
  .cl-log { min-height: 30px; }
  .cl-log-line { font-size: 11px; }
}

/* ---------- summary ---------- */
.summary { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.stat {
  flex: 1 1 130px; background: #fafafc; border: 1px solid var(--line);
  border-radius: 8px; padding: 12px 14px;
}
.stat-num { font-size: 24px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 12.5px; color: var(--ink-soft); }
.stat.bad .stat-num { color: var(--bad); }
.stat.ai .stat-num { color: var(--ai); }

/* ---------- results ---------- */
.site-card {
  border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 14px; overflow: hidden; background: #fff;
}
.site-card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; cursor: pointer; background: #fafafc;
  border-bottom: 1px solid transparent;
}
.site-card.open .site-card-head { border-bottom-color: var(--line); }
.site-card-head:hover { background: #f4f4f8; }
.chev { color: var(--ink-soft); transition: transform .15s; flex: none; }
.site-card.open .chev { transform: rotate(90deg); }
.site-card-title { flex: 1; min-width: 0; }
.site-card-title .code { font-weight: 700; }
.site-card-title .full {
  font-size: 12.5px; color: var(--ink-soft);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.badge {
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; flex: none;
}
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-ai { background: var(--ai-bg); color: var(--ai); }
.badge-fb { background: #eaf1fd; color: #244a86; }

/* collapsed cards hide their contents */
.site-card:not(.open) .issues,
.site-card:not(.open) .feedback-note,
.site-card:not(.open) .reviewer-note { display: none; }

.issues { padding: 4px 0; }

.issue {
  display: flex; gap: 14px; padding: 14px 16px;
  border-bottom: 1px solid #f2f2f6;
}
.issue:last-child { border-bottom: none; }

.issue-photo {
  flex: none; width: 120px; height: 90px;
  border-radius: 8px; overflow: hidden; background: #ececf1;
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-in; border: 1px solid var(--line);
}
.issue-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* the reviewer's drawing, overlaid in the photo's own coordinate space */
.issue-photo { position: relative; }
.markup-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.has-markup { border-color: var(--bad); box-shadow: 0 0 0 2px var(--bad-bg); }
/* markups are positioned against the whole photo, so it must not be cropped */
.issue-photo.has-markup img { object-fit: contain; }
.issue-photo.no-photo { cursor: default; color: #a0a0ad; font-size: 11.5px; text-align: center; padding: 6px; }

.issue-body { flex: 1; min-width: 0; }
.issue-col { font-weight: 650; margin-bottom: 4px; }
.issue-meta {
  display: flex; gap: 12px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--ink-soft); margin-bottom: 8px;
}
.issue-comment {
  background: var(--bad-bg); border-left: 3px solid var(--bad);
  padding: 9px 12px; border-radius: 0 6px 6px 0;
  font-size: 14px; white-space: pre-wrap;
}
.issue-comment.none {
  background: #f7f7fa; border-left-color: #d5d5de;
  color: var(--ink-soft); font-style: italic; font-size: 13px;
}
.markup-note { color: var(--ink-soft); font-size: 12.5px; margin-top: 6px; }

.site-error { padding: 14px 16px; color: var(--bad); font-size: 13.5px; }

/* ---------- lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; background: rgba(10, 10, 15, .88);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.lightbox-stage { position: relative; display: inline-block; line-height: 0; }
.lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 8px; display: block; }
.lightbox .markup-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.lightbox-close {
  position: absolute; top: 18px; right: 22px;
  background: rgba(255, 255, 255, .14); color: #fff;
  border: none; border-radius: 8px; width: 40px; height: 40px;
  font-size: 19px; cursor: pointer;
}

/* ==========================================================================
   Mobile — one column, bigger touch targets, photos above the text
   ========================================================================== */
@media (max-width: 720px) {
  body { font-size: 15px; }

  .topbar { height: 52px; padding: 0 14px; gap: 8px; }
  .dots { font-size: 16px; }
  .dots b { font-size: 20px; }
  .title { font-size: 14px; }
  .who { display: none; }
  .pill { font-size: 11.5px; padding: 3px 9px; }

  main { padding: 14px 12px 60px; gap: 14px; }
  .panel { padding: 15px 14px; border-radius: 12px; }
  .panel-head { gap: 10px; margin-bottom: 13px; }
  .panel-head h2 { font-size: 13px; }
  .panel-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .panel-actions .btn { width: 100%; text-align: center; }

  .controls { gap: 10px; }
  .search-wrap { flex: 1 1 100%; flex-wrap: wrap; }
  #search-count { width: 100%; }
  /* 16px keeps iOS from zooming the page when a field is focused */
  input[type="search"], input[type="text"], input[type="email"],
  input[type="password"], textarea { font-size: 16px; padding: 11px 13px; }
  .btn { padding: 10px 14px; }
  .btn-sm { padding: 9px 12px; }
  .check-inline input { width: 20px; height: 20px; }

  /* site picker */
  .site-list { max-height: 50vh; }
  .site-row { padding: 12px 6px; gap: 11px; }
  .site-row input { width: 21px; height: 21px; }
  .site-meta { flex-direction: column; gap: 2px; align-items: flex-end; font-size: 11.5px; }
  .selection-bar { flex-wrap: wrap; gap: 10px; }

  .feedback-list { max-height: 46vh; }
  .fb-row { flex-wrap: wrap; gap: 4px 10px; }
  .fb-site { flex: 1 1 100%; }
  .fb-who { font-size: 12.5px; color: var(--ink-soft); }
  .fb-when { margin-left: auto; width: auto; }

  /* summary tiles: two per row instead of a cramped strip */
  .summary { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat { padding: 10px 12px; }
  .stat-num { font-size: 21px; }
  .stat-label { font-size: 11.5px; }

  /* findings: photo on top, full width — the point of the page is the photo */
  .issue { flex-direction: column; gap: 10px; padding: 14px 13px; }
  .issue-photo { width: 100%; height: 210px; }
  .issue-photo.has-markup img { object-fit: contain; background: #f4f4f7; }
  .issue-col { font-size: 15.5px; }
  .issue-meta { gap: 4px 10px; font-size: 12px; }
  .site-card-head { padding: 12px 13px; gap: 9px; flex-wrap: wrap; }
  .site-card-title { flex: 1 1 60%; }
  .badge { font-size: 11px; padding: 3px 8px; }
  .reviewer-line { flex-wrap: wrap; gap: 4px 10px; }
  .rv-name { min-width: 0; flex: 1 1 100%; }
  .rv-when { margin-left: 0; }

  .log { max-height: 120px; font-size: 11.5px; }
  .login { padding: 26px 14px; }
  .login-card { padding: 22px 20px; }

  .lightbox-close { top: 10px; right: 12px; }
}

@media (max-width: 400px) {
  .panel-actions { grid-template-columns: 1fr; }
  .summary { grid-template-columns: 1fr; }
}
