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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  line-height: 1.6;
  background-color: #f4f4f7;
  padding: 15px;
}

.container {
  background-color: white;
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  padding: 20px;
  max-width: 600px;
  margin: 0 auto;
}

h1 {
  text-align: center;
  color: #333;
  margin-bottom: 20px;
}

.section {
  margin-bottom: 20px;
}

.input-group {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.input-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  flex: 1;
}

.recording-controls {
  position: relative;
}

#recordButton {
  padding: 12px;
  border: none;
  border-radius: 6px;
  background-color: #4CAF50;
  color: white;
  font-size: 16px;
  cursor: pointer;
  transition: background-color 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 120px;
  height: 120px;
  width: 120px;
  flex-direction: column;
}

#recordButton:disabled {
  background-color: #cccccc;
  cursor: not-allowed;
}

#recordButton.recording {
  background-color: #FF6347;
}

#recordButton svg {
  fill: white;
}

.icon-svg {
  width: 48px;
  height: 48px;
  display: inline-block;
  vertical-align: middle;
}

.icon-svg-large {
  width: 48px;
  height: 48px;
  display: block;
  margin: 10px auto;
}

.file-upload {
  position: relative;
  border: 2px dashed #ddd;
  border-radius: 6px;
  padding: 20px;
  text-align: center;
  transition: background-color 0.3s;
  min-width: 120px;
  height: 120px;
  width: 120px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.file-upload.dragover {
  background-color: #f0f0f0;
  border-color: #4CAF50;
}

.file-upload input[type="file"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.file-upload-text {
  color: #777;
  display: flex;
  align-items: center;
  white-space: nowrap;
  flex-direction: column;
}

.file-upload svg {
  fill: #aaa;
}

.uploaded-file-name {
  margin-top: 10px;
  font-weight: bold;
  color: #333;
}

input,
textarea {
  width: 100%;
  padding: 10px;
  margin-bottom: 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 16px;
}

.download-btn {
  display: inline-block;
  margin: 10px 10px 10px 0;
  padding: 10px;
  background-color: #007bff;
  color: white;
  text-decoration: none;
  border-radius: 6px;
  text-align: center;
}

#audioPlayer,
#downloadLinks {
  margin-top: 10px;
  text-align: center;
}

#transcriptionResult {
  white-space: pre-wrap;
  background-color: #f9f9f9;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 15px;
  margin-top: 15px;
  max-height: 300px;
  overflow-y: auto;
}

.collapsible {
  background-color: #f1f1f1;
  color: #333;
  cursor: pointer;
  padding: 18px;
  width: 100%;
  border: none;
  text-align: left;
  outline: none;
  font-size: 16px;
  border-radius: 6px;
}

.collapsible:hover {
  background-color: #ddd;
}

.content {
  padding: 0 18px;
  display: none;
  overflow: hidden;
  background-color: #f9f9f9;
  border-radius: 0 0 6px 6px;
}

#transcribeButton {
  background-color: #007bff;
  color: white;
  border: none;
  padding: 12px 20px;
  font-size: 16px;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.2s ease;
  margin-bottom: 10px;
}

#transcribeButton:disabled {
  background-color: #cccccc;
  cursor: not-allowed;
}

#transcribeButton:hover {
  background-color: #0056b3;
  transform: scale(1.05);
}

@media (max-width: 600px) {
  .input-group {
    flex-direction: row;
    align-items: center;
    justify-content: space-around;
  }
  .input-item {
    margin-bottom: 10px;
    flex: 1;
  }
  #recordButton,
  .file-upload {
    margin-left: 0;
    margin-right: 0;
  }
}

.loading-icon {
  display: none;
  border: 5px solid #f3f3f3;
  border-top: 5px solid #3498db;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  animation: spin 1s linear infinite;
  margin: 10px auto;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

#progressBarContainer {
  width: 100%;
  background-color: #f3f3f3;
  border-radius: 6px;
  height: 15px;
  margin-bottom: 10px;
  display: none;
  overflow: hidden;
}

#progressBar {
  width: 0%;
  height: 100%;
  background-color: #4CAF50;
  border-radius: 6px;
  transition: width 0.3s ease;
  overflow: hidden;
}

.file-upload-text p {
  margin-top: 0;
  font-size: 0.9em;
  color: #777;
}

#recordButton span {
  font-size: 0.9em;
}

.error-message {
  color: red;
  margin-top: 10px;
  display: none;
}

/* チャットインターフェースのスタイル */
.chat-interface {
  margin-top: 20px;
}

.chat-history {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 10px;
  background-color: #f9f9f9;
  margin-bottom: 10px;
}

.chat-message {
  margin-bottom: 15px;
  position: relative;
  clear: both;
  overflow: hidden;
}

/* ユーザーメッセージのスタイル */
.chat-message.user {
  text-align: right;
}

.chat-message.user pre {
  background-color: #dcf8c6;
  border-radius: 12px 12px 0 12px;
  padding: 10px 15px;
  display: inline-block;
  max-width: 80%;
  text-align: left;
  margin: 0 0 5px auto;
  position: relative;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.chat-message.user::before {
  content: "User";
  display: block;
  font-size: 0.8em;
  color: #666;
  margin-bottom: 3px;
}

/* モデルメッセージのスタイル */
.chat-message.model {
  text-align: left;
}

.chat-message.model pre {
  background-color: #ffffff;
  border-radius: 12px 12px 12px 0;
  padding: 10px 15px;
  display: inline-block;
  max-width: 90%;
  text-align: left;
  margin: 0 auto 5px 0;
  position: relative;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  border: 1px solid #e0e0e0;
}

/* グラフを含むメッセージ用の特別なスタイル */
.chat-message.model.chart-message pre {
  width: 90%; /* 幅を明示的に設定 */
}

.chat-message.model::before {
  content: "AI";
  display: block;
  font-size: 0.8em;
  color: #666;
  margin-bottom: 3px;
}

/* エラーメッセージのスタイル */
.chat-message.error pre {
  background-color: #ffebee;
  color: #d32f2f;
  border-radius: 12px;
  padding: 10px 15px;
  display: inline-block;
  max-width: 80%;
  text-align: left;
  margin: 0 auto;
  position: relative;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  border: 1px solid #ffcdd2;
}

.chat-message.error::before {
  content: "エラー";
  display: block;
  font-size: 0.8em;
  color: #d32f2f;
  margin-bottom: 3px;
  text-align: center;
}

/* チャット入力エリアのスタイル */
.chat-input {
  display: flex;
  gap: 10px;
}

.chat-input textarea {
  flex: 1;
  border-radius: 20px;
  padding: 10px 15px;
  resize: none;
  border: 1px solid #ddd;
}

.chat-input button {
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 20px;
  padding: 0 20px;
  cursor: pointer;
  transition: background-color 0.3s;
}

.chat-input button:hover {
  background-color: #0056b3;
}

.chat-input button:disabled {
  background-color: #cccccc;
  cursor: not-allowed;
}

/* プロンプト提案ボタンのスタイル */
.chat-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.prompt-suggestion-btn {
  background-color: #f0f0f0;
  border: 1px solid #ddd;
  border-radius: 16px;
  padding: 5px 12px;
  font-size: 0.9em;
  cursor: pointer;
  transition: all 0.2s;
}

.prompt-suggestion-btn:hover {
  background-color: #e0e0e0;
}

.prompt-suggestion-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* チャットメッセージのダウンロードボタン */
.chat-download-btn {
  font-size: 0.8em;
  padding: 5px 10px;
  background-color: #f0f0f0;
  color: #333;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.chat-download-btn:hover {
  background-color: #e0e0e0;
}

/* ラベル集計機能のスタイル */
.analysis-results {
  width: 100%;
  margin-bottom: 20px;
}

.analysis-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 15px;
  font-size: 0.9em;
}

.analysis-table th,
.analysis-table td {
  border: 1px solid #ddd;
  padding: 8px;
  text-align: left;
}

.analysis-table th {
  background-color: #f2f2f2;
  font-weight: bold;
}

.analysis-table tr:nth-child(even) {
  background-color: #f9f9f9;
}

.analysis-table tr:hover {
  background-color: #f1f1f1;
}

.charts-container {
  width: 100%;
  margin-top: 20px;
}

.chart-container {
  position: relative;
  width: 100%;
  margin-bottom: 20px;
}

/* 円グラフ（カテゴリ別・ラベル別） */
.chart-container:nth-child(1),
.chart-container:nth-child(2) {
  height: 30vh; /* ビューポート高さの30% */
  min-height: 200px; /* 最小高さを保証 */
}

/* 棒グラフ（時間帯別） */
.chart-container:nth-child(3) {
  height: 25vh; /* ビューポート高さの25% */
  min-height: 180px; /* 最小高さを保証 */
}

/* モバイル向け調整 */
@media (max-width: 768px) {
  .chart-container:nth-child(1),
  .chart-container:nth-child(2) {
    height: 35vh;
    min-height: 180px; /* モバイル向けの最小高さ */
  }

  .chart-container:nth-child(3) {
    height: 30vh;
    min-height: 160px; /* モバイル向けの最小高さ */
  }
}

/* --- #001 PoC: テキスト取込 --- */
.text-import-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 8px;
  flex-wrap: wrap;
}

.text-import-controls select,
.text-import-controls button {
  padding: 8px 12px;
  border-radius: 4px;
  border: 1px solid #ccc;
}

.text-import-controls button {
  background-color: #4caf50;
  color: white;
  border: none;
  cursor: pointer;
}

#textImportStatus {
  margin-top: 6px;
  font-size: 0.85em;
  color: #555;
}

/* --- #001 PoC: 一括実行・自動セッション保存 --- */
#pipelineButton {
  margin-top: 8px;
  background-color: #ff9800;
}

#pipelineButton:disabled {
  background-color: #ccc;
}

.autosave-toggle {
  display: block;
  margin-top: 8px;
  font-size: 0.85em;
  color: #555;
}

#autoSaveLinks {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}

#autoSaveLinks .autosave-link {
  font-size: 0.85em;
  align-self: flex-start;
}

/* --- #001 PoC: 授業間比較 --- */
#comparisonControls {
  margin-bottom: 10px;
  font-size: 0.9em;
}

#comparisonControls select {
  padding: 6px 10px;
  border-radius: 4px;
  border: 1px solid #ccc;
  max-width: 100%;
}

.comparison-note {
  font-size: 0.85em;
  color: #555;
  margin: 4px 0 10px;
}

.comparison-chart {
  height: 28vh;
  min-height: 200px;
}

.comparison-utterances {
  margin-top: 10px;
}

.comparison-columns {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.comparison-col {
  flex: 1 1 0;
  min-width: 0;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 8px;
  background: #fafafa;
}

.comparison-col h5 {
  margin: 0 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid #ddd;
}

.utter-row {
  padding: 6px 4px;
  border-bottom: 1px dashed #e0e0e0;
  font-size: 0.85em;
}

.utter-row.labeled {
  background: #fff8e1;
}

.utter-time {
  color: #888;
  margin-right: 6px;
  font-size: 0.9em;
}

.utter-speaker {
  font-weight: bold;
  margin-right: 6px;
}

.utter-label {
  display: inline-block;
  background: #36a2eb;
  color: white;
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 0.85em;
  margin-left: 4px;
}

.utter-text {
  margin-top: 2px;
  white-space: pre-wrap;
  word-break: break-word;
}

.no-utterance {
  color: #999;
  font-size: 0.85em;
}

@media (max-width: 768px) {
  .comparison-columns {
    flex-direction: column;
  }
}
