:root {
  color-scheme: light;
  --bg: #f4f6f9;
  --panel: #ffffff;
  --text: #172033;
  --muted: #667085;
  --border: #dbe2ea;
  --border-strong: #c7d0dd;
  --blue: #2563eb;
  --blue-soft: #eff6ff;
  --green: #0e9f6e;
  --green-soft: #ecfdf5;
  --red: #d64545;
  --red-soft: #fef2f2;
  --amber: #b7791f;
  --amber-soft: #fff7ed;
  --ink-soft: #f8fafc;
  --shadow: 0 10px 26px rgba(25, 38, 64, 0.08);
  --shadow-soft: 0 8px 18px rgba(25, 38, 64, 0.06);
  --sticky-header-height: 72px;
  --sticky-log-height: 98px;
  --sticky-result-head-height: 64px;
  --sticky-activity-height: 0px;
  --sticky-gap: 10px;
  --sticky-result-top: calc(var(--sticky-header-height) + var(--sticky-log-height) + (var(--sticky-gap) * 2));
  --sticky-table-head-top: calc(var(--sticky-result-top) + var(--sticky-result-head-height) + var(--sticky-activity-height));
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

body.modal-open {
  overflow: hidden;
}

.shell {
  width: min(1480px, calc(100vw - 40px));
  margin: 22px auto 40px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 18;
  isolation: isolate;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
  padding: 12px 3px;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.app-header::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  z-index: -1;
  width: 100vw;
  transform: translateX(-50%);
  background: rgba(244, 246, 249, 0.96);
  box-shadow: 0 1px 0 rgba(199, 208, 221, 0.72);
  pointer-events: none;
}

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

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

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

h2 {
  font-size: 17px;
}

h3 {
  font-size: 14px;
}

.header-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.header-badges span,
.section-head span,
.chart-head span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: #42526b;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.header-badges .guide-trigger {
  width: auto;
  min-height: 28px;
  padding: 4px 11px;
  border-color: rgba(37, 99, 235, 0.35);
  border-radius: 999px;
  background: var(--blue-soft);
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.header-badges .guide-trigger:hover {
  border-color: rgba(37, 99, 235, 0.7);
  background: #dbeafe;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 16px;
  align-items: stretch;
}

.query-panel,
.insight-panel,
.table-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.query-panel,
.insight-panel {
  padding: 18px;
}

.query-panel {
  display: flex;
  flex-direction: column;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.form-grid,
.action-row {
  display: grid;
  gap: 12px;
}

.form-grid {
  grid-template-columns: 180px minmax(220px, 1fr) 150px 110px;
  gap: 10px;
  margin-bottom: 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea,
button {
  width: 100%;
  border-radius: 8px;
  font: inherit;
  letter-spacing: 0;
}

input,
select,
textarea {
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text);
  outline: none;
  padding: 10px 12px;
  font-weight: 650;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

textarea {
  min-height: 256px;
  resize: vertical;
  line-height: 1.55;
}

.keyword-field {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
}

.keyword-field label {
  width: max-content;
}

.keyword-actions {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: -4px;
}

.preset-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.preset-tools select {
  width: 210px;
  height: 36px;
  min-height: 36px;
  padding: 7px 10px;
  border-color: #d9e1ec;
  color: #64748b;
  font-size: 12px;
  font-weight: 750;
}

.preset-tools button {
  width: auto;
  min-width: 58px;
  height: 36px;
  min-height: 36px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
  color: #b91c1c;
  border-color: #e2e8f0;
  background: #fff;
}

.save-preset-button {
  width: auto;
  min-width: 82px;
  min-height: 36px;
  padding: 0 12px;
  color: #2563eb;
  border-color: #d9e1ec;
  background: #f8fbff;
  font-size: 12px;
  font-weight: 800;
}

.save-preset-button:hover {
  border-color: rgba(37, 99, 235, 0.72);
  background: #dbeafe;
}

.check {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: auto;
  padding: 0 13px;
  border: 1px solid #d9e1ec;
  border-radius: 8px;
  color: #536174;
  background: #f8fbff;
  cursor: pointer;
  font-weight: 850;
  user-select: none;
}

.check.active {
  border-color: var(--blue);
  background: #f1f7ff;
  color: #1d55d8;
}

.check input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.check span {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.check span::before {
  content: "";
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  border: 1.5px solid #cbd5e1;
  border-radius: 5px;
  background: #fff;
  box-shadow: inset 0 1px 1px rgba(25, 38, 64, 0.04);
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.check span::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 50%;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  opacity: 0;
  transform: translateY(-58%) rotate(45deg) scale(0.72);
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.check.active span::before {
  border-color: var(--blue);
  background: var(--blue);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.check.active span::after {
  opacity: 1;
  transform: translateY(-58%) rotate(45deg) scale(1);
}

.check:has(input:focus-visible) {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.action-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.action-zone {
  position: relative;
  margin-top: auto;
  padding-top: 18px;
}

.action-zone::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 1px;
  background: var(--border);
}

.action-row button {
  width: auto;
  padding: 0 18px;
}

#pluginGuide {
  width: max-content;
  white-space: nowrap;
}

#run {
  min-width: 152px;
  min-height: 48px;
  font-size: 16px;
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.18);
}

#run:hover {
  border-color: #1d4ed8;
  background: #1d4ed8;
  box-shadow: 0 12px 26px rgba(37, 99, 235, 0.24);
}

#clear {
  min-width: 82px;
  border-color: transparent;
  background: transparent;
  color: #64748b;
}

#clear:hover {
  border-color: #dbe2ea;
  background: #f8fafc;
  color: #334155;
}

button {
  min-height: 46px;
  border: 1px solid var(--border-strong);
  cursor: pointer;
  font-weight: 850;
}

button:disabled {
  cursor: wait;
  opacity: 0.75;
}

button.is-running-auto,
button.is-running-auto:disabled {
  position: relative;
  overflow: hidden;
  border-color: #0891b2;
  background:
    radial-gradient(circle at 18% 45%, rgba(255, 255, 255, 0.32), transparent 30%),
    linear-gradient(115deg, #1d4ed8 0%, #0891b2 34%, #10b981 64%, #2563eb 100%);
  background-size: 180% 180%, 240% 240%;
  color: #fff;
  opacity: 1;
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.14), 0 10px 24px rgba(37, 99, 235, 0.22);
  animation:
    autoButtonAurora 5.2s ease-in-out infinite alternate,
    autoButtonPulse 2.9s ease-in-out infinite;
}

#run.is-running-auto,
#run.is-running-auto:disabled {
  border-color: #0891b2;
  background:
    radial-gradient(circle at 18% 45%, rgba(255, 255, 255, 0.32), transparent 30%),
    linear-gradient(115deg, #1d4ed8 0%, #0891b2 34%, #10b981 64%, #2563eb 100%);
  background-size: 180% 180%, 240% 240%;
  color: #fff;
}

button.is-running-auto::before {
  content: "";
  position: absolute;
  inset: -36%;
  pointer-events: none;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.22) 0 8%, rgba(6, 182, 212, 0.2) 18%, transparent 42%);
  opacity: 0;
  transform: scale(0.62);
  animation: autoButtonDiffuse 2.9s ease-out infinite;
}

button.is-running-auto::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(105deg, transparent 0 20%, rgba(255, 255, 255, 0.22) 42%, transparent 64% 100%);
  transform: translateX(-120%);
  animation: autoButtonGlow 4.4s ease-in-out infinite;
}

.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.secondary {
  background: #fff;
  color: #445166;
}

.plugin-inline-status {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  margin-top: 11px;
  padding: 8px 11px;
  border: 1px solid #dbe2ea;
  border-radius: 8px;
  background: #f8fafc;
  color: #536174;
  box-shadow: var(--shadow-soft);
}

.plugin-inline-status strong {
  color: #334155;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.plugin-inline-status small {
  overflow: hidden;
  color: #667085;
  font-size: 12px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.plugin-state-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border-radius: 50%;
  background: #94a3b8;
  box-shadow: 0 0 0 4px rgba(148, 163, 184, 0.14);
}

.plugin-inline-status.connected {
  border-color: rgba(14, 159, 110, 0.22);
  background: #f0fdf4;
}

.plugin-inline-status.connected .plugin-state-dot {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(14, 159, 110, 0.13);
}

.plugin-inline-status.connected strong {
  color: #087a56;
}

.plugin-inline-status.warning {
  border-color: rgba(183, 121, 31, 0.24);
  background: #fffbeb;
}

.plugin-inline-status.warning .plugin-state-dot {
  background: #d97706;
  box-shadow: 0 0 0 4px rgba(217, 119, 6, 0.13);
}

.plugin-inline-status.warning strong {
  color: #a15c07;
}

.plugin-inline-status.checking .plugin-state-dot {
  animation: pluginStatusPulse 1.6s ease-in-out infinite;
}

.plugin-inline-status.disconnected {
  border-color: rgba(214, 69, 69, 0.2);
  background: #fef2f2;
}

.plugin-inline-status.disconnected .plugin-state-dot {
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(214, 69, 69, 0.12);
}

.plugin-inline-status.disconnected strong {
  color: #b91c1c;
}

.danger-text {
  color: var(--red);
}

.progress {
  position: relative;
  height: 18px;
  margin-top: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: #e3e8f0;
}

#bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2563eb, #22a6f2);
  transition: width 180ms ease;
}

#progressText {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  padding-left: 9px;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

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

.metric {
  min-height: 76px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--ink-soft);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.metric strong {
  display: block;
  margin-top: 8px;
  color: var(--text);
  font-size: 25px;
  line-height: 1;
}

.chart-wrap {
  position: relative;
  margin-top: 16px;
  min-height: 310px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 14px 0;
}

.rank-chart {
  width: 100%;
  height: 268px;
}

.rank-chart.fallback-chart {
  height: 268px;
  padding: 14px;
  overflow: auto;
}

.fallback-label {
  overflow: hidden;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fallback-bars {
  display: grid;
  gap: 12px;
  min-height: 238px;
  align-content: center;
}

.fallback-bar-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 28px;
  align-items: center;
  gap: 10px;
}

.fallback-track {
  height: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: #eef2f7;
}

.fallback-track span {
  display: block;
  min-width: 2px;
  height: 100%;
  border-radius: inherit;
}

.chart-empty {
  position: absolute;
  inset: 52px 12px 12px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
}

.chart-wrap.has-data .chart-empty {
  display: none;
}

.log-panel {
  position: sticky;
  top: calc(var(--sticky-header-height) + var(--sticky-gap));
  z-index: 16;
  margin-top: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  -webkit-backdrop-filter: blur(14px) saturate(1.08);
  backdrop-filter: blur(14px) saturate(1.08);
  box-shadow: var(--shadow);
  transition: background-color 0.18s ease, backdrop-filter 0.18s ease;
}

body.page-scrolled .log-panel {
  background: rgba(255, 255, 255, 0.9);
  -webkit-backdrop-filter: blur(14px) saturate(1.08);
  backdrop-filter: blur(14px) saturate(1.08);
}

.log-head {
  margin: 0;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.run-log {
  max-height: 190px;
  overflow: auto;
  background: rgba(251, 252, 254, 0.9);
  transition: background-color 0.18s ease;
}

body.page-scrolled .run-log {
  background: rgba(251, 252, 254, 0.9);
}

.log-empty {
  padding: 22px 18px;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.log-row {
  display: grid;
  grid-template-columns: 76px 54px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 11px 18px 11px 15px;
  border-left: 3px solid transparent;
  border-bottom: 1px solid var(--border);
}

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

.log-time {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.log-level {
  display: inline-flex;
  justify-content: center;
  min-height: 24px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #eef2f7;
  color: #536174;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.log-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.log-copy strong {
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
}

.log-copy span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.45;
  word-break: break-word;
}

.log-row.success .log-level {
  background: var(--green-soft);
  color: var(--green);
}

.log-row.success {
  border-left-color: var(--green);
  background: rgba(236, 253, 245, 0.42);
}

.log-row.warning .log-level {
  background: var(--amber-soft);
  color: var(--amber);
}

.log-row.warning {
  border-left-color: #d97706;
  background: rgba(255, 247, 237, 0.52);
}

.log-row.error .log-level {
  background: var(--red-soft);
  color: var(--red);
}

.log-row.error {
  border-left-color: var(--red);
  background: rgba(254, 242, 242, 0.58);
}

.table-panel {
  --table-frame-border: var(--border);
  position: relative;
  margin-top: 16px;
  overflow: visible;
}

.table-panel.is-running {
  --table-frame-border: rgba(37, 99, 235, 0.46);
  border-color: rgba(37, 99, 235, 0.46);
  box-shadow: 0 12px 30px rgba(37, 99, 235, 0.12);
}

.table-head {
  position: sticky;
  top: var(--sticky-result-top);
  z-index: 15;
  margin: -1px -1px 0;
  padding: 16px 18px;
  border: 1px solid var(--table-frame-border);
  border-bottom-color: var(--border);
  border-radius: 8px 8px 0 0;
  background: rgba(255, 255, 255, 0.9);
  -webkit-backdrop-filter: blur(14px) saturate(1.08);
  backdrop-filter: blur(14px) saturate(1.08);
  box-shadow: 0 1px 0 var(--border), 0 8px 18px rgba(25, 38, 64, 0.06);
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
}

.compact-button {
  width: auto;
  min-height: 34px;
  padding: 6px 12px;
  font-size: 13px;
  white-space: nowrap;
}

.table-activity[hidden] {
  display: none;
}

.table-activity {
  position: sticky;
  top: calc(var(--sticky-result-top) + var(--sticky-result-head-height));
  z-index: 14;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 -1px;
  padding: 12px 18px;
  border-right: 1px solid var(--table-frame-border);
  border-bottom: 1px solid #cfe0ff;
  border-left: 1px solid var(--table-frame-border);
  background: linear-gradient(90deg, rgba(239, 246, 255, 0.9), rgba(248, 251, 255, 0.9));
  -webkit-backdrop-filter: blur(14px) saturate(1.08);
  backdrop-filter: blur(14px) saturate(1.08);
}

.table-activity.cooldown {
  border-bottom-color: #fde68a;
  background: linear-gradient(90deg, rgba(255, 251, 235, 0.9), rgba(248, 251, 255, 0.9));
}

.table-activity > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.table-activity strong {
  overflow: hidden;
  color: #1d4ed8;
  font-size: 14px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-activity.cooldown strong {
  color: #b45309;
}

.table-activity span:not(.activity-spinner) {
  color: #536174;
  font-size: 12px;
  font-weight: 800;
}

.activity-spinner {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border: 3px solid #bfdbfe;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 780ms linear infinite;
}

.table-activity.cooldown .activity-spinner {
  border-color: #fde68a;
  border-top-color: #d97706;
}

.table-activity.done {
  border-bottom-color: #bbf7d0;
  background: rgba(240, 253, 244, 0.9);
}

.table-activity.done strong {
  color: var(--green);
}

.table-activity.done .activity-spinner {
  border-color: var(--green);
  animation: none;
}

.table-activity.paused {
  border-bottom-color: #fed7aa;
  background: rgba(255, 247, 237, 0.9);
}

.table-activity.paused strong {
  color: var(--amber);
}

.table-activity.paused .activity-spinner {
  border-color: var(--amber);
  animation: none;
}

.table-scroll {
  margin: 0 -1px -1px;
  overflow-x: visible;
  border: 1px solid var(--table-frame-border);
  border-top: 0;
  border-radius: 0 0 8px 8px;
}

table {
  width: 100%;
  min-width: 1080px;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: var(--sticky-table-head-top);
  z-index: 13;
  color: #536174;
  background: rgba(248, 250, 252, 0.9);
  -webkit-backdrop-filter: blur(14px) saturate(1.08);
  backdrop-filter: blur(14px) saturate(1.08);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
  box-shadow: 0 1px 0 var(--border), 0 8px 18px rgba(25, 38, 64, 0.08);
}

th[data-sort-key] {
  padding: 0;
}

.sort-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 44px;
  padding: 13px 16px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 900;
  text-align: left;
}

.sort-button::after {
  content: "↕";
  color: #c0c8d4;
  font-size: 11px;
  line-height: 1;
}

th.sorted {
  color: var(--blue);
  background: #eff6ff;
}

th.sort-asc .sort-button::after {
  content: "↑";
  color: var(--blue);
}

th.sort-desc .sort-button::after {
  content: "↓";
  color: var(--blue);
}

.sort-button:hover {
  background: #eef4ff;
}

td {
  font-weight: 650;
}

.keyword-link {
  color: #1d4ed8;
  font-weight: 850;
  text-decoration: none;
}

.keyword-link:hover {
  text-decoration: underline;
}

tr:last-child td {
  border-bottom: none;
}

tr.current td {
  background: #eff6ff;
}

tr.current td:first-child {
  box-shadow: inset 3px 0 0 var(--blue);
}

tr.row-done td {
  background: rgba(236, 253, 245, 0.34);
}

tr.row-done td:first-child {
  box-shadow: inset 3px 0 0 var(--green);
}

tr.row-ad-only td {
  background: rgba(232, 247, 251, 0.58);
}

tr.row-ad-only td:first-child {
  box-shadow: inset 3px 0 0 #0891b2;
}

tr.row-missing td,
tr.row-paused td {
  background: rgba(255, 247, 237, 0.5);
}

tr.row-missing td:first-child,
tr.row-paused td:first-child {
  box-shadow: inset 3px 0 0 #d97706;
}

tr.row-error td {
  background: rgba(254, 242, 242, 0.62);
}

tr.row-error td:first-child {
  box-shadow: inset 3px 0 0 var(--red);
}

.empty td {
  padding: 30px;
  text-align: center;
  color: #111827;
  font-size: 17px;
}

.muted {
  color: var(--muted);
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 850;
  white-space: nowrap;
}

.pending {
  background: var(--amber-soft);
  color: var(--amber);
}

.done {
  background: var(--green-soft);
  color: var(--green);
}

.missing {
  background: var(--amber-soft);
  color: var(--amber);
}

.ad-only {
  background: #e8f7fb;
  color: #087990;
}

.error {
  background: var(--red-soft);
  color: var(--red);
}

.paused {
  background: #eef2f7;
  color: #475569;
}

.modal-backdrop[hidden],
.toast[hidden] {
  display: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(17, 24, 39, 0.42);
}

.modal {
  width: min(460px, 100%);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(25, 38, 64, 0.24);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--border);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  min-height: 36px;
  border-color: var(--border);
  background: #fff;
  color: #536174;
  font-size: 22px;
  line-height: 1;
}

.modal-body {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.guide-modal {
  width: min(760px, 100%);
  max-height: calc(100vh - 44px);
  display: flex;
  flex-direction: column;
}

.guide-body {
  gap: 0;
  overflow: auto;
  padding: 0 18px;
}

.guide-section {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.guide-section:last-child {
  border-bottom: none;
}

.guide-section h3 {
  color: var(--text);
  font-size: 15px;
}

.guide-section p,
.guide-steps,
.guide-tips {
  color: #334155;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.58;
}

.guide-section p {
  margin: 9px 0 0;
}

.guide-steps {
  display: grid;
  gap: 9px;
  margin: 10px 0 0;
  padding-left: 20px;
}

.guide-steps li::marker {
  color: var(--blue);
  font-weight: 900;
}

.guide-tips {
  display: grid;
  gap: 9px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.guide-tips li {
  position: relative;
  padding-left: 14px;
}

.guide-tips li::before {
  content: "";
  position: absolute;
  top: 0.72em;
  left: 0;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--blue);
}

.guide-section strong {
  color: var(--text);
  font-weight: 900;
}

.modal input:disabled {
  background: #f8fafc;
  color: #536174;
  -webkit-text-fill-color: #536174;
}

.preset-preview {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--ink-soft);
}

.preset-preview span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.preset-preview strong {
  color: var(--text);
  font-size: 14px;
  word-break: break-word;
}

.plugin-body {
  gap: 16px;
}

.plugin-download {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--ink-soft);
}

.plugin-download span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.plugin-download-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 16px;
  border: 1px solid var(--blue);
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-weight: 900;
  text-decoration: none;
}

.plugin-download-button:hover {
  background: #1d4ed8;
}

.plugin-download p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.5;
}

.plugin-status {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(37, 99, 235, 0.14);
  border-radius: 8px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 850;
}

.plugin-status.error {
  border-color: rgba(220, 38, 38, 0.16);
  background: #fef2f2;
  color: #b91c1c;
}

.plugin-steps {
  display: grid;
  gap: 9px;
  margin: 0;
  padding-left: 20px;
  color: #334155;
  font-size: 13px;
  font-weight: 750;
  line-height: 1.55;
}

.plugin-steps code,
.guide-steps code {
  padding: 1px 5px;
  border-radius: 5px;
  background: #eef2f7;
  color: #334155;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.copyable-url {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  vertical-align: middle;
}

.copy-url-button {
  position: relative;
  width: 22px;
  min-width: 22px;
  height: 22px;
  min-height: 22px;
  padding: 0;
  border-color: transparent;
  background: transparent;
}

.copy-url-button::before,
.copy-url-button::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 10px;
  border: 1.5px solid var(--blue);
  border-radius: 2px;
}

.copy-url-button::before {
  left: 6px;
  top: 8px;
  background: #fff;
}

.copy-url-button::after {
  left: 9px;
  top: 5px;
  background: #eff6ff;
}

.copy-url-button:hover {
  border-color: rgba(37, 99, 235, 0.2);
  background: #dbeafe;
}

.plugin-modal .modal-actions {
  grid-template-columns: minmax(160px, 220px);
  justify-content: end;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 16px 18px 18px;
  border-top: 1px solid var(--border);
}

.guide-actions {
  grid-template-columns: minmax(160px, 220px);
  justify-content: end;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 30;
  max-width: min(420px, calc(100vw - 48px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #172033;
  color: #fff;
  box-shadow: 0 18px 42px rgba(25, 38, 64, 0.2);
  font-size: 14px;
  font-weight: 800;
}

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

@keyframes autoButtonAurora {
  0% {
    background-position: 0% 50%, 0% 50%;
  }

  55% {
    background-position: 72% 34%, 62% 58%;
  }

  100% {
    background-position: 100% 68%, 100% 42%;
  }
}

@keyframes autoButtonPulse {
  0%,
  100% {
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.12), 0 10px 24px rgba(37, 99, 235, 0.2);
  }

  48% {
    box-shadow: 0 0 0 7px rgba(6, 182, 212, 0.2), 0 14px 30px rgba(16, 185, 129, 0.24);
  }
}

@keyframes autoButtonDiffuse {
  0% {
    opacity: 0.68;
    transform: scale(0.58);
  }

  68% {
    opacity: 0.16;
  }

  100% {
    opacity: 0;
    transform: scale(1.32);
  }
}

@keyframes autoButtonGlow {
  0%,
  18% {
    opacity: 0;
    transform: translateX(-120%);
  }

  48% {
    opacity: 0.78;
  }

  82%,
  100% {
    opacity: 0;
    transform: translateX(120%);
  }
}

@keyframes pluginStatusPulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.58;
  }

  50% {
    transform: scale(1.18);
    opacity: 1;
  }
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 1fr;
  }

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

  .table-scroll {
    overflow-x: auto;
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(100vw - 24px, 760px);
    margin-top: 12px;
  }

  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-badges {
    justify-content: flex-start;
  }

  .query-panel,
  .insight-panel {
    padding: 16px;
  }

  .form-grid,
  .action-row {
    grid-template-columns: 1fr;
  }

  .keyword-actions,
  .preset-tools {
    display: grid;
    grid-template-columns: 1fr;
  }

  .preset-tools {
    min-width: 0;
  }

  .preset-tools select,
  .preset-tools button,
  .save-preset-button {
    width: 100%;
  }

  .action-row {
    display: grid;
  }

  .action-row button,
  #pluginGuide,
  .action-toggle {
    width: 100%;
  }

  .plugin-inline-status {
    display: grid;
    grid-template-columns: 9px minmax(0, 1fr);
    align-items: center;
  }

  .plugin-inline-status small {
    grid-column: 2;
    white-space: normal;
  }

  h1 {
    font-size: 24px;
  }

  .modal-actions {
    grid-template-columns: 1fr;
  }

  .guide-actions {
    justify-content: stretch;
  }

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

  .log-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .log-level {
    justify-content: flex-start;
    width: max-content;
  }
}
