body {
  font-family: sans-serif;
  padding: 20px;
  max-width: 1200px;
  margin: auto;
  background-color: #f9f9f9;
}

#container {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
}

#discussion {
  height: 400px;
  overflow-y: auto;
  background: white;
  border: 2px solid #ccc;
  border-bottom: none;
  padding: 15px;
}

#coaching {
  max-height: 160px;
  overflow-y: auto;
  background: #fffdf8;
  border: 2px solid #ccc;
  border-top: 1px solid #e0e0e0;
  padding: 10px 15px;
  transition: max-height 0.35s ease, opacity 0.35s ease, padding 0.35s ease;
  opacity: 1;
}
#coaching.hidden {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
  padding: 0;
  border-top: none;
}

/* iOS-style toggle */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  margin-right: 10px;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #ccc;
  transition: 0.4s;
  border-radius: 24px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.4s;
  border-radius: 50%;
}
.switch input:checked + .slider { background-color: #4cd964; }
.switch input:checked + .slider:before { transform: translateX(20px); }

#controls {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: flex-start;
  align-items: center;
  gap: 6px;
  padding: 2px;
}

#toggle_container {
  position: static;
  display: none;
  background: #f9f9f9;
  margin: 4px 2px;
  border-radius: 4px;
  padding: 0;
  font-size: 14px;
  align-items: center;
}

.toggle_label {
  display: flex;
  font-size: 14px;
}

#toast {
  display: flex;
  visibility: hidden;
  min-width: 100px;
  background-color: #333;
  color: #fff;
  text-align: center;
  border-radius: 4px;
  padding: 8px 16px;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.3s ease;
}
#toast.show {
  visibility: visible;
  opacity: 1;
}

.action_button {
  margin-left: 10px;
  padding: 6px 12px;
  font-size: 14px;
  background-color: #007acc;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}
.action_button:hover { background-color: #005fa3; }

.coach_button {
  margin-left: 10px;
  padding: 6px 12px;
  font-size: 14px;
  background-color: #cc6600;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}
.coach_button:hover { background-color: #a34f00; }

/* Message bubbles */
.partner {
  color: #333;
  max-width: 70%;
  margin: 12px 0;
  padding: 10px 14px;
  background-color: #e0f7fa;
  border-radius: 16px;
  align-self: flex-start;
  text-align: left;
  position: relative;
  margin-right: auto;
}
.user {
  max-width: 70%;
  margin: 12px 0;
  padding: 10px 14px;
  background-color: #d1e7dd;
  color: #0066cc;
  border-radius: 16px;
  align-self: flex-end;
  text-align: left;
  position: relative;
  margin-left: auto;
}
.user, .partner {
  word-wrap: break-word;
  line-height: 1.4;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.score {
  color: #5c513a;
  max-width: 100%;
  margin: 12px 0;
  padding: 10px 14px;
  background-color: #fdf6e3;
  border-radius: 16px;
  text-align: left;
  position: relative;
}
.coach {
  color: #cc6600;
  font-style: italic;
  margin: 12px 0;
}

/* Typing indicator — shown while waiting for first token */
@keyframes blink {
  0%, 100% { opacity: 0.2; }
  50%       { opacity: 1;   }
}
.typing::after {
  content: '●●●';
  letter-spacing: 3px;
  font-size: 10px;
  animation: blink 1.2s ease-in-out infinite;
  margin-left: 6px;
  vertical-align: middle;
  color: #999;
}

/* Chat form */
#chat_form {
  display: flex;
}
#message_input {
  width: 100%;
  min-height: 2em;
  max-height: 150px;
  padding: 15px;
  font-size: 16px;
  resize: none;
  overflow-y: auto;
  line-height: 1.4;
  word-wrap: break-word;
  white-space: pre-wrap;
  box-sizing: border-box;
}


#mic_button {
  margin-left: 6px;
  padding: 0 10px;
  background-color: #eee;
  border: 1px solid #ccc;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #444;
}


#send_button {
  margin-left: 6px;
  font-size: 18px;
  padding: 0 12px;
  background-color: #1D9E75;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

/* Recording UI */
#recording_ui {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  height: 46px;
  background: white;
  border: 1px solid #ccc;
  border-radius: 4px;
}
#recording_ui.active { display: flex; }

#cancel_record, #send_record {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 6px;
  flex-shrink: 0;
}
#cancel_record { color: #999; }
#send_record   { color: #1D9E75; font-weight: bold; }

#rec_timer {
  font-size: 14px;
  color: #E24B4A;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  min-width: 32px;
}

#waveform {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 32px;
  overflow: hidden;
}
#waveform span {
  display: inline-block;
  width: 3px;
  border-radius: 2px;
  background: #E24B4A;
  animation: wave 0.8s ease-in-out infinite;
  transform-origin: center;
}
@keyframes wave {
  0%, 100% { transform: scaleY(0.3); }
  50%       { transform: scaleY(1);   }
}

@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0 rgba(226,75,74,0.4); }
  70%  { box-shadow: 0 0 0 10px rgba(226,75,74,0); }
  100% { box-shadow: 0 0 0 0 rgba(226,75,74,0); }
}

/* ── Sample Topics ── */
#sample_topics {
  margin-bottom: 12px;
}

.topics_label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #888;
  margin-bottom: 8px;
}

#topics_grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.topic_card {
  background: #ffffff;
  border: 1px solid #d0d0d0;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 14px;
  color: #333;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}

.topic_card:hover {
  background: #e8f4ff;
  border-color: #007acc;
  color: #007acc;
  box-shadow: 0 2px 6px rgba(0,122,204,0.12);
}

.topic_card:active {
  background: #d0eaff;
}
