/* CSSは元のまま変更ありません */
* { 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: 8px 24px;
}
.header-main-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.header-left h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.03em;
}
.header-left .sub {
  font-size: 12px;
  opacity: 0.8;
  margin-top: 2px;
}

.timer-box {
  padding: 6px 10px 4px;
  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: 2px;
  transition: color 0.2s;
}
.timer-bar {
  margin-top: 4px;
  width: 100%;
  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;
}

.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-secondary {
  background-color: #e5e7eb;
  color: #111827;
}
.btn-danger { background-color: #b91c1c; color: #ffffff; }
.btn-row {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.btn-small {
  padding: 4px 10px;
  font-size: 12px;
}

/* ==== 難易度・症例選択 ==== */
.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-random {
  margin-bottom: 6px;
  width: 100%;
  text-align: center;
  font-weight: 600;
}

.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-score-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 150px;
}
.vol-score-label {
  font-size: 11px;
  color: #4b5563;
  white-space: nowrap;
}
.vol-score-track {
  width: 120px;
  height: 6px;
  border-radius: 999px;
  background-color: #e5e7eb;
  overflow: hidden;
}
.vol-score-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #22c55e, #eab308, #ef4444);
  transition: width 0.3s ease;
}
.vol-score-fill.high {
  background: linear-gradient(90deg, #22c55e, #16a34a);
}
.vol-score-fill.mid {
  background: linear-gradient(90deg, #eab308, #f97316);
}
.vol-score-fill.low {
  background: linear-gradient(90deg, #f97316, #ef4444);
}

.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: 8px;
  font-size: 12px;
  color: #6b7280;
}

/* ==== Missionカード & 患者タイプ ==== */
.mission-card {
  margin-top: 10px;
  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;
}
.mission-body { font-size: 12px; }

.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: 8px;
  max-height: 360px;
  min-height: 240px;
}
.chat-message-row { display: flex; width: 100%; }
.chat-message {
  max-width: 80%;
  padding: 6px 10px;
  border-radius: 18px;
  font-size: 13px;
  line-height: 1.4;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.chat-message.patient {
  background-color: #ffffff;
  border: 1px solid #e5e7eb;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.chat-message.student {
  margin-left: auto;
  background-color: #2563eb;
  color: #ffffff;
  border-bottom-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-top: 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;
}
.chat-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* 基本モード：フレーズボタン */
.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;
}
.emr-header-title { font-weight: 700; }
.emr-header-meta { font-size: 11px; }

.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-hint { font-size: 11px; color: #6b7280; }
.soap-textarea {
  width: 100%;
  resize: vertical;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  font-size: 13px;
  font-family: inherit;
}
.soap-textarea[disabled] {
  background-color: #f3f4f6;
  color: #9ca3af;
}
.soap-footer-note {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 4px;
}
#soapS { min-height: 220px; }
#soapAP { min-height: 220px; }
#soapO { min-height: 60px; }

/* ==== 自由メモ ==== */
.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;
  font-family: inherit;
}

/* ==== 基本モード用ツール ==== */
.basic-tools-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 10px;
  font-size: 12px;
}
.basic-panel {
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background-color: #ffffff;
  padding: 8px 10px;
}
.basic-panel h3 {
  margin: 0 0 4px;
  font-size: 13px;
}
.checklist-item {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  font-size: 12px;
}
.checklist-item input {
  width: 14px;
  height: 14px;
}
.hint-text-box {
  border-radius: 6px;
  border: 1px dashed #d1d5db;
  background-color: #f9fafb;
  padding: 6px 8px;
  min-height: 60px;
  white-space: pre-wrap;
}

/* ==== 評価エリア ==== */
.evaluation-area { margin-top: 20px; }

.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: 150px;
  height: 150px;
  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);
  position: relative;
}
.score-circle-main {
  font-size: 40px;
  font-weight: 900;
  color: #1f2937;
  line-height: 1;
}
.score-circle-sub {
  font-size: 13px;
  color: #374151;
  margin-top: 4px;
}
.score-circle-rank {
  position: absolute;
  bottom: 10px;
  right: 12px;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background-color: rgba(15, 23, 42, 0.85);
  color: #fef3c7;
}

.scoreboard-text-main {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 6px;
}
.scoreboard-text-sub {
  font-size: 12px;
  margin-bottom: 6px;
  color: #4b5563;
}
.scoreboard-split {
  font-size: 12px;
  margin-bottom: 4px;
}
.scoreboard-split span {
  display: inline-block;
  margin-right: 10px;
}
.scoreboard-rank {
  font-size: 12px;
  color: #6b21a8;
  font-weight: 600;
}
.scoreboard-prev {
  font-size: 11px;
  color: #6b7280;
  margin-top: 4px;
}

.badge-row {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.badge-chip {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  background: linear-gradient(120deg, #ecfeff, #e0f2fe);
  border: 1px solid #bae6fd;
  color: #0369a1;
}

.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-fill.high {
  background: linear-gradient(90deg, #22c55e, #16a34a);
}
.bar-fill.mid {
  background: linear-gradient(90deg, #eab308, #f97316);
}
.bar-fill.low {
  background: linear-gradient(90deg, #f97316, #ef4444);
}
.bar-score {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.evaluation-summary {
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  padding: 10px 12px;
  background-color: #f9fafb;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
}
.score-main { font-size: 20px; font-weight: 800; margin-bottom: 2px; }
.score-sub { font-size: 12px; color: #4b5563; }

.evaluation-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 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;
}
.evaluation-section h4 {
  margin: 6px 0 2px;
  font-size: 12px;
}
.evaluation-section ul {
  margin: 4px 0 4px 18px;
  padding: 0;
}
.evaluation-section li { margin-bottom: 2px; }
.tag-score {
  display: inline-block;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 999px;
  background-color: #eff6ff;
  color: #1d4ed8;
  margin-left: 4px;
}
.tag-good {
  display: inline-block;
  background-color: #dcfce7;
  color: #166534;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  margin-right: 4px;
}
.tag-todo {
  display: inline-block;
  background-color: #fee2e2;
  color: #991b1b;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  margin-right: 4px;
}

/* レーダーチャート（簡易） */
.radar-wrapper {
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.radar-caption {
  font-size: 11px;
  color: #6b7280;
}

/* 模範カルテ用 */
.model-emr-note { margin-top: 4px; }
.model-note-wrapper {
  position: relative;
  overflow: hidden;
  transition: max-height 0.3s ease;
  background-color: #eff6ff;
}
.model-note-wrapper.collapsed { max-height: 140px; }
.model-note-wrapper.expanded { max-height: 600px; }
.model-note-text {
  padding: 8px 10px 16px;
  font-size: 12px;
  white-space: pre-wrap;
}
.model-note-fade {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 32px;
  background: linear-gradient(to bottom, rgba(239,246,255,0), #eff6ff);
  pointer-events: none;
}
.model-note-wrapper.expanded .model-note-fade {
  display: none;
}