:root {
  --bg: #ffffff;
  --bg-alt: #fafafa;
  --fg: #18181b;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #0060df;
  --accent-fg: #ffffff;
  --accent-soft: #e6f0ff;
  --blocking: #d70022;
  --blocking-soft: #fde8ec;
  --rerequested: #9a5b00;
  --rerequested-soft: #fdf0d8;
  --hover: #f3f4f6;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #18181b;
    --bg-alt: #232327;
    --fg: #f4f4f5;
    --muted: #a1a1aa;
    --border: #3f3f46;
    --accent: #5b8cff;
    --accent-fg: #0c1224;
    --accent-soft: #1c2a4a;
    --blocking: #ff6b80;
    --blocking-soft: #3a1620;
    --rerequested: #f0b35b;
    --rerequested-soft: #3a2c14;
    --hover: #2a2a2e;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.4);
  }
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  background: var(--bg);
  color: var(--fg);
  font-size: 14px;
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code, pre {
  font-family: "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

/* ---------- Header ---------- */

header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  max-width: 1400px;
  margin: 0 auto;
}

h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 600;
}

.header-right {
  display: flex;
  gap: 12px;
  align-items: center;
}

.user-info {
  color: var(--muted);
  font-size: 13px;
}

.user-info strong {
  color: var(--fg);
  font-weight: 500;
}

/* ---------- Buttons ---------- */

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  padding: 6px 12px;
  border-radius: 6px;
  transition: background 0.1s, border-color 0.1s;
}

button:hover {
  background: var(--hover);
}

button.primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

button.primary:hover {
  filter: brightness(1.05);
  background: var(--accent);
}

button.danger {
  color: var(--blocking);
  border-color: var(--blocking);
}

button.danger:hover {
  background: var(--blocking-soft);
}

button.icon-btn {
  background: transparent;
}

button.link-btn {
  background: transparent;
  border: none;
  color: var(--accent);
  padding: 4px 8px;
}

button.link-btn:hover {
  background: var(--hover);
  text-decoration: underline;
}

/* ---------- Filters ---------- */

.filters {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
}

.filter-row {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.filter-group {
  min-width: 0;
}

.filter-group.flex-grow {
  flex: 1 1 320px;
}

.filter-group h3 {
  margin: 0 0 6px 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  color: var(--muted);
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg);
  line-height: 1.4;
  white-space: nowrap;
}

.pill:hover {
  background: var(--hover);
}

.pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

.pill .count {
  opacity: 0.7;
  margin-left: 4px;
  font-size: 11px;
}

.filter-actions {
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.result-count {
  color: var(--muted);
  font-size: 13px;
}

/* ---------- Main ---------- */

main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 24px 64px;
}

.status {
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

.status.error {
  color: var(--blocking);
  white-space: pre-wrap;
  text-align: left;
  background: var(--blocking-soft);
  border-radius: 8px;
  padding: 16px;
}

.revision-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ---------- Revision card ---------- */

.revision {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
}

.revision.blocking {
  border-left: 3px solid var(--blocking);
}

.revision-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.revision-id {
  font-family: "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  font-weight: 600;
  color: var(--muted);
  font-size: 13px;
}

.revision-id a {
  color: inherit;
}

.bug-link {
  font-family: "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 1px 8px;
  border-radius: 4px;
}

.bug-link:hover {
  text-decoration: none;
  filter: brightness(0.95);
}

.revision-title {
  flex: 1 1 200px;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.revision-title-link {
  color: var(--fg);
  font-weight: 500;
  text-decoration: none;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.revision-title-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

.expand-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0 8px;
  height: 22px;
  line-height: 1;
  font-size: 11px;
  border-radius: 4px;
  flex-shrink: 0;
}

.expand-btn:hover {
  background: var(--hover);
  color: var(--fg);
}

.expand-btn[aria-expanded="true"] {
  background: var(--hover);
  color: var(--fg);
}

.badges {
  display: flex;
  gap: 4px;
  align-items: center;
}

.badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--hover);
  color: var(--muted);
}

.badge.blocking {
  background: var(--blocking-soft);
  color: var(--blocking);
}

.badge.explicit {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge.re-requested {
  background: var(--rerequested-soft);
  color: var(--rerequested);
}

.revision-meta {
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.revision-meta .reviewers {
  flex: 1 1 auto;
}

.reviewer {
  color: var(--muted);
}

.reviewer.matched {
  color: var(--fg);
  font-weight: 500;
}

.reviewer.matched.blocking::after {
  content: " !";
  color: var(--blocking);
  font-weight: 700;
}

.reviewer.accepted {
  text-decoration: line-through;
  opacity: 0.7;
}

.reviewer.rejected {
  color: var(--blocking);
}

.reviewer.accepted-stale {
  text-decoration: line-through;
  text-decoration-style: dashed;
  text-decoration-color: var(--accent);
}

.reviewer.accepted-stale::after {
  content: " ↻";
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.revision-summary {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--bg-alt);
  border-radius: 6px;
  white-space: pre-wrap;
  font-family: "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12.5px;
  color: var(--fg);
  border: 1px solid var(--border);
  max-height: 400px;
  overflow: auto;
}

/* ---------- Dialog ---------- */

dialog {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  max-width: 520px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

#settings-form {
  padding: 20px 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#settings-form h2 {
  margin: 0;
  font-size: 16px;
}

#settings-form .field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}

#settings-form .field > span {
  font-weight: 500;
}

#settings-form .field small {
  color: var(--muted);
  font-size: 12px;
}

#settings-form input {
  width: 100%;
  padding: 8px 10px;
  font-family: "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-alt);
  color: var(--fg);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.dialog-actions .danger {
  margin-right: auto;
}

/* ---------- Loading spinner ---------- */

.spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

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