    :root {
      --bg: #0d1117;
      --bar-bg: rgba(13, 17, 23, 0.88);
      --drawer-bg: rgba(15, 20, 28, 0.82);
      --border-subtle: rgba(240, 246, 252, 0.12);
      --border-gold: rgba(217, 180, 84, 0.3);
      --gold: #d9b454;
      --text: #e6edf3;
      --text-muted: #8b949e;
      --text-dark: #1b1f24;
      --blue-accent: #1f6feb;
    }

    * {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
      -webkit-tap-highlight-color: transparent;
    }

    body {
      font-family: "Zen Kaku Gothic New", "Noto Sans JP", -apple-system, sans-serif;
      background: var(--bg);
      color: var(--text);
      overflow: hidden;
      height: 100vh;
      width: 100vw;
      display: flex;
    }

    #cy {
      position: absolute;
      top: 0;
      left: 0;
      width: 100vw;
      height: 100vh;
      background: radial-gradient(circle at center, #1b202c 0%, #0d0f14 100%);
      z-index: 1;
    }

    /* ========================================================
       1. Left Permanent Sidebar (Chronology Bar)
       ======================================================== */
    .timeline-sidebar {
      position: absolute;
      top: 0;
      left: 0;
      width: 200px;
      height: 100vh;
      background: var(--bar-bg);
      backdrop-filter: blur(14px);
      border-right: 1px solid var(--border-subtle);
      z-index: 30;
      display: flex;
      flex-direction: column;
      padding: 1.8rem 0.8rem 1.5rem 0.8rem;
      user-select: none;
      box-sizing: border-box;
      transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .header-year-wrap {
      margin-bottom: 2.2rem;
      padding-left: 0.2rem;
    }

    .header-year {
      font-family: 'Google Sans Flex', sans-serif;
      font-size: 2.1rem;
      font-weight: 500;
      color: var(--text);
      letter-spacing: 0.04em;
      line-height: 1.1;
      font-feature-settings: "tnum";
    }

    /* Vertical Chronology Track */
    .chronology-track-wrap {
      display: flex;
      gap: 12px;
      position: relative;
      padding-left: 0;
      overflow: visible;
      height: 420px;
      min-height: 400px;
      margin-bottom: 2rem;
    }

    .rail-column {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 8px;
      height: 100%;
      user-select: none;
      flex-shrink: 0;
    }

    /* The Vertical Rail Line & Knob */
    .rail-container {
      width: 20px;
      height: 100%;
      position: relative;
      display: flex;
      justify-content: center;
      cursor: pointer;
    }

    .rail-line {
      width: 2px;
      height: 100%;
      background: rgba(255, 255, 255, 0.85);
      border-radius: 1px;
      position: relative;
    }

    .rail-knob {
      width: 14px;
      height: 14px;
      background: #ffffff;
      border-radius: 50%;
      position: absolute;
      left: 50%;
      transform: translate(-50%, -50%);
      box-shadow: 0 0 12px rgba(255, 255, 255, 0.95);
      pointer-events: none;
      transition: top 0.1s ease-out;
    }

    .rail-endpoint-label {
      font-family: 'Google Sans Flex', sans-serif;
      font-size: 0.75rem;
      color: var(--text-muted);
      text-align: center;
      line-height: 1.2;
    }

    /* Phase Epoch List */
    .phase-list {
      display: flex;
      flex-direction: column;
      flex: 1;
      min-width: 0; /* Enable flex child shrinking & text ellipsis */
      height: 100%;
      justify-content: space-between;
    }

    .phase-item {
      display: flex;
      flex-direction: column;
      gap: 2px;
      cursor: pointer;
      padding: 0.25rem 0.3rem;
      border-radius: 4px;
      transition: all 0.2s ease;
      border-top: 1px solid transparent;
      min-width: 0;
    }

    .phase-item:not(:first-child) {
      border-top: 1px solid var(--border-subtle);
      padding-top: 0.5rem;
    }

    .phase-item-year {
      font-family: 'Google Sans Flex', sans-serif;
      font-size: 0.8rem;
      color: var(--text-muted);
      letter-spacing: 0.02em;
    }

    .phase-item-title {
      font-size: 0.85rem;
      color: var(--text);
      font-weight: 500;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .phase-item.active .phase-item-year {
      color: var(--gold);
      font-weight: 700;
    }
    .phase-item.active .phase-item-title {
      color: #ffffff;
      font-weight: 700;
    }

    /* Bottom Utility Actions (Fit & Reset & Copyright) */
    .sidebar-actions {
      display: flex;
      flex-direction: column;
      gap: 8px;
      margin-top: auto;
    }

    .side-btn {
      height: 44px;
      border-radius: 4px;
      border: 1px solid var(--border-subtle);
      background: transparent;
      color: #ffffff;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 10px;
      font-size: 0.88rem;
      font-weight: 500;
      cursor: pointer;
      transition: all 0.2s;
    }

    .side-btn:hover {
      background: rgba(255, 255, 255, 0.1);
      border-color: rgba(255, 255, 255, 0.4);
    }

    .side-btn svg {
      width: 18px;
      height: 18px;
      stroke: #ffffff;
    }

    /* Sidebar Copyright Link & Icon */
    .sidebar-copyright-wrap {
      margin-top: 4px;
      padding-top: 6px;
      border-top: 1px solid var(--border-subtle);
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .sidebar-copyright-btn {
      background: none;
      border: none;
      color: var(--text-muted);
      cursor: pointer;
      font-size: 0.72rem;
      line-height: 1.3;
      padding: 4px 6px;
      border-radius: 4px;
      display: flex;
      align-items: center;
      gap: 6px;
      transition: color 0.2s, background 0.2s;
      width: 100%;
      text-align: left;
    }

    .sidebar-copyright-btn:hover {
      color: #ffffff;
      background: rgba(255, 255, 255, 0.05);
    }

    .copyright-badge-icon {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 16px;
      height: 16px;
      border-radius: 50%;
      border: 1px solid currentColor;
      font-size: 0.68rem;
      font-family: serif;
      flex-shrink: 0;
    }

    .copyright-desktop-text {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    /* Generic Modal Dialog for Info/Copyright */
    .app-modal-overlay {
      position: fixed;
      top: 0;
      left: 0;
      width: 100vw;
      height: 100vh;
      background: rgba(0, 0, 0, 0.65);
      backdrop-filter: blur(6px);
      z-index: 999;
      display: none;
      align-items: center;
      justify-content: center;
      padding: 16px;
    }

    .app-modal-overlay.open {
      display: flex;
    }

    .app-modal-box {
      background: #161b22;
      border: 1px solid var(--border-subtle);
      border-radius: 8px;
      width: 100%;
      max-width: 440px;
      box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5);
      overflow: hidden;
      animation: modalFadeIn 0.2s ease-out;
    }

    @keyframes modalFadeIn {
      from { opacity: 0; transform: scale(0.96); }
      to { opacity: 1; transform: scale(1); }
    }

    .app-modal-header {
      padding: 14px 18px;
      border-bottom: 1px solid var(--border-subtle);
      display: flex;
      align-items: center;
      justify-content: space-between;
    }

    .app-modal-title {
      font-size: 0.95rem;
      font-weight: 700;
      color: var(--gold);
    }

    .app-modal-close {
      background: none;
      border: none;
      color: var(--text-muted);
      cursor: pointer;
      font-size: 1.2rem;
      line-height: 1;
      padding: 4px;
    }

    .app-modal-close:hover {
      color: #ffffff;
    }

    .app-modal-body {
      padding: 18px;
      font-size: 0.85rem;
      line-height: 1.6;
      color: var(--text);
      display: flex;
      flex-direction: column;
      gap: 12px;
    }

    .app-modal-footer {
      padding: 10px 18px;
      border-top: 1px solid var(--border-subtle);
      display: flex;
      justify-content: flex-end;
      background: rgba(0, 0, 0, 0.2);
    }

    /* Mobile Floating Epoch Popover (appears during touch dragging) */
    .mobile-epoch-popover {
      display: flex;
      flex-direction: column;
      gap: 4px;
      position: absolute;
      left: 60px;
      top: 150px;
      background: rgba(0, 0, 0, 0.92);
      border: 1px solid var(--border-subtle);
      border-radius: 8px;
      padding: 0.8rem 1rem;
      z-index: 50;
      box-shadow: 0 10px 30px rgba(0,0,0,0.8);
      pointer-events: none;
      min-width: 160px;
      backdrop-filter: blur(16px);
      transform: translateY(-50%);
      opacity: 0;
      visibility: hidden;
      transition: opacity 0.25s ease, visibility 0.25s ease, top 0.08s ease-out;
    }

    .mobile-epoch-popover.visible {
      opacity: 1;
      visibility: visible;
    }

    /* ========================================================
       2. Left Slide-out Person Drawer
       ======================================================== */
    .person-drawer {
      position: absolute;
      top: 0;
      left: 200px;
      width: 334px;
      height: 100vh;
      background: var(--drawer-bg);
      backdrop-filter: blur(20px);
      border-right: 1px solid var(--border-subtle);
      z-index: 25;
      display: flex;
      flex-direction: column;
      overflow-y: auto;
      overflow-x: hidden;
      transform: translateX(-120%);
      opacity: 0;
      pointer-events: none;
      transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
      box-shadow: 10px 0 40px rgba(0,0,0,0.5);
    }

    .person-drawer.open {
      transform: translateX(0);
      opacity: 1;
      pointer-events: auto;
    }

    /* Slit Close Button (Fixed within Drawer) */
    .drawer-close-btn {
      position: sticky;
      top: 32px;
      margin-left: auto;
      margin-right: 24px;
      margin-bottom: -44px; /* Collapse its vertical footprint so header layout stays intact */
      width: 28px;
      height: 28px;
      border: 1px solid rgba(255, 255, 255, 0.6);
      border-radius: 6px;
      background: rgba(0, 0, 0, 0.65);
      backdrop-filter: blur(12px);
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      z-index: 50;
      transition: all 0.2s;
    }

    .drawer-close-btn:hover {
      background: rgba(255, 255, 255, 0.15);
      border-color: #ffffff;
    }

    .drawer-close-slit {
      width: 1px;
      height: 14px;
      background: #ffffff;
    }

    /* Relation Pair Avatar Header */
    .drawer-relation-avatars {
      display: none;
      align-items: center;
      gap: 12px;
      margin-bottom: 6px;
    }

    .relation-node-badge {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 6px;
    }

    .relation-avatar-img {
      width: 72px;
      height: 72px;
      border-radius: 50%;
      border: 2px solid rgba(255, 255, 255, 0.4);
      object-fit: cover;
      background: #111;
    }

    .relation-node-name {
      font-size: 0.82rem;
      font-weight: 700;
      color: #ffffff;
    }

    .relation-arrow-wrap {
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 0 8px;
    }

    .relation-arrow-icon {
      font-size: 1.5rem;
      color: var(--gold);
      line-height: 1;
    }

    /* Person Header Profile */
    .drawer-header {
      padding: 50px 24px 28px 24px;
      display: flex;
      flex-direction: column;
      gap: 18px;
    }

    .drawer-avatar {
      width: 116px;
      height: 116px;
      border-radius: 50%;
      border: 2px solid rgba(255, 255, 255, 0.3);
      object-fit: cover;
      background: #000000;
    }

    .drawer-name-block {
      display: flex;
      flex-direction: column;
      gap: 6px;
    }

    .drawer-name {
      font-size: 1.6rem;
      font-weight: 700;
      color: #ffffff;
      line-height: 1.2;
    }

    .drawer-subname {
      font-size: 0.88rem;
      color: #ffffff;
      opacity: 0.9;
    }

    /* Capsule Badge (Faction + Lifespan) */
    .drawer-capsule {
      display: inline-flex;
      align-items: center;
      height: 28px;
      border-radius: 30px;
      overflow: hidden;
      max-width: 100%;
      width: fit-content;
      font-size: 0.85rem;
      font-weight: 500;
    }

    .capsule-faction {
      background: var(--blue-accent);
      color: #ffffff;
      padding: 4px 14px;
      height: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      border-top-left-radius: 30px;
      border-bottom-left-radius: 30px;
      white-space: nowrap;
      flex-shrink: 0;
    }

    .capsule-years {
      background: #e6edf3;
      color: var(--text-dark);
      padding: 4px 12px;
      height: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      border-top-right-radius: 30px;
      border-bottom-right-radius: 30px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    /* Jump to Epoch Link when character is not on current stage */
    .drawer-jump-banner {
      display: none;
      align-items: center;
      gap: 6px;
      padding: 4px 0;
      color: var(--gold);
      font-size: 0.8rem;
      cursor: pointer;
      background: none;
      border: none;
      text-decoration: none;
      opacity: 0.85;
      transition: all 0.2s ease;
    }

    .drawer-jump-banner:hover {
      opacity: 1;
      text-decoration: underline;
      text-underline-offset: 3px;
    }

    .drawer-jump-banner span.jump-arrow {
      color: var(--gold);
      font-size: 0.82rem;
      transition: transform 0.2s ease;
    }

    .drawer-jump-banner:hover span.jump-arrow {
      transform: translateX(2px);
    }

    /* Tab Switcher (概要 vs 特性) */
    .drawer-tabs {
      display: flex;
      padding: 0 10px;
      gap: 6px;
    }

    .drawer-tab {
      flex: 1;
      height: 40px;
      border-top-left-radius: 4px;
      border-top-right-radius: 4px;
      border: 1px solid var(--border-subtle);
      border-bottom: none;
      background: transparent;
      color: var(--text);
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 0.88rem;
      font-weight: 500;
      cursor: pointer;
      transition: background 0.2s;
    }

    .drawer-tab.active {
      background: rgba(255, 255, 255, 0.08);
      border-color: rgba(255, 255, 255, 0.25);
    }

    .drawer-tab-content {
      padding: 20px 24px;
      background: rgba(255, 255, 255, 0.08);
      font-size: 0.88rem;
      line-height: 1.8;
      color: rgba(230, 237, 243, 0.92);
      letter-spacing: 0.02em;
    }

    /* Tag Exploration Section */
    .drawer-section {
      padding: 20px 24px;
      border-top: 1px solid var(--border-subtle);
      display: flex;
      flex-direction: column;
      gap: 14px;
    }

    .section-title {
      font-size: 0.82rem;
      font-weight: 700;
      color: var(--text-muted);
      letter-spacing: 0.02em;
    }

    .tag-cloud {
      display: flex;
      flex-wrap: wrap;
      gap: 7px;
    }

    .tag-pill {
      background: rgba(240, 246, 252, 0.1);
      border: 1px solid rgba(240, 246, 252, 0.16);
      color: var(--text);
      border-radius: 30px;
      padding: 3px 10px;
      font-size: 0.78rem;
      font-weight: 500;
      cursor: pointer;
      transition: all 0.18s ease;
      user-select: none;
    }

    .tag-pill:hover, .tag-pill.active {
      background: var(--gold);
      border-color: var(--gold);
      color: var(--text-dark);
      font-weight: 700;
      transform: translateY(-1px);
    }

    /* Tag Matched Character List */
    .matched-group {
      display: flex;
      flex-direction: column;
      gap: 12px;
      margin-top: 6px;
    }

    .matched-group-title {
      font-size: 0.88rem;
      font-weight: 700;
      color: #ffffff;
    }

    .matched-item {
      display: flex;
      align-items: center;
      gap: 14px;
      cursor: pointer;
      padding: 4px 8px;
      border-radius: 6px;
      transition: background 0.2s;
    }

    .matched-item:hover {
      background: rgba(255, 255, 255, 0.08);
    }

    .matched-avatar {
      width: 40px;
      height: 40px;
      border-radius: 50%;
      object-fit: cover;
      background: #333333;
    }

    .matched-name {
      font-size: 0.88rem;
      font-weight: 700;
      color: #ffffff;
    }

    .matched-sub {
      font-size: 0.85rem;
      font-weight: 700;
      color: rgba(255, 255, 255, 0.8);
      margin-left: auto;
    }

    /* Wikipedia Link Footer */
    .drawer-wiki-footer {
      padding: 20px 24px 50px 24px;
      border-top: 1px solid var(--border-subtle);
    }

    .wiki-link {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      color: rgba(255, 255, 255, 0.6);
      text-decoration: none;
      font-size: 0.8rem;
      transition: color 0.2s;
    }

    .wiki-link:hover {
      color: var(--gold);
    }

    /* ========================================================
       3. Interactive Map (Top-Right / Bottom-Right)
       ======================================================== */
    .map-card {
      position: absolute;
      top: 0;
      right: 0;
      width: 260px;
      height: 206px;
      background: rgba(0, 0, 0, 0.7);
      backdrop-filter: blur(14px);
      border-bottom-left-radius: 8px;
      border-left: 1px solid var(--border-subtle);
      border-bottom: 1px solid var(--border-subtle);
      z-index: 20;
      overflow: hidden;
      display: flex;
      flex-direction: column;
    }

    .map-svg-wrap {
      flex: 1;
      width: 100%;
      height: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .map-svg-wrap svg {
      width: 100%;
      height: 100%;
      object-fit: contain;
    }

    .country {
      transition: all 0.25s ease;
      cursor: pointer;
    }
    .country:hover {
      filter: brightness(1.3);
      stroke: #ffffff;
      stroke-width: 2px;
    }
    .country.active {
      filter: brightness(1.6) drop-shadow(0 0 6px var(--gold));
      stroke: var(--gold);
      stroke-width: 3px;
    }

    /* ========================================================
       4. Responsive Mobile Adaptation (max-width: 768px)
       ======================================================== */
    @media (max-width: 768px) {
      .timeline-sidebar {
        width: 51px;
        padding: 1.5rem 0.2rem calc(2rem + env(safe-area-inset-bottom, 20px)) 0.2rem;
        align-items: center;
      }

      .header-year-wrap {
        display: none;
      }

      /* Compact vertical header label on mobile */
      .mobile-header-year {
        display: block;
        position: absolute;
        top: 25px;
        left: 65px;
        font-family: 'Google Sans Flex', sans-serif;
        font-size: 1.7rem;
        font-weight: 500;
        color: #ffffff;
        letter-spacing: 0.04em;
        line-height: 1;
        z-index: 40;
        pointer-events: none;
      }

      .chronology-track-wrap {
        padding-left: 0;
        gap: 0;
        height: 380px;
        min-height: 360px;
      }

      .phase-list {
        display: none; /* Hide full text on mobile rail */
      }

      .rail-container {
        width: 32px;
      }

      .rail-line {
        height: 100%;
      }

      .rail-endpoint-label {
        font-family: 'Google Sans Flex', sans-serif;
        font-size: 0.8rem;
        color: var(--text-muted);
        text-align: center;
        line-height: 1.2;
      }

      /* Small icon buttons */
      .sidebar-actions {
        gap: 8px;
        align-items: center;
      }

      .side-btn {
        width: 30px;
        height: 30px;
        padding: 0;
      }
      .side-btn span {
        display: none;
      }

      .sidebar-copyright-wrap {
        width: 100%;
        justify-content: center;
        padding-top: 4px;
      }

      .sidebar-copyright-btn {
        width: 30px;
        height: 30px;
        padding: 0;
        justify-content: center;
      }

      .copyright-desktop-text {
        display: none;
      }

      /* Mobile Person Drawer: Slides over from x=47px */
      .person-drawer {
        left: 47px;
        width: calc(100vw - 47px);
        max-width: 340px;
        height: 100dvh;
        padding-bottom: calc(70px + env(safe-area-inset-bottom, 20px));
      }

      .drawer-wiki-footer {
        padding: 20px 24px calc(80px + env(safe-area-inset-bottom, 20px)) 24px;
      }

      /* Give ample top clearance on mobile so avatar clears the top-left year badge */
      .person-drawer .drawer-header {
        padding-top: 85px;
      }

      .person-drawer .drawer-close-btn {
        top: 24px;
      }

      /* Mobile Map: Snaps to Bottom-Right */
      .map-card {
        top: auto;
        bottom: 0;
        right: 0;
        width: 200px;
        height: 158px;
        border-bottom-left-radius: 0;
        border-top-left-radius: 8px;
        border-top: 1px solid var(--border-subtle);
      }
    }
