/* ==============================================
   AI Content Dashboard — Refined UI
   ============================================== */

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

/* === Base === */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: #f4f5f7;
  color: #1d1d1f;
  line-height: 1.55;
  font-size: 14px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* === Header === */
header {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  padding: 0 24px;
  height: 50px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.logo {
  font-size: 15px;
  font-weight: 700;
  color: #1d1d1f;
  letter-spacing: -0.3px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* === Main Navigation Tabs === */
.main-nav {
  display: flex;
  gap: 2px;
  background: #f0f1f4;
  border-radius: 6px;
  padding: 2px;
  margin-left: 24px;
}

.main-nav-tab {
  background: transparent;
  color: #6b7280;
  padding: 5px 16px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 4px;
  border: none;
  margin: 0;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.main-nav-tab:hover {
  color: #1d1d1f;
  background: rgba(255, 255, 255, 0.5);
}

.main-nav-tab.active {
  background: #fff;
  color: #1d1d1f;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* === View Switching === */
.view-hidden {
  display: none !important;
}

.header-env {
  font-size: 10px;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.darkmode-toggle {
  width: 32px;
  height: 32px;
  padding: 0;
  margin: 0;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #f6f7f9;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.darkmode-toggle:hover {
  background: #e5e7eb;
}

.darkmode-toggle.active {
  background: #e5e7eb;
  border-color: #9ca3af;
}

.dm-icon {
  font-size: 16px;
  line-height: 1;
}

/* === App Layout === */
.app-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  min-height: calc(100vh - 50px);
}

/* === Sidebar === */
.sidebar {
  background: #fff;
  border-right: 1px solid #ebedf0;
  padding: 24px;
  overflow-y: auto;
}

.sidebar-section {
  margin-bottom: 20px;
}

.sidebar-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #9ca3af;
}

.sidebar .step {
  background: none;
  border: none;
  border-radius: 0;
  padding: 0;
  margin: 0;
}

/* === Field Groups === */
.field-group {
  margin-bottom: 24px;
}

.field-group-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #b0b5be;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid #f0f1f4;
}

/* === Form Elements === */
form {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.field {
  margin-bottom: 14px;
}

.field:last-child {
  margin-bottom: 0;
}

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

label .optional {
  font-weight: 400;
  color: #b0b5be;
  text-transform: none;
  letter-spacing: 0;
}

input, select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #dfe1e6;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  color: #1d1d1f;
  background: #f8f9fb;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #4a8ceb;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(74, 140, 235, 0.1);
}

textarea {
  resize: vertical;
}

.divider {
  border: none;
  border-top: 1px solid #eef0f3;
  margin: 4px 0 16px;
}

/* === Select Row & Icon Buttons === */
.select-row {
  display: flex;
  gap: 6px;
  align-items: stretch;
}

.select-row select {
  flex: 1;
}

.icon-btn {
  width: 32px;
  min-width: 32px;
  padding: 0;
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  font-style: italic;
  font-family: Georgia, serif;
  background: #f0f1f4;
  color: #6b7280;
  border: 1px solid #dfe1e6;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.icon-btn:hover {
  background: #e5e7eb;
  color: #1d1d1f;
}

/* === Info Panels (Rules / Author) === */
.rules-panel {
  background: #f8f9fb;
  border: 1px solid #eef0f3;
  border-radius: 6px;
  padding: 10px 12px;
  margin-top: 6px;
  max-height: 240px;
  overflow-y: auto;
}

.rules-panel ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rules-panel li {
  font-size: 11px;
  color: #6b7280;
  line-height: 1.5;
  padding-left: 12px;
  position: relative;
}

.rules-panel li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  width: 4px;
  height: 4px;
  background: #b0b5be;
  border-radius: 50%;
}

.rules-panel p {
  font-size: 11px;
  color: #6b7280;
  line-height: 1.6;
  white-space: pre-line;
}

/* === Buttons === */
button {
  font-family: inherit;
  cursor: pointer;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  background: #1d1d1f;
  color: #fff;
  transition: background 0.15s, box-shadow 0.15s;
  margin: 0;
}

.btn-primary:hover {
  background: #333;
}

.btn-primary:disabled {
  background: #c4c7cc;
  cursor: not-allowed;
}

.btn-generate-main {
  width: 100%;
  padding: 11px 20px;
  font-size: 13.5px;
  margin-top: 8px;
  border-radius: 8px;
}

.btn-generate-main:hover:not(:disabled) {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 14px;
  background: #ef4444;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-danger:hover { background: #dc2626; }
body.dark .btn-danger { background: #dc2626; }
body.dark .btn-danger:hover { background: #b91c1c; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 14px;
  background: transparent;
  color: #1a1c23;
  border: 1px solid #c4c7cc;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-secondary:hover {
  background: #f0f1f3;
  border-color: #999;
}

.btn-secondary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* === Editorial Context Templates === */
.context-label-row {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
}

.btn-template-trigger {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid #dfe1e6;
  background: #f0f1f4;
  color: #6b7280;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}

.btn-template-trigger:hover {
  background: #e5e7eb;
  color: #1d1d1f;
}

.template-dropdown {
  background: #fff;
  border: 1px solid #dfe1e6;
  border-radius: 6px;
  margin-bottom: 6px;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.template-list {
  display: flex;
  flex-direction: column;
}

.template-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  font-size: 12px;
  color: #1d1d1f;
  cursor: pointer;
  border-bottom: 1px solid #f0f1f4;
  transition: background 0.1s;
}

.template-item:hover {
  background: #f4f5f7;
}

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

.template-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-item-delete {
  background: none;
  border: none;
  color: #b0b5be;
  font-size: 13px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.15s;
}

.template-item-delete:hover {
  color: #dc2626;
}

.template-dropdown-footer {
  padding: 6px 10px;
  border-top: 1px solid #f0f1f4;
}

.template-add-btn {
  background: none;
  border: none;
  color: #4a8ceb;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  padding: 2px 0;
  transition: color 0.15s;
}

.template-add-btn:hover {
  color: #2563eb;
}

.template-empty {
  padding: 12px 10px;
  font-size: 11px;
  color: #9ca3af;
  text-align: center;
}

body.dark .btn-template-trigger {
  background: #262a36;
  border-color: #353944;
  color: #858a9a;
}

body.dark .btn-template-trigger:hover {
  background: #353944;
  color: #e2e4e9;
}

body.dark .template-dropdown {
  background: #1f2230;
  border-color: #353944;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

body.dark .template-item {
  color: #e2e4e9;
  border-bottom-color: #262a36;
}

body.dark .template-item:hover {
  background: #262a36;
}

body.dark .template-dropdown-footer {
  border-top-color: #262a36;
}

body.dark .template-empty {
  color: #5c6070;
}

/* === Dev Paste Shortcut === */
.dev-paste {
  margin-top: 16px;
  text-align: center;
}

.dev-paste-toggle {
  background: none;
  border: none;
  font-size: 12px;
  color: #9ca3af;
  cursor: pointer;
  padding: 4px 0;
  transition: color 0.15s;
}

.dev-paste-toggle:hover {
  color: #6b7280;
}

#paste-panel {
  margin-top: 10px;
}

#paste-panel textarea {
  margin-bottom: 8px;
}

body.dark .dev-paste-toggle {
  color: #5c6070;
}

body.dark .dev-paste-toggle:hover {
  color: #858a9a;
}

/* === Workspace === */
.workspace {
  padding: 28px 36px;
  overflow-y: auto;
}

/* === Pipeline === */
.pipeline {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 28px;
  padding: 14px 20px;
  background: #fff;
  border: 1px solid #ebedf0;
  border-radius: 10px;
}

.pipeline-step {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border-radius: 6px;
  opacity: 0.35;
  transition: opacity 0.25s, background 0.25s;
}

.pipeline-step.active {
  opacity: 1;
  background: rgba(0, 0, 0, 0.04);
}

.pipeline-step.done {
  opacity: 1;
}

.pip-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #e5e7eb;
  color: #6b7280;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.25s, color 0.25s, box-shadow 0.25s;
}

.pipeline-step.active .pip-num {
  background: #1d1d1f;
  color: #fff;
}

.pipeline-step.done .pip-num {
  background: #16a34a;
  color: #fff;
}

.pip-label {
  font-size: 12px;
  font-weight: 500;
  color: #6b7280;
  white-space: nowrap;
  transition: color 0.25s;
}

.pipeline-step.active .pip-label {
  color: #1d1d1f;
  font-weight: 600;
}

.pipeline-step.done .pip-label {
  color: #16a34a;
}

.pipeline-step.clickable {
  cursor: pointer;
}

.pipeline-step.clickable:hover {
  background: rgba(22, 163, 74, 0.06);
}

.pipeline-step.clickable:hover .pip-num {
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
}

.pipeline-step.clickable:hover .pip-label {
  color: #15803d;
}

.pipeline-connector {
  flex: 1;
  height: 2px;
  background: #e5e7eb;
  margin: 0 4px;
  min-width: 12px;
  border-radius: 1px;
  transition: background 0.3s;
}

/* Color connectors after completed steps */
.pipeline-step.done + .pipeline-connector {
  background: #16a34a;
}

/* === Step Sections === */
.workspace .step {
  background: #fff;
  border: 1px solid #ebedf0;
  border-radius: 10px;
  padding: 24px 28px;
  margin-bottom: 16px;
}

.workspace .step:not(.locked) {
  animation: stepReveal 0.35s ease-out;
}

@keyframes stepReveal {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.workspace .step.locked {
  opacity: 0;
  pointer-events: none;
  max-height: 0;
  padding: 0;
  margin: 0;
  border: none;
  overflow: hidden;
}

/* === Section Headers & Actions === */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f0f1f4;
}

.section-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: #1d1d1f;
}

.section-actions {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #f0f1f4;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* === Tooltip === */
.image-info-trigger {
  position: relative;
}

.image-info-trigger:hover::after {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #1d1d1f;
  color: #fff;
  font-size: 11px;
  font-style: normal;
  font-weight: 400;
  white-space: pre-line;
  padding: 10px 14px;
  border-radius: 6px;
  line-height: 1.6;
  width: max-content;
  max-width: 280px;
  z-index: 50;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* === Tabs === */
.tabs {
  display: flex;
  gap: 2px;
  background: #f0f1f4;
  border-radius: 6px;
  padding: 2px;
}

.tab {
  background: transparent;
  color: #6b7280;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 4px;
  border: none;
  margin: 0;
  transition: background 0.15s, color 0.15s;
}

.tab:hover {
  color: #1d1d1f;
  background: rgba(255, 255, 255, 0.5);
}

.tab.active {
  background: #fff;
  color: #1d1d1f;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.tab-content {
  display: none;
}

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

/* === Draft Display === */
#draft-rendered {
  border: 1px solid #eef0f3;
  border-radius: 8px;
  padding: 22px;
  overflow-y: auto;
  background: #fafbfc;
  max-width: calc(100% - 320px);
}

#draft-rendered h1 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 12px;
  color: #1d1d1f;
}

#draft-rendered h2 {
  font-size: 16px;
  font-weight: 600;
  margin: 20px 0 8px;
  color: #333;
}

#draft-rendered p {
  margin-bottom: 10px;
  font-size: 14px;
  color: #374151;
  line-height: 1.65;
}

#draft-raw {
  background: #1a1c23;
  color: #a5d6a7;
  padding: 18px;
  border-radius: 8px;
  font-size: 12px;
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  max-height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  max-width: calc(100% - 320px);
}

/* === Checklist === */
#checklist {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#checklist li {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
}

#checklist li .icon {
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#checklist li.pass {
  background: #f0fdf4;
  border: 1px solid #dcfce7;
  color: #166534;
}

#checklist li.pass .icon {
  background: #16a34a;
  color: #fff;
  font-size: 11px;
}

#checklist li.fail {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

#checklist li.fail .icon {
  background: #dc2626;
  color: #fff;
  font-size: 11px;
}

.detail {
  font-size: 11px;
  color: #9ca3af;
  margin-left: auto;
}

#checklist li.check-category {
  background: none;
  border: none;
  padding: 12px 0 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #8b8f96;
}

#checklist li.check-category:first-child {
  padding-top: 0;
}

#checklist li.diagnostic {
  background: #fef3c7;
  border: 1px solid #fde68a;
  color: #92400e;
  margin-top: 8px;
  padding: 12px 14px;
  font-size: 13px;
}

#checklist li.diagnostic.pass {
  background: #f0fdf4;
  border-color: #dcfce7;
  color: #166534;
}

/* === Checklist Section Headers === */
#checklist li.check-section-header {
  background: none;
  border: none;
  padding: 16px 0 6px;
  font-size: 12px;
  font-weight: 700;
  justify-content: space-between;
  color: #1d1d1f;
  letter-spacing: 0.2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

#checklist li.check-section-header:first-child {
  padding-top: 0;
}

.section-icon {
  font-size: 14px;
  opacity: 0.6;
}

.section-header-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

#checklist li.check-section-header .btn-secondary.btn-sm {
  font-size: 10px;
  padding: 2px 8px;
  flex-shrink: 0;
}

/* === Eye Button & Highlights === */
.btn-eye {
  margin-left: 8px;
  padding: 0;
  width: 26px;
  height: 26px;
  font-size: 14px;
  line-height: 1;
  border: 1px solid #dfe1e6;
  border-radius: 4px;
  background: #f0f1f4;
  color: #6b7280;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-eye:hover {
  background: #e5e7eb;
  color: #1d1d1f;
}

.btn-eye.disabled {
  opacity: 0.3;
  cursor: default;
}

.btn-eye.active {
  background: #fef08a;
  border-color: #eab308;
  color: #854d0e;
}

mark.long-sentence {
  background: #fef08a;
  color: #854d0e;
  padding: 1px 2px;
  border-radius: 2px;
}

mark.colon-sentence {
  background: #dbeafe;
  color: #1e40af;
  padding: 1px 2px;
  border-radius: 2px;
}

/* === Split Layout (Verify / Detect editors) === */
.step-split-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.split-editor {
  flex: 1;
  min-width: 0;
}

.split-editor-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.split-editor-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #9ca3af;
}

.edit-badge {
  font-size: 10px;
  font-weight: 600;
  color: #92400e;
  background: #fef3c7;
  padding: 2px 8px;
  border-radius: 4px;
}

.split-editor-content {
  border: 1px solid #eef0f3;
  border-radius: 8px;
  padding: 22px;
  background: #fafbfc;
  outline: none;
  min-height: 200px;
  line-height: 1.65;
  font-size: 14px;
  color: #374151;
  cursor: text;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-user-select: text;
  user-select: text;
  pointer-events: auto;
}

.split-editor-content:focus {
  border-color: #4a8ceb;
  box-shadow: 0 0 0 3px rgba(74, 140, 235, 0.1);
}

.split-editor-content h1 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 12px;
  color: #1d1d1f;
}

.split-editor-content h2 {
  font-size: 16px;
  font-weight: 600;
  margin: 20px 0 8px;
  color: #333;
}

.split-editor-content p {
  margin-bottom: 10px;
}

.split-panel {
  width: 300px;
  flex-shrink: 0;
  position: sticky;
  top: 80px;
  align-self: flex-start;
  max-height: calc(100vh - 160px);
  overflow-y: auto;
  background: #f8f9fb;
  border: 1px solid #eef0f3;
  border-radius: 8px;
  padding: 16px;
}

.split-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #eef0f3;
}

.split-panel-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b7280;
}

.stale-notice {
  background: #fef3c7;
  border: 1px solid #fde68a;
  color: #92400e;
  font-size: 12px;
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 12px;
}

/* Panel overrides for checklist and detect elements */
.split-panel #checklist {
  gap: 3px;
}

.split-panel #checklist li {
  padding: 8px 10px;
  font-size: 12px;
}

.split-panel .detect-metrics {
  flex-direction: column;
  gap: 8px;
}

.split-panel .detect-metric {
  padding: 10px 12px;
}

.split-panel .detect-metric-value {
  font-size: 18px;
}

.split-panel .detect-sent-row {
  font-size: 12px;
  padding: 6px 8px;
}

/* === Image Previews === */
#image-preview, .image-preview-area {
  border: 1px solid #eef0f3;
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fafbfc;
}

#image-preview img, .image-preview-area img {
  max-width: 100%;
  border-radius: 6px;
}

/* === Image Step Sub-sections === */
.image-section {
  margin-bottom: 20px;
}

.image-section-header {
  margin-bottom: 12px;
}

.image-section-header h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  color: #1e293b;
}

.image-branding-actions {
  margin-bottom: 12px;
}

.image-download-row {
  margin-top: 12px;
  text-align: center;
}

.image-download-row a {
  display: inline-block;
  text-decoration: none;
}

/* === Publish Result === */
#publish-result {
  background: #f0fdf4;
  border: 1px solid #dcfce7;
  border-radius: 8px;
  padding: 22px;
  font-size: 13px;
  color: #166534;
  line-height: 1.7;
}

#publish-result:empty {
  display: none;
}

#publish-result a {
  color: #16a34a;
  font-weight: 600;
  text-decoration: none;
}

#publish-result a:hover {
  text-decoration: underline;
}

/* === Empty State === */
.workspace-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 100px 40px 80px;
  text-align: center;
}

.workspace-empty-icon {
  font-size: 36px;
  opacity: 0.18;
  margin-bottom: 16px;
}

.workspace-empty-title {
  font-size: 16px;
  font-weight: 600;
  color: #9ca3af;
  margin-bottom: 8px;
}

.workspace-empty-desc {
  font-size: 13px;
  color: #b0b5be;
  max-width: 320px;
  line-height: 1.6;
}

/* Hide empty state when any step is visible */
.workspace:has(.step:not(.locked)) .workspace-empty {
  display: none;
}

/* === Loading / Spinner === */
.spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.5s linear infinite;
  vertical-align: middle;
  margin-right: 4px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==============================================
   RESEARCH TAB
   ============================================== */

/* --- Research Layout --- */
.research-layout {
  display: grid;
  grid-template-columns: 300px 1fr 260px;
  min-height: calc(100vh - 50px);
}

.research-filters {
  background: #fff;
  border-right: 1px solid #ebedf0;
  padding: 24px;
  overflow-y: auto;
}

.research-filter-count {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #f0f1f4;
  font-size: 12px;
  color: #9ca3af;
}

/* --- Content Stream --- */
.research-stream {
  padding: 28px 36px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.research-stream-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.research-stream-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: #1d1d1f;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}

/* --- Research Cards --- */
.research-cards {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.research-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid #ebedf0;
  border-radius: 8px;
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer;
}

.research-card:hover {
  border-color: #d1d5db;
}

.research-card.selected {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.research-card-check {
  margin-top: 2px;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  accent-color: #4a8ceb;
  cursor: pointer;
}

.research-card-body {
  flex: 1;
  min-width: 0;
}

.research-card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.research-card-source {
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
}

.research-card-type {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.type-news {
  background: #dbeafe;
  color: #1d4ed8;
}

.type-social {
  background: #fef3c7;
  color: #92400e;
}

/* --- Card Action Buttons --- */
.research-card-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.research-btn-read,
.research-btn-open {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid #dfe1e6;
  border-radius: 4px;
  background: #f0f1f4;
  color: #6b7280;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.research-btn-read:hover,
.research-btn-open:hover {
  background: #e5e7eb;
  color: #1d1d1f;
}

.expanded .research-btn-read {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #1d4ed8;
}

/* --- Card Full Content (expanded) --- */
.research-card-full {
  font-size: 13px;
  color: #374151;
  line-height: 1.7;
  margin-bottom: 4px;
  padding: 14px 18px;
  background: #f8f9fb;
  border: 1px solid #eef0f3;
  border-radius: 6px;
  max-height: 500px;
  overflow-y: auto;
}

.research-card-full h1,
.research-card-full h2,
.research-card-full h3 {
  font-size: 15px;
  font-weight: 600;
  color: #1d1d1f;
  margin: 16px 0 8px;
}

.research-card-full h1:first-child,
.research-card-full h2:first-child,
.research-card-full h3:first-child {
  margin-top: 0;
}

.research-card-full p {
  margin-bottom: 10px;
}

.research-card-full img {
  max-width: 100%;
  border-radius: 4px;
  margin: 8px 0;
}

.research-card-full a {
  color: #4a8ceb;
  text-decoration: none;
}

.research-card-full a:hover {
  text-decoration: underline;
}

.research-card-full figure {
  margin: 12px 0;
}

.research-card-full figcaption {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 4px;
}

.research-card-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #9ca3af;
  font-size: 12px;
}

.spinner-dark {
  border-color: rgba(0, 0, 0, 0.1);
  border-top-color: #6b7280;
}

.research-card-error {
  color: #991b1b;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.research-card-rss-notice {
  background: #fef3c7;
  color: #92400e;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  margin-bottom: 8px;
}

.research-btn-retry {
  background: none;
  border: 1px solid #fecaca;
  border-radius: 4px;
  color: #991b1b;
  font-size: 11px;
  padding: 2px 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.research-btn-retry:hover {
  background: #fef2f2;
}

.research-card-title {
  font-size: 13px;
  font-weight: 500;
  color: #1d1d1f;
  line-height: 1.4;
  margin-bottom: 4px;
}

.research-card-excerpt {
  font-size: 12px;
  color: #6b7280;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.research-card-date {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 6px;
}

/* --- Empty / No Results --- */
.research-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 40px;
  text-align: center;
}

.research-empty-icon {
  font-size: 30px;
  opacity: 0.18;
  margin-bottom: 12px;
}

.research-empty-text {
  font-size: 13px;
  color: #9ca3af;
}

/* --- Selected Items Panel (sticky right) --- */
.research-selection-panel {
  background: #fff;
  border-left: 1px solid #ebedf0;
  padding: 24px 20px;
  position: sticky;
  top: 50px;
  align-self: start;
  height: calc(100vh - 50px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.research-selection-count {
  font-size: 20px;
  font-weight: 700;
  color: #1d1d1f;
  margin: 12px 0 16px;
  line-height: 1;
}

.research-selected-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
}

.research-selection-empty {
  font-size: 12px;
  color: #9ca3af;
  text-align: center;
  padding: 24px 8px;
  line-height: 1.5;
}

.research-selected-chips {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.research-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  font-size: 11px;
  color: #374151;
  line-height: 1.3;
}

.research-chip-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.research-chip-remove {
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  margin: 0;
  flex-shrink: 0;
  transition: color 0.15s;
}

.research-chip-remove:hover {
  color: #dc2626;
}

.btn-send-production {
  width: 100%;
  margin-top: 16px;
  flex-shrink: 0;
}

/* ==============================================
   REVIEW TAB
   ============================================== */

.review-layout-with-tasks {
  display: grid;
  grid-template-columns: 220px 1fr 1fr;
  min-height: calc(100vh - 50px);
}

/* Task sidebar */
.review-task-sidebar {
  background: #fff;
  border-right: 1px solid #ebedf0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.review-task-sidebar-header {
  padding: 20px 16px 12px;
  border-bottom: 1px solid #ebedf0;
}

.review-task-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.review-task-empty {
  padding: 24px 12px;
  text-align: center;
  font-size: 12px;
  color: #9ca3af;
  line-height: 1.5;
}

.review-task-item {
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  margin-bottom: 4px;
  transition: background 0.15s;
  border: 1px solid transparent;
}

.review-task-item:hover {
  background: #f3f4f6;
}

.review-task-item.active {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.review-task-item-title {
  font-size: 12px;
  font-weight: 600;
  color: #1d1d1f;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.review-task-item-meta {
  font-size: 10px;
  color: #9ca3af;
  display: flex;
  align-items: center;
  gap: 6px;
}

.review-task-status {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.review-task-status.pending { background: #d1d5db; }
.review-task-status.extracting { background: #f59e0b; }
.review-task-status.extracted { background: #16a34a; }
.review-task-status.edited { background: #3b82f6; }
.review-task-status.sent_to_production { background: #8b5cf6; }

.review-article-panel {
  background: #fff;
  border-right: 1px solid #ebedf0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.review-extraction-panel {
  background: #f8f9fb;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.review-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid #ebedf0;
}

.review-panel-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: #1d1d1f;
}

.review-article-tabs {
  display: flex;
  gap: 2px;
  background: #f0f1f4;
  border-radius: 6px;
  padding: 2px;
}

.review-article-tabs:empty {
  display: none;
}

.review-article-tab {
  background: transparent;
  color: #6b7280;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.review-article-tab:hover {
  color: #1d1d1f;
  background: rgba(255, 255, 255, 0.5);
}

.review-article-tab.active {
  background: #fff;
  color: #1d1d1f;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.review-article-url {
  padding: 8px 24px;
  font-size: 11px;
  color: #9ca3af;
  border-bottom: 1px solid #f0f1f4;
  word-break: break-all;
}

.review-article-url:empty {
  display: none;
}

.review-article-url a {
  color: #4a8ceb;
  text-decoration: none;
}

.review-article-url a:hover {
  text-decoration: underline;
}

.review-article-content {
  flex: 1;
  padding: 24px;
  font-size: 13px;
  color: #374151;
  line-height: 1.7;
  overflow-y: auto;
}

.review-article-content h1,
.review-article-content h2,
.review-article-content h3 {
  font-size: 15px;
  font-weight: 600;
  color: #1d1d1f;
  margin: 16px 0 8px;
}

.review-article-content h1:first-child,
.review-article-content h2:first-child,
.review-article-content h3:first-child {
  margin-top: 0;
}

.review-article-content p {
  margin-bottom: 10px;
}

.review-article-content img {
  max-width: 100%;
  border-radius: 4px;
  margin: 8px 0;
}

.review-article-content a {
  color: #4a8ceb;
  text-decoration: none;
}

.review-article-content a:hover {
  text-decoration: underline;
}

.review-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 40px;
  text-align: center;
  color: #9ca3af;
}

.review-empty-icon {
  font-size: 30px;
  opacity: 0.18;
  margin-bottom: 12px;
}

.review-empty-state p {
  font-size: 13px;
  line-height: 1.6;
  max-width: 280px;
}

.btn-extract {
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  background: #0071e3;
  color: #fff;
  transition: background 0.2s, opacity 0.2s;
}

.btn-extract:hover {
  background: #0060c0;
}

.btn-extract.extracting {
  background: #6b7280;
  cursor: not-allowed;
  opacity: 0.85;
}

.btn-extract.extracted {
  background: #16a34a;
  cursor: pointer;
}

.btn-extract.extracted:hover {
  background: #15803d;
}

.review-section {
  padding: 0 24px;
  margin-bottom: 16px;
}

.review-section:first-child {
  padding-top: 20px;
}

.review-section-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #9ca3af;
  margin-bottom: 6px;
}

.review-textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #dfe1e6;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  color: #1d1d1f;
  background: #fff;
  resize: vertical;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.review-textarea:focus {
  outline: none;
  border-color: #4a8ceb;
  box-shadow: 0 0 0 3px rgba(74, 140, 235, 0.1);
}

/* Structure block (H1/H2) */
.review-structure-block {
  border-top: 1px solid #ebedf0;
  padding-top: 4px;
  margin-top: 8px;
}

.review-structure-header {
  padding: 12px 24px 0;
}

.review-field-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  margin-bottom: 6px;
}

.review-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #dfe1e6;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  color: #1d1d1f;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.review-input:focus {
  outline: none;
  border-color: #4a8ceb;
  box-shadow: 0 0 0 3px rgba(74, 140, 235, 0.1);
}

.review-h2-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.review-h2-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.review-h2-row input {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid #dfe1e6;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  color: #1d1d1f;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.review-h2-row input:focus {
  outline: none;
  border-color: #4a8ceb;
  box-shadow: 0 0 0 3px rgba(74, 140, 235, 0.1);
}

.btn-remove-h2 {
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
}

.btn-remove-h2:hover {
  color: #dc2626;
  background: #fef2f2;
}

.btn-add-h2 {
  background: none;
  border: 1px dashed #d1d5db;
  border-radius: 6px;
  color: #6b7280;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  cursor: pointer;
  margin-top: 6px;
  transition: border-color 0.15s, color 0.15s;
}

.btn-add-h2:hover {
  border-color: #4a8ceb;
  color: #4a8ceb;
}

.review-actions {
  padding: 16px 24px;
  border-top: 1px solid #ebedf0;
}

.review-actions .btn-primary {
  width: 100%;
}

/* ==============================================
   AI DETECTION
   ============================================== */

/* Split panel header actions */
.split-panel-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* GPTZero button */
.btn-gptzero {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 12px;
  background: transparent;
  color: #6b7280;
  border: 1px dashed #c4c7cc;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-gptzero:hover {
  background: #f0f1f3;
  border-color: #999;
  color: #1a1c23;
}

body.dark .btn-gptzero {
  color: #858a9a;
  border-color: #4a4e5c;
}

body.dark .btn-gptzero:hover {
  background: #262a36;
  border-color: #858a9a;
  color: #e2e4e9;
}

/* Provider sections */
.detect-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: #9ca3af;
  font-size: 14px;
  text-align: center;
}

body.dark .detect-placeholder {
  color: #5c6070;
}

.detect-provider-section {
  margin-bottom: 4px;
}

.detect-provider-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #9ca3af;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid #eef0f3;
}

body.dark .detect-provider-label {
  color: #5c6070;
  border-bottom-color: #262a36;
}

.detect-gptzero-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 2px solid #eef0f3;
}

body.dark .detect-gptzero-section {
  border-top-color: #262a36;
}

/* Gauge */
.detect-gauge-container {
  margin-bottom: 20px;
}

.detect-gauge-bar {
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}

.detect-gauge-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}

.detect-gauge-label {
  font-size: 13px;
  font-weight: 600;
}

/* Metrics */
.detect-metrics {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
}

.detect-metric {
  flex: 1;
  background: #f8f9fb;
  border: 1px solid #eef0f3;
  border-radius: 8px;
  padding: 14px 16px;
  text-align: center;
}

.detect-metric-value {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 4px;
}

.detect-metric-label {
  font-size: 11px;
  font-weight: 500;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Sentences */
.detect-sentences-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #9ca3af;
  margin-bottom: 8px;
}

.detect-sent-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  border-bottom: 1px solid #f0f1f4;
}

.detect-sent-row:last-child {
  border-bottom: none;
}

.detect-sent-score {
  font-weight: 700;
  font-size: 12px;
  min-width: 36px;
  text-align: right;
  flex-shrink: 0;
}

.detect-sent-text {
  color: #374151;
  line-height: 1.5;
}

/* ==============================================
   DARK MODE
   ============================================== */

body.dark {
  background: #0f1117;
  color: #e2e4e9;
}

body.dark header {
  background: #181b24;
  border-bottom-color: #262a36;
}

body.dark .logo {
  color: #e2e4e9;
}

body.dark .darkmode-toggle {
  background: #262a36;
  border-color: #353944;
}

body.dark .darkmode-toggle.active {
  background: #353944;
  border-color: #4b5060;
}

body.dark .darkmode-toggle:hover {
  background: #353944;
}

body.dark .header-env {
  color: #5c6070;
}

/* --- Sidebar (dark) --- */
body.dark .sidebar {
  background: #181b24;
  border-right-color: #262a36;
}

body.dark .sidebar-title {
  color: #5c6070;
}

body.dark .field-group-label {
  color: #4a4e5c;
  border-bottom-color: #262a36;
}

body.dark label {
  color: #858a9a;
}

body.dark input,
body.dark select,
body.dark textarea {
  background: #1f2230;
  border-color: #353944;
  color: #e2e4e9;
}

body.dark input:focus,
body.dark select:focus,
body.dark textarea:focus {
  border-color: #4a8ceb;
  background: #252838;
  box-shadow: 0 0 0 3px rgba(74, 140, 235, 0.12);
}

body.dark input::placeholder,
body.dark textarea::placeholder {
  color: #4a4e5c;
}

body.dark .divider {
  border-top-color: #262a36;
}

body.dark .icon-btn {
  background: #262a36;
  border-color: #353944;
  color: #858a9a;
}

body.dark .icon-btn:hover {
  background: #353944;
  color: #e2e4e9;
}

body.dark .rules-panel {
  background: #1f2230;
  border-color: #262a36;
}

body.dark .rules-panel li {
  color: #858a9a;
}

body.dark .rules-panel li::before {
  background: #5c6070;
}

body.dark .rules-panel p {
  color: #858a9a;
}

/* --- Buttons (dark) --- */
body.dark .btn-primary {
  background: #e2e4e9;
  color: #181b24;
}

body.dark .btn-primary:hover {
  background: #c8cad0;
}

body.dark .btn-primary:disabled {
  background: #353944;
  color: #5c6070;
}

body.dark .btn-generate-main:hover:not(:disabled) {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

body.dark .btn-secondary {
  color: #e2e4e9;
  border-color: #4a4e5c;
}

body.dark .btn-secondary:hover {
  background: #262a36;
  border-color: #858a9a;
}

/* --- Pipeline (dark) --- */
body.dark .pipeline {
  background: #181b24;
  border-color: #262a36;
}

body.dark .pip-num {
  background: #262a36;
  color: #5c6070;
}

body.dark .pipeline-step.active {
  background: rgba(255, 255, 255, 0.04);
}

body.dark .pipeline-step.active .pip-num {
  background: #e2e4e9;
  color: #181b24;
}

body.dark .pip-label {
  color: #5c6070;
}

body.dark .pipeline-step.active .pip-label {
  color: #e2e4e9;
}

body.dark .pipeline-step.done .pip-num {
  background: #16a34a;
  color: #fff;
}

body.dark .pipeline-step.done .pip-label {
  color: #4ade80;
}

body.dark .pipeline-step.done + .pipeline-connector {
  background: #16a34a;
}

body.dark .pipeline-step.clickable:hover {
  background: rgba(22, 163, 74, 0.08);
}

body.dark .pipeline-step.clickable:hover .pip-label {
  color: #4ade80;
}

body.dark .pipeline-connector {
  background: #262a36;
}

/* --- Step Cards (dark) --- */
body.dark .workspace .step {
  background: #181b24;
  border-color: #262a36;
}

body.dark .section-header {
  border-bottom-color: #262a36;
}

body.dark .section-header h2 {
  color: #e2e4e9;
}

body.dark .section-actions {
  border-top-color: #262a36;
}

/* --- Tabs (dark) --- */
body.dark .tabs {
  background: #1f2230;
}

body.dark .tab {
  color: #858a9a;
}

body.dark .tab:hover {
  color: #e2e4e9;
  background: rgba(255, 255, 255, 0.05);
}

body.dark .tab.active {
  background: #181b24;
  color: #e2e4e9;
  box-shadow: none;
}

/* --- Draft Display (dark) --- */
body.dark #draft-rendered {
  background: #1f2230;
  border-color: #262a36;
}

body.dark #draft-rendered h1 { color: #e2e4e9; }
body.dark #draft-rendered h2 { color: #c8cad0; }
body.dark #draft-rendered p { color: #a1a7b3; }

body.dark #draft-raw {
  background: #0a0c10;
}

/* --- Checklist (dark) --- */
body.dark #checklist li.pass {
  background: #0f2419;
  border-color: #1a3a28;
  color: #4ade80;
}

body.dark #checklist li.pass .icon {
  background: #16a34a;
}

body.dark #checklist li.fail {
  background: #2a1215;
  border-color: #3a1a1e;
  color: #f87171;
}

body.dark .detail {
  color: #5c6070;
}

body.dark #checklist li.check-category {
  color: #5c6070;
}

body.dark #checklist li.diagnostic {
  background: #2a2315;
  border-color: #3a3120;
  color: #fbbf24;
}

body.dark #checklist li.diagnostic.pass {
  background: #0f2419;
  border-color: #1a3a28;
  color: #4ade80;
}

body.dark #checklist li.check-section-header {
  color: #e2e4e9;
}

/* --- Eye Button (dark) --- */
body.dark .btn-eye {
  background: #262a36;
  border-color: #353944;
  color: #858a9a;
}

body.dark .btn-eye:hover {
  background: #353944;
  color: #e2e4e9;
}

body.dark .btn-eye.active {
  background: #854d0e;
  border-color: #a16207;
  color: #fef08a;
}

body.dark mark.long-sentence {
  background: #854d0e;
  color: #fef08a;
}

body.dark mark.colon-sentence {
  background: #1e3a5f;
  color: #93c5fd;
}

/* --- Image Previews (dark) --- */
body.dark #image-preview,
body.dark .image-preview-area {
  background: #1f2230;
  border-color: #262a36;
}

body.dark .image-section-header h3 {
  color: #e0e7ef;
}

/* --- Publish Result (dark) --- */
body.dark #publish-result {
  background: #0f2419;
  border-color: #1a3a28;
  color: #4ade80;
}

body.dark #publish-result:empty {
  display: none;
}

body.dark #publish-result a {
  color: #4ade80;
}

/* --- Tooltip (dark) --- */
body.dark .image-info-trigger:hover::after {
  background: #e2e4e9;
  color: #181b24;
}

/* --- Empty State (dark) --- */
body.dark .workspace-empty-icon {
  opacity: 0.12;
}

body.dark .workspace-empty-title {
  color: #5c6070;
}

body.dark .workspace-empty-desc {
  color: #4a4e5c;
}

/* === Task List === */
.task-section {
  margin-top: 24px;
  border-top: 1px solid #ebedf0;
  padding-top: 20px;
}

.task-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.btn-new-task {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid #dfe1e6;
  background: #f0f1f4;
  color: #6b7280;
  font-size: 16px;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}

.btn-new-task:hover {
  background: #e5e7eb;
  color: #1d1d1f;
}

.task-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 400px;
  overflow-y: auto;
}

.task-list-empty {
  font-size: 12px;
  color: #9ca3af;
  text-align: center;
  padding: 20px 0;
}

.task-item {
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.task-item:hover {
  background: #f4f5f7;
}

.task-item.active {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.task-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.task-topic {
  font-size: 12px;
  font-weight: 500;
  color: #1d1d1f;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.task-status {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.status-draft { background: #f3f4f6; color: #6b7280; }
.status-verified { background: #dbeafe; color: #1d4ed8; }
.status-detected { background: #fef3c7; color: #92400e; }
.status-image { background: #fef3c7; color: #92400e; }
.status-template { background: #ede9fe; color: #6d28d9; }
.status-published { background: #dcfce7; color: #166534; }

.task-item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: #9ca3af;
}

/* === Task Navigation === */
.task-nav {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.btn-task-nav {
  flex: 1;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid #dfe1e6;
  background: #f0f1f4;
  color: #6b7280;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn-task-nav:hover:not(:disabled) {
  background: #e5e7eb;
  color: #1d1d1f;
}

.btn-task-nav:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* === Review Task Delete === */
.review-task-delete {
  display: none;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  background: none;
  color: #b0b5be;
  font-size: 12px;
  cursor: pointer;
  border-radius: 4px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-left: auto;
  transition: color 0.15s, background 0.15s;
}

.review-task-item:hover .review-task-delete {
  display: inline-flex;
}

.review-task-delete:hover {
  color: #dc2626;
  background: #fef2f2;
}

/* --- Task List (dark) --- */
body.dark .task-section {
  border-top-color: #262a36;
}

body.dark .btn-new-task {
  background: #262a36;
  border-color: #353944;
  color: #858a9a;
}

body.dark .btn-new-task:hover {
  background: #353944;
  color: #e2e4e9;
}

body.dark .task-list-empty {
  color: #5c6070;
}

body.dark .task-item:hover {
  background: #1f2230;
}

body.dark .task-item.active {
  background: #1a2440;
  border-color: #2d4a7c;
}

body.dark .task-topic {
  color: #e2e4e9;
}

body.dark .task-item-meta {
  color: #5c6070;
}

body.dark .status-draft { background: #262a36; color: #858a9a; }
body.dark .status-verified { background: #1e3a5f; color: #93c5fd; }
body.dark .status-detected { background: #3a3120; color: #fbbf24; }
body.dark .status-image { background: #3a3120; color: #fbbf24; }
body.dark .status-template { background: #2e1a5e; color: #c4b5fd; }
body.dark .status-published { background: #0f2419; color: #4ade80; }

/* Task spinner (in-progress indicator) */
.task-spinner {
  display: none;
  width: 12px;
  height: 12px;
  border: 2px solid #d1d5db;
  border-top-color: #6b7280;
  border-radius: 50%;
  animation: spin 0.5s linear infinite;
  flex-shrink: 0;
}

.task-item.pending .task-spinner {
  display: inline-block;
}

.task-item.pending .task-status {
  display: none;
}

/* Task delete button */
.task-delete {
  display: none;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  background: none;
  color: #b0b5be;
  font-size: 12px;
  cursor: pointer;
  border-radius: 4px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}

.task-item:hover .task-delete {
  display: inline-flex;
}

.task-delete:hover {
  color: #dc2626;
  background: #fef2f2;
}

body.dark .task-spinner {
  border-color: #353944;
  border-top-color: #858a9a;
}

body.dark .task-delete {
  color: #5c6070;
}

body.dark .task-delete:hover {
  color: #f87171;
  background: #2a1215;
}

body.dark .btn-task-nav {
  background: #262a36;
  border-color: #353944;
  color: #858a9a;
}

body.dark .btn-task-nav:hover:not(:disabled) {
  background: #353944;
  color: #e2e4e9;
}

body.dark .review-task-delete {
  color: #5c6070;
}

body.dark .review-task-delete:hover {
  color: #f87171;
  background: #2a1215;
}

/* --- Main Nav (dark) --- */
body.dark .main-nav {
  background: #1f2230;
}

body.dark .main-nav-tab {
  color: #858a9a;
}

body.dark .main-nav-tab:hover {
  color: #e2e4e9;
  background: rgba(255, 255, 255, 0.05);
}

body.dark .main-nav-tab.active {
  background: #181b24;
  color: #e2e4e9;
  box-shadow: none;
}

/* --- Research Layout (dark) --- */
body.dark .research-filters {
  background: #181b24;
  border-right-color: #262a36;
}

body.dark .research-filter-count {
  color: #5c6070;
  border-top-color: #262a36;
}

body.dark .research-stream-header h2 {
  color: #e2e4e9;
}

body.dark .research-card {
  background: #181b24;
  border-color: #262a36;
}

body.dark .research-card:hover {
  border-color: #353944;
}

body.dark .research-card.selected {
  background: #1a2440;
  border-color: #2d4a7c;
}

body.dark .research-card-source {
  color: #858a9a;
}

body.dark .type-news {
  background: #1e3a5f;
  color: #93c5fd;
}

body.dark .type-social {
  background: #3a3120;
  color: #fbbf24;
}

body.dark .research-btn-read,
body.dark .research-btn-open {
  background: #262a36;
  border-color: #353944;
  color: #858a9a;
}

body.dark .research-btn-read:hover,
body.dark .research-btn-open:hover {
  background: #353944;
  color: #e2e4e9;
}

body.dark .expanded .research-btn-read {
  background: #1e3a5f;
  border-color: #2d5a9e;
  color: #93c5fd;
}

body.dark .research-card-full {
  color: #c8cad0;
  background: #1f2230;
  border-color: #262a36;
}

body.dark .research-card-full h1,
body.dark .research-card-full h2,
body.dark .research-card-full h3 {
  color: #e2e4e9;
}

body.dark .research-card-full a {
  color: #93c5fd;
}

body.dark .research-card-full figcaption {
  color: #5c6070;
}

body.dark .research-card-loading {
  color: #5c6070;
}

body.dark .spinner-dark {
  border-color: rgba(255, 255, 255, 0.1);
  border-top-color: #858a9a;
}

body.dark .research-card-error {
  color: #f87171;
}

body.dark .research-card-rss-notice {
  background: #451a03;
  color: #fcd34d;
}

body.dark .research-btn-retry {
  border-color: #3a1a1e;
  color: #f87171;
}

body.dark .research-btn-retry:hover {
  background: #2a1215;
}

body.dark .research-card-title {
  color: #e2e4e9;
}

body.dark .research-card-excerpt {
  color: #858a9a;
}

body.dark .research-card-date {
  color: #5c6070;
}

body.dark .research-empty-text {
  color: #5c6070;
}

body.dark .research-selection-panel {
  background: #181b24;
  border-left-color: #262a36;
}

body.dark .research-selection-count {
  color: #e2e4e9;
}

body.dark .research-selection-empty {
  color: #5c6070;
}

body.dark .research-chip {
  background: #262a36;
  border-color: #353944;
  color: #c8cad0;
}

body.dark .research-chip-remove:hover {
  color: #f87171;
}

/* --- Review Layout (dark) --- */
body.dark .review-task-sidebar {
  background: #181b24;
  border-right-color: #262a36;
}

body.dark .review-task-sidebar-header {
  border-bottom-color: #262a36;
}

body.dark .review-task-item:hover {
  background: #1e2230;
}

body.dark .review-task-item.active {
  background: #1e293b;
  border-color: #334155;
}

body.dark .review-task-item-title {
  color: #e2e4e9;
}

body.dark .review-task-item-meta {
  color: #5c6070;
}

body.dark .review-article-panel {
  background: #181b24;
  border-right-color: #262a36;
}

body.dark .review-extraction-panel {
  background: #0f1117;
}

body.dark .review-panel-header {
  border-bottom-color: #262a36;
}

body.dark .review-panel-header h2 {
  color: #e2e4e9;
}

body.dark .review-article-tabs {
  background: #1f2230;
}

body.dark .review-article-tab {
  color: #858a9a;
}

body.dark .review-article-tab:hover {
  color: #e2e4e9;
  background: rgba(255, 255, 255, 0.05);
}

body.dark .review-article-tab.active {
  background: #181b24;
  color: #e2e4e9;
  box-shadow: none;
}

body.dark .review-article-url {
  color: #5c6070;
  border-bottom-color: #262a36;
}

body.dark .review-article-url a {
  color: #93c5fd;
}

body.dark .review-article-content {
  color: #c8cad0;
}

body.dark .review-article-content h1,
body.dark .review-article-content h2,
body.dark .review-article-content h3 {
  color: #e2e4e9;
}

body.dark .review-article-content a {
  color: #93c5fd;
}

body.dark .review-empty-state {
  color: #5c6070;
}

body.dark .btn-extract {
  background: #0071e3;
}
body.dark .btn-extract.extracting {
  background: #555a66;
}

body.dark .review-section-label {
  color: #5c6070;
}

body.dark .review-textarea {
  background: #1f2230;
  border-color: #353944;
  color: #e2e4e9;
}

body.dark .review-textarea:focus {
  border-color: #4a8ceb;
  background: #252838;
  box-shadow: 0 0 0 3px rgba(74, 140, 235, 0.12);
}

body.dark .review-actions {
  border-top-color: #262a36;
}

body.dark .review-structure-block {
  border-top-color: #262a36;
}

body.dark .review-field-label {
  color: #858a9a;
}

body.dark .review-input {
  background: #1e2230;
  border-color: #333847;
  color: #e2e4e9;
}

body.dark .review-input:focus {
  border-color: #4a8ceb;
}

body.dark .review-h2-row input {
  background: #1e2230;
  border-color: #333847;
  color: #e2e4e9;
}

body.dark .review-h2-row input:focus {
  border-color: #4a8ceb;
}

body.dark .btn-remove-h2 {
  color: #5c6070;
}

body.dark .btn-remove-h2:hover {
  color: #f87171;
  background: rgba(220, 38, 38, 0.1);
}

body.dark .btn-add-h2 {
  border-color: #333847;
  color: #858a9a;
}

body.dark .btn-add-h2:hover {
  border-color: #4a8ceb;
  color: #4a8ceb;
}

/* --- Split Layout (dark) --- */
body.dark .split-editor-label {
  color: #5c6070;
}

body.dark .edit-badge {
  background: #3a3120;
  color: #fbbf24;
}

body.dark .split-editor-content {
  background: #1f2230;
  border-color: #262a36;
  color: #c8cad0;
}

body.dark .split-editor-content:focus {
  border-color: #4a8ceb;
  box-shadow: 0 0 0 3px rgba(74, 140, 235, 0.12);
}

body.dark .split-editor-content h1 {
  color: #e2e4e9;
}

body.dark .split-editor-content h2 {
  color: #c8cad0;
}

body.dark .split-panel {
  background: #1a1d27;
  border-color: #262a36;
}

body.dark .split-panel-header {
  border-bottom-color: #262a36;
}

body.dark .split-panel-title {
  color: #858a9a;
}

body.dark .stale-notice {
  background: #2a2315;
  border-color: #3a3120;
  color: #fbbf24;
}

/* --- AI Detection (dark) --- */
body.dark .detect-gauge-bar {
  background: #262a36;
}

body.dark .detect-metric {
  background: #1f2230;
  border-color: #262a36;
}

body.dark .detect-metric-label {
  color: #5c6070;
}

body.dark .detect-sentences-header {
  color: #5c6070;
}

body.dark .detect-sent-row {
  border-bottom-color: #262a36;
}

body.dark .detect-sent-text {
  color: #c8cad0;
}

/* ==============================================
   RESPONSIVE
   ============================================== */
@media (max-width: 900px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid #ebedf0;
  }

  body.dark .sidebar {
    border-bottom-color: #262a36;
  }

  .workspace {
    padding: 20px 16px;
  }

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

  .research-filters {
    border-right: none;
    border-bottom: 1px solid #ebedf0;
  }

  body.dark .research-filters {
    border-bottom-color: #262a36;
  }

  .research-stream {
    padding: 20px 16px;
  }

  .research-selection-panel {
    position: static;
    height: auto;
    border-left: none;
    border-top: 1px solid #ebedf0;
  }

  body.dark .research-selection-panel {
    border-top-color: #262a36;
  }

  .review-layout-with-tasks {
    grid-template-columns: 1fr;
  }

  .review-task-sidebar {
    border-right: none;
    border-bottom: 1px solid #ebedf0;
    max-height: 30vh;
  }

  .review-article-panel {
    border-right: none;
    border-bottom: 1px solid #ebedf0;
    max-height: 50vh;
  }

  body.dark .review-task-sidebar {
    border-bottom-color: #262a36;
  }

  body.dark .review-article-panel {
    border-bottom-color: #262a36;
  }

  #draft-rendered,
  #draft-raw {
    max-width: 100%;
  }

  .step-split-layout {
    flex-direction: column;
  }

  .split-panel {
    width: 100%;
    position: static;
    max-height: none;
  }
}

/* === Draft Warnings === */
.draft-warnings {
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 12px;
  color: #92400e;
}

.draft-warnings strong {
  font-weight: 600;
}

.draft-warnings ul {
  margin: 6px 0 0 0;
  padding-left: 18px;
}

.draft-warnings li {
  margin-bottom: 2px;
}

body.dark .draft-warnings {
  background: #3a3120;
  border-color: #854d0e;
  color: #fcd34d;
}

/* ==============================================
   EDIT BUTTONS (pencil icons)
   ============================================== */

.icon-btn-edit {
  font-style: normal;
  font-size: 13px;
}

.btn-add-inline {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid #dfe1e6;
  background: #f0f1f4;
  color: #6b7280;
  font-size: 12px;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin-left: 6px;
  vertical-align: middle;
  transition: background 0.15s, color 0.15s;
}

.btn-add-inline:hover {
  background: #e5e7eb;
  color: #1d1d1f;
}

body.dark .btn-add-inline {
  background: #262a36;
  border-color: #353944;
  color: #858a9a;
}

body.dark .btn-add-inline:hover {
  background: #353944;
  color: #e2e4e9;
}

/* Rules / Author edit panels */
.rules-edit-panel {
  background: #f8f9fb;
  border: 1px solid #eef0f3;
  border-radius: 6px;
  padding: 12px;
  margin-top: 6px;
}

.rules-edit-panel textarea {
  font-size: 12px;
  line-height: 1.5;
}

.rules-edit-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

body.dark .rules-edit-panel {
  background: #1f2230;
  border-color: #262a36;
}

/* ==============================================
   MODAL OVERLAYS
   ============================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-content {
  background: #fff;
  border-radius: 12px;
  width: 600px;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.modal-sm {
  width: 420px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #ebedf0;
}

.modal-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: #1d1d1f;
}

.modal-close {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: #f0f1f4;
  color: #6b7280;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.modal-close:hover {
  background: #e5e7eb;
  color: #1d1d1f;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

body.dark .modal-content {
  background: #181b24;
}

body.dark .modal-header {
  border-bottom-color: #262a36;
}

body.dark .modal-header h3 {
  color: #e2e4e9;
}

body.dark .modal-close {
  background: #262a36;
  color: #858a9a;
}

body.dark .modal-close:hover {
  background: #353944;
  color: #e2e4e9;
}

/* Template modal list */
.template-modal-list {
  margin-bottom: 16px;
}

.template-modal-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.1s;
  border: 1px solid transparent;
  margin-bottom: 2px;
}

.template-modal-item:hover {
  background: #f4f5f7;
}

.template-modal-item-name {
  flex: 1;
  font-weight: 500;
}

.template-modal-item-actions {
  display: flex;
  gap: 4px;
}

.template-modal-item-actions button {
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid #dfe1e6;
  background: #f0f1f4;
  color: #6b7280;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.template-modal-item-actions button:hover {
  background: #e5e7eb;
  color: #1d1d1f;
}

.template-modal-item-actions .btn-delete-tpl:hover {
  background: #fef2f2;
  color: #dc2626;
  border-color: #fecaca;
}

body.dark .template-modal-item:hover {
  background: #1f2230;
}

body.dark .template-modal-item-name {
  color: #e2e4e9;
}

body.dark .template-modal-item-actions button {
  background: #262a36;
  border-color: #353944;
  color: #858a9a;
}

body.dark .template-modal-item-actions button:hover {
  background: #353944;
  color: #e2e4e9;
}

.template-modal-form {
  border-top: 1px solid #ebedf0;
  padding-top: 16px;
}

.template-modal-form h4 {
  font-size: 13px;
  font-weight: 600;
  color: #1d1d1f;
  margin-bottom: 12px;
}

body.dark .template-modal-form {
  border-top-color: #262a36;
}

body.dark .template-modal-form h4 {
  color: #e2e4e9;
}

/* Template H2 directive inputs */
.tpl-h2-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  background: #f8f9fb;
  border: 1px solid #eef0f3;
  border-radius: 6px;
  margin-bottom: 6px;
}

.tpl-h2-row-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tpl-h2-row-header input {
  flex: 1;
  font-weight: 500;
}

.tpl-h2-directive {
  font-size: 12px;
}

body.dark .tpl-h2-row {
  background: #1f2230;
  border-color: #262a36;
}

/* === Site URL field === */
.siteurl-display {
  font-size: 12px;
  color: #3b82f6;
  padding: 4px 0;
  word-break: break-all;
}

.siteurl-display.siteurl-empty {
  color: #9ca3af;
  font-style: italic;
}

.siteurl-edit-panel {
  margin-top: 6px;
}

.siteurl-edit-panel input {
  width: 100%;
  margin-bottom: 6px;
}

body.dark .siteurl-display {
  color: #60a5fa;
}

body.dark .siteurl-display.siteurl-empty {
  color: #6b7280;
}

/* ==============================================
   Internal Linking — Sitemap Viewer
   ============================================== */

.linking-header {
  margin-bottom: 16px;
}

.linking-title {
  font-size: 15px;
  font-weight: 600;
  color: #1d1d1f;
  margin-bottom: 2px;
}

.linking-subtitle {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 8px;
}

.linking-count {
  font-size: 13px;
  font-weight: 600;
  color: #3b82f6;
}

.linking-list {
  max-height: 500px;
  overflow-y: auto;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
}

.linking-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid #f0f1f4;
  font-size: 13px;
  transition: background 0.1s;
}

.linking-row:last-child {
  border-bottom: none;
}

.linking-row:hover {
  background: #f8f9fb;
}

.linking-date {
  flex: 0 0 100px;
  color: #6b7280;
  font-size: 12px;
  white-space: nowrap;
}

.linking-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.linking-title {
  font-weight: 500;
  color: #1d1d1f;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.linking-slug {
  font-weight: 500;
  color: #1d1d1f;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.linking-desc {
  color: #6b7280;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.linking-url {
  color: #9ca3af;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.linking-meta-status {
  padding: 6px 12px;
  font-size: 12px;
  color: #3b82f6;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  margin-bottom: 8px;
}

.linking-copy, .linking-open {
  flex: 0 0 auto;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #374151;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}

.linking-copy:hover, .linking-open:hover {
  background: #f0f1f4;
  border-color: #9ca3af;
}

.linking-notice {
  padding: 24px;
  text-align: center;
  color: #6b7280;
  font-size: 13px;
}

.linking-notice strong {
  color: #1d1d1f;
}

.linking-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 40px 24px;
  color: #6b7280;
  font-size: 13px;
}

.linking-loader[hidden] {
  display: none;
}

.linking-error {
  padding: 16px;
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 12px;
}

.linking-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 0;
}

.linking-page-info {
  font-size: 12px;
  color: #6b7280;
}

/* Dark mode — Internal Linking */
body.dark .linking-title {
  color: #e5e7eb;
}

body.dark .linking-subtitle {
  color: #9ca3af;
}

body.dark .linking-list {
  background: #181a24;
  border-color: #262a36;
}

body.dark .linking-row {
  border-bottom-color: #262a36;
}

body.dark .linking-row:hover {
  background: #1f2230;
}

body.dark .linking-title {
  color: #e5e7eb;
}

body.dark .linking-slug {
  color: #e5e7eb;
}

body.dark .linking-desc {
  color: #9ca3af;
}

body.dark .linking-url {
  color: #6b7280;
}

body.dark .linking-meta-status {
  background: #1e2433;
  border-color: #2d3a52;
  color: #60a5fa;
}

body.dark .linking-copy, body.dark .linking-open {
  background: #1f2230;
  border-color: #363a48;
  color: #d1d5db;
}

body.dark .linking-copy:hover, body.dark .linking-open:hover {
  background: #262a36;
  border-color: #4b5563;
}

body.dark .linking-notice {
  color: #9ca3af;
}

body.dark .linking-notice strong {
  color: #e5e7eb;
}

body.dark .linking-error {
  background: #2d1b1b;
  color: #f87171;
  border-color: #7f1d1d;
}

body.dark .linking-page-info {
  color: #9ca3af;
}

/* ==============================================
   Optimization Step
   ============================================== */

.section-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.optimization-layout {
  display: flex;
  gap: 16px;
  height: calc(100vh - 220px);
  min-height: 500px;
}

.optimization-editor-col {
  flex: 7;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.optimization-sidebar-col {
  flex: 3;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Editor Toolbar */
.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 8px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  flex-wrap: wrap;
}

.editor-toolbar button {
  width: 30px;
  height: 28px;
  padding: 0;
  border: none;
  background: transparent;
  color: #4b5563;
  font-size: 13px;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s;
}

.editor-toolbar button:hover {
  background: #f3f4f6;
  color: #1d1d1f;
}

.editor-toolbar button.is-active {
  background: #e0e7ff;
  color: #2563eb;
}

.editor-toolbar button[data-cmd="footer"] {
  width: auto;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.toolbar-sep {
  width: 1px;
  height: 18px;
  background: #e5e7eb;
  margin: 0 4px;
  flex-shrink: 0;
}

/* Footer button group */
.toolbar-footer-group {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0;
}

.toolbar-footer-btn {
  border-radius: 4px 0 0 4px !important;
  width: auto !important;
  padding: 0 8px !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  letter-spacing: 0.3px;
}

.toolbar-footer-arrow {
  width: 20px !important;
  border-radius: 0 !important;
  font-size: 10px !important;
  border-left: 1px solid #e5e7eb !important;
}

.toolbar-footer-edit {
  width: 24px !important;
  border-radius: 0 4px 4px 0 !important;
  font-size: 11px !important;
  border-left: 1px solid #e5e7eb !important;
}

/* Footer dropdown */
.footer-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 2px;
  min-width: 180px;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  z-index: 50;
  padding: 4px 0;
}

.footer-dropdown .footer-dropdown-item {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  height: auto;
  text-align: left;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 400;
  border: none;
  background: none;
  cursor: pointer;
  color: #374151;
  white-space: nowrap;
  border-radius: 0;
  justify-content: flex-start;
}

.footer-dropdown .footer-dropdown-item:hover {
  background: #f0f5ff;
  color: #1e40af;
}

.footer-dropdown .footer-dropdown-item.active {
  font-weight: 600;
  color: #2563eb;
}

.footer-dropdown .footer-dropdown-item .footer-check {
  width: 14px;
  text-align: center;
  font-size: 11px;
}

.footer-dropdown-empty {
  padding: 8px 12px;
  font-size: 11px;
  color: #9ca3af;
  text-align: center;
}

/* Footer modal list */
.footer-modal-list {
  margin-bottom: 16px;
  max-height: 200px;
  overflow-y: auto;
}

.footer-modal-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid #f0f1f4;
  font-size: 12px;
}

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

.footer-modal-item-name {
  font-weight: 600;
  color: #1d1d1f;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.footer-modal-item-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.footer-modal-item-actions button {
  padding: 2px 6px;
  font-size: 11px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 3px;
  color: #6b7280;
}

.footer-modal-item-actions button:hover { background: #f3f4f6; color: #1d1d1f; }
.footer-modal-item-actions .footer-btn-delete:hover { color: #dc2626; background: #fef2f2; }

/* Tiptap Editor */
.optimization-editor {
  border: 1px solid #e5e7eb;
  border-radius: 0 0 8px 8px;
  background: #fff;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

/* hr in editor */
.optimization-editor .tiptap hr {
  border: none;
  border-top: 2px solid #e5e7eb;
  margin: 16px 0;
}

/* Blockquote in editor */
.optimization-editor .tiptap blockquote {
  border-left: 3px solid #d1d5db;
  padding-left: 12px;
  margin: 8px 0;
  color: #6b7280;
}

.optimization-editor .tiptap {
  padding: 20px 24px;
  outline: none;
  font-size: 14px;
  line-height: 1.7;
  color: #1d1d1f;
}

.optimization-editor .tiptap h1 {
  font-size: 1.4em;
  font-weight: 700;
  margin: 0 0 12px;
  line-height: 1.3;
}

.optimization-editor .tiptap h2 {
  font-size: 1.15em;
  font-weight: 600;
  margin: 20px 0 8px;
  line-height: 1.3;
}

.optimization-editor .tiptap p {
  margin: 0 0 12px;
}

.optimization-editor .tiptap a {
  color: #2563eb;
  text-decoration: underline;
  cursor: text;
}

.optimization-editor .tiptap strong {
  font-weight: 600;
}

/* Sitemap sidebar */
.optimization-sitemap {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.optimization-sitemap-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.optimization-sitemap-header h3 {
  font-size: 13px;
  font-weight: 600;
  margin: 0;
  color: #1d1d1f;
}

.optimization-sitemap-count {
  font-size: 11px;
  color: #6b7280;
}

.optimization-search {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 12px;
  margin-bottom: 8px;
  box-sizing: border-box;
}

.optimization-sitemap-list {
  flex: 1;
  overflow-y: auto;
  font-size: 12px;
}

.opt-sitemap-row {
  padding: 6px 8px;
  border-bottom: 1px solid #f0f1f4;
  cursor: pointer;
  transition: background 0.1s;
}

.opt-sitemap-row:last-child {
  border-bottom: none;
}

.opt-sitemap-row:hover {
  background: #f0f5ff;
}

.opt-sitemap-row .opt-row-title {
  font-weight: 500;
  color: #1d1d1f;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.opt-sitemap-row .opt-row-url {
  color: #9ca3af;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Optimization Preview Panel */
.optimization-preview {
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: #eff6ff;
  padding: 12px;
}

.optimization-preview-header {
  margin-bottom: 10px;
}

.optimization-preview-header h3 {
  font-size: 13px;
  font-weight: 600;
  margin: 0;
  color: #1e40af;
}

/* Preview summary badges */
.opt-preview-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.opt-summary-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  background: #e0e7ff;
  color: #3730a3;
}

.opt-summary-internal {
  background: #dbeafe;
  color: #1e40af;
}

.opt-summary-external {
  background: #d1fae5;
  color: #065f46;
}

/* Preview details list */
.opt-preview-details {
  font-size: 12px;
}

.opt-detail-row {
  padding: 5px 0;
  border-bottom: 1px solid #dbeafe;
  line-height: 1.4;
}

.opt-detail-row:last-child {
  border-bottom: none;
}

.opt-detail-anchor {
  font-weight: 500;
  color: #1d1d1f;
}

.opt-detail-arrow {
  color: #9ca3af;
  margin: 0 2px;
}

.opt-detail-url {
  font-size: 11px;
  color: #2563eb;
  word-break: break-all;
}

.opt-detail-internal .opt-detail-anchor::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3b82f6;
  margin-right: 5px;
  vertical-align: middle;
}

.opt-detail-external .opt-detail-anchor::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  margin-right: 5px;
  vertical-align: middle;
}

/* Preview action buttons */
.opt-preview-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.opt-preview-actions .btn-primary {
  flex: 1;
}

.opt-preview-actions .btn-secondary {
  flex: 0;
  white-space: nowrap;
}

/* Visual preview marks in Tiptap editor */
.optimization-editor .opt-preview-internal {
  border-bottom: 2px dashed #3b82f6;
  padding-bottom: 1px;
  cursor: default;
}

.optimization-editor .opt-preview-external {
  border-bottom: 2px dashed #10b981;
  padding-bottom: 1px;
  cursor: default;
}

/* Preview detail rows with per-link actions */
.opt-detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.opt-detail-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.opt-detail-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.opt-detail-btn {
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 4px;
  font-size: 12px;
  line-height: 1;
  color: #6b7280;
  display: flex;
  align-items: center;
  justify-content: center;
}

.opt-detail-btn:hover {
  background: #f3f4f6;
}

.opt-detail-btn-delete:hover {
  color: #dc2626;
  background: #fef2f2;
}

.opt-detail-btn-swap:hover {
  color: #2563eb;
  background: #eff6ff;
}

.opt-detail-row.opt-detail-swapping {
  background: #eff6ff;
  border-radius: 4px;
  padding-left: 4px;
  padding-right: 4px;
}

/* Link mini-menu */
.link-menu {
  position: fixed;
  z-index: 200;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  padding: 4px 0;
  min-width: 140px;
}

.link-menu-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 14px;
  font-size: 12px;
  border: none;
  background: none;
  cursor: pointer;
  color: #374151;
}

.link-menu-btn:hover {
  background: #f0f5ff;
  color: #1e40af;
}

.link-menu-btn-danger:hover {
  background: #fef2f2;
  color: #dc2626;
}

.link-menu-url {
  padding: 4px 14px;
  font-size: 10px;
  color: #9ca3af;
  border-top: 1px solid #e5e7eb;
  margin-top: 2px;
  word-break: break-all;
  max-width: 250px;
}

/* Link editing mode */
.optimization-editor .tiptap a.link-editing,
.publish-editor-content .tiptap a.link-editing {
  outline: 2px solid #3b82f6;
  outline-offset: 1px;
  border-radius: 2px;
}

/* Dark mode — Toolbar */
body.dark .editor-toolbar {
  background: #1e2030;
  border-color: #262a36;
}

body.dark .editor-toolbar button {
  color: #9ca3af;
}

body.dark .editor-toolbar button:hover {
  background: #262a36;
  color: #e5e7eb;
}

body.dark .editor-toolbar button.is-active {
  background: #1e2d4a;
  color: #60a5fa;
}

body.dark .toolbar-sep {
  background: #363a48;
}

body.dark .toolbar-footer-arrow,
body.dark .toolbar-footer-edit {
  border-left-color: #363a48 !important;
}

body.dark .footer-dropdown {
  background: #1f2230;
  border-color: #363a48;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

body.dark .footer-dropdown .footer-dropdown-item { color: #d1d5db; }
body.dark .footer-dropdown .footer-dropdown-item:hover { background: #262a36; color: #60a5fa; }
body.dark .footer-dropdown .footer-dropdown-item.active { color: #60a5fa; }

body.dark .footer-modal-item { border-bottom-color: #262a36; }
body.dark .footer-modal-item-name { color: #e5e7eb; }
body.dark .footer-modal-item-actions button:hover { background: #262a36; color: #e5e7eb; }
body.dark .footer-modal-item-actions .footer-btn-delete:hover { color: #f87171; background: #2a1f1f; }

/* Dark mode — Optimization */
body.dark .optimization-editor {
  background: #181a24;
  border-color: #262a36;
}

body.dark .optimization-editor .tiptap hr {
  border-top-color: #363a48;
}

body.dark .optimization-editor .tiptap blockquote {
  border-left-color: #363a48;
  color: #9ca3af;
}

body.dark .optimization-editor .tiptap {
  color: #e0e7ef;
}

body.dark .optimization-editor .tiptap a {
  color: #60a5fa;
}

body.dark .optimization-sitemap {
  background: #181a24;
  border-color: #262a36;
}

body.dark .optimization-sitemap-header h3 {
  color: #e5e7eb;
}

body.dark .optimization-search {
  background: #1f2230;
  border-color: #363a48;
  color: #e0e7ef;
}

body.dark .opt-sitemap-row {
  border-bottom-color: #262a36;
}

body.dark .opt-sitemap-row:hover {
  background: #1f2a44;
}

body.dark .opt-sitemap-row .opt-row-title {
  color: #e5e7eb;
}

body.dark .opt-sitemap-row .opt-row-url {
  color: #6b7280;
}

body.dark .optimization-preview {
  background: #1e2433;
  border-color: #2d3a52;
}

body.dark .optimization-preview-header h3 {
  color: #60a5fa;
}

body.dark .opt-summary-badge {
  background: #2d3a52;
  color: #93c5fd;
}

body.dark .opt-summary-internal {
  background: #1e2d4a;
  color: #60a5fa;
}

body.dark .opt-summary-external {
  background: #132f2b;
  color: #6ee7b7;
}

body.dark .opt-detail-row {
  border-bottom-color: #2d3a52;
}

body.dark .opt-detail-anchor {
  color: #e5e7eb;
}

body.dark .opt-detail-url {
  color: #60a5fa;
}

body.dark .optimization-editor .opt-preview-internal {
  border-bottom-color: #60a5fa;
}

body.dark .optimization-editor .opt-preview-external {
  border-bottom-color: #6ee7b7;
}

body.dark .opt-detail-btn {
  color: #9ca3af;
}

body.dark .opt-detail-btn:hover {
  background: #262a36;
}

body.dark .opt-detail-btn-delete:hover {
  color: #f87171;
  background: #2a1f1f;
}

body.dark .opt-detail-btn-swap:hover {
  color: #60a5fa;
  background: #1e2d4a;
}

body.dark .opt-detail-row.opt-detail-swapping {
  background: #1e2d4a;
}

body.dark .link-menu {
  background: #1f2230;
  border-color: #363a48;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

body.dark .link-menu-btn {
  color: #d1d5db;
}

body.dark .link-menu-btn:hover {
  background: #262a36;
  color: #60a5fa;
}

body.dark .link-menu-btn-danger:hover {
  background: #2a1f1f;
  color: #f87171;
}

body.dark .link-menu-url {
  color: #6b7280;
  border-top-color: #363a48;
}

body.dark .optimization-editor .tiptap a.link-editing,
body.dark .publish-editor-content .tiptap a.link-editing {
  outline-color: #60a5fa;
}

/* === Task Rename Button === */
.task-rename {
  display: none;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  background: none;
  color: #b0b5be;
  font-size: 12px;
  cursor: pointer;
  border-radius: 4px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}

.task-item:hover .task-rename {
  display: inline-flex;
}

.task-rename:hover {
  color: #2563eb;
  background: #eff6ff;
}

body.dark .task-rename { color: #5c6070; }
body.dark .task-rename:hover { color: #60a5fa; background: #1a2440; }

.task-topic-editing {
  background: #fff;
  border: 1px solid #2563eb;
  border-radius: 4px;
  padding: 2px 4px;
  outline: none;
  white-space: pre;
}

body.dark .task-topic-editing {
  background: #1a1d28;
  border-color: #60a5fa;
  color: #e2e4e9;
}

/* === Generating status === */
.status-generating { background: #fef3c7; color: #92400e; }
body.dark .status-generating { background: #3a3120; color: #fbbf24; }
.status-failed { background: #fef2f2; color: #dc2626; }
body.dark .status-failed { background: #2a1215; color: #f87171; }

.task-item.generating .task-spinner {
  display: inline-block;
}

/* === Verify Word Count Badge === */
.verify-word-count {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  background: #f3f4f6;
  color: #6b7280;
  margin-left: 8px;
}

.verify-word-count.over-limit {
  background: #fef2f2;
  color: #dc2626;
}

.verify-word-count.under-limit {
  background: #fef3c7;
  color: #92400e;
}

body.dark .verify-word-count { background: #262a36; color: #858a9a; }
body.dark .verify-word-count.over-limit { background: #2a1215; color: #f87171; }
body.dark .verify-word-count.under-limit { background: #3a3120; color: #fbbf24; }

/* === Sitemap row enhancements === */
.opt-row-top {
  display: flex;
  align-items: center;
  gap: 6px;
}

.opt-row-top .opt-row-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.opt-row-open {
  flex-shrink: 0;
  font-size: 14px;
  color: #9ca3af;
  text-decoration: none;
  transition: color 0.15s;
}

.opt-row-open:hover {
  color: #2563eb;
}

body.dark .opt-row-open { color: #5c6070; }
body.dark .opt-row-open:hover { color: #60a5fa; }

.opt-row-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
}

.opt-row-bottom .opt-row-url {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.opt-row-date {
  flex-shrink: 0;
  font-size: 10px;
  color: #9ca3af;
}

body.dark .opt-row-date { color: #5c6070; }

/* ==============================================
   Settings View
   ============================================== */

.settings-layout {
  padding: 24px;
  max-width: 900px;
  margin: 0 auto;
}

.settings-container {
  background: #fff;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  padding: 28px 32px;
}

body.dark .settings-container {
  background: #1e1f25;
  border-color: #2d2e36;
}

.settings-main-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 24px;
  color: #1d1d1f;
}

body.dark .settings-main-title { color: #e5e7eb; }

.settings-section {
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid #f0f1f4;
}

body.dark .settings-section { border-bottom-color: #2d2e36; }

.settings-section:last-of-type {
  border-bottom: none;
  margin-bottom: 8px;
}

.settings-section-title {
  font-size: 14px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 16px;
}

body.dark .settings-section-title { color: #c9cdd4; }

/* --- Settings sub-tabs --- */
.settings-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 0;
}
.settings-tab {
  padding: 8px 16px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: #6b7280;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.settings-tab:hover { color: #374151; }
.settings-tab.active {
  color: #2563eb;
  border-bottom-color: #2563eb;
}
body.dark .settings-tabs { border-bottom-color: #374151; }
body.dark .settings-tab { color: #9ca3af; }
body.dark .settings-tab:hover { color: #d1d5db; }
body.dark .settings-tab.active { color: #60a5fa; border-bottom-color: #60a5fa; }
.settings-tab-content { display: none; }
.settings-tab-content.active { display: block; }

.settings-row {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.settings-field {
  flex: 1;
  min-width: 140px;
}

.settings-field-wide {
  flex: 2;
  min-width: 300px;
}

.settings-field label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: #6b7280;
  margin-bottom: 4px;
}

body.dark .settings-field label { color: #8b8fa0; }

.settings-field input[type="text"],
.settings-field input[type="number"],
.settings-field select {
  width: 100%;
  padding: 6px 10px;
  font-size: 13px;
  border: 1px solid #d1d5db;
  border-radius: 5px;
  background: #fff;
  color: #1d1d1f;
}

body.dark .settings-field input[type="text"],
body.dark .settings-field input[type="number"],
body.dark .settings-field select {
  background: #16171c;
  border-color: #3a3b45;
  color: #e5e7eb;
}

.settings-toggle-field {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  min-width: 100px;
  flex: 0 0 auto;
}

.settings-toggle-field input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin-top: 2px;
}

.settings-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: #374151;
  margin-bottom: 8px;
}

body.dark .settings-label { color: #c9cdd4; }

.settings-group {
  margin-bottom: 16px;
}

/* Feed rows */
.settings-feeds-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.settings-feed-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-feed-toggle {
  flex-shrink: 0;
}

.settings-feed-toggle input[type="checkbox"] {
  width: 15px;
  height: 15px;
}

.settings-feed-source {
  width: 140px !important;
  flex: 0 0 140px;
  padding: 5px 8px;
  font-size: 12px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #fff;
  color: #1d1d1f;
}

.settings-feed-url {
  flex: 1;
  padding: 5px 8px;
  font-size: 12px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #fff;
  color: #1d1d1f;
}

body.dark .settings-feed-source,
body.dark .settings-feed-url {
  background: #16171c;
  border-color: #3a3b45;
  color: #e5e7eb;
}

.btn-feed-remove {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 3px;
  line-height: 1;
}

.btn-feed-remove:hover {
  background: #fef2f2;
}

body.dark .btn-feed-remove:hover {
  background: #3b1c1c;
}

/* Actions bar */
.settings-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-top: 16px;
  border-top: 1px solid #f0f1f4;
}

body.dark .settings-actions { border-top-color: #2d2e36; }

.settings-toast {
  font-size: 12px;
  font-weight: 500;
  transition: opacity 0.3s;
}

.settings-toast-ok { color: #059669; }
.settings-toast-err { color: #ef4444; }

/* API Keys input row */
.api-key-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.api-key-input {
  flex: 1;
  font-family: monospace;
  letter-spacing: 0.5px;
}
.btn-toggle-key {
  flex-shrink: 0;
  cursor: pointer;
  font-size: 16px;
  padding: 4px 6px;
}

/* ==============================================
   Publish Tab — 2-column layout
   ============================================== */

/* Title bar — full width above editor */
.publish-title-bar {
  margin-bottom: 0;
}

.publish-title-input {
  width: 100%;
  padding: 14px 20px;
  font-size: 20px;
  font-weight: 700;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  background: var(--bg-primary);
  color: var(--text-primary);
  outline: none;
  line-height: 1.3;
}

.publish-title-input::placeholder {
  color: var(--text-muted, #aaa);
  font-weight: 400;
}

.publish-title-input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.publish-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  min-height: 500px;
}

.publish-editor-col {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 0 0 10px 10px;
  overflow: hidden;
  background: var(--bg-primary);
}

#publish-editor-toolbar {
  border-bottom: 1px solid var(--border);
  border-radius: 0;
}

.publish-editor-content {
  flex: 1;
  min-height: 400px;
  max-height: 70vh;
  overflow-y: auto;
  padding: 16px 20px;
  outline: none;
  font-size: 14px;
  line-height: 1.7;
}

.publish-editor-content .ProseMirror {
  min-height: 380px;
  outline: none;
}

.publish-editor-content .ProseMirror h2 {
  font-size: 1.25em;
  margin: 1.2em 0 0.5em;
  font-weight: 600;
}

.publish-editor-content .ProseMirror h3 {
  font-size: 1.1em;
  margin: 1em 0 0.4em;
  font-weight: 600;
}

.publish-editor-content .ProseMirror p {
  margin-bottom: 0.7em;
}

.publish-editor-content .ProseMirror a {
  color: #3b82f6;
  text-decoration: underline;
}

.publish-editor-content .ProseMirror img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 12px 0;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.publish-editor-content .ProseMirror img.ProseMirror-selectednode {
  outline: 2px solid #3b82f6;
}

/* Meta Panel */
.publish-meta-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  overflow-y: auto;
  max-height: calc(70vh + 60px);
}

.publish-meta-section {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.publish-meta-section:last-child {
  border-bottom: none;
}

.publish-meta-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.publish-meta-input,
.publish-meta-select,
.publish-meta-textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 13px;
}

.publish-meta-textarea {
  resize: vertical;
  font-family: inherit;
}

.publish-meta-hint {
  display: block;
  font-size: 11px;
  color: var(--text-muted, #888);
  margin-top: 4px;
}

.publish-checkbox-list {
  max-height: 180px;
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-primary);
  padding: 4px 0;
}

.publish-checkbox-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  font-size: 13px;
  cursor: pointer;
}

.publish-checkbox-list label:hover {
  background: var(--bg-hover, #f0f0f0);
}

.publish-checkbox-list .publish-cat-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
}

.publish-checkbox-list input[type="checkbox"] {
  margin: 0;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Featured Image Preview */
.publish-featured-image-preview {
  width: 100%;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  min-height: 40px;
}

.publish-featured-image-preview img {
  width: 100%;
  height: auto;
  display: block;
}

.publish-featured-image-preview .no-image {
  padding: 12px;
  text-align: center;
  color: var(--text-muted, #999);
  font-size: 12px;
}

/* Publish Action Button */
.publish-action-section {
  padding-top: 14px;
}

.publish-btn-main {
  width: 100%;
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
}

.publish-result {
  margin-top: 10px;
  font-size: 13px;
  line-height: 1.5;
}

.publish-result a {
  color: #3b82f6;
}

/* Schedule row */
.publish-schedule-row {
  display: flex;
  gap: 8px;
}

.publish-schedule-input {
  flex: 1;
}

/* Loading state for WP data */
.publish-meta-loading {
  font-size: 12px;
  color: var(--text-muted, #888);
  padding: 8px 0;
}

@media (max-width: 900px) {
  .publish-layout {
    grid-template-columns: 1fr;
  }
  .publish-meta-panel {
    max-height: none;
  }
  .publish-editor-col {
    border-radius: 0 0 10px 10px;
  }
}

/* === Tracking Tab === */

.tracking-layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px;
}

.tracking-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.tracking-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
}

.tracking-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tracking-date-input {
  padding: 5px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  color: #1a1a2e;
}

.tracking-project-filter {
  padding: 5px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  color: #1a1a2e;
  min-width: 140px;
}

/* Stats cards */
.tracking-stats {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.tracking-stat-card {
  flex: 1;
  min-width: 100px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 16px 18px;
  text-align: center;
}

.tracking-stat-value {
  font-size: 26px;
  font-weight: 700;
  color: #1a1a2e;
  line-height: 1.2;
}

.tracking-stat-label {
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

.tracking-stat-published .tracking-stat-value { color: #16a34a; }
.tracking-stat-draft .tracking-stat-value { color: #2563eb; }
.tracking-stat-failed .tracking-stat-value { color: #dc2626; }

/* Table */
.tracking-table-wrap {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
}

.tracking-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.tracking-table thead {
  background: #f3f4f6;
}

.tracking-table th {
  text-align: left;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b7280;
  border-bottom: 1px solid #e5e7eb;
}

.tracking-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #f3f4f6;
  color: #374151;
}

.tracking-table tbody tr:last-child td {
  border-bottom: none;
}

.tracking-table tbody tr:hover {
  background: #f9fafb;
}

.tracking-col-time {
  white-space: nowrap;
  width: 70px;
  color: #6b7280;
}

.tracking-col-title {
  font-weight: 500;
  max-width: 350px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tracking-col-words {
  text-align: right;
  width: 60px;
  font-variant-numeric: tabular-nums;
}

.tracking-col-link a {
  color: #2563eb;
  text-decoration: none;
  font-weight: 500;
}

.tracking-col-link a:hover {
  text-decoration: underline;
}

.tracking-empty {
  text-align: center;
  padding: 32px 14px !important;
  color: #9ca3af;
  font-style: italic;
}

/* Status badges */
.tracking-status {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
}

.tracking-status-published {
  background: #dcfce7;
  color: #166534;
}

.tracking-status-scheduled {
  background: #dbeafe;
  color: #1e40af;
}

.tracking-status-draft {
  background: #f3f4f6;
  color: #4b5563;
}

.tracking-status-failed {
  background: #fee2e2;
  color: #991b1b;
}

/* --- Tracking (dark mode) --- */

body.dark .tracking-title {
  color: #e0e7ef;
}

body.dark .tracking-date-input,
body.dark .tracking-project-filter {
  background: #1e2a3a;
  border-color: #2d3a4a;
  color: #e0e7ef;
}

body.dark .tracking-stat-card {
  background: #141c2b;
  border-color: #2d3a4a;
}

body.dark .tracking-stat-value {
  color: #e0e7ef;
}

body.dark .tracking-stat-label {
  color: #8899aa;
}

body.dark .tracking-stat-published .tracking-stat-value { color: #4ade80; }
body.dark .tracking-stat-draft .tracking-stat-value { color: #60a5fa; }
body.dark .tracking-stat-failed .tracking-stat-value { color: #f87171; }

body.dark .tracking-table-wrap {
  border-color: #2d3a4a;
}

body.dark .tracking-table thead {
  background: #1a2435;
}

body.dark .tracking-table th {
  color: #8899aa;
  border-bottom-color: #2d3a4a;
}

body.dark .tracking-table td {
  color: #c5cdd8;
  border-bottom-color: #1e2a3a;
}

body.dark .tracking-table tbody tr:hover {
  background: #1a2435;
}

body.dark .tracking-col-time {
  color: #8899aa;
}

body.dark .tracking-col-link a {
  color: #60a5fa;
}

body.dark .tracking-empty {
  color: #5a6a7a;
}

body.dark .tracking-status-published {
  background: #0f2419;
  color: #4ade80;
}

body.dark .tracking-status-scheduled {
  background: #0f1a2e;
  color: #60a5fa;
}

body.dark .tracking-status-draft {
  background: #1e2a3a;
  color: #8899aa;
}

body.dark .tracking-status-failed {
  background: #2a1215;
  color: #f87171;
}

/* ==============================================
   Market Data Widget (Review tab)
   ============================================== */

.market-data-widget {
  border-top: 1px solid #ebedf0;
  padding-top: 4px;
  margin-top: 8px;
}

.market-data-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px 8px;
}

.btn-market-refresh {
  background: none;
  border: 1px solid #dfe1e6;
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn-market-refresh:hover {
  background: #f3f4f6;
  border-color: #c5c8ce;
}

.market-data-body {
  max-height: 320px;
  overflow-y: auto;
  padding: 0 24px;
}

.market-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.market-data-table th {
  font-size: 10px;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 6px;
  border-bottom: 1px solid #ebedf0;
  text-align: left;
}

.market-data-table td {
  padding: 5px 6px;
  border-bottom: 1px solid #f3f4f6;
  white-space: nowrap;
}

.market-data-table tr:hover {
  background: #f9fafb;
}

.market-data-table input[type="checkbox"] {
  margin: 0;
  cursor: pointer;
}

.market-data-coin {
  display: flex;
  align-items: center;
  gap: 6px;
}

.market-data-coin img {
  width: 16px;
  height: 16px;
  border-radius: 50%;
}

.market-data-symbol {
  font-weight: 600;
  color: #1d1d1f;
}

.market-data-name {
  color: #9ca3af;
  margin-left: 4px;
}

.market-data-price {
  text-align: right;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.market-data-change {
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.market-data-change.positive { color: #16a34a; }
.market-data-change.negative { color: #dc2626; }

.market-data-actions {
  padding: 8px 24px 12px;
  text-align: right;
}

.btn-market-confirm {
  background: #16a34a !important;
  border-color: #16a34a !important;
  color: #fff !important;
}

body.dark .btn-market-confirm {
  background: #22c55e !important;
  border-color: #22c55e !important;
  color: #000 !important;
}

.market-data-loading {
  text-align: center;
  padding: 24px;
  color: #9ca3af;
  font-size: 12px;
}

/* Dark mode */
body.dark .market-data-widget {
  border-top-color: #262a36;
}

body.dark .btn-market-refresh {
  border-color: #353944;
  color: #8b8fa3;
}

body.dark .btn-market-refresh:hover {
  background: #252838;
  border-color: #4a4e5c;
}

body.dark .market-data-table th {
  color: #5c6070;
  border-bottom-color: #2a2e3a;
}

body.dark .market-data-table td {
  border-bottom-color: #22252f;
}

body.dark .market-data-table tr:hover {
  background: #1f2230;
}

body.dark .market-data-symbol {
  color: #e2e4e9;
}

body.dark .market-data-name {
  color: #5c6070;
}

body.dark .market-data-price {
  color: #e2e4e9;
}

/* === Publish link menu confirm state === */
.publish-link-menu-btn-confirm {
  background: #dc2626 !important;
  color: #fff !important;
}

.publish-link-menu-btn-confirm:hover {
  background: #b91c1c !important;
}

/* === Publish result links === */
.publish-link {
  color: #2563eb;
  cursor: pointer;
  text-decoration: underline;
}

.publish-link:hover {
  color: #1e40af;
}

body.dark .publish-link {
  color: #60a5fa;
}

body.dark .publish-link:hover {
  color: #93bbfc;
}

/* === Analytics === */
.analytics-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px;
}

.analytics-banner {
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
}

.analytics-banner-mock {
  background: #fef3c7;
  border: 1px solid #fbbf24;
  color: #92400e;
}

.analytics-banner-ok {
  background: #dcfce7;
  border: 1px solid #86efac;
  color: #166534;
}

.analytics-controls {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.analytics-control-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.analytics-control-group label {
  font-size: 11px;
  color: #6b7280;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.analytics-select {
  background: #fff;
  border: 1px solid #dfe1e6;
  color: #374151;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  min-width: 160px;
}

.analytics-summary {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.analytics-card {
  flex: 1;
  min-width: 100px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 16px 18px;
  text-align: center;
}

.analytics-card-label {
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

.analytics-card-value {
  font-size: 26px;
  font-weight: 700;
  color: #1a1a2e;
  line-height: 1.2;
}

.analytics-section-title {
  font-size: 15px;
  color: #1d1d1f;
  margin-bottom: 12px;
  font-weight: 700;
}

.analytics-chart-section {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 24px;
  background: #fff;
}

.analytics-chart {
  width: 100%;
  min-height: 200px;
  overflow-x: auto;
}

.analytics-chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 180px;
  padding: 0 4px;
}

.analytics-bar-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 18px;
  gap: 1px;
}

.analytics-bar-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  gap: 1px;
}

.analytics-bar {
  width: 80%;
  border-radius: 2px 2px 0 0;
  min-height: 1px;
  transition: height 0.3s ease;
}

.analytics-bar-clicks {
  background: #3b82f6;
}

.analytics-bar-impressions {
  background: #818cf8;
  opacity: 0.4;
}

.analytics-bar-label {
  font-size: 9px;
  color: #6b7280;
  margin-top: 4px;
  transform: rotate(-45deg);
  white-space: nowrap;
}

.analytics-chart-legend {
  display: flex;
  gap: 20px;
  justify-content: center;
  margin-top: 12px;
}

.analytics-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #6b7280;
}

.analytics-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

.analytics-table-section {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
  padding-top: 20px;
}

.analytics-table-section .analytics-section-title {
  padding: 0 20px;
}

.analytics-table-wrapper {
  overflow-x: auto;
}

.analytics-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.analytics-table thead {
  background: #f3f4f6;
}

.analytics-table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 14px;
  border-bottom: 1px solid #e5e7eb;
  cursor: pointer;
  user-select: none;
}

.analytics-table thead th:hover {
  color: #374151;
}

.analytics-th-page {
  min-width: 300px;
}

.analytics-th-num {
  text-align: right !important;
  min-width: 100px;
}

.analytics-th-match {
  min-width: 80px;
  text-align: center !important;
}

.analytics-table tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid #f3f4f6;
  color: #374151;
}

.analytics-table tbody tr:last-child td {
  border-bottom: none;
}

.analytics-table tbody tr:hover {
  background: #f9fafb;
}

.analytics-page-url {
  color: #2563eb;
  text-decoration: none;
  word-break: break-all;
  font-size: 12px;
  font-weight: 500;
}

.analytics-page-url:hover {
  text-decoration: underline;
}

.analytics-page-title {
  font-size: 13px;
  font-weight: 500;
  color: #1d1d1f;
  margin-bottom: 2px;
}

.analytics-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.analytics-match-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
}

.analytics-match-yes {
  background: #dcfce7;
  color: #166534;
}

.analytics-match-no {
  background: #f3f4f6;
  color: #9ca3af;
}

.analytics-empty {
  text-align: center;
  color: #9ca3af;
  padding: 32px 14px !important;
  font-style: italic;
}

.analytics-loading {
  text-align: center;
  padding: 40px 14px !important;
  color: #9ca3af;
  font-style: italic;
}

/* --- Analytics (dark mode) --- */

body.dark .analytics-banner-mock {
  background: #1e2a3a;
  border-color: #2d3a4a;
  color: #8899aa;
}

body.dark .analytics-banner-ok {
  background: #0f2419;
  border-color: #166534;
  color: #4ade80;
}

body.dark .analytics-control-group label {
  color: #8899aa;
}

body.dark .analytics-select {
  background: #1e2a3a;
  border-color: #2d3a4a;
  color: #e0e7ef;
}

body.dark .analytics-card {
  background: #141c2b;
  border-color: #2d3a4a;
}

body.dark .analytics-card-value {
  color: #e0e7ef;
}

body.dark .analytics-card-label {
  color: #8899aa;
}

body.dark .analytics-section-title {
  color: #e0e7ef;
}

body.dark .analytics-chart-section {
  background: #141c2b;
  border-color: #2d3a4a;
}

body.dark .analytics-bar-clicks {
  background: #60a5fa;
}

body.dark .analytics-bar-label {
  color: #5a6a7a;
}

body.dark .analytics-chart-legend .analytics-legend-item {
  color: #8899aa;
}

body.dark .analytics-table-section {
  border-color: #2d3a4a;
}

body.dark .analytics-table thead {
  background: #1a2435;
}

body.dark .analytics-table thead th {
  color: #8899aa;
  border-bottom-color: #2d3a4a;
}

body.dark .analytics-table thead th:hover {
  color: #e0e7ef;
}

body.dark .analytics-table tbody td {
  color: #c5cdd8;
  border-bottom-color: #1e2a3a;
}

body.dark .analytics-table tbody tr:hover {
  background: #1a2435;
}

body.dark .analytics-page-url {
  color: #60a5fa;
}

body.dark .analytics-page-title {
  color: #e0e7ef;
}

body.dark .analytics-match-yes {
  background: #0f2419;
  color: #4ade80;
}

body.dark .analytics-match-no {
  background: #1a2435;
  color: #5a6a7a;
}

body.dark .analytics-empty {
  color: #5a6a7a;
}

body.dark .analytics-loading {
  color: #5a6a7a;
}

@media (max-width: 768px) {
  .analytics-summary {
    flex-wrap: wrap;
  }
  .analytics-card {
    min-width: calc(50% - 8px);
  }
  .analytics-controls {
    flex-direction: column;
    align-items: stretch;
  }
}

/* === Automation === */
.automation-layout {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px;
}

.automation-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.automation-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 4px;
}

.automation-desc {
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 16px;
}

body.dark .automation-desc {
  color: #9ca3af;
}

.automation-config {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 20px;
}

body.dark .automation-config {
  background: #1e1e1e;
  border-color: #333;
}

.automation-config-row {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.automation-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 150px;
}

.automation-config-row[hidden] {
  display: none !important;
}

.automation-field[hidden] {
  display: none !important;
}

.automation-field label {
  font-size: 12px;
  font-weight: 500;
  color: #374151;
}

body.dark .automation-field label {
  color: #d1d5db;
}

.automation-field select {
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
}

body.dark .automation-field select {
  background: #2a2a2a;
  border-color: #444;
  color: #e5e7eb;
}

.automation-status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

.automation-status-badge.running { background: #dbeafe; color: #1d4ed8; }
.automation-status-badge.completed { background: #dcfce7; color: #166534; }
.automation-status-badge.failed { background: #fee2e2; color: #991b1b; }
.automation-status-badge.stopped { background: #fef3c7; color: #92400e; }
.automation-status-badge.paused { background: #e0e7ff; color: #4338ca; }

body.dark .automation-status-badge.running { background: #1e3a5f; color: #93c5fd; }
body.dark .automation-status-badge.completed { background: #14532d; color: #86efac; }
body.dark .automation-status-badge.failed { background: #450a0a; color: #fca5a5; }
body.dark .automation-status-badge.stopped { background: #451a03; color: #fcd34d; }
body.dark .automation-status-badge.paused { background: #312e81; color: #a5b4fc; }

.automation-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.automation-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f9fafb;
  border: 1px solid #f3f4f6;
  font-size: 13px;
}

body.dark .automation-step {
  background: #252525;
  border-color: #333;
}

.automation-step-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.automation-step-name {
  font-weight: 500;
  min-width: 100px;
}

.automation-step-detail {
  color: #6b7280;
  flex: 1;
  font-size: 12px;
}

body.dark .automation-step-detail {
  color: #9ca3af;
}

.automation-step-time {
  color: #9ca3af;
  font-size: 11px;
  min-width: 50px;
  text-align: right;
}

.automation-step.pending .automation-step-icon::after { content: "\25CB"; color: #d1d5db; }
.automation-step.running .automation-step-icon::after { content: "\25CF"; color: #3b82f6; animation: pulse-dot 1s infinite; }
.automation-step.done .automation-step-icon::after { content: "\2713"; color: #16a34a; }
.automation-step.error .automation-step-icon::after { content: "\2717"; color: #dc2626; }
.automation-step.skipped .automation-step-icon::after { content: "\2014"; color: #9ca3af; }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.auto-run-card.auto-run-cancelled {
  opacity: 0.5;
}

.auto-run-card.auto-run-cancelled:hover {
  opacity: 1;
}

.automation-error {
  margin-top: 12px;
  padding: 10px 14px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: #991b1b;
  font-size: 13px;
}

body.dark .automation-error {
  background: #450a0a;
  border-color: #7f1d1d;
  color: #fca5a5;
}

.automation-result {
  margin-top: 12px;
  padding: 10px 14px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  color: #166534;
  font-size: 13px;
}

body.dark .automation-result {
  background: #14532d;
  border-color: #166534;
  color: #86efac;
}

/* Run cards section */
.automation-runs-section {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 20px;
}

body.dark .automation-runs-section {
  background: #1e1e1e;
  border-color: #333;
}

.automation-runs-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
}

.automation-runs {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.automation-runs-empty {
  color: #9ca3af;
  font-size: 13px;
  text-align: center;
  padding: 24px;
}

/* Individual run card */
.auto-run-card {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
}

body.dark .auto-run-card {
  border-color: #333;
}

.auto-run-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  background: #f9fafb;
  user-select: none;
  transition: background 0.15s;
}

body.dark .auto-run-header {
  background: #252525;
}

.auto-run-header:hover {
  background: #f3f4f6;
}

body.dark .auto-run-header:hover {
  background: #2a2a2a;
}

.auto-run-project,
.auto-run-topic {
  font-size: 13px;
  font-weight: 500;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auto-run-steps-count {
  font-size: 12px;
  color: #6b7280;
}

.auto-run-time {
  font-size: 12px;
  color: #9ca3af;
  margin-left: auto;
}

.auto-run-delete {
  font-size: 16px;
  color: #6b7280;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  flex-shrink: 0;
}
.auto-run-delete:hover {
  color: #f87171;
}

.auto-run-chevron {
  font-size: 12px;
  color: #9ca3af;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.auto-run-card.expanded .auto-run-chevron {
  transform: rotate(180deg);
}

/* Collapsible body */
.auto-run-body {
  display: none;
  padding: 14px;
  border-top: 1px solid #e5e7eb;
}

body.dark .auto-run-body {
  border-top-color: #333;
}

.auto-run-card.expanded .auto-run-body {
  display: block;
}

.auto-run-steps-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auto-run-summary {
  color: #9ca3af;
  font-size: 13px;
  text-align: center;
  padding: 12px;
}

/* Checkpoint panel inside run card */
.auto-run-checkpoint {
  margin-top: 14px;
  padding: 14px;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 8px;
}

body.dark .auto-run-checkpoint {
  background: #1e1b4b;
  border-color: #4338ca;
}

.checkpoint-label {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
  color: #1e1b4b;
}

body.dark .checkpoint-label {
  color: #c7d2fe;
}

.checkpoint-sub-label {
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

body.dark .checkpoint-sub-label {
  color: #9ca3af;
}

.checkpoint-h1 {
  font-size: 14px;
  font-weight: 500;
  padding: 8px 12px;
  background: #f0f9ff;
  border-left: 3px solid #3b82f6;
  border-radius: 4px;
  margin: 8px 0 12px 0;
}

body.dark .checkpoint-h1 {
  background: #1e3a5f;
  color: #e0f2fe;
}

.checkpoint-h2s ul {
  margin: 6px 0 12px 0;
  padding-left: 20px;
}

.checkpoint-h2s li {
  font-size: 13px;
  margin: 4px 0;
  color: #374151;
}

body.dark .checkpoint-h2s li {
  color: #d1d5db;
}

.checkpoint-sources ul {
  margin: 6px 0 12px 0;
  padding-left: 20px;
  font-size: 12px;
}

.checkpoint-sources li {
  margin: 4px 0;
}

.checkpoint-sources a {
  color: #2563eb;
  text-decoration: none;
}

.checkpoint-sources a:hover {
  text-decoration: underline;
}

body.dark .checkpoint-sources a {
  color: #60a5fa;
}

.checkpoint-source-tag {
  font-size: 11px;
  color: #9ca3af;
  margin-left: 4px;
}

.checkpoint-hint {
  font-size: 12px;
  color: #6b7280;
  font-style: italic;
  margin-top: 8px;
}

body.dark .checkpoint-hint {
  color: #9ca3af;
}

.automation-checkpoint-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.automation-checkpoint-actions .btn-primary {
  font-size: 13px;
  padding: 8px 18px;
}

.automation-checkpoint-actions .btn-secondary {
  font-size: 13px;
  padding: 8px 18px;
}

/* AUTO badge in production task list */
.task-auto-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: #818cf8;
  color: #fff;
  margin-right: 6px;
  flex-shrink: 0;
  vertical-align: middle;
}

body.dark .task-auto-badge {
  background: #6366f1;
  color: #e0e7ff;
}

/* Step badge in production task list */
.task-step-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 500;
  background: #f3f4f6;
  color: #6b7280;
  margin-right: 4px;
  flex-shrink: 0;
}

body.dark .task-step-badge {
  background: #374151;
  color: #9ca3af;
}

.task-step-badge.step-draft { background: #dbeafe; color: #1d4ed8; }
.task-step-badge.step-verify { background: #fef3c7; color: #92400e; }
.task-step-badge.step-optimize { background: #ede9fe; color: #6d28d9; }
.task-step-badge.step-image { background: #fce7f3; color: #be185d; }
.task-step-badge.step-ready { background: #dcfce7; color: #166534; }
.task-step-badge.step-publish { background: #cffafe; color: #0e7490; }
.task-step-badge.step-published { background: #dcfce7; color: #166534; }

body.dark .task-step-badge.step-draft { background: #1e3a5f; color: #93c5fd; }
body.dark .task-step-badge.step-verify { background: #451a03; color: #fcd34d; }
body.dark .task-step-badge.step-optimize { background: #2e1065; color: #c4b5fd; }
body.dark .task-step-badge.step-image { background: #500724; color: #f9a8d4; }
body.dark .task-step-badge.step-ready { background: #14532d; color: #86efac; }
body.dark .task-step-badge.step-publish { background: #164e63; color: #67e8f9; }
body.dark .task-step-badge.step-published { background: #14532d; color: #86efac; }

/* === RSS History — Used badges === */

.research-card-used-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  vertical-align: middle;
  margin-left: 4px;
}

.research-card-used-badge.used-manual {
  background: #e0e7ff;
  color: #3730a3;
}

.research-card-used-badge.used-automation {
  background: #fef3c7;
  color: #92400e;
}

body.dark .research-card-used-badge.used-manual {
  background: #312e81;
  color: #a5b4fc;
}

body.dark .research-card-used-badge.used-automation {
  background: #451a03;
  color: #fcd34d;
}

.research-card-used {
  opacity: 0.7;
}

.research-card-used:hover {
  opacity: 1;
}

/* Hide Used toggle in research filters */
.research-filter-toggle {
  margin-top: 8px;
}

.research-filter-toggle .toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #374151;
  cursor: pointer;
  user-select: none;
}

body.dark .research-filter-toggle .toggle-label {
  color: #d1d5db;
}

.research-filter-toggle input[type="checkbox"] {
  width: 14px;
  height: 14px;
  cursor: pointer;
}

/* RSS Used popup */
.rss-used-popup {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 100;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px 16px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  min-width: 220px;
  font-size: 13px;
  margin-top: 4px;
}

body.dark .rss-used-popup {
  background: #1e1e1e;
  border-color: #333;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.rss-used-popup-header {
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 13px;
}

.rss-used-popup-row {
  margin-bottom: 4px;
  font-size: 12px;
  color: #4b5563;
}

body.dark .rss-used-popup-row {
  color: #9ca3af;
}

.rss-used-popup-row strong {
  color: #111827;
}

body.dark .rss-used-popup-row strong {
  color: #e5e7eb;
}

.rss-used-popup-close {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: #9ca3af;
  line-height: 1;
}

.rss-used-popup-close:hover {
  color: #374151;
}

body.dark .rss-used-popup-close:hover {
  color: #e5e7eb;
}
