:root {
  --bg: #fff; --fg: #1a1a1a; --muted: #666; --line: #e2e2e2; --card: #f7f7f8; --hover: #eef2ff;
  --accent: #2563eb; --accent-fg: #fff; --danger: #dc2626; --warn-bg: #fff7ed; --warn-fg: #9a3412; --danger-bg: #fef2f2;
  --draft: #6b7280; --ready: #d97706; --released: #16a34a; --abandoned: #9ca3af; --stage: #7c3aed;
  --sp: 8px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111214; --fg: #e6e6e6; --muted: #9a9a9a; --line: #2c2d31; --card: #1a1b1e; --hover: #1f2330;
    --accent: #3b82f6; --warn-bg: #2a1d0f; --warn-fg: #fdba74; --danger-bg: #2a1414;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.45 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0 0 calc(var(--sp) * 1.5); }
h2 { font-size: 16px; margin: calc(var(--sp) * 3) 0 var(--sp); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
p { margin: var(--sp) 0; }

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

.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: calc(var(--sp) * 2); padding: var(--sp) calc(var(--sp) * 2); border-bottom: 1px solid var(--line); background: var(--bg); }
.brand { font-weight: 600; color: var(--fg); }
.topnav { display: flex; gap: calc(var(--sp) * 1.5); flex: 1; }
.user { display: flex; align-items: center; gap: var(--sp); color: var(--muted); }

main { max-width: 960px; margin: 0 auto; padding: calc(var(--sp) * 2); }
.center { text-align: center; padding: 60px 16px; }
.toolbar { display: flex; align-items: center; gap: var(--sp); flex-wrap: wrap; margin-bottom: var(--sp); }
.toolbar h1, .toolbar h2 { flex: 1; margin: 0; }

.btn { font: inherit; padding: 6px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--fg); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn-primary .spinner { border-color: rgba(255,255,255,.4); border-top-color: #fff; }
.btn-danger { color: var(--danger); }
.btn-sm { padding: 3px 8px; font-size: 12px; }
.actions { display: flex; gap: var(--sp); flex-wrap: wrap; margin: calc(var(--sp) * 1.5) 0; }

.table-wrap { overflow-x: auto; max-width: 100%; margin: var(--sp) 0; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
th { font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--hover); }
td.versions { font-size: 13px; }

.badge { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; font-weight: 600; color: #fff; text-transform: uppercase; vertical-align: middle; }
.badge + .badge { margin-left: 4px; }
.badge-draft { background: var(--draft); }
.badge-ready { background: var(--ready); }
.badge-released { background: var(--released); }
.badge-abandoned { background: var(--abandoned); }
.badge-stage { background: var(--stage); }
.badge-queue { background: transparent; color: var(--ready); border: 1px solid var(--ready); }
.badge-ahead { background: transparent; color: var(--ready); border: 1px solid var(--ready); text-transform: none; font-weight: 500; }
.badge-same { background: transparent; color: var(--muted); border: 1px solid var(--line); text-transform: none; font-weight: 500; }
.badge-pre { background: transparent; color: var(--danger); border: 1px solid var(--danger); text-transform: none; font-weight: 500; cursor: help; }
.ok { color: var(--released); }
.diff { color: var(--ready); }
.muted { color: var(--muted); }
.error { color: var(--danger); }
.note { padding: var(--sp) calc(var(--sp) * 1.5); background: var(--card); border-radius: 6px; margin: calc(var(--sp) * 1.5) 0; }
.warn { padding: var(--sp) calc(var(--sp) * 1.5); background: var(--warn-bg); color: var(--warn-fg); border-radius: 6px; margin: var(--sp) 0; }
.warn ul, .note ul, .modal-body ul { margin: 4px 0 0; padding-left: 20px; }
.explainer { color: var(--muted); margin: 0 0 var(--sp); }

.form { display: grid; gap: calc(var(--sp) * 1.5); max-width: 520px; }
.form label { display: grid; gap: 4px; font-weight: 600; }
.form label span.hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.form .field-error { color: var(--danger); font-weight: 400; font-size: 12px; }
input, select, textarea { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); width: 100%; }
input[aria-invalid="true"] { border-color: var(--danger); }
textarea { min-height: 80px; resize: vertical; }

.timeline { display: flex; flex-wrap: wrap; gap: 0; margin: var(--sp) 0 calc(var(--sp) * 2); padding: 0; list-style: none; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.timeline li { flex: 1 1 120px; padding: var(--sp) calc(var(--sp) * 1.5); border-right: 1px solid var(--line); background: var(--card); min-width: 0; }
.timeline li:last-child { border-right: 0; }
.timeline .step { display: block; font-size: 11px; text-transform: uppercase; font-weight: 600; color: var(--muted); }
.timeline .when { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timeline .who { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timeline li.done { background: var(--bg); }
.timeline li.done .step { color: var(--released); }
.timeline li.pending { opacity: .55; }
.timeline li.blocked .step { color: var(--abandoned); }

.spinner { width: 20px; height: 20px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
.spinner-sm { width: 12px; height: 12px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 10; }
.modal { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: calc(var(--sp) * 2) calc(var(--sp) * 2.5); width: min(460px, 92vw); max-height: 90vh; overflow: auto; }
.modal h2 { margin-top: 0; }
.modal-body p { margin: 6px 0; }
.modal-body code { white-space: nowrap; }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--sp); margin-top: calc(var(--sp) * 1.5); }

.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 20; max-width: min(560px, 94vw); }
.toast { background: var(--fg); color: var(--bg); padding: 8px 14px; border-radius: 6px; display: flex; align-items: flex-start; gap: 10px; }
.toast a { color: inherit; text-decoration: underline; }
.toast-error { background: var(--danger); color: #fff; }
.toast .toast-close { background: none; border: 0; color: inherit; cursor: pointer; font: inherit; padding: 0 2px; opacity: .7; }
.toast .toast-close:hover { opacity: 1; }

@media (max-width: 600px) {
  .topnav { gap: var(--sp); }
  main { padding: 10px; }
  .form { max-width: none; }
  .timeline li { flex-basis: 100%; border-right: 0; border-bottom: 1px solid var(--line); }
  .timeline li:last-child { border-bottom: 0; }
}

/* Class display rules (flex/grid) must not defeat the hidden attribute. */
[hidden] { display: none !important; }
