:root {
  color-scheme: light;
  --paper: #f6f0e7;
  --paper-deep: #ebe0d2;
  --ink: #1c1a17;
  --muted: #6e675d;
  --line: #d8ccbc;
  --jade: #2f7d64;
  --jade-deep: #1f5a48;
  --cinnabar: #b7472a;
  --gold: #b5873d;
  --water: #34759b;
  --white: #fffaf2;
  --shadow: 0 18px 48px rgba(64, 45, 25, 0.12);
  font-family:
    "Noto Serif SC", "Songti SC", "STSong", "SimSun", Georgia, serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background:
    linear-gradient(90deg, rgba(47, 125, 100, 0.05) 1px, transparent 1px),
    linear-gradient(0deg, rgba(183, 71, 42, 0.04) 1px, transparent 1px),
    var(--paper);
  background-size: 36px 36px;
}

body {
  margin: 0;
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

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

.topbar {
  min-height: 56px;
  padding: 8px max(14px, env(safe-area-inset-left)) 8px max(14px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(28, 26, 23, 0.08);
  background: rgba(246, 240, 231, 0.9);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 20;
}

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

.brand-mark {
  width: 38px;
  height: 38px;
  display: block;
}

.top-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.top-action-button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(47, 125, 100, 0.28);
  border-radius: 8px;
  background: rgba(255, 250, 242, 0.84);
  color: var(--jade-deep);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  transition: background 150ms ease, color 150ms ease, transform 150ms ease;
}

.top-action-button.is-primary {
  border-color: var(--jade);
  background: var(--jade);
  color: #fff;
}

.top-action-button:hover {
  transform: translateY(-1px);
}

.h5-shell {
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: 12px 14px 22px;
  flex: 1;
}

.hero-panel {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 10px 0 12px;
}

.eyebrow {
  margin: 0;
  color: var(--cinnabar);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(34px, 9vw, 52px);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 21px;
  letter-spacing: 0;
}

.flow-steps {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
}

.flow-step {
  min-height: 18px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.flow-step::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--line);
}

.flow-step + .flow-step::after {
  content: "";
  order: -1;
  width: 18px;
  height: 1px;
  background: var(--line);
  margin-right: 2px;
}

.flow-step.is-active {
  color: var(--jade-deep);
}

.flow-step.is-active::before {
  background: var(--jade);
}

.flow-view {
  display: none;
}

.flow-view.is-active {
  display: block;
}

.naming-form,
.result-top,
.report-panel {
  border: 1px solid rgba(28, 26, 23, 0.12);
  border-radius: 8px;
  background: rgba(255, 250, 242, 0.9);
  box-shadow: var(--shadow);
}

.naming-form {
  display: grid;
  gap: 13px;
  padding: 15px;
}

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

.field {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  border: 0;
}

.field > span,
.field legend,
.range-field span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

input[type="text"],
input[type="date"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  outline: none;
  min-height: 44px;
  padding: 9px 12px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

textarea {
  min-height: 88px;
  resize: vertical;
  line-height: 1.7;
}

input::placeholder,
textarea::placeholder {
  color: #9a9184;
}

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

.date-picker select {
  min-width: 0;
  padding-inline: 10px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--jade);
  box-shadow: 0 0 0 3px rgba(47, 125, 100, 0.14);
}

.segmented {
  min-height: 42px;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--white);
}

.segmented label,
.chips label {
  position: relative;
  display: grid;
  place-items: center;
}

.segmented input,
.chips input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  width: 100%;
  min-height: 40px;
  display: grid;
  place-items: center;
  padding: 0 8px;
  color: var(--muted);
  border-right: 1px solid var(--line);
  font-weight: 700;
  transition: background 160ms ease, color 160ms ease;
}

.segmented label:last-child span {
  border-right: 0;
}

.segmented input:checked + span {
  background: var(--jade);
  color: #fff;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chips span {
  min-height: 32px;
  display: inline-grid;
  place-items: center;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--muted);
  font-size: 14px;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}

.chips input:checked + span {
  border-color: var(--gold);
  background: rgba(181, 135, 61, 0.16);
  color: var(--ink);
}

.range-field {
  display: grid;
  gap: 10px;
}

.range-field input {
  accent-color: var(--jade);
}

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

.quantity-option {
  position: relative;
}

.quantity-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.quantity-option span {
  min-height: 50px;
  display: grid;
  place-items: center;
  gap: 2px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--muted);
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.quantity-option strong {
  color: var(--ink);
  font-size: 18px;
  line-height: 1;
}

.quantity-option small {
  font-size: 12px;
  line-height: 1;
}

.quantity-option input:checked + span {
  border-color: var(--jade);
  background: rgba(47, 125, 100, 0.12);
}

.quantity-option.is-disabled span {
  opacity: 0.48;
}

.hint-text,
.form-message {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.form-message {
  min-height: 20px;
  color: var(--cinnabar);
  font-weight: 700;
}

.sticky-actions {
  padding-top: 4px;
  padding-bottom: max(2px, env(safe-area-inset-bottom));
}

.primary-button,
.icon-button,
.text-button,
.copy-button {
  border-radius: 8px;
  min-height: 44px;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.primary-button {
  width: 100%;
  border: 0;
  background: var(--jade);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 10px 28px rgba(47, 125, 100, 0.24);
}

.primary-button.is-disabled {
  background: #8e877e;
  box-shadow: none;
}

.icon-button {
  width: 44px;
  border: 0;
  background: var(--jade);
  color: #fff;
  font-size: 22px;
}

.text-button,
.copy-button {
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--jade-deep);
  padding: 0 12px;
  font-size: 14px;
  font-weight: 700;
}

.primary-button:hover,
.icon-button:hover,
.text-button:hover,
.copy-button:hover {
  transform: translateY(-1px);
}

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

.names-section,
.insight-grid,
.report-panel {
  margin-top: 18px;
}

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

.section-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.name-item {
  display: grid;
  gap: 12px;
  padding: 18px;
  border-radius: 8px;
  border: 1px solid rgba(28, 26, 23, 0.1);
  background: linear-gradient(180deg, rgba(255, 250, 242, 0.92), rgba(235, 224, 210, 0.48));
  box-shadow: 0 12px 36px rgba(64, 45, 25, 0.08);
}

.name-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.name {
  font-size: clamp(33px, 10vw, 44px);
  line-height: 1.05;
  font-weight: 900;
  letter-spacing: 0;
}

.name-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.name-meta span {
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(183, 71, 42, 0.1);
  color: #7d2f1d;
  font-size: 13px;
}

.name-reason {
  margin: 0;
  color: var(--muted);
  line-height: 1.75;
  font-size: 14px;
}

.copy-button {
  flex: 0 0 auto;
  justify-self: start;
  min-height: 34px;
}

.name-head .copy-button {
  min-width: 54px;
  padding: 0 12px;
}

.insight-grid {
  display: grid;
  gap: 12px;
}

.hexagram-card,
.reading-card,
.element-card {
  border: 1px solid rgba(28, 26, 23, 0.12);
  border-radius: 8px;
  background: rgba(255, 250, 242, 0.88);
  box-shadow: var(--shadow);
}

.hexagram-card {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 14px;
  align-items: center;
  padding: 16px;
}

.hexagram-symbol {
  width: 88px;
  height: 112px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(183, 71, 42, 0.08), transparent 44%),
    var(--paper);
  font-family: "Noto Sans Symbols 2", "Apple Symbols", "Segoe UI Symbol", serif;
  font-size: 62px;
  line-height: 1;
}

.hexagram-card p:last-child {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.reading-card {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.reading-line {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(28, 26, 23, 0.1);
}

.reading-line:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.reading-line span,
.element-row span {
  color: var(--muted);
}

.reading-line strong {
  text-align: right;
}

.element-card {
  padding: 16px;
}

#support-elements {
  color: var(--cinnabar);
  font-weight: 800;
  white-space: nowrap;
}

.element-bars {
  display: grid;
  gap: 12px;
}

.element-row {
  display: grid;
  grid-template-columns: 34px 1fr 48px;
  gap: 10px;
  align-items: center;
}

.bar-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--paper-deep);
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--jade);
}

.empty-state {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.name-list .empty-state {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 242, 0.62);
}

.report-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.order-summary {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
  font-size: 14px;
}

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

.report-lines span {
  min-height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.reports-panel[hidden] {
  display: none;
}

.reports-panel,
.payment-panel {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  align-items: end;
}

.payment-panel[hidden] {
  display: none;
}

.reports-backdrop,
.payment-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(28, 26, 23, 0.28);
}

.reports-sheet,
.payment-sheet {
  position: relative;
  width: min(100%, 560px);
  max-height: min(76vh, 620px);
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(28, 26, 23, 0.12);
  border-radius: 16px 16px 0 0;
  background: var(--white);
  box-shadow: 0 -18px 48px rgba(64, 45, 25, 0.16);
}

.payment-sheet {
  width: min(100%, 420px);
  justify-items: stretch;
}

.reports-head,
.payment-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.close-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 250, 242, 0.9);
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
}

.reports-list {
  overflow: auto;
  display: grid;
  gap: 10px;
  padding-bottom: max(4px, env(safe-area-inset-bottom));
}

.payment-body {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 4px 0 8px;
}

.payment-qr {
  width: min(72vw, 260px);
  aspect-ratio: 1;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  object-fit: contain;
}

.payment-order,
.payment-status {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  line-height: 1.6;
}

.payment-status {
  color: var(--jade-deep);
  font-weight: 800;
}

.payment-actions {
  display: flex;
  justify-content: center;
  padding-bottom: max(2px, env(safe-area-inset-bottom));
}

.secondary-button {
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid rgba(47, 125, 100, 0.28);
  border-radius: 8px;
  background: rgba(255, 250, 242, 0.92);
  color: var(--jade-deep);
  font-weight: 800;
}

.reports-list .empty-state {
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(246, 240, 231, 0.58);
}

.report-item {
  width: 100%;
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(28, 26, 23, 0.1);
  border-radius: 8px;
  background: rgba(246, 240, 231, 0.52);
  color: var(--ink);
  text-align: left;
}

.report-item span {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.report-item strong,
.report-item small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.report-item strong {
  font-size: 20px;
  line-height: 1.15;
}

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

.report-item em {
  flex: 0 0 auto;
  font-style: normal;
  color: var(--jade-deep);
  font-size: 13px;
  font-weight: 800;
}

.footer {
  width: min(100% - 28px, 1120px);
  margin: 0 auto 24px;
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.service-contact {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

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

.service-contact strong {
  color: var(--jade-deep);
  font-size: 16px;
  letter-spacing: 0;
}

@media (min-width: 760px) {
  .topbar {
    padding-inline: clamp(24px, 4vw, 48px);
  }

  .reports-panel {
    align-items: center;
    padding: 24px;
  }

  .reports-sheet {
    border-radius: 8px;
  }

  .h5-shell {
    padding: 28px 24px 32px;
  }

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

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

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

  .insight-grid {
    grid-template-columns: minmax(280px, 0.9fr) minmax(280px, 1fr);
  }

  .element-card {
    grid-column: 1 / -1;
  }
}

@media (min-width: 1080px) {
  .flow-view.is-active {
    max-width: none;
  }

  #result-view.is-active {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 340px);
    gap: 18px;
    align-items: start;
  }

  .result-top,
  .names-section {
    grid-column: 1;
  }

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

  .name-item {
    gap: 10px;
    padding: 14px;
  }

  .name {
    font-size: clamp(30px, 2.7vw, 40px);
  }

  .name-meta {
    gap: 5px;
  }

  .name-meta span {
    min-height: 24px;
    padding: 3px 7px;
    font-size: 12px;
  }

  .name-reason {
    line-height: 1.65;
    font-size: 13px;
  }

  .insight-grid,
  .report-panel {
    grid-column: 2;
    margin-top: 0;
  }

  .insight-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  .hexagram-card {
    grid-template-columns: 72px 1fr;
    gap: 12px;
    padding: 14px;
  }

  .hexagram-symbol {
    width: 72px;
    height: 92px;
    font-size: 50px;
  }

  .reading-card,
  .element-card,
  .report-panel {
    padding: 14px;
  }

  .element-card {
    grid-column: auto;
  }

  .element-bars {
    gap: 10px;
  }

  .element-row {
    grid-template-columns: 28px 1fr 42px;
    gap: 8px;
  }

  .bar-track {
    height: 10px;
  }

  .report-panel {
    margin-top: 14px;
  }
}

@media (max-width: 420px) {
  .brand {
    gap: 8px;
    font-size: 16px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .top-actions {
    gap: 6px;
  }

  .top-action-button {
    min-height: 34px;
    padding-inline: 9px;
    font-size: 13px;
  }
}
