/* ── Layout ───────────────────────────────────────────────────────────────── */
.hidden {
  display: none !important;
}

html, body {
  overflow-x: hidden;
  max-width: 100%;
  background: #fafafa;
}

/* ── Spacing helpers ──────────────────────────────────────────────────────── */
.mt-1 { margin-top: 16px; }
.mt-2 { margin-top: 32px; }
.ml-1 { margin-left: 8px; }

/* ── All pages: full viewport, no outer scroll ────────────────────────────── */
.page {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* ── Update banner ────────────────────────────────────────────────────────── */
.update-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: #fff8e1;
  border-bottom: 1px solid #ffe082;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.update-banner i {
  color: #f9a825;
  flex-shrink: 0;
}

.update-banner a {
  color: #00695c;
  font-weight: bold;
}

.update-banner-dismiss {
  margin-left: auto;
  padding: 0;
  height: 24px;
  line-height: 24px;
  min-width: 0;
  color: #9e9e9e;
}

/* ── Setup page ───────────────────────────────────────────────────────────── */
.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background-color: #009688;
  color: white;
  font-size: 0.85rem;
  font-weight: bold;
  margin-right: 10px;
  vertical-align: middle;
}

.deploy-steps {
  margin-top: 12px;
  padding-left: 20px;
}

.deploy-steps li {
  margin-bottom: 6px;
  line-height: 1.6;
}

.existing-panel {
  border-radius: 4px;
  margin-top: 16px;
  font-size: 0.9rem;
}

/* ── GAS code block ───────────────────────────────────────────────────────── */
.code-wrapper {
  margin-top: 12px;
  background: #f5f5f5;
  border-radius: 4px;
  border: 1px solid #e0e0e0;
  overflow: hidden;
}

.code-toolbar {
  display: flex;
  justify-content: flex-end;
  padding: 4px 6px;
  border-bottom: 1px solid #e0e0e0;
}

.code-block {
  margin: 0;
  padding: 16px;
  overflow-x: auto;
  font-size: 0.78rem;
  line-height: 1.5;
  white-space: pre;
  max-height: 300px;
  overflow-y: auto;
}

.copy-btn {
  font-size: 0.75rem;
  padding: 0 8px;
  height: 28px;
  line-height: 28px;
}

.copy-btn i {
  font-size: 14px;
  vertical-align: middle;
  margin-right: 2px;
}

/* ── Authorization pending panel ──────────────────────────────────────────── */
.pending-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}

.pending-star-icon {
  font-size: 1.3rem !important;
}

.auth-explainer {
  border-radius: 4px;
  margin-top: 16px;
}

.auth-explainer p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.6;
}

/* API key setup step */
.whisper-cost-note {
  font-size: 0.85rem;
  color: #757575;
  margin-top: 4px;
}

/* ── Browse screen ────────────────────────────────────────────────────────── */
#page-browse {
  position: relative;
}

#page-browse .page-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 80px; /* clear FAB */
}

/* Search match highlight */
mark {
  background: #e0e0e0;
  color: inherit;
  font-weight: bold;
  border-radius: 2px;
  padding: 0 1px;
}

/* Search bar */
.search-bar-row {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  gap: 8px;
  flex-shrink: 0;
}

.search-bar-row i {
  color: #9e9e9e;
  flex-shrink: 0;
}

.search-bar-row input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 1rem;
  background: transparent;
  padding: 4px 0;
}

/* Recording list */
#recordings-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.recording-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid #eeeeee;
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.recording-item:active,
.recording-item:hover {
  background: #f5f5f5;
}

.recording-item-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #e0f2f1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-right: 14px;
}

.recording-item-icon i {
  color: #009688;
  font-size: 1.2rem;
}

.recording-item-body {
  flex: 1;
  min-width: 0;
}

.recording-item-meta {
  font-size: 0.8rem;
  color: #9e9e9e;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recording-item-preview {
  font-size: 0.92rem;
  color: #424242;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recording-item-preview.pending {
  color: #9e9e9e;
  font-style: italic;
}

.recording-item-duration {
  font-size: 0.82rem;
  color: #9e9e9e;
  flex-shrink: 0;
  margin-left: 10px;
}

.recordings-empty {
  text-align: center;
  padding: 48px 24px;
  color: #9e9e9e;
}

.recordings-empty i {
  font-size: 3rem;
  color: #bdbdbd;
  display: block;
  margin-bottom: 12px;
}

/* FAB */
#btn-new-recording {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

#btn-new-recording i {
  font-size: 1.5rem;
}

/* ── Record screen ────────────────────────────────────────────────────────── */
#page-record {
  background: #fff;
}

.record-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  gap: 24px;
}

/* Timer */
#record-timer {
  font-size: 3rem;
  font-weight: 300;
  letter-spacing: 0.05em;
  color: #212121;
  font-variant-numeric: tabular-nums;
  min-width: 140px;
  text-align: center;
}

/* Waveform canvas */
#waveform-canvas {
  width: 100%;
  max-width: 400px;
  height: 80px;
  border-radius: 8px;
  background: #f5f5f5;
  display: block;
}

/* Location display */
#record-location {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  color: #757575;
}

#record-location i {
  font-size: 1rem;
  color: #9e9e9e;
}

/* Record controls */
.record-controls {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: center;
}

/* Record button — big red circle */
#btn-record-start {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #e53935;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(229, 57, 53, 0.4);
  transition: transform 0.1s, box-shadow 0.1s;
  -webkit-tap-highlight-color: transparent;
}

#btn-record-start:active {
  transform: scale(0.95);
  box-shadow: 0 2px 6px rgba(229, 57, 53, 0.4);
}

#btn-record-start i {
  font-size: 2rem;
  color: white;
}

/* Pause and done buttons */
#btn-record-pause,
#btn-record-done {
  height: 44px;
  line-height: 44px;
}

/* Saving overlay */
.record-saving {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
}

.saving-step {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1rem;
  color: #757575;
}

.saving-step.active {
  color: #009688;
  font-weight: 500;
}

.saving-step.done {
  color: #212121;
}

.saving-step i {
  font-size: 1.2rem;
}

/* Background tab warning */
.tab-warning {
  background: #e65100;
  color: white;
  padding: 10px 16px;
  font-size: 0.88rem;
  text-align: center;
  flex-shrink: 0;
}

/* ── Playback screen ──────────────────────────────────────────────────────── */
#page-playback {
  background: #fff;
}

/* Mobile layout: controls stay pinned, transcript scrolls */
.playback-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Playback header info */
.playback-meta {
  padding: 16px 16px 0;
}

.playback-meta-location {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 1.05rem;
  font-weight: 500;
  color: #212121;
}

.playback-meta-date {
  font-size: 0.85rem;
  color: #9e9e9e;
  margin-top: 2px;
}

/* Custom audio player controls */
.audio-controls {
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.audio-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #757575;
  padding: 8px;
  border-radius: 8px;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s;
}

.audio-btn:active,
.audio-btn:hover {
  color: #009688;
}

.audio-btn i {
  font-size: 1.6rem;
}

.audio-btn span {
  font-size: 0.65rem;
  margin-top: 1px;
}

/* Play/Pause button */
#btn-play-pause {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#btn-play-pause i {
  font-size: 1.6rem;
}

/* Progress bar */
.progress-container {
  padding: 0 16px;
}

.progress-bar-track {
  position: relative;
  height: 20px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: none; /* prevent scroll interference while scrubbing */
}

/* Grey background rail via pseudo-element */
.progress-bar-track::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 4px;
  background: #e0e0e0;
  border-radius: 2px;
  pointer-events: none;
}

.progress-bar-fill {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 4px;
  background: #009688;
  border-radius: 2px;
  width: 0%;
  pointer-events: none;
}

.progress-bar-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #009688;
  pointer-events: none;
  transition: transform 0.1s;
}

.progress-bar-track:active .progress-bar-thumb,
.progress-bar-track:hover .progress-bar-thumb {
  transform: translate(-50%, -50%) scale(1.3);
}

.progress-times {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: #9e9e9e;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

/* Transcript container: fills remaining height, scrolls independently */
.transcript-container {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

.transcript-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 4px;
  border-top: 1px solid #eeeeee;
}

.transcript-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9e9e9e;
  font-weight: 500;
}

#btn-copy-transcript {
  color: #9e9e9e;
  padding: 4px;
  height: auto;
  line-height: 1;
  transition: color 0.15s;
}

#btn-copy-transcript:hover,
#btn-copy-transcript:active {
  color: #009688;
}

/* Scroll-to-current floating button */
.scroll-to-current {
  position: sticky;
  bottom: 16px;
  left: calc(100% - 52px);
  z-index: 10;
  width: 36px !important;
  height: 36px !important;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 8px 8px auto;
}

.scroll-to-current i {
  font-size: 1.2rem;
}

/* Transcript list */
.transcript-divider {
  border: none;
  border-top: 1px solid #eeeeee;
  margin: 8px 0 0;
}

#transcript-list {
  list-style: none;
  margin: 0;
  padding: 0 0 48px;
}

.transcript-segment {
  display: flex;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid #f5f5f5;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
  border-left: 3px solid transparent;
}

.transcript-segment:hover {
  background: #f5f5f5;
}

.transcript-segment.active-segment {
  background: #e0f2f1;
  border-left-color: #009688;
}

.segment-time {
  font-size: 0.75rem;
  color: #9e9e9e;
  flex-shrink: 0;
  min-width: 36px;
  padding-top: 2px;
  font-variant-numeric: tabular-nums;
}

.active-segment .segment-time {
  color: #009688;
  font-weight: 500;
}

.segment-text {
  font-size: 0.95rem;
  color: #424242;
  line-height: 1.5;
}

.active-segment .segment-text {
  color: #212121;
  font-weight: 500;
}

.transcript-empty {
  padding: 32px 16px;
  text-align: center;
  color: #9e9e9e;
  font-size: 0.9rem;
}

/* ── Settings modal ───────────────────────────────────────────────────────── */
.modal-settings {
  max-width: 520px;
}

.settings-section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9e9e9e;
  margin-bottom: 8px;
  margin-top: 24px;
}

.settings-section-title:first-child {
  margin-top: 0;
}

.key-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
}

.key-status.valid {
  color: #2e7d32;
}

.key-status.invalid {
  color: #c62828;
}

.key-status.none {
  color: #9e9e9e;
}

.settings-url-block {
  margin-top: 8px;
  margin-bottom: 0;
}

.settings-url {
  display: block;
  padding: 10px 12px;
  font-size: 0.78rem;
  word-break: break-all;
  background: transparent;
}

.reset-steps {
  padding-left: 20px;
  margin-top: 8px;
}

.reset-steps li {
  margin-bottom: 6px;
  line-height: 1.6;
}

/* ── Delete confirmation modal ────────────────────────────────────────────── */
.modal-delete {
  max-width: 400px;
}

/* ── Loading state ────────────────────────────────────────────────────────── */
.loading-list {
  padding: 48px 24px;
  text-align: center;
  color: #9e9e9e;
}

/* Sync spinner + done checkmark — fixed to the left of the FAB, no layout impact */
.browse-sync-ring,
.browse-sync-done {
  position: fixed;
  bottom: 33px; /* (23 + 28) - 18 = vertically centred with FAB */
  right: 91px;  /* 23 + 56 + 12 = 12px gap to the left of FAB */
  pointer-events: none;
  z-index: 997;
}

.browse-sync-done {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #009688;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease;
}

.browse-sync-done.fading {
  opacity: 0;
}

/* ── Mobile ───────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  #record-timer {
    font-size: 2.5rem;
  }

  .audio-controls {
    gap: 12px;
  }

  .modal-settings,
  .modal-delete {
    max-width: 100%;
    width: 95% !important;
    max-height: 88vh !important;
    top: 6vh !important;
  }

  .search-bar-row {
    padding: 8px 12px;
  }

  .recording-item {
    padding: 12px;
  }

  #btn-new-recording {
    bottom: 16px;
    right: 16px;
  }
}
