:root {
  color-scheme: light dark;
  /* Indigo theme: one indigo accent; pink-red only for bad/close */
  --bg: #f7f7fb; --card: #fff; --text: #16163a; --muted: #6b6b8a; --line: #e6e6f2;
  --accent: #5b5bf7; --accent-2: #8b5cf6; --keep: #5b5bf7; --save: #8b5cf6; --close: #e0245e; --warn: #d97706;
  --good-bg: #e8e8ff; --good-text: #4338ca; --bad-bg: #fde8ec; --bad-text: #e0245e;
  --on-accent: #fff; --brand: #5b5bf7; --brand-2: #8b5cf6;
}
/* Dark: follows the system/browser theme. Accents get lighter, so text on them turns dark */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121225; --card: #1b1b33; --text: #ececff; --muted: #a3a3c7; --line: #2e2e4d;
    --accent: #8585ff; --accent-2: #a78bfa; --keep: #8585ff; --save: #a78bfa; --close: #ff4d8d; --warn: #fbbf24;
    --good-bg: #25254f; --good-text: #b4b4ff; --bad-bg: #3a1528; --bad-text: #ff6b9d; --on-accent: #121225;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 13px/1.45 system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); }
header { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); z-index: 2; }
.brand { font-weight: 800; font-size: 15px; display: flex; align-items: center; }
.logo { width: 22px; height: 22px; margin-right: 7px; }
.status { color: var(--muted); font-size: 11px; }
.status.bad { color: var(--close); }
.screen { padding: 14px; }
.hidden { display: none; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 14px; }
.label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.grade { font-size: 56px; font-weight: 800; line-height: 1.1; margin: 6px 0 12px; }
.grade.small { font-size: 22px; display: block; margin: 0; }
.grade.F, .grade.D { color: var(--bad-text); } .grade.A, .grade.B, .grade.C { color: var(--good-text); }
.clutter .grade { display: inline-flex; align-items: center; justify-content: center; width: 72px; height: 72px; border-radius: 14px; font-size: 48px; font-weight: 900; background: var(--good-bg); }
.clutter .grade.F, .clutter .grade.D { background: var(--bad-bg); }
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.metrics div, .before-after div { display: flex; flex-direction: column; }
.metrics b { font-size: 20px; } .metrics span, .before-after span { color: var(--muted); font-size: 11px; }
button { font: inherit; cursor: pointer; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); padding: 9px 12px; width: 100%; margin-bottom: 8px; }
button:disabled { opacity: .5; cursor: default; }
.primary { background: var(--accent); color: var(--on-accent); border: 0; font-weight: 700; }
.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 88%, #000); }
.big { font-size: 16px; padding: 14px; }
.ghost { background: transparent; }
.danger { color: var(--close); }
.link { border: 0; background: none; color: var(--muted); text-decoration: underline; }
.hint { color: var(--muted); text-align: center; font-size: 12px; margin: 4px 0 18px; }
.scan-count { font-size: 22px; font-weight: 700; margin: 4px 0 8px; }
.scan-phase { color: var(--muted); font-size: 12px; margin-bottom: 8px; min-height: 17px; }
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-bottom: 12px; position: relative; }
.bar div { position: absolute; inset: 0 auto 0 0; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.bar div.read { background: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.feed { list-style: none; padding: 0; margin: 0; }
.feed li { padding: 7px 0; border-bottom: 1px solid var(--line); animation: fadein .3s; }
.feed .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed .s { color: var(--muted); font-size: 12px; }
@keyframes fadein { from { opacity: 0; transform: translateY(-4px); } }
.pill { display: inline-block; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 6px; margin-right: 4px; color: var(--on-accent); text-transform: uppercase; }
.pill.keep { background: var(--keep); } .pill.save { background: var(--save); } .pill.close { background: var(--close); }
.pill.flag { background: var(--warn); }
.summary { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.stats { color: var(--muted); font-size: 11px; margin-bottom: 12px; }
.group { background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; overflow: hidden; }
.group > summary { padding: 10px 12px; font-weight: 700; cursor: pointer; display: flex; justify-content: space-between; list-style: none; }
.group > summary .count { color: var(--muted); font-weight: 500; }
.row { display: grid; grid-template-columns: 16px 1fr auto; gap: 8px; align-items: start; padding: 8px 12px; border-top: 1px solid var(--line); }
.row img { width: 16px; height: 16px; margin-top: 2px; }
.row .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .s { color: var(--muted); font-size: 12px; }
.row .r { font-size: 11px; color: var(--muted); font-style: italic; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { width: auto; margin: 0; border: 0; border-radius: 0; padding: 4px 7px; font-size: 11px; font-weight: 600; background: transparent; color: var(--muted); }
.seg button.on.keep { background: var(--keep); color: var(--on-accent); } .seg button.on.save { background: var(--save); color: var(--on-accent); } .seg button.on.close { background: var(--close); color: var(--on-accent); }
.row.locked .seg { opacity: .5; pointer-events: none; }
.sticky { position: sticky; bottom: 0; padding: 10px 0 4px; background: linear-gradient(transparent, var(--bg) 30%); }
.before-after { display: flex; align-items: center; justify-content: space-around; margin: 10px 0; }
.before-after b { font-size: 32px; } .arrow { font-size: 26px; color: var(--muted); }
.lines { padding-left: 18px; margin: 8px 0 0; }

/* Review: one group at a time */
.step-label { font-size: 12px; font-weight: 700; color: var(--accent); margin-bottom: 6px; }
.dots { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 10px; }
.dots span { width: 18px; height: 4px; border-radius: 2px; background: var(--line); }
.dots span.done { background: var(--keep); }
.dots span.on { background: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip { width: auto; margin: 0; padding: 3px 9px; font-size: 11px; border-radius: 999px; color: var(--keep); border-color: var(--keep); background: transparent; }
.group-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px; }
.gname { font-size: 18px; font-weight: 800; }
.mini { display: flex; gap: 2px; flex-wrap: wrap; justify-content: flex-end; }
.group.flash { animation: flash-in .9s ease-out; }
@keyframes flash-in {
  0% { opacity: 0; transform: translateX(28px) scale(.98); box-shadow: 0 0 0 3px var(--accent); }
  35% { opacity: 1; transform: none; box-shadow: 0 0 0 3px var(--accent), 0 0 24px var(--accent); }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.group.flash .row { animation: fadein .35s both; }
.group.flash .row:nth-child(2) { animation-delay: .15s; } .group.flash .row:nth-child(3) { animation-delay: .2s; }
.group.flash .row:nth-child(4) { animation-delay: .25s; } .group.flash .row:nth-child(5) { animation-delay: .3s; }
.group.flash .row:nth-child(n+6) { animation-delay: .35s; }
.nav { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; }
.nav button { margin: 0; }
.nav button[hidden] { display: none; }

/* Group colours (match Chrome tab-group colours) */
:root {
  --g-grey: #5f6368; --g-blue: #1a73e8; --g-red: #d93025; --g-yellow: #e8a600; --g-green: #188038;
  --g-pink: #d01884; --g-purple: #a142f4; --g-cyan: #007b83; --g-orange: #e8710a; --g: var(--accent);
}
@media (prefers-color-scheme: dark) {
  :root {
    --g-grey: #dadce0; --g-blue: #8ab4f8; --g-red: #f28b82; --g-yellow: #fdd663; --g-green: #81c995;
    --g-pink: #ff8bcb; --g-purple: #c58af9; --g-cyan: #78d9ec; --g-orange: #fcad70;
  }
}
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.tile { text-align: left; margin: 0; padding: 10px 10px 10px 14px; border-radius: 12px; position: relative; overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--g) 35%, var(--line));
  background: color-mix(in srgb, var(--g) 9%, var(--card)); animation: pop .45s both; }
.tile::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--g); }
.tile:hover { border-color: var(--g); }
.tname { font-weight: 800; font-size: 14px; color: var(--g); }
.tcount { color: var(--muted); font-size: 11px; margin-bottom: 6px; }
.tile .mini { justify-content: flex-start; }
@keyframes pop {
  0% { opacity: 0; transform: scale(.85); box-shadow: 0 0 0 0 var(--g); }
  60% { opacity: 1; transform: scale(1.03); box-shadow: 0 0 0 4px color-mix(in srgb, var(--g) 40%, transparent); }
  100% { transform: none; box-shadow: 0 0 0 0 transparent; }
}
.group { border-top: 5px solid var(--g); }
.gname { color: var(--g); }
.group.flash { animation-name: flash-in-g; }
@keyframes flash-in-g {
  0% { opacity: 0; transform: translateX(28px) scale(.98); box-shadow: 0 0 0 3px var(--g); }
  35% { opacity: 1; transform: none; box-shadow: 0 0 0 3px var(--g), 0 0 24px var(--g); }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.dots span { flex: 1; max-width: 22px; }
.dots span.on, .dots span.done { background: var(--g); }
.dots span.done { opacity: .45; }
.chip { color: var(--g); border-color: var(--g); background: color-mix(in srgb, var(--g) 8%, transparent); }

/* Review footer: pinned to the panel bottom so Next never moves between groups */
#screen-review { padding-bottom: 150px; }
#screen-review .sticky { position: fixed; left: 0; right: 0; bottom: 0; z-index: 3; padding: 10px 14px 6px;
  background: var(--bg); border-top: 1px solid var(--line); box-shadow: 0 -6px 16px rgba(0, 0, 0, .06); }
#screen-review .sticky .approve-all { margin: 8px 0 0; height: 40px; font-weight: 700; color: var(--accent);
  border: 1.5px solid var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--card)); }
#screen-review .sticky .approve-all:hover { background: color-mix(in srgb, var(--accent) 16%, var(--card)); }
#screen-review .sticky .approve-all[hidden] { display: block; visibility: hidden; }

/* Group bar: every group always visible in a fixed position */
.step-label { display: flex; justify-content: space-between; align-items: baseline; }
.reviewed-count { color: var(--muted); font-weight: 600; font-size: 11px; }
.chips { gap: 5px; }
.chip { color: var(--muted); border-color: color-mix(in srgb, var(--g) 45%, var(--line)); background: transparent; }
.chip .tick { display: inline-block; width: 1.1em; color: var(--g); }
.chip.seen { color: var(--g); background: color-mix(in srgb, var(--g) 10%, transparent); }
.chip.on { color: var(--on-accent); background: var(--g); border-color: var(--g); }
.chip.on .tick { color: var(--on-accent); }
.chip.all { --g: var(--text); }
.chip.all.on { color: var(--bg); }

/* Done screen: dark punchline + where the tabs went */
.punch { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border-radius: 16px; padding: 18px 16px 14px; margin-bottom: 12px; animation: pop .5s both; --g: var(--brand); box-shadow: 0 10px 28px color-mix(in srgb, var(--brand) 30%, transparent); }
.punch .amt { font-size: 72px; font-weight: 900; line-height: .95; color: #fff; letter-spacing: -.02em; }
.punch .line { font-size: 20px; font-weight: 800; margin-top: 8px; line-height: 1.25; }
.punch .line u { text-decoration-color: #ffd166; text-decoration-thickness: 3px; text-underline-offset: 3px; }
.punch .fine { color: #d9d9ff; font-size: 11px; margin-top: 10px; }
.fate { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 12px; animation: pop .5s .15s both; }
.fate .t { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-weight: 800; margin-bottom: 8px; }
.fate .t em { font-style: normal; color: var(--muted); font-weight: 600; font-size: 11px; text-align: right; }
.fate .bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--line); }
.fate .bar i { display: block; transform-origin: left; animation: grow .8s .4s both; }
.fate .keep { background: var(--keep); } .fate .save { background: var(--save); } .fate .close { background: var(--close); }
@keyframes grow { from { transform: scaleX(0); } }
.fate .legend { display: flex; justify-content: space-between; gap: 6px; margin-top: 8px; }
.fate .legend b { font-size: 18px; display: block; }
.fate .legend span { color: var(--muted); font-size: 11px; }
.fate .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }

/* Before/after card */
.shift { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 12px; animation: pop .5s .1s both; }
.shift .t { font-weight: 800; margin-bottom: 6px; }
.shift .pair { display: flex; align-items: center; justify-content: space-around; }
.shift .side { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.shift .side b { font-size: 30px; font-weight: 900; line-height: 1; }
.shift .lbl { color: var(--muted); font-size: 11px; }
.shift .arrow { font-size: 24px; color: var(--muted); }
.shift .g { display: inline-block; font-weight: 900; border-radius: 6px; padding: 0 8px; font-size: 14px; background: var(--good-bg); color: var(--good-text); }
.shift .g.F, .shift .g.D { background: var(--bad-bg); color: var(--bad-text); }

/* Done layout: stacked in a narrow panel, two columns when wide */
#screen-done { max-width: 960px; margin: 0 auto; }
.done-side > :last-child { margin-bottom: 12px; }
@media (min-width: 720px) {
  .done-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: stretch; }
  .done-grid .punch { margin-bottom: 0; display: flex; flex-direction: column; justify-content: center; }
  .done-side { display: flex; flex-direction: column; gap: 12px; }
  .done-side > * { margin-bottom: 0 !important; flex: 1; }
  .done-grid + button { margin-top: 12px; }
  .punch .amt { font-size: 88px; }
}

.undo { font-weight: 700; color: var(--accent); border: 1.5px solid color-mix(in srgb, var(--accent) 40%, var(--line)); }
.undo:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 8%, var(--card)); }
