:root {
  color-scheme: light;
  --bg: #f4f6f1;
  --surface: #ffffff;
  --surface-warm: #fffaf1;
  --ink: #141711;
  --muted: #65705d;
  --line: #dfe6d8;
  --line-strong: #cbd8c0;
  --green: #176b5b;
  --green-soft: #e6f4ee;
  --blue: #2852a3;
  --blue-soft: #eaf0ff;
  --gold: #b96b15;
  --gold-soft: #fff0d8;
  --red: #b42318;
  --red-soft: #fff1ee;
  --shadow: 0 18px 50px rgba(40, 52, 34, 0.08);
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
}

button,
a,
input,
select,
textarea {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-header {
  align-items: center;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  left: 0;
  padding: 14px clamp(18px, 5vw, 64px);
  position: sticky;
  right: 0;
  top: 0;
  z-index: 10;
}

.brand {
  align-items: center;
  display: flex;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  align-items: center;
  background: #111827;
  border-radius: 8px;
  color: #fff;
  display: inline-flex;
  font-weight: 900;
  height: 42px;
  justify-content: center;
  width: 42px;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.nav-links,
.header-actions,
.history-actions {
  display: flex;
  gap: 10px;
}

.nav-links a {
  border-radius: 7px;
  color: var(--muted);
  padding: 10px 12px;
}

.nav-links a:hover {
  background: var(--green-soft);
  color: var(--green);
}

main {
  display: grid;
  gap: 20px;
  margin: 0 auto;
  max-width: 1500px;
  padding: 34px clamp(18px, 5vw, 64px) 56px;
}

.hero {
  align-items: center;
  display: grid;
  gap: 28px;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.52fr);
  min-height: 315px;
}

.eyebrow,
.section-kicker {
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  margin: 0 0 10px;
  text-transform: uppercase;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(42px, 6vw, 76px);
  letter-spacing: 0;
  line-height: 0.95;
  margin-bottom: 22px;
  max-width: 900px;
}

h2 {
  font-size: 20px;
  margin-bottom: 0;
}

h3 {
  font-size: 17px;
}

.lead {
  color: #495744;
  font-size: clamp(18px, 2vw, 22px);
  line-height: 1.65;
  max-width: 860px;
}

.hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.hero-tags span,
.source-pill {
  background: var(--green-soft);
  border: 1px solid #acd8c7;
  border-radius: 999px;
  color: var(--green);
  font-size: 13px;
  font-weight: 900;
  padding: 7px 10px;
}

.status-card,
.panel,
.metrics article {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.status-card {
  padding: 24px;
}

.status-title {
  align-items: center;
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.pulse {
  background: var(--green);
  border-radius: 999px;
  box-shadow: 0 0 0 7px var(--green-soft);
  height: 10px;
  width: 10px;
}

.status-card p {
  color: var(--muted);
  line-height: 1.65;
}

.status-card dl {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  margin: 18px 0 0;
  padding-top: 18px;
}

.status-card div {
  display: flex;
  justify-content: space-between;
}

.status-card dt {
  color: var(--muted);
}

.status-card dd {
  font-weight: 900;
  margin: 0;
}

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

.metrics article {
  min-height: 132px;
  padding: 18px;
}

.metrics span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 10px;
}

.metrics strong {
  display: block;
  font-size: 24px;
  line-height: 1.1;
  margin-bottom: 10px;
}

.metrics p,
.helper {
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 0;
}

.workspace,
.result-layout {
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.95fr);
}

.result-layout {
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.45fr);
}

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

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

.button,
.file-button,
.refine-actions button {
  align-items: center;
  border-radius: 7px;
  cursor: pointer;
  display: inline-flex;
  font-weight: 900;
  justify-content: center;
  min-height: 40px;
  padding: 0 15px;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease;
  white-space: nowrap;
}

.button:hover,
.file-button:hover,
.refine-actions button:hover {
  transform: translateY(-1px);
}

.button-primary {
  background: #111827;
  border: 1px solid #111827;
  color: #fff;
}

.button-primary:hover {
  background: var(--green);
  border-color: var(--green);
}

.button-secondary,
.file-button,
.refine-actions button {
  background: #fff;
  border: 1px solid var(--line-strong);
  color: var(--ink);
}

.button-danger {
  background: var(--red-soft);
  border: 1px solid #f0b8ae;
  color: var(--red);
}

.file-button input {
  display: none;
}

.field {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  font-weight: 900;
  gap: 7px;
}

.field.compact {
  min-width: 160px;
}

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

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

input,
select,
textarea {
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--ink);
  min-height: 42px;
  padding: 10px 11px;
  width: 100%;
}

textarea {
  line-height: 1.55;
  resize: vertical;
}

button:focus-visible,
input:focus,
select:focus,
textarea:focus,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(23, 107, 91, 0.22);
  outline-offset: 2px;
}

.table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 16px;
  max-height: 260px;
  overflow: auto;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  line-height: 1.45;
  padding: 11px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--surface-warm);
  color: var(--muted);
  font-size: 12px;
  position: sticky;
  text-transform: uppercase;
  top: 0;
}

.payload-preview {
  margin-top: 14px;
}

summary {
  color: var(--green);
  cursor: pointer;
  font-weight: 900;
}

pre {
  background: #111827;
  border-radius: 8px;
  color: #f8fafc;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  max-height: 260px;
  overflow: auto;
  padding: 14px;
  white-space: pre-wrap;
}

.empty-state {
  align-content: center;
  color: var(--muted);
  display: grid;
  min-height: 520px;
  text-align: center;
}

.empty-state h2 {
  color: var(--ink);
  margin-bottom: 10px;
}

.insights {
  background: var(--surface-warm);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  padding: 14px;
}

.insights strong {
  color: var(--green);
}

.insights p {
  color: #495744;
  line-height: 1.55;
  margin: 0;
}

.refine-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.refine-actions button:hover {
  border-color: var(--green);
  color: var(--green);
}

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

.version-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.version-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.version-header h3 {
  margin: 0;
}

.version-header strong {
  align-items: center;
  background: var(--green-soft);
  border-radius: 50%;
  color: var(--green);
  display: inline-flex;
  height: 50px;
  justify-content: center;
  width: 50px;
}

.version-card h4 {
  font-size: 17px;
  line-height: 1.38;
  margin: 16px 0;
}

.version-card ul {
  margin: 0 0 14px;
  padding-left: 18px;
}

.version-card li {
  line-height: 1.55;
  margin-bottom: 8px;
}

.keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.keywords span {
  background: var(--blue-soft);
  border: 1px solid #c7d6ff;
  border-radius: 999px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  padding: 6px 9px;
}

.score-grid {
  display: grid;
  gap: 8px;
  margin: 12px 0 14px;
}

.score-item {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: 104px 34px 1fr;
}

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

.score-item strong {
  color: var(--green);
  font-size: 13px;
  text-align: right;
}

meter {
  height: 10px;
  width: 100%;
}

.ad-copy,
.recommendation {
  background: #f7faf4;
  border-left: 4px solid var(--green);
  color: #334155;
  line-height: 1.55;
  padding: 12px;
}

.recommendation {
  margin-top: 16px;
}

.version-card details {
  margin-top: 12px;
}

.script-panel ol {
  color: #394657;
  line-height: 1.85;
  margin: 0;
  padding-left: 22px;
}

.script-panel li + li {
  margin-top: 10px;
}

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

.history-item {
  align-items: stretch;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  display: grid;
  gap: 7px;
  min-height: 112px;
  padding: 14px;
  text-align: left;
}

.history-item:hover,
.history-item.active {
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(23, 107, 91, 0.12);
}

.history-item span {
  font-size: 15px;
  font-weight: 900;
  line-height: 1.35;
}

.history-item small,
.empty-history {
  color: var(--muted);
  line-height: 1.45;
}

.empty-history {
  margin: 0;
}

@media (max-width: 1120px) {
  .app-header,
  .hero,
  .workspace,
  .result-layout {
    grid-template-columns: 1fr;
  }

  .nav-links {
    order: 3;
  }

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

@media (max-width: 740px) {
  main {
    padding-inline: 14px;
  }

  .app-header {
    padding-inline: 14px;
  }

  .header-actions,
  .history-actions,
  .nav-links,
  .form-grid,
  .metrics,
  .versions,
  .history-list {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .panel-heading,
  .result-head {
    align-items: stretch;
    display: grid;
  }

  .button,
  .file-button,
  .nav-links a {
    width: 100%;
  }

  h1 {
    font-size: 42px;
  }
}
