:root {
  --bg: #0f0c15;
  --bg-2: #17131f;
  --card: #1d1828;
  --card-2: #251f33;
  --line: #342c45;
  --text: #f4f0fa;
  --muted: #a49cb5;
  --brand-a: #ff4f7b;
  --brand-b: #ff9a5a;
  --merge: #2fd480;
  --close: #ff5d6c;
  --comment: #5aa9ff;
  --skip: #f5b93d;
  --blocker: #ff5d6c;
  --major: #ff9a5a;
  --minor: #f5d24a;
  --nit: #8e86a3;
  --radius: 22px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 50% -200px, #2a1730 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.link { color: var(--comment); text-decoration: none; }
.link:hover { text-decoration: underline; }

.demo-banner {
  background: linear-gradient(90deg, var(--brand-a), var(--brand-b));
  color: #1a0b12; text-align: center; font-weight: 600; font-size: 13px; padding: 6px 16px;
}
.demo-banner a { font-weight: 700; }

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px; max-width: 1100px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 800; font-size: 19px; letter-spacing: -0.02em; }
.brand-mark { font-size: 22px; }
.repo-button {
  background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 14px; font-weight: 600; font-size: 14px; max-width: 40vw;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.repo-button:hover { border-color: var(--muted); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.method { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.method select {
  background: var(--card); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 5px 8px; font: inherit; font-size: 13px;
}
.pill {
  font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.pill.ok { color: var(--merge); border-color: color-mix(in srgb, var(--merge) 40%, transparent); }
.pill.bad { color: var(--close); }

main { max-width: 1100px; margin: 0 auto; padding: 8px 16px 40px; }

/* Buttons */
.primary {
  border: 0; border-radius: 999px; padding: 12px 26px; font-weight: 700;
  background: linear-gradient(90deg, var(--brand-a), var(--brand-b)); color: #1a0b12;
  box-shadow: 0 8px 30px -8px rgba(255, 79, 123, .6);
}
.primary:disabled { opacity: .5; cursor: default; }
.ghost { background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 10px 20px; font-weight: 600; }

/* Connect */
.hero-panel { max-width: 560px; margin: 8vh auto 0; text-align: center; }
.hero-emoji { font-size: 64px; animation: beat 1.6s ease-in-out infinite; }
@keyframes beat { 0%, 100% { transform: scale(1); } 15% { transform: scale(1.15); } 30% { transform: scale(1); } }
.hero-panel h1 { font-size: 44px; line-height: 1.05; letter-spacing: -0.03em; margin: 12px 0; }
.lede { color: var(--muted); font-size: 17px; }
.legend { list-style: none; padding: 0; margin: 26px auto; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; max-width: 420px; text-align: left; }
.legend li { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.key { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--card); border: 1px solid var(--line); font-size: 15px; }
.key.merge { color: var(--merge); } .key.close { color: var(--close); } .key.comment { color: var(--comment); } .key.skip { color: var(--skip); }

/* Repo picker */
.panel { max-width: 640px; margin: 4vh auto 0; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.panel h2 { font-size: 28px; letter-spacing: -0.02em; margin: 0 0 12px; }
.search {
  width: 100%; padding: 12px 16px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font: inherit; outline: none;
}
.search:focus { border-color: var(--brand-a); }
.repo-list { list-style: none; padding: 0; margin: 14px 0; display: grid; gap: 8px; }
.repo-list button {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px;
}
.repo-list button:hover { border-color: var(--brand-a); transform: translateY(-1px); }
.repo-list img { width: 36px; height: 36px; border-radius: 10px; background: var(--card-2); }
.repo-name { font-weight: 600; }
.repo-meta { color: var(--muted); font-size: 12px; }
.repo-list .go { margin-left: auto; color: var(--muted); }

/* Deck */
.deck-wrap { display: flex; flex-direction: column; align-items: center; }
.deck { position: relative; width: min(440px, 100%); height: min(680px, calc(100vh - 230px)); min-height: 460px; margin-top: 6px; }
.card {
  position: absolute; inset: 0; border-radius: var(--radius); overflow: hidden;
  background: var(--card); border: 1px solid var(--line);
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .6);
  display: flex; flex-direction: column; touch-action: pan-y; user-select: none;
  transition: transform .35s cubic-bezier(.2, .8, .2, 1), opacity .35s;
  will-change: transform;
}
.card.dragging { transition: none; cursor: grabbing; }
.card.behind-1 { transform: translateY(12px) scale(.96); opacity: .85; }
.card.behind-2 { transform: translateY(24px) scale(.92); opacity: .5; }
.card.behind-1, .card.behind-2 { pointer-events: none; }

.stamp {
  position: absolute; top: 34px; z-index: 5; padding: 6px 14px; border: 4px solid; border-radius: 12px;
  font-weight: 800; font-size: 30px; letter-spacing: .06em; opacity: 0; pointer-events: none;
}
.stamp.like { left: 22px; color: var(--merge); transform: rotate(-14deg); }
.stamp.nope { right: 22px; color: var(--close); transform: rotate(14deg); }

.hero {
  position: relative; padding: 20px 20px 16px; cursor: grab;
  background: linear-gradient(135deg, var(--h1), var(--h2));
}
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 30%, rgba(15, 12, 21, .55)); pointer-events: none; }
.hero > * { position: relative; z-index: 1; }
.hero-top { display: flex; align-items: center; gap: 12px; }
.avatar { width: 56px; height: 56px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .85); background: var(--card-2); flex: none; }
.who { min-width: 0; }
.who .num { font-family: var(--mono); font-size: 13px; opacity: .9; }
.who .author { font-weight: 700; font-size: 15px; }
.who .age { font-size: 12px; opacity: .85; }
.hero h3 { font-size: 22px; line-height: 1.2; letter-spacing: -0.02em; margin: 14px 0 10px; word-break: break-word; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: rgba(15, 12, 21, .45); backdrop-filter: blur(6px); }
.tag.add { color: #8ff0bb; } .tag.del { color: #ffb0b8; }
.tag.mono { font-family: var(--mono); font-weight: 500; }
.tag.draft { background: var(--skip); color: #251a00; }

.body { flex: 1; overflow-y: auto; padding: 16px 20px 20px; overscroll-behavior: contain; user-select: text; }
.verdict {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px;
  background: var(--card-2); border: 1px solid var(--line); margin-bottom: 12px;
}
.verdict .icon { font-size: 26px; }
.verdict .label { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.verdict .value { font-weight: 800; font-size: 17px; }
.verdict.merge { border-color: color-mix(in srgb, var(--merge) 50%, transparent); }
.verdict.merge .value { color: var(--merge); }
.verdict.needs_work { border-color: color-mix(in srgb, var(--skip) 50%, transparent); }
.verdict.needs_work .value { color: var(--skip); }
.verdict.close { border-color: color-mix(in srgb, var(--close) 50%, transparent); }
.verdict.close .value { color: var(--close); }
.tagline { font-size: 17px; font-style: italic; font-weight: 500; margin: 4px 0 10px; }
.summary { color: #dcd5e8; margin: 0 0 14px; }
.facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 14px; }
.fact { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 7px 8px; text-align: center; }
.fact .k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.fact .v { font-weight: 700; font-size: 13px; text-transform: capitalize; }
.v.good { color: var(--merge); } .v.warn { color: var(--skip); } .v.bad { color: var(--close); }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; margin: 16px 0 8px; }
.flags { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.flags.green li { padding-left: 22px; position: relative; color: #dcd5e8; }
.flags.green li::before { content: "💚"; position: absolute; left: 0; font-size: 12px; top: 2px; }
.finding { background: var(--bg-2); border: 1px solid var(--line); border-left: 4px solid var(--sev); border-radius: 12px; padding: 10px 12px; }
.finding .row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.sev { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--sev); }
.finding .t { font-weight: 600; }
.finding .loc { font-family: var(--mono); font-size: 12px; color: var(--comment); text-decoration: none; word-break: break-all; }
.finding .loc:hover { text-decoration: underline; }
.finding p { margin: 6px 0 0; color: #cfc7dc; font-size: 14px; }
.finding .fix { font-size: 13px; color: var(--muted); }
.finding .fix b { color: var(--merge); font-weight: 600; }
.tests { font-size: 13px; color: var(--muted); margin-top: 12px; }
.card-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; font-size: 13px; }
.card-foot button { background: none; border: 0; color: var(--muted); padding: 0; }
.card-foot button:hover { color: var(--text); }

/* Reviewing state */
.reviewing { text-align: center; padding: 14px 0 0; }
.radar { width: 74px; height: 74px; margin: 6px auto 10px; border-radius: 50%; position: relative; background: radial-gradient(circle, var(--brand-a) 0 7px, transparent 8px); }
.radar::before, .radar::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--brand-a); animation: ping 1.8s ease-out infinite; }
.radar::after { animation-delay: .9s; }
@keyframes ping { from { transform: scale(.2); opacity: 1; } to { transform: scale(1.2); opacity: 0; } }
.reviewing h4 { margin: 0; font-size: 16px; }
.reviewing .sub { color: var(--muted); font-size: 13px; margin: 4px 0 12px; }
.log { list-style: none; padding: 10px 12px; margin: 0; text-align: left; background: #0b0910; border: 1px solid var(--line); border-radius: 12px; font-family: var(--mono); font-size: 11.5px; color: #bdb4cc; max-height: 220px; overflow: hidden; }
.log li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 1px 0; }
.log li.cmd::before { content: "$ "; color: var(--merge); }
.log li.step { color: var(--muted); }
.log li.warn, .log li.error { color: var(--close); }
.errorbox { background: color-mix(in srgb, var(--close) 12%, transparent); border: 1px solid color-mix(in srgb, var(--close) 40%, transparent); border-radius: 14px; padding: 12px 14px; margin-top: 8px; }
.errorbox button { margin-top: 10px; }

/* Empty deck */
.empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 30px; border: 2px dashed var(--line); border-radius: var(--radius); }
.empty .big { font-size: 54px; }
.empty h3 { font-size: 22px; margin: 8px 0 6px; }

/* Controls */
.controls { display: flex; align-items: center; gap: 18px; margin-top: 22px; }
.ctl {
  width: 64px; height: 64px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: var(--card); font-size: 26px; font-weight: 800;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .7), inset 0 0 0 1px var(--line);
  transition: transform .15s ease, box-shadow .15s ease;
}
.ctl:hover { transform: scale(1.08); }
.ctl:active { transform: scale(.95); }
.ctl:disabled { opacity: .35; transform: none; cursor: default; }
.ctl.skip, .ctl.comment { width: 50px; height: 50px; font-size: 20px; }
.ctl.close { color: var(--close); } .ctl.merge { color: var(--merge); font-size: 30px; }
.ctl.skip { color: var(--skip); } .ctl.comment { color: var(--comment); }
.ctl.close:hover { box-shadow: 0 0 0 2px var(--close), 0 10px 30px -10px var(--close); }
.ctl.merge:hover { box-shadow: 0 0 0 2px var(--merge), 0 10px 30px -10px var(--merge); }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 14px; text-align: center; }

/* Toasts */
.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 50; width: min(400px, calc(100% - 32px)); }
.toast {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px;
  background: #241e31; border: 1px solid var(--line); box-shadow: 0 20px 40px -12px rgba(0, 0, 0, .7);
  animation: rise .25s ease-out; font-size: 14px; position: relative; overflow: hidden;
}
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }
.toast .msg { flex: 1; min-width: 0; }
.toast .msg small { display: block; color: var(--muted); }
.toast button { background: var(--card-2); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; font-weight: 700; font-size: 13px; white-space: nowrap; }
.toast a { color: var(--comment); font-weight: 600; font-size: 13px; white-space: nowrap; }
.toast .bar { position: absolute; left: 0; bottom: 0; height: 3px; background: linear-gradient(90deg, var(--brand-a), var(--brand-b)); animation: drain linear forwards; }
@keyframes drain { from { width: 100%; } to { width: 0; } }
.toast.ok { border-color: color-mix(in srgb, var(--merge) 50%, transparent); }
.toast.err { border-color: color-mix(in srgb, var(--close) 50%, transparent); }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--brand-a); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Dialog */
.dialog { border: 1px solid var(--line); border-radius: 20px; background: var(--card); color: var(--text); padding: 22px; width: min(560px, calc(100% - 32px)); }
.dialog::backdrop { background: rgba(8, 6, 12, .7); backdrop-filter: blur(4px); }
.dialog h3 { margin: 0 0 12px; }
.dialog textarea { width: 100%; background: var(--bg-2); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 12px; font: inherit; resize: vertical; outline: none; }
.dialog textarea:focus { border-color: var(--comment); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.chip { background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-size: 12.5px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip:hover { border-color: var(--comment); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }

/* Match */
.match { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: radial-gradient(circle at 50% 40%, rgba(20, 70, 45, .97), rgba(8, 6, 12, .98) 65%); backdrop-filter: blur(10px); animation: fade .3s; }
@keyframes fade { from { opacity: 0; } }
.match-inner { text-align: center; padding: 20px; }
.match-title { font-size: clamp(44px, 10vw, 78px); font-weight: 800; font-style: italic; letter-spacing: -0.03em; background: linear-gradient(90deg, #8ff0bb, var(--merge), #b6ff8f); -webkit-background-clip: text; background-clip: text; color: transparent; animation: pop .5s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop { from { transform: scale(.4); } }
.match-sub { font-size: 17px; margin: 6px 0 18px; color: #dcd5e8; }
.match-hearts { font-size: 40px; margin-bottom: 22px; }

@media (max-width: 900px) {
  .toasts { left: 50%; right: auto; transform: translateX(-50%); bottom: auto; top: 12px; }
}
@media (max-width: 560px) {
  .topbar { padding: 10px 16px; gap: 8px; }
  .brand span:last-child { display: none; }
  .repo-button { max-width: none; flex: 1; min-width: 0; }
  .topbar-right { margin-left: 0; }
  .method span, #gh-pill { display: none; }
  .controls { margin-top: 14px; }
  .hint { display: none; }
  .hero-panel h1 { font-size: 34px; }
  .facts { grid-template-columns: repeat(2, 1fr); }
  .deck { height: calc(100dvh - 200px); min-height: 380px; }
  .legend { grid-template-columns: 1fr; }
}
.log:empty { display: none; }
.deck-status { color: var(--muted); font-size: 12.5px; margin: 10px 0 0; min-height: 1em; text-align: center; }
.deck-status:not(:empty)::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--brand-a); margin-right: 8px; animation: beat 1.2s infinite; }

.oc-badge {
  font-size: 11.5px; font-weight: 700; letter-spacing: .02em; text-decoration: none; white-space: nowrap;
  padding: 4px 10px; border-radius: 999px; color: #ffd9e3;
  background: linear-gradient(90deg, rgba(255, 79, 123, .18), rgba(255, 154, 90, .18));
  border: 1px solid rgba(255, 120, 120, .35);
}
.oc-badge:hover { border-color: var(--brand-a); }
.cta-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 22px; }
.cta-row a { text-decoration: none; display: inline-block; }
.app-foot { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; padding: 0 16px 28px; }
.app-foot a { color: var(--muted); }
.app-foot a:hover { color: var(--text); }
#login-form .search { max-width: 320px; margin: 18px auto 0; display: block; }
body.embed .topbar, body.embed .demo-banner, body.embed .hint, body.embed .app-foot, body.embed .deck-status { display: none !important; }
body.embed { background: var(--bg); }
body.embed main { padding: 12px 12px 8px; }
body.embed .deck { height: calc(100vh - 110px); min-height: 0; margin-top: 0; }
body.embed .controls { margin-top: 14px; }
body.embed .ctl { width: 54px; height: 54px; font-size: 22px; }
body.embed .ctl.skip, body.embed .ctl.comment { width: 44px; height: 44px; font-size: 18px; }
body.embed .toasts { left: 50%; right: auto; transform: translateX(-50%); top: 10px; bottom: auto; width: calc(100% - 24px); }
@media (max-width: 560px) { .oc-badge { display: none; } }
