/* PostLooper — calm, trustworthy autopilot. Dark-first, safety-status color language.
   Green = looping safely. Amber = attention. Red = failed/blocked. */

:root {
  --bg: #0e1116;
  --bg-raised: #161b22;
  --bg-inset: #1c222b;
  --border: #262d38;
  --border-soft: #1e242e;
  --text: #e6edf3;
  --text-dim: #9aa7b4;
  --text-faint: #6b7683;

  --safe: #34d399;
  --safe-bg: rgba(52, 211, 153, 0.12);
  --safe-border: rgba(52, 211, 153, 0.32);
  --warn: #fbbf24;
  --warn-bg: rgba(251, 191, 36, 0.12);
  --warn-border: rgba(251, 191, 36, 0.32);
  --err: #f87171;
  --err-bg: rgba(248, 113, 113, 0.12);
  --err-border: rgba(248, 113, 113, 0.32);
  --accent: #34d399;
  --accent-ink: #04120c;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

:root[data-theme="light"] {
  --bg: #f6f8fa;
  --bg-raised: #ffffff;
  --bg-inset: #f0f3f6;
  --border: #d8dee4;
  --border-soft: #e4e9ee;
  --text: #1c2128;
  --text-dim: #57606a;
  --text-faint: #8b949e;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 8px 24px -16px rgba(0, 0, 0, 0.2);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 0.4em; }
h1 { font-size: 1.5rem; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; letter-spacing: -0.01em; }
h3 { font-size: 1rem; }
p { margin: 0 0 1em; }
small { color: var(--text-dim); }
code { font-family: var(--mono); font-size: 0.86em; background: var(--bg-inset); padding: 0.1em 0.4em; border-radius: 5px; }

/* --- Nav ------------------------------------------------------------------ */
.nav {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-raised) 80%, transparent);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.05rem;
}
.brand-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--safe);
  box-shadow: 0 0 0 3px var(--safe-bg), 0 0 12px var(--safe);
  animation: pulse 3s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
.nav-links { display: flex; gap: 4px; margin-right: auto; flex-wrap: wrap; }
.nav-links a {
  text-decoration: none; color: var(--text-dim); padding: 6px 12px;
  border-radius: var(--radius-sm); font-weight: 500; font-size: 0.92rem;
}
.nav-links a:hover { color: var(--text); background: var(--bg-inset); }
.nav-links a.active { color: var(--text); background: var(--bg-inset); }
.nav-user { display: flex; align-items: center; gap: 14px; }
.nav-email { color: var(--text-faint); font-size: 0.85rem; }
.nav-logout { color: var(--text-dim); text-decoration: none; font-size: 0.85rem; }
.nav-logout:hover { color: var(--text); }

/* --- Layout --------------------------------------------------------------- */
.wrap { max-width: 960px; margin: 0 auto; padding: 32px 24px 80px; }
.wrap-narrow { max-width: 620px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head p { color: var(--text-dim); margin: 0; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }

/* --- Cards ---------------------------------------------------------------- */
.card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card-inset { background: var(--bg-inset); border-color: var(--border-soft); box-shadow: none; }
.card h2, .card h3 { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }

/* Safety-status left border accents */
.card-safe { border-left: 3px solid var(--safe); }
.card-warn { border-left: 3px solid var(--warn); }
.card-err { border-left: 3px solid var(--err); }

/* --- Status dots & pills -------------------------------------------------- */
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dot-ok { background: var(--safe); box-shadow: 0 0 8px var(--safe-border); }
.dot-warn { background: var(--warn); box-shadow: 0 0 8px var(--warn-border); }
.dot-err { background: var(--err); box-shadow: 0 0 8px var(--err-border); }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 600;
  border: 1px solid var(--border);
}
.pill-safe { background: var(--safe-bg); border-color: var(--safe-border); color: var(--safe); }
.pill-warn { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn); }
.pill-err { background: var(--err-bg); border-color: var(--err-border); color: var(--err); }
.pill-muted { background: var(--bg-inset); color: var(--text-dim); }

/* --- Buttons -------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 9px 16px; border-radius: var(--radius-sm); font-weight: 600; font-size: 0.9rem;
  border: 1px solid var(--border); background: var(--bg-inset); color: var(--text);
  cursor: pointer; text-decoration: none; transition: filter 0.12s, background 0.12s;
  font-family: inherit;
}
.btn:hover { filter: brightness(1.15); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-danger { background: var(--err-bg); border-color: var(--err-border); color: var(--err); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 0.82rem; }

/* --- Forms ---------------------------------------------------------------- */
label { display: block; font-weight: 600; font-size: 0.88rem; margin-bottom: 6px; }
.hint { color: var(--text-faint); font-weight: 400; font-size: 0.82rem; margin-top: 4px; }
input[type="text"], input[type="email"], input[type="url"], input[type="number"],
input[type="datetime-local"], textarea, select {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font-family: inherit; font-size: 0.95rem;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--safe-border); border-color: var(--safe); }
textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
.field + .field { margin-top: 16px; }
.checkline { display: flex; align-items: center; gap: 10px; }
.checkline input { width: auto; }
.checkline label { margin: 0; }

/* --- Alerts / banners ----------------------------------------------------- */
.alert { padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); font-size: 0.9rem; }
.alert-safe { background: var(--safe-bg); border-color: var(--safe-border); }
.alert-warn { background: var(--warn-bg); border-color: var(--warn-border); }
.alert-err { background: var(--err-bg); border-color: var(--err-border); }
.alert strong { display: block; margin-bottom: 2px; }

/* --- Auth / marketing ----------------------------------------------------- */
.hero { max-width: 560px; margin: 0 auto; padding: 72px 24px; text-align: center; }
.hero .brand-dot { margin: 0 auto 20px; width: 16px; height: 16px; }
.hero h1 { font-size: 2.1rem; letter-spacing: -0.03em; }
.hero .lede { color: var(--text-dim); font-size: 1.1rem; margin-bottom: 32px; }
.auth-card { max-width: 400px; margin: 40px auto; }

/* --- Queue / list items --------------------------------------------------- */
.queue-item { display: flex; gap: 14px; align-items: flex-start; padding: 16px 0; border-bottom: 1px solid var(--border-soft); }
.queue-item:last-child { border-bottom: none; }
.queue-time { flex: none; width: 128px; color: var(--text-dim); font-size: 0.85rem; }
.queue-time strong { display: block; color: var(--text); font-size: 0.92rem; }
.queue-body { flex: 1; min-width: 0; }
.queue-text { white-space: pre-wrap; word-break: break-word; margin-bottom: 8px; }
.queue-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.acct-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--text-dim); background: var(--bg-inset); padding: 2px 8px; border-radius: 999px; }

.empty { text-align: center; padding: 56px 24px; color: var(--text-dim); }
.empty-icon { font-size: 2.4rem; margin-bottom: 12px; opacity: 0.7; }

/* --- Calendar ------------------------------------------------------------- */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 8px; }
.cal-head { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint); text-align: center; padding: 4px 0; }
.cal-day { min-height: 76px; border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 6px; background: var(--bg-raised); }
.cal-day.other { opacity: 0.4; }
.cal-day.today { border-color: var(--safe); }
.cal-date { font-size: 0.76rem; color: var(--text-faint); margin-bottom: 4px; }
.cal-post { font-size: 0.72rem; padding: 2px 5px; border-radius: 5px; background: var(--safe-bg); color: var(--safe); margin-bottom: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-post.err { background: var(--err-bg); color: var(--err); }
.cal-post.done { background: var(--bg-inset); color: var(--text-dim); }

/* --- Variation editor ----------------------------------------------------- */
.variation { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 10px; background: var(--bg); }
.variation-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.variation-num { font-size: 0.8rem; color: var(--text-faint); font-weight: 600; }

.charcount { font-size: 0.78rem; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.charcount.over { color: var(--err); font-weight: 600; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs button { background: none; border: none; color: var(--text-dim); padding: 8px 14px; cursor: pointer; font-weight: 600; font-size: 0.9rem; border-bottom: 2px solid transparent; font-family: inherit; }
.tabs button.active { color: var(--text); border-bottom-color: var(--safe); }

.muted { color: var(--text-dim); }
.tabular { font-variant-numeric: tabular-nums; }
hr { border: none; border-top: 1px solid var(--border-soft); margin: 20px 0; }

/* --- Usage meters (billing) ---------------------------------------------- */
.usage-bar { height: 8px; border-radius: 999px; background: var(--bg-inset); overflow: hidden; }
.usage-fill { height: 100%; border-radius: 999px; transition: width 0.3s ease; }
.usage-ok { background: var(--safe); }
.usage-warn { background: var(--warn); }
.usage-err { background: var(--err); }

/* Safety panel specifics */
.safety-list { list-style: none; padding: 0; margin: 0; }
.safety-list li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border-soft); }
.safety-list li:last-child { border-bottom: none; }
.safety-list .shield { flex: none; color: var(--safe); font-size: 1.1rem; line-height: 1.4; }
.safety-list strong { display: block; }
.safety-list span { color: var(--text-dim); font-size: 0.9rem; }

@media (max-width: 640px) {
  .nav { gap: 12px; padding: 12px 16px; }
  .nav-email { display: none; }
  .wrap { padding: 20px 16px 64px; }
  .queue-item { flex-direction: column; gap: 6px; }
  .queue-time { width: auto; }
  .cal { font-size: 0.65rem; }
  .cal-day { min-height: 56px; }
}
