/* ── Linear Design System ────────────────────────────── */

/* ── Dark Theme (default) ────────────────────────────── */
:root,
[data-theme="dark"] {
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif;
  --font-mono: 'SF Mono', 'Menlo', 'Monaco', monospace;

  --bg-app:     #0F0F11;
  --bg-surface: #1A1A1F;
  --bg-hover:   #212128;
  --bg-active:  #28282F;

  --text-primary:   #E2E2E9;
  --text-secondary: #72727A;
  --text-tertiary:  #48484F;

  --border:        rgba(255,255,255,0.06);
  --border-strong: rgba(255,255,255,0.1);

  --accent:      #5E6AD2;
  --accent-hover:#6872D6;
  --accent-text: #818CF8;
  --accent-muted:rgba(94,106,210,.12);

  --green:       #4DA771;
  --green-muted: rgba(77,167,113,.12);
  --red:         #D1242F;
  --red-muted:   rgba(209,36,47,.12);
  --orange:      #E5863D;
  --orange-muted:rgba(229,134,61,.12);

  --sidebar-bg:     #1A1A1F;
  --sidebar-border: rgba(255,255,255,0.06);

  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow:    0 2px 8px rgba(0,0,0,.5);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.6);

  --radius:    6px;
  --radius-sm: 4px;
  --sidebar-w: 220px;
  --topbar-h:  48px;
}

/* ── Light Theme ─────────────────────────────────────── */
[data-theme="light"] {
  --bg-app:     #FAFAFA;
  --bg-surface: #FFFFFF;
  --bg-hover:   #F4F4F5;
  --bg-active:  #ECECED;

  --text-primary:   #0F0F11;
  --text-secondary: #6B6B72;
  --text-tertiary:  #A0A0A8;

  --border:        rgba(0,0,0,0.06);
  --border-strong: rgba(0,0,0,0.1);

  --accent:      #5E6AD2;
  --accent-hover:#4F5BC6;
  --accent-text: #5E6AD2;
  --accent-muted:rgba(94,106,210,.08);

  --green:       #34A853;
  --green-muted: rgba(52,168,83,.08);
  --red:         #D93025;
  --red-muted:   rgba(217,48,37,.08);
  --orange:      #E8710A;
  --orange-muted:rgba(232,113,10,.08);

  --sidebar-bg:     #FFFFFF;
  --sidebar-border: rgba(0,0,0,0.06);

  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow:    0 2px 8px rgba(0,0,0,.06);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.1);
}

/* ── Reset ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-app);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Scrollbar ───────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* ── Layout ──────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 40;
  overflow-y: auto;
}

.sidebar-logo {
  height: var(--topbar-h);
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-logo-img {
  height: 18px;
  width: auto;
  flex-shrink: 0;
}

/* Invert black logo to white in dark theme */
[data-theme="dark"] .sidebar-logo-img,
:root .sidebar-logo-img {
  filter: invert(1);
}
[data-theme="light"] .sidebar-logo-img {
  filter: none;
}

.sidebar-logo span {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

/* ── App Switcher ──────────────────────────────────── */
.app-switcher {
  display: flex;
  gap: 4px;
  padding: 0 12px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.app-switcher-item {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background .15s, color .15s;
}
.app-switcher-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.app-switcher-item.active {
  background: var(--accent-muted);
  color: var(--accent-text);
}

.sidebar-nav {
  flex: 1;
  padding: 8px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  padding: 0 12px;
  margin: 1px 8px;
  border-radius: var(--radius-sm);
  border-left: 2px solid transparent;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  transition: background 80ms ease, color 80ms ease;
  cursor: pointer;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--bg-hover);
  border-left-color: var(--accent);
  color: var(--text-primary);
}

.nav-item svg {
  width: 14px; height: 14px;
  flex-shrink: 0;
  opacity: .5;
}

.nav-item.active svg { opacity: .8; }
.nav-item:hover svg { opacity: .7; }

.sidebar-bottom {
  padding: 8px 0;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

/* ── Theme toggle ────────────────────────────────────── */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2px;
  margin: 4px 16px;
}

.tt-btn {
  width: 22px; height: 22px;
  border-radius: 11px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  transition: all 80ms ease;
  font-size: 11px;
  padding: 0;
}

.tt-btn.on {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* ── Main Area ───────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-h);
  padding: 0 24px;
  background: var(--bg-app);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
  flex-shrink: 0;
}

.page-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.page-count {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-secondary);
}

.content {
  padding: 20px 24px;
  flex: 1;
}

/* ── Stats grid ──────────────────────────────────────── */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1px;
  margin-bottom: 20px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.stat {
  background: var(--bg-app);
  padding: 14px 16px;
}

.stat-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-tertiary);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stat-sub {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 400;
  margin-left: 4px;
}

/* ── Card — flat sections, no box ────────────────────── */
.card {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
  margin-bottom: 16px;
}

.card:last-child { border-bottom: none; margin-bottom: 0; }
.card + .card { margin-top: 0; }

.card-header {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-tertiary);
  margin-bottom: 10px;
  padding-bottom: 0;
  border-bottom: none;
}

.card-info {
  background: var(--bg-hover);
  border: 1px solid var(--border);
}
.card-info .card-body {
  padding: 0 4px;
}
.card-info .card-body ul {
  list-style: none;
  padding-left: 0 !important;
}
.card-info .card-body li {
  padding: 2px 0;
}
.card-info .card-body li::before {
  content: "→ ";
  color: var(--text-tertiary);
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 20px;
}

/* ── Table ───────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: 12px; }

thead th {
  text-align: left;
  padding: 0 12px;
  height: 28px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-tertiary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  vertical-align: middle;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 100ms ease;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover); }

tbody td {
  padding: 0 12px;
  height: 36px;
  color: var(--text-primary);
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
  font-size: 12px;
}

/* Table links — not accent colored */
tbody td a {
  color: var(--text-primary);
  text-decoration: none;
}
tbody td a:hover {
  color: var(--accent-text);
}

/* ── Badges ──────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  line-height: 18px;
}

.badge-primary { background: var(--accent-muted); color: var(--accent-text); }
.badge-success { background: var(--green-muted);  color: var(--green); }
.badge-muted   { background: var(--bg-hover);     color: var(--text-secondary); }
.badge-warning { background: var(--orange-muted); color: var(--orange); }
.badge-danger  { background: var(--red-muted);    color: var(--red); }
.badge-accent  { background: var(--accent);       color: #fff; }

.badge.relevant,
.badge.used     { background: var(--green-muted); color: var(--green); }
.badge.not-relevant,
.badge.rejected { background: var(--red-muted);   color: var(--red); }
.badge.new      { background: var(--accent-muted); color: var(--accent-text); }

/* Pillar badges — neutral with left color stripe */
.badge-pillar {
  background: var(--bg-hover);
  color: var(--text-secondary);
  border-left: 2px solid var(--accent);
  border-radius: 0 3px 3px 0;
  font-size: 11px;
  font-weight: 500;
}

/* ── Buttons ─────────────────────────────────────────── */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 80ms ease;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  color: var(--text-primary);
  background: var(--bg-surface);
}

button:hover, .btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

/* Default submit/primary — neutral style */
button[type="submit"], .btn-primary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
}

button[type="submit"]:hover, .btn-primary:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

/* Accent filled — only for special CTA buttons */
.btn-accent {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.btn-accent:hover {
  background: var(--accent-hover);
  border-color: transparent;
}

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-sm { height: 24px; padding: 0 8px; font-size: 11px; }

.btn-ghost {
  background: transparent;
  color: var(--text-tertiary);
  border: none;
  height: 24px;
  padding: 0 4px;
}

.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.btn-danger {
  background: transparent;
  color: var(--red);
  border: 1px solid var(--border);
}

.btn-danger:hover {
  background: var(--red-muted);
  border-color: var(--red);
}

/* ── Forms ───────────────────────────────────────────── */
.form-group { margin-bottom: 12px; }
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  align-items: end;
}

label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="date"],
input[type="datetime-local"],
input[type="search"],
select,
textarea {
  width: 100%;
  height: 28px;
  padding: 0 8px;
  font-size: 12px;
  font-family: var(--font);
  color: var(--text-primary);
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 80ms ease;
  -webkit-appearance: none;
}

textarea {
  height: auto;
  padding: 8px;
  resize: vertical;
  min-height: 64px;
  line-height: 1.5;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
}

input::placeholder, textarea::placeholder {
  color: var(--text-tertiary);
}

/* ── Filter row ──────────────────────────────────────── */
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.filter-row input,
.filter-row select { width: auto; flex: 1; min-width: 110px; }

/* ── Notices ─────────────────────────────────────────── */
.notice {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.notice.success { background: var(--green-muted); color: var(--green); }
.notice.error   { background: var(--red-muted);   color: var(--red); }

/* ── Pagination ──────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-secondary);
}

.pagination a {
  color: var(--text-secondary);
  text-decoration: none;
  height: 24px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  transition: all 80ms ease;
}

.pagination a:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

/* ── Utilities ───────────────────────────────────────── */
.text-muted { color: var(--text-secondary); }
.empty-row  { text-align: center; color: var(--text-tertiary); padding: 24px; font-size: 12px; }

code {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg-hover);
  padding: 1px 4px;
  border-radius: 3px;
  color: var(--text-secondary);
}

#action-result, #filter-result {
  font-size: 12px;
  color: var(--text-secondary);
  min-height: 1.5rem;
}

/* ── Link ────────────────────────────────────────────── */
.link-external {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 11px;
}

.link-external:hover { color: var(--accent-text); text-decoration: none; }

/* ── Bulk Bar ────────────────────────────────────────── */
.bulk-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  background: var(--accent-muted);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  font-size: 13px;
  color: var(--text-primary);
}

/* ── Analytics ───────────────────────────────────────── */
.stat-card { text-align:center; padding:1rem; }
.stat-label { font-size:11px; text-transform:uppercase; color:var(--text-secondary); letter-spacing:0.5px; }
.stat-value { font-size:28px; font-weight:700; color:var(--text-primary); margin:4px 0; }
.stat-detail { font-size:11px; color:var(--text-tertiary); }

.bar-chart { display:flex; align-items:flex-end; gap:2px; height:120px; padding:0.5rem 0; }
.bar-col { flex:1; display:flex; flex-direction:column; align-items:center; height:100%; justify-content:flex-end; }
.bar-fill { width:100%; background:var(--accent); border-radius:2px 2px 0 0; min-height:2px; transition:height 0.3s; }
.bar-label { font-size:9px; color:var(--text-tertiary); margin-top:4px; }

/* ── Calendar ────────────────────────────────────────── */
.calendar-table { width:100%; border-collapse:collapse; table-layout:fixed; }
.calendar-table th { padding:6px 4px; font-size:11px; text-transform:uppercase; color:var(--text-secondary); text-align:center; }
.cal-day { vertical-align:top; padding:4px; min-height:80px; border:1px solid var(--border); }
.cal-empty { border:none; }
.cal-today { background:var(--accent-muted); }
.cal-day-num { font-size:12px; font-weight:600; margin-bottom:2px; color:var(--text-secondary); }
.cal-today .cal-day-num { color:var(--accent-text); }
.cal-item { font-size:10px; padding:2px 4px; border-radius:3px; margin-bottom:2px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.cal-scheduled { background:var(--orange-muted, rgba(229,134,61,.15)); color:var(--orange); }
.cal-published { background:var(--green-muted); color:var(--green); }
.cal-more { font-size:10px; color:var(--text-tertiary); }
.cal-dot { display:inline-block; width:8px; height:8px; border-radius:50%; margin-right:4px; }
.cal-dot-scheduled { background:var(--orange); }
.cal-dot-published { background:var(--green); }

/* ── Drawer ──────────────────────────────────────────── */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease;
}

.drawer-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.drawer {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(.95);
  width: 680px;
  max-width: 92vw;
  max-height: 90vh;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 24px;
  opacity: 0;
  transition: opacity 200ms ease, transform 200ms cubic-bezier(.25,.1,.25,1);
  box-shadow: var(--shadow-lg);
}

.drawer-overlay.open .drawer {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

.drawer-close {
  position: absolute;
  top: 12px; right: 12px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 28px; height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 80ms ease;
  padding: 0;
}

.drawer-close:hover {
  background: var(--bg-active);
  color: var(--text-primary);
}

.drawer-content { display: flex; flex-direction: column; gap: 16px; }

.drawer-header {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.drawer-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
}

.drawer-desc {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.6;
}

.drawer-section { display: flex; flex-direction: column; gap: 6px; }

.drawer-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-tertiary);
}

.drawer-outline {
  margin: 0;
  padding-left: 20px;
  font-size: 12px;
  color: var(--text-primary);
  line-height: 1.8;
}

.drawer-source-text {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-secondary);
  max-height: 240px;
  overflow-y: auto;
}

.drawer-draft-text {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-primary);
  max-height: 360px;
  overflow-y: auto;
}

.drawer-draft-textarea {
  width: 100%;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
  resize: vertical;
  min-height: 120px;
  box-sizing: border-box;
}
.drawer-draft-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.drawer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

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

/* ── Scores ──────────────────────────────────────────── */
.drawer-scores {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.score-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.score-label {
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
}

.score-dots {
  letter-spacing: 1px;
  color: var(--accent-text);
}

.score-total {
  width: 100%;
  font-size: 12px;
  color: var(--text-primary);
  border-top: 1px solid var(--border);
  padding-top: 6px;
  margin-top: 2px;
}

/* ── Pillar list ─────────────────────────────────────── */
.pillar-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 0;
}

.pillar-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 0;
}

.pillar-bar-wrap {
  flex: 1;
  height: 6px;
  background: var(--bg-hover);
  border-radius: 3px;
  overflow: hidden;
  margin: 0 8px;
}

.pillar-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 300ms ease;
}

.pillar-count {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  min-width: 28px;
  text-align: right;
}

/* ── Login ───────────────────────────────────────────── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-app);
}

.login-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

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

.login-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--accent);
  font-weight: 600;
  font-size: 13px;
}

.login-card h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-primary);
}

/* ── HTMX indicator ──────────────────────────────────── */
.htmx-indicator { display: none; font-size: 11px; color: var(--text-tertiary); }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { display: inline; }

/* ── Style page ──────────────────────────────────────── */
.style-layout {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.prompt-textarea {
  width: 100%;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-primary);
  resize: vertical;
  box-sizing: border-box;
  tab-size: 2;
}
.prompt-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}
.prompt-textarea-lg {
  min-height: 400px;
}

.style-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.75rem;
}

.style-tab {
  padding: 8px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 100ms ease;
}
.style-tab:hover {
  color: var(--text-primary);
}
.style-tab.active {
  color: var(--accent-text);
  border-bottom-color: var(--accent);
}

.style-tab-content {
  display: none;
}
.style-tab-content.active {
  display: block;
}

/* ── Toast notifications ─────────────────────────────── */
#toast-container {
  position: fixed; top: 16px; right: 16px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 10px 16px; border-radius: 8px; font-size: 13px;
  color: #fff; opacity: 0; transform: translateX(40px);
  transition: opacity 200ms ease, transform 200ms ease;
  max-width: 360px; line-height: 1.4;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast-success { background: #1a7f37; }
.toast-error   { background: #c33; }
.toast-info    { background: var(--bg-active); color: var(--text-primary); border: 1px solid var(--border-strong); }

/* ── Channel type toggle ─────────────────────────────── */
.type-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer; font-size: 12px; padding: 3px 8px;
  border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg-surface); transition: all 150ms ease;
  user-select: none; white-space: nowrap;
}
.type-toggle:hover { border-color: var(--border-strong); background: var(--bg-hover); }
.type-toggle[data-author="1"] {
  border-color: rgba(94,106,210,0.3); background: rgba(94,106,210,0.08);
  color: var(--accent-text);
}
tr.author-row { background: rgba(94,106,210,0.03); }

/* ── Hamburger button (hidden on desktop) ────────────── */
.hamburger {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 0 4px;
  height: 28px;
  width: 28px;
  cursor: pointer;
  flex-shrink: 0;
}
.hamburger:hover { color: var(--text-primary); background: var(--bg-hover); }

/* ── Sidebar overlay (mobile) ────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 35;
}
.sidebar-overlay.open { display: block; }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 768px) {
  /* Sidebar */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 150ms ease;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  /* Main area */
  .main { margin-left: 0; }
  .content { padding: 12px 12px; }

  /* Topbar */
  .topbar { padding: 0 12px; }
  .hamburger { display: flex; align-items: center; justify-content: center; margin-right: 8px; }

  /* Grids */
  .two-col { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }

  /* Table: hide columns */
  .mobile-hide { display: none; }

  /* Table: smaller cells */
  tbody td { padding: 0 6px; height: 32px; max-width: 160px; font-size: 11px; }
  thead th { padding: 0 6px; font-size: 10px; }

  /* Action buttons: icon-only */
  .btn-sm span, .btn span.btn-label { display: none; }

  /* Drawer: fullscreen on mobile */
  .drawer {
    width: 100vw;
    max-width: 100vw;
    max-height: 100vh;
    border: none;
    border-radius: 0;
  }

  /* Filter row: stack */
  .filter-row { flex-direction: column; }
  .filter-row input,
  .filter-row select { width: 100%; min-width: 0; }

  /* Pagination */
  .pagination { flex-wrap: wrap; justify-content: center; }

  /* Toast: full width */
  #toast-container { left: 12px; right: 12px; }
  .toast { max-width: 100%; }
}

/* ── Period dropdown ─────────────────────────────────── */
.period-menu {
  z-index: 1000;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  min-width: 140px;
  overflow: hidden;
}
.period-opt {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  font-size: 13px;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
}
.period-opt:hover {
  background: var(--bg-hover);
}

/* Score strip — compact 6-dot display */
.score-strip { display:inline-flex; gap:2px; cursor:help; vertical-align:middle; }
.sd { display:inline-block; width:10px; height:10px; border-radius:50%; }
.sd-0{background:#555}.sd-1{background:#e74c3c}.sd-2{background:#e67e22}
.sd-3{background:#f1c40f}.sd-4{background:#2ecc71}.sd-5{background:#27ae60}

/* Alert board */
.alert-board { display:flex; flex-wrap:wrap; gap:8px; margin-bottom:1rem; }
.alert-item { display:flex; align-items:center; gap:6px; padding:6px 12px; border-radius:var(--radius); font-size:13px; border:1px solid; }
.alert-icon { font-size:12px; flex-shrink:0; }
.alert-ok { background:var(--green-muted); border-color:rgba(77,167,113,.2); color:var(--green); }
.alert-warning { background:rgba(229,134,61,.1); border-color:rgba(229,134,61,.2); color:var(--orange); }
.alert-error { background:var(--red-muted); border-color:rgba(209,36,47,.2); color:var(--red); }
