:root {
  color-scheme: light;
  --ink: #1b1b1f;
  --muted: #626672;
  --line: #d8dde7;
  --panel: #ffffff;
  --paper: #f6f7f9;
  --jade: #1f7a5a;
  --jade-soft: #dff3e8;
  --gold: #9d6a18;
  --gold-soft: #fff0c7;
  --red: #a83232;
  --red-soft: #ffe1df;
  --blue: #265f94;
  --blue-soft: #dfefff;
  --shadow: 0 18px 48px rgba(31, 42, 68, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(135deg, rgba(31, 122, 90, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(157, 106, 24, 0.13), transparent 38%),
    var(--paper);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

.shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
}

.workspace {
  width: min(1040px, 100%);
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(320px, 1fr);
  gap: 16px;
  align-items: stretch;
}

.topbar,
.input-panel,
.details-panel {
  grid-column: 1;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 4px 2px 2px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--jade);
  font-weight: 700;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 34px;
  line-height: 1.05;
  letter-spacing: 0;
}

.icon-button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-size: 22px;
  cursor: pointer;
}

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

.input-panel,
.details-panel {
  padding: 18px;
}

.input-panel {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span,
.caption {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}

input:focus,
button:focus-visible {
  outline: 3px solid rgba(38, 95, 148, 0.25);
  outline-offset: 2px;
}

.mode-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef1f5;
}

.segmented {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.segmented.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(31, 42, 68, 0.12);
}

.lunar-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.note {
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.result-band {
  grid-column: 2;
  grid-row: 1 / span 2;
  min-height: 280px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
  overflow: hidden;
}

.result-name {
  font-size: 72px;
  line-height: 1;
  font-weight: 850;
  letter-spacing: 0;
}

.result-verdict {
  margin-top: 16px;
  max-width: 540px;
  color: var(--muted);
  font-size: 21px;
  line-height: 1.45;
}

.badge {
  align-self: flex-start;
  border-radius: 8px;
  padding: 10px 12px;
  font-weight: 800;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge.good {
  background: var(--jade-soft);
  color: var(--jade);
}

.badge.caution {
  background: var(--gold-soft);
  color: var(--gold);
}

.badge.bad {
  background: var(--red-soft);
  color: var(--red);
}

.badge.neutral {
  background: var(--blue-soft);
  color: var(--blue);
}

.badge.topic {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.details-panel {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
}

.number-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.number-strip div {
  min-height: 84px;
  display: grid;
  align-content: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fafbfc;
}

.number-strip strong {
  font-size: 34px;
  line-height: 1;
}

.path-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.path-list li {
  min-height: 84px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.path-list span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.path-list strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

.custom-answer,
.meaning {
  grid-column: 1 / -1;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.custom-answer h2,
.meaning h2 {
  font-size: 22px;
  margin-bottom: 8px;
}

.custom-answer p,
.meaning p {
  color: var(--muted);
  line-height: 1.6;
}

.custom-answer .caption {
  margin-bottom: 4px;
}

.timing-advice {
  margin-top: 10px;
  color: var(--ink) !important;
  font-weight: 700;
}

.context-text {
  margin-top: 10px;
  font-size: 14px;
}

@media (max-width: 820px) {
  .shell {
    padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    place-items: start center;
  }

  .workspace,
  .details-panel {
    grid-template-columns: 1fr;
  }

  .topbar,
  .input-panel,
  .result-band,
  .details-panel {
    grid-column: 1;
  }

  .result-band {
    grid-row: auto;
    min-height: 230px;
  }

  .result-name {
    font-size: 52px;
  }

  .result-verdict {
    font-size: 18px;
  }

  .path-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 460px) {
  .lunar-grid,
  .number-strip {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 29px;
  }
}
