:root {
  --bg:        #f6f7f9;
  --surface:   #ffffff;
  --ink:       #16191d;
  --muted:     #5b636e;
  --hairline:  #dde1e6;
  --accent:    #1f3a5f;
  --accent-in: #ffffff;
  --danger:    #b3261e;
  --ok:        #1c6b3f;
  --warn:      #8a5a00;
  --radius:    10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:       #14171b;
    --surface:  #1c2026;
    --ink:      #e8eaed;
    --muted:    #9aa3ad;
    --hairline: #2c323a;
    --accent:   #7ea6d8;
    --accent-in:#10141a;
    --danger:   #f2857c;
    --ok:       #7fd0a1;
    --warn:     #e5b45f;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}

header#topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--accent); color: var(--accent-in);
}
header#topbar h1 { font-size: 16px; margin: 0; flex: 1; font-weight: 600; }
header#topbar nav { display: flex; gap: 12px; }
header#topbar nav a { color: var(--accent-in); text-decoration: none; opacity: .82; font-size: 13px; }
header#topbar nav a:hover, header#topbar nav a.active { opacity: 1; text-decoration: underline; }
button.icon {
  background: none; border: 0; color: inherit; font-size: 20px; cursor: pointer; padding: 0 4px;
}

main { padding: 14px; padding-bottom: 60px; max-width: 900px; margin: 0 auto; }

.card {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
}
.card h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 10px; }
.card h3 { font-size: 15px; margin: 0 0 6px; }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.stack > * + * { margin-top: 10px; }

label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
input, textarea, select {
  width: 100%; padding: 9px 10px; font: inherit; color: var(--ink);
  background: var(--bg); border: 1px solid var(--hairline); border-radius: 8px;
}
textarea { min-height: 76px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

button {
  font: inherit; font-weight: 600; padding: 9px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--hairline); background: var(--surface); color: var(--ink);
}
button.primary { background: var(--accent); color: var(--accent-in); border-color: var(--accent); }
button.danger  { color: var(--danger); }
button.small   { padding: 5px 9px; font-size: 13px; font-weight: 500; }
button:disabled { opacity: .5; cursor: default; }

a.item {
  display: block; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px;
}
a.item:hover { border-color: var(--accent); }

.pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; border: 1px solid var(--hairline); color: var(--muted);
}
.pill.needs_review { color: var(--warn);   border-color: var(--warn); }
.pill.ready        { color: var(--ok);     border-color: var(--ok); }
.pill.delivered    { color: var(--muted); }
.pill.failed       { color: var(--danger); border-color: var(--danger); }
.pill.queued, .pill.running { color: var(--accent); border-color: var(--accent); }

.entry { border: 1px solid var(--hairline); border-radius: 8px; padding: 10px; margin-bottom: 8px; }
.entry .row.between { margin-bottom: 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }

iframe.preview {
  width: 100%; height: 70vh; border: 1px solid var(--hairline); border-radius: var(--radius); background: #fff;
}

#toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: max(16px, env(safe-area-inset-bottom));
  background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 999px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .18s; max-width: 90vw; z-index: 50;
}
#toast.show { opacity: 1; }
#toast.error { background: var(--danger); color: #fff; }

.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
