* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: #f3f4f6;
  color: #222;
}

/* ==== ヘッダー（固定） ==== */
header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background-color: #f8c9cf;
  border-bottom: 3px solid #f1a7b3;
  padding: 4px 24px;
}
.header-main-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-left h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.03em;
}
.header-left .sub {
  font-size: 12px;
  opacity: 0.8;
  margin-top: 2px;
}
.help-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background-color: #ffffff;
  color: #f1a7b3;
  border: 2px solid #f1a7b3;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.help-btn:hover {
  background-color: #fce7f3;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.timer-box {
  padding: 4px 10px 2px;
  border-radius: 10px;
  background-color: #fee2e2;
  border: 1px solid #fecaca;
  min-width: 200px;
}
.timer-label {
  font-size: 11px;
  color: #7f1d1d;
}
.timer-time {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.1;
  margin-top: 0;
  transition: color 0.2s;
}
.timer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}
.timer-bar {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background-color: #fecaca;
  overflow: hidden;
}
.timer-bar-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #22c55e, #eab308, #ef4444);
  transition: width 0.2s linear, background 0.2s;
}
.timer-caption {
  font-size: 11px;
  color: #7f1d1d;
  margin-top: 2px;
}

.header-patient {
  margin-top: 4px;
  font-size: 11px;
  color: #374151;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.hidden { display: none !important; }

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 24px 32px;
}
section { margin-bottom: 24px; }

.panel {
  background-color: #ffffff;
  border-radius: 10px;
  padding: 16px 18px;
  box-shadow: 0 2px 4px rgba(15, 23, 42, 0.08);
  border-top: 4px solid #f1a7b3;
}
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}
.panel-title { font-size: 16px; font-weight: 700; }
.panel-subtitle { font-size: 12px; color: #6b7280; }

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}
.field label { font-weight: 600; }
.helper-text {
  font-size: 11px;
  color: #6b7280;
  margin-top: 4px;
}

/* === 履歴機能 === */
.history-toolbar { display:flex; gap:8px; margin-bottom:12px; }
.history-list { margin-top:8px; }
.history-card { background:#fff; padding:15px; margin-bottom:15px; border-radius:6px; box-shadow:0 1px 3px rgba(0,0,0,0.1); display:flex; justify-content:space-between; align-items:center; cursor:pointer; transition:transform 0.1s; border-left:5px solid #ccc; position:relative; }
.history-card:hover { transform: translateY(-2px); box-shadow:0 4px 6px rgba(0,0,0,0.1); }
.history-card.score-high { border-left-color:#27ae60; }
.history-card.score-mid { border-left-color:#f39c12; }
.history-card.score-low { border-left-color:#e74c3c; }
.history-card.favorite { background:#fffdf0; border:2px solid #f1c40f; }
.history-main { flex-grow:1; padding-right:10px; }
.history-date { font-size:0.8em; color:#7f8c8d; }
.history-title { font-weight:bold; font-size:1.1em; margin:4px 0; display:flex; align-items:center; gap:8px; }
.fav-icon { color:#ccc; font-size:1.2em; cursor:pointer; transition:color 0.2s; }
.fav-icon.active { color:#f1c40f; }
.history-actions { display:flex; align-items:center; gap:10px; }
.history-score-badge { width:45px; height:45px; border-radius:50%; background:#eee; display:flex; align-items:center; justify-content:center; font-weight:bold; font-size:1.1em; color:#555; flex-shrink:0; }
.btn-icon-del { background:none; border:none; color:#aaa; font-size:1.2em; padding:5px; }
.btn-icon-del:hover { color:#e74c3c; background:#fee; border-radius:50%; }

/* モーダル */
.modal-overlay { position:fixed; top:0; left:0; width:100%; height:100%; background:rgba(0,0,0,0.5); z-index:1000; display:flex; justify-content:center; align-items:center; }
.modal-content { background:#fff; width:90%; max-width:800px; height:90%; border-radius:8px; display:flex; flex-direction:column; overflow:hidden; animation:slideIn 0.3s ease; }
@keyframes slideIn { from { transform: translateY(20px); opacity:0; } to { transform: translateY(0); opacity:1; } }
.modal-header { padding:15px; border-bottom:1px solid #ddd; display:flex; justify-content:space-between; background:#f8f9fa; }
.modal-body { padding:20px; overflow-y:auto; flex-grow:1; }
.modal-footer { padding:10px; border-top:1px solid #ddd; text-align:right; background:#f8f9fa; }

.detail-section { margin-bottom:30px; }
.detail-label { font-size:0.9em; color:#7f8c8d; border-bottom:2px solid #eee; margin-bottom:10px; padding-bottom:5px; }
.log-container { background:#f9f9f9; padding:15px; border-radius:6px; max-height:300px; overflow-y:auto; border:1px solid #eee; }
.log-row { margin-bottom:8px; }
.log-bubble { padding:6px 10px; border-radius:8px; display:inline-block; max-width:80%; }
.log-user .log-bubble { background:#d1ecf1; color:#0c5460; }
.log-model .log-bubble { background:#e2e3e5; color:#383d41; }
.log-user { text-align:right; }

.btn {
  border: none;
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(120deg, #2563eb, #3b82f6);
  color: #ffffff;
  box-shadow: 0 3px 6px rgba(37, 99, 235, 0.4);
}
.btn-primary:disabled {
  background: #9ca3af;
  cursor: not-allowed;
  box-shadow: none;
}
.btn-secondary {
  background-color: #e5e7eb;
  color: #111827;
}
.btn-row {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.start-session-row {
  margin: 6px 0 12px;
  display: flex;
  justify-content: flex-end;
}
.start-session-row.bottom {
  margin-top: 18px;
}

/* ==== 難易度・症例選択 ==== */
.difficulty-buttons {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}
.difficulty-btn {
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background-color: #f9fafb;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
}
.difficulty-btn.selected {
  background-color: #2563eb;
  color: #ffffff;
  border-color: #1d4ed8;
}

.case-buttons { margin-top: 6px; }
.case-buttons.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.case-random {
  margin-bottom: 6px;
  width: 100%;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-align: left;
}
.case-vol {
  margin-top: 10px;
  padding-top: 6px;
  border-top: 1px dashed #e5e7eb;
}
.case-vol-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
  gap: 8px;
}
.case-vol-title {
  font-size: 12px;
  color: #6b7280;
  font-weight: 600;
}
/* 新しいVolヘッダー */
.case-vol-header-styled {
  margin-top: 12px;
  margin-bottom: 6px;
  padding: 6px 10px;
  background-color: #f3f4f6;
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  font-weight: 700;
  color: #374151;
}
.vol-score-container {
  display: flex;
  align-items: center;
  gap: 8px;
}
.vol-score-text { font-size: 12px; color: #6b7280; }
.vol-score-track {
  width: 100px;
  height: 8px;
  background-color: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}
.vol-score-fill { height: 100%; border-radius: 999px; }

/* 全体の成績用スタイル（さらに大きく） */
.total-score-header {
  font-size: 16px;
  padding: 10px 14px;
  border: 1px solid #e5e7eb;
  background-color: #f3f4f6;
}
.total-score-header .vol-score-text {
  font-size: 14px;
  font-weight: 700;
  color: #374151;
}

/* スコア別色分け：高（緑） */
.total-score-header.score-high {
  background-color: #dcfce7;
  border-color: #86efac;
}
.total-score-header.score-high .vol-score-text {
  color: #166534;
}
/* スコア別色分け：中（黄） */
.total-score-header.score-mid {
  background-color: #fef9c3;
  border-color: #fde047;
}
.total-score-header.score-mid .vol-score-text {
  color: #854d0e;
}
/* スコア別色分け：低（赤） */
.total-score-header.score-low {
  background-color: #fee2e2;
  border-color: #fca5a5;
}
.total-score-header.score-low .vol-score-text {
  color: #991b1b;
}
.total-score-header .vol-score-track {
  width: 160px;
  height: 10px;
}

.case-buttons-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.case-btn {
  width: 100%;
  text-align: left;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  background-color: #f9fafb;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.case-btn span.index {
  font-weight: 700;
  margin-right: 4px;
}
.case-btn.selected {
  background-color: #2563eb;
  color: #ffffff;
  border-color: #1d4ed8;
}

/* ==== 予診票 ==== */
.yoshinhyo-grid {
  display: grid;
  grid-template-columns: 120px 1fr;
  row-gap: 6px;
  column-gap: 12px;
  font-size: 13px;
}
.yoshinhyo-label {
  font-weight: 600;
  text-align: right;
  padding-right: 4px;
}
.yoshinhyo-value {
  background-color: #f9fafb;
  border-radius: 4px;
  padding: 4px 6px;
  border: 1px solid #e5e7eb;
}
.yoshinhyo-small {
  margin-bottom: 12px;
  font-size: 13px;
  color: #1e3a8a;
  background-color: #eff6ff;
  border: 1px solid #bfdbfe;
  padding: 8px 12px;
  border-radius: 6px;
  font-weight: 600;
}

/* ==== Missionカード & 患者タイプ ==== */
.mission-card {
  margin: 0 0 16px 0;
  border-radius: 8px;
  padding: 8px 10px;
  background: linear-gradient(120deg, #e0f2fe, #fef9c3);
  border: 1px solid #bae6fd;
  font-size: 12px;
}
.mission-title {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 2px;
}
.patient-persona {
  margin-top: 6px;
  font-size: 12px;
  color: #4b5563;
}

/* ==== チャット ==== */
.chat-panel { display: flex; flex-direction: column; gap: 8px; }
.chat-log {
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  padding: 8px;
  background-color: #f9fafb;
  overflow-y: auto;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 360px;
  min-height: 240px;
}
.chat-message-row {
  display: flex;
  width: 100%;
  gap: 10px;
  align-items: flex-start;
}
/* 医学生（右側） */
.chat-message-row.student {
  flex-direction: row-reverse;
}
/* システムメッセージ（中央） */
.chat-message-row.system {
  justify-content: center;
}

/* アイコン */
.chat-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #eee;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.chat-message-row.student .chat-icon {
  background-color: #dbeafe; /* 薄い青 */
}
.chat-message-row.patient .chat-icon {
  background-color: #fff;
  border: 1px solid #e5e7eb;
}

/* コンテンツラッパー（名前と吹き出し） */
.chat-content {
  display: flex;
  flex-direction: column;
  max-width: 70%;
}
.chat-message-row.student .chat-content {
  align-items: flex-end;
}
.chat-message-row.patient .chat-content {
  align-items: flex-start;
}

.chat-message {
  max-width: 100%;
  padding: 8px 12px;
  border-radius: 18px;
  font-size: 13px;
  line-height: 1.4;
  word-wrap: break-word;
  white-space: pre-wrap;
  position: relative;
}
.chat-message.patient {
  background-color: #ffffff;
  border: 1px solid #e5e7eb;
  border-top-left-radius: 4px;
}
.chat-message.student {
  background-color: #2563eb;
  color: #ffffff;
  border-top-right-radius: 4px;
}
.chat-message.system {
  margin: 0 auto;
  background-color: #e5e7eb;
  color: #374151;
  font-size: 12px;
  border-radius: 999px;
  padding: 4px 12px;
}
.chat-meta {
  font-size: 10px;
  color: #9ca3af;
  margin-bottom: 2px;
}
.chat-input-area { display: flex; flex-direction: column; gap: 6px; }
.chat-input-row { display: flex; gap: 6px; }
.chat-input-area textarea {
  flex: 1;
  resize: vertical;
  min-height: 60px;
  max-height: 130px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  font-size: 13px;
}
.phrase-buttons-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 11px;
}
.phrase-btn {
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background-color: #f3f4f6;
  padding: 4px 10px;
  cursor: pointer;
}

/* ==== 電子カルテ風ノート ==== */
.emr-note {
  border-radius: 8px;
  border: 1px solid #d1d5db;
  background-color: #eff6ff;
  margin-top: 6px;
  overflow: hidden;
}
.emr-header {
  background-color: #93c5fd;
  color: #111827;
  padding: 4px 8px;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.soap-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
  gap: 12px;
  align-items: flex-start;
  padding: 8px 10px;
}
.soap-column-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 4px;
}
.soap-sample-box {
  background-color: #f9fafb;
  border-radius: 8px;
  border: 1px dashed #d1d5db;
  padding: 8px 10px;
  font-size: 12px;
  white-space: pre-wrap;
}
.soap-section { margin-bottom: 10px; }
.soap-label-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.soap-label { font-size: 13px; font-weight: 700; }
.soap-textarea {
  width: 100%;
  resize: vertical;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  font-size: 13px;
  font-family: inherit;
  min-height: 240px;
}
.memo-section {
  margin-top: 14px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background-color: #f9fafb;
  padding: 8px 10px;
  font-size: 12px;
}
.memo-section textarea {
  width: 100%;
  min-height: 80px;
  resize: vertical;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  padding: 6px 8px;
  font-size: 13px;
}

/* ==== 評価エリア ==== */
.evaluation-area { margin-top: 20px; }
.soap-comparison { margin-bottom: 14px; }
.scoreboard {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 16px;
  border-radius: 14px;
  background-color: #ffffff;
  border: 1px solid #e5e7eb;
  box-shadow: 0 6px 12px rgba(148, 163, 184, 0.4);
  color: #111827;
  margin-bottom: 14px;
}
.score-circle {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 20%, #fef3c7, #fbbf24 40%, #f97316 70%, #b45309 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 18px rgba(251, 191, 36, 0.8);
}
.score-circle-main {
  font-size: 32px;
  font-weight: 900;
  color: #1f2937;
  line-height: 1;
}
.score-circle-sub { font-size: 11px; color: #374151; }
.scoreboard-text-main { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.scoreboard-text-sub { font-size: 12px; color: #4b5563; }

.evaluation-bars {
  background-color: #ffffff;
  border-radius: 10px;
  padding: 10px 12px;
  color: #111827;
  margin-bottom: 12px;
  box-shadow: 0 2px 6px rgba(148, 163, 184, 0.5);
  font-size: 12px;
  border: 1px solid #e5e7eb;
}
.evaluation-bars-title { font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.bar-row {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 3fr) 60px;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.bar-label { white-space: nowrap; }
.bar-track {
  height: 9px;
  border-radius: 999px;
  background-color: #e5e7eb;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #22c55e, #eab308, #ef4444);
}
.bar-score { text-align: right; font-variant-numeric: tabular-nums; }

.evaluation-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.evaluation-section {
  background-color: #ffffff;
  border-radius: 8px;
  padding: 8px 10px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  font-size: 12px;
}
.evaluation-section h3 { margin: 0 0 4px; font-size: 13px; }
.tag-score {
  display: inline-block;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 999px;
  background-color: #eff6ff;
  color: #1d4ed8;
  margin-left: 4px;
}
