:root {
  --speaking-color: #4caf50;
  --processing-color: #2196f3;
  --bg-color: #f5f7fa;
  --card-bg: white;
  --text-color: #212529;
  --text-muted: #6c757d;
  --meter-bg: #e9ecef;
}

[data-theme="dark"] {
  --bg-color: #0d0d0d;
  --card-bg: #1a1a1a;
  --text-color: #f0f0f0;
  --text-muted: #b8b8b8;
  --meter-bg: #2a2a2a;
}

body { background: var(--bg-color); min-height: 100vh; color: var(--text-color); }
.container { max-width: 900px; }
.card { border: none; box-shadow: 0 2px 12px rgba(0,0,0,0.08); background: var(--card-bg); }
.card-header { background: var(--card-bg) !important; }

/* Audio panel with inline indicators */
.audio-panel {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.audio-meter-wrap { flex: 1; min-width: 0; }
.audio-meter {
  position: relative;
  height: 28px;
  background: var(--meter-bg);
  border-radius: 6px;
  overflow: visible;
  touch-action: none;
}
.audio-meter .level {
  height: 100%;
  width: 0%;
  border-radius: 6px;
  background: linear-gradient(90deg, #4caf50, #8bc34a, #ffeb3b, #ff9800);
  transition: width 0.05s;
}
.audio-meter .threshold-marker {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 4px;
  background: #dc3545;
  border-radius: 2px;
  cursor: ew-resize;
  z-index: 10;
  box-shadow: 0 0 6px rgba(220,53,69,0.6);
}

/* Compact state indicators */
.state-indicators {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}
.state-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: white;
  opacity: 0.25;
  transition: all 0.2s ease;
}
.state-dot.speaking { background: var(--speaking-color); }
.state-dot.processing { background: var(--processing-color); }
.state-dot.active { opacity: 1; transform: scale(1.1); box-shadow: 0 0 12px currentColor; }
.state-dot.processing.active { animation: pulse 1s infinite; }
@keyframes pulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.2)} }

/* Dictation items - continuous script style, clickable */
.dictation-item {
  position: relative;
  padding: 0.15rem 0.5rem;
  margin-bottom: 0.35rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}
.dictation-item:hover {
  background: rgba(128, 128, 128, 0.1);
}
.dictation-text {
  font-size: 1rem;
  color: var(--text-color);
  word-break: break-word;
  line-height: 1.6;
}

/* Copy-all button in transcription header */
.copy-all-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  border-radius: 4px;
  font-size: 0.9rem;
  line-height: 1;
  transition: color 0.2s, background 0.2s;
}
.copy-all-btn:hover {
  color: var(--text-color);
  background: rgba(128, 128, 128, 0.12);
}
.copy-all-btn .bi-check2 { color: #198754; }

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
}

/* Header responsive */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.app-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  user-select: none;
}

/* Hamburger dropdown trigger */
.hamburger-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-color);
  font-size: 1.7rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: opacity 0.15s;
}
.hamburger-btn:hover { opacity: 0.65; }
.hamburger-btn:focus-visible { outline: 2px solid currentColor; border-radius: 3px; }


.dropdown-item {
  padding: 0.5rem 1rem;
}

/* Status row: mic icon + status text, directly under title.
   Left-aligned with the title text (past hamburger icon + gap). */
.app-status-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.1rem;
  padding-left: calc(1.7rem + 0.5rem); /* hamburger width + app-title gap */
}
.app-status-row #titleMicIcon {
  font-size: 0.8rem;
  transition: all 0.2s ease;
}
.app-status {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Settings section label */
.settings-section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.75rem;
}

/* About shortcuts */
.about-shortcuts kbd {
  min-width: 2.5rem;
  text-align: center;
  display: inline-block;
}

/* Save file group in modal */
.save-file-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

/* Edit transcript modal — textarea fills available space */
#itemModal .modal-content {
  min-height: min(55vh, 520px);
}
#itemModal .modal-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}
#itemModalText {
  flex: 1 1 auto;
  resize: none;
  min-height: 120px;
}

/* Mobile adjustments */
@media (max-width: 576px) {
  body { padding: 0; }
  .container { padding: 0.75rem; }
  .card { border-radius: 12px; }
  .card-body { padding: 0.875rem; }
  .app-title { font-size: 1.1rem; }
  /* Minimum 44px touch targets */
  .btn { min-height: 44px; padding: 0.5rem 0.875rem; font-size: 0.9rem; }
  .hamburger-btn { min-width: 44px; min-height: 44px; }
  .dropdown-item { min-height: 44px; display: flex; align-items: center; }
  .copy-all-btn { min-width: 44px; min-height: 44px; padding: 0.5rem; }
  .audio-meter { height: 36px; border-radius: 6px; }
  .threshold-marker { width: 6px; } /* easier to grab on touch */
  .state-dot { width: 40px; height: 40px; font-size: 1rem; }
  .dictation-item { padding: 0.35rem 0.5rem; margin-bottom: 0.25rem; }
  .dictation-text { font-size: 0.95rem; }
  .empty-state { padding: 1.5rem 0.75rem; }
  .empty-state i { font-size: 2.5rem !important; }
  /* Item modal footer: wrap buttons into two rows */
  #itemModal .modal-footer {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  #itemModal .modal-footer .btn {
    flex: 1 1 calc(50% - 0.25rem);
    min-width: 0;
  }
  #itemModal .modal-footer .me-auto {
    flex: 1 1 100%;
    margin-right: 0 !important;
  }
}

/* Dictations scroll area */
.dictations-scroll {
  max-height: 65vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Full-height app layout on mobile */
@media (max-width: 576px) {
  html, body {
    height: 100%;
  }
  body {
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
  }
  .transcript-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
  }
  .transcript-card .card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
  }
  .dictations-scroll {
    flex: 1;
    max-height: none;
    min-height: 0;
  }
}

/* Dropdown dark mode */
[data-theme="dark"] .dropdown-menu {
  background: var(--card-bg);
  border-color: rgba(255,255,255,0.12);
}
[data-theme="dark"] .dropdown-item {
  color: var(--text-color);
}
[data-theme="dark"] .dropdown-item:hover,
[data-theme="dark"] .dropdown-item:focus {
  background: rgba(255,255,255,0.08);
  color: var(--text-color);
}

/* Modal dark mode */
[data-theme="dark"] .modal-content {
  background: var(--card-bg);
  color: var(--text-color);
}
[data-theme="dark"] .modal-header {
  border-color: rgba(255,255,255,0.1);
}
[data-theme="dark"] .btn-close {
  filter: invert(1);
}
[data-theme="dark"] .input-group-text {
  background: #252525;
  border-color: rgba(255,255,255,0.15);
  color: var(--text-muted);
}
[data-theme="dark"] .form-control {
  background: #252525;
  border-color: rgba(255,255,255,0.15);
  color: var(--text-color);
}
[data-theme="dark"] .form-control::placeholder {
  color: var(--text-muted);
}
[data-theme="dark"] textarea.form-control {
  background: #252525;
  border-color: rgba(255,255,255,0.15);
  color: var(--text-color);
}
[data-theme="dark"] .modal-footer {
  border-color: rgba(255,255,255,0.1);
}
