/* ══════════════════════════════════════════
   リセット & ベース
══════════════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg: #0f0f1a;
  --surface: #1a1a2e;
  --surface2: #16213e;
  --border: rgba(255,255,255,0.08);
  --text: #e8e8f0;
  --text-muted: #8888aa;
  --user-bubble: #2563eb;
  --ai-bubble: #1e293b;
  --radius: 18px;
  --radius-sm: 10px;
  --shadow: 0 4px 20px rgba(0,0,0,0.4);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
}

/* ══════════════════════════════════════════
   画面システム
══════════════════════════════════════════ */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.screen.active {
  transform: translateX(0);
}

/* ══════════════════════════════════════════
   画面①: キャラクター選択
══════════════════════════════════════════ */
#screen-select {
  background: var(--bg);
  overflow: hidden;
  transform: translateX(0); /* 最初はこちらが表示 */
}

.select-header {
  padding: 32px 24px 12px;
  text-align: center;
  flex-shrink: 0;
}

.logo-full {
  width: 100%;
  max-width: 260px;
  height: auto;
  display: block;
  margin: 0 auto 4px;
  filter: drop-shadow(0 2px 12px rgba(0, 150, 199, 0.18));
}

.app-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.app-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

.help-link {
  display: inline-block;
  margin-top: 10px;
  padding: 7px 18px;
  background: rgba(0,150,199,0.12);
  border: 1px solid rgba(0,150,199,0.3);
  border-radius: 20px;
  color: #0096c7;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}

.help-link:hover {
  background: rgba(0,150,199,0.22);
  border-color: rgba(0,150,199,0.5);
}

/* ── モード選択 ── */
.mode-section {
  padding: 0 16px 4px;
  flex-shrink: 0;
}

.section-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  margin-bottom: 8px;
  padding-left: 1px;
}

/* ② ステップ番号バッジ */
.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  background: rgba(255,255,255,0.15);
  border-radius: 50%;
  font-size: 10px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}

.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.mode-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  position: relative;
}

.mode-icon { font-size: 20px; flex-shrink: 0; }

.mode-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mode-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.mode-desc {
  font-size: 10px;
  color: var(--text-muted);
}

.mode-card:active { transform: scale(0.97); }

/* ③ 選択状態: キャラクター色と混同しないニュートラル白系 */
.mode-card.active {
  background: rgba(255,255,255,0.10);
  border-color: rgba(255,255,255,0.42);
  border-width: 1.5px;
}
.mode-card.active .mode-title { color: #fff; font-weight: 800; }
.mode-card.active .mode-desc  { color: rgba(255,255,255,0.55); }

/* 選択インジケーター（右上の小さなドット）*/
.mode-card.active::after {
  content: '✓';
  position: absolute;
  top: 5px;
  right: 7px;
  font-size: 9px;
  color: rgba(255,255,255,0.5);
  font-weight: 900;
}

/* ── キャラクターセクションラベル ── */
.char-section-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 6px 17px 4px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
  flex-shrink: 0;
}

/* ── コンテンツ入力エリア（旧 article-section）── */
.content-section {
  padding: 0 16px 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

/* ── 記事読み込みセクション（後方互換） ── */
.article-section {
  padding: 0 16px 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.article-load-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px 20px;
  background: rgba(0,150,199,0.1);
  border: 1px dashed rgba(0,150,199,0.4);
  border-radius: 12px;
  color: #0096c7;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.article-load-btn:hover, .article-load-btn:active {
  background: rgba(0,150,199,0.2);
  border-color: rgba(0,150,199,0.7);
}

/* ④ モード別ボタン色 */
.article-load-btn.mode-article {
  color: #0096c7;
  border-color: rgba(0,150,199,0.4);
  background: rgba(0,150,199,0.1);
}
.article-load-btn.mode-proofread {
  color: #fb923c;
  border-color: rgba(234,88,12,0.4);
  background: rgba(234,88,12,0.08);
}
.article-load-btn.mode-proofread:hover, .article-load-btn.mode-proofread:active {
  background: rgba(234,88,12,0.16);
  border-color: rgba(234,88,12,0.7);
}
.article-load-btn.mode-presentation {
  color: #c084fc;
  border-color: rgba(124,58,237,0.4);
  background: rgba(124,58,237,0.08);
}
.article-load-btn.mode-presentation:hover, .article-load-btn.mode-presentation:active {
  background: rgba(124,58,237,0.16);
  border-color: rgba(124,58,237,0.7);
}

.article-load-icon { font-size: 20px; }

.article-loaded-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(0,200,100,0.1);
  border: 1px solid rgba(0,200,100,0.3);
  border-radius: 12px;
}

.article-loaded-icon { font-size: 16px; flex-shrink: 0; }

.article-loaded-text {
  flex: 1;
  font-size: 12px;
  color: #7ec8e3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.article-clear-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
  flex-shrink: 0;
}

/* 記事モーダル タブ */
.article-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  background: rgba(255,255,255,0.04);
  border-radius: 10px;
  padding: 4px;
}

.article-tab {
  flex: 1;
  padding: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.article-tab.active {
  background: rgba(0,150,199,0.25);
  color: #0096c7;
}

.article-tab-content { margin-bottom: 4px; }

#article-url-input {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 14px;
  padding: 12px;
  margin-bottom: 8px;
}

#article-url-input:focus { outline: none; border-color: rgba(0,150,199,0.5); }

.pdf-upload-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 20px;
  background: rgba(255,255,255,0.04);
  border: 2px dashed var(--border);
  border-radius: 12px;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 8px;
}

.pdf-upload-label:hover { border-color: rgba(0,150,199,0.4); color: #0096c7; }
.pdf-upload-label.selected { border-color: rgba(0,200,100,0.5); color: #4ade80; }
#article-pdf-input { display: none; }

.article-input-note {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ── 記事分析カード ── */
.article-analysis-card {
  background: rgba(0, 150, 199, 0.07);
  border: 1px solid rgba(0, 150, 199, 0.22);
  border-radius: 14px;
  overflow: hidden;
}

.analysis-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.analysis-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(0,150,199,0.3);
  border-top-color: #0096c7;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

.analysis-result {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.analysis-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.analysis-field-badge {
  display: inline-block;
  padding: 4px 12px;
  background: rgba(0, 150, 199, 0.2);
  border: 1px solid rgba(0, 150, 199, 0.4);
  border-radius: 20px;
  color: #7ec8e3;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.analysis-level-badge {
  display: inline-block;
  padding: 4px 12px;
  background: rgba(255, 200, 0, 0.12);
  border: 1px solid rgba(255, 200, 0, 0.3);
  border-radius: 20px;
  color: #ffd60a;
  font-size: 12px;
  font-weight: 700;
}

.analysis-summary {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.7;
}

.analysis-concepts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.concept-tag {
  display: inline-block;
  padding: 3px 10px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 11px;
  color: var(--text-muted);
  font-family: monospace;
  letter-spacing: 0.2px;
}

/* モード選択ボタン */
.analysis-mode-btns {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.analysis-mode-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 8px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.analysis-mode-btn .mode-btn-icon {
  font-size: 16px;
}

.analysis-mode-btn.active {
  background: rgba(0, 150, 199, 0.2);
  border-color: rgba(0, 150, 199, 0.5);
  color: #7ec8e3;
}

.analysis-mode-btn:active {
  transform: scale(0.97);
}

/* ── 朗読パネル（チャット画面） ── */
.reading-panel {
  background: linear-gradient(90deg, rgba(0,150,199,0.12), rgba(100,0,200,0.08));
  border-bottom: 1px solid rgba(0,150,199,0.2);
  padding: 10px 16px;
  flex-shrink: 0;
  flex-direction: column;
  gap: 8px;
}

.reading-panel-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.reading-panel-label {
  font-size: 13px;
  font-weight: 600;
  color: #7ec8e3;
}

.reading-panel-count {
  font-size: 12px;
  color: var(--text-muted);
}

.reading-progress-bar {
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
  overflow: hidden;
}

.reading-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #0096c7, #7c3aed);
  border-radius: 4px;
  transition: width 0.4s ease;
  width: 0%;
}

.reading-controls {
  display: flex;
  gap: 8px;
}

.reading-ctrl-btn {
  flex: 1;
  padding: 7px;
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.reading-ctrl-btn:active {
  background: rgba(255,255,255,0.14);
}

.reading-ctrl-btn.reading-stop {
  border-color: rgba(220,38,38,0.3);
  color: #f87171;
}

.reading-ctrl-btn.reading-stop:active {
  background: rgba(220,38,38,0.15);
}

.character-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 10px;
  padding: 2px 16px 4px;
  flex: 1;
  min-height: 0;
}

/* キャラクターカード */
.character-card {
  border-radius: 20px;
  padding: 12px 14px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  min-height: 0;
}

.character-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.05);
  opacity: 0;
  transition: opacity 0.2s;
}

.character-card:active {
  transform: scale(0.96);
}

.character-card:active::before {
  opacity: 1;
}

/* ── キャラクターポートレート ── */
.card-portrait {
  width: clamp(64px, 14vw, 90px);
  height: clamp(64px, 14vw, 90px);
  border-radius: 50%;
  overflow: hidden;
  border: 2.5px solid rgba(255,255,255,0.35);
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
  flex-shrink: 0;
}

.card-portrait-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-portrait-fallback {
  display: none;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  font-size: clamp(28px, 6vw, 44px);
}

/* チャット画面: ヘッダーアバター画像 */
.header-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* チャット画面: メインアバター画像 */
.avatar-portrait-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.card-emoji {
  font-size: clamp(32px, 5vw, 52px);
  line-height: 1;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
}

.card-name {
  font-size: clamp(14px, 2.5vw, 20px);
  font-weight: 700;
  color: #fff;
}

.card-flag {
  font-size: clamp(14px, 2.5vw, 20px);
}

.card-desc {
  font-size: clamp(10px, 1.8vw, 12px);
  color: rgba(255,255,255,0.75);
  text-align: center;
  line-height: 1.4;
}

.select-footer {
  padding: 8px 24px 14px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
}

/* 更新バナー */
.update-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: linear-gradient(135deg, #0096c7, #0077b6);
  padding: 12px 16px;
  box-shadow: 0 -4px 20px rgba(0, 150, 199, 0.4);
  animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.update-banner-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 480px;
  margin: 0 auto;
}

.update-icon {
  font-size: 22px;
  flex-shrink: 0;
}

.update-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.update-text strong {
  font-size: 14px;
  color: #fff;
}

.update-text span {
  font-size: 12px;
  color: rgba(255,255,255,0.8);
}

.update-btn {
  background: #fff;
  color: #0077b6;
  border: none;
  border-radius: 20px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.1s;
}

.update-btn:active {
  transform: scale(0.96);
}

.app-version {
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.app-copyright {
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  letter-spacing: 0.5px;
  margin-top: 4px;
}

/* ══════════════════════════════════════════
   画面②: チャット
══════════════════════════════════════════ */
#screen-chat {
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

/* ── ヘッダー ── */
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 54px 16px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

.back-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 28px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  line-height: 1;
  transition: background 0.15s;
  flex-shrink: 0;
}

.back-btn:active {
  background: rgba(255,255,255,0.1);
}

.header-character-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.header-name {
  font-size: 17px;
  font-weight: 600;
}

.header-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.new-conv-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
}

.new-conv-btn:active {
  background: rgba(255,255,255,0.15);
}

.lang-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}

.lang-btn:active {
  background: rgba(255,255,255,0.15);
}

.lang-btn.active {
  background: rgba(0, 150, 199, 0.25);
  border-color: rgba(0, 150, 199, 0.5);
}

/* 記憶バッジ */
.memory-badge {
  background: linear-gradient(90deg, rgba(0,150,199,0.15), rgba(0,119,182,0.10));
  border-bottom: 1px solid rgba(0,150,199,0.2);
  color: #7ec8e3;
  font-size: 12px;
  padding: 6px 16px;
  text-align: center;
  letter-spacing: 0.3px;
}

.memory-badge strong {
  color: #0096c7;
}

.save-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 20px;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}

.save-btn:active {
  background: rgba(255,255,255,0.15);
}

/* ── アバターエリア ── */
.avatar-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 16px 12px;
  background: var(--surface2);
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}

.avatar-circle {
  position: relative;
  width: 88px;
  height: 88px;
  margin-bottom: 10px;
}

.avatar-emoji {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 46px;
  position: relative;
  z-index: 2;
  border: 3px solid rgba(255,255,255,0.15);
}

.speaking-ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 3px solid transparent;
  opacity: 0;
  transition: opacity 0.3s;
}

.avatar-area.speaking .speaking-ring {
  opacity: 1;
  animation: speakPulse 1s ease-in-out infinite;
}

@keyframes speakPulse {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.08); opacity: 0.5; }
}

.avatar-status {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

/* ── チャット本体 ── */
.chat-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* メッセージバブル */
.message {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  animation: fadeSlideIn 0.3s ease-out;
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.message.user {
  align-self: flex-end;
  align-items: flex-end;
}

.message.ai {
  align-self: flex-start;
  align-items: flex-start;
}

.bubble {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 16px;
  line-height: 1.55;
  word-break: break-word;
}

.message.user .bubble {
  background: var(--user-bubble);
  border-bottom-right-radius: 4px;
  color: #fff;
}

.message.ai .bubble {
  background: var(--ai-bubble);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--border);
}

/* 日本語訳 */
.translation {
  margin-top: 6px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.04);
  border-left: 3px solid;
  border-radius: 0 8px 8px 0;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  animation: fadeIn 0.5s ease-out 0.2s both;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* タイムスタンプ */
.msg-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 0 4px;
}

/* ── 文法訂正パネル ── */
.correction-panel {
  background: #1a1400;
  border-top: 2px solid #d4a017;
  padding: 12px 16px;
  flex-shrink: 0;
  max-height: 160px;
  overflow-y: auto;
}

.correction-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #d4a017;
}

.correction-close {
  background: none;
  border: none;
  color: #d4a017;
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
}

.correction-item {
  margin-bottom: 10px;
  font-size: 13px;
  line-height: 1.6;
}

.correction-item:last-child {
  margin-bottom: 0;
}

.correction-wrong {
  color: #ff6b6b;
  text-decoration: line-through;
  font-family: monospace;
}

.correction-arrow {
  color: var(--text-muted);
  margin: 0 6px;
}

.correction-right {
  color: #51cf66;
  font-weight: 600;
  font-family: monospace;
}

.correction-tip {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 2px;
}

.correction-category {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
  margin-bottom: 4px;
  letter-spacing: 0.3px;
}

.correction-category.grammar    { background: rgba(220,38,38,0.18);  color: #f87171; }
.correction-category.vocabulary { background: rgba(217,119,6,0.18);  color: #fbbf24; }
.correction-category.clarity    { background: rgba(37,99,235,0.18);  color: #60a5fa; }
.correction-category.style      { background: rgba(124,58,237,0.18); color: #c084fc; }
.correction-category.academic   { background: rgba(5,150,105,0.18);  color: #34d399; }

/* ── コントロールバー ── */
.control-bar {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 16px 20px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  gap: 16px;
}

/* サブボタン（話題、テキスト、記事） */
.topic-btn, .text-btn, .article-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 14px;
  padding: 10px 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 20px;
  transition: all 0.15s;
  min-width: 56px;
}

.topic-btn span, .text-btn span, .article-btn span {
  font-size: 11px;
  color: var(--text-muted);
}

.topic-btn:active, .text-btn:active, .article-btn:active {
  background: rgba(255,255,255,0.12);
  transform: scale(0.95);
}

.article-btn.active {
  background: rgba(0,150,199,0.2);
  border-color: rgba(0,150,199,0.5);
}

.article-btn.active span {
  color: #0096c7;
}

/* 記事モードバナー */
.article-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: linear-gradient(90deg, rgba(0,150,199,0.18), rgba(0,119,182,0.12));
  border-bottom: 1px solid rgba(0,150,199,0.25);
  flex-shrink: 0;
}

.article-banner-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.article-banner-text {
  flex: 1;
  font-size: 12px;
  color: #7ec8e3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.article-exit-btn {
  background: rgba(0,150,199,0.2);
  border: 1px solid rgba(0,150,199,0.4);
  color: #0096c7;
  border-radius: 12px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

/* 記事モーダル */
.article-modal-box {
  max-height: 85vh;
  overflow-y: auto;
  width: 92%;
  max-width: 480px;
}

.article-modal-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 14px;
}

#article-input {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 14px;
  padding: 12px;
  resize: vertical;
  min-height: 160px;
  max-height: 280px;
  font-family: var(--font);
  line-height: 1.6;
  margin-bottom: 6px;
}

#article-input:focus {
  outline: none;
  border-color: rgba(0,150,199,0.5);
}

.article-char-count {
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
  margin-bottom: 14px;
}

.article-char-count span {
  color: var(--text);
  font-weight: 600;
}

/* 朗読テキスト表示バブル */
.reading-chunk {
  align-self: stretch;
  max-width: 100%;
}

.reading-chunk .bubble {
  background: rgba(0, 150, 199, 0.05);
  border: 1px solid rgba(0, 150, 199, 0.13);
  color: rgba(232, 232, 240, 0.45);
  font-size: 15px;
  line-height: 1.78;
  border-radius: 12px;
  transition: background 0.25s ease, border-color 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
}

.reading-chunk.reading-active .bubble {
  background: rgba(0, 150, 199, 0.15);
  border-color: rgba(0, 150, 199, 0.45);
  color: var(--text);
  box-shadow: 0 0 0 2px rgba(0, 150, 199, 0.15);
}

/* メインマイクボタン */
.mic-btn {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.4);
  transition: all 0.15s;
  flex-shrink: 0;
  position: relative;
}

.mic-btn:active, .mic-btn.listening {
  transform: scale(1.08);
  box-shadow: 0 4px 30px rgba(37, 99, 235, 0.7);
}

.mic-btn.listening {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  box-shadow: 0 4px 30px rgba(220, 38, 38, 0.5);
  animation: micPulse 1s ease-in-out infinite;
}

.mic-btn.processing {
  background: linear-gradient(135deg, #d97706, #b45309);
  box-shadow: 0 4px 20px rgba(217, 119, 6, 0.4);
}

@keyframes micPulse {
  0%, 100% { box-shadow: 0 4px 30px rgba(220, 38, 38, 0.5); }
  50% { box-shadow: 0 4px 40px rgba(220, 38, 38, 0.9), 0 0 0 12px rgba(220, 38, 38, 0.1); }
}

.mic-icon {
  font-size: 28px;
  line-height: 1;
}

.mic-label {
  font-size: 10px;
  color: rgba(255,255,255,0.8);
  font-weight: 500;
}

/* テキスト入力エリア */
.text-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.text-input-area input {
  flex: 1;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 22px;
  padding: 10px 16px;
  font-size: 16px;
  outline: none;
}

.text-input-area input:focus {
  border-color: rgba(37,99,235,0.5);
}

.text-input-area button {
  background: #2563eb;
  border: none;
  color: #fff;
  border-radius: 22px;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

/* ══════════════════════════════════════════
   モーダル
══════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: flex-end;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.modal-box {
  background: var(--surface);
  width: 100%;
  border-radius: 24px 24px 0 0;
  padding: 24px 20px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 -8px 40px rgba(0,0,0,0.5);
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-muted);
}

.modal-box input {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 16px;
  outline: none;
  width: 100%;
}

.modal-box input:focus {
  border-color: rgba(37,99,235,0.6);
}

.modal-buttons {
  display: flex;
  gap: 12px;
}

.modal-buttons button {
  flex: 1;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  transition: background 0.15s;
}

.modal-buttons button.primary {
  background: #2563eb;
  border-color: #2563eb;
  font-weight: 600;
}

.modal-buttons button:active {
  opacity: 0.8;
}

/* ══════════════════════════════════════════
   ローディング
══════════════════════════════════════════ */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 50;
  gap: 16px;
  backdrop-filter: blur(2px);
}

.loading-spinner {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(255,255,255,0.15);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-text {
  font-size: 15px;
  color: rgba(255,255,255,0.8);
}

/* ══════════════════════════════════════════
   トースト通知
══════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(30,30,50,0.95);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 24px;
  font-size: 14px;
  border: 1px solid var(--border);
  opacity: 0;
  transition: all 0.3s;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: var(--shadow);
  z-index: 200;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ══════════════════════════════════════════
   ユーティリティ
══════════════════════════════════════════ */
button { -webkit-tap-highlight-color: transparent; }

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