/* ==========================================================================================
   Contact Archive — mobile-first stylesheet (owner: ui)

   Rules of the house:
   * No external fonts (system stack only), no imports, no url() to anywhere.
   * Light and dark via prefers-color-scheme; both themes use the same tokens.
   * Touch targets >= 44 px (--touch). Base font 16 px so iOS never zooms on input focus.
   * Animations/transitions only on transform/opacity/colour (never width/height/top/left),
     so scrolling and typing never trigger layout thrash.
   * 360 px is the narrowest supported width; a 420 px+ breakpoint adds desktop niceties.
   ========================================================================================== */

:root {
  --touch: 44px;
  --radius: 12px;
  --radius-sm: 8px;
  --gap: 12px;
  --pad: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* light theme */
  --bg: #f5f3ef;
  --surface: #ffffff;
  --surface-2: #efebe4;
  --text: #1d1f23;
  --muted: #5c6069;
  --line: #dcd7cf;
  --accent: #2f5f8f;
  --accent-text: #ffffff;
  --accent-soft: #e2ecf6;
  --fresh: #6b7280;
  --fresh-bg: #e9e7e3;
  --warm: #8a5300;
  --warm-bg: #fbe8c8;
  --cold: #9b1c1c;
  --cold-bg: #f8dcdc;
  --danger: #a11717;
  --ok: #1f6b3a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 2px 8px rgba(0, 0, 0, 0.04);
  --chart-fresh: #8d939d;
  --chart-warm: #d08a1d;
  --chart-cold: #c0392b;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1c1f25;
    --surface-2: #262a31;
    --text: #e9e7e2;
    --muted: #a2a7b0;
    --line: #333842;
    --accent: #7fb0e0;
    --accent-text: #10161c;
    --accent-soft: #24313f;
    --fresh: #9aa0a8;
    --fresh-bg: #2b2f36;
    --warm: #f0b45a;
    --warm-bg: #3d3016;
    --cold: #ff8f8f;
    --cold-bg: #42201f;
    --danger: #ff8f8f;
    --ok: #7ddc9f;
    --shadow: none;
    --chart-fresh: #7f858f;
    --chart-warm: #d99b35;
    --chart-cold: #d9534f;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
  /* room for the fixed tab bar + the iOS home indicator */
  padding-bottom: calc(var(--touch) + env(safe-area-inset-bottom, 0px) + 8px);
  overflow-wrap: anywhere;
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

h1,
h2,
h3 {
  line-height: 1.25;
  margin: 0;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  padding: 12px 16px;
  background: var(--accent);
  color: var(--accent-text);
  z-index: 100;
}
.skip-link:focus {
  left: 8px;
  top: 8px;
}

/* ------------------------------------------------ layout --------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
  padding: calc(env(safe-area-inset-top, 0px) + 8px) var(--pad) 8px;
}

.topbar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--touch);
  max-width: 900px;
  margin: 0 auto;
}

.topbar-title {
  font-size: 1.15rem;
  font-weight: 650;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-title:focus {
  outline: none;
}

.topbar-actions {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}

.topbar-back {
  flex: 0 0 auto;
}

.main {
  padding: var(--pad);
  outline: none;
}

.app {
  max-width: 900px;
  margin: 0 auto;
}

.stack > * + * {
  margin-top: var(--gap);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--pad);
  box-shadow: var(--shadow);
}

.section-title {
  font-size: 1rem;
  font-weight: 650;
  margin-bottom: 10px;
}

.lede {
  margin: 0 0 8px;
  color: var(--muted);
}

.hint,
.field-help,
.muted,
.list-end,
.count-line,
.shortcut-hint {
  color: var(--muted);
  font-size: 0.875rem;
  margin: 6px 0;
}

.list-end {
  text-align: center;
  padding: 12px 0;
}

.state-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
}

.state-block.error {
  color: var(--danger);
}

.state-block p {
  margin: 0;
}

.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 3s;
  }
  * {
    transition-duration: 0.01ms !important;
  }
}

.icon {
  display: inline-flex;
  width: 20px;
  height: 20px;
  vertical-align: -4px;
}
.icon svg {
  width: 100%;
  height: 100%;
}
.icon-lg {
  width: 40px;
  height: 40px;
  opacity: 0.6;
}
.icon-xl {
  width: 64px;
  height: 64px;
  color: var(--accent);
}

.hero-logo {
  display: flex;
  justify-content: center;
  padding: 24px 0 8px;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--touch);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease, opacity 0.12s ease;
  touch-action: manipulation;
}
.btn:hover {
  background: var(--surface-2);
}
.btn:disabled {
  opacity: 0.55;
  cursor: progress;
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.btn-primary:hover {
  background: var(--accent);
  filter: brightness(1.08);
}
.btn-quiet {
  background: transparent;
  border-color: transparent;
  color: var(--accent);
}
.btn-small {
  min-height: 36px;
  padding: 6px 10px;
  font-size: 0.875rem;
}
.btn-lg {
  min-height: 52px;
  font-size: 1.05rem;
}
.btn-block {
  display: flex;
  width: 100%;
}
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.btn-row > .btn-block {
  flex: 1 1 100%;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--touch);
  height: var(--touch);
  border-radius: 50%;
  color: var(--text);
  text-decoration: none;
}
.icon-btn:hover {
  background: var(--surface-2);
}
.topbar-back .icon {
  transform: scaleX(-1);
}

.input,
select.input,
textarea.input {
  display: block;
  width: 100%;
  min-height: var(--touch);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  /* 16px stops iOS from zooming the page on focus */
  font-size: 16px;
}
.input-lg {
  min-height: 52px;
  font-size: 1.05rem;
}
.input-short {
  max-width: 8ch;
}
.textarea {
  min-height: 96px;
  resize: vertical;
}
.file-input {
  display: block;
  width: 100%;
  padding: 12px;
  border: 2px dashed var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font: inherit;
  font-size: 0.95rem;
}
.file-input::file-selector-button {
  min-height: 36px;
  margin-right: 10px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
}

.form > * + * {
  margin-top: 10px;
}

.field-label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: -4px;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.form-row > .form-col {
  flex: 1 1 160px;
  min-width: 0;
}
.form-row > .form-col-short {
  flex: 0 0 96px;
}
.form-row > label,
.form-row > .input {
  flex: 1 1 100%;
}

.form-message {
  margin: 8px 0 0;
  font-weight: 600;
}
.form-message:empty {
  display: none;
}
.form-message.is-error {
  color: var(--danger);
}
.form-message.is-success {
  color: var(--ok);
}

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.search-wrap,
.sort-wrap {
  min-width: 0;
}

.progress-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.progress {
  flex: 1 1 auto;
  height: 12px;
  accent-color: var(--accent);
}
.progress-pct {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 0.875rem;
  min-width: 4ch;
  text-align: right;
}

/* ------------------------------------------------ tabs / nav ----------------------------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.tabbar a {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-height: var(--touch);
  padding: 6px 2px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.7rem;
  font-weight: 600;
}
.tabbar a.is-active {
  color: var(--accent);
}
.tab-icon {
  font-size: 1.2rem;
  line-height: 1;
}

/* ------------------------------------------------ avatar / people list ------------------- */

.avatar {
  --hue: 210;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: hsl(var(--hue) 45% 88%);
  color: hsl(var(--hue) 45% 25%);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.02em;
  user-select: none;
}
@media (prefers-color-scheme: dark) {
  .avatar {
    background: hsl(var(--hue) 30% 30%);
    color: hsl(var(--hue) 60% 90%);
  }
}
.avatar-lg {
  width: 64px;
  height: 64px;
  font-size: 1.4rem;
}

.people-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.people-list > li + li {
  border-top: 1px solid var(--line);
}

.person-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 10px 12px;
  color: var(--text);
  text-decoration: none;
}
.person-row:hover {
  background: var(--surface-2);
}
.row-main {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
}
.row-name {
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-phone {
  color: var(--muted);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.chip,
.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}
.chip-more {
  background: var(--accent-soft);
  color: var(--accent);
}

.age {
  flex: 0 0 auto;
  display: inline-block;
  /* wide enough for the longest edge text ("never"), so the badge never looks clipped */
  min-width: 7ch;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
}
.age-fresh {
  background: var(--fresh-bg);
  color: var(--fresh);
}
.age-warm {
  background: var(--warm-bg);
  color: var(--warm);
}
.age-cold {
  background: var(--cold-bg);
  color: var(--cold);
}
.age-never {
  background: var(--surface-2);
  color: var(--muted);
  font-style: italic;
}

.sentinel {
  height: 1px;
}
.more-wrap {
  padding: 4px 0;
}

/* ------------------------------------------------ person detail -------------------------- */

.person-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.person-head-main {
  flex: 1 1 auto;
  min-width: 0;
}
.person-name {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
}
.person-sub {
  margin: 2px 0 6px;
  color: var(--muted);
  font-size: 0.875rem;
}

.photo-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  align-items: center;
}
.photo {
  width: 84px;
  height: 84px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex: 0 0 auto;
  background: var(--surface-2);
}

.kv-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.kv {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  padding: 7px 0;
  border-top: 1px solid var(--line);
  /* label and value share the first row; the source device always gets the full row below */
  border-left: 0;
}
.kv:first-child {
  border-top: 0;
}
.kv-label {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: lowercase;
  min-width: 5ch;
}
.kv-value {
  flex: 1 1 0;
  min-width: 0;
  font-variant-numeric: tabular-nums;
}
.kv-source {
  flex: 0 0 100%;
  color: var(--muted);
  font-size: 0.75rem;
}
/* a source with nothing before it (rare) simply fills the row */
.kv-source:only-child {
  flex: 1 1 auto;
}
.kv.is-diff {
  background: var(--warm-bg);
  border-radius: 6px;
  padding-inline: 6px;
  border-top-color: var(--warm-bg);
}

.birthday-block {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.badge-birthday {
  background: var(--accent-soft);
  color: var(--accent);
}

.tag-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 10px;
  padding: 0;
}
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px 2px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
}
.tag-remove {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}
.tag-form {
  display: flex;
  gap: 8px;
}
.tag-form .input {
  flex: 1 1 auto;
  min-width: 0;
}
.tag-form .btn {
  flex: 0 0 auto;
  padding-inline: 18px;
}

.found-on {
  border-top: 1px solid var(--line);
  padding: 6px 0;
}
.found-on:first-of-type {
  border-top: 0;
}
.found-on > summary {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: var(--touch);
  padding: 10px 4px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  list-style-position: inside;
}
.found-on > summary:hover {
  background: var(--surface-2);
}
.found-device {
  font-weight: 650;
}
.found-meta {
  color: var(--muted);
  font-size: 0.8rem;
}
.found-body {
  padding: 4px 4px 10px;
}
.found-subtitle {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 12px 0 4px;
}
.found-facts {
  display: grid;
  grid-template-columns: minmax(7ch, max-content) 1fr;
  gap: 4px 12px;
  margin: 0;
}
.found-facts dt {
  color: var(--muted);
  font-size: 0.85rem;
}
.found-facts dd {
  margin: 0;
}
.found-label {
  margin: 8px 0 0;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.found-note {
  margin: 10px 0 0;
  padding: 8px 10px;
  border-left: 3px solid var(--line);
  color: var(--muted);
  white-space: pre-wrap;
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0 0 0 14px;
  border-left: 2px solid var(--line);
}
.timeline-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0 10px 6px;
  position: relative;
}
.timeline-item::before {
  content: "";
  position: absolute;
  left: -21px;
  top: 16px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}
.timeline-text {
  flex: 1 1 auto;
  min-width: 0;
}
.timeline-item > .btn {
  flex: 0 0 auto;
  white-space: nowrap;
}
.timeline-summary {
  margin: 0;
}
.timeline-when {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.event-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.event {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0 10px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.event:first-child {
  border-top: 0;
}
.event-kind {
  grid-row: span 2;
  align-self: start;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}
.event-call {
  background: var(--accent-soft);
  color: var(--accent);
}
.event-sms {
  background: var(--surface-2);
  color: var(--muted);
}
.event-when {
  font-variant-numeric: tabular-nums;
}
.event-detail {
  color: var(--muted);
  font-size: 0.85rem;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ------------------------------------------------ upload --------------------------------- */

.card-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.pick-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  min-height: 64px;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.pick-card:hover {
  border-color: var(--accent);
}
.pick-card.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  background-image: linear-gradient(var(--accent-soft), var(--accent-soft));
  position: relative;
  padding-right: 44px;
}
.pick-card.is-selected::after {
  content: "✓";
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent);
  font-weight: 800;
  font-size: 1.2rem;
}
.pick-name {
  font-weight: 650;
  font-size: 1.05rem;
}
.pick-meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.summary {
  margin-top: 12px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.summary-line {
  margin: 0 0 10px;
}
/* one block per uploaded file, above the totals line */
.summary-file {
  padding: 8px 0 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
}
.summary-file:last-of-type {
  border-bottom: 0;
  margin-bottom: 0;
}
.summary-file-name {
  margin: 0 0 4px;
  font-weight: 650;
  overflow-wrap: anywhere;
}
.summary-facts {
  list-style: none;
  margin: 0;
  padding: 0;
}
.summary-facts > li {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  padding: 2px 0;
}
.summary-facts .kv-value {
  font-variant-numeric: tabular-nums;
}
.summary .btn + .btn,
.summary .btn + p,
.summary + .btn {
  margin-top: 8px;
}
.issues {
  margin: 8px 0 10px;
}
.issues > summary {
  min-height: var(--touch);
  padding: 10px 4px;
  cursor: pointer;
  font-weight: 600;
}
.issues ul {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ------------------------------------------------ dashboard ------------------------------ */

.hero-strip {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.hero-stat {
  display: flex;
  flex-direction: column;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.hero-number {
  font-size: 1.8rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.hero-label {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.chart {
  display: grid;
  gap: 6px;
}
.chart-row {
  display: grid;
  grid-template-columns: 11ch 1fr 4ch;
  align-items: center;
  gap: 8px;
}
.chart-label {
  font-size: 0.8rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chart-track {
  height: 16px;
  border-radius: 4px;
  background: var(--surface-2);
  overflow: hidden;
}
.chart-bar {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: var(--chart-fresh);
  min-width: 2px;
  transform-origin: left center;
  transition: width 0.25s ease;
}
.chart-bar[data-level="warm"] {
  background: var(--chart-warm);
}
.chart-bar[data-level="cold"] {
  background: var(--chart-cold);
}
.chart-bar[data-level="never"] {
  background: var(--chart-cold);
  opacity: 0.55;
}
.chart-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  font-size: 0.85rem;
}

.simple-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.simple-list li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.simple-list li:first-child {
  border-top: 0;
}

/* ------------------------------------------------ review queue --------------------------- */

.review-counter {
  margin: 0;
  font-weight: 650;
  color: var(--muted);
}
.review-counter:empty {
  display: none;
}
.pair-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--pad);
  box-shadow: var(--shadow);
}
.pair-reason {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
}
.pair-score {
  margin: 2px 0 12px;
  color: var(--muted);
  font-size: 0.85rem;
}
/* the API's differences are sentences ("From different phones: …"), listed as they come */
.pair-diff-list {
  margin: 0 0 12px;
  padding-left: 1.1em;
  color: var(--muted);
  font-size: 0.9rem;
}
.pair-diff-list > li {
  margin: 2px 0;
}
.pair-flag {
  margin: 8px 0 0;
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--warm);
}
.pair-sides {
  display: grid;
  gap: 10px;
}
.pair-side {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  min-width: 0;
  /* the .is-diff highlight uses a wide box-shadow; keep it inside the card */
  overflow: hidden;
}
.pair-device {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pair-name {
  margin: 2px 0 6px;
  font-weight: 700;
  font-size: 1.05rem;
  border-radius: 4px;
}
.pair-name.is-diff {
  background: var(--warm-bg);
  color: var(--warm);
  padding: 0 6px;
  box-shadow: 0 0 0 4px var(--warm-bg);
}
.pair-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  white-space: pre-wrap;
}
.pair-open {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.85rem;
}
.pair-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 14px;
}
.pair-actions .btn {
  width: 100%;
}
kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface);
  font-family: var(--mono);
  font-size: 0.8rem;
  text-align: center;
}

/* ------------------------------------------------ devices --------------------------------- */

.device-list {
  list-style: none;
  margin: 0 -4px;
  padding: 0;
}
.device-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 4px;
  border-top: 1px solid var(--line);
}
.device-row:first-child {
  border-top: 0;
}
.device-row.is-retired {
  opacity: 0.6;
}
.device-main {
  display: flex;
  flex-direction: column;
  flex: 1 1 160px;
  min-width: 0;
}
.device-name {
  font-weight: 650;
}
.device-meta {
  color: var(--muted);
  font-size: 0.8rem;
}
.device-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* ------------------------------------------------ wide screens --------------------------- */

@media (min-width: 480px) {
  .hero-strip {
    grid-template-columns: repeat(4, 1fr);
  }
  .toolbar {
    flex-direction: row;
    align-items: center;
  }
  .search-wrap {
    flex: 1 1 auto;
  }
  .sort-wrap {
    flex: 0 0 15rem;
  }
  .pair-actions {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 720px) {
  .pair-sides {
    grid-template-columns: 1fr 1fr;
  }
  .card {
    padding: 20px;
  }
  .main {
    padding: 24px;
  }
}

.review-status:empty {
  display: none;
}
.review-status .form-message {
  margin: 0 0 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--cold-bg);
}

/* Chips never push the age badge: the chip row truncates instead (360 px is the narrowest). */
.chips {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
.chip {
  max-width: 18ch;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Focus rings inside scroll containers must not be clipped (photo strip, chip rows). */
.photo-strip {
  padding-block: 4px;
}
.person-row:focus-visible {
  outline-offset: -3px;
}
.pair-side:focus-within {
  border-color: var(--accent);
}

/* An explicit, legible sort control: the native select's caret is invisible on many Android
   builds once the background is themed, so the arrow is drawn in the label itself. */
.sort-wrap {
  position: relative;
}
.sort-wrap::after {
  content: "▾";
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--muted);
  font-size: 0.9rem;
}
.sort-wrap .input {
  padding-right: 34px;
  appearance: none;
  -webkit-appearance: none;
}
/* The tab bar and the header never overlap content on a 360 px screen. */
.main {
  padding-top: 12px;
}
