/* Phone-first: one column, big tap targets, bottom tab bar like a native app. */
:root {
  --bg: #f4f6f2;
  --surface: #ffffff;
  --ink: #1b221d;
  --muted: #5f6b63;
  --line: #dfe5dd;
  --accent: #2f6b4f;
  --accent-ink: #ffffff;
  --accent-soft: #e2efe6;
  --live: #1f7a4d;
  --live-soft: #ddf2e5;
  --warn: #9a5b00;
  --warn-soft: #fbefd9;
  --bad: #b3261e;
  --bad-soft: #fbe3e1;
  --idle: #5f6b63;
  --idle-soft: #eceeea;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141815;
    --surface: #1d231f;
    --ink: #edf2ee;
    --muted: #9aa69e;
    --line: #2e3631;
    --accent: #6fbf94;
    --accent-ink: #0f1a13;
    --accent-soft: #23392c;
    --live: #6fd39b;
    --live-soft: #1f3a2b;
    --warn: #f0b85a;
    --warn-soft: #3a2f1c;
    --bad: #ff8a80;
    --bad-soft: #3d2220;
    --idle: #9aa69e;
    --idle-soft: #272e29;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }
[hidden] { display: none !important; }

.boot { padding: 40vh 16px; text-align: center; color: var(--muted); }

/* Layout */
.screen {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) max(16px, env(safe-area-inset-right, 0px))
    calc(env(safe-area-inset-bottom, 0px) + 96px) max(16px, env(safe-area-inset-left, 0px));
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.topbar { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.topbar h1 { font-size: 1.6rem; line-height: 1.15; margin: 0; flex: 1; letter-spacing: -0.01em; text-wrap: balance; }
.topbar h1.small { font-size: 1.15rem; }
.back { border: 0; background: none; color: var(--accent); font-weight: 600; padding: 10px 4px; cursor: pointer; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 6px max(8px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 6px) max(8px, env(safe-area-inset-left, 0px));
}
.tabs a {
  flex: 1; max-width: 200px; text-align: center; text-decoration: none; color: var(--muted);
  font-size: 0.75rem; font-weight: 600; padding: 6px 0; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tabs a svg { width: 24px; height: 24px; }
.tabs a[aria-current="page"] { color: var(--accent); }

/* Cards and lists */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.list { display: flex; flex-direction: column; gap: 10px; }
.section-title { font-size: 0.8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin: 8px 0 -6px; }

.campaign { display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: inherit; }
.campaign .row { display: flex; align-items: center; gap: 10px; }
.campaign .name { font-weight: 650; font-size: 1.05rem; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.campaign .meta { display: flex; gap: 16px; color: var(--muted); font-size: 0.875rem; font-variant-numeric: tabular-nums; flex-wrap: wrap; }
.campaign .meta b { color: var(--ink); font-weight: 650; }

.thumbs { display: flex; gap: 6px; flex-wrap: wrap; }
.thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--idle-soft); display: block; }
.thumbs.large { margin-top: 8px; }
.thumbs.large .thumb { width: 72px; height: 72px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--accent-soft); color: var(--ink); border-radius: 999px; padding: 3px 10px; font-size: 0.85rem; font-weight: 550; }
.chip button { border: 0; background: none; padding: 0 0 0 6px; cursor: pointer; color: var(--muted); font-size: 1rem; line-height: 1; }

.pill { border-radius: 999px; padding: 2px 9px; font-size: 0.75rem; font-weight: 700; white-space: nowrap; }
.pill.live { background: var(--live-soft); color: var(--live); }
.pill.scheduled { background: var(--warn-soft); color: var(--warn); }
.pill.ended, .pill.paused { background: var(--idle-soft); color: var(--idle); }
.pill.failed { background: var(--bad-soft); color: var(--bad); }

/* Summary numbers */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; min-width: 0; }
.stat .n { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat .l { font-size: 0.78rem; color: var(--muted); }
.stat.bad .n { color: var(--bad); }

.bars { display: flex; align-items: flex-end; gap: 4px; height: 96px; padding-top: 8px; }
.bars div { flex: 1; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; opacity: 0.85; }
.bars div.zero { background: var(--line); opacity: 1; }
.bar-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.72rem; margin-top: 4px; }

/* Activity */
.event { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.event:last-child { border-bottom: 0; }
.event .who { font-weight: 600; overflow-wrap: anywhere; }
.event .what { color: var(--muted); font-size: 0.875rem; overflow-wrap: anywhere; }
.event .when { color: var(--muted); font-size: 0.8rem; white-space: nowrap; margin-left: auto; }
.event .err { color: var(--bad); font-size: 0.85rem; margin-top: 2px; }

/* Forms */
form { display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-weight: 650; font-size: 0.95rem; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 0; }
input[type="text"], input[type="email"], input[type="password"], input[type="url"], input[type="datetime-local"], textarea {
  width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 12px 14px; min-height: 48px;
  font-size: 16px; /* stops iPhone zooming in */
}
textarea { min-height: 110px; resize: vertical; }
input:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }
.row-input { display: flex; gap: 8px; }
.row-input input { flex: 1; min-width: 0; }
.count { font-size: 0.8rem; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.count.over { color: var(--bad); font-weight: 700; }

.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--idle-soft); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { border: 0; border-radius: 10px; padding: 10px; background: transparent; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgb(0 0 0 / 0.12); }

.quick { display: flex; flex-wrap: wrap; gap: 6px; }
.quick button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 0.85rem; cursor: pointer; }

.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.toggle input { width: 52px; height: 30px; appearance: none; background: var(--line); border-radius: 999px; position: relative; cursor: pointer; transition: background 0.15s; flex: none; }
.toggle input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 0.25); transition: transform 0.15s; }
.toggle input:checked { background: var(--live); }
.toggle input:checked::after { transform: translateX(22px); }

.posts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.post { position: relative; aspect-ratio: 1; border: 0; padding: 0; background: var(--idle-soft); border-radius: 8px; overflow: hidden; cursor: pointer; max-width: 100%; }
.post img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post .cap { position: absolute; inset: auto 0 0 0; font-size: 0.65rem; padding: 4px; color: #fff; background: linear-gradient(transparent, rgb(0 0 0 / 0.6)); text-align: left; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.post[aria-pressed="true"] { outline: 3px solid var(--accent); outline-offset: -3px; }
.post[aria-pressed="true"]::after { content: "✓"; position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 800; }

.preview { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--accent-soft); border-radius: 18px 18px 18px 4px; padding: 12px 14px; font-size: 0.95rem; }

/* Buttons */
.btn { border: 0; border-radius: 12px; padding: 14px 18px; font-weight: 650; cursor: pointer; min-height: 48px; text-align: center; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn.danger.armed { background: var(--bad); color: #fff; }
.btn.small { padding: 8px 12px; min-height: 40px; font-size: 0.9rem; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.block { width: 100%; }
.actions { display: flex; flex-direction: column; gap: 10px; }

.fab {
  position: fixed; z-index: 21; right: max(16px, env(safe-area-inset-right, 0px));
  bottom: calc(env(safe-area-inset-bottom, 0px) + 76px);
  border-radius: 999px; padding: 14px 20px; box-shadow: 0 6px 20px rgb(0 0 0 / 0.18);
}

.notice { border-radius: 12px; padding: 12px 14px; font-size: 0.9rem; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.bad { background: var(--bad-soft); color: var(--bad); }
.notice.ok { background: var(--live-soft); color: var(--live); }
.notice ul { margin: 6px 0 0; padding-left: 18px; }

.empty { text-align: center; color: var(--muted); padding: 32px 16px; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.empty strong { color: var(--ink); font-size: 1.05rem; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 30;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 140px);
  background: var(--ink); color: var(--bg); border-radius: 999px; padding: 10px 18px; font-weight: 600; font-size: 0.9rem;
  max-width: calc(100vw - 32px);
}

.login { min-height: 100vh; display: flex; align-items: center; }
.login .screen { padding-bottom: 32px; }
.login img { width: 72px; height: 72px; border-radius: 18px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
