:root {
  --primary-color: #7c3aed;
  --secondary-color: #ec4899;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;
  --info-color: #3b82f6;
  --background: #f9fafb;
  --surface: #ffffff;
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --border-color: #e5e7eb;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-full: 9999px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--background);
  color: var(--text-primary);
  line-height: 1.6;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem;
}

/* Header Styles */
.header {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: white;
  padding: 2rem 0;
  margin-bottom: 2rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.header h1 {
  text-align: center;
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.header .subtitle {
  text-align: center;
  opacity: 0.9;
  font-size: 1.1rem;
}

/* Card/Panel Styles */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  margin-bottom: 1.5rem;
  border: 1px solid var(--border-color);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--border-color);
}

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-title .icon {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: white;
  border-radius: var(--radius-sm);
  font-size: 14px;
}

/* Grid Layouts */
.grid {
  display: grid;
  gap: 1.5rem;
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

@media (max-width: 768px) {
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
}

/* Form Elements */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-primary);
  font-size: 0.95rem;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 1rem;
  transition: all 0.3s ease;
  background: white;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgb(124 58 237 / 0.1);
}

.form-textarea {
  min-height: 120px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.5;
}

/* Button Styles */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-secondary {
  background: white;
  color: var(--primary-color);
  border: 2px solid var(--primary-color);
}

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

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

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

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

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.btn-group {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

/* Recording Button */
.record-btn {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-lg);
  position: relative;
}

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

.record-btn.recording {
  background: var(--danger-color);
  animation: pulse 1.5s infinite;
}

.record-btn.recording::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: inherit;
  opacity: 0.5;
  animation: ripple 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes ripple {
  0% {
    transform: scale(1);
    opacity: 0.5;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

.record-btn .mic-icon {
  font-size: 2.5rem;
}

.record-timer {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 1rem;
}

/* Status Messages */
.status {
  padding: 1rem;
  border-radius: var(--radius-md);
  margin: 1rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
}

.status.connected {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.status.error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.status.warning {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.status.info {
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

/* Score Display */
.scores-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.score-card {
  background: var(--background);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  text-align: center;
  border: 2px solid var(--border-color);
  transition: all 0.3s ease;
}

.score-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.score-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.score-value {
  font-size: 2.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.score-bar {
  width: 100%;
  height: 8px;
  background: var(--border-color);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: 0.5rem;
}

.score-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 1s ease, background 0.3s ease;
}

.score-fill.high {
  background: linear-gradient(90deg, var(--success-color), #34d399);
}

.score-fill.medium {
  background: linear-gradient(90deg, var(--warning-color), #fbbf24);
}

.score-fill.low {
  background: linear-gradient(90deg, var(--danger-color), #f87171);
}

/* Transcription Display */
.transcription-box {
  background: var(--background);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  min-height: 150px;
  font-size: 1.1rem;
  line-height: 1.8;
  position: relative;
}

.transcription-box.active {
  border-color: var(--primary-color);
  background: white;
}

.transcription-box .partial {
  color: var(--text-secondary);
  font-style: italic;
}

.transcription-indicator {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  gap: 0.25rem;
}

.transcription-indicator.active span {
  width: 8px;
  height: 8px;
  background: var(--primary-color);
  border-radius: 50%;
  animation: blink 1.4s infinite both;
}

.transcription-indicator.active span:nth-child(2) {
  animation-delay: 0.2s;
}

.transcription-indicator.active span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes blink {
  0%, 80%, 100% { opacity: 0; }
  40% { opacity: 1; }
}

/* Rubric Builder */
.rubric-builder {
  background: var(--background);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin: 1rem 0;
}

.rubric-criteria {
  margin: 1rem 0;
}

.criterion-item {
  background: white;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1rem;
  transition: all 0.3s ease;
}

.criterion-item:hover {
  border-color: var(--primary-color);
}

.criterion-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.criterion-name {
  font-weight: 600;
  color: var(--text-primary);
}

.criterion-weight {
  background: var(--primary-color);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 600;
}

.criterion-levels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.level-item {
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  text-align: center;
  font-weight: 500;
}

.level-beginner {
  background: #fee2e2;
  color: #991b1b;
}

.level-intermediate {
  background: #fef3c7;
  color: #92400e;
}

.level-advanced {
  background: #d1fae5;
  color: #065f46;
}

/* Feedback Display */
.feedback-section {
  background: var(--background);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin: 1rem 0;
}

.feedback-summary {
  font-size: 1.1rem;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: white;
  border-radius: var(--radius-md);
  border-left: 4px solid var(--primary-color);
}

.feedback-list {
  display: grid;
  gap: 1rem;
}

.feedback-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem;
  background: white;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.feedback-icon {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-weight: 700;
}

.feedback-icon.strength {
  background: var(--success-color);
  color: white;
}

.feedback-icon.improvement {
  background: var(--warning-color);
  color: white;
}

.feedback-text {
  flex: 1;
  color: var(--text-primary);
  line-height: 1.5;
}

/* Sample Sentences */
.sample-sentences {
  display: grid;
  gap: 0.75rem;
  margin: 1rem 0;
}

.sample-sentence {
  padding: 1rem;
  background: white;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 1.05rem;
}

.sample-sentence:hover {
  border-color: var(--primary-color);
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.05), rgba(236, 72, 153, 0.05));
  transform: translateX(4px);
}

.sample-sentence.selected {
  border-color: var(--primary-color);
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.1), rgba(236, 72, 153, 0.1));
}

/* Word Analysis */
.word-analysis {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1rem 0;
}

.word-item {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-weight: 500;
  border: 2px solid transparent;
}

.word-item.correct {
  background: #d1fae5;
  color: #065f46;
  border-color: #10b981;
}

.word-item.warning {
  background: #fef3c7;
  color: #92400e;
  border-color: #f59e0b;
}

.word-item.error {
  background: #fee2e2;
  color: #991b1b;
  border-color: #ef4444;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: 1.5rem;
}

.tab {
  padding: 0.75rem 1.5rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.3s ease;
  background: none;
  border: none;
  font-size: 1rem;
}

.tab:hover {
  color: var(--primary-color);
}

.tab.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

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

/* Loading Spinner */
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 2rem auto;
}

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

/* Toggle Switch */
.toggle-switch {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.toggle-switch input[type="checkbox"] {
  display: none;
}

.toggle-switch label {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 26px;
  background: var(--border-color);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background 0.3s ease;
}

.toggle-switch label::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: transform 0.3s ease;
}

.toggle-switch input[type="checkbox"]:checked + label {
  background: var(--primary-color);
}

.toggle-switch input[type="checkbox"]:checked + label::after {
  transform: translateX(24px);
}

/* Utility Classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-secondary); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.hidden { display: none !important; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }