@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@300;400;500;700&family=Noto+Serif+JP:wght@400;700&display=swap');

/* ========================================
   リセット
   ======================================== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-app: #0c0f14;
  --bg-sidebar: #111520;
  --bg-header: #111520;
  --bg-content: #0e1218;
  --bg-mail: #161c26;
  --bg-mail-hover: #1a2230;
  --bg-mail-active: #1e2636;

  --text-primary: #d1d5db;
  --text-secondary: #8b949e;
  --text-muted: #4a5260;
  --text-white: #eaecef;

  --accent: #6b8aaf;
  --accent-bright: #8ba8cc;
  --accent-dim: #3d5570;
  --accent-bg: rgba(107, 138, 175, 0.1);

  --unread-accent: #c9a87c;
  --unread-bg: rgba(201, 168, 124, 0.08);
  --unread-border: rgba(201, 168, 124, 0.4);

  --danger: #c75d5d;
  --danger-bg: rgba(199, 93, 93, 0.12);

  --border: #1e2636;
  --border-light: #2a3444;

  --keyword-bg: rgba(201, 168, 124, 0.12);
  --keyword-border: rgba(201, 168, 124, 0.35);
  --keyword-text: #dfc49a;

  --font-body: 'Noto Sans JP', -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Noto Serif JP', serif;

  --sidebar-w: 180px;
  --header-h: 44px;
}

html {
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.8;
  color: var(--text-primary);
  background: var(--bg-app);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

a { color: var(--accent-bright); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ========================================
   メールクライアント全体レイアウト
   ======================================== */
.app {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

/* ========================================
   サイドバー
   ======================================== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}

.sidebar__logo {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.04em;
}

.sidebar__nav {
  padding: 8px 0;
  flex: 1;
}

.sidebar__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: all 0.15s;
  text-decoration: none;
}

.sidebar__item:hover {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.02);
  text-decoration: none;
}

.sidebar__item.is-active {
  color: var(--text-white);
  background: var(--accent-bg);
  border-left-color: var(--accent);
}

.sidebar__item.is-locked {
  opacity: 0.3;
  pointer-events: none;
}

.sidebar__badge {
  margin-left: auto;
  font-size: 0.7rem;
  background: var(--unread-bg);
  color: var(--unread-accent);
  padding: 0 6px;
  border-radius: 8px;
  min-width: 18px;
  text-align: center;
}

.sidebar__divider {
  height: 1px;
  background: var(--border);
  margin: 6px 16px;
}

/* ========================================
   メインエリア
   ======================================== */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* ヘッダーバー */
.header {
  height: var(--header-h);
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
}

.header__title {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.header__unread-badge {
  font-size: 0.65rem;
  background: var(--danger-bg);
  color: var(--danger);
  padding: 1px 7px;
  border-radius: 8px;
}

/* モード切替（ヘッダー右） */
.mode-toggle {
  display: flex;
  align-items: center;
  gap: 3px;
}

.mode-toggle__label {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-right: 4px;
  letter-spacing: 0.08em;
}

.mode-toggle__btn {
  padding: 2px 9px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all 0.15s;
}

.mode-toggle__btn:hover {
  border-color: var(--border-light);
  color: var(--text-secondary);
}

.mode-toggle__btn.is-active {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
  color: #fff;
}

/* コンテンツ領域 */
.content {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-content);
}

/* ========================================
   メール一覧
   ======================================== */
.mail-list__header {
  padding: 8px 16px;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--bg-sidebar);
}

.mail-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
  text-decoration: none;
  color: inherit;
}

.mail-item:hover {
  background: var(--bg-mail-hover);
  text-decoration: none;
}

.mail-item.is-unread {
  border-left: 3px solid var(--unread-accent);
  background: var(--unread-bg);
}

.mail-item.is-unread .mail-item__sender {
  color: var(--text-white);
  font-weight: 500;
}

.mail-item.is-unread .mail-item__subject {
  color: var(--text-white);
}

/* アバター */
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 500;
  flex-shrink: 0;
  margin-top: 2px;
}

.avatar--unknown {
  background: rgba(201, 168, 124, 0.15);
  color: var(--unread-accent);
}

.avatar--person {
  background: var(--accent-bg);
  color: var(--accent-bright);
}

.mail-item__body {
  flex: 1;
  min-width: 0;
}

.mail-item__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1px;
}

.mail-item__sender {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.mail-item__date {
  font-size: 0.7rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.mail-item__subject {
  font-size: 0.85rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ========================================
   メールスレッド表示（人物ページ共通）
   ======================================== */
.thread {
  padding: 20px;
  max-width: 600px;
}

.thread__header {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.thread__subject {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text-white);
  margin-bottom: 4px;
}

.thread__meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.thread__message {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  line-height: 1.9;
  color: var(--text-primary);
}

.thread__message blockquote {
  border-left: 2px solid var(--border-light);
  padding-left: 12px;
  margin: 8px 0;
  color: var(--text-secondary);
}

/* 質問カード */
.question-cards {
  padding: 16px 0;
}

.question-cards__title {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.question-card {
  display: block;
  width: 100%;
  padding: 10px 14px;
  margin-bottom: 6px;
  background: var(--bg-mail);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}

.question-card:hover {
  background: var(--bg-mail-hover);
  border-color: var(--accent-dim);
}

.question-card.is-answered {
  opacity: 0.4;
  pointer-events: none;
}

.question-card.is-locked {
  display: none;
}

/* 確認モーダル（取消不可アクション用） */
.confirm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.65);
  align-items: center;
  justify-content: center;
}

.confirm-overlay.is-visible { display: flex; }

.confirm-dialog {
  background: var(--bg-mail);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 24px 28px;
  max-width: 340px;
  width: 90%;
  text-align: center;
}

.confirm-dialog__text {
  font-size: 0.9rem;
  color: var(--text-primary);
  margin-bottom: 20px;
  line-height: 1.8;
}

.confirm-dialog__actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* ========================================
   ボタン
   ======================================== */
.btn {
  display: inline-block;
  padding: 9px 28px;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  background: var(--bg-mail);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.btn:hover {
  background: var(--bg-mail-hover);
  border-color: var(--accent-dim);
}

.btn--accent {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
  color: #fff;
}

.btn--accent:hover {
  background: var(--accent);
  border-color: var(--accent);
}

.btn--danger {
  border-color: rgba(199, 93, 93, 0.4);
  color: var(--danger);
}

.btn--danger:hover {
  background: var(--danger-bg);
}

/* ========================================
   EASY モードのキーワード強調
   ======================================== */
.kw {
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

body.easy-mode .kw {
  background: var(--keyword-bg);
  border-bottom: 1.5px solid var(--keyword-border);
  color: var(--keyword-text);
  padding: 0 2px;
  border-radius: 2px;
}

/* ========================================
   モバイル対応
   ======================================== */

/* ハンバーガーボタン（モバイル時のみ表示） */
.hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
}

/* サイドバーオーバーレイ背景 */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 90;
}

@media (max-width: 600px) {
  :root {
    --sidebar-w: 220px;
  }

  .hamburger { display: block; }

  .sidebar {
    position: fixed;
    left: calc(-1 * var(--sidebar-w));
    top: 0;
    bottom: 0;
    z-index: 100;
    transition: left 0.25s ease;
  }

  .sidebar.is-open { left: 0; }

  .sidebar-overlay.is-visible { display: block; }

  body { overflow-x: hidden; }
  .content { overflow-y: auto; }
}

/* ========================================
   reduced motion
   ======================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
