* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', sans-serif;
  background: #f0f4f8;
  height: 100dvh;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 700px;
  margin: 0 auto;
  background: white;
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.08);
}

/* ヘッダー */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: #1a56db;
  color: white;
  flex-shrink: 0;
}

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

.phase-badge {
  background: rgba(255, 255, 255, 0.2);
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
}

/* チャットエリア */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.loading {
  color: #94a3b8;
  text-align: center;
  padding: 40px 0;
  font-size: 14px;
}

/* メッセージ */
.message {
  display: flex;
  flex-direction: column;
  max-width: 85%;
}

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

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

.message-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.65;
  word-break: break-word;
}

.message.user .message-bubble {
  background: #1a56db;
  color: white;
  border-bottom-right-radius: 4px;
  white-space: pre-wrap;
}

.message.ai .message-bubble {
  background: #f1f5f9;
  color: #1e293b;
  border-bottom-left-radius: 4px;
}

/* Markdown スタイル（AIメッセージ内） */
.message.ai .message-bubble p { margin: 6px 0; }
.message.ai .message-bubble p:first-child { margin-top: 0; }
.message.ai .message-bubble p:last-child  { margin-bottom: 0; }

.message.ai .message-bubble strong {
  font-weight: 600;
  color: #0f172a;
}

.message.ai .message-bubble code {
  background: #dde4ef;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.88em;
  color: #1e3a8a;
}

.message.ai .message-bubble pre {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px 14px;
  overflow-x: auto;
  margin: 8px 0;
}

.message.ai .message-bubble pre code {
  background: none;
  padding: 0;
  font-size: 0.85em;
  color: #334155;
}

.message.ai .message-bubble ul,
.message.ai .message-bubble ol {
  padding-left: 20px;
  margin: 6px 0;
}

.message.ai .message-bubble li { margin: 3px 0; }

.message.ai .message-bubble hr {
  border: none;
  border-top: 1px solid #e2e8f0;
  margin: 10px 0;
}

/* SRS追加バー */
.vocab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  max-width: 85%;
}

.btn-add-srs {
  background: #f0fdf4;
  border: 1px solid #86efac;
  color: #16a34a;
  padding: 4px 11px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-add-srs:hover { background: #dcfce7; border-color: #4ade80; }

.btn-add-srs.added {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #94a3b8;
  cursor: default;
}

/* セッションサマリーカード */
.session-summary {
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 14px;
  padding: 18px;
  align-self: stretch;
}

.session-summary h3 {
  color: #16a34a;
  font-size: 15px;
  margin-bottom: 10px;
}

.session-summary p {
  color: #374151;
  font-size: 14px;
  line-height: 1.7;
}

.session-summary p + p {
  margin-top: 8px;
}

/* ローディングアニメーション（考え中...） */
.thinking {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 14px 18px;
  background: #f1f5f9;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}

.thinking span {
  width: 8px;
  height: 8px;
  background: #94a3b8;
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out;
}

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

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

/* 入力エリア */
.input-area {
  padding: 12px 16px 16px;
  border-top: 1px solid #e2e8f0;
  background: white;
  flex-shrink: 0;
}

#userInput {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  font-size: 15px;
  font-family: inherit;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
  line-height: 1.5;
}

#userInput:focus {
  border-color: #1a56db;
}

#userInput:disabled {
  background: #f8fafc;
  color: #94a3b8;
}

.input-buttons {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}

.btn-send {
  background: #1a56db;
  color: white;
  border: none;
  padding: 10px 26px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-send:hover:not(:disabled) {
  background: #1547c0;
}

.btn-send:disabled {
  background: #93b4f8;
  cursor: not-allowed;
}

.btn-end {
  background: none;
  border: 1px solid #e2e8f0;
  color: #64748b;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-end:hover:not(:disabled) {
  background: #f8fafc;
}

.btn-end:disabled {
  color: #cbd5e1;
  cursor: not-allowed;
}

/* ドラフト復元バナー */
.draft-banner {
  background: #fefce8;
  border: 1px solid #fde047;
  border-radius: 14px;
  padding: 16px;
  align-self: stretch;
  text-align: center;
}

.draft-banner p {
  color: #713f12;
  font-size: 14px;
  margin-bottom: 12px;
}

.draft-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.btn-restore {
  background: #1a56db;
  color: white;
  border: none;
  padding: 9px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.btn-discard {
  background: none;
  border: 1px solid #e2e8f0;
  color: #64748b;
  padding: 9px 20px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}

/* 復元完了メッセージ */
.restore-notice {
  text-align: center;
  font-size: 13px;
  color: #94a3b8;
  padding: 4px 0 8px;
}
