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

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: #111827;
  background: #ffffff;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
}

select, input {
  font-family: inherit;
}

.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: 100vh;
  height: 100dvh;
  /* Below this, the page scrolls instead of squishing the columns / sidebar. */
  min-height: 420px;
  width: 100%;
}

/* ─── Sidebar ─────────────────────────────────────── */

.sidebar {
  background: #ffffff;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #e5e7eb;
  min-height: 0;
  overflow: hidden;
}

.sidebar-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 22px;
  overflow-y: auto;
  padding: 22px 14px 22px 0;
  margin-right: -14px;
  min-height: 0;
}

.sidebar-content::-webkit-scrollbar {
  width: 6px;
}

.sidebar-content::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 18px;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.brand-logo {
  display: block;
  width: 100%;
  max-width: 220px;
  height: auto;
  margin-left: calc(-35.567 / 1210 * 220px);
}

.brand-tagline {
  font-size: 13px;
  color: #6b7280;
}

.section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section h3 {
  font-size: 13px;
  font-weight: 600;
  color: #111827;
  margin: 0;
}

.section select {
  width: 100%;
  padding: 9px 36px 9px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  background-color: #ffffff;
  color: #111827;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236b7280'><path fill-rule='evenodd' d='M5.23 7.21a.75.75 0 0 1 1.06.02L10 11.06l3.71-3.83a.75.75 0 1 1 1.08 1.04l-4.25 4.39a.75.75 0 0 1-1.08 0L5.21 8.27a.75.75 0 0 1 .02-1.06z' clip-rule='evenodd'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.section select:hover:not(:disabled) {
  border-color: #9ca3af;
}

.section select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

/* ─── Checkboxes ──────────────────────────────────── */

.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  color: #374151;
  user-select: none;
}

.checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #3b82f6;
}

select:disabled,
.checkbox input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.checkbox input:disabled + * {
  opacity: 0.6;
}

.checkbox[data-tooltip],
.section[data-tooltip],
.help[data-tooltip] {
  position: relative;
}

.checkbox[data-tooltip] {
  cursor: not-allowed;
}

.checkbox[data-tooltip]::after,
.section[data-tooltip]::after,
.help[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  background: #111827;
  color: #ffffff;
  padding: 5px 9px;
  border-radius: 6px;
  font-size: 11px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 0.12s, transform 0.12s;
  z-index: 10;
}

.checkbox[data-tooltip]:hover::after,
.section[data-tooltip]:hover::after,
.help[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateY(0);
}

/* Tooltip for the price-bar "?" sits at the bottom of the viewport, so
   anchor it to the right edge of the icon to keep it on-screen. */
.help[data-tooltip]::after {
  left: auto;
  right: 0;
}

/* ─── Footer / Action button ──────────────────────── */

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 18px;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.status {
  text-align: center;
  font-size: 12px;
  color: #6b7280;
}

.action-row {
  display: flex;
  gap: 8px;
}

/* Icon swap based on current mode (mic = no source selected, file = source selected) */
.action-row[data-mode="mic"] .action-btn .icon-file,
.action-row[data-mode="file"] .action-btn .icon-mic {
  display: none;
}

.action-btn {
  flex: 1;
  background: #2563eb;
  color: #ffffff;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s;
}

.action-btn:hover:not(:disabled) {
  background: #1d4ed8;
}

.action-btn[data-state="running"] {
  background: #dc2626;
}

.action-btn[data-state="running"]:hover {
  background: #b91c1c;
}

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

.action-btn .icon {
  flex-shrink: 0;
}

.mode-toggle {
  width: 44px;
  background: #ffffff;
  color: #2563eb;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}

.mode-toggle:hover:not(:disabled) {
  border-color: #2563eb;
  background: #eff6ff;
}

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

.mode-toggle .icon {
  flex-shrink: 0;
}

/* ─── Source display chip ─────────────────────────── */

.source-display {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px 6px 10px;
  background: #f3f4f6;
  border-radius: 8px;
  font-size: 12px;
  color: #374151;
}

.source-display[hidden] {
  display: none;
}

.source-display svg {
  flex-shrink: 0;
  color: #6b7280;
}

#source-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#clear-source {
  background: none;
  border: none;
  color: #6b7280;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  border-radius: 4px;
}

#clear-source:hover {
  color: #111827;
  background: #e5e7eb;
}

/* ─── Audio source modal ──────────────────────────── */

/* Center the dialog box in the viewport. The combination of
   position:fixed + inset:0 + margin:auto is the canonical way to center an
   element of intrinsic (content-driven) size — more reliable than
   relying on the UA's default <dialog> placement, which varies. */
.modal {
  position: fixed;
  inset: 0;
  margin: auto;
  border: none;
  border-radius: 14px;
  padding: 0;
  max-width: 480px;
  width: 92%;
  max-height: calc(100dvh - 40px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.18);
  background: #ffffff;
  color: #111827;
  overflow: hidden;
}

.modal::backdrop {
  background: rgba(17, 24, 39, 0.5);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 22px 0;
  gap: 12px;
}

.modal-header h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  color: #111827;
}

.modal-desc {
  margin: 4px 0 0;
  font-size: 13px;
  color: #6b7280;
}

.modal-close {
  background: none;
  border: none;
  color: #6b7280;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 6px;
  flex-shrink: 0;
}

.modal-close:hover {
  background: #f3f4f6;
  color: #111827;
}

.modal-body {
  padding: 18px 22px 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  max-height: calc(100dvh - 140px);
}

.modal-section h3 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6b7280;
  margin: 0 0 8px;
}

.preset-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.preset-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: #f9fafb;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 14px;
  color: #111827;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  font-family: inherit;
}

.preset-item:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.preset-item svg {
  flex-shrink: 0;
  color: #6b7280;
}

.file-upload-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: #374151;
  transition: background 0.12s, border-color 0.12s;
}

.file-upload-btn:hover {
  background: #f9fafb;
  border-color: #9ca3af;
}

/* ─── Mobile top bar (burger) ─────────────────────── */

/* Hidden on desktop; revealed by the mobile media query. */
.mobile-bar {
  display: none;
}

.sidebar-backdrop {
  display: none;
}

/* ─── Main columns ────────────────────────────────── */

.main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.columns-wrap {
  flex: 1 1 0;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
}

.column {
  background: #ffffff;
  padding: 24px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.column + .column {
  border-left: 1px solid #e5e7eb;
}

.column-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 16px 0;
  padding-bottom: 12px;
  border-bottom: 1px solid #e5e7eb;
}

.column h2 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6b7280;
  margin: 0;
}

.provider-model {
  font-size: 11px;
  color: #9ca3af;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.transcript {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
}

.transcript::-webkit-scrollbar {
  width: 6px;
}

.transcript::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

.transcript::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

.utterance {
  margin-bottom: 12px;
  padding: 12px 14px;
  background: #f9fafb;
  border-radius: 10px;
  font-size: 15px;
  line-height: 1.55;
  color: #111827;
}

.utterance .label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.partial {
  color: #9ca3af;
}

/* ─── Price bar ───────────────────────────────────── */

.price-bar {
  flex-shrink: 0;
  padding: 10px 24px;
  border-top: 1px solid #e5e7eb;
  background: #f9fafb;
  font-size: 12px;
  color: #6b7280;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

#price-cost {
  color: #111827;
  font-weight: 500;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: help;
  margin-left: 4px;
  user-select: none;
}

.help img {
  width: 14px;
  height: 14px;
  opacity: 0.5;
  transition: opacity 0.12s;
}

.help:hover img {
  opacity: 0.9;
}

/* ─── Responsive ──────────────────────────────────── */

@media (max-width: 450px) {
  /* Single-column layout: main fills the viewport; sidebar becomes a fixed
     drawer that slides in from the left. */
  .layout {
    grid-template-columns: 1fr;
  }

  /* Sidebar — off-screen drawer by default. */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(320px, 85vw);
    z-index: 30;
    border-right: 1px solid #e5e7eb;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: none;
  }

  .layout.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  }

  /* Backdrop — only present when the drawer is open. */
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 20;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }

  .layout.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  /* Mobile top bar with burger. */
  .mobile-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid #e5e7eb;
    background: #ffffff;
    flex-shrink: 0;
  }

  .mobile-bar-brand {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
  }

  .mobile-bar-logo {
    display: block;
    width: 140px;
    max-width: 100%;
    height: auto;
    /* Mirror the sidebar logo's negative margin to compensate for empty
       space at the left edge of the SVG (35.567 / 1210 of its width). */
    margin-left: calc(-35.567 / 1210 * 140px);
  }

  .mobile-bar-tagline {
    font-size: 11px;
    color: #6b7280;
    line-height: 1.2;
  }

  .burger-btn {
    background: transparent;
    color: #111827;
    padding: 6px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
  }

  .burger-btn:hover,
  .burger-btn:focus-visible {
    background: #f3f4f6;
    outline: none;
  }

  /* Stack columns as rows filling the remaining height — no page scroll. */
  .columns-wrap {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }

  .column {
    min-height: 0;
    padding: 16px;
  }

  .column + .column {
    border-left: none;
    border-top: 1px solid #e5e7eb;
  }

  .column-header {
    margin-bottom: 10px;
    padding-bottom: 8px;
  }

  .price-bar {
    padding: 10px 14px;
  }
}
