:root {
  --primary: #fff;
  --primary-gradient: linear-gradient(135deg, #8ab4f8, #c58af9);
  --bg-color: #0b0b0b;
  --card-bg: #18191c;
  --header-bg: #1f2023;
  --text-main: #e8eaed;
  --text-muted: #9aa0a6;
  --border-color: #3c4043;

  --crash-bg: rgba(234, 67, 53, 0.15);
  --surge-bg: rgba(52, 168, 83, 0.15);
  --aspect-strong: rgba(251, 189, 5, 0.08);

  --planet: #fbc02d;
  --conjunc: #ff5252;
  --oppos: #448aff;
  --square: #e040fb;
  --trine: #69f0ae;
  --sextile: #18ffff;
  --others: #ffd740;
  --sign: #8ab4f8;
  
  --glass-bg: rgba(24, 25, 28, 0.85);
  --glass-border: rgba(255, 255, 255, 0.1);
}

.light-mode {
  --bg-color: #f0f2f5;
  --card-bg: #ffffff;
  --header-bg: #ffffff;
  --text-main: #1f2023;
  --text-muted: #5f6368;
  --border-color: #dadce0;
  --primary: #1a73e8;
  --glass-bg: rgba(255, 255, 255, 0.75);
  --glass-border: rgba(0, 0, 0, 0.1);
  --primary-gradient: linear-gradient(135deg, #1a73e8, #4285f4);
  
  /* ライトモード用の記号カラー調整（視認性向上） */
  --planet: #bf8f00; /* 濃いめの黄色 */
  --others: #af8f00;
  --sign: #1a73e8;
}

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

body {
  font-family: 'Inter', 'Noto Sans JP', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 0.7rem;
  /* overflow: hidden; */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden; /* 横揺れ防止 */
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 2rem;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border-color);
  position: relative;
  z-index: 100;
}

.logo h1 {
  font-family: 'Tangerine', cursive;
  font-size: 2.2rem;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 700;
  letter-spacing: 1px;
}

.btn-primary {
  background: var(--primary-gradient);
  color: #000;
  border: none;
  padding: 0.4rem 1rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.7rem;
  cursor: pointer;
  transition: transform 0.2s;
}

.btn-secondary {
  background: #08254b;
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 0.4rem 1rem;
  border-radius: 6px;
  font-weight: 500;
  font-size: 0.7rem;
  cursor: pointer;
}

.btn-primary:hover {
  transform: scale(1.02);
}

main {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  /* overflow: hidden; */ /* 内部スクロールを解除 */
}

.filter-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--header-bg);
  padding: 15px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  margin-bottom: 15px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
  min-width: 80px;
}

.filter-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #25262b;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 5px 12px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.72rem;
  transition: all 0.2s ease;
  user-select: none;
}

.filter-chip:hover {
  border-color: var(--primary);
  color: var(--text-main);
}

.filter-chip.active {
  background: #1a73e8;
  color: #fff;
  border: none;
  font-weight: 600;
}

.filter-chip input {
  display: none;
}

.filter-chip::before {
  content: '☐';
  font-family: monospace;
}

.filter-chip.active::before {
  content: '☑';
}

/* アクティブ時：アスペクト種別ごとに色を変える */
.aspect-tab-btn.active[data-aspect="all"] {
  background: #1a73e8;
  color: #fff;
  border: none;
  font-weight: 600;
}

.aspect-tab-btn.active[data-aspect="☌"] {
  background: var(--conjunc);
  color: #000;
  border: none;
  font-weight: 600;
}

.aspect-tab-btn.active[data-aspect="☍"] {
  background: var(--oppos);
  color: #000;
  border: none;
  font-weight: 600;
}

.aspect-tab-btn.active[data-aspect="□"] {
  background: var(--square);
  color: #000;
  border: none;
  font-weight: 600;
}

.aspect-tab-btn.active[data-aspect="△"] {
  background: var(--trine);
  color: #000;
  border: none;
  font-weight: 600;
}

.aspect-tab-btn.active[data-aspect="✱"] {
  background: var(--sextile);
  color: #000;
  border: none;
  font-weight: 600;
}

.aspect-tab-btn.active[data-aspect="⚼"] {
  background: var(--others);
  color: #000;
  border: none;
  font-weight: 600;
}

.table-container {
  width: 100%;
  overflow-x: auto; /* 横スクロールのみ有効化 */
  overflow-y: visible; /* 縦方向はコンテンツに合わせて拡張 */
  background: var(--card-bg);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  position: relative;
  margin-bottom: 2rem;
}

table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
}

th,
td {
  padding: 0.8rem;
  border-bottom: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  min-width: 100px;
  text-align: left;
  font-size: 0.7rem;
}

th {
  background: var(--header-bg);
  color: var(--text-muted);
  font-weight: 600;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 10;
}

.sticky-col {
  position: sticky;
  left: 0;
  background: var(--card-bg);
  z-index: 5;
  border-right: 2px solid var(--border-color);
  min-width: 60px;
}

th.sticky-col {
  z-index: 20;
  background: var(--header-bg);
}

.first-col {
  font-weight: 600;
  color: var(--primary);
  text-align: center;
}

/* 記号カラーリング */
.sym-planet {
  color: var(--planet);
}

.sym-sign {
  color: var(--sign);
  opacity: 0.9;
}

/* アスペクト別配色 */
.asp-conjunc {
  color: var(--conjunc);
}

.asp-oppos {
  color: var(--oppos);
}

.asp-square {
  color: var(--square);
}

.asp-trine {
  color: var(--trine);
}

.asp-sextile {
  color: var(--sextile);
}

.asp-others {
  color: var(--others);
}

/* 背景ハイライト */
.row-crash {
  background-color: var(--crash-bg) !important;
}

.row-surge {
  background-color: var(--surge-bg) !important;
}

.cell-important {
  background-color: var(--aspect-strong);
}

.cell-highlight {
  background: rgba(95, 37, 32, 0.158);
  color: #000 !important;
  font-weight: 600;
}

.event-tag {
  display: block;
  font-size: 0.7rem;
  margin-top: 0.2rem;
  color: var(--text-muted);
  font-style: italic;
}

.event-name {
  font-weight: 500;
  font-size: 0.7rem;
  color: var(--text-main);
}

.importance {
  color: #fbc02d !important;
  /* Force Yellow */
  font-size: 0.7rem;
  margin-left: 0.2rem;
  text-shadow: 0 0 3px rgba(251, 192, 45, 0.5);
}

/* Modal */
.hidden {
  display: none !important;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  background: var(--header-bg);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  padding: 2rem;
  border-radius: 8px;
  width: 90%;
  max-width: 500px;
}

.analysis-modal {
  max-width: 680px !important;
  max-height: 80vh;
  overflow-y: auto;
}

.analysis-modal h2 {
  font-size: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.analysis-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.analysis-item {
  padding: 0.8rem 0;
  border-bottom: 1px solid rgba(60, 64, 67, 0.5);
}

.analysis-item:last-child {
  border-bottom: none;
}

.analysis-item h3 {
  font-size: 0.78rem;
  color: var(--primary);
  border-left: 3px solid var(--primary);
  padding-left: 0.6rem;
  margin-bottom: 0.4rem;
  font-weight: 600;
}

.analysis-item p {
  font-size: 0.72rem;
  line-height: 1.7;
  color: var(--text-muted);
  padding-left: 0.9rem;
  margin: 0;
}

.analysis-modal .modal-actions {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  text-align: right;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* テーブルのフォントサイズ制御 */
#cycleTable th {
  font-size: 0.7rem !important;
}

/* 左端2列目～10列目のヘッダー背景色と固定幅 */
#cycleTable th:nth-child(n+2):nth-child(-n+10),
#cycleTable td:nth-child(n+2):nth-child(-n+10) {
  min-width: 90px !important;
  width: 90px !important;
}




@media (max-width: 768px) {
  header {
    flex-direction: column;
    padding: 1rem;
    gap: 15px;
    height: auto;
    text-align: center;
  }

  header nav {
    flex-direction: column;
    width: 100%;
    gap: 10px !important;
  }

  header .btn-secondary,
  header .theme-toggle-btn {
    width: 100%;
    justify-content: center;
  }

  .logo h1 {
    font-size: 1.8rem;
    line-height: 1.2;
  }

  main {
    padding: 0.5rem;
    height: auto;
    /* overflow-y: auto; */
  }

  .filter-container {
    padding: 10px;
  }

  .table-container {
    width: 100%;
    overflow-x: auto;
    overflow-y: visible;
  }

  #cycleTable td:nth-child(n+2):nth-child(-n+10) {
    font-size: 0.9rem !important;
  }
  
  .banner-container {
    flex-direction: column;
    align-items: center;
  }
}

/* テーマ切替ボタン */
.theme-toggle-btn {
  background: none;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-main);
  transition: all 0.2s;
}

.theme-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: rotate(15deg);
}

.light-mode .theme-toggle-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

.theme-toggle-btn .light-icon { display: none; }
.light-mode .theme-toggle-btn .light-icon { display: inline; }
.light-mode .theme-toggle-btn .dark-icon { display: none; }

/* ライトモード時のグラスモルフィズム強化 */
.light-mode .filter-container,
.light-mode .table-container,
.light-mode .modal-content {

  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.05);
}

.light-mode .filter-chip.active {
  background: var(--primary-gradient);
  color: #ffffff !important;
  border: none;
  box-shadow: 0 2px 8px rgba(26, 115, 232, 0.3);
}

.light-mode .filter-chip:active {
  background: #e1e5ea;
  color: #1a73e8 !important;
}

.light-mode .filter-chip {
  background: #ffffff;
  color: #3c4043;
  border: 1px solid #dadce0;
}

.light-mode .filter-chip:hover {
  background: #f8f9fa;
  border-color: #1a73e8;
  color: #1a73e8;
}

.light-mode .filter-chip.active:hover {
  background: var(--primary-gradient);
  opacity: 0.85;
  color: #ffffff !important;
}

.light-mode .btn-secondary {
  background: #1a73e8;
  color: #ffffff;
  border: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.light-mode .btn-secondary:hover {
  background: #1765cc;
  transform: translateY(-1px);
}

.light-mode .btn-primary {
  color: #ffffff;
}

.light-mode th {
  background: #f1f3f4;
  color: #3c4043;
}


.light-mode .sticky-col {
  background: #ffffff;
}

.light-mode th.sticky-col {
  background: #f1f3f4;
}

.light-mode .event-name {
  color: #202124;
}

.light-mode .logo h1 {
  background: none;
  color: #1a73e8;
  -webkit-text-fill-color: #1a73e8;
  font-family: 'Tangerine', cursive;
}

/* 記号パレット (Symbol Palette) */
.symbol-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
  background: var(--bg-color);
  padding: 6px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
}

.palette-btn {
  background: var(--header-bg);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 2px 6px;
  border-radius: 3px;
  transition: 0.2s;
}

.palette-btn:hover {
  background: var(--primary);
  color: white;
}

/* ページ下部バナー */
.banner-container {
  display: flex;
  justify-content: center;
  margin: 20px auto;
  gap: 10px;
}

.banner-container img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  transition: 0.2s;
}

.banner-container img:hover {
  transform: scale(1.02);
  border-color: var(--primary);
}

/* メモ列 */
.memo-col {
  min-width: 180px;
  color: var(--text-muted);
  font-size: 0.7rem;
  white-space: pre-wrap;
  vertical-align: middle;
  padding: 0.6rem;
  border-left: 2px dashed var(--border-color);
}

.action-col {
  text-align: center;
  min-width: 80px;
}

.edit-row-btn {
  font-size: 0.7rem;
  padding: 4px 8px;
}