:root {
  --bg: #fff8ee;
  --ink: #10162f;
  --muted: #596581;
}
* { box-sizing: border-box; }

/* The HTML `hidden` attribute defaults to `display: none` via UA stylesheet,
 * which loses to any author rule that sets `display` (e.g. `.overlay
 * { display: flex }`). Force `hidden` to win — otherwise modals like
 * #passwordModal stay in the DOM with duplicate password inputs that
 * break autofill and the login form. */
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: "Avenir Next", "Noto Sans TC", "PingFang TC", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top, rgba(255, 196, 107, 0.35), transparent 28%),
    linear-gradient(180deg, #fff8ee 0%, #f4f7ff 55%, #eef3ff 100%);
}
.shell { width: min(1200px, calc(100vw - 24px)); margin: 0 auto; padding: 28px 0 64px; }
.hero { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 20px; }
.hero-card, .metric-card, .panel, .card {
  background: rgba(255,255,255,0.84);
  border: 1px solid rgba(16,22,47,0.08);
  border-radius: 28px;
  backdrop-filter: blur(18px);
  box-shadow: 0 24px 60px rgba(15,23,42,0.08);
}
.hero-card { padding: 32px; }
.eyebrow { display:inline-block; padding:6px 12px; border-radius:999px; background:rgba(16,22,47,0.08); color:#314062; font-size:.78rem; letter-spacing:.08em; text-transform:uppercase; }
h1 { margin: 16px 0 0; font-size: clamp(2.3rem, 5vw, 4.3rem); line-height: .96; }
h2 { margin: 8px 0 0; font-size: clamp(1.7rem, 4vw, 2.7rem); }
p { color: var(--muted); line-height: 1.72; }
.metric-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px; }
.metric-card { padding: 18px; }
.metric-card strong { display:block; margin-top:10px; font-size:2rem; color:var(--ink); }
.panel { margin-top: 24px; padding: 24px; display:grid; gap:18px; }
.field, .mini-field { display:grid; gap:8px; }
.field label, .field span, .mini-field label { color: var(--muted); font-size:.9rem; }
.field-head { display:flex; justify-content:space-between; align-items:center; gap:12px; }
.chip-actions { display:flex; gap:8px; }
.link-btn {
  background:none; border:none; padding:4px 8px; cursor:pointer;
  font:inherit; font-size:.82rem; color:#0c3d90; text-decoration:underline;
  text-underline-offset:3px; border-radius:8px;
}
.link-btn:hover { background:rgba(12,61,144,0.08); }
.chip-grid {
  display:flex; flex-wrap:wrap; gap:8px;
  padding:6px 0;
}
.chip {
  border:1px solid rgba(49,64,98,0.18);
  background:rgba(255,255,255,0.85);
  color:#324163;
  padding:8px 14px;
  border-radius:999px;
  font:inherit;
  font-size:.86rem;
  cursor:pointer;
  transition:background .14s ease, color .14s ease, border-color .14s ease;
}
.chip:hover { background:rgba(49,64,98,0.08); }
.chip.active {
  background:#10162f;
  color:#fff8ea;
  border-color:#10162f;
}
textarea, input, select {
  width:100%; border:1px solid rgba(49,64,98,0.14); border-radius:16px; padding:14px 16px;
  background:rgba(255,255,255,0.94); color:var(--ink); font:inherit;
}
.field-row { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:16px; }
.toggle-row { display:flex; gap:10px; }
.toggle, .primary-action {
  border:none; border-radius:999px; cursor:pointer; font:inherit; transition:transform .16s ease;
}
.toggle { padding:12px 16px; background:rgba(49,64,98,0.08); color:#324163; }
.toggle.active { background:#10162f; color:#fff8ea; }
.primary-action { padding:14px 22px; background:linear-gradient(135deg,#10162f,#f47d42); color:#fff; font-weight:600; }
.action-row, .results-header { display:flex; justify-content:space-between; gap:18px; align-items:center; }
.results-header { margin: 40px 0 18px; align-items:flex-end; }
.crawl-status {
  display:grid;
  gap:10px;
  padding:16px 18px;
  border-radius:22px;
  background:rgba(16,22,47,0.04);
  border:1px solid rgba(16,22,47,0.08);
}
.status-pill {
  display:inline-flex;
  width:max-content;
  padding:7px 12px;
  border-radius:999px;
  background:rgba(16,22,47,0.08);
  color:#314062;
  font-size:.78rem;
  font-weight:700;
}
.crawl-status[data-state="live"] .status-pill { background:rgba(38, 125, 88, 0.14); color:#186046; }
.crawl-status[data-state="cached"] .status-pill { background:rgba(12, 61, 144, 0.12); color:#0c3d90; }
.crawl-status[data-state="error"] .status-pill { background:rgba(183, 49, 59, 0.14); color:#9b1c27; }
.crawl-status p { margin:0; }
.warning-text { color:#8e5410; }
.status-filter {
  display:flex; flex-wrap:wrap; gap:10px;
  margin: 0 0 10px;
}
.tag-filter { margin-bottom: 18px; }
.status-chip {
  display:inline-flex; align-items:center; gap:8px;
  border:1px solid rgba(49,64,98,0.18);
  background:rgba(255,255,255,0.9);
  color:#324163;
  padding:9px 15px;
  border-radius:999px;
  font:inherit; font-size:.88rem;
  cursor:pointer;
  transition:background .14s ease, color .14s ease, border-color .14s ease;
}
.status-chip:hover { background:rgba(49,64,98,0.08); }
.status-chip.active {
  background:#10162f; color:#fff8ea; border-color:#10162f;
}
.status-chip .count {
  display:inline-flex; align-items:center; justify-content:center;
  min-width:24px; padding:2px 8px;
  border-radius:999px;
  background:rgba(16,22,47,0.1); color:#314062;
  font-size:.78rem; font-weight:700;
}
.status-chip.active .count { background:rgba(255,248,234,0.18); color:#fff8ea; }
.empty-state {
  grid-column: 1 / -1;
  padding: 36px 24px;
  text-align: center;
  background: rgba(255,255,255,0.6);
  border: 1px dashed rgba(49,64,98,0.2);
  border-radius: 22px;
  color: var(--muted);
}
.card-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:18px; }
.card { padding:24px; }
.card-top, .stat-row, .link-row { display:flex; justify-content:space-between; gap:14px; }
.platform-badge, .score-pill, .tag, .source-pill { display:inline-flex; align-items:center; border-radius:999px; }
.platform-row { display:flex; gap:6px; margin-bottom:8px; flex-wrap:wrap; }
.platform-badge { padding:5px 10px; font-size:.72rem; font-weight:700; letter-spacing:.02em; }
.platform-badge.platform-instagram { background:rgba(244,125,66,0.14); color:#a94e22; }
.platform-badge.platform-threads { background:rgba(16,22,47,0.1); color:#10162f; }
.score-pill { padding:10px 12px; background:#10162f; color:#fff8ea; font-weight:700; }
.handle { margin:6px 0 0; color:#6c7791; }
.stat-row { margin-top:16px; }
.stat { flex:1; padding:14px; background:rgba(11,18,43,0.04); border-radius:18px; }
.stat span { color:var(--muted); font-size:.85rem; }
.stat strong { display:block; margin-top:5px; }
.bio { margin-top:18px; }
.tag-wrap, .source-wrap { display:flex; flex-wrap:wrap; gap:10px; margin-top:16px; }
.tag { padding:8px 12px; background:rgba(16,22,47,0.06); color:#314062; font-size:.82rem; }
.source-pill { padding:8px 10px; background:rgba(255,196,107,.2); color:#8e5410; font-size:.78rem; }
.link-row { margin-top:18px; }
.link-row a { color:#0c3d90; text-decoration:underline; text-underline-offset:3px; }
.mini-grid { display:grid; gap:14px; margin-top:18px; }
@media (max-width: 980px) {
  .hero, .metric-grid, .field-row, .card-grid { grid-template-columns: 1fr; }
  .action-row, .results-header, .card-top, .stat-row, .link-row { flex-direction:column; align-items:stretch; }
}

/* ---------- "不合適" rejected pipeline ---------- */
/* Cards marked rejected stay readable but visually de-prioritised so the
 * active BD work isn't competing with them. The dedicated filter chip can
 * pull them back into focus when needed. */
.card[data-pipeline="rejected"] {
  opacity: 0.55;
  background: rgba(255,255,255,0.55);
  border-style: dashed;
}
.card[data-pipeline="rejected"]:hover { opacity: 0.85; }
.card[data-pipeline="rejected"] h3,
.card[data-pipeline="rejected"] .score-pill { color: #6c7791; }
.card[data-pipeline="rejected"] .score-pill { background: rgba(16,22,47,0.4); }
.card[data-pipeline="rejected"] .platform-badge,
.card[data-pipeline="rejected"] .tag,
.card[data-pipeline="rejected"] .source-pill { filter: grayscale(0.7); }
.card[data-pipeline="rejected"]::before {
  content: "不合適";
  position: absolute;
  top: 12px; right: 12px;
  padding: 4px 10px;
  background: rgba(89, 101, 129, 0.18);
  color: #596581;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .02em;
}
.card { position: relative; }
.status-chip.status-chip-rejected { color: #596581; }
.status-chip.status-chip-rejected.active {
  background: #596581;
  border-color: #596581;
  color: #fff8ea;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255,248,238,0.86);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(16,22,47,0.08);
}
.topbar-inner {
  width: min(1200px, calc(100vw - 24px));
  margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 0;
}
.brand { display:flex; align-items:center; gap:10px; font-weight:700; color:#10162f; }
.brand-dot {
  width:12px; height:12px; border-radius:50%;
  background: linear-gradient(135deg,#10162f,#f47d42);
}
.brand-text { letter-spacing:.02em; }
.topbar-actions { display:flex; align-items:center; gap:14px; }
.topbar-btn {
  position:relative;
  border:1px solid rgba(49,64,98,0.18);
  background:rgba(255,255,255,0.9);
  color:#324163;
  padding:8px 14px;
  border-radius:999px;
  font:inherit; font-size:.86rem;
  cursor:pointer;
  transition:background .14s ease, color .14s ease, border-color .14s ease;
}
.topbar-btn:hover { background:rgba(49,64,98,0.08); }
.topbar-btn.active { background:#10162f; color:#fff8ea; border-color:#10162f; }
.topbar-badge {
  display:inline-flex; align-items:center; justify-content:center;
  min-width:18px; height:18px; padding:0 6px; margin-left:6px;
  border-radius:999px;
  background:#f47d42; color:#fff8ea;
  font-size:.7rem; font-weight:700;
}
.me-badge { display:flex; align-items:center; gap:10px; color:#324163; font-size:.9rem; }
.me-name { font-weight:600; color:#10162f; }
.role-pill {
  padding:3px 10px; border-radius:999px;
  background:rgba(16,22,47,0.08); color:#314062;
  font-size:.72rem; letter-spacing:.04em; text-transform:uppercase;
}

/* ---------- Login overlay ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at top, rgba(255,196,107,0.45), transparent 32%),
    linear-gradient(180deg, rgba(255,248,238,0.94) 0%, rgba(238,243,255,0.94) 100%);
  backdrop-filter: blur(8px);
}
.login-card {
  width: min(420px, 100%);
  background: rgba(255,255,255,0.94);
  border: 1px solid rgba(16,22,47,0.08);
  border-radius: 28px;
  box-shadow: 0 24px 60px rgba(15,23,42,0.12);
  padding: 32px;
  display: grid; gap: 14px;
}
.login-card h2 { margin: 8px 0 0; font-size: 1.7rem; }
.login-card label { display:grid; gap:6px; color: var(--muted); font-size:.9rem; }
.login-card label span { font-size:.85rem; }
.login-card .primary-action { margin-top: 6px; }
.login-error {
  margin: 0;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(183, 49, 59, 0.12);
  color: #9b1c27;
  font-size:.88rem;
}
.login-hint { margin: 0; color: var(--muted); font-size:.82rem; }
.modal-overlay { background: rgba(15,23,42,0.42); backdrop-filter: blur(6px); }
.modal-actions { display:flex; justify-content:flex-end; gap:10px; margin-top: 4px; }

/* ---------- Activity drawer ---------- */
.drawer-scrim {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(15,23,42,0.34);
  backdrop-filter: blur(4px);
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50;
  width: min(420px, 92vw);
  background: rgba(255,248,238,0.98);
  border-left: 1px solid rgba(16,22,47,0.08);
  box-shadow: -28px 0 80px rgba(15,23,42,0.18);
  padding: 24px 22px 32px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
}
.drawer-head { display:flex; align-items:center; justify-content:space-between; }
.drawer-head h3 { margin:0; font-size:1.2rem; }
.drawer-hint { margin: 0; color: var(--muted); font-size:.85rem; }
.drawer-filters {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px;
  padding: 10px 12px;
  background: rgba(16,22,47,0.04);
  border: 1px solid rgba(16,22,47,0.08);
  border-radius: 16px;
  margin-top: 4px;
}
.drawer-filter { display: grid; gap: 4px; font-size: .82rem; color: var(--muted); }
.drawer-filter select,
.drawer-filter input {
  padding: 8px 10px; border-radius: 10px;
  border: 1px solid rgba(49,64,98,0.18);
  background: rgba(255,255,255,0.94);
  color: var(--ink); font: inherit; font-size: .88rem;
}
#activityFilterClear { grid-column: 1 / -1; justify-self: end; padding: 4px 8px; font-size: .8rem; }
a.topbar-btn { text-decoration: none; display: inline-flex; align-items: center; }
a.topbar-btn:hover { text-decoration: none; }
.activity-list { display:flex; flex-direction:column; gap:10px; margin-top: 8px; }
.activity-item {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255,255,255,0.86);
  border: 1px solid rgba(16,22,47,0.08);
  display: grid; gap: 6px;
}
.activity-item .who { font-weight: 600; color: #10162f; font-size:.92rem; }
.activity-item .what { color: #324163; font-size:.88rem; line-height: 1.55; }
.activity-item .when { color: var(--muted); font-size:.78rem; }
.activity-item .memo-diff {
  margin: 4px 0 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(16,22,47,0.05);
  color: #324163;
  font-size:.82rem;
  white-space: pre-wrap;
  max-height: 6.5em;
  overflow: hidden;
}
.activity-empty {
  padding: 18px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed rgba(49,64,98,0.2);
  border-radius: 16px;
}

/* ---------- Card edited-by stamp ---------- */
.edited-stamp {
  margin-top: 12px;
  font-size:.78rem;
  color: var(--muted);
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
}
.edited-stamp strong { color: #314062; font-weight: 600; }
.edited-stamp .saving {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  background: rgba(12,61,144,0.12); color: #0c3d90;
  font-size:.72rem;
}
.edited-stamp .saving[data-state="saved"] { background: rgba(38, 125, 88, 0.14); color: #186046; }
.edited-stamp .saving[data-state="error"] { background: rgba(183, 49, 59, 0.14); color: #9b1c27; }

body[data-auth="loading"] .topbar,
body[data-auth="loading"] #appShell { visibility: hidden; }

@media (max-width: 720px) {
  .topbar-inner { flex-wrap: wrap; gap: 10px; }
  .me-badge .role-pill { display: none; }
}
