:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e3e6ea;
  --text: #1c1f24;
  --muted: #6b7280;
  --primary: #d8232a; /* Pokémon-red accent, matches the app */
  --primary-ink: #ffffff;
  --ok: #1a9d54;
  --fail: #d8232a;
  --run: #d9870b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 4px 16px rgba(16, 24, 40, 0.06);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang TC", "Microsoft JhengHei", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a20;
    --border: #262b33;
    --text: #e8eaed;
    --muted: #9aa3af;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 22px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

/* `hidden` must win over class-based `display` rules (e.g. .gate/.progress set
   display:grid, which would otherwise override the attribute and never hide). */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.logo { font-weight: 800; letter-spacing: 0.02em; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: filter 0.12s ease, opacity 0.12s ease;
}
.btn:hover { filter: brightness(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.btn-ghost { background: transparent; }
.btn-lg { padding: 12px 22px; font-size: 15px; }
.btn-sm { padding: 6px 10px; font-size: 13px; }

/* ---- Sign-in gate ---- */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.gate-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px;
  max-width: 400px;
  text-align: center;
}
.gate-card .logo { font-size: 22px; color: var(--primary); }
.gate-card h1 { font-size: 20px; margin: 6px 0 12px; }
.gate-card p { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 0 0 22px; }
.gate-card .btn { width: 100%; justify-content: center; }

/* ---- Top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand { font-size: 15px; font-weight: 600; }
.brand .logo { color: var(--primary); }
.brand .sep { color: var(--muted); margin: 0 6px; }
.user { display: flex; align-items: center; gap: 10px; }
.avatar { border-radius: 50%; background: var(--border); }
.user-login { font-size: 14px; font-weight: 600; }

/* ---- Content ---- */
.content { max-width: 880px; margin: 28px auto; padding: 0 22px; display: grid; gap: 22px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.card-head, .publish-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.card h2 { font-size: 16px; margin: 0 0 2px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.publish-head p { font-size: 13.5px; line-height: 1.5; margin: 6px 0 0; max-width: 52ch; }

/* ---- Progress ---- */
.progress { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border); display: grid; gap: 10px; }
.progress-row { display: flex; align-items: center; gap: 10px; }
.progress-message { font-size: 14px; font-weight: 500; }
.progress-elapsed { margin-left: auto; font-variant-numeric: tabular-nums; }
.badge {
  text-transform: capitalize;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--run) 16%, transparent);
  color: var(--run);
}
.badge[data-state="done"] { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.badge[data-state="failed"] { background: color-mix(in srgb, var(--fail) 16%, transparent); color: var(--fail); }
.bar { height: 8px; border-radius: 999px; background: var(--border); overflow: hidden; }
.bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--primary);
  transition: width 0.4s ease;
}
.bar-fill.done { background: var(--ok); }
.bar-fill.failed { background: var(--fail); }
.bar-fill.indeterminate {
  width: 35% !important;
  animation: slide 1.3s ease-in-out infinite;
}
@keyframes slide {
  0% { margin-left: -35%; }
  100% { margin-left: 100%; }
}

/* ---- Runs table ---- */
.runs { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: 14px; }
.runs th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; padding: 0 10px 8px; }
.runs td { padding: 11px 10px; border-top: 1px solid var(--border); vertical-align: middle; }
.runs tbody tr:hover { background: color-mix(in srgb, var(--text) 3%, transparent); }
.runs .empty td { color: var(--muted); text-align: center; padding: 22px; }
.status { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dot.ok { background: var(--ok); }
.dot.fail { background: var(--fail); }
.dot.run { background: var(--run); animation: pulse 1.1s ease-in-out infinite; }
.dot.queued { background: var(--muted); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.runs a { color: var(--primary); text-decoration: none; font-weight: 600; }
.runs a:hover { text-decoration: underline; }
.mono { font-variant-numeric: tabular-nums; color: var(--muted); }

.error { color: var(--fail); font-size: 13.5px; margin: 12px 0 0; }

@media (max-width: 600px) {
  .publish-head { flex-direction: column; }
  .publish-head .btn { width: 100%; justify-content: center; }
  .runs th:nth-child(2), .runs td:nth-child(2) { display: none; }
}
