:root {
  color-scheme: light;
  --bg: #f4f1eb;
  --surface: #fffdf8;
  --surface-2: #f9f6ef;
  --ink: #27241e;
  --muted: #706a5d;
  --line: #d9d1c2;
  --green: #2f6f59;
  --blue: #315f8c;
  --amber: #a45d22;
  --red: #9a3a32;
  --shadow: 0 18px 48px rgba(53, 45, 31, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(47, 111, 89, 0.07) 1px, transparent 1px),
    linear-gradient(180deg, rgba(49, 95, 140, 0.06) 1px, transparent 1px),
    var(--bg);
  background-size: 32px 32px;
  color: var(--ink);
}

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

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 42px;
  padding: 0 16px;
  cursor: pointer;
  background: var(--surface);
  color: var(--ink);
}

button:hover {
  border-color: #bba980;
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

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

.secondary {
  background: #fffaf0;
}

.app-shell {
  width: min(1240px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar,
.panel-heading,
.report-head,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--amber);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.08;
  font-family: Georgia, "Noto Serif CJK SC", serif;
  font-weight: 700;
}

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

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

.safety-pill {
  border: 1px solid #c8bda6;
  border-radius: 999px;
  padding: 8px 14px;
  background: rgba(255, 253, 248, 0.75);
  color: var(--muted);
  white-space: nowrap;
}

.workspace {
  display: grid;
  grid-template-columns: 400px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.input-panel,
.result-panel {
  background: rgba(255, 253, 248, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.input-panel {
  position: sticky;
  top: 20px;
  padding: 22px;
}

.result-panel {
  min-height: 680px;
  padding: 24px;
}

.yunqi-mark {
  width: 92px;
  height: 92px;
  color: var(--green);
  flex: 0 0 auto;
}

.yunqi-mark text {
  fill: currentColor;
  font-size: 11px;
  font-weight: 700;
}

.analysis-form {
  display: grid;
  gap: 16px;
  margin-top: 22px;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 12px 13px;
  outline: none;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(49, 95, 140, 0.15);
}

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

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

.hint {
  display: block;
  margin-top: -8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.form-actions,
.report-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.notice {
  display: grid;
  gap: 6px;
  margin-top: 18px;
  padding: 14px;
  border-left: 4px solid var(--blue);
  background: #eef4f7;
  color: #334b5f;
  border-radius: 6px;
  line-height: 1.55;
}

.pdf-export-stage {
  position: absolute;
  top: 0;
  left: -200vw;
  width: 1120px;
  background: var(--bg);
  pointer-events: none;
}

.pdf-export-sheet {
  width: 1120px;
  min-height: 0;
  padding: 30px;
  box-shadow: none;
}

.pdf-export-sheet .result {
  display: block;
}

.pdf-export-sheet .report-actions {
  display: none;
}

.pdf-export-sheet .report-head {
  border-bottom: 2px solid var(--ink);
  padding-bottom: 12px;
}

.pdf-export-sheet .metric-card {
  min-height: 128px;
}

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

.empty-state h2 {
  color: var(--ink);
  font-family: Georgia, "Noto Serif CJK SC", serif;
  font-size: 34px;
}

.thinking-state h2::after {
  content: "";
  display: inline-block;
  width: 1.2em;
  text-align: left;
  animation: thinking-dots 1.2s steps(4, end) infinite;
}

@keyframes thinking-dots {
  0% {
    content: "";
  }
  25% {
    content: ".";
  }
  50% {
    content: "..";
  }
  75%,
  100% {
    content: "...";
  }
}

.hidden {
  display: none;
}

.summary {
  margin: 18px 0 20px;
  padding: 16px;
  border-radius: 8px;
  background: #f1eee4;
  border: 1px solid #ded3ba;
  line-height: 1.75;
}

.report-meta-strip {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.68fr) minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 10px;
  margin: 0 0 18px;
}

.report-meta-strip span {
  border: 1px solid #ded3ba;
  border-radius: 8px;
  background: #fff8e7;
  color: #5f4a20;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.5;
}

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

.metric-card,
.axis-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 15px;
}

.metric-card {
  min-height: 144px;
}

.metric-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 20px;
}

.metric-card span,
.axis-card p,
.element-row span,
.clean-list {
  color: var(--muted);
  line-height: 1.65;
}

.section-block {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.graphic-board {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 14px;
  margin-top: 20px;
}

.visual-card,
.report-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
}

.element-wheel {
  width: 100%;
  height: auto;
  margin-top: 12px;
  color: var(--green);
}

.wheel-grid {
  fill: none;
  stroke: #d7cbb8;
  stroke-width: 1;
}

.wheel-axis {
  stroke: #d7cbb8;
  stroke-width: 1;
}

.wheel-value {
  fill: rgba(47, 111, 89, 0.22);
  stroke: var(--green);
  stroke-width: 2;
}

.element-wheel text {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.yunqi-map {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.yunqi-flow-card {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 4px 12px;
  align-items: center;
  border: 1px solid #e1d8c8;
  border-left: 5px solid var(--blue);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 12px;
}

.yunqi-flow-card.main {
  border-left-color: var(--green);
  background: #eff6f1;
}

.yunqi-flow-card.qi {
  border-left-color: var(--amber);
}

.yunqi-flow-card.month {
  border-left-color: #8a6fbb;
}

.flow-label {
  grid-row: span 2;
  color: var(--amber);
  font-size: 12px;
  font-weight: 800;
}

.yunqi-flow-card strong {
  color: var(--ink);
  font-size: 18px;
}

.yunqi-flow-card p {
  grid-column: 2;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.element-profile {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.element-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 12px;
}

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

.bar-fill {
  height: 100%;
  background: var(--green);
}

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

.jiao-chart {
  display: grid;
  gap: 13px;
  margin-top: 18px;
}

.jiao-row {
  display: grid;
  gap: 8px;
}

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

.jiao-head span {
  color: var(--amber);
  font-size: 13px;
  font-weight: 700;
}

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

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

.jiao-row p,
.report-section p,
.explain-item p,
.focus-card p,
.plan-card p,
.season-card p {
  color: var(--muted);
  line-height: 1.75;
}

.season-rhythm {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.season-rhythm::before {
  content: "";
  position: absolute;
  top: 27px;
  left: 28px;
  right: 28px;
  height: 2px;
  background: #d6c8b2;
}

.season-rhythm-item {
  position: relative;
  display: grid;
  gap: 6px;
  min-height: 174px;
  border: 1px solid #e1d8c8;
  border-radius: 8px;
  background: linear-gradient(180deg, #fffdf8, #f8f4ea);
  padding: 44px 12px 12px;
}

.season-rhythm-item strong {
  color: var(--green);
  font-size: 18px;
}

.season-index {
  position: absolute;
  top: 10px;
  left: 12px;
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 999px;
  background: var(--green);
  color: white;
  font-size: 13px;
  font-weight: 800;
  z-index: 1;
}

.season-period {
  color: var(--amber);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
}

.season-rhythm-item p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.season-rhythm-item em {
  align-self: end;
  border-top: 1px solid #e1d8c8;
  padding-top: 8px;
  color: #36584a;
  font-size: 13px;
  font-style: normal;
  line-height: 1.55;
}

.report-document {
  display: grid;
  gap: 16px;
  margin-top: 22px;
}

.report-section h3 {
  margin-bottom: 12px;
  font-size: 22px;
  font-family: Georgia, "Noto Serif CJK SC", serif;
}

.report-section h4 {
  margin: 16px 0 8px;
  font-size: 16px;
}

.keyword-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.keyword-chip {
  border: 1px solid #c8bda6;
  border-radius: 999px;
  padding: 6px 10px;
  background: #fff8e7;
  color: #5f4a20;
  font-size: 13px;
  font-weight: 700;
}

.explain-list,
.plan-grid,
.season-grid,
.focus-grid {
  display: grid;
  gap: 12px;
}

.explain-item,
.regional-card,
.focus-card,
.plan-card,
.season-card {
  border: 1px solid #e1d8c8;
  border-radius: 8px;
  background: var(--surface-2);
  padding: 14px;
}

.regional-card {
  position: relative;
  overflow: hidden;
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(47, 111, 89, 0.1), transparent 42%),
    var(--surface-2);
}

.regional-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  border-radius: 999px;
  background: var(--green);
  color: white;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 800;
}

.regional-card h4 {
  margin: 14px 0 8px;
  font-size: 20px;
}

.regional-card p,
.regional-card small {
  color: var(--muted);
  line-height: 1.75;
}

.regional-card small {
  display: block;
  margin-top: 10px;
  border-top: 1px solid #dfd4c3;
  padding-top: 10px;
  font-size: 12px;
}

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

.focus-card {
  position: relative;
  padding-top: 42px;
}

.number-badge {
  position: absolute;
  top: 14px;
  left: 14px;
  display: inline-grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 999px;
  background: var(--green);
  color: white;
  font-weight: 800;
  font-size: 13px;
}

.plan-grid,
.season-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 14px;
}

.lead-line {
  padding: 12px;
  border-left: 4px solid var(--green);
  border-radius: 6px;
  background: #eff6f1;
  color: #2c4e40;
}

.axis-card h4 {
  margin: 0 0 10px;
  font-size: 17px;
}

.axis-card p {
  margin: 8px 0 0;
}

.two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}

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

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

.modifier-card {
  display: grid;
  gap: 8px;
  border: 1px solid #e1d8c8;
  border-left: 5px solid var(--blue);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 13px;
}

.modifier-card.risk {
  border-left-color: var(--red);
  background: #fff3f1;
}

.modifier-card.buffer {
  border-left-color: var(--green);
  background: #eff6f1;
}

.modifier-card span {
  width: fit-content;
  border-radius: 999px;
  padding: 4px 9px;
  background: rgba(49, 95, 140, 0.12);
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.modifier-card.risk span {
  background: rgba(154, 58, 50, 0.12);
  color: var(--red);
}

.modifier-card.buffer span {
  background: rgba(47, 111, 89, 0.12);
  color: var(--green);
}

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

.modifier-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.modifier-points {
  display: grid;
  gap: 7px;
  margin: 2px 0 0;
  padding-left: 18px;
  color: #3f3b34;
  font-size: 14px;
  line-height: 1.75;
}

.modifier-points li::marker {
  color: currentColor;
}

.current-regional-context {
  margin-top: 12px;
}

.annual-section h3,
.action-section h3 {
  font-size: 25px;
}

.annual-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.65fr);
  gap: 14px;
}

.annual-main,
.annual-side {
  border: 1px solid #e1d8c8;
  border-radius: 8px;
  background: var(--surface-2);
  padding: 16px;
}

.annual-main {
  background:
    linear-gradient(135deg, rgba(49, 95, 140, 0.11), transparent 45%),
    var(--surface-2);
}

.annual-pill {
  display: inline-flex;
  margin-bottom: 12px;
  border-radius: 999px;
  background: var(--blue);
  color: white;
  padding: 7px 12px;
  font-size: 14px;
  font-weight: 800;
}

.annual-main p,
.annual-side p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.8;
}

.annual-side h4 {
  margin-top: 0;
  color: var(--green);
  font-size: 18px;
}

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

.check-card {
  border: 1px solid #e1d8c8;
  border-radius: 8px;
  background: var(--surface-2);
  padding: 15px;
}

.check-card h4 {
  margin-top: 0;
  color: var(--ink);
  font-size: 19px;
}

.caution-card {
  border-left: 5px solid var(--amber);
  background: #fff8e7;
}

.urgent-card {
  border-left: 5px solid var(--red);
  background: #fff3f1;
}

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

.clean-list li + li {
  margin-top: 8px;
}

.alert-list li::marker {
  color: var(--red);
}

.disclaimer {
  margin: 22px 0 0;
  padding: 14px;
  border: 1px solid #e2c0bd;
  border-radius: 8px;
  background: #fff3f1;
  color: #6e332e;
  line-height: 1.7;
}

.error {
  margin-top: 12px;
  color: var(--red);
  font-weight: 700;
}

@media (max-width: 980px) {
  .workspace,
  .two-column,
  .annual-layout,
  .graphic-board,
  .report-meta-strip,
  .season-rhythm,
  .focus-grid,
  .modifier-grid,
  .checklist-grid,
  .plan-grid,
  .season-grid {
    grid-template-columns: 1fr;
  }

  .input-panel {
    position: static;
  }

  .season-rhythm::before {
    display: none;
  }
}

@media (max-width: 680px) {
  .app-shell {
    width: min(100% - 20px, 1240px);
    padding-top: 18px;
  }

  .topbar,
  .panel-heading,
  .report-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .safety-pill {
    white-space: normal;
  }

  .metrics,
  .axis-grid,
  .report-meta-strip,
  .season-rhythm {
    grid-template-columns: 1fr;
  }

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

  .form-actions,
  .report-actions {
    justify-content: stretch;
  }

  .form-actions button,
  .report-actions button {
    flex: 1 1 120px;
  }
}

@media print {
  @page {
    margin: 12mm;
  }

  body {
    background: white;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
    font-size: 10.2pt;
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  .input-panel,
  .report-actions,
  .topbar {
    display: none;
  }

  .workspace {
    display: block;
  }

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

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

  .report-meta-strip {
    display: grid;
    grid-template-columns: 1.25fr 0.68fr 0.95fr 1.05fr;
    gap: 6px;
  }

  .two-column,
  .annual-layout,
  .focus-grid,
  .modifier-grid,
  .checklist-grid,
  .plan-grid,
  .season-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

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

  .result-panel {
    border: 0;
    box-shadow: none;
    padding: 0;
  }

  .report-head {
    border-bottom: 2px solid var(--ink);
    margin-bottom: 8px;
    padding-bottom: 8px;
  }

  .report-head h2 {
    font-size: 24pt;
  }

  .summary,
  .disclaimer,
  .report-meta-strip span,
  .metric-card,
  .visual-card,
  .report-section,
  .explain-item,
  .modifier-card,
  .regional-card,
  .annual-main,
  .annual-side,
  .check-card,
  .focus-card,
  .plan-card,
  .season-card {
    box-shadow: none;
  }

  .summary {
    margin: 8px 0 9px;
    padding: 9px;
  }

  .report-meta-strip {
    margin-bottom: 9px;
  }

  .report-meta-strip span {
    padding: 6px 8px;
    font-size: 8.8pt;
  }

  .metric-card {
    min-height: 86px;
    padding: 9px;
  }

  .metric-card strong {
    font-size: 13pt;
  }

  .visual-card,
  .report-section {
    padding: 10px;
  }

  .visual-card {
    min-height: 0;
  }

  .element-wheel {
    max-height: 55mm;
  }

  .yunqi-map {
    gap: 5px;
  }

  .yunqi-flow-card {
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 2px 7px;
    padding: 6px 8px;
  }

  .yunqi-flow-card strong {
    font-size: 11pt;
  }

  .yunqi-flow-card p {
    font-size: 8.8pt;
  }

  .flow-label {
    font-size: 8.5pt;
  }

  .season-rhythm::before {
    top: 20px;
    left: 18px;
    right: 18px;
  }

  .season-rhythm-item {
    min-height: 0;
    padding: 34px 7px 7px;
  }

  .season-index {
    top: 6px;
    left: 8px;
    width: 28px;
    height: 28px;
    font-size: 10pt;
  }

  .season-rhythm-item strong {
    font-size: 12pt;
  }

  .season-rhythm-item span,
  .season-rhythm-item p,
  .season-rhythm-item em {
    font-size: 8.6pt;
  }

  .report-document {
    gap: 8px;
    margin-top: 10px;
  }

  .report-section h3 {
    font-size: 15pt;
    margin-bottom: 7px;
  }

  .report-section h4 {
    margin: 8px 0 5px;
  }

  .clean-list {
    margin-top: 7px;
  }

  .metric-card,
  .visual-card,
  .report-section,
  .focus-card,
  .plan-card,
  .season-card,
  .modifier-card,
  .regional-card,
  .annual-main,
  .annual-side,
  .check-card,
  .explain-item {
    break-inside: avoid;
    page-break-inside: avoid;
    margin-bottom: 10px;
  }

  .summary,
  .disclaimer {
    break-inside: avoid;
  }

  .report-section:nth-of-type(3),
  .report-section:nth-of-type(5),
  .report-section:nth-of-type(7) {
    break-before: page;
  }
}
