:root {
  --bg: #f5f0e7;
  --bg-strong: #f0e4d4;
  --panel: rgba(255, 251, 245, 0.84);
  --panel-strong: rgba(255, 255, 255, 0.92);
  --line: rgba(35, 43, 54, 0.12);
  --ink: #1f2530;
  --muted: #616976;
  --accent: #135d66;
  --accent-strong: #0b7b6d;
  --warm: #bf5b2d;
  --success: #13795b;
  --danger: #b23f50;
  --warning: #c28214;
  --shadow: 0 22px 50px rgba(44, 42, 37, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --font-ui: "Segoe UI Variable", "Microsoft YaHei UI", "PingFang SC", sans-serif;
  --font-code: "Cascadia Mono", "Consolas", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  position: relative;
  font-family: var(--font-ui);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 208, 155, 0.44), transparent 28%),
    radial-gradient(circle at top right, rgba(43, 122, 120, 0.18), transparent 26%),
    linear-gradient(180deg, #fcf8f1 0%, #f3ece1 42%, #efe5d6 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(13, 34, 44, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(13, 34, 44, 0.018) 1px, transparent 1px);
  background-size: 26px 26px;
  pointer-events: none;
}

.background-orb {
  position: fixed;
  border-radius: 999px;
  filter: blur(12px);
  pointer-events: none;
  opacity: 0.65;
}

.orb-a {
  width: 320px;
  height: 320px;
  top: 72px;
  right: 6%;
  background: rgba(224, 117, 60, 0.16);
}

.orb-b {
  width: 260px;
  height: 260px;
  bottom: 8%;
  left: 4%;
  background: rgba(12, 121, 132, 0.12);
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1560px;
  margin: 0 auto;
  padding: 32px 24px 48px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 24px;
  padding: 28px 30px;
  border: 1px solid rgba(255, 255, 255, 0.52);
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, rgba(255, 252, 246, 0.82), rgba(255, 245, 231, 0.65));
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.eyebrow,
.panel-kicker {
  margin: 0 0 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 12px;
  color: var(--warm);
}

.topbar h1,
.panel-header h2,
.detail-head h2 {
  margin: 0;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.05;
}

.topbar-copy {
  margin: 12px 0 0;
  max-width: 700px;
  color: var(--muted);
}

.topbar-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 18px;
}

.nav-tabs {
  display: flex;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.58);
}

.nav-tab,
.primary-btn,
.ghost-btn,
.run-chip {
  border: none;
  font: inherit;
  cursor: pointer;
  transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.nav-tab {
  padding: 10px 16px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
}

.nav-tab.active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #194a6e);
  box-shadow: 0 10px 24px rgba(21, 94, 102, 0.28);
}

.connection-pill {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(19, 121, 91, 0.12);
  color: var(--success);
  font-size: 13px;
}

.connection-pill.is-offline {
  background: rgba(178, 63, 80, 0.12);
  color: var(--danger);
}

main {
  display: grid;
  gap: 22px;
  min-width: 0;
}

.view {
  display: none;
  min-width: 0;
}

.view.active {
  display: block;
}

.stats-ribbon,
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  padding: 16px 18px;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
}

.stat-value {
  margin-top: 8px;
  font-size: 28px;
  font-weight: 700;
}

.panel-grid {
  display: grid;
  gap: 22px;
}

.tasks-grid {
  grid-template-columns: minmax(340px, 480px) minmax(0, 1fr);
}

.prompts-grid {
  grid-template-columns: minmax(360px, 520px) minmax(0, 1fr);
}

.panel {
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  min-width: 0;
}

.form-panel,
.list-panel,
.settings-panel,
.detail-panel {
  padding: 24px;
}

.detail-panel {
  min-width: 0;
}

.panel-header,
.detail-topbar,
.task-card-head,
.detail-head,
.progress-row,
.task-foot,
.action-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.panel-header {
  margin-bottom: 22px;
}

.stack-form {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-size: 14px;
}

input,
select,
textarea {
  width: 100%;
  padding: 13px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  font: inherit;
  color: var(--ink);
  resize: vertical;
}

textarea,
pre,
code {
  font-family: var(--font-code);
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(21, 94, 102, 0.22);
  border-color: rgba(21, 94, 102, 0.45);
}

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

.hint-card,
.detail-meta-card,
.sequence-card,
.raw-json-box {
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(19, 93, 102, 0.12);
  background: rgba(255, 255, 255, 0.66);
}

.hint-card-title,
.review-title,
.detail-label,
.compare-pane-head,
.section-title {
  font-weight: 700;
  color: var(--ink);
}

.prompt-preview {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--muted);
  max-height: 220px;
  overflow: auto;
}

.prompt-preview-card {
  max-height: 180px;
}

.primary-btn,
.ghost-btn {
  padding: 12px 16px;
  border-radius: 999px;
}

.primary-btn {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #1c4571);
  box-shadow: 0 16px 28px rgba(22, 70, 100, 0.22);
}

.ghost-btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.56);
  color: var(--ink);
}

.danger-btn {
  color: var(--danger);
}

.primary-btn:hover,
.ghost-btn:hover,
.nav-tab:hover,
.run-chip:hover {
  transform: translateY(-1px);
}

.task-list,
.prompt-list {
  display: grid;
  gap: 16px;
}

.manual-answer-list {
  display: grid;
  gap: 14px;
}

.manual-answer-item textarea {
  min-height: 148px;
}

.task-card,
.prompt-card {
  padding: 18px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(19, 93, 102, 0.1);
  background: var(--panel-strong);
}

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

.task-card h3,
.prompt-card h3 {
  margin: 0;
  font-size: 20px;
}

.task-meta,
.detail-side-note,
.brand-sub,
.task-foot,
.answer-meta,
.rich-text,
.warning-item {
  color: var(--muted);
}

.detail-side-note {
  max-width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: right;
}

.task-question {
  margin: 14px 0;
  color: var(--ink);
  line-height: 1.65;
}

.progress-row,
.task-foot,
.answer-meta {
  flex-wrap: wrap;
  font-size: 13px;
}

.task-error,
.error-block p {
  margin: 12px 0 0;
  color: var(--danger);
  white-space: pre-wrap;
}

.status-badge,
.mini-badge,
.rank-pill,
.inline-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status-queued {
  background: rgba(194, 130, 20, 0.12);
  color: var(--warning);
}

.status-running {
  background: rgba(19, 93, 102, 0.12);
  color: var(--accent);
}

.status-completed,
.status-succeeded {
  background: rgba(19, 121, 91, 0.12);
  color: var(--success);
}

.status-completed_with_errors,
.status-failed {
  background: rgba(178, 63, 80, 0.12);
  color: var(--danger);
}

.mini-badge,
.rank-pill,
.inline-chip {
  background: rgba(20, 93, 102, 0.1);
  color: var(--accent);
}

.settings-panel {
  width: 100%;
  max-width: none;
}

.detail-topbar {
  margin-bottom: 18px;
}

.detail-head {
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

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

.detail-value {
  margin-top: 8px;
  line-height: 1.65;
}

.run-pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.run-pager-label {
  min-width: 160px;
  text-align: center;
  font-weight: 700;
}

.run-chip-strip {
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  padding-bottom: 2px;
}

.run-chip-strip-shell {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 8px;
  margin-bottom: 18px;
}

.run-chip {
  flex: 0 0 auto;
  min-width: 120px;
  max-width: 180px;
  display: grid;
  gap: 6px;
  text-align: left;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.62);
  color: var(--ink);
}

.run-chip > span {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.run-chip.active {
  border-color: rgba(19, 93, 102, 0.4);
  background: rgba(19, 93, 102, 0.1);
}

.run-chip-brand {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.compare-grid > * {
  min-width: 0;
}

.compare-pane {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  align-content: start;
  min-height: 620px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(19, 93, 102, 0.14);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.76);
}

.compare-pane-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 248, 249, 0.84);
}

.compare-scroll {
  padding: 18px;
  overflow: auto;
  min-height: 0;
}

.review-compare-pane {
  grid-template-rows: auto auto;
  min-width: 0;
  overflow: hidden;
}

#review-pane.compare-scroll {
  width: 100%;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: hidden;
}

.review-tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.review-tab {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.66);
  color: var(--ink);
}

.review-tab.active {
  border-color: rgba(19, 93, 102, 0.35);
  background: rgba(19, 93, 102, 0.12);
  color: var(--accent);
}

.review-tab-panel {
  min-height: 100%;
  min-width: 0;
}

.review-section {
  min-width: 0;
}

.review-section + .review-section {
  margin-top: 18px;
}

.scroll-x-shell {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 6px;
}

.sequence-grid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(280px, 320px);
  gap: 14px;
  margin-top: 12px;
  width: max-content;
  min-width: 100%;
}

.sequence-scroll-shell {
  margin-top: 12px;
}

.sequence-card {
  min-width: 0;
}

.sequence-card h4 {
  margin: 0 0 10px;
  word-break: break-word;
}

.sequence-ranks {
  display: grid;
  gap: 10px;
}

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

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  margin-top: 12px;
  padding-bottom: 6px;
}

.brand-table {
  width: max-content;
  min-width: 1100px;
  border-collapse: collapse;
}

.brand-table th,
.brand-table td {
  padding: 14px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.brand-table th {
  position: sticky;
  top: 0;
  background: rgba(255, 252, 248, 0.96);
}

.brand-main {
  font-weight: 700;
}

.brand-role {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
}

.brand-role-target {
  background: rgba(19, 93, 102, 0.12);
  color: var(--accent);
}

.brand-role-competitor {
  background: rgba(194, 130, 20, 0.12);
  color: #8e6206;
}

.inline-chip {
  margin: 2px 6px 2px 0;
}

.warning-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.warning-item {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: rgba(194, 130, 20, 0.1);
  color: #8e6206;
}

.raw-json-box pre {
  margin: 0;
  max-height: none;
  overflow: visible;
  white-space: pre-wrap;
  word-break: break-word;
}

.markdown-body {
  line-height: 1.8;
  color: var(--ink);
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  margin: 0 0 12px;
  color: var(--ink);
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol {
  margin: 0 0 14px;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 22px;
}

.markdown-body li + li {
  margin-top: 8px;
}

.markdown-body code {
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(19, 93, 102, 0.08);
}

.rich-text {
  line-height: 1.75;
}

mark {
  padding: 1px 3px;
  border-radius: 6px;
  background: rgba(224, 117, 60, 0.22);
}

.empty-state,
.error-block {
  padding: 24px;
  border-radius: var(--radius-lg);
  border: 1px dashed rgba(19, 93, 102, 0.22);
  background: rgba(255, 255, 255, 0.52);
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  padding: 14px 18px;
  border-radius: 16px;
  background: rgba(24, 28, 32, 0.92);
  color: #fff;
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.18);
}

.toast.error {
  background: rgba(178, 63, 80, 0.96);
}

.hidden {
  display: none !important;
}

@media (max-width: 1180px) {
  .tasks-grid,
  .prompts-grid,
  .compare-grid,
  .detail-meta {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
  }

  .topbar-side {
    width: 100%;
    align-items: flex-start;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 18px 14px 32px;
  }

  .topbar,
  .form-panel,
  .list-panel,
  .settings-panel,
  .detail-panel {
    padding: 18px;
  }

  .inline-fields,
  .stats-ribbon,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .nav-tabs {
    width: 100%;
    overflow: auto;
  }

  .nav-tab {
    white-space: nowrap;
  }
}
