:root {
  --bg: #141a2e;
  --bg-deep: #0d1120;
  --card: #1c2340;
  --line: #2d365a;
  --text: #ecebe4;
  --muted: #a3a8bf;
  --moon: #f3e3a6;
  --moon-dark: #2a3150;
  --accent: #f3e3a6;
  --serif: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", serif;
  --sans: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: linear-gradient(180deg, var(--bg-deep) 0, var(--bg) 640px) no-repeat;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.7;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
main, header.site, footer.site { max-width: 480px; margin: 0 auto; padding: 0 16px; }
a { color: var(--accent); }
button, select, .button { font: inherit; color: inherit; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

header.site { display: flex; align-items: baseline; justify-content: space-between; padding-top: 14px; }
header.site h1 { font-family: var(--serif); font-weight: 600; font-size: 1.1rem; letter-spacing: .2em; margin: 0; }
.brand { font-size: .8rem; color: var(--muted); text-decoration: none; letter-spacing: .1em; }

.sky { text-align: center; padding: 20px 0 8px; }
.moon-hero { width: 168px; height: 168px; margin: 0 auto 8px; filter: drop-shadow(0 0 28px rgba(243, 227, 166, .22)); }
.moon-hero svg { width: 100%; height: 100%; }
.age { margin: 0; font-family: var(--serif); }
.age-label { font-size: .9rem; color: var(--muted); letter-spacing: .2em; }
#age { font-size: 2.6rem; font-weight: 600; letter-spacing: .02em; }
.moon-name { margin: 0; font-family: var(--serif); font-size: 1.15rem; letter-spacing: .15em; color: var(--moon); min-height: 1.7em; }
.illum { margin: 0; font-size: .8rem; color: var(--muted); }

.riseset { display: flex; justify-content: center; gap: 32px; margin: 14px 0 6px; }
.riseset div { display: flex; flex-direction: column; align-items: center; }
.riseset dt { font-size: .75rem; color: var(--muted); letter-spacing: .15em; }
.riseset dd { margin: 0; font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.place { display: flex; justify-content: center; align-items: center; gap: 8px; font-size: .85rem; color: var(--muted); }
.place select {
  background: transparent; border: 1px solid var(--line); border-radius: 8px;
  padding: 4px 8px; font-size: .85rem; color: var(--text); max-width: 60vw;
}
.place select option { background: var(--card); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin: 14px 0; }
.card h2 { font-family: var(--serif); font-size: 1rem; font-weight: 600; letter-spacing: .12em; margin: 0 0 4px; }
.hint { font-size: .8rem; color: var(--muted); margin: 0 0 10px; }
.small { font-size: .75rem; color: var(--muted); }

.koyomi { text-align: center; }
.koyomi p { margin: 0; }
.today { font-size: 1rem; }
.kyureki { font-family: var(--serif); font-size: .95rem; color: var(--moon); letter-spacing: .08em; }
.koyomi .sub { font-size: .8rem; color: var(--muted); }

.day-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; margin-bottom: 12px; }
.day-switch button { background: none; border: 0; border-radius: 999px; padding: 4px 14px; font-size: .8rem; color: var(--muted); cursor: pointer; }
.day-switch button[aria-selected="true"] { background: var(--line); color: var(--text); }

.levels { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.level {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: none; border: 1px solid transparent; border-radius: 12px; padding: 8px 2px; cursor: pointer;
  -webkit-tap-highlight-color: transparent; transition: transform .15s, border-color .15s, background .15s;
}
.level svg { width: 44px; height: 44px; }
.level span { font-size: .7rem; color: var(--muted); white-space: nowrap; }
.level:active { transform: scale(.94); }
.level[aria-checked="true"] { border-color: var(--moon); background: rgba(243, 227, 166, .08); }
.level[aria-checked="true"] span { color: var(--moon); }
.status { font-size: .8rem; color: var(--muted); min-height: 1.4em; margin: 8px 0 0; text-align: center; }
.status button { background: none; border: 0; color: var(--accent); text-decoration: underline; font-size: .8rem; cursor: pointer; padding: 0 4px; }

.back-list { list-style: none; margin: 8px 0 0; padding: 0; }
.back-list li { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.back-list li:first-child { border-top: 0; }
.back-list svg { width: 30px; height: 30px; flex: none; }
.back-list .when { flex: 1; font-size: .85rem; }
.back-list .when small { display: block; color: var(--muted); font-size: .72rem; }
.back-list .what { font-size: .85rem; color: var(--moon); }
.back-list .none { color: var(--muted); }

#graph svg { width: 100%; height: auto; display: block; }
.graph .axis { stroke: var(--line); stroke-width: 1; }
.graph .label { fill: var(--muted); font-size: 9px; font-family: var(--sans); }
.graph .dot { fill: var(--moon); opacity: .35; }
.graph .wave { fill: none; stroke: var(--moon); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.graph .now { stroke: #8fa6ff; stroke-width: 1; stroke-dasharray: 3 3; }
.graph .now-label { fill: #8fa6ff; font-size: 9px; }

.about p { font-size: .85rem; margin: 6px 0; }
.data-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.data-tools button, .data-tools .button {
  background: none; border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; font-size: .8rem; cursor: pointer;
}

footer.site { text-align: center; padding: 8px 16px 32px; font-size: .8rem; }
footer.site a { color: var(--muted); text-decoration: none; letter-spacing: .1em; }
