/* ============================================================
   プロフィールモーダル
   ============================================================ */
.profile-modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--black-alpha-50);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}

.profile-modal {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 28px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-width: 320px;
  max-width: 420px;
  width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.profile-modal-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid var(--primary);
  object-fit: cover;
  margin-bottom: 4px;
}

.profile-modal-name {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--heading);
}

.profile-modal-email {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 8px;
}

.profile-modal-logout {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 24px;
  background: var(--primary);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
  transition: background 0.2s;
}

.profile-modal-logout:hover {
  background: var(--primary-hover);
}

.profile-modal-logout .material-symbols-outlined {
  font-size: 18px;
}

.profile-modal-divider {
  width: 100%;
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.profile-modal-sessions-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.profile-modal-sessions-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.profile-modal-sessions-header .material-symbols-outlined {
  font-size: 16px;
}

.profile-sessions-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  max-height: 200px;
  overflow-y: auto;
}

.profile-sessions-loading,
.profile-sessions-empty {
  font-size: 0.8rem;
  color: var(--text-light);
  text-align: center;
  padding: 8px;
}

.profile-session-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--hover-bg);
  border: 1px solid transparent;
}

.profile-session-item.current {
  border-color: var(--primary);
  background: var(--primary-alpha-10);
}

.profile-session-icon {
  font-size: 18px;
  color: var(--text-light);
  flex-shrink: 0;
}

.profile-session-item.current .profile-session-icon {
  color: var(--primary);
}

.profile-session-info {
  flex: 1;
  min-width: 0;
}

.profile-session-device {
  font-size: 0.85rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.profile-session-current-badge {
  font-size: 0.7rem;
  background: var(--primary);
  color: var(--white);
  padding: 1px 6px;
  border-radius: 10px;
}

.profile-session-meta {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 1px;
}

.profile-session-revoke {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  transition: color 0.2s, background 0.2s;
  flex-shrink: 0;
}

.profile-session-revoke:hover {
  color: #ff6b6b;
  background: rgba(255, 107, 107, 0.1);
}

.profile-session-revoke .material-symbols-outlined {
  font-size: 18px;
}

.profile-logout-others {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 16px;
  background: none;
  color: #ff6b6b;
  border: 1px solid rgba(255, 107, 107, 0.4);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
  font-family: inherit;
  transition: background 0.2s, border-color 0.2s;
  width: 100%;
}

.profile-logout-others:hover {
  background: rgba(255, 107, 107, 0.1);
  border-color: #ff6b6b;
}

.profile-logout-others:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.profile-logout-others .material-symbols-outlined {
  font-size: 16px;
}/* ============================================================
   ナビゲーションドロワー（モバイル専用）
   ============================================================ */
.nav-drawer,
.session-list,
.files-list,
.xterm-viewport {
  touch-action: pan-y;
}

.nav-drawer {
  position: fixed;
  left: -290px;
  top: 0;
  width: 280px;
  height: 100vh;
  height: 100dvh;
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  z-index: 310;
  transition: left 0.25s ease;
  box-shadow: 2px 0 16px rgba(0, 0, 0, 0.15);
  /* スクロールコンテナはflexを使わない（iOS Safariでflex+overflow-yが効かないバグ対策） */
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* コンテンツのflexレイアウトはスクロールコンテナの内側で行う。
   min-height:100%により余白がある時はフッターが下端に固定される。 */
.nav-drawer-scroll {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.nav-drawer.open {
  left: 0;
}

.nav-drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--black-alpha-50);
  z-index: 309;
}

.nav-drawer-overlay.active {
  display: block;
}

.nav-drawer-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: #282a36;
  flex-shrink: 0;
}

.nav-drawer-kamon {
  width: 24px;
  height: 24px;
  animation: spin 20s linear infinite;
}

.nav-drawer-title {
  font-size: 1rem;
  font-weight: 600;
  color: white;
  letter-spacing: 0.05em;
  flex: 1;
}

.nav-drawer-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.nav-drawer-close:hover {
  color: white;
  background: rgba(255, 255, 255, 0.15);
}

.nav-drawer-close .material-symbols-outlined {
  font-size: 20px;
}

.nav-drawer-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.nav-drawer-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid var(--primary);
  object-fit: cover;
  margin-bottom: 8px;
}

.nav-drawer-user-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--heading);
  text-align: center;
}

.nav-drawer-user-email {
  font-size: 0.78rem;
  color: var(--text-light);
  text-align: center;
  margin-top: 2px;
}

.nav-drawer-nav {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  padding: 8px 0;
  gap: 2px;
}

.nav-drawer-tab {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 20px;
  background: none;
  border: none;
  border-radius: 0;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  width: 100%;
}

.nav-drawer-tab:hover {
  background: var(--primary-alpha-10);
}

.nav-drawer-tab.active {
  background: var(--primary-alpha-15);
  color: var(--primary);
  font-weight: 600;
}

.nav-drawer-tab .material-symbols-outlined {
  font-size: 22px;
  flex-shrink: 0;
}

.nav-drawer-tab.active .material-symbols-outlined {
  color: var(--primary);
}

.nav-drawer-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-drawer-sessions-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}

.nav-drawer-sessions-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.nav-drawer-sessions-header .material-symbols-outlined {
  font-size: 15px;
}

.nav-drawer-sessions-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 160px;
  overflow-y: auto;
}

.nav-drawer-reload {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-light);
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.nav-drawer-reload:hover {
  background: var(--primary-alpha-10);
  color: var(--text);
}

.nav-drawer-reload .material-symbols-outlined {
  font-size: 18px;
}

.nav-drawer-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-light);
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.nav-drawer-logout:hover {
  background: var(--primary-alpha-10);
  color: var(--text);
}

.nav-drawer-logout .material-symbols-outlined {
  font-size: 18px;
}

.sidebar-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-title {
  font-size: 0.85rem;
  color: var(--text-light);
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar-title .material-symbols-outlined {
  font-size: 16px;
}

.btn-new-session {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
  transition: background 0.2s;
}

.btn-new-session:hover {
  background: var(--primary-hover);
}

.btn-new-session .material-symbols-outlined {
  font-size: 18px;
}

/* セッションリスト */
.session-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}

.session-item {
  display: flex;
  align-items: center;
  padding: 9px 14px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all 0.15s;
  position: relative;
  gap: 8px;
  min-width: 0;
}

.session-item:hover {
  background: var(--primary-alpha-10);
}

.session-item.active {
  background: var(--primary-alpha-15);
  border-left-color: var(--primary);
}

.session-item-icon {
  font-size: 14px;
  color: var(--text-light);
  flex-shrink: 0;
}

.session-item-body {
  flex: 1;
  min-width: 0;
}

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

.session-item-meta {
  font-size: 0.72rem;
  color: var(--text-light);
  margin-top: 1px;
}

.session-item-delete {
  opacity: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-light);
  padding: 2px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.session-item:hover .session-item-delete {
  opacity: 1;
}

.session-item-delete:hover {
  color: #c0392b;
  background: rgba(192, 57, 43, 0.1);
}

.session-item-delete .material-symbols-outlined {
  font-size: 16px;
}

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* アプリタイトルバー */
.aichat-titlebar {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.aichat-titlebar-icon {
  width: 30px;
  height: 30px;
  background: var(--primary-alpha-15);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.aichat-titlebar-icon .material-symbols-outlined {
  font-size: 18px;
  color: var(--primary);
}

.aichat-titlebar-text h2 {
  font-size: 0.95rem;
  color: var(--heading);
}

.aichat-titlebar-text span {
  font-size: 0.75rem;
  color: var(--text-light);
}

/* メッセージバブル */
.message {
  display: flex;
  gap: 10px;
  max-width: 90%;
}

/* ツール使用インジケーター */
.tool-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.78rem;
  color: var(--text-light);
  margin: 2px 0;
}

.tool-indicator .material-symbols-outlined {
  font-size: 14px;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* セッション未選択時の空状態 */
.no-session-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  gap: 16px;
  padding: 40px;
}

.no-session-placeholder .material-symbols-outlined {
  font-size: 56px;
  opacity: 0.3;
}

.no-session-placeholder h3 {
  font-size: 1rem;
  color: var(--text-light);
}

/* ============================================================
   ローディング状態
   ============================================================ */
.thinking-indicator {
  display: flex;
  gap: 5px;
  padding: 10px 14px;
  align-items: center;
}

.thinking-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
  animation: thinking 1.2s ease-in-out infinite;
}

.thinking-dot:nth-child(2) { animation-delay: 0.2s; }
.thinking-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes thinking {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* 既定は非表示、モバイルのメディアクエリで display: flex に戻す。
   メディアクエリは詳細度を上げないため、この基底ルールは必ずクエリより
   前に置くこと（後ろに置くと後方のこれが勝ち、モバイルでボタンが消える） */
.mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  padding: 4px;
}

.mobile-menu-btn .material-symbols-outlined {
  font-size: 22px;
}

/* ============================================================
   モバイル対応
   ============================================================ */
@media (max-width: 768px) {
  /* 横幅が足りないためステータスバーの利用枠は隠す */
  .header-usage { display: none; }

  :root {
    --mobile-rail-width: 44px;
  }

  #app {
    flex-direction: row;
  }

  .mobile-nav-rail {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 0 0 var(--mobile-rail-width);
    width: var(--mobile-rail-width);
    background: #282a36;
    border-right: 1px solid #313244;
    z-index: 210;
    padding: 6px 0 8px;
    gap: 4px;
  }

  .rail-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #cdd6f4;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    position: relative;
  }

  .rail-btn:active {
    background: #313244;
  }

  .rail-kamon-icon {
    width: 22px;
    height: 22px;
    animation: spin 20s linear infinite;
  }

  .rail-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    width: 100%;
  }

  .rail-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #6c7086;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .rail-tab .material-symbols-outlined {
    font-size: 22px;
  }

  .rail-tab.active {
    color: #f9e2af;
    background: #313244;
  }

  .rail-tab:active {
    background: #45475a;
  }

  .rail-coffee-screens {
    flex-direction: column;
    gap: 2px;
    height: auto;
    min-height: 36px;
    padding: 4px 0;
  }

  .rail-coffee-screens .terminal-status {
    width: 6px;
    height: 6px;
    flex-shrink: 0;
  }

  .rail-coffee-screens .material-symbols-outlined {
    font-size: 20px;
  }

  .rail-coffee-video .material-symbols-outlined {
    font-size: 20px;
  }

  /* 開いている間は点灯させる（プレイヤーがターミナルの高さを削っているため、
     なぜ狭いのかがレールを見れば分かるようにする） */
  .rail-coffee-video.on {
    background: #313244;
    color: #89b4fa;
  }

  .rail-spacer {
    flex: 1;
    min-height: 8px;
  }

  .rail-clock {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    padding: 4px 2px 0;
    color: #6c7086;
    font-family: 'Consolas', 'Monaco', monospace;
    line-height: 1.1;
    pointer-events: none;
    user-select: none;
  }

  .rail-clock-time {
    font-size: 0.52rem;
    letter-spacing: -0.02em;
  }

  .rail-clock-date {
    font-size: 0.48rem;
    opacity: 0.85;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    max-height: 72px;
    overflow: hidden;
  }

  /* 上部ヘッダーを廃止し縦方向をコンテンツに譲る */
  .navbar {
    display: none;
  }

  /* iOS Safari でキーボード表示時に body がスクロールしないよう固定
     position: fixed はタップイベントを阻害するため使わない */
  html, body {
    overflow: hidden;
    overscroll-behavior: none;
  }

  /* スクロールバーを非表示（webkit） */
  ::-webkit-scrollbar {
    display: none;
  }

  /* スクロールバーを非表示（Firefox） */
  * {
    scrollbar-width: none;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--black-alpha-50);
    z-index: 99;
  }

  .sidebar-overlay.active {
    display: block;
  }

  .mobile-menu-btn {
    display: flex;
  }

  .system-stats {
    display: none;
  }

  /* モバイルではナビバータブを非表示（ドロワーに移動） */
  .navbar-tabs {
    display: none;
  }
}

