:root,
html[data-theme="light"] {
  /* Eva / Blueberry-inspired tokens */
  --primary: #3366ff;
  --primary-hover: #274bdb;
  --primary-soft: #eef2ff;
  --primary-muted: #d6e0ff;
  --success: #00d68f;
  --success-soft: #e5fff5;
  --warning: #ffaa00;
  --warning-soft: #fff4d6;
  --danger: #ff3d71;
  --danger-soft: #ffe5ec;
  --info: #0095ff;
  --info-soft: #e5f4ff;

  --bg: #f1f5f9;
  --panel: #ffffff;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --sidebar-w: 288px;
  --sidebar-collapsed-w: 84px;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --font: "Inter", ui-sans-serif, system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --top-bg: rgba(255, 255, 255, 0.9);
  --hub-grad: linear-gradient(165deg, #ffffff 0%, #f8fafc 100%);
  --chart-label: #94a3b8;
  --label-tracking: 0.01em;
  --side-bg: #eef2ff;
}

html[data-theme="dark"] {
  --primary: #598bff;
  --primary-hover: #7ea1ff;
  --primary-soft: rgba(89, 139, 255, 0.16);
  --primary-muted: rgba(89, 139, 255, 0.35);
  --success: #00e096;
  --success-soft: rgba(0, 224, 150, 0.14);
  --warning: #ffc94d;
  --warning-soft: rgba(255, 201, 77, 0.14);
  --danger: #ff708d;
  --danger-soft: rgba(255, 112, 141, 0.14);
  --info: #42aaff;
  --info-soft: rgba(66, 170, 255, 0.14);

  --bg: #151a30;
  --panel: #222b45;
  --line: #2e3a59;
  --line-strong: #3d4c70;
  --ink: #edf1f7;
  --ink-2: #c5cee0;
  --muted: #8f9bb3;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.25);
  --top-bg: rgba(34, 43, 69, 0.92);
  --hub-grad: linear-gradient(180deg, #222b45 0%, #1a2138 100%);
  --chart-label: #8f9bb3;
  --ink: #edf1f7;
  --ink-2: #c5cee0;
  --muted: #9aa5bd;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.011em;
  transition: background .2s ease, color .2s ease;
}
html[data-theme="dark"] body {
  background: var(--bg);
}
a { color: inherit; }
button, a[href], label { cursor: pointer; }
button:disabled { opacity: 0.55; cursor: wait; }

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100dvh;
  transition: grid-template-columns .22s ease;
}
html.sidebar-collapsed .app {
  grid-template-columns: var(--sidebar-collapsed-w) 1fr;
}

/* —— Sidebar (light Blueberry) —— */
.side {
  background: color-mix(in srgb, var(--primary-soft) 55%, #ffffff);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 0;
  box-shadow: none;
  z-index: 2;
  transition: padding .22s ease;
  overflow: hidden;
}
html[data-theme="dark"] .side {
  background: rgba(89, 139, 255, 0.08);
}
.brand {
  display: flex; gap: 12px; align-items: center;
  padding: 18px 20px 16px;
  text-decoration: none; color: inherit;
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
}
.brand-text { min-width: 0; }
.logo {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--primary);
  color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(51, 102, 255, 0.35);
}
.brand strong { display: block; color: var(--ink); font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.brand small { color: var(--muted); font-size: 12px; font-weight: 400; letter-spacing: 0; }

html.sidebar-collapsed .side { padding: 0; }
html.sidebar-collapsed .brand { justify-content: center; padding: 16px 10px; }
html.sidebar-collapsed .nav { padding: 10px 8px; }
html.sidebar-collapsed .brand-text,
html.sidebar-collapsed .nav-label,
html.sidebar-collapsed .nav a > span:not(.badge):not(.nav-ico),
html.sidebar-collapsed .nav .nav-text,
html.sidebar-collapsed .user-meta,
html.sidebar-collapsed .side-foot .icon-btn {
  display: none;
}
html.sidebar-collapsed .nav a {
  justify-content: center; padding: 12px; position: relative;
}
html.sidebar-collapsed .nav .badge {
  position: absolute; top: 6px; right: 6px; margin: 0;
  min-width: 16px; height: 16px; font-size: 10px;
}
html.sidebar-collapsed .user-card { justify-content: center; padding: 8px; }
html.sidebar-collapsed .nav a[title]:hover::after,
html.sidebar-collapsed .nav a[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
  background: var(--ink); color: var(--panel); font-size: 12px; font-weight: 700;
  padding: 6px 10px; border-radius: 8px; white-space: nowrap; z-index: 20;
  box-shadow: var(--shadow);
}

.nav { flex: 1; overflow: auto; padding: 12px 12px 8px; }
.nav-label {
  margin: 14px 12px 8px;
  font-size: 11px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase; color: #94a3b8;
}
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; margin: 2px 0; border-radius: 12px;
  color: #475569; text-decoration: none;
  font-size: 14px; font-weight: 500; letter-spacing: -0.01em;
  min-height: 44px;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.nav a:hover { background: rgba(255,255,255,.7); color: var(--ink); }
.nav a.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 2px rgba(51, 102, 255, 0.35);
  font-weight: 600;
}
.nav a.active .badge { background: rgba(255,255,255,.22); color: #fff; }
.nav a.active .nav-ico { opacity: 1; color: #fff; }
.nav .badge {
  margin-left: auto;
  background: var(--primary);
  color: #fff;
  font-size: 11px; font-weight: 700;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px; display: inline-grid; place-items: center;
}
.nav-ico {
  width: 18px; height: 18px; opacity: 0.85; flex-shrink: 0;
}
.nav a.active .nav-ico { opacity: 1; }

.side-foot {
  border-top: 1px solid rgba(226, 232, 240, 0.9);
  padding: 12px; margin-top: 0;
}
.user-card {
  display: flex; gap: 10px; align-items: center;
  background: rgba(255,255,255,.75); border-radius: 12px; padding: 10px 12px;
}
.user-meta { min-width: 0; flex: 1; }
.user-meta p {
  margin: 0; font-size: 13px; font-weight: 700; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-meta span { display: block; font-size: 11px; color: var(--muted); }
.icon-btn {
  border: 0; background: transparent; color: var(--muted);
  width: 32px; height: 32px; border-radius: 10px; font-size: 14px;
}
.icon-btn:hover { color: var(--danger); background: var(--danger-soft); }

/* —— Main —— */
.main { display: flex; flex-direction: column; min-width: 0; }
.top {
  background: var(--top-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px;
  padding: 14px 24px; position: sticky; top: 0; z-index: 5;
}
.top-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.chrome-btn {
  width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink-2);
  display: grid; place-items: center; box-shadow: var(--shadow-sm);
}
.chrome-btn:hover { border-color: var(--primary-muted); color: var(--primary); background: var(--primary-soft); }
.field-error {
  display: block; margin-top: 4px; font-size: 12px; font-weight: 700; color: var(--danger);
}
input.is-invalid, select.is-invalid, textarea.is-invalid {
  border-color: var(--danger) !important;
  background: var(--danger-soft);
}
.hub-card {
  background: var(--hub-grad);
}
.crumbs { font-size: 12.5px; color: var(--muted); font-weight: 500; letter-spacing: 0.01em; }
.crumbs b { color: var(--ink); font-weight: 700; }
.ws {
  /* legacy class — custom select uses .c-select-sm */
  border: 1px solid var(--line); background: var(--panel); border-radius: 12px;
  padding: 9px 12px; font: inherit; font-weight: 600; font-size: 13px;
  color: var(--ink); box-shadow: var(--shadow-sm);
}

/* Tasks-style custom select */
.c-select {
  position: relative;
  width: 100%;
  min-width: 0;
}
.c-select-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}
.c-select-btn {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcfe;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.011em;
  text-align: left;
  box-shadow: inset 0 1px 2px rgba(34, 43, 69, 0.03);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
  cursor: pointer;
}
.c-select-sm .c-select-btn {
  padding: 9px 12px;
  font-size: 13px;
  border-radius: 12px;
  width: auto;
  min-width: 10rem;
}
.c-select-btn:hover { border-color: var(--line-strong); }
.c-select.is-open .c-select-btn {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(51, 102, 255, 0.18);
}
.c-select.is-disabled .c-select-btn {
  opacity: 0.55;
  cursor: not-allowed;
}
.c-select-value {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.c-select-value.is-placeholder { color: var(--muted); font-weight: 500; }
.c-select-chevron {
  flex-shrink: 0;
  color: var(--muted);
  transition: transform .2s ease;
}
.c-select.is-open .c-select-chevron { transform: rotate(180deg); color: var(--primary); }

.c-select-menu {
  margin: 0;
  padding: 4px;
  list-style: none;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 12px 32px rgba(34, 43, 69, 0.14), 0 2px 8px rgba(34, 43, 69, 0.06);
}
html[data-theme="dark"] .c-select-menu {
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}
.c-select-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 500;
  transition: background .12s ease;
}
.c-select-option:hover { background: var(--bg); }
.c-select-option.is-selected {
  background: var(--primary-soft);
  color: var(--ink);
  font-weight: 600;
}
.c-select-option.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.c-select-option-label { flex: 1; min-width: 0; }
.c-select-check {
  flex-shrink: 0;
  color: var(--primary);
  opacity: 0;
}
.c-select-option.is-selected .c-select-check { opacity: 1; }

.c-select.is-invalid .c-select-btn,
.field:has(select.is-invalid) .c-select-btn,
label:has(select.is-invalid) .c-select-btn {
  border-color: var(--danger) !important;
  background: var(--danger-soft);
}
.search {
  width: min(280px, 36vw);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 14px; font: inherit; background: var(--panel); color: var(--muted);
  box-shadow: var(--shadow-sm);
}
.avatar {
  width: 36px; height: 36px; border-radius: 12px;
  background: var(--primary-soft); color: var(--primary);
  display: grid; place-items: center; font-weight: 700; font-size: 13px; flex-shrink: 0;
  border: 1px solid var(--primary-muted);
}

.content {
  /* Match Tasks AdminLayout: mx-auto max-w-7xl + generous padding */
  width: 100%;
  max-width: 80rem; /* 1280px — empty right gutter on wide screens is intentional */
  margin-inline: auto;
  padding: 1.5rem 1.5rem 3rem;
}
@media (min-width: 640px) {
  .content { padding: 1.5rem 1.5rem 3rem; }
}
@media (min-width: 1024px) {
  .content { padding: 2rem 2rem 3.5rem; }
}
.title-row {
  display: flex; justify-content: space-between; gap: 16px;
  align-items: end; margin-bottom: 1.5rem; flex-wrap: wrap;
}
h1 {
  margin: 0; font-size: 1.5rem;
  letter-spacing: -.025em; font-weight: 600; color: var(--ink);
  line-height: 1.25;
}
.sub {
  margin: 6px 0 0; color: var(--muted); font-size: 14px;
  font-weight: 400; line-height: 1.5; max-width: 42rem; letter-spacing: -0.01em;
}
.page-kicker {
  margin: 0 0 4px; font-size: 12px; font-weight: 500;
  letter-spacing: 0; text-transform: none; color: var(--primary);
}

.btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 12px; padding: 10px 16px; font: inherit; font-weight: 600; font-size: 13.5px;
  letter-spacing: -0.01em;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn.primary {
  background: var(--primary);
  border-color: var(--primary); color: #fff;
  box-shadow: 0 6px 16px rgba(51, 102, 255, 0.28);
}
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { color: var(--danger); border-color: var(--danger-soft); background: var(--panel); }
.btn.sm { padding: 7px 11px; font-size: 12px; border-radius: 10px; }
.btn.ghost { background: transparent; box-shadow: none; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* KPI widgets — Tasks StatCard pattern */
.kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 1.25rem;
}
@media (min-width: 1280px) {
  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.kpi {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 14px 14px 16px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.kpi::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--primary);
}
.kpi.tone-brand::before { background: var(--primary); }
.kpi.tone-warning { border-color: rgba(245, 158, 11, 0.28); }
.kpi.tone-warning::before { background: #f59e0b; }
.kpi.tone-info { border-color: rgba(14, 165, 233, 0.28); }
.kpi.tone-info::before { background: #0ea5e9; }
.kpi.tone-success { border-color: rgba(0, 214, 143, 0.28); }
.kpi.tone-success::before { background: var(--success); }
.kpi.tone-danger { border-color: rgba(255, 61, 113, 0.28); }
.kpi.tone-danger::before { background: var(--danger); }
.kpi.tone-violet { border-color: rgba(139, 92, 246, 0.28); }
.kpi.tone-violet::before { background: #8b5cf6; }

.kpi-top { display: none; } /* legacy */
.kpi-ico {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 800; font-size: 13px;
  margin-left: 2px;
}
.kpi-ico.blue { background: var(--primary-soft); color: var(--primary); }
.kpi-ico.orange { background: var(--warning-soft); color: #db8b00; }
.kpi-ico.cyan { background: var(--info-soft); color: var(--info); }
.kpi-ico.green { background: var(--success-soft); color: #00b887; }
.kpi-ico.pink { background: var(--danger-soft); color: var(--danger); }
.kpi-body { min-width: 0; }
.kpi .l {
  margin: 0; font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}
.kpi .n {
  margin-top: 3px; font-size: 1.55rem; font-weight: 800;
  letter-spacing: -.04em; color: var(--ink); line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.kpi .spark { display: none; }

.section-label {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 12px;
}
.section-label::before {
  content: "";
  width: 4px; height: 20px; border-radius: 99px;
  background: var(--primary); flex-shrink: 0;
}
.section-label h3 {
  margin: 0; font-size: 14px; font-weight: 700; color: var(--ink);
}
.section-label.tone-violet::before { background: #8b5cf6; }
.section-label.tone-sky::before { background: #0ea5e9; }

.queue-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 1.25rem;
}
@media (min-width: 1280px) {
  .queue-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.queue-list { list-style: none; margin: 0; padding: 4px 8px; }
.queue-list li { border-bottom: 1px solid var(--line); }
.queue-list li:last-child { border-bottom: 0; }
.queue-item {
  display: block; padding: 10px 12px; border-radius: 10px;
  text-decoration: none; transition: background .12s ease;
}
.queue-item:hover { background: var(--bg); }
.queue-item-top {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
}
.queue-item-title {
  margin: 0; font-size: 13.5px; font-weight: 600; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.queue-item-meta {
  margin: 4px 0 0; font-size: 11px; color: var(--muted);
}
.queue-item-meta .mono { color: var(--primary); font-weight: 700; }
.queue-empty {
  margin: 16px; padding: 28px 16px; text-align: center;
  border: 1px dashed var(--line); border-radius: 12px;
  background: var(--bg); color: var(--muted); font-size: 13.5px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}
.grid-home {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
.grid-home-secondary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
}
/* Legacy .panel = same shell as .crm-panel (universal) */
.panel {
  position: relative;
  background: var(--panel);
  border: 1px solid rgba(51, 102, 255, 0.22);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.panel::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--primary);
}
.panel-pad { padding: 20px 22px 22px; }
.panel-h {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid var(--line);
  background: var(--primary-soft);
}
.panel-h h2 { margin: 0; font-size: 14px; font-weight: 700; color: var(--ink); }
.panel-h p { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.panel-h a { font-size: 13px; font-weight: 700; color: var(--primary); text-decoration: none; white-space: nowrap; }

table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.75px; background: var(--panel); }
table.data th, table.data td {
  text-align: left; padding: 14px 18px; border-bottom: 1px solid var(--line); vertical-align: middle;
}
table.data th {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); background: linear-gradient(180deg, #f7f9fc, #f0f3f9);
  font-weight: 700;
}
html[data-theme="dark"] table.data th {
  background: rgba(0,0,0,.18);
}
table.data tbody tr { transition: background .12s ease; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: rgba(51, 102, 255, 0.035); }
html[data-theme="dark"] table.data tbody tr:hover td { background: rgba(89, 139, 255, 0.08); }
table.data a { font-weight: 700; text-decoration: none; color: var(--ink); }
table.data a:hover { color: var(--primary); }
table.data td { color: var(--ink-2); font-weight: 500; }
.mono { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--ink-2); letter-spacing: -0.02em; }
.muted { color: var(--muted); }

.person-cell {
  display: flex; align-items: center; gap: 10px; min-width: 0;
}
.person-avatar {
  width: 36px; height: 36px; border-radius: 999px; flex-shrink: 0;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600; letter-spacing: -0.02em;
  background: var(--primary-soft);
  color: var(--primary);
  border: 0;
}
.person-meta { min-width: 0; }
.person-meta strong {
  display: block; font-size: 14px; font-weight: 500; color: var(--ink);
  letter-spacing: -0.01em;
}
.person-meta span {
  display: block; margin-top: 2px; font-size: 11px; font-weight: 400; color: #94a3b8;
}

.status-dot {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 3px 10px 3px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 500;
  background: #ecfdf5; color: #047857;
  ring: 1px solid #a7f3d0;
  box-shadow: inset 0 0 0 1px #a7f3d0;
}
.status-dot::before {
  content: ""; width: 7px; height: 7px; border-radius: 99px;
  background: #10b981; flex-shrink: 0;
}
.status-dot.off {
  background: #f8fafc; color: #64748b;
  box-shadow: inset 0 0 0 1px #e2e8f0;
}
.status-dot.off::before { background: #94a3b8; }

.directory-toolbar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.directory-search {
  position: relative; flex: 1; min-width: 200px; max-width: 28rem;
}
.directory-search svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: #94a3b8; pointer-events: none;
}
.directory-search input {
  padding-left: 38px !important;
  background: #fff !important;
  box-shadow: none !important;
}
.directory-filters {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.directory-filters .c-select { width: auto; min-width: 9.5rem; }
.directory-filters .c-select-btn {
  background: #fff;
  box-shadow: none;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  height: 40px;
}

.crm-count {
  display: inline-flex; align-items: center;
  margin-left: 6px; padding: 2px 7px; border-radius: 6px;
  font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums;
  background: var(--primary-soft); color: var(--primary);
}

.role-pill {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 500;
}
.role-pill.admin { background: #eef2ff; color: #4338ca; box-shadow: inset 0 0 0 1px #c7d2fe; }
.role-pill.member { background: #f0f9ff; color: #0369a1; box-shadow: inset 0 0 0 1px #bae6fd; }

table.data th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: #64748b; background: #f1f5f9;
  font-weight: 600;
}
table.data td { font-size: 13.5px; font-weight: 400; color: #334155; }
table.data tbody tr:hover td { background: #f8fafc; }

.crm-panel-head h2 {
  margin: 0; font-size: 14px; font-weight: 600; color: var(--ink);
  letter-spacing: -0.01em;
}
.crm-panel-head p {
  margin: 4px 0 0; font-size: 12px; color: var(--muted); line-height: 1.45;
  max-width: 62ch; font-weight: 400;
}

.pill {
  display: inline-flex; align-items: center; border-radius: 999px;
  padding: 4px 10px; font-size: 11px; font-weight: 700; letter-spacing: 0.01em;
  background: var(--primary-soft); color: var(--primary);
}
.pill.neutral { background: var(--bg); color: var(--ink-2); }
.pill.ok { background: var(--success-soft); color: #00b887; }
.pill.approve, .s-queued { background: var(--warning-soft); color: #c47f00; }
.pill.write, .s-writing { background: var(--primary-soft); color: var(--primary); }
.pill.review, .s-drafted, .s-approved { background: var(--success-soft); color: #00b887; }
.pill.outreach { background: #f0e7ff; color: #7b61ff; }
.s-rejected, .s-failed { background: var(--danger-soft); color: var(--danger); }
.s-published { background: var(--success-soft); color: #00b887; }
.status {
  display: inline-flex; border-radius: 999px; padding: 4px 10px;
  font-size: 11px; font-weight: 700; text-transform: capitalize; letter-spacing: 0.01em;
}

.tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.tab {
  border: 1px solid var(--line); background: var(--panel); border-radius: 999px;
  padding: 8px 14px; font-size: 13px; font-weight: 700; color: var(--muted);
  text-decoration: none; box-shadow: var(--shadow-sm);
}
.tab.on {
  background: var(--primary); color: #fff; border-color: var(--primary);
  box-shadow: 0 6px 14px rgba(51, 102, 255, 0.25);
}

.hubs { display: grid; grid-template-columns: 1fr; gap: 10px; padding: 0; }
.hub-card {
  border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
  background: var(--bg);
  text-decoration: none; display: block;
  transition: border-color .15s ease, transform .15s ease;
}
.hub-card:hover { border-color: var(--primary-muted); transform: translateY(-1px); }
.hub-card h3 { margin: 0 0 4px; font-size: 14px; color: var(--ink); }
.hub-card p { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.45; }
html[data-theme="dark"] .hub-card { background: rgba(0,0,0,.15); }

.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); min-height: 380px; }
.split-left { border-right: 1px solid var(--line); overflow: auto; }
.detail { padding: 18px; }
.detail h3 { margin: 0 0 6px; font-size: 17px; }
.meta { color: var(--muted); font-size: 12.5px; margin-bottom: 12px; }
.draft-view {
  max-height: 55vh; overflow: auto; white-space: pre-wrap; word-break: break-word;
  background: #151a30; color: #edf1f7; border-radius: 12px; padding: 14px;
  font-size: 12.5px; line-height: 1.55; font-family: var(--mono);
}
html[data-theme="dark"] .draft-view { background: #0d1224; border: 1px solid var(--line); }
.scoreline { margin: 0 0 10px; color: var(--muted); font-size: 13px; }
.scoreline b { color: #00b887; }
.empty, .note, .status-line, .coming {
  padding: 14px 16px; border-radius: 14px; background: var(--bg); color: var(--muted);
  border: 1px solid var(--line); font-size: 13.5px;
}
.status-line { margin: 10px 0; background: var(--panel); }
.status-line.busy { color: var(--primary); border-color: var(--primary-muted); background: var(--primary-soft); }
.status-line.ok { color: #00b887; border-color: #b8f0d8; background: var(--success-soft); }
.status-line.err { color: var(--danger); border-color: #ffc2d1; background: var(--danger-soft); }

.pipeline {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 6px 0 14px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow-x: auto;
}
.pipeline-step {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
}
.pipeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--line);
  border: 2px solid var(--line);
}
.pipeline-step.done { color: #00b887; }
.pipeline-step.done .pipeline-dot { background: #00b887; border-color: #00b887; }
.pipeline-step.current { color: var(--primary); font-weight: 600; }
.pipeline-step.current .pipeline-dot {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}
.pipeline-rail {
  flex: 1 1 28px;
  height: 2px;
  min-width: 20px;
  margin: 0 10px;
  background: var(--line);
}
.pipeline-rail.on { background: #00b887; }

.next-step {
  margin: 0 0 16px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--primary-muted);
  background: var(--primary-soft);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.45;
}
.next-step.ok { border-color: #b8f0d8; background: var(--success-soft); color: #067a5a; }
.next-step.err { border-color: #ffc2d1; background: var(--danger-soft); color: var(--danger); }
.next-step.busy { color: var(--primary); }
.next-step a { color: inherit; font-weight: 600; }

.draft-meta-strip {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.draft-fails {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  font-size: 12.5px;
}
.draft-fails ul { margin: 6px 0 0; padding-left: 18px; color: #9a3412; }

/* ——— On-page SEO score (Check score) ——— */
.seo-score-panel {
  margin: 0 0 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 92%, #e8eef8);
}
.seo-score-summary {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px 20px;
  align-items: center;
}
.seo-score-gauge {
  position: relative;
  width: 110px;
  height: 110px;
}
.seo-score-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.seo-score-ring-bg {
  fill: none;
  stroke: color-mix(in srgb, var(--line) 80%, #cbd5e1);
  stroke-width: 10;
}
.seo-score-ring-fg {
  fill: none;
  stroke: var(--primary);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s ease, stroke 0.3s ease;
}
.seo-score-ring-fg.is-good { stroke: #059669; }
.seo-score-ring-fg.is-mid { stroke: #d97706; }
.seo-score-ring-fg.is-low { stroke: #dc2626; }
.seo-score-gauge-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.seo-score-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.seo-score-label {
  margin-top: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.seo-score-cats { display: grid; gap: 8px; min-width: 0; }
.seo-cat-row { display: grid; gap: 4px; }
.seo-cat-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text);
}
.seo-cat-label strong { font-variant-numeric: tabular-nums; }
.seo-cat-bar {
  height: 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--line) 70%, #e2e8f0);
  overflow: hidden;
}
.seo-cat-bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), color-mix(in srgb, var(--primary) 55%, #38bdf8));
}
.seo-score-issues {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  align-self: start;
  text-align: right;
}
.seo-score-issues.has-issues { color: #b45309; }
.seo-score-issues.clean { color: #067a5a; }
.seo-score-todos {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.seo-score-todos-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}
.seo-todo-list { display: grid; gap: 8px; }
.seo-todo-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.seo-todo-row.sev-error { border-color: #fecaca; background: #fff5f5; }
.seo-todo-row.sev-warning { border-color: #fde68a; background: #fffbeb; }
.seo-todo-row.sev-notice { border-color: #e2e8f0; }
.seo-todo-main strong { display: block; font-size: 13.5px; margin-bottom: 2px; }
.seo-todo-main p { margin: 0 0 4px; font-size: 12.5px; line-height: 1.4; color: var(--text); }
.seo-todo-main p.muted { margin: 0; }
.seo-kb-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  padding: 8px 10px;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--text);
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 8px;
}
.seo-kb-status strong { font-weight: 600; }
.seo-kb-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #059669;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.seo-google-tip {
  margin-top: 8px;
  padding: 8px 10px;
  border-left: 3px solid #94a3b8;
  background: #f8fafc;
  border-radius: 0 6px 6px 0;
}
.seo-google-tip-label {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 4px;
}
.seo-google-tip p {
  margin: 0 0 4px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text);
}
.seo-google-tip p:last-child { margin-bottom: 0; }
.seo-house-rule span {
  font-weight: 600;
  color: #475569;
}
.seo-google-sources {
  font-size: 12px !important;
}
.seo-google-sources a {
  color: #0369a1;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.seo-check-body .seo-google-tip { margin-top: 6px; }
.seo-todo-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.seo-sev {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 3px 8px;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
}
.sev-error .seo-sev { background: #fee2e2; color: #991b1b; }
.sev-notice .seo-sev { background: #e2e8f0; color: #475569; }
.seo-todo-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.seo-score-sections {
  margin-top: 14px;
  display: grid;
  gap: 8px;
}
.seo-section-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
}
.seo-section-card > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  font-size: 13.5px;
  font-weight: 600;
}
.seo-section-card > summary::-webkit-details-marker { display: none; }
.seo-section-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  color: var(--muted);
  font-size: 12px;
}
.seo-fraction {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--ink);
}
.seo-check-list {
  margin: 0;
  padding: 0 12px 10px;
  list-style: none;
  display: grid;
  gap: 6px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}
.seo-check-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: start;
  font-size: 12.5px;
  line-height: 1.4;
}
.seo-check-ico {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  margin-top: 1px;
}
.seo-check-item.pass .seo-check-ico { background: #d1fae5; color: #065f46; }
.seo-check-item.fail .seo-check-ico { background: #fef3c7; color: #92400e; }
.seo-check-body { display: grid; gap: 2px; min-width: 0; }
.seo-check-body strong { font-size: 12.5px; }
.seo-check-body span { color: var(--muted); }
.seo-check-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.seo-fix-focus {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  border-radius: 8px;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent);
}
#seo-score-status { margin-top: 10px; }
.seo-ai-fix-dialog {
  width: min(760px, 100%);
  display: flex;
  flex-direction: column;
  max-height: min(84vh, 820px);
}
.seo-ai-fix-options {
  display: grid;
  gap: 10px;
  margin: 12px 0 14px;
  overflow: auto;
  min-height: 0;
  flex: 1;
}
.seo-ai-fix-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
}
.seo-ai-fix-card:has(input:checked) {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 16%, transparent);
}
.seo-ai-fix-card.is-recommended {
  border-color: #059669;
}
.seo-ai-fix-card.is-recommended:has(input:checked) {
  border-color: #059669;
  box-shadow: 0 0 0 3px color-mix(in srgb, #059669 22%, transparent);
}
.seo-ai-rec-pill {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: #059669;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  vertical-align: middle;
}
.seo-ai-fix-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 8px;
  font-size: 12px;
}
.seo-ai-pred { font-weight: 650; color: var(--text); }
.seo-ai-fixes { color: #047857; }
.seo-ai-miss { color: #b45309; }
.seo-ai-changes {
  margin: 0 0 8px;
  padding-left: 18px;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--text);
}
.seo-ai-fix-card input { margin-top: 4px; }
.seo-ai-fix-card-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}
.seo-ai-fix-card-body p { margin: 0 0 8px; font-size: 13px; line-height: 1.4; }
.seo-ai-fix-meta {
  display: grid;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12.5px;
}
.seo-ai-fix-excerpt {
  font-size: 12px;
  line-height: 1.4;
  max-height: 4.2em;
  overflow: hidden;
}
.seo-ai-fix-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
  position: sticky;
  bottom: 0;
  padding-top: 10px;
  background: var(--panel);
  border-top: 1px solid var(--line);
}
@media (max-width: 800px) {
  .seo-score-summary {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }
  .seo-score-cats { width: 100%; }
  .seo-score-issues { text-align: center; }
  .seo-todo-row { grid-template-columns: 1fr; }
  .seo-todo-side { align-items: flex-start; }
}

.mono { font-family: var(--mono); font-size: 12.5px; }

.image-notes-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 6px;
}
.image-notes {
  display: block;
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  min-height: 64px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  line-height: 1.45;
}
.image-notes:focus {
  outline: 2px solid color-mix(in srgb, var(--primary) 55%, transparent);
  outline-offset: 1px;
  border-color: var(--primary);
}

/* —— Topic detail page (Task-detail inspired) —— */
.topic-detail {
  max-width: 1180px;
}
.topic-back {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
}
.topic-back a {
  font-size: 13px;
  font-weight: 650;
  color: var(--muted);
  text-decoration: none;
}
.topic-back a:hover { color: var(--primary); }
.topic-back-code {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 650;
  color: var(--primary);
  display: none;
}
@media (max-width: 960px) {
  .topic-back-code { display: inline; }
}

.topic-record {
  position: relative;
  overflow: hidden;
  margin-bottom: 14px;
  padding: 14px 16px 16px 18px;
  border: 1px solid color-mix(in srgb, var(--primary) 22%, var(--line));
  border-radius: 14px;
  background: linear-gradient(145deg, var(--panel) 0%, color-mix(in srgb, var(--primary-soft) 55%, var(--panel)) 100%);
  box-shadow: var(--shadow-sm);
}
.topic-record-bar {
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--primary);
}
.topic-record-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px 16px;
}
.topic-record-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.topic-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
}
.topic-badge.code {
  font-family: var(--mono);
  letter-spacing: 0.02em;
  background: var(--primary-soft);
  color: var(--primary);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 18%, transparent);
}
.topic-badge.seo {
  background: var(--success-soft);
  color: #067a5a;
  box-shadow: inset 0 0 0 1px rgba(0, 214, 143, 0.28);
}
.topic-badge.score {
  background: var(--info-soft);
  color: #0369a1;
  box-shadow: inset 0 0 0 1px rgba(0, 149, 255, 0.22);
}
.topic-record-title {
  margin: 0;
  font-size: clamp(1.15rem, 1.05rem + 0.45vw, 1.4rem);
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.3;
  max-width: 52rem;
}
.topic-record-title-row {
  margin-top: 10px;
  max-width: 52rem;
}
.topic-record-title-text {
  display: inline;
}
.topic-record-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.topic-chiplet {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 600;
  box-shadow: inset 0 0 0 1px transparent;
}
.topic-chiplet.kw {
  background: var(--primary-soft);
  color: var(--primary);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 16%, transparent);
}
.topic-chiplet.intent {
  background: #fff7ed;
  color: #c2410c;
  box-shadow: inset 0 0 0 1px rgba(194, 65, 12, 0.16);
}
html[data-theme="dark"] .topic-chiplet.intent {
  background: rgba(194, 65, 12, 0.18);
  color: #fdba74;
}
.topic-chiplet.by {
  background: #f5f3ff;
  color: #5b21b6;
  box-shadow: inset 0 0 0 1px rgba(91, 33, 182, 0.14);
}
html[data-theme="dark"] .topic-chiplet.by {
  background: rgba(139, 92, 246, 0.16);
  color: #c4b5fd;
}
.topic-chiplet.words {
  background: var(--info-soft);
  color: #0369a1;
  box-shadow: inset 0 0 0 1px rgba(0, 149, 255, 0.18);
}
.topic-chiplet.plan {
  background: #ecfdf5;
  color: #047857;
  text-decoration: none;
}
.topic-chiplet.plan:hover {
  text-decoration: underline;
}
html[data-theme="dark"] .topic-chiplet.plan {
  background: rgba(16, 185, 129, 0.16);
  color: #6ee7b7;
}
.topic-record-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.topic-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
  gap: 14px;
  align-items: start;
}
.topic-layout:has(.has-draft-chat) {
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
}
@media (max-width: 960px) {
  .topic-layout,
  .topic-layout:has(.has-draft-chat) { grid-template-columns: 1fr; }
  .topic-side { display: none; }
  .topic-side.has-draft-chat {
    display: flex;
    position: static;
    max-height: none;
    overflow: visible;
  }
  .topic-side.has-draft-chat > .td-card { display: none; }
  .topic-props-mobile { display: block; margin-bottom: 12px; }
}
@media (min-width: 961px) {
  .topic-props-mobile { display: none; }
}
.topic-main { min-width: 0; }
.topic-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 12px;
}
.topic-side.has-draft-chat {
  max-height: calc(100vh - 24px);
  overflow: hidden;
}
.topic-side.has-draft-chat > .td-card {
  flex: 0 1 auto;
  min-height: 0;
  max-height: 30vh;
  overflow: auto;
}

.td-card {
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line);
}
.td-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--primary);
}
.td-card.tone-indigo { border-color: color-mix(in srgb, var(--primary) 28%, var(--line)); }
.td-card.tone-indigo::before { background: var(--primary); }
.td-card.tone-sky { border-color: color-mix(in srgb, var(--info) 30%, var(--line)); }
.td-card.tone-sky::before { background: var(--info); }
.td-card.tone-amber { border-color: color-mix(in srgb, var(--warning) 35%, var(--line)); }
.td-card.tone-amber::before { background: var(--warning); }
.td-card.tone-emerald { border-color: color-mix(in srgb, var(--success) 35%, var(--line)); }
.td-card.tone-emerald::before { background: var(--success); }

.td-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  padding: 10px 14px 10px 16px;
  border-bottom: 1px solid var(--line);
}
.td-card.tone-indigo .td-card-head { background: color-mix(in srgb, var(--primary-soft) 70%, transparent); border-bottom-color: color-mix(in srgb, var(--primary) 14%, var(--line)); }
.td-card.tone-sky .td-card-head { background: color-mix(in srgb, var(--info-soft) 75%, transparent); border-bottom-color: color-mix(in srgb, var(--info) 16%, var(--line)); }
.td-card.tone-amber .td-card-head { background: color-mix(in srgb, var(--warning-soft) 75%, transparent); border-bottom-color: color-mix(in srgb, var(--warning) 18%, var(--line)); }
.td-card.tone-emerald .td-card-head { background: color-mix(in srgb, var(--success-soft) 75%, transparent); border-bottom-color: color-mix(in srgb, var(--success) 18%, var(--line)); }

.td-card-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  background: var(--panel);
  color: var(--ink-2);
  box-shadow: inset 0 0 0 1px var(--line);
}
.td-card.tone-indigo .td-card-ico { color: var(--primary); background: var(--primary-soft); box-shadow: none; }
.td-card.tone-sky .td-card-ico { color: #0369a1; background: var(--info-soft); box-shadow: none; }
.td-card.tone-amber .td-card-ico { color: #b45309; background: var(--warning-soft); box-shadow: none; }
.td-card.tone-emerald .td-card-ico { color: #067a5a; background: var(--success-soft); box-shadow: none; }

.td-card-head h2 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.td-card-count {
  display: inline-flex;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  background: var(--panel);
  color: var(--ink-2);
  box-shadow: inset 0 0 0 1px var(--line);
}
.td-head-actions {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.td-card-body { padding: 12px 14px 14px 16px; }
.topic-summary-lead {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink-2);
}
.topic-draft-body { padding-top: 10px; }

.draft-chat-pane {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  background:
    radial-gradient(120% 80% at 100% 0%, color-mix(in srgb, var(--primary) 14%, transparent), transparent 55%),
    color-mix(in srgb, var(--bg) 55%, var(--panel));
}
@media (max-width: 960px) {
  .draft-chat-pane { min-height: 420px; height: 440px; flex: none; }
}
.draft-chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  backdrop-filter: blur(8px);
}
.draft-chat-orb {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  box-shadow: 0 8px 18px color-mix(in srgb, var(--primary) 35%, transparent);
}
.draft-chat-head h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 750;
  letter-spacing: -0.02em;
}
.draft-chat-head p {
  margin: 1px 0 0;
  font-size: 11px;
  color: var(--muted);
}
.draft-chat-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
}
.draft-chat-welcome {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
  min-height: 100%;
  padding: 8px 4px 4px;
}
.draft-chat-welcome h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.draft-chat-welcome p {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--muted);
}
.draft-chat-chips {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.draft-chat-chip {
  appearance: none;
  text-align: left;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 80%, transparent);
  border-radius: 14px;
  padding: 10px 12px;
  font: inherit;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.35;
  cursor: pointer;
}
.draft-chat-chip:hover {
  border-color: color-mix(in srgb, var(--primary) 45%, var(--line));
  background: var(--panel);
  color: var(--ink);
}
.draft-chat-thread {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 8px;
}
.dchat-msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 100%;
}
.dchat-msg.user {
  justify-content: flex-end;
}
.dchat-avatar {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.dchat-bubble {
  max-width: 88%;
}
.dchat-msg.user .dchat-bubble {
  background: var(--primary);
  color: #fff;
  border-radius: 18px 18px 6px 18px;
  padding: 9px 12px;
}
.dchat-msg.assistant .dchat-bubble {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px 18px 18px 6px;
  padding: 9px 12px;
}
.dchat-msg.thinking .dchat-text {
  opacity: 0.7;
  font-style: italic;
  animation: dchat-pulse 1.4s ease-in-out infinite;
}
@keyframes dchat-pulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 0.9; }
}
.dchat-text {
  font-size: 13.5px;
  line-height: 1.45;
  white-space: pre-wrap;
}
.draft-chat-dock {
  flex: 0 0 auto;
  padding: 8px 10px 10px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}
.draft-chat-dock .status-line {
  margin: 0 0 8px;
  font-size: 12px;
}
.draft-chat-box {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 4px 4px 4px 12px;
  background: var(--bg);
  box-shadow: none;
}
.draft-chat-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 16%, transparent);
}
.draft-chat-send {
  appearance: none;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  flex-shrink: 0;
}
.draft-chat-send:hover { filter: brightness(1.06); }
.draft-chat-send:disabled {
  opacity: 0.45;
  cursor: wait;
}
.draft-chat-hint {
  margin: 6px 4px 0;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}
.topic-studio-body { padding: 0; }
.topic-studio-body .topic-studio { margin: 0; }

/* Cover assistant header inside topic card */
.topic-covers-head.td-card-head {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: 12px 14px 12px 16px;
}
.topic-covers-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  min-width: 0;
}
.topic-covers-title > div {
  min-width: 0;
  flex: 1 1 auto;
}
.topic-covers-title h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 750;
}
.topic-covers-sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}
.topic-covers-card .studio-stage-pill {
  margin-left: 0;
  padding: 4px 10px;
  font-size: 11px;
  border-radius: 999px;
}
.topic-covers-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-top: 2px;
  border-top: 1px solid color-mix(in srgb, var(--warning) 16%, var(--line));
}
.topic-covers-actions .btn {
  padding: 7px 12px;
  font-size: 13px;
}
@media (min-width: 720px) {
  .topic-covers-head.td-card-head {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px 16px;
  }
  .topic-covers-actions {
    border-top: 0;
    padding-top: 0;
    flex-shrink: 0;
    margin-left: auto;
  }
}
.topic-covers-card .topic-studio .studio-chat-app {
  min-height: 480px;
}
.topic-covers-card .studio-chat-column {
  min-height: 440px;
}
@media (max-width: 1080px) {
  .topic-covers-card .studio-chat-column { min-height: 400px; }
}

/* Blog preview + section layout */
.blog-inject-toggle {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--info) 28%, var(--line));
  background: color-mix(in srgb, var(--info-soft) 55%, var(--panel));
  cursor: pointer;
}
.blog-inject-toggle input {
  margin-top: 3px;
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  flex-shrink: 0;
}
.blog-inject-toggle span {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13.5px;
  color: var(--ink);
}
.blog-inject-toggle em {
  font-style: normal;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}
.blog-layout-board {
  margin-bottom: 16px;
  padding: 12px;
  border: 1px dashed color-mix(in srgb, var(--info) 35%, var(--line));
  border-radius: 12px;
  background: color-mix(in srgb, var(--info-soft) 45%, var(--panel));
}
.blog-layout-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 12px;
  margin-bottom: 10px;
  font-size: 13px;
}
.blog-layout-toolbar strong { font-size: 13.5px; }
.blog-cover-tray {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  min-height: 52px;
}
.blog-cover-tray-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-right: 4px;
}
.blog-cover-tray-empty { font-size: 12.5px; }
.blog-cover-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 4px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  cursor: grab;
  box-shadow: var(--shadow-sm);
}
.blog-cover-chip.dragging { opacity: 0.55; }
.blog-cover-chip img {
  width: 44px;
  height: 28px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}
.blog-cover-chip em {
  font-style: normal;
  font-size: 11px;
  font-weight: 650;
  color: var(--ink-2);
}
.blog-section-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.blog-section-card {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 120px;
  gap: 10px;
  align-items: stretch;
  padding: 10px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  cursor: grab;
  box-shadow: var(--shadow-sm);
}
.blog-section-card.dragging { opacity: 0.5; }
.blog-section-card.drag-over {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft);
}
.blog-section-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 14px;
  letter-spacing: -2px;
  user-select: none;
}
.blog-section-title {
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--ink);
}
.blog-section-excerpt {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.blog-section-drop {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 64px;
  border-radius: 10px;
  border: 1px dashed var(--line-strong);
  background: color-mix(in srgb, var(--bg) 60%, var(--panel));
  overflow: hidden;
}
.blog-section-drop.drop-ready {
  border-color: var(--info);
  background: var(--info-soft);
}
.blog-section-drop img {
  width: 100%;
  height: 64px;
  object-fit: cover;
  display: block;
}
.blog-drop-hint {
  font-size: 11px;
  font-weight: 650;
  color: var(--muted);
  text-align: center;
  padding: 4px;
}
.blog-cover-clear {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.65);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}
.blog-preview-frame {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
html[data-theme="dark"] .blog-preview-frame {
  background: color-mix(in srgb, var(--panel) 92%, #000);
}
.blog-preview-empty { padding: 28px 18px; text-align: center; }
.blog-preview-article { padding: 0 0 28px; }
.blog-preview-head {
  padding: 22px 22px 8px;
  border-bottom: 1px solid var(--line);
}
.blog-preview-kicker {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.blog-preview-head h1 {
  margin: 0;
  font-size: clamp(1.35rem, 1.2rem + 0.6vw, 1.75rem);
  line-height: 1.25;
  letter-spacing: -0.03em;
}
.blog-preview-meta {
  margin: 10px 0 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}
.blog-preview-hero {
  margin: 0;
}
.blog-preview-hero img {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: cover;
}
.blog-preview-body {
  padding: 8px 22px 0;
  font-size: 15.5px;
  line-height: 1.7;
  color: var(--ink);
}
.blog-preview-body h2 {
  margin: 1.6em 0 0.55em;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  line-height: 1.3;
}
.blog-preview-body p { margin: 0.75em 0; }
.blog-preview-body ul, .blog-preview-body ol { margin: 0.75em 0; padding-left: 1.25em; }
.blog-preview-body a { color: var(--primary); }
.blog-preview-body .jashn-seo-cover {
  margin: 0.85em 0 1.25em;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--bg);
}
.blog-preview-body .jashn-seo-cover img {
  display: block;
  width: 100%;
  height: auto;
}
@media (max-width: 720px) {
  .blog-section-card {
    grid-template-columns: 24px minmax(0, 1fr);
  }
  .blog-section-drop {
    grid-column: 1 / -1;
    min-height: 72px;
  }
  .blog-section-drop img { height: 72px; }
}

.td-props {
  margin: 0;
  padding: 4px 14px 8px 16px;
}
.td-prop {
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  padding: 9px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 85%, transparent);
}
.td-prop:last-child { border-bottom: 0; }
.td-prop dt {
  margin: 0;
  padding-top: 2px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.td-prop dt.c-status { color: #0369a1; }
.td-prop dt.c-intent { color: #c2410c; }
.td-prop dt.c-score { color: var(--primary); }
.td-prop dt.c-seo { color: #067a5a; }
.td-prop dt.c-words { color: #0369a1; }
.td-prop dt.c-approver { color: #5b21b6; }
.td-prop dt.c-keyword { color: var(--primary); }
.td-prop dt.c-wp { color: #067a5a; }
html[data-theme="dark"] .td-prop dt.c-approver { color: #c4b5fd; }
html[data-theme="dark"] .td-prop dt.c-intent { color: #fdba74; }
.td-prop dd {
  margin: 0;
  font-size: 13.5px;
  color: var(--ink);
  min-width: 0;
  word-break: break-word;
}
.td-prop-link {
  font-weight: 650;
  color: var(--primary);
  text-decoration: none;
}
.td-prop-link:hover { text-decoration: underline; }

.topic-pipeline-list {
  list-style: none;
  margin: 0;
  padding: 8px 14px 12px 16px;
}
.topic-pipeline-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  font-size: 13px;
  color: var(--muted);
}
.topic-pipeline-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  background: transparent;
  flex-shrink: 0;
}
.topic-pipeline-item.done { color: #067a5a; }
.topic-pipeline-item.done .topic-pipeline-dot {
  background: var(--success);
  border-color: var(--success);
}
.topic-pipeline-item.current {
  color: var(--primary);
  font-weight: 650;
}
.topic-pipeline-item.current .topic-pipeline-dot {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.topic-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin: 0 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg) 70%, var(--panel));
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
}
.topic-tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13.5px;
  font-weight: 650;
  padding: 8px 14px;
  border-radius: 9px;
  white-space: nowrap;
}
.topic-tab.on {
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.topic-panel { display: none; }
.topic-panel.on { display: block; }

.topic-keyword-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.topic-kw {
  display: inline-flex;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
}

.topic-draft-bar {
  display: grid;
  grid-template-columns: minmax(140px, 0.7fr) minmax(0, 1.6fr) auto;
  gap: 12px 16px;
  padding: 0 0 12px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
@media (max-width: 900px) {
  .topic-draft-bar { grid-template-columns: 1fr; }
}
.topic-draft-bar-grow { min-width: 0; }
.topic-draft-view {
  max-height: min(70vh, 820px);
  border-radius: 12px;
  margin: 0;
}

.topic-draft-head-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

.draft-edit-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.draft-edit-meta {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(160px, 0.6fr);
  gap: 12px 14px;
}
.draft-edit-meta .draft-edit-span {
  grid-column: 1 / -1;
}
@media (max-width: 720px) {
  .draft-edit-meta { grid-template-columns: 1fr; }
}
.draft-edit-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px 16px;
}
.draft-editor-chrome {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0;
}
.draft-editor-tabs {
  display: flex;
  gap: 0;
  align-items: flex-end;
}
.draft-mode-tab {
  appearance: none;
  border: 1px solid transparent;
  border-bottom: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px 10px;
  border-radius: 10px 10px 0 0;
  cursor: pointer;
  margin-bottom: -1px;
}
.draft-mode-tab:hover {
  color: var(--ink);
}
.draft-mode-tab.on {
  color: var(--ink);
  background: var(--panel);
  border-color: var(--line);
  box-shadow: 0 1px 0 var(--panel);
}
.draft-visual-wrap {
  border: 1px solid var(--line);
  border-radius: 0 12px 12px 12px;
  overflow: hidden;
  background: var(--panel);
  min-height: 520px;
}
.draft-visual-wrap .tox-tinymce {
  border: 0 !important;
  border-radius: 0 !important;
}
.draft-visual-wrap .tox .tox-edit-area::before {
  display: none;
}
.draft-visual-wrap .tox-statusbar {
  border-top: 1px solid var(--line) !important;
}
.draft-editor {
  width: 100%;
  min-height: min(62vh, 720px);
  resize: vertical;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  padding: 14px;
  border-radius: 0 12px 12px 12px;
  border: 1px solid var(--line);
  background: #fbfcfe;
  color: var(--ink);
  white-space: pre-wrap;
  tab-size: 2;
}
html[data-theme="dark"] .draft-editor {
  background: rgba(0, 0, 0, 0.18);
  color: var(--ink);
}
.draft-editor:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 0 0 4px rgba(51, 102, 255, 0.14);
}
html[data-theme="dark"] .draft-editor:focus {
  background: var(--panel);
  color: var(--ink);
}
.draft-edit-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}

.draft-media-modal {
  position: fixed;
  inset: 0;
  z-index: 200000; /* above TinyMCE toolbar / aux (~1300) */
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.45);
}
.draft-media-modal[hidden] { display: none !important; }
/* Keep TinyMCE chrome under the media modal while it's open */
body.draft-media-open .tox-tinymce-aux,
body.draft-media-open .tox.tox-tinymce--toolbar-sticky-on .tox-editor-header,
body.draft-media-open .tox .tox-editor-header {
  z-index: 1 !important;
}
body.draft-media-open .tox-toolbar-dock-fadeout,
body.draft-media-open .tox-toolbar-overlord {
  visibility: hidden !important;
  pointer-events: none !important;
}
.draft-media-dialog {
  width: min(720px, 100%);
  max-height: min(84vh, 820px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.28);
  padding: 16px 18px 18px;
}
.draft-media-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.draft-media-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}
.draft-media-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}
.draft-media-tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.draft-media-tab.on {
  color: var(--primary);
  background: var(--primary-soft);
}
.draft-media-pane .field { margin-bottom: 12px; }
.draft-media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}
.draft-media-thumb {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 12px;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
}
.draft-media-thumb:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.draft-media-thumb img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  display: block;
  background: #0f172a12;
}
.draft-media-thumb span {
  display: block;
  padding: 6px 8px;
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.draft-media-hint { margin: 8px 0 0; font-size: 13px; }
body.draft-media-open { overflow: hidden; }

.topic-studio.studio-shell {
  margin-top: 0;
  border: 0;
  box-shadow: none;
  background: transparent;
}
.topic-studio .studio-chat-app {
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  min-height: 520px;
  background: var(--panel);
}

.studio-thumb-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.studio-thumb-grid-lg {
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.studio-thumb {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel);
}
.studio-thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: #0f172a;
}
.studio-thumb .image-zoom-trigger {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
  position: relative;
}
.studio-thumb .image-zoom-trigger::after {
  content: "Zoom";
  position: absolute;
  right: 5px;
  bottom: 5px;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.75);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  opacity: 0;
  transition: opacity .15s ease;
  pointer-events: none;
}
.studio-thumb .image-zoom-trigger:hover::after {
  opacity: 1;
}
.studio-thumb figcaption {
  padding: 5px 7px 4px;
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}
.studio-thumb-del {
  display: block;
  width: calc(100% - 14px);
  margin: 0 7px 7px;
  border: 1px solid var(--line);
  background: #fff;
  color: #b42318;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.studio-thumb-del:hover {
  background: #fef3f2;
  border-color: #fecdca;
}
.studio-thumb-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 10px;
}

.image-notes-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 6px;
}
.image-notes {
  display: block;
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  min-height: 64px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  line-height: 1.45;
}
.image-notes:focus {
  outline: 2px solid color-mix(in srgb, var(--primary) 55%, transparent);
  outline-offset: 1px;
  border-color: var(--primary);
}

.studio-shell {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.studio-shell-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--primary-soft), transparent);
}
.studio-shell-title {
  margin: 4px 0 0;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.studio-shell-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.studio-stage-pill {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--warning-soft);
  color: #9a6700;
  border: 1px solid rgba(245, 158, 11, 0.28);
  white-space: nowrap;
}
.studio-stage-pill.stage-preview {
  background: var(--info-soft);
  color: #0369a1;
  border-color: rgba(14, 165, 233, 0.28);
}
.studio-stage-pill.stage-final {
  background: var(--success-soft);
  color: #067a5a;
  border-color: rgba(0, 214, 143, 0.35);
}

.studio-chat-app {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.85fr);
  min-height: 560px;
}
@media (max-width: 1080px) {
  .studio-chat-app { grid-template-columns: 1fr; min-height: 0; }
}

.studio-chat-column {
  display: flex;
  flex-direction: column;
  min-height: 520px;
  border-right: 1px solid var(--line);
  background:
    radial-gradient(90% 60% at 50% 0%, rgba(51, 102, 255, 0.06), transparent 55%),
    var(--panel);
}
@media (max-width: 1080px) {
  .studio-chat-column { border-right: 0; border-bottom: 1px solid var(--line); min-height: 480px; }
}

.studio-msg-scroll {
  flex: 1;
  overflow: auto;
  min-height: 0;
}
.studio-msg-inner {
  max-width: 44rem;
  margin: 0 auto;
  padding: 20px 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.studio-welcome {
  max-width: 32rem;
  margin: auto;
  padding: 40px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.studio-welcome-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: #fff;
  font-size: 22px;
  box-shadow: var(--shadow-sm);
}
.studio-welcome h3 {
  margin: 8px 0 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.studio-welcome p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  max-width: 36ch;
}
.studio-suggestions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
  margin-top: 8px;
}
@media (max-width: 640px) {
  .studio-suggestions { grid-template-columns: 1fr; }
}
.studio-suggest {
  text-align: left;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 16px;
  padding: 12px 14px;
  font: inherit;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.35;
  box-shadow: var(--shadow-sm);
}
.studio-suggest:hover {
  border-color: var(--primary-muted);
  background: var(--primary-soft);
  color: var(--ink);
}

.studio-msg {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.studio-msg.user {
  justify-content: flex-end;
}
.studio-avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  margin-top: 2px;
}
.studio-msg-bubble {
  max-width: min(100%, 36rem);
}
.studio-msg.user .studio-msg-bubble {
  background: var(--primary);
  color: #fff;
  border-radius: 22px;
  padding: 10px 14px;
}
.studio-msg.assistant .studio-msg-bubble {
  padding: 2px 0;
  color: var(--ink);
}
.studio-msg.thinking .studio-msg-text {
  opacity: 0.7;
  font-style: italic;
}
.studio-msg-meta {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 4px;
  letter-spacing: 0.02em;
}
.studio-msg.user .studio-msg-meta {
  color: rgba(255, 255, 255, 0.78);
  text-align: right;
}
.studio-msg-text {
  font-size: 15px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.studio-composer-dock {
  border-top: 1px solid var(--line);
  padding: 12px 16px 14px;
  background: color-mix(in srgb, var(--bg) 55%, var(--panel));
}
.studio-targets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 6px;
  max-width: 44rem;
  margin-left: auto;
  margin-right: auto;
}
.studio-target {
  margin: 0;
  cursor: pointer;
  text-align: center;
  padding: 7px 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
}
.studio-target:hover {
  border-color: color-mix(in srgb, var(--primary) 40%, var(--line));
  color: var(--ink);
}
.studio-target.on {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}
.studio-target-hint {
  margin: 0 auto 10px;
  max-width: 44rem;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}
.studio-target-hint strong { color: var(--ink); font-weight: 700; }
.studio-thumb.is-dimmed {
  opacity: 0.28;
  filter: grayscale(0.35);
}
.studio-thumb.is-focused {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 10px;
}
.studio-composer-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
  max-width: 44rem;
  margin: 0 auto;
}
.studio-composer-row textarea {
  width: 100%;
  min-height: 48px;
  max-height: 140px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px 14px;
  font: inherit;
  font-size: 14.5px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.studio-composer-row textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--primary) 45%, transparent);
  border-color: var(--primary);
}
.studio-send {
  border-radius: 14px;
  min-width: 72px;
}
.studio-composer-hint {
  max-width: 44rem;
  margin: 8px auto 0;
  font-size: 12px;
  color: var(--muted);
}

.studio-covers-pane {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: color-mix(in srgb, var(--bg) 70%, var(--panel));
  min-height: 280px;
  max-height: calc(100vh - 220px);
  overflow: auto;
}
.studio-covers-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  position: sticky;
  top: 0;
  z-index: 1;
  padding-bottom: 4px;
  background: color-mix(in srgb, var(--bg) 85%, var(--panel));
}
.studio-covers-head h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.studio-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.studio-tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 9px;
}
.studio-tab.on {
  background: var(--primary-soft);
  color: var(--primary);
}
.studio-gal-panel { display: none; }
.studio-gal-panel.on { display: block; }
.studio-grid {
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)) !important;
  gap: 10px !important;
}
.studio-covers-pane .image-card {
  border-radius: 10px;
}
.studio-covers-pane .image-card img {
  aspect-ratio: 16 / 10;
}
.studio-covers-pane .image-zoom-trigger {
  position: relative;
}
.studio-covers-pane .image-zoom-trigger::after {
  content: "Zoom";
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  opacity: 0;
  transition: opacity .15s ease;
  pointer-events: none;
}
.studio-covers-pane .image-zoom-trigger:hover::after,
.studio-covers-pane .image-zoom-trigger:focus-visible::after {
  opacity: 1;
}
.studio-covers-pane .image-card figcaption {
  padding: 6px 8px 8px;
  gap: 2px;
}
.studio-covers-pane .image-card figcaption strong {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.studio-covers-pane .image-card figcaption .muted {
  font-size: 11px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.studio-empty {
  display: grid;
  place-content: center;
  text-align: center;
  gap: 6px;
  min-height: 140px;
  padding: 20px 14px;
  border-radius: 14px;
  border: 1px dashed var(--line-strong);
  color: var(--muted);
}
.studio-empty strong { color: var(--ink); }
.studio-empty p { margin: 0; font-size: 13px; }
.studio-linkish {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 0;
  align-self: start;
}
.studio-linkish:hover { color: var(--primary); }
.studio-panel { margin-top: 18px; }

.bulk-images-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--primary-soft) 45%, #fff);
}
.bulk-images-bar input[type="text"] {
  flex: 1 1 220px;
  min-width: 180px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  font: inherit;
  font-size: 13px;
  background: var(--panel);
  color: var(--ink);
}
.bulk-images-bar select {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 8px;
  font: inherit;
  font-size: 13px;
  background: var(--panel);
  color: var(--ink);
}
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
html[data-theme="dark"] .studio-stage-pill { color: #ffd58a; }
html[data-theme="dark"] .bulk-images-bar {
  background: rgba(89, 139, 255, 0.1);
}
.image-card {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--panel);
}
.image-card img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #0f172a;
  image-rendering: auto;
}
.image-zoom-trigger {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}
.image-zoom-trigger:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}
.image-card figcaption {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px 12px;
  font-size: 12.5px;
}

.img-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(8, 14, 28, 0.82);
  backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, visibility 0.18s ease;
}
.img-lightbox.is-open {
  opacity: 1;
  visibility: visible;
}
.img-lightbox-inner {
  position: relative;
  max-width: min(1400px, 96vw);
  max-height: 90vh;
}
.img-lightbox-inner img {
  display: block;
  max-width: 100%;
  max-height: 90vh;
  width: auto;
  height: auto;
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
  background: #0f172a;
  image-rendering: auto;
}
.img-lightbox-close {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: #0f172a;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}
.img-lightbox-close:hover { background: #f1f5f9; }
body.lightbox-open { overflow: hidden; }
.image-card .pill {
  align-self: flex-start;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 600;
}
.brand-logo-preview {
  margin-top: 16px;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: #fff;
  max-width: 320px;
}
.brand-logo-preview img {
  max-width: 100%;
  max-height: 72px;
  object-fit: contain;
}
.gen-results { margin-top: 10px; }
.gen-results .mini {
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  background: var(--panel); margin-bottom: 8px; font-size: 13px; box-shadow: var(--shadow-sm);
}
.stack-form {
  display: flex; flex-direction: column; align-items: stretch;
  gap: 18px; width: 100%; max-width: none;
}
.inline-form {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 18px 16px;
  align-items: end;
  width: 100%;
}
.inline-form .btn { justify-self: start; }
.inline-form label.check { align-self: center; padding-bottom: 2px; }
label, .field {
  display: flex; flex-direction: column; gap: 7px; min-width: 0;
  font-size: 13px; font-weight: 600; color: var(--ink-2);
}
/* Row-style labels must not inherit the column stack above */
label.check,
label.topic-card-check,
label.kw-row-toggle,
label.blog-inject-toggle,
label.discover-source-opt,
label.discover-persist {
  flex-direction: row;
}
label.check {
  position: relative;
  flex-direction: row; align-items: center; justify-content: flex-start;
  gap: 12px; width: fit-content; max-width: 100%;
  font-size: 13.5px; font-weight: 500; color: #334155; cursor: pointer;
  padding: 11px 14px; border-radius: 12px; border: 1px solid #e2e8f0;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
  user-select: none;
}
label.check:hover {
  border-color: #c7d2fe;
  background: #f8fafc;
  box-shadow: 0 2px 8px rgba(51, 102, 255, 0.08);
}
label.check:has(input:focus-visible) {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(51, 102, 255, 0.14);
}
label.check:has(input:checked) {
  border-color: #c7d2fe;
  background: linear-gradient(180deg, #eef2ff, #f8faff);
}
label.check input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: -1px;
  clip: rect(0,0,0,0);
  pointer-events: none;
}
.check-box {
  width: 20px; height: 20px; flex-shrink: 0;
  border-radius: 6px;
  border: 1.5px solid #cbd5e1;
  background: #fff;
  display: grid; place-items: center;
  transition: background .15s ease, border-color .15s ease, transform .12s ease, box-shadow .15s ease;
  box-shadow: inset 0 1px 1px rgba(15, 23, 42, 0.04);
}
.check-box svg {
  width: 12px; height: 12px;
  opacity: 0; transform: scale(0.6);
  transition: opacity .12s ease, transform .12s ease;
  color: #fff;
}
label.check input:checked + .check-box {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 2px 6px rgba(51, 102, 255, 0.35);
}
label.check input:checked + .check-box svg {
  opacity: 1; transform: scale(1);
}
label.check:active .check-box { transform: scale(0.94); }
.check-text { line-height: 1.35; }

/* Premium toggle variant */
label.check.toggle {
  padding: 10px 14px 10px 12px;
}
label.check.toggle .check-box { display: none; }
.check-switch {
  position: relative;
  width: 40px; height: 22px; flex-shrink: 0;
  border-radius: 999px;
  background: #e2e8f0;
  transition: background .18s ease;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.08);
}
.check-switch::after {
  content: "";
  position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 99px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.2);
  transition: transform .18s ease;
}
label.check.toggle input:checked ~ .check-switch {
  background: var(--primary);
}
label.check.toggle input:checked ~ .check-switch::after {
  transform: translateX(18px);
}
label.check.toggle:has(input:checked) {
  border-color: #c7d2fe;
  background: linear-gradient(180deg, #eef2ff, #f8faff);
}

input[type="checkbox"], input[type="radio"] {
  width: auto; min-width: 17px; height: 17px; margin: 0; padding: 0;
  border-radius: 5px; box-shadow: none; flex-shrink: 0; accent-color: var(--primary);
}
input, select:not(.c-select-native), textarea {
  font: inherit; color: var(--ink); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; background: #fbfcfe; width: 100%;
  font-size: 14px; font-weight: 500; letter-spacing: -0.011em;
  box-shadow: inset 0 1px 2px rgba(34, 43, 69, 0.03);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
html[data-theme="dark"] input,
html[data-theme="dark"] select:not(.c-select-native),
html[data-theme="dark"] textarea {
  background: rgba(0,0,0,.18);
}
input::placeholder, textarea::placeholder { color: #a3adc2; font-weight: 500; }
input:hover, select:not(.c-select-native):hover, textarea:hover {
  border-color: var(--line-strong);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); background: var(--panel);
  box-shadow: 0 0 0 4px rgba(51, 102, 255, 0.14);
}
.draft-chat-box textarea,
.draft-chat-box textarea:hover,
.draft-chat-box textarea:focus {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  min-height: 34px;
  max-height: 96px;
  margin: 0;
  resize: none;
  border: 0;
  outline: none;
  border-radius: 0;
  padding: 8px 0;
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: inherit;
  background: transparent;
  box-shadow: none;
  color: var(--ink);
}
input:disabled, select:disabled {
  opacity: 0.72; background: var(--bg); cursor: not-allowed;
}
.field-label {
  font-size: 13px; font-weight: 500; color: #334155;
  letter-spacing: 0;
}
.field-hint {
  font-size: 12.25px; color: var(--muted); line-height: 1.45; margin-top: 1px; font-weight: 500;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px 20px;
  width: 100%;
}
.discover-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 560px;
}
.discover-focus {
  margin: 0;
  max-width: 100%;
}
.discover-focus input[type="text"] {
  width: 100%;
  box-sizing: border-box;
}
.field-optional {
  font-style: normal;
  font-weight: 500;
  color: var(--muted, #6b7280);
  font-size: 0.85em;
}
.discover-limit {
  margin: 0;
  max-width: 220px;
}
.discover-limit input[type="number"] {
  width: 100%;
  box-sizing: border-box;
}
.discover-option {
  margin: 0;
}
.discover-source {
  border: 0;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.discover-source legend {
  padding: 0;
  margin: 0 0 2px;
}
.discover-source-opt {
  align-items: flex-start !important;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 10px;
  background: #fff;
}
.discover-source-opt .check-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.discover-source-opt .check-text strong {
  font-size: 13.5px;
  font-weight: 650;
  color: var(--ink);
}
.discover-source-opt .check-text em {
  font-style: normal;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.4;
}
.discover-persist {
  width: 100%;
  max-width: 100%;
  align-items: flex-start !important;
  gap: 12px;
  padding: 12px 14px !important;
}
.discover-persist .check-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.discover-persist .check-text strong {
  font-size: 13.5px;
  font-weight: 650;
  color: var(--ink);
}
.discover-persist .check-text em {
  font-style: normal;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.4;
}
.discover-form .form-actions {
  margin: 0;
  padding-top: 0;
}
#gen-status {
  margin-top: 14px;
}
#gen-results {
  margin-top: 10px;
}

.form-grid .topic-edit-basics,
.form-grid .kw-editor {
  grid-column: 1 / -1;
}
.field-span-2 { grid-column: 1 / -1; }
.pill.bucket-striking_distance { background: #fff7ed; color: #c2410c; box-shadow: inset 0 0 0 1px #fed7aa; }
.pill.bucket-zero_click { background: #fef2f2; color: #b91c1c; box-shadow: inset 0 0 0 1px #fecaca; }
.pill.bucket-rising_demand { background: #eff6ff; color: #1d4ed8; box-shadow: inset 0 0 0 1px #bfdbfe; }
.pill.bucket-low_ctr { background: #f5f3ff; color: #6d28d9; box-shadow: inset 0 0 0 1px #ddd6fe; }
.pill.bucket-low_volume { background: #f8fafc; color: #64748b; box-shadow: inset 0 0 0 1px #e2e8f0; }
.pill.bucket-monitor { background: #ecfdf5; color: #047857; box-shadow: inset 0 0 0 1px #a7f3d0; }

.perm-grid .check {
  width: 100%;
  max-width: none;
  align-items: flex-start;
}
.perm-grid .check-text { min-width: 0; }

.crm-panel {
  position: relative;
  background: var(--panel);
  border: 1px solid rgba(197, 206, 224, 0.85);
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
/* Topic list menus must escape the rounded clip and stack above the next panel */
.crm-panel:has(.topic-cards) {
  overflow: visible;
}
.crm-panel:has(.topic-cards) .crm-panel-body {
  overflow: visible;
  border-radius: 0 0 16px 16px;
}
.crm-panel:has(.topic-cards) .crm-panel-head {
  border-radius: 16px 16px 0 0;
  overflow: hidden;
}
.crm-panel:has(.topic-more[open]) {
  z-index: 40;
}
.crm-panel::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--primary);
}
.crm-panel.tone-sky { border-color: rgba(14, 165, 233, 0.25); }
.crm-panel.tone-sky::before { background: #0ea5e9; }
.crm-panel.tone-amber { border-color: rgba(245, 158, 11, 0.28); }
.crm-panel.tone-amber::before { background: #f59e0b; }
.crm-panel.tone-violet { border-color: rgba(139, 92, 246, 0.28); }
.crm-panel.tone-violet::before { background: #8b5cf6; }
.crm-panel.tone-indigo { border-color: rgba(51, 102, 255, 0.28); }
.crm-panel.tone-indigo::before { background: var(--primary); }
.crm-panel.tone-emerald { border-color: rgba(0, 214, 143, 0.28); }
.crm-panel.tone-emerald::before { background: var(--success); }

.crm-panel-head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.crm-panel-head > a {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 12.75px; font-weight: 700; color: var(--primary); text-decoration: none;
  align-self: center; letter-spacing: -0.01em;
}
.crm-panel.tone-sky .crm-panel-head { background: linear-gradient(180deg, rgba(14, 165, 233, 0.12), rgba(14, 165, 233, 0.05)); }
.crm-panel.tone-amber .crm-panel-head { background: linear-gradient(180deg, rgba(245, 158, 11, 0.14), rgba(245, 158, 11, 0.05)); }
.crm-panel.tone-violet .crm-panel-head { background: linear-gradient(180deg, rgba(139, 92, 246, 0.12), rgba(139, 92, 246, 0.04)); }
.crm-panel.tone-indigo .crm-panel-head { background: linear-gradient(180deg, #eef2ff, #f7f9ff); }
html[data-theme="dark"] .crm-panel.tone-sky .crm-panel-head { background: rgba(14, 165, 233, 0.12); }
html[data-theme="dark"] .crm-panel.tone-amber .crm-panel-head { background: rgba(245, 158, 11, 0.12); }
html[data-theme="dark"] .crm-panel.tone-violet .crm-panel-head { background: rgba(139, 92, 246, 0.14); }
html[data-theme="dark"] .crm-panel.tone-indigo .crm-panel-head { background: var(--primary-soft); }
html[data-theme="dark"] .crm-panel.tone-emerald .crm-panel-head { background: var(--success-soft); }
.crm-panel.tone-emerald .crm-panel-head { background: linear-gradient(180deg, rgba(0, 214, 143, 0.12), rgba(0, 214, 143, 0.04)); }

.crm-panel-head h2 {
  margin: 0; font-size: 15px; font-weight: 800; color: var(--ink);
  letter-spacing: -0.02em;
}
.crm-panel-head p {
  margin: 5px 0 0; font-size: 12.75px; color: var(--muted); line-height: 1.5;
  max-width: 62ch; font-weight: 500;
}
.crm-ico {
  width: 32px; height: 32px; border-radius: 10px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 14px; font-weight: 800;
  background: var(--panel); color: var(--ink-2); border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.crm-panel.tone-sky .crm-ico { background: rgba(14,165,233,.15); color: #0284c7; border-color: transparent; }
.crm-panel.tone-amber .crm-ico { background: rgba(245,158,11,.18); color: #b45309; border-color: transparent; }
.crm-panel.tone-violet .crm-ico { background: rgba(139,92,246,.16); color: #7c3aed; border-color: transparent; }
.crm-panel.tone-indigo .crm-ico { background: #fff; color: var(--primary); border-color: var(--primary-muted); }
.crm-panel-body { padding: 22px 22px 24px; }

.nested-box {
  border-radius: 12px; padding: 16px 18px; border: 1px solid var(--line);
}
.nested-box.tone-amber {
  border-color: rgba(245, 158, 11, 0.25);
  background: rgba(245, 158, 11, 0.08);
}

.settings-link {
  display: flex; flex-direction: column; gap: 4px;
  padding: 16px 18px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg);
  text-decoration: none; transition: border-color .15s ease, transform .15s ease;
}
.settings-link:hover { border-color: var(--primary-muted); transform: translateY(-1px); }
.settings-link strong { font-size: 14px; color: var(--ink); }
.settings-link span { font-size: 12.5px; color: var(--muted); }

@media (max-width: 960px) {
  .grid-2, .grid-home-secondary, .split { grid-template-columns: 1fr; }
  .split-left { border-right: 0; border-bottom: 1px solid var(--line); }
}
@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
  .field-span-2 { grid-column: auto; }
  .content { padding: 1rem 0.75rem 2.5rem; }
}
.back-link { margin: 0 0 12px; }
.back-link a { font-size: 13px; font-weight: 700; color: var(--muted); text-decoration: none; }
.back-link a:hover { color: var(--primary); }

.chart-card { padding: 16px 18px 8px; }
.chart-legend {
  display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 8px;
  font-size: 12px; font-weight: 600; color: var(--muted);
}
.dot { width: 8px; height: 8px; border-radius: 99px; display: inline-block; margin-right: 6px; }
.dot.blue { background: var(--primary); }
.dot.green { background: var(--success); }

/* Login */
.login-body {
  min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background:
    radial-gradient(700px 420px at 10% 0%, rgba(51,102,255,.12), transparent 60%),
    radial-gradient(600px 380px at 100% 10%, rgba(123,97,255,.10), transparent 55%),
    var(--bg);
}
.login-shell { width: min(420px, 100%); }
.login-hero { text-align: center; margin-bottom: 18px; }
.login-hero .logo {
  width: 52px; height: 52px; margin: 0 auto 14px; font-size: 15px; border-radius: 16px;
}
.login-hero h1 { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -0.03em; }
.login-hero p { margin: 8px 0 0; color: var(--muted); font-size: 14.5px; font-weight: 500; }
.login-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 20px;
  padding: 24px; box-shadow: var(--shadow);
}
.login-note { margin: 14px 0 0; text-align: center; font-size: 12px; color: var(--muted); }

html[data-theme="dark"] .pill.outreach { background: rgba(123, 97, 255, 0.2); color: #c4b5fd; }
html[data-theme="dark"] .login-body {
  background:
    radial-gradient(700px 420px at 10% 0%, rgba(89,139,255,.18), transparent 60%),
    radial-gradient(600px 380px at 100% 10%, rgba(123,97,255,.12), transparent 55%),
    var(--bg);
}

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .side { display: none; }
  html.sidebar-collapsed .app { grid-template-columns: 1fr; }
  .grid-2, .grid-home-secondary, .split { grid-template-columns: 1fr; }
  .split-left { border-right: 0; border-bottom: 1px solid var(--line); }
  .search { display: none; }
  #sidebar-toggle { display: none; }
}

/* Topics / workspace plan */
.title-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.plan-banner {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) auto auto;
  gap: 14px 20px;
  align-items: center;
  margin: 0 0 16px;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.plan-banner::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--primary);
}
.plan-banner.on-track::before { background: var(--success); }
.plan-banner.behind::before { background: var(--warning); }
.plan-banner-kicker {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 4px;
}
.plan-banner-main h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 750;
  letter-spacing: -0.02em;
}
.plan-banner-main p {
  margin: 6px 0 0;
  font-size: 13.5px;
  color: var(--ink-2);
  line-height: 1.45;
}
.plan-banner-stats {
  display: flex;
  gap: 16px;
}
.plan-banner-stats > div {
  text-align: center;
  min-width: 52px;
}
.plan-stat-n {
  display: block;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.plan-stat-l {
  font-size: 11px;
  font-weight: 650;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.plan-banner-link {
  font-size: 13px;
  font-weight: 650;
  color: var(--primary);
  text-decoration: none;
  white-space: nowrap;
}
.plan-banner-link:hover { text-decoration: underline; }
@media (max-width: 800px) {
  .plan-banner {
    grid-template-columns: 1fr;
  }
}

.topic-filter-tabs .tab em {
  display: inline-flex;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  background: var(--primary-soft);
  color: var(--primary);
}
.topic-filter-tabs .tab.on em {
  background: color-mix(in srgb, var(--primary) 18%, transparent);
}

.topic-edit-form {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 18px 16px 20px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel, #fff) 92%, var(--bg, #f4f6fb));
  box-shadow: none;
  position: relative;
}
.topic-edit-form::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 3px;
  background: var(--primary);
}
html[data-theme="dark"] .topic-edit-form {
  background: color-mix(in srgb, var(--panel, #1a1f2b) 88%, #000);
  box-shadow: none;
}
.topic-edit-form[hidden] { display: none !important; }
.topic-edit-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  margin: 0;
}
.topic-edit-head strong {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--ink);
}
.topic-edit-head span {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.topic-edit-form .field { margin: 0; min-width: 0; }
.topic-edit-span { width: 100%; }
.topic-edit-basics {
  display: grid;
  grid-template-columns: 1fr minmax(120px, 160px);
  gap: 12px;
}
.topic-edit-meta-row {
  display: grid;
  grid-template-columns: minmax(160px, 220px);
  gap: 12px;
}
.topic-edit-form input,
.topic-edit-form select {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.topic-edit-form .field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
  letter-spacing: 0.01em;
}
.topic-edit-form .field-hint,
.kw-editor-hint {
  margin: 6px 0 0;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--muted);
}
.topic-edit-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  padding-top: 4px;
  border-top: 1px solid var(--line);
  margin-top: 2px;
}
.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  box-shadow: none;
}
.btn.ghost:hover {
  color: var(--ink);
  background: color-mix(in srgb, var(--ink) 6%, transparent);
}
.topic-card-words,
.topic-card-kwcount { display: none; }

/* Related keywords — editable rows */
.kw-editor {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel, #fff);
}
html[data-theme="dark"] .kw-editor {
  background: color-mix(in srgb, var(--panel, #1a1f2b) 80%, #000);
}
.kw-editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.kw-editor-head .field-label {
  margin: 0;
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
}
.kw-editor-sub {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
  max-width: 42ch;
}
.kw-editor-sub code {
  font-size: 11px;
  padding: 1px 4px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--ink) 6%, transparent);
}
.kw-editor-head-actions {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}
.kw-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.kw-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg, #f4f6fb) 70%, var(--panel, #fff));
}
.kw-row input[type="text"],
.kw-row input[type="url"] {
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 8px 10px;
  font-size: 13px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel, #fff);
  color: var(--ink);
  box-sizing: border-box;
}
.kw-row input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--primary) 55%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent);
}
.kw-row-toggle {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 7px;
  margin: 0;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.kw-row-toggle input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
.kw-toggle-ui {
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 28%, #fff);
  border: 1px solid var(--line);
  position: relative;
  flex: 0 0 auto;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.kw-toggle-ui::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.2);
  transition: transform 0.15s ease;
}
.kw-row-toggle input:checked + .kw-toggle-ui {
  background: #059669;
  border-color: #047857;
}
.kw-row-toggle input:checked + .kw-toggle-ui::after {
  transform: translateX(14px);
}
.kw-row-toggle input:disabled + .kw-toggle-ui {
  opacity: 0.45;
  cursor: not-allowed;
}
.kw-row-toggle input:checked ~ .kw-row-toggle-text {
  color: #047857;
}
.kw-row-remove {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.kw-row-remove:hover {
  background: color-mix(in srgb, var(--danger, #e11d48) 10%, transparent);
  color: var(--danger, #e11d48);
}
.kw-empty-hint {
  margin: 0;
  padding: 14px;
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--bg, #f4f6fb) 50%, transparent);
}
.topic-kw-linked {
  background: rgba(16, 185, 129, 0.12) !important;
  color: #047857 !important;
}
@media (max-width: 720px) {
  .topic-edit-basics {
    grid-template-columns: 1fr;
  }
  .topic-edit-meta-row {
    grid-template-columns: 1fr;
  }
  .kw-editor-head {
    flex-direction: column;
  }
  .kw-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .kw-row-toggle {
    justify-content: flex-start;
  }
  .kw-row-remove {
    width: 100%;
  }
}
.topic-cards {
  display: flex;
  flex-direction: column;
}
.topic-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px 20px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  align-items: center;
  transition: background 0.12s ease;
  position: relative;
  z-index: 0;
}
.topic-card:hover {
  background: color-mix(in srgb, var(--primary) 3.5%, transparent);
}
.topic-card:has(.topic-more[open]) {
  z-index: 50;
}
.topic-card:last-child { border-bottom: 0; }
.topic-card-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.topic-card-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.topic-card-status {
  flex: 0 0 auto;
  padding: 2px 8px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
/* Keep copy glued to the last word of the title — never stretched to the row edge */
.topic-card-heading {
  min-width: 0;
  flex: 1 1 auto;
  max-width: 100%;
}
.topic-card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.35;
  min-width: 0;
}
.topic-card-title a {
  color: var(--ink);
  text-decoration: none;
  display: inline;
}
.topic-card-title a:hover { color: var(--primary); }
.topic-copy-title {
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 6px;
  background: color-mix(in srgb, var(--ink) 3%, transparent);
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  line-height: 1;
  cursor: pointer;
  opacity: 1;
  transition: color 0.12s ease, border-color 0.12s ease, background 0.12s ease, transform 0.12s ease;
}
/* Default: sit immediately after title text (detail, cards, discovery results) */
.topic-record-title > .topic-copy-title,
.topic-card-title > .topic-copy-title,
.gen-topic-row > .topic-copy-title,
.title-with-copy > .topic-copy-title {
  display: inline-flex;
  vertical-align: middle;
  margin: 0 0 0 6px;
}
.topic-copy-title .copy-ico {
  width: 12px;
  height: 12px;
  display: block;
  flex: 0 0 auto;
}
.topic-copy-title:hover {
  color: var(--primary, #2563eb);
  border-color: color-mix(in srgb, var(--primary, #2563eb) 40%, var(--line, #e5e7eb));
  background: color-mix(in srgb, var(--primary, #2563eb) 8%, transparent);
}
.topic-copy-title:active {
  transform: scale(0.94);
}
.topic-copy-title.is-copied {
  color: #15803d;
  border-color: color-mix(in srgb, #15803d 40%, var(--line, #e5e7eb));
  background: color-mix(in srgb, #15803d 10%, transparent);
}
.topic-copy-title.inline {
  width: 22px;
  height: 22px;
  vertical-align: middle;
  margin: 0 0 0 6px;
}
.gen-topic-row {
  line-height: 1.45;
}
.gen-topic-row > strong {
  display: inline;
  font-weight: 700;
}
.topic-copy-title.topic-more-copy {
  width: 100%;
  height: auto;
  min-height: 34px;
  justify-content: flex-start;
  gap: 8px;
  padding: 7px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-size: 13px;
  font-weight: 550;
  color: inherit;
}
.topic-copy-title.topic-more-copy .copy-ico {
  width: 15px;
  height: 15px;
}
.topic-copy-title.topic-more-copy:hover {
  background: color-mix(in srgb, var(--ink) 6%, transparent);
  color: var(--ink);
  border-color: transparent;
}
.topic-copy-title.topic-more-copy.is-copied {
  color: #15803d;
  background: color-mix(in srgb, #15803d 8%, transparent);
}
.topic-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  align-items: center;
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}
.topic-card-meta > span:not(:last-child)::after {
  content: "·";
  margin: 0 7px;
  color: color-mix(in srgb, var(--muted) 55%, transparent);
  font-weight: 600;
}
.topic-card-meta .mono {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.topic-card-meta .meta-warn {
  color: #b45309;
  font-weight: 650;
}
.topic-card-kw {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 52ch;
}
/* Topic card actions: fixed columns so every control aligns across rows
   [ Primary CTA ] [ Edit ] [ ⋯ ] [ checkbox ] */
.topic-card-actions {
  display: grid;
  grid-template-columns: 7.5rem 3.25rem 32px;
  column-gap: 6px;
  align-items: center;
  justify-items: stretch;
  flex: 0 0 auto;
}
.topic-card-actions.has-check {
  grid-template-columns: 7.5rem 3.25rem 32px 20px;
}
.tac-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  min-width: 0;
}
.tac-slot form {
  margin: 0;
  display: flex;
  width: 100%;
}
.tac-btn {
  width: 100%;
  justify-content: center;
  box-sizing: border-box;
  box-shadow: none !important;
  padding: 6px 8px !important;
  border-radius: 8px;
  font-size: 12.5px !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tac-primary .tac-btn.primary {
  box-shadow: 0 1px 2px rgba(51, 102, 255, 0.18) !important;
}
.tac-empty {
  display: block;
  width: 100%;
  height: 32px;
}
.tac-more .topic-more {
  margin: 0 auto;
}
.tac-check {
  justify-content: center;
}
.topic-more {
  position: relative;
  z-index: 1;
}
.topic-more[open] {
  z-index: 60;
}
.topic-more-btn {
  list-style: none;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  font-weight: 700;
  user-select: none;
}
.topic-more-btn::-webkit-details-marker { display: none; }
.topic-more-btn::marker { content: ""; }
.topic-more-btn:hover,
.topic-more[open] > .topic-more-btn {
  background: color-mix(in srgb, var(--ink) 6%, transparent);
  color: var(--ink);
  border-color: var(--line);
}
.topic-more-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 70;
  min-width: 168px;
  padding: 6px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel, #fff);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.topic-more.drop-up .topic-more-menu {
  top: auto;
  bottom: calc(100% + 4px);
}
html[data-theme="dark"] .topic-more-menu {
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}
.topic-more-menu a,
.topic-more-menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 8px 10px;
  border-radius: 7px;
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}
.topic-more-menu a:hover,
.topic-more-menu button:hover {
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}
.topic-more-menu button.is-copied {
  color: var(--ok, #15803d);
}
.topic-more-menu .danger-item {
  color: var(--danger, #e11d48);
}
.topic-more-menu .danger-item:hover {
  background: color-mix(in srgb, var(--danger, #e11d48) 10%, transparent);
}
.topic-more-menu form { margin: 0; }
.topic-card-check {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin: 0;
  padding: 0;
  gap: 0;
  font-weight: inherit;
  color: inherit;
  cursor: pointer;
  flex: 0 0 20px;
}
.topic-card-check.is-disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.topic-card-check input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}
.topic-card-check.is-disabled input {
  cursor: not-allowed;
}
.topic-card-check-spacer {
  display: none;
}
.bulk-images-bar .check.check-compact {
  padding: 6px 10px;
  min-height: 36px;
  box-sizing: border-box;
  align-items: center;
}
table.data td.actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.topic-empty {
  text-align: center;
  padding: 28px 16px;
}
.topic-empty strong { display: block; margin-bottom: 6px; font-size: 15px; }
.topic-empty p { margin: 0 0 14px; }
@media (max-width: 720px) {
  .topic-card {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 12px;
  }
  .topic-card-actions,
  .topic-card-actions.has-check {
    width: 100%;
    grid-template-columns: 1fr 1fr 32px 20px;
  }
  .topic-card-actions:not(.has-check) {
    grid-template-columns: 1fr 1fr 32px;
  }
  .topic-card-title-row {
    align-items: flex-start;
  }
  .topic-card-status {
    margin-top: 2px;
  }
}

/* Pagination */
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  padding: 14px 18px 16px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}
.pager-solo {
  display: block;
  margin: 0;
  padding: 12px 18px 16px;
  color: var(--muted);
  font-size: 13px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}
.pager-meta {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.pager-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.pager-page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  text-decoration: none;
  border: 1px solid transparent;
}
.pager-page:hover {
  background: var(--primary-soft);
  color: var(--primary);
}
.pager-page.on {
  background: var(--primary);
  color: #fff;
}
.pager-ellipsis {
  color: var(--muted);
  padding: 0 4px;
}
.btn.is-disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  pointer-events: none;
}
