:root {
  color-scheme: light;
  --ink: #172026;
  --muted: #65717a;
  --soft: #edf2f1;
  --surface: #ffffff;
  --surface-strong: #f8faf7;
  --line: #dbe4df;
  --primary: #0f766e;
  --primary-dark: #0a5c55;
  --accent: #c75146;
  --amber: #b98212;
  --plum: #6d4b7f;
  --calm: #256a7b;
  --danger-bg: #fff1ef;
  --warning-bg: #fff7df;
  --calm-bg: #e9f5f7;
  --shadow: 0 16px 42px rgba(23, 32, 38, 0.11);
  --radius: 8px;
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui,
    -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: #f4f1eb;
  color: var(--ink);
}

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(15, 118, 110, 0.08), transparent 38%),
    linear-gradient(180deg, #fbfaf6 0%, #eef4f2 52%, #f8f5ef 100%);
  font-size: 16px;
  line-height: 1.6;
}

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

button {
  touch-action: manipulation;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.35);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: 12px;
  z-index: 50;
  transform: translateY(-140%);
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  padding: 10px 14px;
}

.skip-link:focus {
  transform: translateY(0);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid rgba(219, 228, 223, 0.9);
  background: rgba(255, 255, 255, 0.92);
  padding: 14px clamp(16px, 4vw, 48px);
  backdrop-filter: blur(18px);
}

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

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
}

.brand strong {
  display: block;
  font-size: 18px;
  line-height: 1.2;
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.nav {
  display: flex;
  gap: 8px;
}

.nav-button,
.primary-button,
.ghost-button,
.icon-button,
.price-chip {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background 180ms ease,
    color 180ms ease,
    box-shadow 180ms ease;
}

.nav-button {
  background: transparent;
  color: var(--muted);
  padding: 10px 14px;
}

.nav-button.active {
  background: #e6f0ee;
  color: var(--primary-dark);
}

.nav-button:hover,
.ghost-button:hover,
.price-chip:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.primary-button {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  padding: 12px 18px;
  box-shadow: 0 12px 22px rgba(15, 118, 110, 0.22);
}

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

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
  box-shadow: none;
}

.ghost-button {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 12px 16px;
}

.icon-button {
  width: 44px;
  height: 44px;
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

.danger-icon {
  color: var(--accent);
}

.app-shell {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: clamp(18px, 4vw, 42px);
}

.workspace,
.report-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 22px;
  align-items: start;
}

.audit-panel,
.side-panel,
.report-main,
.report-actions,
.history-layout {
  min-width: 0;
}

.section-heading {
  margin-bottom: 20px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 700;
}

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

h1 {
  max-width: 760px;
  margin-bottom: 12px;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.15;
}

h2 {
  margin-bottom: 12px;
  font-size: 20px;
  line-height: 1.3;
}

h3 {
  margin-bottom: 8px;
  font-size: 18px;
  line-height: 1.35;
}

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

.upload-card,
.audit-form,
.metric-board,
.principles,
.report-section,
.report-header,
.paywall,
.empty-state,
.history-item,
.report-actions {
  border: 1px solid rgba(219, 228, 223, 0.9);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.upload-card {
  margin-bottom: 18px;
  overflow: hidden;
}

.dropzone {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 178px;
  border: 1px dashed #9db8af;
  background: #f6fbf9;
  padding: 26px;
  text-align: center;
  cursor: pointer;
}

.dropzone svg {
  width: 42px;
  height: 42px;
  color: var(--primary);
}

.dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.file-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px;
}

.file-list span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 6px;
  background: #eef3ef;
  color: #344148;
  padding: 7px 10px;
  font-size: 14px;
}

.audit-form {
  padding: clamp(18px, 3vw, 28px);
}

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

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

.field span {
  color: #2d3b41;
  font-size: 14px;
  font-weight: 700;
}

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

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid #cfdad5;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
}

.field textarea {
  resize: vertical;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

.side-panel {
  display: grid;
  gap: 16px;
}

.metric-board,
.principles,
.report-actions {
  padding: 18px;
}

.metric {
  display: grid;
  gap: 2px;
  border-top: 1px solid var(--line);
  padding: 14px 0;
}

.metric strong {
  color: var(--plum);
  font-size: 26px;
  line-height: 1.1;
}

.metric span {
  font-weight: 700;
}

.metric small,
.principles li {
  color: var(--muted);
}

.principles ul {
  margin: 0;
  padding-left: 18px;
}

.report-layout {
  grid-template-columns: minmax(0, 1fr) 270px;
}

.report-main {
  display: grid;
  gap: 16px;
}

.report-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: clamp(18px, 3vw, 28px);
}

.report-header h1 {
  font-size: clamp(26px, 3vw, 38px);
}

.score-dial {
  display: grid;
  flex: 0 0 116px;
  width: 116px;
  height: 116px;
  place-items: center;
  border: 10px solid #dbece8;
  border-top-color: var(--accent);
  border-radius: 50%;
  background: #fff;
}

.score-dial strong {
  margin-top: 12px;
  font-size: 34px;
  line-height: 0.8;
}

.score-dial span {
  margin-top: -18px;
  color: var(--muted);
  font-size: 12px;
}

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

.summary-item {
  display: grid;
  gap: 6px;
  min-height: 118px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px;
}

.summary-item svg {
  color: var(--primary);
}

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

.summary-item strong {
  word-break: break-word;
}

.report-section {
  padding: clamp(16px, 3vw, 24px);
}

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

.section-title span {
  border-radius: 999px;
  background: #edf3f0;
  color: var(--primary-dark);
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 700;
}

.risk-list {
  display: grid;
  gap: 12px;
}

.risk-card {
  border: 1px solid var(--line);
  border-left-width: 5px;
  border-radius: var(--radius);
  padding: 16px;
}

.risk-card.danger {
  border-left-color: var(--accent);
  background: var(--danger-bg);
}

.risk-card.warning {
  border-left-color: var(--amber);
  background: var(--warning-bg);
}

.risk-card.calm {
  border-left-color: var(--calm);
  background: var(--calm-bg);
}

.risk-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.risk-top span {
  font-weight: 800;
}

.risk-top small {
  color: var(--muted);
}

.ask-box {
  display: grid;
  gap: 4px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  padding: 10px;
}

.ask-box span {
  color: #344148;
}

.paywall {
  display: grid;
  gap: 14px;
  margin-top: 16px;
  padding: 18px;
  background: #172026;
  color: #fff;
}

.paywall p,
.paywall small {
  color: #cbd6d4;
}

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

.price-chip {
  border-color: #4b5c60;
  background: transparent;
  color: #fff;
  padding: 10px 16px;
}

.price-chip.selected {
  border-color: #f4c05e;
  background: #f4c05e;
  color: #1e2426;
}

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

.item-card {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  padding: 14px;
}

.item-card span {
  color: var(--primary-dark);
  font-size: 22px;
  font-weight: 800;
}

.item-card small {
  color: var(--muted);
}

.item-card p {
  margin-bottom: 0;
}

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

.clean-list {
  margin: 0;
  padding-left: 22px;
}

.clean-list li {
  margin-bottom: 10px;
}

.script-box {
  display: grid;
  gap: 10px;
}

.script-box p,
.family-summary {
  border-radius: 8px;
  background: #f6f8f4;
  color: #26343a;
  margin-bottom: 0;
  padding: 12px;
}

.disclaimer {
  margin: 16px 0 0;
  color: #7a4c45;
  font-size: 14px;
}

.report-actions {
  position: sticky;
  top: 96px;
  display: grid;
  gap: 10px;
}

.upsell {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  margin-top: 8px;
  padding-top: 14px;
}

.upsell span {
  border-radius: 6px;
  background: #f5f1e7;
  color: #5c4b32;
  padding: 8px 10px;
  font-size: 14px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 420px;
  padding: 34px;
  text-align: center;
}

.empty-state svg {
  width: 52px;
  height: 52px;
  color: var(--primary);
}

.empty-state.compact {
  min-height: 260px;
}

.history-layout {
  max-width: 980px;
}

.history-list {
  display: grid;
  gap: 12px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
}

.history-item h2 {
  margin-bottom: 6px;
}

.history-item p {
  margin-bottom: 0;
}

.history-actions {
  display: flex;
  gap: 8px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 30;
  max-width: min(380px, calc(100vw - 40px));
  border-radius: 8px;
  background: #172026;
  color: #fff;
  padding: 13px 16px;
  box-shadow: var(--shadow);
}

svg {
  width: 20px;
  height: 20px;
}

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

  .side-panel,
  .report-actions {
    position: static;
  }

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

@media (max-width: 720px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .nav {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .nav-button {
    padding: 9px 8px;
  }

  .nav-button span {
    font-size: 13px;
  }

  .app-shell {
    padding: 16px;
  }

  .form-grid,
  .summary-strip,
  .item-grid,
  .two-column {
    grid-template-columns: 1fr;
  }

  .report-header,
  .history-item {
    align-items: flex-start;
    flex-direction: column;
  }

  .score-dial {
    width: 104px;
    height: 104px;
  }

  .history-actions {
    width: 100%;
    justify-content: space-between;
  }

  .history-actions .ghost-button {
    flex: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
