* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: #0b0e1a;
  color: #e8e6f0;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  min-height: 100vh;
}

.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding: 10px 14px;
  background: #151a2e;
  border: 1px solid #2a3152;
  border-radius: 10px;
}

.time-buttons {
  display: flex;
  gap: 6px;
}

.time-buttons button {
  min-width: 44px;
  padding: 8px 6px;
  font-size: 14px;
  font-weight: 600;
  color: #e8e6f0;
  background: #232a4a;
  border: 1px solid #3a4270;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.time-buttons button:hover {
  background: #2f3860;
}

.time-buttons button.active {
  background: #4a3f8f;
  border-color: #7a6fd0;
  box-shadow: 0 0 8px rgba(122, 111, 208, 0.5);
}

.time-buttons button.now.active {
  background: #1f6b4a;
  border-color: #3fae7c;
  box-shadow: 0 0 8px rgba(63, 174, 124, 0.5);
}

/* スマホなどの狭い画面では時間ボタンを枠内に収める */
@media (max-width: 520px) {
  .time-buttons {
    width: 100%;
    gap: 4px;
  }

  .time-buttons button {
    flex: 1;
    min-width: 0;
    padding: 7px 2px;
    font-size: 12px;
  }
}

.time-display {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 日時ピッカー: 表示欄 + カレンダーボタンで開くポップアップ */
.time-picker {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tp-display {
  width: 17ch;
  padding: 6px 8px;
  font-size: 13px;
  font-family: inherit;
  color: #e8e6f0;
  background: #0f1326;
  border: 1px solid #3a4270;
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
}

.tp-cal-btn {
  display: flex;
  padding: 7px;
  color: #8f88b8;
  background: #232a4a;
  border: 1px solid #3a4270;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tp-cal-btn:hover {
  color: #e8e6f0;
  background: #2f3860;
}

.tp-cal-btn.open {
  color: #fff;
  background: #4a3f8f;
  border-color: #7a6fd0;
}

.tp-pop {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 20;
  padding: 10px;
  background: #151a2e;
  border: 1px solid #3a4270;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

.tp-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-bottom: 6px;
}

.tp-nav-label {
  flex: 1;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
}

.tp-nav-btn {
  width: 26px;
  height: 26px;
  font-size: 13px;
  color: #8f88b8;
  background: none;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

.tp-nav-btn:hover {
  color: #e8e6f0;
  background: #2f3860;
}

.tp-week,
.tp-grid {
  display: grid;
  grid-template-columns: repeat(7, 30px);
}

.tp-week span {
  padding: 2px 0;
  font-size: 10px;
  text-align: center;
  color: #8f88b8;
}

.tp-week .tp-sun {
  color: #d08a8a;
}

.tp-week .tp-sat {
  color: #8a9ed0;
}

.tp-grid button {
  height: 26px;
  font-size: 12px;
  color: #e8e6f0;
  background: none;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}

.tp-grid button:hover {
  background: #2f3860;
}

.tp-grid button.tp-out {
  color: #565a7a;
}

.tp-grid button.tp-today {
  box-shadow: inset 0 0 0 1px #6a6098;
}

.tp-grid button.tp-sel {
  color: #fff;
  background: #4a3f8f;
}

/* 時刻スピナー (時分秒それぞれに ▲▼) */
.tp-time {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid #2a3152;
}

.tp-seg {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.tp-btn {
  padding: 0 6px;
  font-size: 8px;
  line-height: 1.6;
  color: #6f68a0;
  background: none;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.tp-btn:hover {
  color: #e8e6f0;
  background: #2f3860;
}

.tp-btn:active {
  color: #fff;
  background: #4a3f8f;
}

.tp-val {
  width: 100%;
  padding: 1px 0;
  font-size: 14px;
  font-family: inherit;
  text-align: center;
  color: #ffd97a;
  background: none;
  border: none;
  border-radius: 3px;
  font-variant-numeric: tabular-nums;
}

.tp-val:focus {
  outline: none;
  background: #232a4a;
  color: #fff;
}

.tp-sep {
  color: #6f68a0;
  font-size: 13px;
}

.tp-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #2a3152;
}

.tp-picked {
  flex: 1;
  font-size: 11px;
  color: #ffd97a;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tp-apply,
.tp-cancel {
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

.tp-apply {
  color: #e8e6f0;
  background: #4a3f8f;
  border: 1px solid #7a6fd0;
}

.tp-apply:hover {
  background: #5c4fae;
}

.tp-cancel {
  color: #8f88b8;
  background: #1a2038;
  border: 1px solid #2a3152;
}

.tp-cancel:hover {
  color: #e8e6f0;
  background: #232a4a;
}

.range-warning {
  font-size: 12px;
  color: #ffb45e;
}

.sign-select {
  position: relative;
  display: flex;
  align-items: center;
  font-size: 13px;
}

#top-sign {
  background: #0f1326;
  color: #e8e6f0;
  border: 1px solid #3a4270;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

#top-sign:hover {
  background: #1a2038;
}

#sign-pop {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 8px;
  background: #10142a;
  border: 1px solid #3a4270;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

#sign-pop[hidden] {
  display: none;
}

/* タッチで押しやすいよう1項目を大きめにする */
.sign-pop-item {
  padding: 10px 12px;
  font-size: 14px;
  color: #e8e6f0;
  background: #1a2038;
  border: 1px solid #2a3152;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.sign-pop-item:hover {
  background: #232a4a;
}

.sign-pop-item.selected {
  background: #4a3f8f;
  border-color: #7a6fd0;
}

main {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 16px;
  align-items: flex-start;
}

#chart-container {
  flex: 1 1 600px;
  min-width: 320px;
  position: relative;
}

/* ホロスコープ左上の表示中時刻。止まっているときはオレンジ、移動中は薄い灰色 */
#display-time {
  position: absolute;
  top: 6px;
  left: 8px;
  font-size: 12px;
  color: #ffd97a;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

#display-time.moving {
  color: #8f88b8;
  font-weight: 400;
}

/* 表示中時刻の下の日の出/日の入り (3行目に基準地の東京 (JST)) */
#sun-times {
  position: absolute;
  top: 24px;
  left: 8px;
  font-size: 11px;
  line-height: 1.5;
  color: #8f88b8;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

#sun-times .sun-loc {
  font-size: 10px;
  color: #6f68a0;
}

.chart-tooltip {
  display: none;
  position: absolute;
  z-index: 10;
  pointer-events: none;
  max-width: 300px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.6;
  background: rgba(13, 16, 36, 0.96);
  border: 1px solid #5a5488;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
}

.chart-tooltip .tt-head {
  font-size: 14px;
  font-weight: 600;
  color: #ffd75e;
}

.chart-tooltip .tt-theme {
  color: #c9c3e8;
  margin-bottom: 4px;
}

.chart-tooltip .tt-trait {
  color: #c9c3e8;
  margin-bottom: 4px;
}

.chart-tooltip .tt-element {
  display: inline-block;
  margin-right: 6px;
  padding: 0 5px;
  font-size: 11px;
  line-height: 1.5;
  border: 1px solid;
  border-radius: 4px;
}

.chart-tooltip .tt-sub {
  color: #8fa3d0;
  font-size: 11px;
}

.chart-tooltip ul {
  list-style: none;
  margin: 2px 0 0;
}

.chart-tooltip .tt-glyph {
  display: inline-block;
  width: 18px;
  font-size: 14px;
}

.chart-tooltip .tt-retro {
  color: #ff8f8f;
  font-size: 11px;
}

.chart-tooltip .tt-aspects {
  margin-left: 22px;
  font-size: 11px;
  color: #a8a0d0;
}

.chart-tooltip .tt-aspects .asp-sym {
  font-size: 13px;
}

.chart-tooltip .tt-aspects .tt-glyph {
  width: 15px;
  font-size: 12px;
}

.chart-tooltip .tt-none {
  color: #6f68a0;
}

#chart-container svg {
  width: 100%;
  height: auto;
  max-height: calc(100vh - 150px);
  display: block;
  margin: 0 auto;
}

/* チャートとリストが横並びになる幅 (600+360+gap16+padding32=1008px 以上) では
   ページ全体のスクロールを止め、右パネルの内部だけをスクロールさせる。
   ヘッダは左カラム幅に収め、右パネルは画面最上部から最下部まで伸ばす */
@media (min-width: 1008px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  .layout {
    display: grid;
    grid-template-columns: minmax(320px, 1fr) 360px;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 16px;
    height: 100dvh;
  }

  .layout main {
    display: contents;
  }

  .layout header {
    grid-column: 1;
    grid-row: 1;
  }

  #chart-container {
    grid-column: 1;
    grid-row: 2;
    min-height: 0;
  }

  /* ヘッダの行数に関わらず残りの行の高さに収める */
  #chart-container svg {
    max-height: 100%;
  }

  /* タブ行は固定し、下のビュー (イベント/惑星) の中身だけをスクロールさせる */
  #planet-list {
    grid-column: 2;
    grid-row: 1 / span 2;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  #planet-view,
  #event-view {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

#planet-list {
  flex: 0 0 360px;
  background: #151a2e;
  border: 1px solid #2a3152;
  border-radius: 10px;
  padding: 12px;
}

.view-tabs {
  display: flex;
  margin-bottom: 10px;
  border-bottom: 1px solid #2a3152;
}

.view-tabs button {
  flex: 1;
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 600;
  color: #8f88b8;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.view-tabs button:hover {
  color: #cfc8f8;
}

.view-tabs button.active {
  color: #e8e6f0;
  border-bottom-color: #7a6fd0;
}

.list-order {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.list-order button {
  flex: 1;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 600;
  color: #8f88b8;
  background: #1a2038;
  border: 1px solid #2a3152;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}

.list-order button:hover {
  background: #232a4a;
}

.list-order button.active {
  color: #e8e6f0;
  background: #4a3f8f;
  border-color: #7a6fd0;
}

.ev-title {
  font-size: 11px;
  color: #8f88b8;
  margin-bottom: 6px;
}

.ev {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 6px;
  font-size: 12px;
  border-bottom: 1px solid #232a4a;
  cursor: pointer;
  white-space: nowrap;
}

.ev:hover {
  background: #1d2340;
}

/* 解釈を開いている行 */
.ev.ev-active {
  background: #2a3160;
  box-shadow: inset 3px 0 0 #7a6fd0;
}

.ev.ev-done {
  background: #131728;
  opacity: 0.45;
}

.ev.ev-done:hover {
  opacity: 0.8;
}

/* 表示中の時刻と同じ日のイベント (完了スタイルより優先して目立たせる)
   淡い金色の背景と細い枠で囲むカード風 (文字と接触するバーは使わない) */
.ev.ev-today {
  background: rgba(255, 217, 122, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 217, 122, 0.5);
  border-radius: 6px;
  opacity: 1;
}

.ev.ev-today .ev-date {
  color: #fff3c4;
  font-weight: 700;
}

.ev:last-child {
  border-bottom: none;
}

.ev-date {
  flex: 0 0 88px;
  color: #ffd97a;
  font-variant-numeric: tabular-nums;
  font-size: 11px;
}

.ev-glyph {
  flex: 0 0 16px;
  text-align: center;
}

.ev-retro {
  color: #ff8f8f;
}

.ev-eclipse {
  color: #f0a06a;
  font-weight: 600;
}

.ev-stars {
  margin-left: auto;
  color: #ffd97a;
  font-size: 10px;
  letter-spacing: 1px;
}

#planet-list tr.group-break td {
  border-top: 2px solid #3a4270;
}

#planet-list table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

#planet-list td {
  padding: 5px 4px;
  border-bottom: 1px solid #232a4a;
  white-space: nowrap;
}

#planet-list tr:last-child td {
  border-bottom: none;
}

#planet-list .glyph {
  font-size: 16px;
  width: 24px;
}

#planet-list .deg {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: #ffd97a;
}

#planet-list .transit {
  font-size: 10px;
  color: #8f88b8;
  font-variant-numeric: tabular-nums;
}

#planet-list .transit .jump {
  cursor: pointer;
}

#planet-list .transit .jump:hover {
  color: #cfc8f8;
  text-decoration: underline;
}

#planet-list .retro {
  color: #ff8f8f;
  width: 16px;
  text-align: center;
}

#planet-list .aspect-title {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #2a3152;
  font-size: 12px;
  color: #8fa3d0;
  letter-spacing: 0.1em;
}

#planet-list .asp-sym {
  font-size: 15px;
}

#planet-list .asp-kind {
  font-size: 11px;
  color: #8f88b8;
}

#planet-list .aspect-none {
  font-size: 12px;
  color: #6f68a0;
  padding: 6px 0;
}

/* ---- イベントの解釈 (行クリックで開く LLM の解説) ---- */

/* イベント行の直下に開く解釈ブロック */
.ev-reading {
  margin: 2px 0 8px;
  padding: 8px 10px 8px 12px;
  background: #10142a;
  border-left: 3px solid #7a6fd0;
  border-radius: 0 8px 8px 0;
}

.fortune-loading,
.fortune-error {
  color: #8f88b8;
  font-size: 13px;
  margin: 10px 2px;
  line-height: 1.6;
}

.fortune-error {
  color: #f08c7a;
}

/* 解釈ブロック内の「この時刻で固定」ボタン */
.ev-reading-jump {
  margin-top: 8px;
  padding: 4px 10px;
  font-size: 11px;
  color: #b8b0e0;
  background: #1a2038;
  border: 1px solid #3a4270;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.ev-reading-jump:hover {
  background: #232a4a;
  color: #e8e6f0;
}

.fortune-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #ffd97a;
}

.fortune-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #3a4270;
  border-top-color: #ffd97a;
  border-radius: 50%;
  animation: fortune-spin 0.9s linear infinite;
}

@keyframes fortune-spin {
  to { transform: rotate(360deg); }
}

.fortune-text {
  font-size: 13px;
  line-height: 1.7;
  color: #cfcbe8;
}

.fortune-basis-row {
  margin-top: 6px;
  font-size: 11px;
  color: #8f88b8;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.fortune-basis {
  padding: 2px 8px;
  background: #10142a;
  border: 1px solid #3a4270;
  border-radius: 10px;
  color: #b8b0e0;
  cursor: default;
}

.fortune-basis[data-planet] {
  cursor: pointer;
}

.fortune-basis[data-planet]:hover {
  border-color: #ffd97a;
  color: #ffd97a;
}

