:root {
  --bg: #f5f5f7;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-solid: #ffffff;
  --surface-muted: #fbfbfd;
  --ink: #1d1d1f;
  --text: #2b2d31;
  --muted: #6e6e73;
  --faint: #9a9aa0;
  --line: rgba(0, 0, 0, 0.1);
  --line-soft: rgba(0, 0, 0, 0.06);
  --blue: #0071e3;
  --blue-press: #0066cc;
  --green: #248a3d;
  --amber: #b26a00;
  --red: #d70015;
  --violet: #6e56cf;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 32px 90px rgba(0, 0, 0, 0.18);
  --radius: 8px;
  --content-max: 1720px;
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Segoe UI", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei",
    Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 0;
  background:
    linear-gradient(180deg, #ffffff 0, rgba(255, 255, 255, 0) 260px),
    var(--bg);
  color: var(--ink);
  font-size: 14px;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button,
.file-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  padding: 0 14px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition:
    background 150ms ease,
    border-color 150ms ease,
    box-shadow 150ms ease,
    color 150ms ease,
    transform 150ms ease;
}

button:hover,
.file-button:hover {
  border-color: rgba(0, 0, 0, 0.16);
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

button:active,
.file-button:active {
  transform: translateY(1px);
}

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

#addAccount,
#aiCreatorDistillation,
#aiAnalyzeBenchmarkCandidate,
#syncBrainState,
#runBrainDiagnosis,
#createAnalysisPack,
#createVideoBrief,
#generateScripts {
  border-color: var(--blue);
  background: var(--blue);
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(0, 113, 227, 0.22);
}

#addAccount:hover,
#aiCreatorDistillation:hover,
#aiAnalyzeBenchmarkCandidate:hover,
#syncBrainState:hover,
#runBrainDiagnosis:hover,
#createAnalysisPack:hover,
#createVideoBrief:hover,
#generateScripts:hover {
  border-color: var(--blue-press);
  background: var(--blue-press);
}

#saveCreatorDistillation,
#addBenchmarkCandidate {
  border-color: rgba(0, 0, 0, 0.16);
  background: #1d1d1f;
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.16);
}

input,
select,
textarea {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  outline: none;
  transition:
    background 150ms ease,
    border-color 150ms ease,
    box-shadow 150ms ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(0, 113, 227, 0.55);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.12);
}

a {
  color: var(--blue);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px max(28px, calc((100vw - var(--content-max)) / 2 + 28px));
  border-bottom: 1px solid var(--line-soft);
  background: rgba(250, 250, 252, 0.78);
  backdrop-filter: saturate(180%) blur(18px);
}

.app-header h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.18;
  font-weight: 760;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 760;
}

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

.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.file-button input {
  display: none;
}

.app-shell {
  width: min(var(--content-max), 100%);
  margin: 0 auto;
  padding: 18px 28px 32px;
}

.summary-band {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  min-height: 94px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 16px;
  backdrop-filter: blur(18px);
}

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

.metric strong {
  display: block;
  margin-top: 10px;
  color: var(--ink);
  font-size: 30px;
  line-height: 1;
  font-weight: 760;
}

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

.account-rail,
.account-hero,
.panel,
.tabs {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.account-rail {
  position: sticky;
  top: 88px;
  min-height: calc(100vh - 116px);
  overflow: hidden;
}

.rail-tools {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line-soft);
}

.rail-tools input,
.rail-tools select {
  width: 100%;
  min-height: 38px;
  padding: 0 12px;
  background: var(--surface-muted);
}

.rail-tools input::placeholder {
  color: var(--faint);
}

.account-list {
  max-height: calc(100vh - 224px);
  overflow: auto;
  padding: 8px;
}

.account-card {
  display: grid;
  width: 100%;
  gap: 9px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  padding: 12px;
  text-align: left;
  box-shadow: none;
}

.account-card:hover {
  background: rgba(0, 0, 0, 0.035);
  box-shadow: none;
}

.account-card.active {
  border-color: rgba(0, 113, 227, 0.22);
  background: rgba(0, 113, 227, 0.08);
  box-shadow: none;
}

.account-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.account-title-row strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 720;
}

.mini-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.badge,
.stage-chip,
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 720;
  white-space: nowrap;
}

.badge.green,
.status-pill.green {
  color: var(--green);
  background: rgba(36, 138, 61, 0.1);
  border-color: rgba(36, 138, 61, 0.18);
}

.badge.blue,
.status-pill.blue {
  color: var(--blue);
  background: rgba(0, 113, 227, 0.1);
  border-color: rgba(0, 113, 227, 0.18);
}

.badge.amber,
.status-pill.amber {
  color: var(--amber);
  background: rgba(178, 106, 0, 0.1);
  border-color: rgba(178, 106, 0, 0.18);
}

.badge.red,
.status-pill.red {
  color: var(--red);
  background: rgba(215, 0, 21, 0.08);
  border-color: rgba(215, 0, 21, 0.16);
}

.badge.violet,
.status-pill.violet {
  color: var(--violet);
  background: rgba(110, 86, 207, 0.1);
  border-color: rgba(110, 86, 207, 0.18);
}

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

.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  margin-bottom: 12px;
  padding: 6px;
}

.tab {
  min-width: 88px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  font-weight: 650;
}

.tab:hover {
  border-color: transparent;
  background: rgba(0, 0, 0, 0.045);
  box-shadow: none;
}

.tab.active {
  border-color: rgba(0, 0, 0, 0.08);
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.07);
}

.tab-panel {
  display: none;
}

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

.account-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
  padding: 20px;
}

.account-hero h2 {
  margin: 0;
  color: var(--ink);
  font-size: 26px;
  line-height: 1.2;
  font-weight: 780;
}

.hero-side {
  display: grid;
  justify-items: end;
  gap: 10px;
}

.subtle {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.auth-line,
.panel-note,
.modal-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.stage-chip {
  min-width: 112px;
  min-height: 34px;
  color: var(--blue);
  background: rgba(0, 113, 227, 0.1);
  border-color: rgba(0, 113, 227, 0.18);
}

.stage-chip.green {
  color: var(--green);
  background: rgba(36, 138, 61, 0.1);
  border-color: rgba(36, 138, 61, 0.18);
}

.stage-chip.amber {
  color: var(--amber);
  background: rgba(178, 106, 0, 0.1);
  border-color: rgba(178, 106, 0, 0.18);
}

.stage-chip.red {
  color: var(--red);
  background: rgba(215, 0, 21, 0.08);
  border-color: rgba(215, 0, 21, 0.16);
}

.stage-chip.violet {
  color: var(--violet);
  background: rgba(110, 86, 207, 0.1);
  border-color: rgba(110, 86, 207, 0.18);
}

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

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

.panel {
  min-width: 0;
  padding: 18px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-soft);
}

.panel-heading h3 {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.3;
  font-weight: 720;
}

.panel-heading span {
  color: var(--muted);
  font-size: 12px;
}

.narrative {
  margin-bottom: 14px;
  color: var(--text);
  line-height: 1.75;
}

.reason-list,
.action-list,
.gate-list,
.check-list,
.event-list,
.guardrail-list,
.draft-list,
.benchmark-list {
  display: grid;
  gap: 10px;
}

.reason,
.action,
.gate,
.check,
.event,
.guardrail,
.draft,
.benchmark,
.trend-item,
.budget-box,
.benchmark-metrics div {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.62);
  padding: 12px;
}

.reason:hover,
.action:hover,
.gate:hover,
.check:hover,
.event:hover,
.guardrail:hover,
.draft:hover,
.benchmark:hover {
  border-color: var(--line);
  background: #ffffff;
}

.reason strong,
.action strong,
.gate strong,
.check strong,
.event strong,
.guardrail strong,
.draft strong,
.benchmark strong {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 720;
}

.reason p,
.action p,
.gate p,
.check p,
.event p,
.guardrail p,
.draft p,
.benchmark p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

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

.trend-item {
  min-height: 92px;
}

.trend-item span,
.benchmark-metrics span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.trend-item strong {
  display: block;
  margin-top: 8px;
  color: var(--ink);
  font-size: 23px;
  font-weight: 760;
}

.trend-item em {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  font-style: normal;
}

.positive {
  color: var(--green);
}

.negative {
  color: var(--red);
}

.neutral {
  color: var(--amber);
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  min-height: 30px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--text);
  padding: 6px 10px;
  font-size: 13px;
}

.benchmark {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(260px, 0.92fr);
  gap: 16px;
}

.benchmark a {
  color: var(--blue);
  font-weight: 720;
  text-decoration: none;
}

.benchmark a:hover {
  text-decoration: underline;
}

.breakdown {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.breakdown div {
  border-left: 2px solid rgba(0, 113, 227, 0.34);
  padding-left: 10px;
}

.breakdown span {
  display: block;
  color: var(--ink);
  font-size: 13px;
  font-weight: 720;
}

.breakdown p {
  margin-top: 2px;
}

.benchmark-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.benchmark-metrics strong {
  display: block;
  margin: 6px 0 0;
  color: var(--ink);
}

.budget-box {
  padding: 16px;
}

.budget-main {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line-soft);
}

.budget-main strong {
  color: var(--ink);
  font-size: 34px;
  line-height: 1;
  font-weight: 780;
}

.budget-main span {
  color: var(--muted);
  font-size: 13px;
}

.budget-box p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.traffic-plan {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.traffic-plan div {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.62);
  padding: 12px;
}

.traffic-plan strong {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 720;
}

.empty {
  display: grid;
  min-height: 80px;
  place-items: center;
  border: 1px dashed rgba(0, 0, 0, 0.14);
  border-radius: var(--radius);
  color: var(--muted);
  padding: 14px;
  text-align: center;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.36);
  padding: 24px;
  backdrop-filter: blur(8px);
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(980px, 100%);
  max-height: min(780px, calc(100vh - 48px));
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-lg);
  padding: 22px;
}

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

.modal-heading h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 760;
}

.icon-button {
  width: 38px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

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

.modal-grid section {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.66);
  padding: 16px;
}

.modal-grid h3 {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 720;
}

.modal label,
.benchmark-form label {
  display: grid;
  gap: 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
}

.modal label {
  margin-bottom: 12px;
}

.modal input,
.modal textarea,
.benchmark-form input,
.benchmark-form select,
.benchmark-form textarea {
  padding: 10px 12px;
}

.modal textarea,
.benchmark-form textarea {
  resize: vertical;
}

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

.safe-callout {
  border: 1px solid rgba(178, 106, 0, 0.2);
  border-radius: var(--radius);
  background: rgba(178, 106, 0, 0.08);
  color: #7a4a00;
  padding: 12px;
  font-size: 13px;
  line-height: 1.65;
}

.safe-callout.ready {
  border-color: rgba(36, 138, 61, 0.22);
  background: rgba(36, 138, 61, 0.09);
  color: var(--green);
}

.safe-callout.blocked {
  border-color: rgba(215, 0, 21, 0.18);
  background: rgba(215, 0, 21, 0.07);
  color: var(--red);
}

.advanced-config {
  margin-top: 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.68);
  padding: 10px 12px;
}

.advanced-config summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
}

.advanced-config label:first-of-type {
  margin-top: 12px;
}

.qr-panel {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.qr-box {
  display: grid;
  min-height: 240px;
  place-items: center;
  border: 1px dashed rgba(0, 0, 0, 0.16);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.62);
  color: var(--muted);
  padding: 12px;
  text-align: center;
}

.qr-box svg {
  display: block;
  width: min(220px, 100%);
  height: auto;
}

.modal-actions,
.memory-actions,
.brain-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.modal-actions {
  justify-content: flex-end;
  margin-top: 18px;
}

.memory-actions,
.brain-actions {
  margin-bottom: 12px;
}

.brain-workbench,
.benchmark-workbench {
  margin-bottom: 18px;
}

.brain-status {
  min-height: 48px;
  border: 1px solid rgba(0, 113, 227, 0.16);
  border-radius: var(--radius);
  background: rgba(0, 113, 227, 0.06);
  color: var(--text);
  padding: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.brain-status.success {
  border-color: rgba(36, 138, 61, 0.22);
  background: rgba(36, 138, 61, 0.08);
}

.brain-status.error {
  border-color: rgba(215, 0, 21, 0.18);
  background: rgba(215, 0, 21, 0.07);
}

.benchmark-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.benchmark-form .wide-field {
  grid-column: span 2;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 280px minmax(0, 1fr);
  }

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

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

  .account-rail {
    position: static;
    min-height: auto;
  }

  .account-list {
    max-height: 360px;
  }
}

@media (max-width: 760px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
    padding: 16px;
  }

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

  .app-shell {
    padding: 14px;
  }

  .summary-band,
  .trend-grid,
  .benchmark-form {
    grid-template-columns: 1fr;
  }

  .benchmark-form .wide-field {
    grid-column: auto;
  }

  .account-hero,
  .panel-heading,
  .budget-main,
  .benchmark,
  .modal-grid,
  .field-row {
    align-items: flex-start;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .hero-side {
    justify-items: start;
  }

  .tabs {
    padding: 5px;
  }

  .tab {
    min-width: 82px;
  }
}
