/* Visual refresh layer. Loaded after the built CSS; no logic changes. */
:root {
  --bg: #f0eadf;
  --panel: #fffdf8;
  --field: #f8f2e7;
  --ink: #151f1b;
  --muted: #687268;
  --line: #d8ccba;
  --line-soft: #e8decd;
  --green: #0d756d;
  --green-soft: #e3f2ed;
  --green-border: #a9d5ca;
  --rust: #9f3d18;
  --focus: rgba(13, 117, 109, 0.2);
  --shadow: 0 16px 38px rgba(21, 31, 27, 0.1);
}

body {
  background:
    linear-gradient(90deg, rgba(21, 31, 27, 0.04) 1px, transparent 1px),
    linear-gradient(180deg, rgba(21, 31, 27, 0.032) 1px, transparent 1px),
    linear-gradient(180deg, #fbf8ef 0%, var(--bg) 100%);
  background-size: 24px 24px, 24px 24px, auto;
}

.app-shell {
  padding: max(18px, env(safe-area-inset-top)) 18px 18px;
}

.topbar {
  background:
    linear-gradient(90deg, rgba(255, 242, 206, 0.08) 1px, transparent 1px),
    linear-gradient(135deg, #102f2b 0%, #0d5f57 58%, #17352f 100%);
  background-size: 18px 18px, auto;
  border: 1px solid rgba(255, 242, 206, 0.28);
  border-radius: 8px;
  box-shadow: 0 16px 36px rgba(12, 37, 34, 0.2);
  max-width: 1460px;
  padding: 14px 16px;
}

.topbar h1 {
  color: #fffdf8;
  font-weight: 950;
}

.eyebrow {
  color: rgba(255, 242, 206, 0.78);
}

.status-dot,
.icon-button {
  background: rgba(255, 253, 248, 0.13);
  border-color: rgba(255, 242, 206, 0.32);
  color: #fff2ce;
}

.icon-button:hover {
  background: #fffdf8;
  color: var(--green);
}

.controls,
.panel,
.empty-state {
  border-color: rgba(216, 204, 186, 0.86);
  box-shadow: var(--shadow);
}

.controls {
  gap: 14px;
  max-height: calc(100vh - 28px);
  overflow-y: auto;
}

.panel-title {
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 8px;
}

.panel-title svg {
  color: var(--green);
}

input,
select,
.date-trigger,
.submit-button {
  min-height: 42px;
}

.segmented {
  background: #efe6d7;
}

.segmented button.active,
.submit-button:hover,
.submit-button.is-dirty,
.date-day:hover,
.date-day.is-selected {
  background: linear-gradient(180deg, #108279, #0b645d);
}

.submit-button {
  box-shadow: 0 10px 22px rgba(13, 117, 109, 0.2);
}

.headline-panel,
.vertical-panel,
.metric,
.vertical-meta,
.god-cell,
.date-picker-popover,
.date-trigger,
.date-day {
  background: linear-gradient(180deg, #fffdf8, #f8f2e7);
}

.headline-panel h2 {
  font-weight: 950;
}

.vertical-panel {
  background:
    linear-gradient(90deg, rgba(185, 135, 45, 0.1) 1px, transparent 1px),
    linear-gradient(180deg, #fffdf8, #fbf5ea);
  background-size: 22px 22px, auto;
}

.status-dot {
  display: none !important;
}

.vertical-report {
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.vertical-line {
  min-width: max-content;
}

.vertical-meta {
  border-color: #e3d5bd;
}

.true-self-badge {
  background: #8a5a08;
}

.life-star-badge {
  background: #0d5f57;
}

.shen-sha-badge {
  background: #883c2d;
}

.special-marker-legend {
  background: #fff8e7;
  border-color: #e3d5bd;
}

.table-wrap {
  background: #fffdf8;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}

th {
  background: #f6ecdc;
  color: #6a5540;
}

tbody tr:hover td {
  background: #fbf5ea;
}

@media (max-width: 720px) {
  .app-shell {
    padding: max(10px, env(safe-area-inset-top)) 8px 12px;
  }

  .topbar {
    border-radius: 8px;
    gap: 10px;
    margin-bottom: 10px;
    padding: 12px;
  }

  .topbar h1 {
    font-size: 23px;
  }

  .layout,
  .results {
    gap: 10px;
  }

  .controls,
  .panel {
    padding: 12px;
  }

  .controls {
    max-height: none;
  }

  .headline-panel h2 {
    font-size: 24px;
  }

  .vertical-report {
    font-size: 13px;
  }

  .vertical-line {
    padding-right: 10px;
  }

  .table-wrap {
    overflow-x: auto;
  }

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

  .god-cell {
    min-height: 52px;
    padding: 7px;
  }

  .date-picker-popover {
    width: min(320px, calc(100vw - 28px));
  }
}

/* Professional plate style: dense white table, thin dividers, native controls. */
:root {
  --bg: #f7f7f8;
  --panel: #ffffff;
  --field: #fbfbfc;
  --ink: #171717;
  --muted: #858585;
  --line: #e2e2e5;
  --line-soft: #eeeeef;
  --green: #2f6fe4;
  --green-soft: #eef3ff;
  --green-border: #d9e4ff;
  --rust: #d71920;
  --focus: rgba(47, 111, 228, 0.18);
  --shadow: none;
}

body {
  background: var(--bg);
}

.app-shell {
  padding: 10px 10px 14px;
}

.topbar {
  background: #ffffff;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
  margin-bottom: 10px;
  padding: 10px 12px;
}

.topbar h1 {
  color: var(--ink);
  font-size: 24px;
  font-weight: 850;
}

.eyebrow,
.status-dot {
  color: var(--muted);
}

.status-dot,
.icon-button {
  background: #ffffff;
  border-color: var(--line);
}

.icon-button {
  color: var(--ink);
}

.controls,
.panel,
.empty-state {
  background: #ffffff;
  border-color: var(--line);
  box-shadow: none;
}

.panel-title {
  border-bottom-color: var(--line);
  color: var(--ink);
  font-weight: 850;
}

.panel-title svg {
  color: var(--green);
}

input,
select,
.date-trigger,
.date-day,
.metric,
.vertical-meta,
.god-cell,
.date-picker-popover {
  background: #fbfbfc;
  border-color: var(--line);
}

.segmented {
  background: #f1f1f3;
  border: 0;
  border-radius: 20px;
  padding: 4px;
}

.segmented button {
  border-radius: 16px;
}

.segmented button.active,
.date-day:hover,
.date-day.is-selected {
  background: #ffffff;
  box-shadow: 0 2px 10px rgba(47, 111, 228, 0.14);
  color: var(--green);
}

.submit-button,
.submit-button:hover,
.submit-button.is-dirty {
  background: #171717;
  border-color: #171717;
  box-shadow: none;
}

.headline-panel,
.vertical-panel {
  background: #ffffff;
  border-color: var(--line);
  box-shadow: none;
}

.headline-panel h2 {
  color: var(--ink);
  font-weight: 850;
}

.vertical-panel {
  border-radius: 8px;
}

.vertical-report {
  color: #171717;
  font-variant-numeric: tabular-nums;
}

.vertical-summary {
  border-bottom-color: var(--line);
}

.vertical-red {
  color: #d71920;
}

.vertical-green {
  color: #39a84a;
}

.vertical-blue {
  color: #2f80ed;
}

.table-wrap {
  background: #ffffff;
  border-color: var(--line);
  box-shadow: none;
}

th {
  background: #f3f3f4;
  color: var(--muted);
}

td {
  border-bottom-color: var(--line-soft);
}

tbody tr:hover td {
  background: #fafafa;
}

.special-marker-legend {
  background: #fbfbfc;
  border-color: var(--line);
}

@media (max-width: 720px) {
  .app-shell {
    padding: 8px 8px 10px;
  }

  .topbar {
    border-radius: 0;
    margin: -8px -8px 8px;
    padding: 10px 14px;
  }

  .topbar h1 {
    font-size: 22px;
  }

  .controls,
  .panel {
    border-radius: 8px;
    padding: 10px;
  }

  .vertical-panel {
    border-radius: 8px;
  }

  .vertical-report {
    font-size: 13px;
  }

  .vertical-meta,
  .metric,
  .god-cell {
    border-radius: 6px;
  }
}

/* Revert to jade-paper art direction. */
:root {
  --bg: #f0eadf;
  --panel: #fffdf8;
  --field: #f8f2e7;
  --ink: #151f1b;
  --muted: #687268;
  --line: #d8ccba;
  --line-soft: #e8decd;
  --green: #0d756d;
  --green-soft: #e3f2ed;
  --green-border: #a9d5ca;
  --rust: #9f3d18;
  --focus: rgba(13, 117, 109, 0.2);
  --shadow: 0 16px 38px rgba(21, 31, 27, 0.1);
}

body {
  background:
    linear-gradient(90deg, rgba(21, 31, 27, 0.04) 1px, transparent 1px),
    linear-gradient(180deg, rgba(21, 31, 27, 0.032) 1px, transparent 1px),
    linear-gradient(180deg, #fbf8ef 0%, var(--bg) 100%);
  background-size: 24px 24px, 24px 24px, auto;
}

.topbar {
  background:
    linear-gradient(90deg, rgba(255, 242, 206, 0.08) 1px, transparent 1px),
    linear-gradient(135deg, #102f2b 0%, #0d5f57 58%, #17352f 100%);
  background-size: 18px 18px, auto;
  border: 1px solid rgba(255, 242, 206, 0.28);
  border-radius: 8px;
  box-shadow: 0 16px 36px rgba(12, 37, 34, 0.2);
}

.topbar h1 {
  color: #fffdf8;
}

.eyebrow,
.status-dot {
  color: rgba(255, 242, 206, 0.78);
}

.controls,
.panel,
.empty-state,
.headline-panel,
.vertical-panel {
  background: var(--panel);
  border-color: rgba(216, 204, 186, 0.86);
  box-shadow: var(--shadow);
}

input,
select,
.date-trigger,
.date-day,
.metric,
.vertical-meta,
.god-cell {
  background: linear-gradient(180deg, #fffdf8, #f8f2e7);
  border-color: var(--line);
}

.segmented {
  background: #efe6d7;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.segmented button.active,
.submit-button:hover,
.submit-button.is-dirty,
.date-day:hover,
.date-day.is-selected {
  background: linear-gradient(180deg, #108279, #0b645d);
  color: #ffffff;
}

.submit-button {
  background: #151f1b;
  border-color: #151f1b;
}

.vertical-panel {
  background:
    linear-gradient(90deg, rgba(185, 135, 45, 0.1) 1px, transparent 1px),
    linear-gradient(180deg, #fffdf8, #fbf5ea);
  background-size: 22px 22px, auto;
}

@media (max-width: 720px) {
  .topbar {
    border-radius: 8px;
    margin: 0 0 10px;
  }
}

.special-marker {
  height: 6px;
}

.special-marker.is-wenchang,
.special-text-fill-segment.is-wenchang {
  background: #2563eb;
}

.special-marker.is-yangren,
.special-text-fill-segment.is-yangren {
  background: #dc2626;
}

.special-marker.is-feiren,
.special-text-fill-segment.is-feiren {
  background: #f97316;
}

.special-marker.is-jinyu,
.special-text-fill-segment.is-jinyu {
  background: #c28a00;
}

.special-marker.is-guoyin,
.special-text-fill-segment.is-guoyin {
  background: #7c3aed;
}

.special-marker.is-zhai,
.special-text-fill-segment.is-zhai {
  background: #0891b2;
}

.special-marker.is-zhuang,
.special-text-fill-segment.is-zhuang {
  background: #16a34a;
}

.special-marker.is-longevity,
.special-text-fill-segment.is-longevity {
  background: #ec4899;
}

.vertical-report .vertical-red,
.vertical-report .vertical-green,
.vertical-report .vertical-blue,
.vertical-report .vertical-year-item span {
  color: var(--ink) !important;
}

/* Stronger special marker emphasis: tint + matching border, no logic changes. */
.special-text-highlight {
  border-radius: 7px;
  line-height: 1.18;
  margin: 0 2px;
  padding: 0.03em 0.24em 0.05em;
  vertical-align: baseline;
}

.special-text-fill {
  border-radius: inherit;
  inset: -0.12em -0.08em -0.14em;
  height: auto;
  overflow: visible;
}

.special-text-fill-segment {
  opacity: 1;
  position: relative;
}

.special-text-fill-segment:first-child {
  border-radius: 7px 0 0 7px;
}

.special-text-fill-segment:last-child {
  border-radius: 0 7px 7px 0;
}

.special-text-fill-segment:only-child {
  border-radius: 7px;
}

.special-text-content {
  text-shadow: 0 1px 0 rgba(255, 253, 248, 0.52);
}

.special-text-fill-segment.is-wenchang {
  background: rgba(37, 99, 235, 0.2);
  box-shadow: inset 0 0 0 2px #2563eb;
}

.special-text-fill-segment.is-yangren {
  background: rgba(220, 38, 38, 0.2);
  box-shadow: inset 0 0 0 2px #dc2626;
}

.special-text-fill-segment.is-feiren {
  background: rgba(249, 115, 22, 0.2);
  box-shadow: inset 0 0 0 2px #f97316;
}

.special-text-fill-segment.is-jinyu {
  background: rgba(194, 138, 0, 0.22);
  box-shadow: inset 0 0 0 2px #c28a00;
}

.special-text-fill-segment.is-guoyin {
  background: rgba(124, 58, 237, 0.2);
  box-shadow: inset 0 0 0 2px #7c3aed;
}

.special-text-fill-segment.is-zhai {
  background: rgba(8, 145, 178, 0.2);
  box-shadow: inset 0 0 0 2px #0891b2;
}

.special-text-fill-segment.is-zhuang {
  background: rgba(22, 163, 74, 0.2);
  box-shadow: inset 0 0 0 2px #16a34a;
}

.special-text-fill-segment.is-longevity {
  background: rgba(236, 72, 153, 0.2);
  box-shadow: inset 0 0 0 2px #ec4899;
}

@media (max-width: 720px) {
  .special-text-highlight {
    border-radius: 6px;
    margin: 0 2px;
    padding: 0.04em 0.23em 0.06em;
  }

  .special-text-fill {
    border-radius: 6px;
  }

  .special-text-fill-segment:first-child {
    border-radius: 6px 0 0 6px;
  }

  .special-text-fill-segment:last-child {
    border-radius: 0 6px 6px 0;
  }

  .special-text-fill-segment:only-child {
    border-radius: 6px;
  }
}

/* Final bazi workspace tuning: compact header, readable mobile form, wrapped shen-sha lines. */
.topbar {
  align-items: center;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 82px;
}

.topbar h1 {
  line-height: 1.12;
}

.top-actions {
  align-items: center;
  display: flex;
  height: auto;
  justify-content: flex-end;
  width: auto;
}

.icon-button {
  flex: none;
}

.controls {
  scrollbar-color: rgba(13, 117, 109, 0.32) transparent;
}

.panel-title {
  line-height: 1.25;
}

input,
select,
.date-trigger,
.switch-row {
  font-size: 15px;
}

.switch-row span {
  color: var(--ink);
  font-weight: 800;
}

.vertical-summary {
  align-items: stretch;
}

.vertical-meta strong,
.metric strong {
  overflow-wrap: anywhere;
}

.vertical-report {
  overflow-x: auto;
  overscroll-behavior-inline: contain;
}

.vertical-line {
  min-width: 0;
  width: 100%;
}

.vertical-line.is-shen-sha-line {
  line-height: 1.7;
  min-height: auto;
  padding-right: 0;
  white-space: normal;
}

.vertical-line.is-shen-sha-line .vertical-line-content {
  display: block;
}

.shen-sha-list-item {
  background: rgba(248, 242, 231, 0.86);
  border: 1px solid rgba(216, 204, 186, 0.74);
  border-radius: 6px;
  line-height: 1.35;
  margin: 2px 5px 2px 0;
  padding: 2px 6px;
}

.vertical-da-yun {
  border-top: 1px solid rgba(216, 204, 186, 0.5);
  padding-top: 8px;
}

.vertical-da-yun:first-child {
  border-top: 0;
  padding-top: 0;
}

.vertical-line.is-da-yun-title {
  color: #17211d;
  font-weight: 900;
}

.vertical-year-item {
  margin-right: 12px;
}

@media (min-width: 721px) {
  .topbar {
    padding: 13px 16px;
  }

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

@media (max-width: 720px) {
  .app-shell {
    padding: max(8px, env(safe-area-inset-top)) 8px 12px;
  }

  .topbar {
    gap: 10px;
    margin-bottom: 8px;
    min-height: 64px;
    padding: 10px 12px;
  }

  .topbar h1 {
    font-size: 20px;
    margin-top: 2px;
  }

  .eyebrow {
    font-size: 12px;
  }

  .icon-button {
    height: 40px;
    width: 40px;
  }

  .controls,
  .panel {
    padding: 10px;
  }

  .controls,
  .results {
    gap: 9px;
  }

  .panel-title {
    margin-bottom: 9px;
    padding-bottom: 7px;
  }

  .field-grid,
  .field-grid.two {
    gap: 8px;
  }

  label,
  .segmented-field,
  .date-picker-field {
    gap: 5px;
  }

  label span,
  .segmented-field > span,
  .date-picker-label {
    font-size: 12px;
  }

  input,
  select,
  .date-trigger,
  .switch-row {
    height: 40px;
    min-height: 40px;
  }

  .segmented {
    padding: 3px;
  }

  .segmented button {
    min-height: 30px;
  }

  .submit-button {
    height: 44px;
    margin-top: 2px;
  }

  .inline-note {
    font-size: 12px;
    margin-top: -4px;
  }

  .vertical-summary {
    gap: 8px;
    margin-bottom: 12px;
  }

  .vertical-meta {
    min-height: 52px;
    padding: 8px;
  }

  .vertical-meta span {
    font-size: 11px;
  }

  .vertical-meta strong {
    font-size: 13px;
  }

  .special-marker-legend {
    gap: 6px 9px;
    margin: 7px 0 10px;
    padding: 7px 8px;
  }

  .special-marker {
    width: 22px;
  }

  .vertical-report {
    font-size: 13px;
    line-height: 1.56;
  }

  .vertical-block {
    margin-top: 14px;
  }

  .vertical-flow-block {
    margin-top: 22px;
  }

  .vertical-da-yun {
    margin-bottom: 9px;
  }

  .shen-sha-list-item {
    font-size: 12px;
    padding: 2px 5px;
  }

  .date-picker-popover {
    width: min(318px, calc(100vw - 32px));
  }

  .is-embedded-in-portal .app-shell {
    padding-top: 0;
  }

  .is-embedded-in-portal .topbar {
    background:
      linear-gradient(90deg, rgba(255, 242, 206, 0.07) 1px, transparent 1px),
      linear-gradient(135deg, #0f3a35 0%, #0d6a62 100%);
    background-size: 16px 16px, auto;
    min-height: 52px;
    padding: 8px 10px;
  }

  .is-embedded-in-portal .topbar h1 {
    font-size: 18px;
  }

  .is-embedded-in-portal .eyebrow {
    display: none;
  }
}

@media (min-width: 360px) and (max-width: 720px) {
  .vertical-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
