/* Platypus Economics brand palette — mirrors BrandAssets/index.html */
:root {
  --abyss:     #0E4A53;
  --abyss-2:   #13585F;
  --abyss-3:   #1A6770;
  --surf:      #2F9E97;
  --surf-2:    #5DBAB4;
  --sun:       #D9A315;
  --coral:     #D93A43;
  --algae:     #006B2E;
  --algae-2:   #1B8F4D;
  --orchid:    #8E4AA0;

  --ink:       #082C32;
  --paper:     #F6F4EE;
  --paper-2:   #FFFFFF;

  --rule:        rgba(255,255,255,0.08);
  --rule-strong: rgba(255,255,255,0.16);
  --text:        #E7EFEF;
  --text-dim:    #9BB4B4;
  --text-dimmer: #6B8688;

  --radius:    10px;
  --radius-sm: 6px;
  --shadow:    0 8px 28px rgba(0,0,0,0.35);

  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--ink);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv02","cv03","cv04","cv11";
}

a { color: var(--surf-2); text-decoration: none; }
a:hover { color: var(--surf); }

/* ─── Top bar ───────────────────────────────────────────────────── */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 28px;
  background: linear-gradient(180deg, var(--abyss) 0%, #062227 100%);
  border-bottom: 1px solid var(--rule);
  color: var(--paper);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-marks { display: inline-flex; align-items: center; gap: 6px; }
.brand-arrow {
  color: var(--text-dim);
  font-size: 16px;
  line-height: 1;
  font-weight: 400;
}
.brand-mark {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--paper);
  display: grid; place-items: center;
  overflow: hidden;
  flex-shrink: 0;
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; padding: 3px; display: block; }
.brand-mark--wa {
  background: #25D366;
  padding: 0;
}
.brand-mark--wa img { padding: 4px; }
.brand-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--paper);
}
.brand-sub {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
  margin-top: 1px;
  letter-spacing: 0.01em;
}

.status-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--rule);
  color: var(--text-dim);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-family: var(--mono);
  letter-spacing: 0.01em;
}
.pill.ok   { background: rgba(27, 143, 77, 0.22);  color: #6FD495; border-color: rgba(27,143,77,0.45); }
.pill.warn { background: rgba(217, 163, 21, 0.20); color: #F2C75A; border-color: rgba(217,163,21,0.45); }
.pill.err  { background: rgba(217, 58, 67, 0.22);  color: #F08089; border-color: rgba(217,58,67,0.45); }

.build-stamp {
  align-self: center;
  margin-left: 4px;
  color: var(--text-dimmer);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.build-stamp:empty { display: none; }

/* ─── Tabs ──────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  background: #0B3A41;
  border-bottom: 1px solid var(--rule);
  padding: 0 20px;
  overflow-x: auto;
}
.tab {
  background: none;
  border: none;
  padding: 12px 18px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-dim);
  border-bottom: 2px solid transparent;
  font-family: inherit;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.tab:hover { color: var(--paper); }
.tab.active {
  color: var(--paper);
  border-bottom-color: var(--surf);
  font-weight: 600;
}

/* ─── Main / panels ────────────────────────────────────────────── */
main {
  flex: 1;
  padding: 28px 28px 64px;
  max-width: 980px;
  margin: 0 auto;
  width: 100%;
}
.panel { display: none; }
.panel.active { display: block; }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rule);
  gap: 14px;
  flex-wrap: wrap;
}
.panel-head h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--paper);
}
.panel-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ─── Buttons ──────────────────────────────────────────────────── */
button {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
button:hover {
  background: rgba(255,255,255,0.10);
  border-color: rgba(255,255,255,0.24);
  color: var(--paper);
}
button.primary {
  background: var(--surf);
  color: #04262A;
  border-color: var(--surf);
  font-weight: 700;
}
button.primary:hover {
  background: var(--surf-2);
  border-color: var(--surf-2);
  color: #04262A;
}
button.danger {
  background: rgba(217, 58, 67, 0.18);
  color: #F08089;
  border-color: rgba(217, 58, 67, 0.45);
}
button.danger:hover {
  background: rgba(217, 58, 67, 0.32);
  color: #FFB3B8;
}

/* ─── Cards ────────────────────────────────────────────────────── */
.card-list { display: flex; flex-direction: column; gap: 14px; }
.card {
  background: var(--abyss-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card h3 {
  margin: 0 0 14px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--surf-2);
}

/* ─── Draft cards ──────────────────────────────────────────────── */
.draft-card {
  background: var(--abyss-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.draft-card .meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 10px;
}
.draft-card .meta .badge {
  background: rgba(255,255,255,0.06);
  color: var(--text);
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid var(--rule);
}
.draft-card .meta .badge.pending   { background: rgba(217,163,21,0.20); color: #F2C75A; border-color: rgba(217,163,21,0.45); }
.draft-card .meta .badge.scheduled { background: rgba(47,158,151,0.20); color: var(--surf-2); border-color: rgba(47,158,151,0.45); }
.draft-card .meta .badge.sending   { background: rgba(142,74,160,0.22); color: #C49AD2; border-color: rgba(142,74,160,0.45); }
.draft-card .meta .badge.sent      { background: rgba(27,143,77,0.22);  color: #6FD495; border-color: rgba(27,143,77,0.45); }
.draft-card .meta .badge.error     { background: rgba(217,58,67,0.22);  color: #F08089; border-color: rgba(217,58,67,0.45); }
.draft-card .meta .badge.rejected  { background: rgba(255,255,255,0.05); color: var(--text-dimmer); border-color: var(--rule); }
.draft-card pre,
.draft-card textarea.draft-source-editor {
  background: rgba(8,44,50,0.55);
  border: 1px solid var(--rule);
  padding: 12px 14px;
  border-radius: 8px;
  font-family: var(--sans);
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 13.5px;
  margin: 10px 0;
  line-height: 1.55;
  color: var(--text);
}
.draft-card textarea.draft-source-editor {
  display: block;
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  min-height: 80px;
  overflow: hidden;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.draft-card textarea.draft-source-editor:focus {
  border-color: rgba(47,158,151,0.65);
  box-shadow: 0 0 0 2px rgba(47,158,151,0.18);
}
.draft-card .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; align-items: center; }

/* ─── Busy overlay (regenerate / refine in flight) ───────────────── */
.draft-card { position: relative; }
.draft-card.busy { pointer-events: none; }
.draft-card.busy .draft-source pre,
.draft-card.busy .draft-source textarea,
.draft-card.busy .draft-preview { opacity: 0.45; filter: blur(0.5px); transition: opacity .15s ease; }
.draft-card .actions button:disabled,
.draft-card .actions .file-btn:has(input:disabled) { opacity: 0.5; cursor: not-allowed; }

.card-busy-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 38, 42, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  border-radius: var(--radius);
  z-index: 5;
  pointer-events: auto;
  animation: card-busy-fade-in .18s ease;
}
@keyframes card-busy-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.card-busy-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 22px 28px;
  background: var(--abyss-2);
  border: 1px solid var(--rule-strong);
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-width: 80%;
  text-align: center;
}
.card-busy-msg {
  font-size: 14px;
  font-weight: 600;
  color: var(--paper);
}
.card-busy-steps {
  list-style: none;
  padding: 0;
  margin: 4px 0 2px;
  text-align: left;
  display: inline-block;
}
.card-busy-steps li {
  font-size: 12.5px;
  color: var(--text);
  padding: 2px 0;
  line-height: 1.4;
}
.card-busy-timer {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}
.card-busy-timer.slow { color: #F2C75A; }
.card-busy-hint {
  font-size: 11.5px;
  color: var(--text-dim);
  max-width: 32ch;
  line-height: 1.45;
}

.spinner {
  width: 26px;
  height: 26px;
  border: 2.5px solid rgba(255,255,255,0.14);
  border-top-color: var(--surf);
  border-radius: 50%;
  animation: spinner-rotate 0.85s linear infinite;
}
@keyframes spinner-rotate {
  to { transform: rotate(360deg); }
}

.media-chip {
  background: rgba(47,158,151,0.20);
  color: var(--surf-2);
  border: 1px solid rgba(47,158,151,0.40);
  padding: 2px 8px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 11px;
}

.yt-chip {
  background: rgba(217, 58, 67, 0.18);
  color: #F08089;
  border: 1px solid rgba(217, 58, 67, 0.45);
  padding: 2px 8px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 11px;
  cursor: help;
}

/* ─── YouTube candidate picker (inline expander on draft cards) ─────── */
.yt-picker {
  margin-top: 10px;
  background: rgba(8,44,50,0.45);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 12px;
}
.yt-picker[hidden] { display: none; }
.yt-picker-loading,
.yt-picker-error {
  font-size: 12.5px;
  color: var(--text-dim);
  padding: 6px 2px;
}
.yt-picker-error { color: #F08089; }
.yt-picker-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 10px;
}
.yt-picker-head strong { color: var(--paper); font-weight: 600; }
.yt-picker-head code {
  background: rgba(255,255,255,0.06);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--surf-2);
  font-size: 11.5px;
}
.yt-close {
  flex-shrink: 0;
  font-size: 11px;
  padding: 4px 10px;
}
.yt-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  max-height: 460px;
  overflow-y: auto;
}
.yt-card {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px;
  padding: 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--rule);
  border-radius: 6px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
}
.yt-card:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.20);
}
.yt-card-match {
  background: rgba(27,143,77,0.14);
  border-color: rgba(27,143,77,0.45);
}
.yt-card-match:hover {
  background: rgba(27,143,77,0.22);
  border-color: rgba(27,143,77,0.6);
}
.yt-card-thumb {
  width: 120px;
  height: 68px;
  object-fit: cover;
  border-radius: 4px;
  background: #000;
}
.yt-card-body { min-width: 0; }
.yt-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--paper);
  margin-bottom: 4px;
  line-height: 1.3;
}
.yt-card-meta {
  display: flex;
  gap: 10px;
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--mono);
}
.yt-card-dur.ok { color: #6FD495; font-weight: 700; }
.yt-card-desc {
  font-size: 11.5px;
  color: var(--text-dim);
  line-height: 1.4;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Treat the "Attach media" file input like a button for visual consistency. */
.file-btn {
  display: inline-flex;
  align-items: center;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
  margin: 0;
  user-select: none;
}
.file-btn:hover { background: rgba(255,255,255,0.10); border-color: rgba(255,255,255,0.24); }
.file-btn input[type="file"] { display: none; }

/* ─── Draft source / preview split ──────────────────────────────────── */
.draft-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  margin: 10px 0;
}
@media (max-width: 880px) {
  .draft-grid { grid-template-columns: 1fr; }
}
.draft-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--text-dim);
  margin-bottom: 6px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.draft-label .label-logo {
  width: 14px;
  height: 14px;
  display: inline-block;
}

/* ─── WhatsApp-style preview bubble ─────────────────────────────────── */
/* Intentionally light-themed inside a dark dashboard — this mirrors what
   followers actually see in the WhatsApp app, so the operator can sanity-
   check formatting, media, and the link-unfurl card before sending. */
.wa-preview {
  background: #efeae2;
  background-image:
    radial-gradient(circle at 12% 18%, rgba(255,255,255,0.5) 0 1px, transparent 1px),
    radial-gradient(circle at 78% 62%, rgba(0,0,0,0.04) 0 1px, transparent 1px);
  background-size: 18px 18px;
  border-radius: 10px;
  padding: 10px;
  border: 1px solid #d6d3ce;
  color: #111827;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.wa-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px 8px;
}
.wa-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: #ffffff;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  overflow: hidden;
  border: 1px solid #d6d3ce;
}
.wa-avatar img { width: 100%; height: 100%; object-fit: contain; padding: 2px; display: block; }
.wa-channel { line-height: 1.18; flex: 1; min-width: 0; }
.wa-channel-name { font-weight: 600; font-size: 13px; color: #111827; }
.wa-channel-meta { font-size: 11px; color: #6b7280; }
.wa-corner-logo {
  width: 18px; height: 18px;
  flex-shrink: 0;
  opacity: 0.95;
}

.wa-bubble {
  background: white;
  border-radius: 8px;
  padding: 8px 10px 4px;
  box-shadow: 0 1px 0.5px rgba(0,0,0,0.13);
  position: relative;
  max-width: 100%;
}
.wa-bubble::before {
  content: '';
  position: absolute;
  top: 0;
  left: -6px;
  width: 8px;
  height: 13px;
  background: white;
  clip-path: polygon(100% 0, 100% 100%, 0 0);
}
.wa-media {
  display: block;
  max-height: 320px;
  object-fit: cover;
  border-radius: 6px;
  margin: -4px -6px 6px;
  width: calc(100% + 12px);
  background: #e5e7eb;
}
.wa-text {
  font-size: 13.5px;
  line-height: 1.42;
  color: #111827;
  white-space: normal;
  word-wrap: break-word;
}
.wa-text strong { font-weight: 600; color: #111827; }
.wa-text em { font-style: italic; }
.wa-text s { color: #6b7280; }
.wa-text code {
  background: #f3f4f6;
  padding: 0 4px;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 0.85em;
  color: #111827;
  border: none;
}
.wa-text a { color: #027eb5; text-decoration: none; }
.wa-text a:hover { text-decoration: underline; }
.wa-text blockquote {
  border-left: 3px solid #25d366;
  background: #f6f5f3;
  margin: 4px 0;
  padding: 4px 8px;
  color: #374151;
  border-radius: 0 4px 4px 0;
}
.wa-text ul, .wa-text ol { margin: 4px 0; padding-left: 22px; }
.wa-text li { margin: 2px 0; }
.wa-text .wa-br { height: 0.5em; }
.wa-empty { color: #9ca3af; }

.wa-link-card {
  display: flex;
  gap: 8px;
  margin: 8px 0 4px;
  padding: 6px;
  border-radius: 6px;
  background: #f6f5f3;
  text-decoration: none;
  color: inherit;
  border: 1px solid #ece9e4;
}
.wa-link-thumb {
  width: 44px; height: 44px;
  border-radius: 4px;
  background: #d1fae5;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.wa-link-body { min-width: 0; flex: 1; }
.wa-link-title {
  font-size: 12.5px;
  font-weight: 600;
  color: #111827;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.wa-link-host { font-size: 11px; color: #6b7280; margin-top: 2px; }

/* YouTube link-preview card. WhatsApp gives YouTube URLs a larger,
   thumbnail-on-top treatment than ordinary link previews — replicate that
   so the operator sees the post the way followers will. */
.wa-yt-card {
  display: block;
  margin: 8px 0 4px;
  border-radius: 6px;
  overflow: hidden;
  background: #f6f5f3;
  text-decoration: none;
  color: inherit;
  border: 1px solid #ece9e4;
}
.wa-yt-thumb {
  display: block;
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  background: #000;
}
.wa-yt-meta { padding: 6px 8px 8px; }
.wa-yt-title {
  font-size: 12.5px;
  font-weight: 600;
  color: #111827;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.wa-yt-host { font-size: 11px; color: #6b7280; margin-top: 2px; }

.wa-stats {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  font-size: 10.5px;
  color: #8696a0;
  margin-top: 2px;
}
.wa-time { font-variant-numeric: tabular-nums; }

/* ─── Composer ─────────────────────────────────────────────────── */
.composer textarea,
.modal-body textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  background: rgba(8,44,50,0.55);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  resize: vertical;
  outline: none;
}
.composer textarea:focus,
.modal-body textarea:focus {
  border-color: var(--surf);
  background: rgba(8,44,50,0.75);
}
.composer-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 12px 0;
  gap: 12px;
  flex-wrap: wrap;
}
.composer-actions { display: flex; gap: 8px; }
.composer-help {
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.6;
  background: rgba(8,44,50,0.55);
  border: 1px solid var(--rule);
  padding: 12px 14px;
  border-radius: 8px;
}
.composer-help strong { color: var(--paper); }
.composer-help code {
  background: rgba(255,255,255,0.06);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--rule-strong);
  font-family: var(--mono);
  font-size: 0.85em;
  margin: 0 2px;
  color: var(--surf-2);
}

/* ─── Forms ────────────────────────────────────────────────────── */
label { display: block; margin: 8px 0; cursor: pointer; }
input[type="radio"], input[type="checkbox"] {
  margin-right: 8px;
  accent-color: var(--surf);
}
select, input[type="text"], input[type="number"], input[type="email"], input[type="file"] {
  padding: 7px 10px;
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  background: rgba(8,44,50,0.55);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  margin-right: 8px;
  outline: none;
}
select:focus, input[type="text"]:focus, input[type="number"]:focus, input[type="email"]:focus {
  border-color: var(--surf);
}
input[type="file"] {
  font-size: 12px;
  color: var(--text-dim);
}
input[type="file"]::file-selector-button {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  padding: 5px 10px;
  margin-right: 8px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
input[type="file"]::file-selector-button:hover {
  background: rgba(255,255,255,0.10);
}

.help { font-size: 12.5px; color: var(--text-dim); }
.help code, code {
  background: rgba(255,255,255,0.06);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.9em;
  color: var(--surf-2);
}

#qrImg {
  max-width: 240px;
  border: 6px solid var(--paper);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

/* ─── Modal ────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal-body {
  background: var(--abyss-2);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  padding: 22px;
  max-width: 640px;
  width: 100%;
  box-shadow: var(--shadow);
}
.modal-body h3 {
  margin: 0 0 14px;
  font-size: 16px;
  font-weight: 700;
  color: var(--paper);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

/* ─── Master toggle & alert rows ──────────────────────────────── */
.master-toggle {
  display: block;
  padding: 12px 14px;
  background: rgba(8,44,50,0.55);
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  margin-bottom: 10px;
}
.master-toggle strong { color: var(--paper); }

.alert-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
  gap: 12px;
}
#alertRules.disabled {
  opacity: 0.45;
  pointer-events: none;
}
.alert-row:last-child { border-bottom: none; }
.alert-row .alert-label { font-size: 13px; color: var(--text); }
.alert-row .alert-config input[type="number"] {
  width: 64px;
  padding: 4px 8px;
}

/* ─── Logs ─────────────────────────────────────────────────────── */
.log-row {
  font-family: var(--mono);
  font-size: 12px;
  padding: 5px 0;
  color: var(--text-dim);
  border-bottom: 1px dashed var(--rule);
}
.log-row:last-child { border-bottom: none; }
.log-row.err { color: #F08089; }

/* ─── Substack buckets ────────────────────────────────────────── */
.bucket {
  background: var(--abyss-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.bucket h3 {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 700;
  color: var(--paper);
  letter-spacing: -0.005em;
}
.bucket .bucket-help {
  font-size: 12px;
  color: var(--text-dim);
  margin: 0 0 10px;
}
.bucket .substack-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-top: 1px solid var(--rule);
  gap: 12px;
}
.bucket .substack-row:first-of-type { border-top: none; }
.bucket .row-meta { flex: 1; min-width: 0; }
.bucket .row-title {
  font-size: 13.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bucket .row-title a { color: var(--surf-2); text-decoration: none; }
.bucket .row-title a:hover { color: var(--surf); text-decoration: underline; }
.bucket .row-date {
  font-size: 11.5px;
  color: var(--text-dimmer);
  font-family: var(--mono);
  margin-top: 2px;
}
.bucket .row-actions { display: flex; gap: 6px; flex-shrink: 0; }
.bucket .row-actions button { font-size: 12px; padding: 5px 10px; }

/* ─── Selection ────────────────────────────────────────────────── */
::selection { background: var(--surf); color: #04262A; }

/* ─── Scrollbars (WebKit) ─────────────────────────────────────── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--ink); }
::-webkit-scrollbar-thumb { background: var(--abyss-3); border-radius: 6px; border: 2px solid var(--ink); }
::-webkit-scrollbar-thumb:hover { background: var(--surf); }

/* ─── Small screens ───────────────────────────────────────────── */
@media (max-width: 720px) {
  .topbar { padding: 12px 16px; flex-wrap: wrap; gap: 10px; }
  main { padding: 20px 16px 48px; }
  .panel-head h2 { font-size: 18px; }
}
