:root {
  --bg: #0d1117;
  --panel: #151b23;
  --panel-alt: #1c2430;
  --border: #2a3441;
  --text: #e6edf3;
  --text-dim: #8b98a5;
  --ponchi: #2dd4a7;
  --deskomigo: #4ea1ff;
  --localsave: #f5a623;
  --accent: #2dd4a7;
  --danger: #ef5350;
}
* { box-sizing: border-box; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Inter, sans-serif;
  margin: 0;
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px; border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 18px; margin: 0; letter-spacing: 0.02em; }
.topbar .sub { color: var(--text-dim); font-size: 13px; }
.nav a {
  color: var(--text-dim); text-decoration: none; margin-left: 20px; font-size: 14px;
}
.nav a.active, .nav a:hover { color: var(--text); }
.badge {
  background: var(--accent); color: #062017; border-radius: 999px;
  font-size: 11px; padding: 2px 8px; margin-left: 6px; font-weight: 600;
}
.container { padding: 28px; max-width: 1100px; margin: 0 auto; }
.brand-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--border); margin-right: 8px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot.ponchi { background: var(--ponchi); }
.dot.deskomigo { background: var(--deskomigo); }
.dot.localsave { background: var(--localsave); }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 18px; margin-bottom: 14px;
}
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.status-pill {
  font-size: 11px; padding: 3px 9px; border-radius: 999px; text-transform: uppercase;
  letter-spacing: 0.04em; font-weight: 700;
}
.status-draft { background: #333; color: #ccc; }
.status-scheduled { background: #1e3a5f; color: #7fb3f5; }
.status-published { background: #1b3d2f; color: var(--ponchi); }
.status-needs_manual_action { background: #4a3410; color: var(--localsave); }
.status-failed { background: #4a1e1e; color: var(--danger); }
.copy-text { color: var(--text); line-height: 1.5; font-size: 14px; }
.meta { color: var(--text-dim); font-size: 12px; margin-top: 8px; }
.platform-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.tag { background: var(--panel-alt); border: 1px solid var(--border); border-radius: 6px; padding: 3px 8px; font-size: 11px; color: var(--text-dim); }

/* Queue swipe UI */
.queue-stack { max-width: 480px; margin: 40px auto; text-align: center; }
.queue-empty { color: var(--text-dim); padding: 60px 20px; }
.queue-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 28px; text-align: left; min-height: 260px; display: flex; flex-direction: column;
}
.queue-card .target { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.queue-card .context { color: var(--text-dim); font-size: 12px; margin-bottom: 14px; }
.queue-card .body { flex: 1; font-size: 15px; line-height: 1.6; white-space: pre-wrap; }
.queue-actions { display: flex; gap: 10px; margin-top: 20px; }
.btn {
  flex: 1; padding: 12px; border-radius: 8px; border: none; font-weight: 600;
  font-size: 14px; cursor: pointer; transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; }
.btn-copy { background: var(--accent); color: #062017; }
.btn-skip { background: var(--panel-alt); color: var(--text-dim); border: 1px solid var(--border); }
.btn-done { background: #1b3d2f; color: var(--ponchi); border: 1px solid var(--ponchi); }
.progress { color: var(--text-dim); font-size: 13px; margin-bottom: 16px; }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #062017; padding: 10px 18px; border-radius: 8px;
  font-size: 13px; font-weight: 600; opacity: 0; transition: opacity 0.2s; pointer-events: none;
}
.toast.show { opacity: 1; }

/* Editable queue card */
.copy-editor {
  flex: 1;
  width: 100%;
  min-height: 200px;
  background: transparent;
  color: var(--text);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px;
  margin: 4px -10px 0;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.6;
  resize: vertical;
  transition: border-color 0.15s, background 0.15s;
}
.copy-editor:hover { border-color: var(--border); }
.copy-editor:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--panel-alt);
}
.editor-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-dim);
}
.editor-meta .hint { text-align: right; opacity: 0.7; }

/* Group blast: selectable group rows */
.group-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 6px; cursor: pointer;
  font-size: 13px; transition: background 0.12s;
}
.group-row:hover { background: var(--panel-alt); }
.group-name { flex: 1; }
.policy {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 2px 7px; border-radius: 999px; font-weight: 700; white-space: nowrap;
}
.policy-none       { background: #4a1e1e; color: var(--danger); }
.policy-thread_only{ background: #4a3410; color: var(--localsave); }
.policy-soft       { background: #1e3a5f; color: #7fb3f5; }
.policy-open       { background: #1b3d2f; color: var(--ponchi); }

/* ============================================================
   Mobile / PWA responsive layer
   ============================================================ */
@media (max-width: 640px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px 16px;
    /* respect phone notches when installed fullscreen */
    padding-top: calc(14px + env(safe-area-inset-top));
  }
  .topbar h1 { font-size: 20px; }

  /* Nav becomes a horizontally scrollable pill strip */
  .nav {
    display: flex;
    gap: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -16px;
    padding: 0 16px 4px;
    scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a {
    margin-left: 0;
    margin-right: 14px;
    white-space: nowrap;
    padding: 6px 2px;
    font-size: 15px;
  }

  .container {
    padding: 16px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
    max-width: 100%;
  }

  .card { padding: 14px; border-radius: 12px; }

  /* Stack the compose action buttons full-width and tappable */
  .queue-actions { flex-direction: column; gap: 10px; }
  .queue-actions .btn { width: 100%; padding: 14px; font-size: 16px; }

  /* Bigger tap targets for checkboxes/rows */
  .group-row { padding: 12px 10px; }
  .account-cb, .group-cb { width: 20px; height: 20px; }

  /* Inputs sized so iOS doesn't zoom on focus (needs >=16px) */
  textarea, select, input[type="text"], .copy-editor {
    font-size: 16px !important;
  }

  /* Queue swipe card fits the viewport */
  .queue-stack { margin: 16px auto; max-width: 100%; }
  .queue-card { padding: 18px; }

  /* Blast result cards & composer variants */
  .brand-chip { font-size: 13px; }
  .status-pill { font-size: 10px; }
}

/* Slightly larger tap targets on tablets too */
@media (max-width: 900px) {
  .btn { min-height: 44px; }
}

/* ============================================================
   Login page
   ============================================================ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 28px;
  width: 100%;
  max-width: 360px;
}
.login-logo { font-size: 24px; margin: 0 0 4px; letter-spacing: 0.02em; }
.login-sub { color: var(--text-dim); font-size: 13px; margin-bottom: 24px; }
.login-input {
  width: 100%;
  padding: 13px 14px;
  margin-bottom: 12px;
  background: var(--panel-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  font-family: inherit;
}
.login-input:focus { outline: none; border-color: var(--accent); }
.login-btn { width: 100%; padding: 14px; font-size: 16px; margin-top: 6px; }
.login-error {
  background: #4a1e1e; color: var(--danger);
  padding: 10px 12px; border-radius: 8px;
  font-size: 13px; margin-bottom: 16px;
}
