:root {
  --ink: #17212b;
  --muted: #67645f;
  --paper: #fffdf8;
  --paper-strong: #f7f3ea;
  --page: #f7f3ea;
  --line: #d8d2c7;
  --jade: #22a98f;
  --terracotta: #a94f2b;
  --red: #e0452e;
  --blue: #1e56d9;
  --yellow: #f0c841;
  --white: #fffdf8;
  --shadow: 0 18px 55px rgba(23, 33, 43, 0.12);
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--page);
}

body:has(.tabs) {
  padding-bottom: env(safe-area-inset-bottom);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--page);
  box-shadow: var(--shadow);
}

.topbar {
  position: fixed;
  top: 0;
  left: 50%;
  width: min(100%, 520px);
  transform: translateX(-50%);
  z-index: 20;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 36px;
  gap: 12px;
  align-items: center;
  padding: calc(4px + env(safe-area-inset-top)) 22px 5px;
  background: rgba(255, 253, 248, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.icon-button {
  width: 36px;
  height: 36px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.date-block {
  position: relative;
  display: grid;
  min-width: 0;
}

.date-label {
  display: none;
}

.date-button {
  width: 100%;
  height: 34px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
  text-align: center;
}

#leapChoice {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 38px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 800;
  text-align: center;
}

#datePicker,
#birthDate {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  border: 0;
  padding: 0;
  opacity: 0;
  cursor: pointer;
}

#datePicker::-webkit-calendar-picker-indicator,
#birthDate::-webkit-calendar-picker-indicator {
  position: absolute;
  inset: 0;
  width: auto;
  height: auto;
  opacity: 0;
  cursor: pointer;
}

.date-block:focus-within .date-button,
.kin-date-block:focus-within .birth-date-button,
#leapChoice:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(169, 79, 43, 0.2);
}

.day-view {
  padding: calc(52px + env(safe-area-inset-top)) 14px calc(164px + env(safe-area-inset-bottom));
}

.hero-panel {
  position: relative;
  min-height: 248px;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(30, 86, 217, 0.08), transparent 36%),
    linear-gradient(315deg, rgba(169, 79, 43, 0.12), transparent 34%),
    var(--paper);
}

.hero-bg {
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(90deg, rgba(23, 33, 43, 0.04) 0 1px, transparent 1px 34px),
    repeating-linear-gradient(0deg, rgba(23, 33, 43, 0.03) 0 1px, transparent 1px 34px);
}

.hero-content {
  position: relative;
  display: grid;
  min-height: 248px;
  align-content: end;
  gap: 10px;
  padding: 16px;
  color: var(--ink);
}

.day-view.compact-hero .hero-panel {
  min-height: 162px;
}

.day-view.compact-hero .hero-content {
  min-height: 162px;
  gap: 7px;
  padding: 11px 14px;
}

.day-view.compact-hero .moon-row {
  gap: 6px;
}

.day-view.compact-hero .moon-row > span,
.day-view.compact-hero .kin-label {
  padding: 4px 8px;
  font-size: 11px;
}

.day-view.compact-hero .plasma-chip-icon {
  width: 18px;
  height: 18px;
}

.day-view.compact-hero .seal-heading {
  grid-template-columns: 56px 1fr;
  gap: 10px;
  min-height: 78px;
}

.day-view.compact-hero .seal-token,
.day-view.compact-hero .seal-token.has-asset .seal-asset {
  width: 56px;
  height: 56px;
}

.day-view.compact-hero .seal-token.has-asset {
  height: 78px;
  gap: 3px;
}

.day-view.compact-hero .seal-token.has-asset .tone-asset {
  width: 48px;
  height: 21px;
}

.day-view.compact-hero h1 {
  font-size: clamp(20px, 5.4vw, 28px);
}

.day-view.compact-hero h1.long-signature,
.day-view.compact-hero h1.extra-long-signature {
  font-size: clamp(19px, 4.9vw, 25px);
}

.day-view.compact-hero .seed {
  font-size: 14px;
  line-height: 1.25;
}

.moon-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.moon-row > span,
.kin-label {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  background: rgba(255, 253, 248, 0.76);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.plasma-chip-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.seal-heading {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 12px;
  align-items: center;
  min-height: 104px;
}

.seal-token {
  width: 72px;
  height: 72px;
  border: 3px solid var(--ink);
  border-radius: 18px;
  display: grid;
  place-items: center;
  color: var(--ink);
  font-size: 26px;
  font-weight: 950;
  position: relative;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.24);
}

.seal-token::after {
  content: attr(data-tone);
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 38px;
  height: 18px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-size: 11px;
  line-height: 14px;
  text-align: center;
}

.seal-token.red {
  background: var(--red);
}

.seal-token.blue {
  background: var(--blue);
  color: var(--white);
}

.seal-token.yellow {
  background: var(--yellow);
}

.seal-token.white {
  background: var(--white);
}

.seal-token.has-asset {
  height: 104px;
  overflow: visible;
  background: transparent;
  border: 0;
  box-shadow: none;
  align-content: end;
  gap: 5px;
}

.seal-token.has-asset .seal-asset {
  width: 72px;
  height: 72px;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 10px 16px rgba(0, 0, 0, 0.22));
}

.seal-token.has-asset .tone-asset {
  width: 60px;
  height: 28px;
  display: block;
  object-fit: contain;
  margin: 0 auto;
}

.seal-token.has-asset::after {
  display: none;
}

.seal-fallback {
  display: none;
}

.kin-label {
  justify-self: center;
  margin: 0;
}

h1 {
  margin: 0;
  font-size: clamp(24px, 7.1vw, 38px);
  line-height: 1.02;
  letter-spacing: 0;
}

h1.long-signature {
  font-size: clamp(22px, 6.3vw, 34px);
}

h1.extra-long-signature {
  font-size: clamp(20px, 5.5vw, 30px);
}

.seed {
  max-width: 34rem;
  margin: 0;
  color: var(--terracotta);
  font-size: 17px;
  font-weight: 750;
  line-height: 1.35;
}

.tabs {
  position: fixed;
  right: max(10px, calc((100vw - 520px) / 2 + 10px));
  bottom: max(8px, env(safe-area-inset-bottom));
  left: max(10px, calc((100vw - 520px) / 2 + 10px));
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 2px;
  min-height: 64px;
  border: 2px solid rgba(23, 33, 43, 0.14);
  border-radius: 16px;
  padding: 5px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: 0 18px 48px rgba(23, 33, 43, 0.16);
  backdrop-filter: blur(18px);
}

.chip-button {
  min-height: 42px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 900;
  cursor: pointer;
}

.tab {
  display: grid;
  min-width: 0;
  min-height: 50px;
  place-items: center;
  gap: 3px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.tab.active {
  background: var(--terracotta);
  color: var(--white);
  box-shadow: inset 0 0 0 1px rgba(255, 253, 248, 0.2);
}

.tab-icon {
  width: 22px;
  height: 22px;
  position: relative;
  display: block;
  background: currentColor;
  mask: center / contain no-repeat;
  -webkit-mask: center / contain no-repeat;
}

.guide-icon {
  mask-image: url("./assets/icons/navigation/guide.svg");
  -webkit-mask-image: url("./assets/icons/navigation/guide.svg");
}

.oracle-icon {
  mask-image: url("./assets/icons/navigation/oracle.svg");
  -webkit-mask-image: url("./assets/icons/navigation/oracle.svg");
}

.wave-icon {
  mask-image: url("./assets/icons/navigation/wave.svg");
  -webkit-mask-image: url("./assets/icons/navigation/wave.svg");
}

.moon-icon-small {
  mask-image: url("./assets/icons/navigation/moon.svg");
  -webkit-mask-image: url("./assets/icons/navigation/moon.svg");
}

.kin-icon {
  mask-image: url("./assets/icons/navigation/kin.svg");
  -webkit-mask-image: url("./assets/icons/navigation/kin.svg");
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.guide-card,
.oracle-card,
.wave-card,
.moon-card,
.kin-card {
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: 16px;
  background: var(--paper);
}

.question {
  margin: 0 0 14px;
  color: var(--terracotta);
  font-size: 22px;
  font-weight: 950;
  line-height: 1.1;
}

.brief {
  margin: 0;
  font-size: 17px;
  line-height: 1.5;
}

.deep {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.deep summary {
  cursor: pointer;
  font-weight: 950;
}

.deep p {
  margin: 12px 0 0;
  line-height: 1.55;
}

.oracle-cross {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-areas:
    ". top ."
    "left center right"
    ". bottom .";
  gap: 10px;
  align-items: center;
  justify-items: center;
  padding: 12px 0 18px;
}

.oracle-position {
  width: 100%;
  display: grid;
  justify-items: center;
  gap: 4px;
}

.oracle-position.top {
  grid-area: top;
}

.oracle-position.left {
  grid-area: left;
}

.oracle-position.center {
  grid-area: center;
}

.oracle-position.right {
  grid-area: right;
}

.oracle-position.bottom {
  grid-area: bottom;
}

.position-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

.mini-seal {
  width: 72px;
  min-height: 126px;
  display: grid;
  justify-items: center;
  gap: 6px;
}

.oracle-cross .mini-seal {
  min-height: 88px;
}

.mini-seal .seal-token {
  width: 58px;
  height: 90px;
  border-radius: 15px;
  font-size: 20px;
}

.mini-seal .seal-token.has-asset .seal-asset {
  width: 58px;
  height: 58px;
}

.mini-seal .seal-token.has-asset .tone-asset {
  width: 50px;
  height: 23px;
  margin-bottom: 2px;
}

.mini-seal strong {
  max-width: 92px;
  min-height: 28px;
  font-size: 12px;
  line-height: 1.15;
  text-align: center;
}

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

.meta-tile {
  min-height: 126px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 10px;
  background: var(--paper);
  text-align: center;
}

.meta-tile span,
.wave-box span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

.meta-tile strong {
  display: block;
  font-size: 17px;
  line-height: 1.15;
}

#oracleWaveName {
  margin-top: 2px;
}

.meta-tile small {
  display: block;
  color: var(--muted);
  line-height: 1.25;
}

.meta-icon {
  display: block;
  max-width: 64px;
  max-height: 70px;
  object-fit: contain;
  margin: 2px auto 8px;
}

.meta-seal {
  display: grid;
  place-items: center;
  min-height: 86px;
}

.meta-seal .seal-token.has-asset {
  width: 66px;
  height: 70px;
}

.meta-seal .seal-token.has-asset .seal-asset {
  width: 66px;
  height: 66px;
}

.iching-icon {
  width: 48px;
  height: 66px;
  object-fit: contain;
}

.rune-icon {
  width: 46px;
  height: 72px;
  object-fit: cover;
  object-position: top;
}

.plasma-icon {
  width: 42px;
  height: 44px;
}

.meta-icon[hidden] {
  display: none;
}

.wave-box {
  margin-top: 10px;
  border: 2px solid rgba(23, 33, 43, 0.12);
  border-radius: 8px;
  padding: 12px;
  background: rgba(30, 86, 217, 0.06);
}

.wave-box strong {
  display: block;
  font-size: 19px;
  margin-bottom: 6px;
}

.wave-box p {
  margin: 0;
  line-height: 1.45;
}

.wave-hero,
.moon-hero {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 14px;
  align-items: center;
}

.moon-hero {
  grid-template-columns: 96px 1fr;
}

.section-kicker {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

.wave-card h2 {
  margin: 0;
  color: var(--terracotta);
  font-size: 28px;
  line-height: 1;
}

.wave-card p {
  line-height: 1.45;
}

#wavePosition,
#moonPosition {
  margin: 8px 0 0;
  color: var(--muted);
  font-weight: 850;
}

.wave-purpose {
  margin-top: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

.wave-purpose strong {
  display: block;
  font-size: 21px;
  line-height: 1.1;
}

.wave-purpose p {
  margin: 8px 0 0;
}

.wave-range {
  margin: 12px 0 10px;
  border-radius: 8px;
  padding: 10px;
  background: rgba(201, 121, 66, 0.12);
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.wave-list .moon-item strong {
  color: var(--ink);
}

.wave-list .moon-item.active {
  align-items: start;
}

.wave-affirmation {
  margin-top: 12px;
  border-top: 1px solid rgba(246, 240, 230, 0.12);
  padding-top: 10px;
}

.wave-list .moon-item .wave-affirmation p {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.35;
}

.wave-list .moon-item .wave-affirmation strong {
  display: block;
  margin-top: 10px;
  color: var(--terracotta);
  font-size: 16px;
  font-weight: 950;
  line-height: 1.3;
}

.lunar-icon {
  width: 88px;
  height: 120px;
  display: grid;
  place-items: center;
  filter: drop-shadow(0 10px 16px rgba(23, 33, 43, 0.14));
}

.lunar-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.moon-card h2 {
  margin: 0;
  color: var(--terracotta);
  font-size: 28px;
  line-height: 1;
}

.kin-form {
  display: grid;
  gap: 8px;
}

.kin-date-block {
  position: relative;
  display: grid;
  min-width: 0;
}

.birth-date-button {
  width: 100%;
  min-width: 0;
  height: 40px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0;
  text-align: center;
}

.leap-control {
  display: none;
}

.leap-control.visible {
  display: block;
}

.kin-result {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 14px;
  align-items: center;
  margin-top: 16px;
  border-block: 1px solid var(--line);
  padding: 16px 0;
}

.kin-result.empty {
  grid-template-columns: 1fr;
}

.kin-result.empty #birthSeal {
  display: none;
}

.kin-result h2 {
  margin: 0;
  color: var(--terracotta);
  font-size: 28px;
  line-height: 1;
}

#birthKinMeta {
  margin: 8px 0 0;
  color: var(--muted);
  font-weight: 850;
}

.kin-reading {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.reading-card {
  border-radius: 8px;
  padding: 10px;
  background: var(--paper);
}

.reading-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

.reading-card strong {
  display: block;
  margin-top: 4px;
  color: var(--terracotta);
  font-size: 17px;
  line-height: 1.15;
}

.reading-card p {
  margin: 6px 0 0;
  line-height: 1.42;
}

.reading-note {
  margin: 2px 0 0;
  border-radius: 8px;
  padding: 10px;
  background: rgba(49, 169, 225, 0.08);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
}

.about-card {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.about-card h2 {
  margin: 4px 0 8px;
  color: var(--terracotta);
  font-size: 24px;
  line-height: 1;
}

.about-card p {
  margin: 8px 0 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}

.about-facts {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
}

.about-facts div {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 10px;
  align-items: start;
  border-radius: 8px;
  padding: 9px 10px;
  background: rgba(247, 243, 234, 0.72);
}

.about-facts dt,
.about-facts dd {
  margin: 0;
}

.about-facts dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

.about-facts dd {
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
  line-height: 1.35;
}

.about-facts a {
  color: var(--terracotta);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.moon-orbit {
  display: grid;
  grid-template-columns: repeat(14, minmax(0, 1fr));
  gap: 4px;
  margin: 14px 0 10px;
  border-block: 1px solid var(--line);
  padding: 10px 0;
}

.orbit-bead {
  aspect-ratio: 1;
  min-width: 0;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(169, 79, 43, 0.44);
  border-radius: 999px;
  background: var(--paper);
  box-shadow: none;
}

.orbit-bead::before {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: inherit;
}

.phase-new::before {
  background: #7a3924;
}

.phase-waxing-crescent::before {
  background:
    radial-gradient(circle at 64% 50%, var(--paper) 0 43%, transparent 44%),
    #7a3924;
}

.phase-first-quarter::before {
  background: linear-gradient(90deg, #7a3924 0 50%, var(--paper) 50% 100%);
}

.phase-waxing-gibbous::before {
  background:
    radial-gradient(circle at 38% 50%, #7a3924 0 35%, transparent 36%),
    var(--paper);
}

.phase-full::before {
  background: var(--paper);
  box-shadow: inset 0 0 0 1px rgba(169, 79, 43, 0.16);
}

.phase-waning-gibbous::before {
  background:
    radial-gradient(circle at 62% 50%, #7a3924 0 35%, transparent 36%),
    var(--paper);
}

.phase-last-quarter::before {
  background: linear-gradient(90deg, var(--paper) 0 50%, #7a3924 50% 100%);
}

.phase-waning-crescent::before {
  background:
    radial-gradient(circle at 36% 50%, var(--paper) 0 43%, transparent 44%),
    #7a3924;
}

.orbit-bead.active {
  border-color: var(--terracotta);
  box-shadow:
    0 0 0 2px rgba(169, 79, 43, 0.86),
    0 0 0 5px rgba(169, 79, 43, 0.12);
}

.moon-toolbar {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.moon-list {
  display: grid;
  gap: 3px;
}

.moon-item {
  width: 100%;
  border: 2px solid transparent;
  border-radius: 8px;
  padding: 9px 10px;
  background: var(--paper);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.icon-list-item {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 9px;
  align-items: center;
}

.icon-list-item .mini-seal {
  width: 48px;
  min-height: 72px;
  align-content: center;
}

.icon-list-item .mini-seal .seal-token {
  width: 44px;
  height: 72px;
  border-radius: 13px;
  font-size: 17px;
}

.icon-list-item .mini-seal .seal-token.has-asset {
  align-content: center;
  gap: 5px;
}

.icon-list-item .mini-seal .seal-token.has-asset .seal-asset {
  width: 44px;
  height: 44px;
}

.icon-list-item .mini-seal .seal-token.has-asset .tone-asset {
  width: 39px;
  height: 17px;
  margin-bottom: 1px;
}

.icon-list-item .mini-seal strong {
  display: none;
}

.icon-list-item .mini-seal .seal-fallback {
  display: none;
}

.item-copy {
  min-width: 0;
}

.moon-item.active {
  border-color: var(--ink);
  background: rgba(245, 200, 76, 0.16);
}

.moon-item strong {
  display: block;
  font-size: 15px;
}

.moon-item span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

@media (min-width: 760px) {
  .app-shell {
    margin-block: 24px;
    min-height: calc(100vh - 48px);
    border: 2px solid var(--ink);
    border-radius: 12px;
    overflow: hidden;
  }

  .topbar {
    top: 24px;
  }

  .tabs {
    bottom: 34px;
  }
}

@media (max-width: 380px) {
  .tab {
    min-height: 38px;
    font-size: 10px;
  }
}
