:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1f232c;
  --border: #2a2f3a;
  --text: #eef0f4;
  --muted: #9aa2b1;
  --accent: #4f8cff;
  --accent-text: #ffffff;
  --green: #2fb170;
  --red: #e0524d;
  --amber: #d9a441;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { padding-bottom: env(safe-area-inset-bottom); }

.screen { min-height: 100vh; display: flex; flex-direction: column; }

.muted { color: var(--muted); }
.center { text-align: center; }

/* ---------------- Login ---------------- */

#login-screen { align-items: center; justify-content: center; padding: 24px; }

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
}

.login-card h1 { font-size: 22px; margin: 0 0 4px; }
.login-card p { margin: 0 0 20px; }

label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }

input[type="text"], input[type="password"], input[type="datetime-local"], textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 12px 14px;
  font-size: 16px; /* prevents iOS zoom-on-focus */
}

textarea { resize: vertical; min-height: 90px; font-family: inherit; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

.btn-block { width: 100%; margin-top: 20px; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-approve { background: var(--green); color: #06210f; }
.btn-reject { background: var(--red); color: #2a0605; }
.btn-regenerate { background: var(--amber); color: #2a1c02; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.error { color: var(--red); font-size: 14px; margin-top: 12px; }

/* ---------------- Top bar / tabs ---------------- */

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px calc(10px + env(safe-area-inset-top)) 16px;
  padding-top: max(14px, env(safe-area-inset-top));
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.topbar-title { display: flex; flex-direction: column; gap: 2px; }
.worker-status { font-size: 12px; color: var(--muted); }
.worker-status.online { color: var(--green); }
.worker-status.offline { color: var(--amber); }

.topbar-actions { display: flex; gap: 8px; }

.icon-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
}

.filter-tabs {
  display: flex; gap: 6px; overflow-x: auto;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
}

.tab {
  flex: 0 0 auto;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}

.tab.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

/* ---------------- Post list / cards ---------------- */

.post-list { padding: 14px 16px 40px; display: flex; flex-direction: column; gap: 14px; }

.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.post-media { width: 100%; aspect-ratio: 4 / 5; background: #05070a; object-fit: cover; display: block; }
.post-media.video-placeholder {
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 14px;
}

.post-body { padding: 14px; }

.post-meta-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }

.badge {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  padding: 4px 8px; border-radius: 999px;
}

.badge-pass { background: rgba(47,177,112,0.18); color: var(--green); }
.badge-review { background: rgba(217,164,65,0.18); color: var(--amber); }
.badge-fail { background: rgba(224,82,77,0.18); color: var(--red); }
.badge-auth { background: rgba(224,82,77,0.18); color: var(--red); }
.badge-neutral { background: var(--surface-2); color: var(--muted); }

.post-topic { font-weight: 700; font-size: 15px; margin: 0 0 4px; }
.post-caption { font-size: 14px; color: var(--text); margin: 6px 0; white-space: pre-wrap; }
.post-subline { font-size: 12px; color: var(--muted); margin: 2px 0; }

.post-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 14px 14px; }
.post-actions .btn { padding: 12px; font-size: 14px; }
.post-actions .full { grid-column: 1 / -1; }

/* ---------------- Detail / modal sheets ---------------- */

.sheet {
  position: fixed; inset: 0; z-index: 20;
  background: var(--bg);
  overflow-y: auto;
}

.sheet-inner { padding: 16px 16px calc(40px + env(safe-area-inset-bottom)); max-width: 560px; margin: 0 auto; }

.walkthrough-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.walkthrough-step { margin: 20px 0; }
.walkthrough-step h3 { font-size: 15px; margin: 0 0 6px; }
.walkthrough-step p { font-size: 14px; color: var(--muted); line-height: 1.5; margin: 0; }

.detail-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.detail-header h2 { font-size: 16px; margin: 0; }

.section-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 18px 0 6px; }

.field-value { font-size: 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; white-space: pre-wrap; }

.history-row { font-size: 12px; color: var(--muted); padding: 6px 0; border-bottom: 1px solid var(--border); }
.history-row:last-child { border-bottom: none; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  padding: 10px 16px; border-radius: 999px; font-size: 13px; z-index: 50;
  max-width: 90vw;
}

@media (min-width: 560px) {
  .post-list { max-width: 480px; margin: 0 auto; width: 100%; }
}
