/* 星学研究所 天体運行カレンダー */
:root {
  --bg: #0e0f24;
  --bg2: #15173a;
  --panel: #1b1d44;
  --panel-line: rgba(231,196,108,.16);
  --line: rgba(255,255,255,.09);
  --text: #ecebf7;
  --muted: #9a99c2;
  --gold: #e7c46c;
  --gold-dim: rgba(231,196,108,.14);
  --today: #e7c46c;
  /* 天体カラー */
  --c-moon: #cdd0ec;
  --c-mercury: #6fa8dc;
  --c-venus: #e59ac0;
  --c-mars: #e2674a;
  --c-jupiter: #e3b352;
  --c-saturn: #b39b6e;
  --c-uranus: #4fc1b0;
  --c-neptune: #6f86e0;
  --c-pluto: #a87adf;
  --radius: 14px;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 600px at 50% -10%, #1b1d4a 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  font-variant-emoji: text; /* 星座グリフを絵文字化させず天体グリフと統一 */
}
.app { max-width: 880px; margin: 0 auto; padding: 16px 14px 40px; overflow-x: clip; }

/* ---- topbar ---- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.title { display: flex; align-items: center; gap: 12px; }
.title-glyph {
  font-size: 30px; color: var(--gold);
  filter: drop-shadow(0 0 10px rgba(231,196,108,.5));
}
.title h1 { font-size: 19px; margin: 0; letter-spacing: .04em; font-weight: 700; }
.subtitle { margin: 2px 0 0; font-size: 11.5px; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.viewtoggle { display: flex; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.vt {
  border: 0; background: transparent; color: var(--muted); font-size: 12.5px;
  padding: 5px 12px; border-radius: 999px; cursor: pointer; font-family: inherit;
}
.vt.active { background: var(--gold); color: #20183a; font-weight: 700; }
.iconbtn {
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  border-radius: 999px; padding: 6px 12px; font-size: 12.5px; cursor: pointer; font-family: inherit;
}
.iconbtn:hover { border-color: var(--panel-line); }

/* ---- month nav ---- */
.monthnav { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 18px 0 12px; }
.navbtn {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font-size: 22px; line-height: 1; cursor: pointer;
}
.navbtn:hover { border-color: var(--gold); color: var(--gold); }
.monthlabel { font-size: 18px; margin: 0; min-width: 140px; text-align: center; font-weight: 700; letter-spacing: .03em; }
.today {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 999px; padding: 5px 10px; font-size: 12px; cursor: pointer; font-family: inherit;
}
.today:hover { color: var(--gold); border-color: var(--gold); }

/* ---- filter panel ---- */
.filterpanel {
  background: var(--panel); border: 1px solid var(--panel-line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 14px;
}
.fp-section + .fp-section { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.fp-label { font-size: 11px; color: var(--muted); letter-spacing: .08em; margin: 0 0 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid var(--line); background: var(--bg2); color: var(--muted);
  border-radius: 999px; padding: 5px 11px; font-size: 12.5px; cursor: pointer; user-select: none;
}
.chip .g { font-size: 14px; }
.chip[aria-pressed="true"] { color: var(--text); border-color: currentColor; background: color-mix(in srgb, currentColor 14%, transparent); }
.chip[data-body="mercury"][aria-pressed="true"] { color: var(--c-mercury); }
.chip[data-body="venus"][aria-pressed="true"]   { color: var(--c-venus); }
.chip[data-body="mars"][aria-pressed="true"]     { color: var(--c-mars); }
.chip[data-body="jupiter"][aria-pressed="true"]  { color: var(--c-jupiter); }
.chip[data-body="saturn"][aria-pressed="true"]   { color: var(--c-saturn); }
.chip[data-body="uranus"][aria-pressed="true"]   { color: var(--c-uranus); }
.chip[data-body="neptune"][aria-pressed="true"]  { color: var(--c-neptune); }
.chip[data-body="pluto"][aria-pressed="true"]    { color: var(--c-pluto); }
.chip[data-opt][aria-pressed="true"] { color: var(--gold); }

/* ---- calendar ---- */
.weekhead { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 6px; }
.weekhead div { text-align: center; font-size: 11px; color: var(--muted); padding: 2px 0; }
.weekhead .sun { color: #e2674a; }
.weekhead .sat { color: #6fa8dc; }
/* 月送り（スワイプ/ボタン）の方向スライド演出 */
@keyframes slideNext { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes slidePrev { from { transform: translateX(-100%); } to { transform: translateX(0); } }
.view.slide-next { animation: slideNext .16s ease-out; }
.view.slide-prev { animation: slidePrev .16s ease-out; }

.cal { display: flex; flex-direction: column; gap: 6px; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; position: relative; }
.cal.has-merc .cell { padding-bottom: 44px; } /* 逆行下線＋逆行バー＋留矢印のレーンを下部に確保 */
.cell {
  position: relative; min-height: 94px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; padding: 5px 5px 9px; cursor: pointer;
  overflow: hidden; transition: border-color .12s;
}
.cell:hover { border-color: var(--panel-line); }
.cell.out { opacity: .38; }
.cell.today { border-color: var(--today); box-shadow: 0 0 0 1px var(--today) inset; }
.cell .dnum { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cell.today .dnum { color: var(--today); font-weight: 700; }
.cell .sun { color: #e2674a; }
.cell .sat { color: #6fa8dc; }
.evs { display: flex; flex-direction: column; gap: 3px; margin-top: 3px; }
.ev {
  display: flex; align-items: center; gap: 1px; font-size: 10.5px; line-height: 1.3;
  padding: 1px 4px; border-radius: 5px; background: rgba(255,255,255,.05);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ev .g { font-size: 12px; }
.ev .nm { font-weight: 600; }
.ev .ar { opacity: .6; margin: 0 1px; }
/* 月相アイコン（CSS描画。新月=暗 / 満月=明 / 上弦=右半分明 / 下弦=左半分明） */
.moon { width: 11px; height: 11px; border-radius: 50%; border: 1px solid #cdd0ec; display: inline-block; box-sizing: border-box; flex: none; vertical-align: middle; }
.moon.new   { background: #0e0f24; }
.moon.full  { background: #e9ebfb; border-color: #e9ebfb; }
.moon.first { background: linear-gradient(90deg, #0e0f24 0 50%, #e9ebfb 50% 100%); }
.moon.last  { background: linear-gradient(90deg, #e9ebfb 0 50%, #0e0f24 50% 100%); }
.ev.phase { background: rgba(205,208,236,.12); }
.ev.phase .sn { color: #e3e5f7; font-weight: 700; }

.ev.station { background: var(--gold-dim); }
.ev.station .sn { color: var(--gold); font-weight: 600; }
.ev .ryu { background: var(--gold); color: #20183a; font-size: 8.5px; font-weight: 700; border-radius: 3px; padding: 0 3px; margin-right: 2px; flex: none; }
.ev.voc { color: var(--c-moon); background: rgba(205,208,236,.08); }
.ev-more { font-size: 10px; color: var(--muted); padding-left: 4px; }

/* 逆行中の天体カラー（水星以外）= セル下端の下線 */
.retro-ribbon { position: absolute; left: 5px; right: 5px; bottom: 4px; display: flex; gap: 2px; height: 3px; }
.retro-ribbon span { flex: 1; border-radius: 2px; opacity: .95; }

/* 水星の逆行期間バー（淡いラベル調。下部レーンに絶対配置で列をまたいで連続） */
.merc-bar {
  position: absolute; bottom: 8px; z-index: 3; pointer-events: none; overflow: hidden;
  height: 17px; display: flex; align-items: center;
  background: color-mix(in srgb, var(--c-mercury) 15%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--c-mercury) 45%, transparent);
  border-radius: 0;
}
.merc-bar.cap-l { border-top-left-radius: 9px; border-bottom-left-radius: 9px; }
.merc-bar.cap-r { border-top-right-radius: 9px; border-bottom-right-radius: 9px; }
.merc-bar:not(.cap-l) { border-left-width: 0; } /* 週またぎは連続して見せる */
.merc-bar:not(.cap-r) { border-right-width: 0; }
.merc-lbl { font-size: 10px; font-weight: 700; white-space: nowrap; padding: 0 7px; color: color-mix(in srgb, var(--c-mercury) 48%, #ffffff); }
.merc-lbl.rt { margin-left: auto; }

/* 留期間 = ←→ 矢印（バーの上に重ねる）。矢印中央に「留」 */
.merc-arrow {
  position: absolute; bottom: 27px; height: 14px; z-index: 4; pointer-events: none;
  display: flex; align-items: center; gap: 3px;
  color: color-mix(in srgb, var(--c-mercury) 62%, #ffffff);
}
.merc-arrow .ln { flex: 1; height: 0; border-top: 1.5px solid currentColor; min-width: 3px; }
.merc-arrow .ah { font-size: 13px; line-height: 1; }
.merc-arrow .albl { font-size: 10px; font-weight: 700; white-space: nowrap; color: color-mix(in srgb, var(--c-mercury) 50%, #ffffff); }

/* ---- list view ---- */
.listwrap { display: flex; flex-direction: column; gap: 2px; }
.list-day { display: grid; grid-template-columns: 64px 1fr; gap: 12px; padding: 10px 6px; border-bottom: 1px solid var(--line); }
.list-date { text-align: right; }
.list-date .d { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.list-date .wd { font-size: 11px; color: var(--muted); }
.list-date.today .d { color: var(--today); }
.list-evs { display: flex; flex-direction: column; gap: 6px; }
.list-ev { display: flex; align-items: baseline; gap: 8px; font-size: 13.5px; }
.list-ev .time { font-size: 11.5px; color: var(--muted); min-width: 38px; font-variant-numeric: tabular-nums; }
.list-ev .g { font-size: 15px; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; font-size: 13px; }

/* ---- detail sheet ---- */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(6,6,18,.6); backdrop-filter: blur(2px); }
.sheet-card {
  position: relative; width: 100%; max-width: 880px; background: var(--bg2);
  border: 1px solid var(--panel-line); border-bottom: 0; border-radius: 18px 18px 0 0;
  padding: 16px 18px 28px; max-height: 78vh; overflow-y: auto;
  animation: slideup .18s ease;
}
@keyframes slideup { from { transform: translateY(16px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sheet-head h3 { margin: 0; font-size: 16px; }
.sheet-close { border: 0; background: transparent; color: var(--muted); font-size: 26px; line-height: 1; cursor: pointer; }
.sheet-body { display: flex; flex-direction: column; gap: 10px; }
.det {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
}
.det .g { font-size: 20px; line-height: 1.1; }
.det .body-t { font-weight: 700; font-size: 14px; }
.det .desc { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.det .when { font-size: 11.5px; color: var(--gold); margin-top: 3px; }
.det.station { border-color: var(--panel-line); }

@media (max-width: 560px) {
  .app { padding: 12px 10px 36px; }
  .title h1 { font-size: 17px; }
  .cell { min-height: 78px; padding: 4px 3px 8px; }
  .cal.has-merc .cell { padding-bottom: 44px; }
  .merc-bar { bottom: 7px; height: 15px; }
  .merc-lbl { font-size: 9px; padding: 0 4px; }
  .merc-arrow { bottom: 24px; }
  .merc-arrow .albl { font-size: 9px; }
  .ev { font-size: 9px; padding: 1px 3px; }
  .ev .nm .sn { font-size: 9px; }
  .ev .g { font-size: 11px; }
  .week, .weekhead { gap: 4px; }
  .merc-label { font-size: 9px; padding: 0 5px; }
  .subtitle { display: none; }
}
