:root {
  color-scheme: light;
  --bg: #eef3f8;
  --panel: #ffffff;
  --surface-soft: #f5f8fc;
  --surface-accent: #eaf7f6;
  --header-wash: #edfafa;
  --input-bg: #ffffff;
  --ink: #15243a;
  --muted: #617086;
  --line: #ced9e6;
  --accent: #0b8077;
  --accent-dark: #09665f;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --danger: #a72f3c;
  --danger-bg: #fff0f2;
  --ok-bg: #e9f9f1;
  --missing-bg: #fff6dc;
  --shadow: 0 12px 34px rgba(28, 49, 78, 0.08);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #09111f;
  --panel: #111c2d;
  --surface-soft: #162338;
  --surface-accent: #123531;
  --header-wash: #102538;
  --input-bg: #0d1727;
  --ink: #edf4fc;
  --muted: #9baac0;
  --line: #2b3b52;
  --accent: #2dd4bf;
  --accent-dark: #0f8f82;
  --blue: #60a5fa;
  --blue-dark: #3b82f6;
  --danger: #ff9aa5;
  --danger-bg: #3a2028;
  --ok-bg: #12372e;
  --missing-bg: #392f18;
  --shadow: 0 16px 42px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
}

.approval-page { display: grid; place-items: center; padding: 24px; background: #f7f4ed; }
.approval-shell { width: min(520px, 100%); }
.approval-card { padding: 42px 30px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); box-shadow: var(--shadow); text-align: center; }
.approval-symbol { display: grid; place-items: center; width: 68px; height: 68px; margin: 0 auto 20px; border-radius: 50%; background: var(--ok-bg); color: var(--accent); font-size: 34px; font-weight: 850; }
.approval-card.invalid .approval-symbol { background: var(--danger-bg); color: var(--danger); }
.approval-eyebrow { margin: 0 0 8px; color: var(--accent); font-size: 12px; font-weight: 850; letter-spacing: .11em; }
.approval-card h1 { margin: 0; font-size: clamp(30px, 8vw, 44px); }
.approval-card > p:not(.approval-eyebrow) { margin: 14px 0 22px; color: var(--muted); font-size: 16px; }
.approval-card small { color: var(--muted); }

.approval-shell.wide { width: min(920px, 100%); }
.approval-selection-intro { margin-bottom: 20px; padding: 28px 30px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); box-shadow: var(--shadow); }
.approval-selection-intro h1 { margin: 0; font-size: clamp(28px, 6vw, 42px); }
.approval-selection-intro > p { margin: 12px 0 0; color: var(--muted); line-height: 1.65; }
.approval-choice-list { display: grid; gap: 20px; }
.approval-choice-card { overflow: hidden; border: 2px solid color-mix(in srgb, var(--accent) 45%, var(--line)); border-radius: 18px; background: var(--panel); box-shadow: var(--shadow); transition: opacity 160ms ease, border-color 160ms ease; }
.approval-choice-card.is-excluded { border-color: var(--line); opacity: .58; }
.approval-article-choice, .approval-image-control { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.approval-article-choice { padding: 17px 20px; border-bottom: 1px solid var(--line); background: var(--surface-accent); }
.approval-article-choice input, .approval-image-control input { position: absolute; opacity: 0; pointer-events: none; }
.approval-custom-check { display: grid; flex: 0 0 27px; width: 27px; height: 27px; place-items: center; border: 2px solid var(--line); border-radius: 7px; background: var(--input-bg); color: transparent; font-size: 18px; font-weight: 900; }
input:checked + .approval-custom-check { border-color: var(--accent); background: var(--accent); color: #fff; }
input:focus-visible + .approval-custom-check { outline: 3px solid color-mix(in srgb, var(--accent) 30%, transparent); outline-offset: 2px; }
.approval-article-choice strong, .approval-image-control strong { display: block; font-size: 15px; }
.approval-article-choice small, .approval-image-control small { display: block; margin-top: 3px; color: var(--muted); line-height: 1.35; }
.approval-newspaper { margin: 18px 24px 0; color: var(--accent); font-size: 12px; font-weight: 850; letter-spacing: .05em; text-transform: uppercase; }
.approval-preview-title { margin: 12px 24px 18px; font-size: clamp(25px, 5vw, 36px); line-height: 1.15; }
.approval-selection-intro.has-error { border-color: var(--danger); }
.approval-category-editor { margin: 0 24px 20px; padding: 16px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-soft); }
.approval-category-editor.has-error { border-color: var(--danger); }
.approval-category-heading { display: flex; align-items: start; justify-content: space-between; gap: 14px; }
.approval-category-heading strong, .approval-category-heading small { display: block; }
.approval-category-heading small { margin-top: 3px; color: var(--muted); }
.approval-category-heading > span { flex: 0 0 auto; color: var(--muted); font-size: 12px; }
.approval-category-chips { display: flex; flex-wrap: wrap; gap: 7px; margin: 13px 0; }
.approval-category-chips span { padding: 6px 10px; border-radius: 999px; background: color-mix(in srgb, var(--accent) 13%, var(--panel)); color: var(--accent-dark); font-size: 12px; font-weight: 800; }
.approval-category-chips em { color: var(--danger); font-size: 13px; font-style: normal; }
.approval-category-editor details { border-top: 1px solid var(--line); padding-top: 11px; }
.approval-category-editor summary { color: var(--accent); cursor: pointer; font-size: 13px; font-weight: 800; }
.approval-category-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.approval-category-option { display: flex; align-items: center; gap: 9px; min-width: 0; padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); cursor: pointer; }
.approval-category-option:has(input:checked) { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); background: color-mix(in srgb, var(--accent) 8%, var(--panel)); }
.approval-category-option input { flex: 0 0 auto; width: 17px; height: 17px; accent-color: var(--accent); }
.approval-category-option span { overflow-wrap: anywhere; font-size: 13px; }
.approval-category-error { margin: 10px 0 0; color: var(--danger); font-size: 13px; font-weight: 750; }
.approval-article-preview { padding: 10px 24px 20px; line-height: 1.7; }
.approval-article-preview article { margin: 0; }
.approval-article-preview h1 { margin: 8px 0 18px; font-size: clamp(25px, 5vw, 36px); line-height: 1.15; }
.approval-article-preview h2, .approval-article-preview h3 { margin: 22px 0 10px; }
.approval-article-preview p { margin: 0 0 14px; }
.approval-image-choice { display: block; margin: 0 20px 20px; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); cursor: pointer; }
.approval-image-control { padding: 14px 16px; }
.approval-image-choice img { display: block; width: 100%; max-height: 520px; object-fit: contain; background: #f7f4ed; }
.approval-source-note { display: grid; gap: 5px; padding: 0 24px 22px; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.approval-source-note a { color: var(--accent); }
.article-checker-sources { margin-top: 24px; padding: 12px 14px; border-radius: 8px; background: #f8fafc; color: var(--muted); font-size: 13px; line-height: 1.65; }
.article-checker-sources a { color: var(--accent); overflow-wrap: anywhere; }
.approval-submit-bar { position: sticky; z-index: 5; bottom: 14px; display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 22px; padding: 15px 18px; border: 1px solid var(--line); border-radius: 15px; background: color-mix(in srgb, var(--panel) 94%, transparent); box-shadow: 0 14px 40px rgba(28,49,78,.18); backdrop-filter: blur(12px); }
.approval-submit-bar p { margin: 0; color: var(--muted); }
.approval-submit-actions { display: flex; align-items: center; gap: 10px; }
.approval-submit-bar button { min-height: 46px; padding: 0 20px; border: 0; border-radius: 10px; background: var(--accent); color: #fff; font: inherit; font-weight: 850; cursor: pointer; }
.approval-submit-bar button:hover { background: var(--accent-dark); }
.approval-submit-bar .approval-delete-button { border: 1px solid var(--danger); background: var(--danger-bg); color: var(--danger); }
.approval-submit-bar .approval-delete-button:hover { background: var(--danger); color: #fff; }
.approval-submit-bar .approval-save-button { background: #475569; }
.approval-submit-bar .approval-save-button:hover { background: #334155; }
.approval-result-list { display: grid; gap: 10px; margin: 22px 0; padding: 0; list-style: none; text-align: left; }
.approval-result-list li { padding: 13px 15px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); }
.approval-result-list li strong, .approval-result-list li span { display: block; }
.approval-result-list li span { margin-top: 4px; color: var(--muted); font-size: 13px; }
.approval-result-list .approval-draft-status { margin-top: 9px; padding-top: 9px; border-top: 1px solid var(--line); font-weight: 750; }
.approval-result-list .approval-draft-status.completed { color: var(--ok); }
.approval-result-list .approval-draft-status.failed { color: var(--danger); }
.approval-result-list .approval-draft-status.publishing { color: var(--accent); }
.approval-draft-status a { display: inline-block; margin-left: 5px; color: var(--accent); }
.approval-retry-form { margin: 18px 0; }
.approval-retry-form button { min-height: 44px; padding: 0 18px; border: 0; border-radius: 9px; background: var(--accent); color: #fff; font: inherit; font-weight: 850; cursor: pointer; }
.approval-retry-form button:hover { background: var(--accent-dark); }
.approval-result-list li.rejected { border-color: color-mix(in srgb, var(--danger) 30%, var(--line)); }

@media (max-width: 620px) {
  .approval-page { padding: 12px; }
  .approval-selection-intro { padding: 22px 18px; }
  .approval-article-preview { padding-inline: 17px; }
  .approval-preview-title { margin-inline: 17px; }
  .approval-category-editor { margin-inline: 12px; }
  .approval-category-heading { display: block; }
  .approval-category-heading > span { display: block; margin-top: 8px; }
  .approval-category-options { grid-template-columns: 1fr; }
  .approval-image-choice { margin-inline: 12px; }
  .approval-source-note { padding-inline: 17px; }
  .approval-submit-bar { align-items: stretch; flex-direction: column; bottom: 8px; }
  .approval-submit-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .approval-submit-bar button { width: 100%; }
}

.quota-limit-toast {
  position: fixed;
  z-index: 1000;
  top: 18px;
  left: 50%;
  width: max-content;
  max-width: calc(100vw - 32px);
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 16px;
  border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
  border-radius: 8px;
  background: var(--danger-bg);
  color: var(--danger);
  box-shadow: var(--shadow);
  font-size: 14px;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.quota-limit-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.quota-limit-toast svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
  display: grid;
  gap: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.control-panel {
  position: relative;
  background: linear-gradient(180deg, var(--header-wash) 0, var(--panel) 215px);
}

.control-panel::before {
  position: absolute;
  top: -1px;
  right: -1px;
  left: -1px;
  height: 5px;
  border-radius: 8px 8px 0 0;
  background: linear-gradient(90deg, var(--accent), #06b6d4 48%, var(--blue));
  content: "";
}

.shell > .panel:not(.control-panel) { border-top: 3px solid var(--blue); }

.heading,
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.product-identity {
  display: grid;
  gap: 3px;
}

.product-heading {
  position: relative;
  justify-content: center;
  min-height: 116px;
  padding: 10px 150px 14px;
  text-align: center;
}

.product-heading .product-identity {
  width: 100%;
  justify-items: center;
}

.company-brand {
  width: fit-content;
  background: linear-gradient(135deg, #22d3ee 0%, #3b7984 45%, #818cf8 100%);
  background-clip: text;
  color: transparent;
  font-size: 44px;
  font-weight: 900;
  line-height: 1;
  text-decoration: none;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.company-brand:hover {
  filter: brightness(0.88) saturate(1.15);
}

.journal-title {
  background: linear-gradient(135deg, #0891b2 0%, #3b7984 48%, #6366f1 100%);
  background-clip: text;
  color: transparent;
  font-size: 31px;
  font-weight: 850;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.product-subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

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

.product-heading .heading-actions {
  position: absolute;
  top: 10px;
  right: 0;
}

.account-session {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
}

.account-session > span { display: grid; text-align: right; }
.account-session strong { max-width: 150px; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.account-session small { color: var(--muted); font-size: 10px; }
.header-logout-form { margin: 0; }

.logout-button {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--danger);
  cursor: pointer;
}

.logout-button:hover { border-color: #d99890; background: var(--danger-bg); }
.logout-button svg { width: 17px; height: 17px; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-shell { width: min(420px, 100%); }
.login-panel { padding: 28px; border: 1px solid var(--line); border-top: 4px solid var(--accent); border-radius: 8px; background: var(--panel); box-shadow: var(--shadow); }
.login-panel header { margin-bottom: 24px; text-align: center; }
.login-panel header p { margin: 0; color: var(--accent); font-size: 14px; font-weight: 900; }
.login-panel header h1 { margin: 5px 0; font-size: 32px; }
.login-panel header span { color: var(--muted); font-size: 14px; }
.login-form { display: grid; gap: 16px; }
.login-form label { display: grid; gap: 7px; }
.login-form label span { color: var(--muted); font-size: 13px; font-weight: 750; }
.login-form button { min-height: 44px; border: 0; border-radius: 6px; background: var(--accent); color: #fff; font: inherit; font-weight: 850; cursor: pointer; }
.login-form button:hover { background: var(--accent-dark); }
.password-input-wrap { position: relative; }
.password-input-wrap input { padding-right: 46px; }
.login-form .password-toggle {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 40px;
  height: 40px;
  min-height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0 5px 5px 0;
  background: transparent;
  color: var(--muted);
}
.login-form .password-toggle:hover { background: var(--soft); color: var(--accent-dark); }
.login-form .password-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }
.password-toggle svg { width: 18px; height: 18px; }
.password-icon-hide { display: none; }
.password-toggle[aria-pressed="true"] .password-icon-show { display: none; }
.password-toggle[aria-pressed="true"] .password-icon-hide { display: block; }
.login-error { margin-bottom: 16px; padding: 11px 12px; border: 1px solid #efb1a8; border-radius: 6px; background: var(--danger-bg); color: var(--danger); font-size: 13px; }

.manual-button,
.manual-close,
.theme-toggle {
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--accent-dark);
  cursor: pointer;
}

.manual-button {
  height: 38px;
  grid-template-columns: 18px auto;
  gap: 7px;
  padding: 0 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
}

.manual-button:hover,
.manual-close:hover,
.theme-toggle:hover {
  border-color: var(--accent);
  background: var(--surface-accent);
}

.manual-button svg,
.manual-close svg,
.theme-toggle svg {
  width: 18px;
  height: 18px;
}

.theme-toggle {
  width: 38px;
  height: 38px;
  padding: 0;
}

.theme-icon-dark { display: none; }
html[data-theme="dark"] .theme-icon-light { display: none; }
html[data-theme="dark"] .theme-icon-dark { display: block; }
.login-theme-toggle { position: fixed; top: 20px; right: 20px; }

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  font-size: 18px;
}

.manual-dialog {
  width: min(680px, calc(100% - 32px));
  max-height: min(760px, calc(100vh - 32px));
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 24px 70px rgba(20, 31, 34, 0.28);
}

.manual-dialog::backdrop {
  background: rgba(20, 31, 34, 0.58);
}

.manual-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}

.manual-header span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.manual-header h2 {
  margin-top: 4px;
  font-size: 22px;
}

.manual-close {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
}

.manual-content {
  max-height: calc(100vh - 150px);
  padding: 4px 22px 20px;
  overflow-y: auto;
}

.manual-content ol {
  margin: 0;
  padding-left: 24px;
}

.manual-content li {
  padding: 14px 4px;
  border-bottom: 1px solid var(--line);
  line-height: 1.5;
}

.manual-content li:last-child {
  border-bottom: 0;
}

.status {
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status.good {
  background: var(--ok-bg);
  color: #17613a;
}

.status.bad {
  background: var(--missing-bg);
  color: #755000;
}

.notice {
  margin-bottom: 16px;
  padding: 10px 12px;
  background: var(--missing-bg);
  border: 1px solid #edd188;
  border-radius: 6px;
  color: #684a00;
}

.crawler-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.field.full {
  grid-column: 1 / -1;
}

.field,
.output-block {
  display: grid;
  gap: 6px;
}

.tag-input-list {
  display: grid;
  gap: 8px;
}

.tag-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 8px;
}

.tag-input-action {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--accent-dark);
  cursor: pointer;
}

.tag-input-action:hover {
  border-color: var(--accent);
  background: var(--surface-accent);
}

.tag-input-action:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.tag-input-action:disabled:hover {
  border-color: var(--line);
  background: var(--input-bg);
}

.tag-input-action svg {
  width: 18px;
  height: 18px;
}

.field-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 22px;
  position: relative;
}

.field-title { display: flex; align-items: baseline; gap: 8px; }
.field-title small { color: var(--accent-dark); font-size: 11px; font-weight: 800; }

.field-header span,
.output-block span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.info-popover {
  position: relative;
}

.info-popover summary {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--accent);
  background: var(--input-bg);
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  list-style: none;
}

.info-popover summary::-webkit-details-marker {
  display: none;
}

.info-popover[open] summary {
  border-color: var(--accent);
  background: var(--surface-accent);
}

.info-popover p {
  position: absolute;
  top: 26px;
  right: 0;
  z-index: 10;
  width: min(260px, calc(100vw - 44px));
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: 0 12px 28px rgba(29, 37, 40, 0.14);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--ink);
  font: inherit;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: 0;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

input,
select {
  height: 42px;
  padding: 0 10px;
}

input:disabled {
  background: #f1f4f2;
  color: #8a9492;
  cursor: not-allowed;
}

input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
}

.checkbox-field {
  align-self: stretch;
  justify-content: end;
}

.checkbox-field > input {
  margin: 0;
}

textarea {
  min-height: 260px;
  padding: 12px;
  resize: vertical;
  line-height: 1.45;
}

textarea.json {
  min-height: 220px;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.action-buttons {
  display: flex;
  gap: 8px;
}

.quota-allowance {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
}

.quota-allowance svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.quota-allowance.depleted { color: var(--danger); }

.run-button {
  height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 7px 16px color-mix(in srgb, var(--accent) 18%, transparent);
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.run-button:hover {
  background: var(--accent-dark);
  box-shadow: 0 9px 20px color-mix(in srgb, var(--accent) 26%, transparent);
  transform: translateY(-1px);
}

.run-button.secondary {
  background: var(--blue);
  box-shadow: 0 7px 18px color-mix(in srgb, var(--blue) 24%, transparent);
}

.run-button.secondary:hover {
  background: var(--blue-dark);
}

.run-button.tag-search {
  border: 1px solid var(--accent);
  background: var(--input-bg);
  color: var(--accent-dark);
  box-shadow: none;
}

.run-button.tag-search:hover {
  background: var(--surface-accent);
}

.run-button:disabled {
  background: #86aaa5;
  cursor: wait;
  box-shadow: none;
  transform: none;
}

.client-status {
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  border-left: 4px solid var(--accent);
  border-radius: 7px;
  background: var(--surface-accent);
  color: var(--ink);
}

.client-status[data-phase="complete"] { border-left-color: #16a06f; }
.client-status[data-phase="cancelling"],
.client-status[data-phase="cancelled"] {
  border-color: #d69a35;
  background: color-mix(in srgb, #d69a35 12%, var(--panel));
}
.client-status[data-phase="failed"] { border-color: var(--danger); background: var(--danger-bg); }

.crawl-progress-heading { display: flex; align-items: center; gap: 12px; }
.crawl-progress-heading > div { flex: 1 1 auto; min-width: 0; }
.crawl-progress-heading strong { display: block; font-size: 15px; }
.crawl-progress-heading p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }

.crawl-stop-button {
  flex: 0 0 auto;
  min-width: 84px;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 11px;
  border: 1px solid color-mix(in srgb, var(--danger) 50%, var(--line));
  border-radius: 6px;
  background: var(--panel);
  color: var(--danger);
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}

.crawl-stop-button svg { width: 14px; height: 14px; fill: currentColor; }
.crawl-stop-button[hidden] { display: none; }
.crawl-stop-button:hover { border-color: var(--danger); background: var(--danger-bg); }
.crawl-stop-button:disabled { cursor: wait; opacity: 0.72; }
.crawl-stop-button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--danger) 22%, transparent);
  outline-offset: 2px;
}

.crawl-progress-spinner {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  border: 3px solid color-mix(in srgb, var(--accent) 24%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: crawl-spin 850ms linear infinite;
}

.client-status[data-phase="complete"] .crawl-progress-spinner,
.client-status[data-phase="failed"] .crawl-progress-spinner,
.client-status[data-phase="cancelled"] .crawl-progress-spinner { animation: none; border-color: currentColor; }

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

.crawl-url-stage {
  position: relative;
  margin: 14px 0 0 32px;
  padding: 12px 14px 12px 34px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: color-mix(in srgb, var(--panel) 78%, transparent);
}

.crawl-url-stage::before {
  position: absolute;
  top: 50%;
  left: 15px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent);
  content: "";
  transform: translateY(-50%);
}

.crawl-url-stage > span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  text-transform: uppercase;
}

.crawl-current-url {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crawl-url-stage.is-changing .crawl-current-url {
  animation: current-url-change 420ms ease-out;
}

@keyframes current-url-change {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.metrics div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
}

.metrics strong {
  display: block;
  font-size: 22px;
}

.metrics span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.ai-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.ai-meta span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.tag-terms {
  margin: 0 0 16px;
}

.tag-terms > strong {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
}

.tag-terms > div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-terms span {
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.grounding-sources {
  margin: 0 0 16px;
}

.grounding-sources h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.grounding-sources ul {
  margin: 0;
  padding-left: 20px;
}

.grounding-sources a {
  color: var(--accent-dark);
  overflow-wrap: anywhere;
}

.direct-answer {
  margin: 0 0 16px;
  padding: 14px;
  border-left: 3px solid var(--accent);
  background: var(--surface-soft);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.55;
}

.crawled-results {
  margin-bottom: 20px;
}

.crawled-results-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.crawled-results-heading h3 {
  margin: 0;
  font-size: 15px;
}

.crawled-results-heading span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.crawled-results-counts {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tag-result-group {
  padding: 18px 0 24px;
  border-top: 2px solid var(--line);
}

.tag-result-group:first-of-type {
  border-top-color: var(--accent);
}

.tag-result-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.tag-result-heading h4 {
  margin: 2px 0 0;
  color: var(--ink);
  font-size: 20px;
  letter-spacing: 0;
}

.tag-result-heading > span,
.tag-result-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.tag-result-label {
  text-transform: uppercase;
}

.tag-result-urls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.tag-result-urls span {
  max-width: 100%;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.tag-result-empty {
  margin: 0;
  padding: 18px 0;
  color: var(--muted);
}

.selection-error {
  margin: -2px 0 10px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 800;
}

.crawled-articles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}

.crawled-article {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.crawled-article[open] {
  grid-column: 1 / -1;
  border-color: #aac9c5;
}

.crawled-article.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(28, 118, 111, 0.14);
}

.crawled-article-summary {
  position: relative;
  display: block;
  min-width: 0;
  cursor: pointer;
  list-style: none;
}

.crawled-article-summary::-webkit-details-marker {
  display: none;
}

.crawled-article-summary:focus-visible {
  outline: 3px solid rgba(28, 118, 111, 0.3);
  outline-offset: -3px;
}

.article-select-control {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  width: 32px;
  height: 32px;
  cursor: pointer;
}

.article-select-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.article-select-control span {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 2px solid #fff;
  border-radius: 50%;
  background: rgba(29, 37, 40, 0.78);
  box-shadow: 0 1px 6px rgba(29, 37, 40, 0.24);
  color: transparent;
}

.article-select-control svg {
  width: 18px;
  height: 18px;
}

.article-select-control input:checked + span {
  background: var(--accent);
  color: #fff;
}

.article-select-control input:focus-visible + span {
  outline: 3px solid rgba(28, 118, 111, 0.32);
  outline-offset: 2px;
}

.article-select-control input:disabled + span {
  cursor: not-allowed;
  opacity: 0.45;
}

.crawled-article-media {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #e8ece9;
}

.crawled-article-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.crawled-article-body {
  position: relative;
  display: block;
  padding: 14px;
  padding-right: 48px;
}

.crawled-article-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.crawled-article-title {
  display: block;
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.crawled-article-description {
  display: -webkit-box;
  margin-top: 8px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.crawled-article-toggle {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--input-bg);
  color: var(--accent-dark);
}

.crawled-article-toggle svg {
  width: 17px;
  height: 17px;
  transition: transform 160ms ease;
}

.crawled-article[open] .crawled-article-toggle svg {
  transform: rotate(180deg);
}

.crawled-article[open] .crawled-article-summary {
  display: grid;
  grid-template-columns: minmax(260px, 38%) minmax(0, 1fr);
  align-items: stretch;
}

.crawled-article[open] .crawled-article-media {
  height: 100%;
  min-height: 220px;
  aspect-ratio: auto;
}

.crawled-article[open] .crawled-article-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 22px 56px 22px 22px;
}

.crawled-article-content {
  padding: 24px;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
}

.crawled-article-content > * {
  max-width: 820px;
  margin-left: auto;
  margin-right: auto;
}

.crawled-article-content p {
  margin-top: 0;
  margin-bottom: 16px;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.7;
}

.crawled-article-content h4 {
  margin-top: 28px;
  margin-bottom: 10px;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.3;
}

.crawled-article-content h4:first-child {
  margin-top: 0;
}

.crawled-article-content blockquote {
  margin-top: 20px;
  margin-bottom: 20px;
  padding: 12px 16px;
  border-left: 3px solid var(--accent);
  background: var(--surface-accent);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.65;
}

.article-list-item {
  position: relative;
  padding-left: 20px;
}

.article-list-item::before {
  position: absolute;
  left: 3px;
  top: 0.72em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  content: "";
}

.crawled-article-content .article-caption {
  color: var(--muted);
  font-size: 13px;
  font-style: italic;
}

.article-plain-text {
  white-space: pre-line;
}

.article-source-link {
  display: block;
  width: fit-content;
  margin-top: 24px;
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 800;
}

.generated-articles {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.journal-results {
  margin-bottom: 22px;
  padding-bottom: 8px;
  border-bottom: 2px solid #c9d9ee;
}

.ai-production-notice {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  padding: 15px 16px;
  border: 1px solid #75a7e8;
  border-left: 4px solid #1269d3;
  border-radius: 7px;
  background: #edf5ff;
  color: #123b72;
}

.ai-production-icon {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #1269d3;
  color: #fff;
}

.ai-production-icon svg {
  width: 20px;
  height: 20px;
}

.ai-production-notice strong {
  display: block;
  font-size: 14px;
  line-height: 1.35;
}

.ai-production-notice p {
  margin: 3px 0 0;
  color: #315b8e;
  font-size: 13px;
  line-height: 1.4;
}

.journal-results-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  margin-bottom: 12px;
}

.journal-results-heading span {
  grid-column: 1;
  color: #3b7984;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.journal-results-heading h2 {
  grid-column: 1;
  margin-top: 2px;
  font-size: 22px;
}

.generated-collection-actions {
  grid-column: 2;
  grid-row: 1 / 3;
  display: flex;
  align-items: center;
  gap: 8px;
}

.generated-collection-actions form {
  margin: 0;
}

.generated-article-count {
  min-width: 36px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  font-size: 13px;
  text-align: center;
}

.remove-all-generated-articles {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border: 1px solid color-mix(in srgb, var(--danger) 38%, var(--line));
  border-radius: 6px;
  background: var(--panel);
  color: var(--danger);
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}

.remove-all-generated-articles svg {
  width: 15px;
  height: 15px;
}

.remove-all-generated-articles:hover {
  border-color: var(--danger);
  background: var(--danger-bg);
}

.remove-all-generated-articles:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--danger) 22%, transparent);
  outline-offset: 2px;
}

.journal-result-message {
  margin-bottom: 16px;
}

.generated-article {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  line-height: 1.65;
}

.generated-article-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 36px;
  margin-bottom: 12px;
}

.generated-article-toolbar .article-marker {
  margin-bottom: 0;
}

.generated-article-toolbar form {
  flex: 0 0 auto;
  margin: 0;
}

.remove-generated-article {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--danger) 38%, var(--line));
  border-radius: 6px;
  background: var(--panel);
  color: var(--danger);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.remove-generated-article svg {
  width: 17px;
  height: 17px;
}

.remove-generated-article:hover {
  border-color: var(--danger);
  background: var(--danger-bg);
}

.remove-generated-article:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--danger) 22%, transparent);
  outline-offset: 2px;
}

.article-marker {
  margin-bottom: 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.image-ai-blocked {
  width: min(100%, 820px);
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid #efb1a8;
  border-radius: 6px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.45;
}

.generated-article-images {
  display: grid;
  gap: 12px;
  margin: 0 0 18px;
}

.generated-article-images figure {
  width: min(100%, 820px);
  margin: 0;
  overflow: hidden;
  border-radius: 6px;
  background: #e8eef3;
  aspect-ratio: 16 / 9;
}

.generated-article-images img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-ai-warning {
  margin: 0 0 16px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 800;
}

.generated-article h1 {
  margin: 0 0 18px;
  max-width: 780px;
  font-size: 30px;
  line-height: 1.18;
}

.generated-article h2 {
  margin: 24px 0 8px;
  font-size: 19px;
  line-height: 1.25;
}

.generated-article p {
  margin: 0 0 14px;
  max-width: 820px;
}

.generated-article ul {
  margin: 0 0 16px 20px;
  max-width: 820px;
  padding: 0;
}

.generated-article li + li {
  margin-top: 6px;
}

.generated-article blockquote {
  margin: 20px 0;
  max-width: 820px;
  padding: 12px 16px;
  border-left: 3px solid var(--accent);
  background: var(--surface-accent);
  color: var(--ink);
  line-height: 1.65;
}

.generated-article a,
.crawled-article-content a {
  color: var(--accent-dark);
  overflow-wrap: anywhere;
}

.generated-article strong,
.crawled-article-content strong {
  font-weight: 800;
}

.generated-article em,
.crawled-article-content em {
  font-style: italic;
}

.generated-article figcaption {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  font-style: italic;
}

.generated-source-link {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  font-weight: 850;
}

.generated-source-link svg { width: 16px; height: 16px; }

.output-block + .output-block {
  margin-top: 16px;
}

.error {
  margin: 0;
  white-space: pre-wrap;
  background: var(--danger-bg);
  border: 1px solid #efb1a8;
  border-radius: 6px;
  color: var(--danger);
  padding: 12px;
  overflow: auto;
}

.topic-search-notice {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, #d69e2e 55%, var(--line));
  border-radius: 6px;
  background: var(--missing-bg);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

.topic-search-notice svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  color: #b7791f;
}

.empty {
  min-height: 180px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 6px;
}

html[data-theme="dark"] .status.good { color: #78e3b2; }
html[data-theme="dark"] .status.bad,
html[data-theme="dark"] .notice { color: #f5d277; }
html[data-theme="dark"] input:disabled { background: #182338; color: #728198; }
html[data-theme="dark"] .run-button.secondary { background: var(--blue); color: #071221; }
html[data-theme="dark"] .run-button.secondary:hover { background: #93c5fd; }
html[data-theme="dark"] .crawled-article-media,
html[data-theme="dark"] .generated-article-images figure { background: #0a1424; }
html[data-theme="dark"] .crawled-article[open] { border-color: var(--accent); }
html[data-theme="dark"] .journal-results { border-bottom-color: var(--line); }
html[data-theme="dark"] .ai-production-notice {
  border-color: #356aa8;
  border-left-color: var(--blue);
  background: #122844;
  color: #e5f1ff;
}
html[data-theme="dark"] .ai-production-icon { background: var(--blue); color: #071221; }
html[data-theme="dark"] .ai-production-notice p { color: #a9c9ee; }
html[data-theme="dark"] .journal-results-heading span { color: var(--accent); }
html[data-theme="dark"] .error,
html[data-theme="dark"] .image-ai-blocked,
html[data-theme="dark"] .login-error { border-color: #7d3c48; }

@media (prefers-reduced-motion: reduce) {
  .crawl-progress-spinner { animation-duration: 1.8s; }
  html { scroll-behavior: auto; }
}

@media (max-width: 980px) {
  .crawler-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .field.full,
  .form-actions,
  .run-button {
    grid-column: 1 / -1;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .crawled-articles {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding: 10px 0;
  }

  .panel {
    padding: 14px;
  }

  .heading,
  .section-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .heading-actions {
    width: 100%;
    display: flex;
    justify-content: flex-start;
  }

  .heading-actions > .status { display: none; }

  .product-heading {
    min-height: 0;
    padding: 6px 0 0;
  }

  .product-heading .heading-actions {
    position: static;
  }

  .account-session { display: none; }
  .header-logout-form { margin-left: auto; }
  .crawl-url-stage { margin-left: 0; }

  .company-brand {
    font-size: 34px;
  }

  .journal-title {
    font-size: 28px;
  }

  .manual-header,
  .manual-content {
    padding-left: 16px;
    padding-right: 16px;
  }

  .crawled-results-heading {
    align-items: flex-start;
  }

  .crawled-results-counts {
    align-items: flex-end;
    flex-direction: column;
    gap: 2px;
  }

  .crawler-form,
  .metrics,
  .form-actions {
    grid-template-columns: 1fr;
  }

  .form-actions {
    display: grid;
  }

  .action-buttons {
    display: grid;
    grid-template-columns: 1fr;
  }

  .journal-results-heading {
    grid-template-columns: minmax(0, 1fr);
  }

  .generated-collection-actions {
    grid-column: 1;
    grid-row: auto;
    justify-content: space-between;
    margin-top: 10px;
  }

  .crawled-article-meta {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

  .crawled-article[open] .crawled-article-summary {
    display: block;
  }

  .crawled-article[open] .crawled-article-media {
    height: auto;
    min-height: 0;
    aspect-ratio: 16 / 9;
  }

  .crawled-article[open] .crawled-article-body {
    padding: 14px 48px 14px 14px;
  }

  .crawled-article-content {
    padding: 18px 14px;
  }

  .crawled-article-content p {
    font-size: 15px;
  }
}
