:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --secondary: #06b6d4;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --text: #1f2937;
  --text-secondary: #6b7280;
  --bg-light: #f9fafb;
  --bg-white: #ffffff;
  --border: #e5e7eb;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  line-height: 1.6;
}

#loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-white);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.spinner {
  width: 50px;
  height: 50px;
  margin: 0 auto 20px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

#main-content {
  display: none;
  min-height: 100vh;
  padding: 20px;
}

.screen { max-width: 800px; margin: 0 auto; }

.container {
  background: var(--bg-white);
  border-radius: 16px;
  padding: 40px;
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
}

.header {
  text-align: center;
  margin-bottom: 40px;
}

.header h1 {
  font-size: 36px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 10px;
}

.subtitle {
  font-size: 18px;
  color: var(--text-secondary);
}

.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--border);
}

.header-bar h2 {
  font-size: 24px;
  color: var(--primary);
}

.timer-display {
  display: flex;
  align-items: center;
  gap: 10px;
}

.timer {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
}

.mode-buttons {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 30px;
}

.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

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

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-2px);
}

.btn-secondary {
  background: var(--secondary);
  color: white;
}

.btn-secondary:hover:not(:disabled) {
  background: #0891b2;
  transform: translateY(-2px);
}

.btn-large {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 20px 30px;
}

.btn-icon { font-size: 32px; }

.btn-content { flex: 1; text-align: left; }

.btn-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}

.btn-description {
  font-size: 14px;
  opacity: 0.9;
}

.btn-record {
  background: var(--danger);
  color: white;
  font-size: 18px;
}

.btn-record:hover:not(:disabled) {
  background: #dc2626;
  transform: scale(1.05);
}

.btn-stop {
  background: var(--warning);
  color: white;
  font-size: 18px;
}

.btn-stop:hover:not(:disabled) {
  background: #d97706;
  transform: scale(1.05);
}

.btn-end {
  background: var(--text-secondary);
  color: white;
}

.btn-end:hover:not(:disabled) {
  background: var(--text);
}

.access-code-form {
  display: flex;
  gap: 10px;
  margin-bottom: 30px;
}

.input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
}

.input:focus {
  outline: none;
  border-color: var(--primary);
}

.info-box {
  background: var(--bg-light);
  border-radius: 8px;
  padding: 20px;
  border-left: 4px solid var(--primary);
}

.info-box p {
  margin-bottom: 8px;
  color: var(--text-secondary);
  font-size: 14px;
}

.status {
  text-align: center;
  padding: 16px;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 30px;
  border: 2px solid transparent;
}

.status.ready {
  background: #d1fae5;
  color: #065f46;
  border-color: var(--success);
}

.status.recording {
  background: #fee2e2;
  color: #991b1b;
  border-color: var(--danger);
  animation: pulse 1.5s ease-in-out infinite;
}

.status.processing {
  background: #fef3c7;
  color: #92400e;
  border-color: var(--warning);
}

.status.speaking {
  background: #dbeafe;
  color: #1e40af;
  border-color: var(--secondary);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.controls {
  display: flex;
  gap: 15px;
  margin-bottom: 30px;
  flex-wrap: wrap;
}

.controls .btn {
  flex: 1;
  min-width: 150px;
}

.conversation-container {
  margin-top: 40px;
}

.conversation-container h3 {
  font-size: 20px;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
}

.conversation-history {
  max-height: 400px;
  overflow-y: auto;
  padding-right: 10px;
}

.message {
  margin-bottom: 20px;
  padding: 16px;
  border-radius: 8px;
  animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.user {
  background: #e0e7ff;
  border-left: 4px solid var(--primary);
}

.message.assistant {
  background: #d1fae5;
  border-left: 4px solid var(--success);
}

.message-label {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.message.user .message-label { color: var(--primary); }
.message.assistant .message-label { color: #065f46; }

.message-text {
  line-height: 1.6;
  font-size: 16px;
}

@media (max-width: 768px) {
  .container { padding: 20px; }
  .header h1 { font-size: 28px; }
  .header-bar { flex-direction: column; gap: 15px; }
  .controls { flex-direction: column; }
  .controls .btn { width: 100%; }
}
