:root {
  color-scheme: light;
  --bg: #f6f1e7;
  --surface: #fffdf7;
  --surface-strong: #15110c;
  --ink: #211a12;
  --muted: #756a5d;
  --line: rgba(66, 48, 28, 0.16);
  --gold: #b68a3a;
  --gold-soft: #ead8aa;
  --jade: #315f4b;
  --cinnabar: #8f2d24;
  --shadow: 0 24px 70px rgba(36, 24, 10, 0.12);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
  font-family: "Noto Serif SC", "Songti SC", "SimSun", "Times New Roman", serif;
  background: var(--bg);
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  min-width: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 8% 8%, rgba(182, 138, 58, 0.12), transparent 28%),
    linear-gradient(135deg, #fbf7ee 0%, #efe5d4 48%, #f7f0e3 100%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input { font: inherit; }
button { cursor: pointer; }

.bazi-widget {
  width: min(1360px, 100%);
  margin: 0 auto;
  padding: clamp(18px, 4vw, 54px);
}

.bazi-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: end;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--jade);
  font-size: 13px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 {
  margin-bottom: 12px;
  font-size: clamp(38px, 7vw, 76px);
  line-height: 0.98;
  letter-spacing: 0.02em;
}

.hero-copy {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--muted);
  font-family: "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: clamp(15px, 2vw, 18px);
  line-height: 1.8;
}

.language-switcher {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 247, 0.74);
  box-shadow: 0 8px 24px rgba(36, 24, 10, 0.06);
}

.language-switcher button {
  min-height: 38px;
  padding: 0 11px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-family: "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
}

.language-switcher button.active {
  background: var(--surface-strong);
  color: var(--gold-soft);
}

.bazi-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.86fr) minmax(0, 1.14fr);
  gap: 22px;
  align-items: start;
}

.form-panel,
.result-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 253, 247, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.form-panel { padding: clamp(18px, 3vw, 34px); }
.result-panel {
  min-height: 610px;
  padding: clamp(16px, 2.4vw, 28px);
}

.panel-heading {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 24px;
}

.panel-heading h2 {
  margin: 0 0 4px;
  font-size: 24px;
  line-height: 1.1;
}

.panel-heading p {
  margin: 0;
  color: var(--muted);
  font-family: "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  line-height: 1.5;
}

.seal {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(143, 45, 36, 0.35);
  border-radius: 14px;
  background: #fff5ed;
  color: var(--cinnabar);
  font-weight: 800;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

label,
legend {
  color: #42311f;
  font-family: "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  font-weight: 700;
}

input[type="text"],
input[type="date"],
input[type="time"],
.field > input {
  width: 100%;
  min-width: 0;
  min-height: 52px;
  border: 1px solid rgba(66, 48, 28, 0.18);
  border-radius: var(--radius-sm);
  padding: 0 15px;
  background: #fffaf0;
  color: var(--ink);
  font-family: "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

input:focus {
  border-color: rgba(182, 138, 58, 0.8);
  background: #fffdf8;
  box-shadow: 0 0 0 4px rgba(182, 138, 58, 0.14);
}

.date-grid {
  display: grid;
  grid-template-columns: 1fr 0.68fr;
  gap: 14px;
}

.segmented,
.option-grid {
  min-width: 0;
  margin: 0 0 18px;
  padding: 0;
  border: 0;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-items: center;
}

.segmented legend {
  grid-column: 1 / -1;
  padding: 0;
}
.segmented label {
  position: relative;
  min-width: 0;
  min-height: 44px;
}

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

.segmented span {
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fffaf0;
  color: var(--muted);
}

.segmented input:checked + span {
  border-color: var(--surface-strong);
  background: var(--surface-strong);
  color: var(--gold-soft);
}

.option-grid {
  display: grid;
  gap: 10px;
}

.option-grid legend { margin-bottom: 8px; }
.toggle-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 250, 240, 0.72);
}

.toggle-row input {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  accent-color: var(--gold);
}

.toggle-row strong {
  display: block;
  margin-bottom: 3px;
  color: var(--ink);
}

.toggle-row small {
  display: block;
  color: var(--muted);
  font-weight: 400;
  line-height: 1.5;
}

.meta {
  min-height: 44px;
  margin: 20px 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: rgba(49, 95, 75, 0.08);
  color: #415c4d;
  font-family: "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  line-height: 1.55;
}

.run-button {
  width: 100%;
  min-height: 58px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #15110c, #3b2b18);
  color: var(--gold-soft);
  font-family: "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.08em;
  box-shadow: 0 16px 36px rgba(21, 17, 12, 0.2);
}

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

.empty-state {
  min-height: 560px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  padding: 30px;
  text-align: center;
}

.empty-state h2 { margin: 0; font-size: 28px; }
.empty-state p {
  max-width: 440px;
  margin: 0;
  color: var(--muted);
  font-family: "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.8;
}

.compass {
  width: 96px;
  height: 96px;
  border: 1px solid rgba(182, 138, 58, 0.45);
  border-radius: 50%;
  background:
    linear-gradient(90deg, transparent 49%, rgba(182, 138, 58, 0.35) 50%, transparent 51%),
    linear-gradient(0deg, transparent 49%, rgba(182, 138, 58, 0.35) 50%, transparent 51%),
    radial-gradient(circle, rgba(182, 138, 58, 0.18) 0 30%, transparent 31%);
}

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

.profile {
  display: grid;
  gap: 12px;
  padding: 18px;
  border-radius: var(--radius-md);
  background: var(--surface-strong);
  color: #fff9ea;
}

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

.profile-name {
  font-size: 24px;
  line-height: 1.2;
}

.profile-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(234, 216, 170, 0.28);
  border-radius: 999px;
  color: rgba(255, 249, 234, 0.82);
  font-family: "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 12px;
}

.table-wrap {
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  text-align: center;
}

th, td {
  padding: 14px 10px;
  border-top: 1px solid rgba(66, 48, 28, 0.12);
  border-left: 1px solid rgba(66, 48, 28, 0.12);
  vertical-align: middle;
  overflow-wrap: anywhere;
}

th:first-child, td:first-child { border-left: 0; }
thead th {
  border-top: 0;
  background: #f1e6d2;
  color: #5a4324;
  font-family: "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
}

tbody th {
  color: #634c2d;
  font-family: "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  text-align: left;
}

tbody tr:nth-child(even) { background: #fbf6ed; }
.stem, .branch {
  display: inline-block;
  font-size: clamp(26px, 3vw, 38px);
  font-weight: 900;
  line-height: 1.1;
}

.sub-line {
  margin: 2px 0;
  font-family: "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  line-height: 1.45;
}

.mobile-pillars { display: none; }

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

.panel {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 253, 247, 0.86);
  font-family: "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.7;
}

.panel h2 {
  margin: 0 0 10px;
  color: #3b2b18;
  font-size: 17px;
}

.luck-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.luck-item {
  padding: 7px 10px;
  border: 1px solid rgba(182, 138, 58, 0.34);
  border-radius: 999px;
  background: #fff8e7;
  color: #59401b;
  font-size: 13px;
}

pre {
  max-height: 300px;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: #4b4237;
  font-size: 12px;
}

@media (max-width: 1040px) {
  .bazi-layout { grid-template-columns: 1fr; }
  .result-panel { min-height: 420px; }
  .empty-state { min-height: 360px; }
}

@media (max-width: 700px) {
  .bazi-widget { padding: 16px; }
  .bazi-hero { grid-template-columns: 1fr; align-items: start; }
  .language-switcher { width: 100%; justify-content: stretch; }
  .language-switcher button { flex: 1; }
  h1 { font-size: clamp(34px, 12vw, 52px); }
  .form-panel, .result-panel { border-radius: 20px; }
  .date-grid { grid-template-columns: 1fr; gap: 0; }
  .segmented { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table-wrap { display: none; }
  .mobile-pillars {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .pillar-card {
    min-width: 0;
    padding: 15px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
  }
  .pillar-card header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: baseline;
    margin-bottom: 12px;
  }
  .pillar-card h3 {
    margin: 0;
    font-size: 18px;
  }
  .pillar-glyph {
    color: var(--gold);
    font-size: 28px;
    font-weight: 900;
  }
  .pillar-list {
    display: grid;
    gap: 8px;
  }
  .pillar-row {
    display: grid;
    grid-template-columns: 86px minmax(0, 1fr);
    gap: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(66, 48, 28, 0.1);
    font-family: "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 13px;
  }
  .pillar-row span:first-child { color: var(--muted); }
  .insight-grid { grid-template-columns: 1fr; }
  .profile-top { display: grid; }
}
