:root {
  --bg: #fff8ef;
  --paper: #fffdf8;
  --ink: #241915;
  --muted: #75685e;
  --line: #eadfce;
  --orange: #ff6b2c;
  --red: #c93422;
  --green: #2f8f68;
  --shadow: 0 18px 50px rgba(74, 43, 25, 0.14);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 80% 2%, rgba(255, 107, 44, 0.18), transparent 30%),
    linear-gradient(180deg, #fff8ef 0%, #fffdf8 46%, #f5efe5 100%);
  color: var(--ink);
  font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(100%, 1180px);
  margin: 0 auto;
  padding: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0 18px;
}

.brand,
.nav-link {
  color: var(--ink);
  text-decoration: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

.nav-actions {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: #fff8ef;
  font-size: 12px;
  letter-spacing: 0.06em;
}

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

.language-toggle {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 14px;
  background: rgba(255, 253, 248, 0.78);
  color: var(--ink);
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
}

.hero-section {
  min-height: 92vh;
  padding: 8px 0 28px;
}

.hero-grid {
  display: grid;
  gap: 24px;
  align-items: center;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--red);
  font-size: 13px;
  font-weight: 800;
}

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

h1 {
  max-width: 690px;
  margin-bottom: 16px;
  font-size: clamp(42px, 13vw, 76px);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  font-size: clamp(26px, 8vw, 44px);
  line-height: 1.08;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 14px;
  font-size: 18px;
}

.hero-subtitle,
.section-heading p,
.fine-print,
.disclaimer p {
  color: var(--muted);
}

.hero-subtitle {
  max-width: 620px;
  font-size: 18px;
  line-height: 1.7;
}

.hero-actions {
  display: grid;
  gap: 12px;
  margin-top: 28px;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  border: 0;
  border-radius: 16px;
  padding: 0 20px;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
}

.primary-button {
  background: var(--ink);
  color: #fff8ef;
  box-shadow: 0 16px 34px rgba(36, 25, 21, 0.22);
}

.secondary-button {
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.72);
  color: var(--ink);
}

.secondary-button.is-saved {
  border-color: rgba(47, 143, 104, 0.5);
  background: rgba(47, 143, 104, 0.12);
  color: var(--green);
}

.compact-button {
  min-height: 44px;
  border-radius: 12px;
  white-space: nowrap;
}

.wide-button {
  width: 100%;
}

.hero-visual {
  position: relative;
  min-height: 360px;
  border: 1px solid rgba(234, 223, 206, 0.88);
  border-radius: 28px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.66), rgba(255, 236, 214, 0.82)),
    repeating-linear-gradient(90deg, rgba(36, 25, 21, 0.04) 0 1px, transparent 1px 18px);
  box-shadow: var(--shadow);
}

.plate-photo {
  position: absolute;
  inset: 42px 24px 82px;
  display: grid;
  place-items: center;
}

.plate-rim {
  position: relative;
  width: min(82vw, 320px);
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #fffefb 0 44%, transparent 45%),
    radial-gradient(circle at 50% 50%, #ede0cf 0 62%, transparent 63%);
  box-shadow: inset 0 0 0 12px rgba(255, 255, 255, 0.72), 0 24px 70px rgba(72, 43, 24, 0.2);
}

.plate-item {
  position: absolute;
  display: block;
  border-radius: 999px;
}

.item-a {
  inset: 30% 20% 38% 28%;
  background: linear-gradient(135deg, #c95124, #ffb05b);
  transform: rotate(-18deg);
}

.item-b {
  inset: 42% 34% 28% 18%;
  background: linear-gradient(135deg, #2f8f68, #b5d96f);
  transform: rotate(18deg);
}

.item-c {
  inset: 25% 28% 48% 48%;
  background: linear-gradient(135deg, #f7d472, #f59d2a);
  transform: rotate(34deg);
}

.hero-stat {
  position: absolute;
  right: 18px;
  bottom: 18px;
  left: 18px;
  display: grid;
  gap: 6px;
  border-radius: 22px;
  padding: 18px;
  background: rgba(36, 25, 21, 0.92);
  color: #fff8ef;
}

.hero-stat span {
  color: #ffd3bc;
}

.hero-stat strong {
  font-size: 28px;
}

section {
  padding: 48px 0;
}

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

.principle-grid,
.result-layout {
  display: grid;
  gap: 14px;
}

.result-card,
.step-card,
.principle-grid > div,
.disclaimer,
.share-output {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 253, 248, 0.82);
  box-shadow: var(--shadow);
}

.analyze-card {
  display: grid;
  gap: 14px;
}

.step-card,
.result-card,
.share-output,
.disclaimer {
  padding: 18px;
}

.step-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.step-title h3 {
  margin: 0;
}

.step-index {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  background: var(--orange);
  color: white;
  font-weight: 900;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 18px 0 14px;
}

.segmented-control input {
  position: absolute;
  opacity: 0;
}

.segmented-control span {
  display: grid;
  min-height: 46px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  font-weight: 800;
}

.segmented-control input:checked + span {
  border-color: var(--ink);
  background: var(--ink);
  color: white;
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 12px;
  background: white;
  color: var(--ink);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 4px rgba(255, 107, 44, 0.12);
}

.full-field {
  margin-top: 12px;
}

.uploader {
  display: grid;
  position: relative;
  gap: 10px;
  width: 100%;
  place-items: center;
  border: 1px dashed #cfbda7;
  border-radius: 20px;
  padding: 26px 16px;
  text-align: center;
  cursor: pointer;
  background: #fff8ed;
  color: inherit;
  overflow: hidden;
}

.file-input {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.upload-content {
  display: grid;
  gap: 10px;
  place-items: center;
  pointer-events: none;
}

.uploader.has-file {
  border-color: rgba(47, 143, 104, 0.5);
  background: rgba(47, 143, 104, 0.08);
}

.upload-icon {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border-radius: 18px;
  background: var(--orange);
  color: white;
  font-size: 12px;
  font-weight: 900;
}

.uploader strong {
  color: var(--ink);
  font-size: 17px;
}

.uploader small {
  color: var(--muted);
  line-height: 1.5;
}

.upload-status {
  min-height: 20px;
  color: var(--green) !important;
  font-weight: 800;
}

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

.preview-wrap img {
  width: 100%;
  max-height: 300px;
  object-fit: cover;
  border-radius: 18px;
}

.fine-print {
  margin: 12px 0 0;
  font-size: 13px;
  line-height: 1.65;
}

.save-button {
  margin-top: 14px;
}

.save-status {
  min-height: 42px;
  margin: 12px 0 0;
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(47, 143, 104, 0.1);
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
}

.save-status.is-warning {
  background: rgba(201, 52, 34, 0.1);
  color: var(--red);
}

.analysis-error {
  margin: 12px 0 0;
  border-radius: 14px;
  padding: 12px;
  background: rgba(201, 52, 34, 0.1);
  color: var(--red);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.5;
}

.analysis-error:empty {
  display: none;
}

.save-status:empty {
  display: none;
}

.loading-panel {
  display: grid;
  gap: 18px;
  place-items: center;
  margin-top: 16px;
  padding: 26px;
  border-radius: 22px;
  background: var(--ink);
  color: white;
}

.loader {
  width: 54px;
  aspect-ratio: 1;
  border: 5px solid rgba(255, 255, 255, 0.24);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-panel ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  text-align: center;
}

.result-hero {
  display: grid;
  gap: 16px;
  border-radius: 26px;
  padding: 22px;
  background: var(--ink);
  color: #fff8ef;
}

.result-quick-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.result-quick-metrics div {
  border: 1px solid rgba(255, 248, 239, 0.14);
  border-radius: 16px;
  padding: 12px;
  background: rgba(255, 248, 239, 0.08);
}

.result-quick-metrics span {
  display: block;
  color: #ffb088;
  font-size: 12px;
  font-weight: 800;
}

.result-quick-metrics strong {
  display: block;
  margin-top: 5px;
  color: #fff8ef;
  font-size: clamp(24px, 5vw, 38px);
  line-height: 1;
}

.result-quick-metrics small {
  font-size: 15px;
}

.result-hero .eyebrow {
  color: #ffb088;
}

.result-hero h2 {
  margin-bottom: 8px;
}

.result-hero p {
  margin-bottom: 0;
  color: #f3dcc7;
  line-height: 1.65;
}

.result-warning {
  margin-top: 12px;
  border-left: 3px solid var(--orange);
  padding-left: 12px;
  color: #ffd3bc !important;
  font-weight: 800;
}

.result-hero .primary-button {
  background: var(--orange);
  color: white;
}

dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.detail-row dt {
  color: var(--muted);
}

.detail-row dd {
  margin: 0;
  text-align: right;
  font-weight: 800;
}

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

.exercise-card {
  display: grid;
  gap: 5px;
  min-height: 110px;
  border-radius: 18px;
  padding: 14px;
  background: #fff6e8;
}

.exercise-card .exercise-code {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--ink);
  color: white;
  font-size: 11px;
  font-weight: 900;
}

.exercise-card strong {
  font-size: 28px;
  line-height: 1;
  color: var(--red);
}

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

.long-term p {
  line-height: 1.7;
}

.uncertainty-note {
  margin: 12px 0 0;
  border-radius: 14px;
  padding: 12px;
  background: rgba(255, 107, 44, 0.1);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.55;
}

.freq-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.freq-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.freq-selector input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.freq-selector span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 14px;
  background: white;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.freq-selector input:checked + span {
  border-color: var(--ink);
  background: var(--ink);
  color: white;
}

.api-config details {
  margin: 0;
}

.api-config summary {
  cursor: pointer;
  font-weight: 800;
  font-size: 15px;
  color: var(--muted);
}

.api-config summary:hover {
  color: var(--ink);
}

.api-config label {
  margin-top: 14px;
}

.api-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.long-term-weight {
  display: grid;
  gap: 4px;
  margin: 4px 0 12px;
  color: var(--muted);
  font-weight: 800;
}

.long-term-weight strong {
  color: var(--red);
  font-size: clamp(48px, 10vw, 76px);
  line-height: 0.95;
}

.share-output {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.share-output canvas {
  width: 100%;
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.principle-grid > div {
  padding: 18px;
}

.principle-grid span {
  color: var(--orange);
  font-weight: 900;
}

.principle-grid strong {
  display: block;
  margin: 8px 0;
  font-size: 20px;
}

.principle-grid p,
.disclaimer p {
  margin-bottom: 0;
  line-height: 1.7;
}

.privacy-grid {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.privacy-grid article {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: rgba(255, 246, 232, 0.72);
}

.privacy-grid strong {
  display: block;
  margin-bottom: 6px;
}

@media (min-width: 760px) {
  .app-shell {
    padding: 28px;
  }

  .hero-grid {
    grid-template-columns: 1.12fr 0.88fr;
  }

  .hero-actions {
    display: flex;
  }

  .principle-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .principle-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .privacy-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .analyze-card {
    grid-template-columns: 1.15fr 0.85fr;
    align-items: start;
  }

  .analyze-card .step-card:last-child {
    grid-column: 1 / -1;
  }

  .result-hero {
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .result-layout {
    grid-template-columns: repeat(2, 1fr);
  }
}
