:root {
  --ink: #0a192f;
  --muted: #667085;
  --line: #e5e7eb;
  --soft: #f8f9fa;
  --green: #2eb75b;
  --green-dark: #22964a;
  --blue: #2563eb;
  --amber: #f59e0b;
  --danger: #dc2626;
  --shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--ink);
  background: #fff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #ffffff 0%, #f7faf9 100%);
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(229, 231, 235, 0.8);
}

.topbar-inner,
.container {
  width: min(100% - 32px, 920px);
  margin: 0 auto;
}

.topbar-inner {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 900;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border-radius: 8px;
  background: #eef2f7;
}

.nav-item {
  min-height: 34px;
  border-radius: 6px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.nav-item.active {
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow);
}

.page {
  flex: 1;
  padding: 26px 0 88px;
}

.pwa-status {
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
}

.pwa-status-inner {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.small-button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 13px;
}

.headline {
  display: grid;
  gap: 8px;
  margin: 18px 0 24px;
}

.headline h1 {
  font-size: clamp(24px, 4vw, 38px);
  line-height: 1.12;
  margin: 0;
  letter-spacing: 0;
}

.headline p {
  color: var(--muted);
  margin: 0;
  font-size: 16px;
}

.eyebrow {
  color: #1d7b3d;
  font-size: 13px;
  font-weight: 900;
}

.split-headline {
  grid-template-columns: 1fr auto;
  align-items: end;
}

.flow-strip {
  display: grid;
  gap: 8px;
  min-width: 170px;
}

.flow-strip span,
.step {
  min-height: 34px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 12px;
  color: #344054;
  font-weight: 800;
  box-shadow: var(--shadow);
}

.flow-strip span:first-child,
.step.active {
  border-color: rgba(46, 183, 91, 0.4);
  background: #eefaf2;
  color: #1d7b3d;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.example-card,
.panel,
.result-card,
.question-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.example-card {
  padding: 18px;
  text-align: left;
  min-height: 178px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.example-card:hover {
  transform: translateY(-2px);
  border-color: rgba(46, 183, 91, 0.5);
}

.card-link {
  color: var(--blue);
  font-weight: 800;
  font-size: 14px;
}

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

.template-card {
  min-height: 84px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  text-align: left;
  display: grid;
  align-content: start;
  gap: 6px;
}

.template-card:hover {
  border-color: rgba(46, 183, 91, 0.5);
  background: #fbfffc;
}

.template-card strong {
  line-height: 1.35;
}

.template-card span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.example-card h2,
.panel h2,
.result-card h2 {
  font-size: 18px;
  margin: 0;
  line-height: 1.35;
}

.audience {
  color: var(--muted);
  font-size: 14px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
}

.tag,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef7f1;
  color: #1d7b3d;
  font-size: 12px;
  white-space: nowrap;
}

.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 18px;
}

.actions.no-margin {
  margin-top: 0;
}

.primary,
.secondary,
.ghost,
.danger {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
}

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

.primary:hover {
  background: var(--green-dark);
}

.secondary {
  background: var(--ink);
  color: #fff;
}

.ghost {
  background: #eef2f7;
  color: var(--ink);
}

.danger {
  background: #fee2e2;
  color: var(--danger);
}

.help-box {
  margin-top: 20px;
  padding: 16px;
  border: 1px dashed #b6c6d8;
  background: #f8fbff;
  border-radius: 8px;
  color: #344054;
}

.page-layout {
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 18px;
  align-items: start;
}

.side-steps {
  position: sticky;
  top: 82px;
  display: grid;
  gap: 8px;
}

.panel {
  padding: 18px;
  margin-bottom: 14px;
}

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

.section-title h2 {
  margin: 0 0 4px;
}

.section-title p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.compact-title {
  margin-bottom: 12px;
}

.audience-builder {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 14px;
  display: grid;
  gap: 12px;
}

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

.quota-preview {
  border-radius: 8px;
  border: 1px solid rgba(46, 183, 91, 0.35);
  background: #eefaf2;
  padding: 12px;
  display: grid;
  gap: 4px;
}

.quota-preview span {
  color: #1d7b3d;
  font-size: 12px;
  font-weight: 900;
}

.quota-preview strong {
  color: var(--ink);
}

.quota-preview p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  background: #eef2f7;
  border-radius: 8px;
  padding: 5px;
  margin-bottom: 14px;
}

.tab {
  min-height: 42px;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow);
}

.result-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  background: #eef2f7;
  border-radius: 8px;
  padding: 5px;
  margin-bottom: 18px;
}

.form-grid {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  font-weight: 800;
  font-size: 14px;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid #cfd8e3;
  border-radius: 6px;
  background: #fff;
  min-height: 42px;
  padding: 10px 12px;
  color: var(--ink);
}

.field textarea {
  resize: vertical;
  min-height: 82px;
}

.large-textarea {
  min-height: 180px;
}

.compact-field {
  max-width: 240px;
  margin-bottom: 14px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.segment {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: #344054;
  font-weight: 700;
}

.segment.active {
  border-color: var(--green);
  background: #eefaf2;
  color: #1d7b3d;
}

.question-card {
  padding: 14px;
  display: grid;
  gap: 10px;
}

.question-row {
  display: grid;
  grid-template-columns: 1fr 140px auto;
  gap: 8px;
  align-items: center;
}

.api-panel {
  position: sticky;
  bottom: 0;
  z-index: 4;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding: 12px 0;
}

.generate-bar {
  display: flex;
  justify-content: flex-end;
  margin: 18px 0 0;
}

.large-action {
  min-width: 180px;
  min-height: 52px;
  font-size: 18px;
}

.settings-layout {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 14px;
  align-items: start;
}

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

.provider-card {
  text-align: left;
  display: grid;
  gap: 6px;
  min-height: 88px;
  padding: 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
}

.provider-card.active {
  border-color: var(--green);
  background: #eefaf2;
}

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

.input-action {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.api-grid {
  display: grid;
  grid-template-columns: 150px 1fr auto auto;
  gap: 8px;
  align-items: end;
}

.tiny {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}

.meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0 18px;
}

.loading {
  min-height: 360px;
  display: grid;
  place-items: center;
  text-align: center;
}

.pulse {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 16px;
}

.pulse span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 0.9s infinite ease-in-out;
}

.pulse span:nth-child(2) {
  animation-delay: 0.15s;
  background: var(--blue);
}

.pulse span:nth-child(3) {
  animation-delay: 0.3s;
  background: var(--amber);
}

@keyframes pulse {
  0%, 100% { transform: scale(0.75); opacity: 0.45; }
  50% { transform: scale(1); opacity: 1; }
}

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

.result-card {
  padding: 18px;
}

.profile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #eef7f1;
  display: grid;
  place-items: center;
  font-size: 22px;
}

.qa {
  display: grid;
  gap: 10px;
}

.qa strong {
  display: block;
  margin-bottom: 4px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(92px, 150px) 1fr 52px;
  gap: 10px;
  align-items: center;
  margin: 10px 0;
}

.bar-track {
  height: 12px;
  background: #edf2f7;
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--blue));
}

.notice {
  border-radius: 8px;
  padding: 12px 14px;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1e3a8a;
}

.analysis-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.analysis-options span {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #344054;
  font-size: 13px;
  font-weight: 800;
}

.analysis-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 14px 0 18px;
}

.analysis-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
  display: grid;
  gap: 8px;
}

.analysis-card strong {
  font-size: 16px;
}

.analysis-card span {
  color: var(--muted);
  line-height: 1.5;
}

.insight-list {
  margin: 10px 0 18px;
  padding-left: 22px;
  color: #344054;
  line-height: 1.7;
}

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

.export-card {
  min-height: 92px;
  text-align: left;
  display: grid;
  gap: 6px;
  align-content: center;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
}

.export-card:hover {
  border-color: rgba(46, 183, 91, 0.5);
  background: #fbfffc;
}

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

.empty-state {
  min-height: 360px;
  display: grid;
  place-items: center;
  text-align: center;
  align-content: center;
  gap: 12px;
}

.empty-state h1,
.empty-state p {
  margin: 0;
}

.empty-state p {
  color: var(--muted);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 20;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10, 25, 47, 0.42);
}

.modal {
  width: min(100%, 420px);
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.22);
  padding: 22px;
}

.modal h2 {
  margin: 0 0 8px;
  font-size: 22px;
}

.modal p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

@media (max-width: 760px) {
  .topbar-inner,
  .container {
    width: min(100% - 24px, 920px);
  }

  .topbar-inner {
    height: auto;
    padding: 10px 0;
    align-items: flex-start;
    flex-direction: column;
  }

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

  .pwa-status-inner {
    align-items: flex-start;
    flex-direction: column;
    padding: 8px 0;
  }

  .nav-item {
    flex: 1 0 auto;
  }

  .card-grid,
  .split-headline,
  .page-layout,
  .settings-layout,
  .provider-grid,
  .template-strip,
  .result-tabs,
  .analysis-grid,
  .export-grid,
  .audience-grid,
  .segmented,
  .input-action,
  .api-grid,
  .question-row {
    grid-template-columns: 1fr;
  }

  .side-steps {
    position: static;
  }

  .generate-bar {
    justify-content: stretch;
  }

  .large-action {
    width: 100%;
  }

  .page {
    padding-top: 16px;
  }

  .api-panel {
    position: static;
  }

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