@import url('https://fonts.googleapis.com/css2?family=Inter:wght@500;600;700&family=Noto+Sans+JP:wght@500;600;700&display=swap');
:root {
  /* アプリ側のエイリアス */
  --bg-start: var(--color-bg-body-start);
  --bg-end: var(--color-bg-body-end);
  --shell: var(--color-bg-white);
  --ink: var(--color-text-primary);
  --muted: var(--color-text-tertiary);
  --color-border-dark: var(--color-border-medium);
  --shadow: 0 22px 60px rgba(15, 23, 42, 0.22);

  /* カラーパレット */
  --color-primary: #394f49;
  --color-primary-dark: #394f49;
  --color-secondary: #394f49;
  --color-success: #28a745;
  --color-accent: #cdff48;

  /* グレースケール */
  --color-text-primary: #222;
  --color-text-secondary: #333;
  --color-text-tertiary: #495057;
  --color-text-muted: #6c757d;
  --color-text-light: #999;

  /* 背景色 */
  --color-bg-body-start: #1c1e1a;
  --color-bg-body-end: #646464;
  --color-bg-white: #ffffff;
  --color-bg-light: #f8f9fa;
  --color-bg-lighter: #eee;
  --color-bg-primary-light: #f8f9ff;
  --color-bg-gradient-start: #667eea20;
  --color-bg-gradient-end: #764ba220;

  /* ボーダー */
  --color-border-light: #e9ecef;
  --color-border-medium: #dee2e6;
  --color-border-dark: #ccc;

  /* トーン */
  --color-tooltip-bg: #2c3e50;
  --color-tooltip-hover: #34495e;

  /* スペーシング */
  --space-xs: 0.25rem; /* 4px */
  --space-sm: 0.5rem; /* 8px */
  --space-md: 0.625rem; /* 10px */
  --space-lg: 0.9375rem; /* 15px */
  --space-xl: 1.25rem; /* 20px */
  --space-2xl: 1.875rem; /* 30px */
  --space-3xl: 2.5rem; /* 40px */

  /* フォントサイズ */
  --font-size-xs: 0.75rem; /* 12px */
  --font-size-sm: 0.85rem; /* ~13.6px */
  --font-size-base: 0.9rem; /* ~14.4px */
  --font-size-md: 0.95rem; /* ~15.2px */
  --font-size-lg: 1.1rem; /* ~17.6px */
  --font-size-xl: 1.25rem; /* 20px */
  --font-size-2xl: 1.5rem; /* 24px */
  --font-size-3xl: 1.875rem; /* 30px */

  /* ボーダー半径 */
  --radius-sm: 0.25rem; /* 4px */
  --radius-md: 0.375rem; /* 6px */
  --radius-lg: 0.5rem; /* 8px */
  --radius-xl: 0.75rem; /* 12px */
  --radius-2xl: 1.25rem; /* 20px */
  --radius-round: 9999px;

  /* シャドウ */
  --shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.2);
  --shadow-md: 0 0.5rem 1.5625rem rgba(50, 113, 49, 0.3);
  --shadow-lg: 0 1.25rem 3.75rem rgba(0, 0, 0, 0.3);
  --shadow-tooltip: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.3);

  /* トランジション */
  --transition-fast: 0.2s ease;
  --transition-base: 0.3s ease;

  /* その他 */
  --header-height: 3.75rem; /* 60px */
  --footer-height: 2.5rem; /* 40px */
  --scrollbar-width: 0.5rem; /* 8px */
}

/* 基本設定 */
html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', 'Noto Sans JP', sans-serif;
  background-color: #f8fafc;
  color: #334155;
}

* {
  box-sizing: border-box;
}

svg {
  display: block;
  width: 100%;
  height: auto;
}

.wrap {
  position: relative;
  width: 100%;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  padding-top: 100px;
  padding-bottom: 50px;
}

/* ナビゲーション */
.navigation {
  position: absolute;
  top: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.navigation ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 0.25em;
}
.navigation a {
  display: block;
  text-decoration: none;
  color: #334155;
  font-size: 14px;
  padding: 0.5em 1.2em;
  border-radius: 100vmax;
  background-color: var(--shell);
  box-shadow: 0 1px 3px rgba(51, 65, 85, 0.1);
  transition: var(--transition-fast);
}
.navigation a:hover {
  background-color: #e2e8f0;
}
.navigation a.is-current {
  background-color: #0f172a;
  color: #fff;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.2);
  pointer-events: none;
}
.sp-nav-button {
  display: none;
}

@media (max-width: 1000px) {
  .sp-nav-button {
    border: none;
    appearance: none;
    background: #fff;
    display: flex;
    top: 8px;
    right: 8px;
    position: fixed;
    width: 50px;
    height: 50px;
    border-radius: var(--radius-sm);
    font-size: 0;
    z-index: 11;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
  }
  .sp-nav-button span {
    display: block;
    width: 24px;
    height: 2px;
    background-color: #0f172a;
    border-radius: 1px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    transition: top var(--transition-fast), transform var(--transition-fast), opacity var(--transition-fast);
  }
  .sp-nav-button span:nth-child(1) {
    top: 18px;
  }
  .sp-nav-button span:nth-child(2) {
    top: 24px;
  }
  .sp-nav-button span:nth-child(3) {
    top: 30px;
  }
  .sp-nav-button.is-open span:nth-child(1) {
    top: 24px;
    transform: translateX(-50%) rotate(45deg);
  }
  .sp-nav-button.is-open span:nth-child(2) {
    opacity: 0;
  }
  .sp-nav-button.is-open span:nth-child(3) {
    top: 24px;
    transform: translateX(-50%) rotate(-45deg);
  }
  .navigation {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    flex-direction: column;
    align-items: flex-end;
    padding: 4.5rem 1rem 1rem 1rem;
    border-radius: 1.5rem 0 1.5rem 1.5rem;
    background-color: #ffffffee;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.1);
    z-index: 10;
  }
  .navigation.is-open {
    display: flex;
  }
  .navigation ul {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-xs);
  }
  .navigation li,
  .navigation a {
    width: 100%;
  }
  .navigation a {
    line-height: 2;
  }
}

/* タイトル表示 */
.title {
  font-size: min(16px, 5vw);
  font-weight: 700;
  color: #0f172a;
  margin-bottom: var(--space-3xl);
  text-align: left;
  word-break: keep-all;
  position: absolute;
  top: 10px;
  left: 20px;
  max-width: calc(100% - 80px);
}

/* 操作バー: トグルとボタンを横並び */
.control {
  display: flex;
  width: calc(100% - var(--space-3xl));
  max-width: 600px;
  gap: var(--space-xl);
  align-items: center;
}

/* モバイル時は縦並びに切り替え */
@media (max-width: 480px) {
  .control {
    flex-direction: column;
    align-items: stretch;
  }
  .control > button {
    width: 100%;
    margin-left: 0;
  }
}

/* モード切り替えトグルの外枠 */
.switch-mode {
  position: relative;
  display: inline-flex;
  align-items: stretch;
  gap: 6px;
  padding: 6px;
  border-radius: var(--radius-round);
  border: 1px solid #cbd5e1;
  background: #f1f5f9;
  isolation: isolate;
}

/* 各セグメントのクリック領域 */
.switch-mode label {
  position: relative;
  cursor: pointer;
  display: block;
}

/* ラジオ本体は隠して見た目をカスタム */
.switch-mode input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* セグメント内テキスト */
.switch-mode label > span {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-md) 14px;
  border-radius: var(--radius-round);
  color: #334155;
  font-size: 14px;
  line-height: 1.2;
  transition: background-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
}

/* 補足テキスト */
.switch-mode label > span small {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: #64748b;
}

/* 非対応ブラウザ向け: 選択セグメントの塗り */
.switch-mode input:checked + span {
  background: #0f172a;
  color: #f8fafc;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.25);
}
.switch-mode input:checked + span small {
  color: #cbd5e1;
}

/* Anchor Positioning対応時: 背景ピルを選択項目へ追従 */
@supports (position-anchor: --switch-active) {
  .switch-mode::before {
    content: '';
    position: absolute;
    position-anchor: --switch-active;
    left: anchor(left);
    top: anchor(top);
    width: anchor-size(width);
    height: anchor-size(height);
    border-radius: var(--radius-round);
    background: #0f172a;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.25);
    transition: left .28s linear(0, 0.1 20%, 0.8 55%, 1.05 82%, 1 100%), top .22s ease, width .22s ease, height .22s ease;
    z-index: 0;
    pointer-events: none;
  }

  .switch-mode label > span {
    background: transparent;
    box-shadow: none;
  }

  .switch-mode input:checked + span {
    anchor-name: --switch-active;
    background: transparent;
    box-shadow: none;
    color: #f8fafc;
  }
}

/* モバイル時のトグル調整 */
@media (max-width: 480px) {
  .switch-mode {
    flex-direction: column;
    align-items: stretch;
    border-radius: 32px;
  }
  .switch-mode label > span {
    padding: var(--space-md);
    min-height: 52px;
  }
}

/* 非対応モード時の無効化表示 */
.switch-mode.is-disabled {
  opacity: 0.5;
  pointer-events: none;
}
.switch-mode.is-disabled label > span {
  background: #e2e8f0;
  color: #94a3b8;
  box-shadow: none;
}
.switch-mode.is-disabled label > span small {
  color: #cbd5e1;
}

/* モーダルを開くボタン */
.control > button {
  margin-left: auto;
  padding: 0 24px;
  min-height: 48px;
  border: 0;
  border-radius: var(--radius-round);
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #f8fafc;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 10px 24px -16px rgba(15, 23, 42, 0.75);
  transition: transform .14s ease, box-shadow var(--transition-fast), filter var(--transition-fast);
}
.control > button:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
  box-shadow: 0 12px 28px -14px rgba(15, 23, 42, 0.85);
}
.control > button:active {
  transform: translateY(0);
}
.control > button:focus-visible {
  outline: 3px solid #93c5fd;
  outline-offset: 3px;
}

/* モーダルのオーバーレイ */
.panel {
  position: fixed;
  display: none;
  place-items: center;
  background-color: rgba(0,0,0,0.3);
  backdrop-filter: blur(8px);
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  &.is-open {
    display: grid;
  }
}

/* モーダルを閉じるボタン */
.close-panel {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  width: 50px;
  height: 50px;
  background-color: var(--shell);
  border: none;
  cursor: pointer;
  border-radius: var(--radius-round);
  &::before, &::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 2px;
    background-color: #0f172a;
  }
  &::before {
    transform: translate(-50%, -50%) rotate(45deg);
  }
  &::after {
    transform: translate(-50%, -50%) rotate(-45deg);
  }
}

/* 解説本文エリア */
.explanation {
  background-color: var(--shell);
  padding: var(--space-xl);
  border-radius: 16px;
  width: 85%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
}

/* 非対応メッセージ */
.unsupported-message {
  margin-top: var(--space-xl);
  padding: 12px 16px;
  background-color: #fee2e2;
  color: #991b1b;
  border-radius: var(--radius-lg);
  font-size: 14px;
  font-weight: 500;
}

.copy {
  position: absolute;
  bottom: 20px;
  right: 20px;
  a {
    text-decoration: none;
    color: #334155;
    font-size: 12px;
  }
}

/* MPA View Transition */
@view-transition {
  navigation: auto;
}
