/* =====================================================================
   DeepL Hub 2.0 — App stylesheet
   ===================================================================== */

:root {
  --bg: #ffffff;
  --bg-alt: #f6f8fa;
  --bg-elev: #ffffff;
  --border: #d0d7de;
  --border-strong: #afb8c1;
  --text: #1f2328;
  --text-muted: #656d76;
  --primary: #0969da;
  --primary-hover: #0860c7;
  --primary-text: #ffffff;
  --danger: #cf222e;
  --success: #1a7f37;
  --warning: #9a6700;
  --info: #0969da;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --radius: 8px;
  --radius-sm: 6px;
  --transition: 150ms ease;

  --font-base: 16px;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

[data-font-size="small"]  { --font-base: 14px; }
[data-font-size="normal"] { --font-base: 16px; }
[data-font-size="large"]  { --font-base: 18px; }

/* Dark theme */
.theme-dark, .theme-auto {
  color-scheme: dark light;
}

@media (prefers-color-scheme: dark) {
  .theme-auto {
    --bg: #0d1117;
    --bg-alt: #161b22;
    --bg-elev: #161b22;
    --border: #30363d;
    --border-strong: #444c56;
    --text: #e6edf3;
    --text-muted: #8b949e;
    --primary: #58a6ff;
    --primary-hover: #79b8ff;
    --primary-text: #0d1117;
    --danger: #f85149;
    --success: #3fb950;
    --warning: #d29922;
    --info: #58a6ff;
    --shadow: 0 1px 3px rgba(0,0,0,0.4), 0 4px 12px rgba(0,0,0,0.2);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
  }
}

.theme-dark {
  --bg: #0d1117;
  --bg-alt: #161b22;
  --bg-elev: #161b22;
  --border: #30363d;
  --border-strong: #444c56;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --primary: #58a6ff;
  --primary-hover: #79b8ff;
  --primary-text: #0d1117;
  --danger: #f85149;
  --success: #3fb950;
  --warning: #d29922;
  --info: #58a6ff;
  --shadow: 0 1px 3px rgba(0,0,0,0.4), 0 4px 12px rgba(0,0,0,0.2);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
}

/* ----- Base ----- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-family);
  font-size: var(--font-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; font-size: inherit; cursor: pointer; }

textarea, input, select, button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

[hidden] { display: none !important; }

/* ----- Header ----- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  gap: 16px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 10;
}

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

.brand-mark {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), #00d3a7);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.5px;
}

.header-brand h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.version {
  color: var(--text-muted);
  font-size: 12px;
  font-family: var(--font-mono);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.quota-display {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
}

.quota-text {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.quota-bar {
  height: 4px;
  background: var(--bg-alt);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.quota-fill {
  height: 100%;
  background: var(--success);
  width: 0%;
  transition: width var(--transition), background var(--transition);
}

.quota-fill.warning { background: var(--warning); }
.quota-fill.danger  { background: var(--danger); }

.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 16px;
  line-height: 1;
  color: var(--text);
  transition: background var(--transition), border-color var(--transition);
}

.btn-icon:hover { background: var(--bg-alt); border-color: var(--border-strong); }

.user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}

#username-display {
  font-weight: 500;
  font-size: 14px;
}

/* ----- Buttons ----- */
.btn {
  background: var(--bg-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-weight: 500;
  transition: background var(--transition), border-color var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn:hover:not(:disabled) { background: var(--bg-elev); border-color: var(--border-strong); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: var(--primary-text);
  border-color: var(--primary);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-block { width: 100%; justify-content: center; }

.btn-link {
  background: transparent;
  border: none;
  color: var(--primary);
  cursor: pointer;
  padding: 4px 8px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}
.btn-link:hover { background: var(--bg-alt); }
.btn-link.danger { color: var(--danger); }

/* ----- Main ----- */
.app-main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.mode-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-alt);
  padding: 4px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  width: fit-content;
}

.mode-tabs .tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 14px;
  transition: background var(--transition), color var(--transition);
}

.mode-tabs .tab:hover { color: var(--text); }
.mode-tabs .tab.active {
  background: var(--bg-elev);
  color: var(--text);
  box-shadow: var(--shadow);
}

.mode-panel { display: none; flex-direction: column; gap: 16px; }
.mode-panel.active { display: flex; }

/* ----- Languages ----- */
.language-controls {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

/* Language combobox: visible button + popover with search; the underlying
   <select> is hidden but kept in the DOM as the source of truth. */
.lang-combo {
  position: relative;
  flex: 1;
  min-width: 220px;
  max-width: 320px;
}

.lang-combo-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.lang-combo-button:hover { border-color: var(--border-strong); }
.lang-combo-button[aria-expanded="true"] {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.15);
}
.lang-combo-value {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lang-combo-caret {
  color: var(--text-muted);
  font-size: 12px;
}

.lang-combo-popover {
  position: absolute;
  z-index: 50;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  max-height: 360px;
  min-width: 240px;
  overflow: hidden;
}

.lang-combo-search {
  background: var(--bg);
  color: var(--text);
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  font-size: 13px;
  outline: none;
}
.lang-combo-search::placeholder { color: var(--text-muted); }

.lang-combo-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.lang-combo-group {
  padding: 6px 12px 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  background: var(--bg-alt);
}

.lang-combo-option {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lang-combo-option:hover,
.lang-combo-option.active { background: var(--bg-alt); }
.lang-combo-option.selected {
  background: rgba(9, 105, 218, 0.12);
  color: var(--primary);
  font-weight: 500;
}

.lang-combo-empty {
  padding: 16px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* Hidden native <select> — kept in DOM for accessibility / form fallback */
.lang-combo-native {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  clip: rect(0 0 0 0);
}

.btn-swap {
  background: var(--bg-alt);
  color: var(--text);
  border: 1px solid var(--border);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 16px;
  display: grid;
  place-items: center;
  transition: transform var(--transition), background var(--transition);
}
.btn-swap:hover { background: var(--bg-elev); transform: rotate(180deg); }

/* ----- Translation area ----- */
.translation-area {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 760px) {
  .translation-area { grid-template-columns: 1fr; }
}

.text-panel {
  position: relative;       /* anchor for mic-btn / mic-overlay */
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.text-panel textarea {
  background: transparent;
  border: none;
  outline: none;
  resize: vertical;
  padding: 14px;
  min-height: 220px;
  font-size: var(--font-base);
  line-height: 1.5;
  color: var(--text);
  font-family: var(--font-family);
}

.text-panel textarea:focus { background: var(--bg-alt); }

.panel-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  border-top: 1px solid var(--border);
  background: var(--bg-alt);
}

.char-count {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ----- Action bar ----- */
.action-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.status-info {
  font-size: 13px;
  color: var(--text-muted);
  flex: 1;
}
.status-info.success { color: var(--success); }
.status-info.error   { color: var(--danger); }
.status-info.warning { color: var(--warning); }

.keyboard-hint {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-alt);
}

.btn-spinner {
  display: inline-block;
  animation: spin 1s linear infinite;
}

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

/* ----- Upload zone ----- */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  background: var(--bg-elev);
  transition: border-color var(--transition), background var(--transition);
  outline: none;
}

.upload-zone:hover, .upload-zone.dragover, .upload-zone:focus-visible {
  border-color: var(--primary);
  background: var(--bg-alt);
}

.upload-icon { font-size: 36px; margin-bottom: 8px; }
.upload-text p { margin: 4px 0; }
.upload-hint { color: var(--text-muted); font-size: 13px; }

.file-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.file-icon { font-size: 24px; }
.file-details { flex: 1; min-width: 0; }
.file-name { font-weight: 500; word-break: break-all; }
.file-meta { color: var(--text-muted); font-size: 12px; font-family: var(--font-mono); }

/* ----- OCR settings (checkboxes) ----- */
.ocr-settings {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.ocr-settings .field-inline {
  margin: 0;
  font-size: 13px;
}

/* ----- OCR status indicator ----- */
.ocr-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-muted);
}

.ocr-status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.ocr-status.up   .dot { background: var(--success); box-shadow: 0 0 8px var(--success); }
.ocr-status.down .dot { background: var(--danger);  box-shadow: 0 0 8px var(--danger); }
.ocr-status.busy .dot { background: var(--warning); animation: pulse 1.4s infinite; }

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

/* ----- Modal ----- */
.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 16px;
}

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

.modal-content {
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 720px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { margin: 0; font-size: 16px; }
.modal-actions { display: flex; gap: 8px; align-items: center; }

.modal-close {
  background: transparent;
  border: none;
  font-size: 24px;
  line-height: 1;
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
}
.modal-close:hover { background: var(--bg-alt); color: var(--text); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

/* ----- History list ----- */
.history-list { display: flex; flex-direction: column; gap: 10px; }

.history-item {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.history-text {
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 6em;
  overflow: hidden;
  position: relative;
}

.history-actions { display: flex; gap: 6px; justify-content: flex-end; }

.history-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
}

.history-pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
}

/* ----- Settings form ----- */
.setting-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin: 0 0 14px;
}
.setting-group legend {
  padding: 0 6px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-muted);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}
.field > span { font-size: 13px; color: var(--text-muted); }
.field input, .field select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: var(--text);
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.15);
}

.field-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.field-inline input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); }

/* ----- Auth screen ----- */
.auth-body {
  background: var(--bg);
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 32px;
  width: 100%;
  max-width: 420px;
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 24px;
}

.auth-brand .brand-mark {
  width: 56px;
  height: 56px;
  font-size: 22px;
  margin-bottom: 12px;
}

.auth-brand h1 {
  margin: 0 0 4px;
  font-size: 24px;
}

.subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-toggle {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin: 4px 0 0;
}

.form-error {
  padding: 10px;
  border: 1px solid var(--danger);
  background: rgba(207, 34, 46, 0.08);
  color: var(--danger);
  border-radius: var(--radius-sm);
  font-size: 13px;
  text-align: center;
}

/* ----- Toasts ----- */
.toasts {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
  pointer-events: none;
}

.toast {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 3px solid var(--info);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  box-shadow: var(--shadow-lg);
  min-width: 240px;
  max-width: 360px;
  font-size: 13px;
  pointer-events: auto;
  animation: toast-in 200ms ease;
}

.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

@keyframes toast-in {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

.result-edited-flag {
  font-size: 12px;
  color: var(--warning);
  font-style: italic;
  margin-left: 6px;
}

/* ----- Responsive tweaks ----- */
/* Tablets and below */
@media (max-width: 900px) {
  .app-header {
    padding: 10px 14px;
    gap: 10px;
  }
  .header-controls { gap: 8px; }
  .quota-display { min-width: 110px; }
  .quota-display .quota-text { font-size: 11px; }
  .lang-combo { min-width: 180px; max-width: none; }
  .app-main { padding: 16px; gap: 12px; }
  .text-panel textarea { min-height: 180px; }
}

/* Small tablets / large phones */
@media (max-width: 760px) {
  .translation-area { grid-template-columns: 1fr; }
  .text-panel textarea { min-height: 160px; }
  .charts-grid { grid-template-columns: 1fr; }
  .language-controls { gap: 8px; }
  .lang-combo { flex: 1 1 100%; max-width: 100%; }
  .btn-swap { order: 3; transform: rotate(90deg); width: 32px; height: 32px; }
  .btn-swap:hover { transform: rotate(270deg); }
  .modal-content { max-width: 100%; max-height: 92vh; }
  .modal-body { padding: 14px; }
}

/* Phones */
@media (max-width: 600px) {
  .app-header {
    flex-direction: column;
    align-items: stretch;
    padding: 10px 12px;
  }
  .header-brand { justify-content: space-between; }
  .header-controls { justify-content: space-between; flex-wrap: wrap; }
  .header-brand h1 { font-size: 16px; }
  .quota-display {
    order: 5;
    flex: 1 1 100%;
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }
  .quota-display .quota-text { white-space: nowrap; }
  .quota-bar { flex: 1; }
  .keyboard-hint { display: none; }
  .app-main { padding: 12px 10px; }
  .mode-tabs {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .mode-tabs .tab {
    flex-shrink: 0;
    padding: 10px 14px;
    font-size: 13px;
  }
  .text-panel textarea {
    padding: 12px;
    font-size: 16px; /* prevent iOS zoom-in on focus */
  }
  .upload-zone { padding: 30px 14px; }
  .btn { padding: 10px 16px; font-size: 14px; }
  .btn-primary { width: 100%; justify-content: center; }
  .action-bar { gap: 8px; }
  .action-bar .status-info { width: 100%; order: 99; }
  .user-menu { padding-left: 8px; }
}

/* Tiny phones */
@media (max-width: 380px) {
  .header-brand .version { display: none; }
  .lang-combo-search { font-size: 12px; padding: 8px 10px; }
  .stat-value { font-size: 22px; }
}

/* Touch-friendly tap targets */
@media (hover: none) and (pointer: coarse) {
  .btn-icon, .btn-link, .modal-close { min-height: 36px; min-width: 36px; }
  .lang-combo-button, .lang-combo-search, .field input, .field select {
    min-height: 40px;
  }
}

/* ----- Voice input — mic button + recording overlay ----- */

.mic-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-elev);
  color: var(--text);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  transition: background var(--transition), border-color var(--transition),
              transform 80ms ease;
  z-index: 2;
}
.mic-btn:hover { background: var(--bg-alt); border-color: var(--border-strong); }
.mic-btn:active { transform: scale(0.94); }
.mic-btn:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.25);
}

/* "Recording" pulse — drawn behind the icon as an animated ring. */
.mic-pulse {
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
}
.mic-btn[data-state="recording"] {
  background: rgba(248, 81, 73, 0.18);
  border-color: var(--danger);
  color: var(--danger);
}
.mic-btn[data-state="recording"] .mic-pulse {
  opacity: 1;
  border: 2px solid var(--danger);
  animation: mic-pulse 1.4s ease-out infinite;
}
.mic-btn[data-state="uploading"] {
  border-color: var(--primary);
  color: var(--primary);
  cursor: wait;
}
.mic-btn[data-state="uploading"] .mic-icon {
  animation: mic-spin 1.2s linear infinite;
}

@keyframes mic-pulse {
  0%   { transform: scale(1);   opacity: 0.85; }
  100% { transform: scale(1.6); opacity: 0;    }
}
@keyframes mic-spin {
  to { transform: rotate(360deg); }
}

/* Recording overlay — full-panel dimmer with a centred status card. */
.mic-overlay {
  position: absolute;
  inset: 0;
  background: rgba(13, 17, 23, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
}
body.theme-light .mic-overlay { background: rgba(255, 255, 255, 0.75); }

.mic-overlay-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  min-width: 220px;
  text-align: center;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}
.mic-overlay-state {
  font-weight: 600;
  font-size: 14px;
}
.mic-overlay-timer {
  font-family: var(--font-mono);
  font-size: 26px;
  letter-spacing: 1px;
  color: var(--danger);
}
.mic-overlay-actions {
  display: flex;
  gap: 8px;
}
.mic-overlay-hint {
  margin-top: 2px;
  font-size: 11px;
}

/* Bigger tap targets on touch devices. */
@media (hover: none) and (pointer: coarse) {
  .mic-btn { width: 42px; height: 42px; font-size: 18px; }
}
