@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg: #faf8f4;
  --text: #1a1a1a;
  --text-mid: #555;
  --text-muted: #777;
  --accent: #b08d57;
  --accent-light: #d4b87a;
  --border: #e0dcd4;
  --card-bg: #fff;
  --surface: #fff;
  --danger: #c0392b;
  --success: #27ae60;
  --warning: #e67e22;
  --info: #2980b9;
  --font-heading: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --sidebar-w: 220px;
  --radius: 6px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-body);
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.main {
  background: #ffffff;
}

/* ─── LOGIN ─────────────────────────────────────────────── */

.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-box {
  text-align: center;
  max-width: 320px;
}
.login-box h1 {
  font-family: var(--font-heading);
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--accent);
}
.login-box p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}
.login-box input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 14px;
  margin-bottom: 1rem;
}
.login-box button {
  width: 100%;
  padding: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
}
.login-tagline {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: -0.5rem;
  margin-bottom: 1.5rem;
  font-style: italic;
}
.login-error { color: var(--danger); margin-top: 0.5rem; font-size: 12px; }
.login-signup-link { margin-top: 1rem; font-size: 12px; color: var(--text-muted); }
.login-signup-link a { color: var(--accent); text-decoration: underline; }

/* ─── LAYOUT ────────────────────────────────────────────── */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  padding: 1.5rem 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 10;
}
.sidebar-brand {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
  padding: 0 1.25rem;
  margin-bottom: 1.5rem;
  letter-spacing: -0.01em;
}
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 1.25rem;
  color: var(--text-mid);
  text-decoration: none;
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: background 0.15s;
}
.sidebar nav a:hover { background: var(--bg); }
.sidebar nav a.active {
  color: var(--text);
  background: var(--bg);
  font-weight: 700;
}
.sidebar nav a .badge {
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: auto;
}

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
}

/* ─── TOKEN BANNER ──────────────────────────────────────── */

.token-banner {
  background: var(--danger);
  color: #fff;
  padding: 8px 20px;
  font-size: 12px;
  text-align: center;
  display: none;
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  z-index: 50;
}
.token-banner.visible { display: block; }
.token-banner a { color: #fff; text-decoration: underline; cursor: pointer; }

/* ─── HEADER ────────────────────────────────────────────── */

.page-header {
  padding: 1.5rem 2rem 1rem;
  border-bottom: 1px solid var(--border);
}
.page-header h2 {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.page-header .subtitle {
  color: var(--text-muted);
  font-size: 12px;
}

/* ─── CONTENT ───────────────────────────────────────────── */

.content { padding: 2rem 2.5rem; }

/* ─── CARDS ─────────────────────────────────────────────── */

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  transition: border-color 0.15s;
}
.card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.card-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ─── BADGES ────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge-evidence { background: #e8f4f8; color: #2980b9; }
.badge-commentary { background: #fef3e2; color: #e67e22; }
.badge-personality { background: #f3e8f4; color: #8e44ad; }
.badge-good { background: #e8f8e8; color: #27ae60; }
.badge-low_confidence { background: #fef3e2; color: #e67e22; }
.badge-rewritten { background: #e8f0f8; color: #2980b9; }
.badge-posted { background: #e8f8e8; color: #27ae60; }
.badge-scheduled { background: #e8f0f8; color: #2980b9; }
.badge-pending { background: #eaeaea; color: #666; }
.badge-benched { background: #f0f0f5; color: #708090; }
.badge-archived { background: #eaeaea; color: #666; }
.badge-research { background: #e8f4f8; color: #2c3e50; }
.badge-manual { background: #fef3e2; color: #b08d57; }
.badge-passed { background: #e8f8e8; color: #27ae60; }
.badge-failed { background: #fdecea; color: #c0392b; }
.badge-skipped { background: #f0f0f5; color: #888; }

/* ─── BUTTONS ───────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-light); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 3px 8px; font-size: 11px; }
/* Tab-style active state — used for Queue/Feed sub-tabs */
.btn.active { background: var(--text); color: var(--card-bg); border-color: var(--text); }
.btn.active:hover { background: var(--text); color: var(--card-bg); border-color: var(--text); }

/* ─── FORMS ─────────────────────────────────────────────── */

.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-mid);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 14px;
  background: var(--card-bg);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  color: var(--text);
}
.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(176, 141, 87, 0.12);
}
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }

/* ─── PILLS ─────────────────────────────────────────────── */

.pills { display: flex; flex-wrap: wrap; gap: 4px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 11px;
  color: var(--text-mid);
}
.pill .remove {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
}
.pill .remove:hover { color: var(--danger); }

/* ─── TABLE ─────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap table { min-width: 520px; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
th {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 2px solid var(--border);
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
tr:hover { background: var(--bg); }

/* ─── DRAFT CARD ────────────────────────────────────────── */

.draft-card { border-left: 3px solid var(--accent); }
.draft-card.bench { border-left-color: #708090; }
.draft-card.evergreen { border-left-color: #27ae60; }
.draft-card.scheduled { border-left-color: #2980b9; }

/* Collapsed card layout */
.card-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
  flex-wrap: wrap;
}

.card-score {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.card-preview {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  margin-bottom: 0.6rem;
}

.card-preview-thumb {
  width: 48px;
  height: 60px;
  object-fit: cover;
  border-radius: var(--radius);
  flex-shrink: 0;
}

.card-preview-text {
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  flex: 1;
}

.card-source {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.card-source a { color: var(--text-muted); text-decoration: underline; }
.card-source a:hover { color: var(--accent); }

.card-warning {
  font-size: 12px;
  color: var(--warning);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.card-schedule-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

/* More menu */
.more-menu-wrap {
  position: relative;
  margin-left: auto;
}

.more-trigger {
  font-size: 18px;
  letter-spacing: 0.1em;
  padding: 3px 10px;
  line-height: 1;
}

.more-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  min-width: 190px;
  z-index: 50;
  overflow: hidden;
}

.more-menu-item {
  display: block;
  width: 100%;
  padding: 10px 14px;
  text-align: left;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}

.more-menu-item:last-child { border-bottom: none; }
.more-menu-item:hover { background: var(--bg); }
.more-menu-danger { color: var(--danger); }
.more-menu-danger:hover { background: #fde8e8; color: var(--danger); }

/* Edit area inside card */
.card-edit-area {
  border-top: 1px solid var(--border);
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  animation: card-expand 0.18s ease;
}

@keyframes card-expand {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── SETTINGS ROWS ────────────────────────────────────── */

/* Expert profile 2-column grid collapses to 1 column on mobile */
.expert-profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 600px) {
  .expert-profile-grid { grid-template-columns: 1fr; }
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.85rem 1.25rem;
  background: none;
  border: none;
  border-top: 1px solid var(--border);
  cursor: pointer;
  text-align: left;
  transition: background 0.1s;
  gap: 1rem;
}

.settings-row:hover { background: var(--bg); }

.settings-row-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 2px;
}

.settings-row-sub {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

[data-theme="dark"] .settings-row:hover { background: #1a2030; }

/* ─── EMPTY STATES ──────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 4rem 2rem 3rem;
  color: var(--text-muted);
}

.empty-state-icon {
  width: 48px;
  height: 48px;
  stroke: var(--border);
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  margin-bottom: 1.25rem;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.empty-state h3 {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-mid);
  margin-bottom: 0.4rem;
  letter-spacing: -0.01em;
}

.empty-state p {
  font-size: 13px;
  line-height: 1.6;
  max-width: 300px;
  margin: 0 auto 1.5rem;
}

.empty-state .btn {
  margin: 0 auto;
}

.card-edit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.card-edit-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.draft-variant {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 0.5rem 0;
  white-space: pre-wrap;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.75;
}

.variant-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 0;
}
.variant-tab {
  padding: 6px 16px;
  font-size: 11px;
  border: 1px solid var(--border);
  border-bottom: none;
  background: var(--bg);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.variant-tab.active {
  background: var(--card-bg);
  color: var(--accent);
  font-weight: 500;
}

/* ─── PHOTO GRID ────────────────────────────────────────── */

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}
.photo-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card-bg);
}
.photo-card img {
  width: 100%;
  height: 150px;
  object-fit: cover;
}
.photo-card .info { padding: 0.75rem; }
.photo-card .info h4 { font-size: 12px; margin-bottom: 4px; }
.photo-card { position: relative; }
.photo-unused { opacity: 0.75; }
.photo-unused-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  background: var(--accent, #4f8ef7);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  letter-spacing: 0.03em;
}

/* ─── TODAY MOBILE NAV ──────────────────────────────────── */

.today-nav {
  display: none; /* desktop: hidden */
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0 1rem;
}
.today-nav-count {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}
.today-nav-btn {
  display: flex;
  align-items: center;
  gap: 4px;
}

@media (max-width: 768px) {
  .today-nav { display: flex; }
}

/* ─── ANALYTICS ─────────────────────────────────────────── */

.analytics-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 0;
}

@media (min-width: 769px) {
  .analytics-stats { grid-template-columns: repeat(4, 1fr); }
}

.analytics-stat-card {
  text-align: center;
  padding: 1.25rem 1rem;
}
.analytics-stat-value {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}
.analytics-stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-mid);
  margin-top: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.analytics-stat-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* Cadence chart */
.cadence-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 80px;
  margin-top: 0.75rem;
  overflow-x: auto;
  padding-bottom: 1.5rem; /* room for labels */
  position: relative;
}
.cadence-col {
  flex: 1;
  min-width: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  position: relative;
}
.cadence-bar-wrap {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
}
.cadence-bar {
  width: 100%;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  transition: height 0.3s ease;
  opacity: 0.75;
}
.cadence-col:hover .cadence-bar { opacity: 1; }
.cadence-label {
  position: absolute;
  bottom: -1.4rem;
  font-size: 9px;
  color: var(--text-muted);
  white-space: nowrap;
  transform: rotate(-35deg);
  transform-origin: top left;
  left: 50%;
}

.mt-md { margin-top: 1rem; }

/* ─── CALENDAR ──────────────────────────────────────────── */

.calendar-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 2px;
}
.cal-header {
  text-align: center;
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px;
}
.cal-day {
  min-height: 80px;
  padding: 6px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 11px;
}
.cal-day.today { border-color: var(--accent); background: #faf3e0; }
.cal-day.today .day-num { color: var(--accent); font-weight: 600; }
.cal-day.other-month { opacity: 0.4; }
.cal-day .day-num {
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 4px;
}
.cal-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 2px;
}
.cal-dot.scheduled { background: var(--accent); }
.cal-dot.posted { background: var(--success); }
.cal-dot.missed { background: var(--warning); }

.cal-day-clickable {
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.cal-day-clickable:hover { border-color: var(--accent); background: #faf6ef; }

.cal-entry {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: 3px;
  line-height: 1.3;
}
.cal-entry-label {
  font-size: 10px;
  color: var(--text-mid);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 90%;
}

/* ─── COMMENT INBOX ─────────────────────────────────────── */

.inbox-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 1rem;
  min-height: 500px;
}
.inbox-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-y: auto;
  max-height: 70vh;
}
.inbox-item {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 12px;
}
.inbox-item:hover { background: var(--bg); }
.inbox-item.active { background: var(--bg); border-left: 3px solid var(--accent); }
.inbox-item .count {
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
}

.comment-thread {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.comment-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.comment-item.unread { border-left: 3px solid var(--accent); padding-left: 10px; }
.comment-reply-suggestion {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 0.75rem;
  margin-top: 0.5rem;
}
.score-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 500;
}
.score-green { background: #e8f8e8; color: #27ae60; }
.score-amber { background: #fef3e2; color: #e67e22; }
.score-red { background: #fde8e8; color: #c0392b; }

/* ─── MODAL ─────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}
.modal h3 {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 1rem;
}

/* ─── ICONS ────────────────────────────────────────────── */

.icon {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
  vertical-align: middle;
}
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 24px; height: 24px; }

/* ─── UTILITIES ─────────────────────────────────────────── */

.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-sm { gap: 0.5rem; }
.gap-md { gap: 1rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mt-sm { margin-top: 0.5rem; }
.mt-md { margin-top: 1rem; }
.mb-sm { margin-bottom: 0.5rem; }
.mb-md { margin-bottom: 1rem; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 11px; }
.text-right { text-align: right; }
.hidden { display: none !important; }

/* ─── LINKEDIN POST PREVIEW ────────────────────────────── */

.linkedin-preview {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 1rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #000;
  font-size: 14px;
  line-height: 1.5;
  max-width: 550px;
}

.linkedin-preview-header {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.linkedin-preview-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #b08d57;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
  flex-shrink: 0;
}

.linkedin-preview-name {
  font-weight: 600;
  font-size: 14px;
  color: #000;
}

.linkedin-preview-title {
  font-size: 12px;
  color: #666;
}

.linkedin-preview-meta {
  font-size: 12px;
  color: #999;
}

.linkedin-preview-body {
  white-space: pre-wrap;
  margin-bottom: 0.75rem;
}

.linkedin-preview-body p {
  margin-bottom: 0.5rem;
}

.linkedin-preview-image {
  width: 100%;
  max-height: 400px;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 0.75rem;
}

.linkedin-preview-comment {
  border-top: 1px solid #e0e0e0;
  padding-top: 0.75rem;
  margin-top: 0.5rem;
  font-size: 13px;
}

.linkedin-preview-comment p {
  margin-top: 0.25rem;
  color: #333;
}

[data-theme="dark"] .linkedin-preview {
  background: #1b1f23;
  border-color: var(--border);
  color: #e0e0e0;
}

[data-theme="dark"] .linkedin-preview-name { color: #e0e0e0; }
[data-theme="dark"] .linkedin-preview-title { color: #a0aab8; }
[data-theme="dark"] .linkedin-preview-meta { color: #6a7590; }
[data-theme="dark"] .linkedin-preview-body { color: #e0e0e0; }
[data-theme="dark"] .linkedin-preview-comment { border-top-color: var(--border); }
[data-theme="dark"] .linkedin-preview-comment p { color: #c0c8d0; }

.screen-disabled {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-mid);
  font-size: 14px;
  line-height: 1.6;
}

/* ─── UPLOAD ────────────────────────────────────────────── */

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.2s;
}
.upload-zone:hover { border-color: var(--accent); }
.upload-zone.dragover { border-color: var(--accent); background: #faf6ef; }

/* ─── MOBILE HEADER ─────────────────────────────────────── */

.mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  z-index: 200;
}

.mobile-brand {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.01em;
}

.hamburger {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 40px;
}
.hamburger span {
  display: block;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: all 0.25s;
  transform-origin: center;
}
/* Animate to ✕ when sidebar is open */
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 149;
}
.sidebar-overlay.visible { display: block; }

/* ─── BOTTOM TAB BAR (mobile) ───────────────────────────── */

.bottom-tabs {
  display: none;
}

/* ─── RESPONSIVE ────────────────────────────────────────── */

@media (max-width: 768px) {
  /* Show slim mobile header */
  .mobile-header { display: flex; }
  /* Hide hamburger — bottom tabs handle nav on mobile */
  .hamburger { display: none; }

  /* Sidebar hidden completely on mobile — bottom tabs take over */
  .sidebar { display: none; }
  .sidebar-overlay { display: none !important; }

  .main {
    margin-left: 0;
    padding-top: 52px;
    padding-bottom: 64px; /* room for bottom tab bar */
    background: #ffffff;
  }

  .page-header {
    padding: 1rem 1rem 0.75rem;
  }

  .page-header h2 { font-size: 1.5rem; }

  .content { padding: 1rem 1rem 2rem; }

  .flex.gap-sm.flex-wrap { flex-wrap: wrap; }

  .form-control,
  input[style*="width:200px"],
  input[style*="width:300px"] {
    width: 100% !important;
  }

  select.form-control[style*="width:auto"] {
    width: 100% !important;
  }

  .card { padding: 1rem; }

  .draft-card .flex.gap-sm.mt-sm { flex-wrap: wrap; }

  .inbox-layout { grid-template-columns: 1fr; }

  .photo-grid { grid-template-columns: 1fr 1fr; }

  /* Tables on mobile: hide non-essential columns instead of trying to scroll */
  .table-wrap { font-size: 12px; }
  /* Archive table: hide Quality (4th), Photo (5th), Analytics (7th) */
  .archive-table th:nth-child(4),
  .archive-table td:nth-child(4),
  .archive-table th:nth-child(5),
  .archive-table td:nth-child(5),
  .archive-table th:nth-child(7),
  .archive-table td:nth-child(7) { display: none; }
  /* Feed manager table: hide Category (2nd) and URL (3rd) */
  .feed-table th:nth-child(2),
  .feed-table td:nth-child(2),
  .feed-table th:nth-child(3),
  .feed-table td:nth-child(3) { display: none; }

  /* Calendar: compact dots-only layout that fits the screen */
  .calendar-scroll { overflow-x: visible; }
  .calendar-grid { min-width: 0; gap: 1px; }
  .cal-header { font-size: 8px; padding: 5px 1px; }
  .cal-day { min-height: 50px; padding: 3px 2px; border-radius: 3px; font-size: 10px; }
  .cal-day .day-num { font-size: 10px; margin-bottom: 2px; }
  .cal-entry-label { display: none; }
  .cal-entry { margin-top: 2px; }

  .modal {
    width: 95vw;
    max-height: 85vh;
    margin: auto;
  }

  .variant-tabs { flex-wrap: wrap; }

  /* Bottom tab bar */
  .bottom-tabs {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 60px;
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    z-index: 200;
    align-items: stretch;
  }

  .bottom-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    transition: color 0.15s;
  }

  .bottom-tab:hover { color: var(--text-mid); }

  .bottom-tab.active {
    color: var(--accent);
  }

  .bottom-tab svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
}

/* Tablet: collapse sidebar to icon-only */
@media (max-width: 1024px) and (min-width: 769px) {
  :root { --sidebar-w: 56px; }

  .sidebar-brand { font-size: 0; padding: 0; text-align: center; height: 44px; }
  .sidebar-brand::after { content: '✦'; font-size: 1.2rem; display: block; color: var(--accent); line-height: 44px; }

  .sidebar nav a {
    padding: 12px 0;
    justify-content: center;
    font-size: 0; /* hide label */
  }

  .sidebar nav a .nav-label { display: none; }

  .sidebar nav a svg { width: 20px; height: 20px; }

  .dark-toggle { padding: 10px 0; justify-content: center; font-size: 0; }
  .dark-toggle #dark-toggle-label { display: none; }
}

/* ─── FEED ──────────────────────────────────────────────── */

.feed-date-group { margin-bottom: 2rem; }

.feed-date-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.75rem;
}

.feed-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 0.6rem;
  transition: box-shadow 0.15s;
}
.feed-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.07); }
.feed-card-drafted { opacity: 0.6; }

.feed-card-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.4rem;
  flex-wrap: wrap;
}

.feed-source {
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.feed-card-title {
  display: block;
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  line-height: 1.4;
  margin-bottom: 0.4rem;
}
.feed-card-title:hover { color: var(--accent); }

.feed-card-summary {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0 0 0.6rem;
}

.feed-card-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

/* ─── TRENDING PANEL ────────────────────────────────────── */

.trending-panel {
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}

.trending-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.trending-title {
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.trending-panel.collapsed .trending-body { display: none; }

.trending-section {
  margin-bottom: 0.75rem;
}

.trending-section:last-child { margin-bottom: 0; }

.trending-section-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}

.trending-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.trending-tag {
  display: inline-block;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  transition: border-color 0.15s, color 0.15s;
}

.trending-tag:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.trending-hn {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.trending-item {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text);
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
  transition: color 0.15s;
}

.trending-item:last-child { border-bottom: none; }

.trending-item:hover { color: var(--accent); }

.trending-item-title {
  flex: 1;
  font-size: 0.85rem;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.trending-item-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ─── TOAST NOTIFICATIONS ───────────────────────────────── */

@keyframes toast-in {
  from { transform: translateX(110%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes toast-out {
  from { transform: translateX(0);    opacity: 1; }
  to   { transform: translateX(110%); opacity: 0; }
}

#toast-container {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 1rem;
  border-radius: var(--radius);
  font-size: 12px;
  font-family: var(--font-body);
  min-width: 220px;
  max-width: 340px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  animation: toast-in 0.25s ease forwards;
  border-left: 3px solid transparent;
}
.toast.out { animation: toast-out 0.25s ease forwards; }

.toast-success { background: #f0faf2; color: #1a5c2e; border-left-color: var(--success); }
.toast-error   { background: #fdf0f0; color: #6b1111; border-left-color: var(--danger); }
.toast-info    { background: #f0f6fc; color: #0d3a5c; border-left-color: var(--info); }

[data-theme="dark"] .toast-success { background: #0b1e12; color: #3dba6d; }
[data-theme="dark"] .toast-error   { background: #250808; color: #e85c50; }
[data-theme="dark"] .toast-info    { background: #0d1e33; color: #5ba8d8; }

/* ─── LOADING SPINNER ───────────────────────────────────── */

@keyframes spin {
  to { transform: rotate(360deg); }
}
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 3rem 2rem;
  color: var(--text-muted);
  font-size: 12px;
}

/* ─── SKELETON LOADING ──────────────────────────────────── */

@keyframes shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position:  600px 0; }
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--border) 25%,
    color-mix(in srgb, var(--border) 50%, var(--bg)) 50%,
    var(--border) 75%
  );
  background-size: 600px 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius);
}

/* Skeleton draft card */
.skeleton-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
}
.skeleton-line { height: 12px; margin-bottom: 8px; }
.skeleton-line.wide  { width: 80%; }
.skeleton-line.med   { width: 55%; }
.skeleton-line.short { width: 35%; }
.skeleton-title { height: 16px; width: 90%; margin-bottom: 10px; }
.skeleton-badge { height: 20px; width: 70px; border-radius: 20px; display: inline-block; }
.skeleton-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 8px;
}
.skeleton-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
}
.skeleton-block {
  flex: 1;
  height: 14px;
}
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner-sm {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 4px;
}

/* ─── SCORE TOOLTIP ─────────────────────────────────────── */

.score-hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 9px;
  cursor: default;
  position: relative;
  vertical-align: middle;
  margin-left: 3px;
}
.score-hint::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1a1a1a;
  color: #fff;
  font-size: 10px;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 10;
}
.score-hint:hover::after { opacity: 1; }

/* .bench-schedule-row removed — replaced by .card-schedule-row */

/* ─── DARK MODE ─────────────────────────────────────────────── */
/*
 * Palette: deep navy-charcoal + warm gold
 * Background layers: #0e1117 → #161c28 → #1e2538
 * Gold accent pops cleanly against the blue-dark base.
 * Text hierarchy: #f0ece4 → #a0aab8 → #505a6a
 */

[data-theme="dark"] {
  --bg:          #0e1117;
  --card-bg:     #161c28;
  --surface:     #161c28;
  --text:        #f0ece4;
  --text-mid:    #a0aab8;
  --text-muted:  #6a7590;
  --accent:      #c9a96e;
  --accent-light:#d4b87a;
  --border:      #232b3a;
  --danger:      #e85c50;
  --success:     #3dba6d;
  --warning:     #e8943a;
  --info:        #5ba8d8;
}

/* Ensure all text-bearing elements inherit the correct colour */
[data-theme="dark"] body,
[data-theme="dark"] textarea,
[data-theme="dark"] input,
[data-theme="dark"] select { color: var(--text); }

[data-theme="dark"] .draft-variant { color: var(--text); }

/* Badges */
[data-theme="dark"] .badge-evidence      { background: #0d1e33; color: #5ba8d8; }
[data-theme="dark"] .badge-commentary    { background: #271606; color: #e8943a; }
[data-theme="dark"] .badge-personality   { background: #1a1030; color: #a87cd8; }
[data-theme="dark"] .badge-good,
[data-theme="dark"] .badge-posted        { background: #0b1e12; color: #3dba6d; }
[data-theme="dark"] .badge-low_confidence{ background: #271606; color: #e8943a; }
[data-theme="dark"] .badge-rewritten     { background: #0d1e33; color: #5ba8d8; }
[data-theme="dark"] .badge-scheduled     { background: #0d1e33; color: #5ba8d8; }
[data-theme="dark"] .badge-pending,
[data-theme="dark"] .badge-archived      { background: #1a1e2a; color: #505a6a; }
[data-theme="dark"] .badge-benched       { background: #161c28; color: #6878a0; }
[data-theme="dark"] .badge-research      { background: #0d1e33; color: #7ab8d8; }
[data-theme="dark"] .badge-manual        { background: #221a08; color: var(--accent); }
[data-theme="dark"] .badge-passed        { background: #0b1e12; color: #3dba6d; }
[data-theme="dark"] .badge-failed        { background: #2a0b0b; color: #e05252; }
[data-theme="dark"] .badge-skipped       { background: #1a1e2a; color: #606878; }

/* Score badges */
[data-theme="dark"] .score-green { background: #0b1e12; color: #3dba6d; }
[data-theme="dark"] .score-amber { background: #271606; color: #e8943a; }
[data-theme="dark"] .score-red   { background: #250808; color: #e85c50; }

/* Sidebar — one step darker than page bg */
[data-theme="dark"] .sidebar {
  background: #090c12;
  border-right-color: var(--border);
}
[data-theme="dark"] .sidebar-brand { color: var(--accent); }
[data-theme="dark"] .sidebar nav a { color: #7a8cb5; }
[data-theme="dark"] .sidebar nav a:hover { background: #0e1117; color: var(--text-mid); }
[data-theme="dark"] .sidebar nav a.active { background: #0e1117; color: var(--text); font-weight: 700; }
[data-theme="dark"] .bottom-tab.active { color: var(--accent); }
[data-theme="dark"] .more-menu { background: var(--card-bg); border-color: var(--border); box-shadow: 0 4px 20px rgba(0,0,0,0.4); }
[data-theme="dark"] .more-menu-item { color: var(--text); border-bottom-color: var(--border); }
[data-theme="dark"] .more-menu-item:hover { background: #1a2030; }
[data-theme="dark"] .more-menu-danger { color: var(--danger); }
[data-theme="dark"] .more-menu-danger:hover { background: #250808; }
[data-theme="dark"] .bottom-tabs { background: #090c12; border-top-color: var(--border); }
[data-theme="dark"] .main { background: var(--bg); }

/* Mobile header — already dark, just fix text */
[data-theme="dark"] .mobile-header { background: #090c12; border-bottom: 1px solid var(--border); }

/* Cards */
[data-theme="dark"] .card { box-shadow: 0 1px 3px rgba(0,0,0,0.2); }

/* Draft left-border accent colours stay vivid */
[data-theme="dark"] .draft-card         { border-left-color: var(--accent); }
[data-theme="dark"] .draft-card.bench   { border-left-color: #6878a0; }
[data-theme="dark"] .draft-card.evergreen { border-left-color: #3dba6d; }
[data-theme="dark"] .draft-card.scheduled { border-left-color: #5ba8d8; }

/* Calendar */
[data-theme="dark"] .cal-day            { background: var(--card-bg); border-color: var(--border); }
[data-theme="dark"] .cal-day.today      { background: #1c2540; border-color: var(--accent); }
[data-theme="dark"] .cal-day.today .day-num { color: var(--accent); }
[data-theme="dark"] .cal-day-clickable:hover { background: #1e2538; border-color: var(--accent); }

/* Upload zone */
[data-theme="dark"] .upload-zone:hover,
[data-theme="dark"] .upload-zone.dragover { background: #1c2540; border-color: var(--accent); }

/* Tables */
[data-theme="dark"] tr:hover { background: #1a2030; }

/* Variant tabs */
[data-theme="dark"] .variant-tab        { background: #0e1117; border-color: var(--border); color: var(--text-muted); }
[data-theme="dark"] .variant-tab.active { background: var(--card-bg); color: var(--accent); }

/* Photo cards */
[data-theme="dark"] .photo-card         { background: var(--card-bg); border-color: var(--border); }

/* Comment inbox */
[data-theme="dark"] .inbox-item:hover   { background: #1a2030; }
[data-theme="dark"] .inbox-item.active  { background: #1a2030; border-left-color: var(--accent); }
[data-theme="dark"] .comment-reply-suggestion { background: #0e1117; }

/* Login */
[data-theme="dark"] .login-screen { background: var(--bg); }
[data-theme="dark"] .login-box input  { background: var(--card-bg); color: var(--text); border-color: var(--border); }
[data-theme="dark"] .login-box button { background: var(--accent); }

/* ─── DARK TOGGLE BUTTON ──────────────────────────────────── */

.dark-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 1.25rem;
  margin-top: auto;
  background: none;
  border: none;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  transition: color 0.15s;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
}
.dark-toggle:hover { color: var(--accent); }
