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

:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface-2: #1c1c1c;
  --gold: #d4af37;
  --gold-light: #f0c94b;
  --gold-dim: #8b7320;
  --gold-glow: rgba(212, 175, 55, 0.15);
  --text: #ffffff;
  --text-secondary: #9a9a9a;
  --border: #2a2a2a;
  --success: #4caf50;
  --danger: #e74c3c;
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.2s ease;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Brand Header */
.brand-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
}

.brand-inner {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

/* Screens */
.screen {
  display: none;
  min-height: 100vh;
  padding: 20px 0;
  animation: fadeIn 0.3s ease;
}

.screen.active {
  display: block;
}

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

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Home Screen */
.home-header {
  text-align: center;
  padding: 40px 0 40px;
}

.logo-icon {
  margin-bottom: 20px;
}

.app-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 8px;
}

.app-subtitle {
  color: var(--gold);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.5px;
}

/* Mode Cards */
.mode-cards {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

.mode-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-align: left;
  cursor: pointer;
  transition: all var(--transition);
  display: block;
  width: 100%;
  color: var(--text);
  font-family: inherit;
  font-size: inherit;
}

.mode-card:hover {
  border-color: var(--gold);
  background: var(--surface-2);
  box-shadow: 0 0 20px var(--gold-glow);
  transform: translateY(-2px);
}

.mode-card:active {
  transform: translateY(0);
}

.mode-icon {
  color: var(--gold);
  margin-bottom: 12px;
}

.mode-card h2 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.mode-card p {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* Buttons */
.btn-primary {
  background: var(--gold);
  color: #000;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 28px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
}

.btn-primary:hover {
  background: var(--gold-light);
  box-shadow: 0 4px 16px var(--gold-glow);
}

.btn-primary:active {
  transform: scale(0.97);
}

.btn-large {
  width: 100%;
  padding: 16px;
  font-size: 1.1rem;
  margin-top: 32px;
}

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 24px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  font-family: inherit;
}

.btn-secondary:hover {
  border-color: var(--gold-dim);
  color: var(--gold);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  padding: 12px 24px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  border-radius: var(--radius-sm);
  font-family: inherit;
}

.btn-ghost:hover {
  color: var(--text);
  background: var(--surface);
}

.btn-back {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  padding: 8px 0;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color var(--transition);
  font-family: inherit;
}

.btn-back:hover {
  color: var(--gold);
}

.btn-icon {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-icon:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  padding: 12px 24px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  width: 100%;
  margin-top: 24px;
  font-family: inherit;
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}

/* Category Selection */
.screen-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 24px 0 8px;
}

.screen-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 32px;
}

.category-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.category-checkbox {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  cursor: pointer;
  transition: all var(--transition);
}

.category-checkbox.active {
  border-color: var(--gold);
  background: rgba(212, 175, 55, 0.05);
}

.category-checkbox input {
  display: none;
}

.checkbox-mark {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-radius: 4px;
  flex-shrink: 0;
  transition: all var(--transition);
  position: relative;
}

.category-checkbox.active .checkbox-mark {
  background: var(--gold);
  border-color: var(--gold);
}

.category-checkbox.active .checkbox-mark::after {
  content: '';
  position: absolute;
  left: 6px;
  top: 2px;
  width: 6px;
  height: 11px;
  border: solid #000;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.checkbox-label {
  font-weight: 600;
  font-size: 1rem;
  flex: 1;
}

.checkbox-count {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* Time Selection */
.time-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 24px;
}

.time-option {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-family: inherit;
  color: var(--text);
}

.time-option:hover {
  border-color: var(--gold-dim);
}

.time-option.selected {
  border-color: var(--gold);
  background: rgba(212, 175, 55, 0.05);
  box-shadow: 0 0 12px var(--gold-glow);
}

.time-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
}

.time-option.selected .time-value {
  color: var(--gold);
}

.time-unit {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Practice Screen */
.practice-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.session-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.category-badge {
  background: var(--gold-glow);
  color: var(--gold);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: capitalize;
}

.progress-text {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* Timer Bar */
.timer-bar {
  background: var(--surface);
  border-radius: 20px;
  height: 32px;
  position: relative;
  margin-bottom: 24px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.timer-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--gold-light));
  border-radius: 20px;
  transition: width 1s linear;
  width: 100%;
}

.timer-bar-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.8rem;
  font-weight: 600;
  color: #000;
  white-space: nowrap;
}

.timer-bar-fill.low {
  background: linear-gradient(90deg, var(--danger), #ff6b6b);
}

.timer-bar-fill.low + .timer-bar-text {
  color: #fff;
}

/* Question Card */
.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 28px;
  margin-bottom: 24px;
  text-align: center;
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.question-text {
  font-size: 1.3rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text);
}

/* Stopwatch */
.stopwatch {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 24px;
}

.stopwatch-display {
  font-size: 2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
  letter-spacing: 2px;
}

.stopwatch-controls {
  display: flex;
  gap: 8px;
}

/* Answer Toggle */
.answer-toggle {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 16px;
}

.toggle-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
}

.toggle-btn.active {
  background: var(--gold);
  color: #000;
}

/* Answer Areas */
.answer-area {
  margin-bottom: 24px;
}

.answer-area.hidden {
  display: none;
}

#answer-textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 16px;
  font-size: 1rem;
  font-family: inherit;
  line-height: 1.6;
  resize: vertical;
  min-height: 120px;
  transition: border-color var(--transition);
}

#answer-textarea:focus {
  outline: none;
  border-color: var(--gold);
}

#answer-textarea::placeholder {
  color: var(--text-secondary);
}

/* Audio Controls - Speech to Text */
.speech-area {
  text-align: center;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}

.btn-speech {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 28px;
  border-radius: 28px;
  border: 1px solid var(--gold);
  background: transparent;
  color: var(--gold);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  margin-bottom: 12px;
}

.btn-speech:hover {
  background: var(--gold);
  color: #000;
}

.btn-speech.listening {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  animation: pulse 1.5s infinite;
}

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

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

.speech-status {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin: 0;
}

.speech-transcript-area textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 16px;
  font-size: 1rem;
  font-family: inherit;
  line-height: 1.6;
  resize: vertical;
  min-height: 100px;
  transition: border-color var(--transition);
}

.speech-transcript-area textarea:focus {
  outline: none;
  border-color: var(--gold);
}

.speech-transcript-area textarea::placeholder {
  color: var(--text-secondary);
}

/* Practice Actions */
.practice-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.practice-actions .btn-primary {
  flex: 1;
}

/* Review Screen */
.review-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.review-header .screen-title {
  margin: 0;
}

.review-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.review-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all var(--transition);
}

.review-item:hover {
  border-color: var(--gold-dim);
}

.review-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.review-item-category {
  font-size: 0.75rem;
  color: var(--gold);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.review-item-time {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.review-item-attempts {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.review-item-question {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 8px;
  line-height: 1.4;
}

.review-item-details {
  display: none;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.review-item.expanded .review-item-details {
  display: block;
}

.review-attempt {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.review-attempt:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.review-attempt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.review-attempt-date {
  font-size: 0.8rem;
  color: var(--gold-dim);
  font-weight: 500;
}

.review-attempt-time {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.btn-delete-attempt {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all var(--transition);
  display: flex;
  align-items: center;
}

.btn-delete-attempt:hover {
  color: var(--danger);
  background: rgba(231, 76, 60, 0.1);
}

.review-attempt-answer {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.review-attempt-no-text {
  font-style: italic;
  opacity: 0.6;
}

.review-item-answer {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.5;
  display: none;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  white-space: pre-wrap;
}

.review-item.expanded .review-item-answer {
  display: block;
}

.review-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.review-empty p {
  margin-top: 12px;
}

.review-empty .text-secondary {
  font-size: 0.9rem;
}

.hidden {
  display: none !important;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.hidden {
  display: none !important;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 32px;
  text-align: center;
  max-width: 400px;
  width: 100%;
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.modal-icon {
  margin-bottom: 16px;
}

.modal-content h2 {
  font-size: 1.4rem;
  margin-bottom: 8px;
}

.modal-content p {
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Responsive */
@media (min-width: 768px) {
  .container {
    padding: 0 32px;
  }

  .home-header {
    padding: 60px 0 48px;
  }

  .app-title {
    font-size: 2.5rem;
  }

  .mode-cards {
    flex-direction: row;
  }

  .mode-card {
    flex: 1;
  }

  .question-text {
    font-size: 1.5rem;
  }

  .question-card {
    padding: 48px 36px;
    min-height: 160px;
  }

  .practice-actions {
    max-width: 400px;
    margin: 0 auto;
  }
}

@media (max-width: 380px) {
  .app-title {
    font-size: 1.6rem;
  }

  .question-text {
    font-size: 1.1rem;
  }

  .stopwatch-display {
    font-size: 1.6rem;
  }

  .question-card {
    padding: 28px 20px;
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gold-dim);
}
