:root {
  --bg: #14181c;
  --surface: #1e242b;
  --surface-2: #2a323b;
  --accent: #2d8c9e;
  --accent-2: #1c505c;
  --text: #e8edf1;
  --text-dim: #9aa7b2;
  --red: #dc3c3c;
  --green: #46c85a;
  --blue: #3c82dc;
  --orange: #f0963c;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  min-height: 100dvh;
}

body {
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--surface);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 19px;
}

.dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: background 0.25s ease;
}
/* Solid colour states — no blinking, per user preference. */
.dot.recording { background: var(--red); }
.dot.processing { background: var(--blue); }
.dot.done { background: var(--green); }
.dot.error { background: var(--orange); }

/* ---- Edge-docked record tab (right screen edge) ---- */
.edge-tab {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;          /* thin when docked */
  height: 88px;
  border: none;
  border-radius: 16px 0 0 16px;
  background: var(--text-dim);   /* grey = idle */
  color: #fff;
  font-size: 0;                   /* hide icon when collapsed */
  cursor: pointer;
  z-index: 60;
  box-shadow: -3px 0 14px rgba(0,0,0,0.4);
  transition: width 0.18s ease, background 0.25s ease, font-size 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;             /* we handle pointer events ourselves */
  -webkit-user-select: none;
  user-select: none;
}
.edge-tab.peek { width: 64px; font-size: 26px; }   /* slid out */
.edge-tab.recording { background: var(--red); width: 64px; font-size: 26px; }
.edge-tab.processing { background: var(--blue); width: 64px; font-size: 26px; }
.edge-tab.done { background: var(--green); width: 64px; font-size: 26px; }
.edge-tab.continuous { box-shadow: -3px 0 0 3px rgba(255,255,255,0.5), -3px 0 14px rgba(0,0,0,0.4); }
@media (hover: hover) {
  .edge-tab:hover { width: 64px; font-size: 26px; }
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}
.icon-btn:active { background: var(--surface-2); }

.container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px 18px;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
}

/* ---- Mode fly-out (Wispr-Flow style) ---- */
.mode-flyout {
  position: relative;
  display: flex;
  justify-content: center;
}

.mode-trigger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 11px 18px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.12);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  z-index: 2;
}
.mode-trigger .trigger-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent);
}
.mode-trigger .trigger-label { color: var(--text-dim); font-weight: 500; }
#current-mode-label { color: var(--accent); }
.mode-trigger .chevron {
  color: var(--text); font-size: 13px;
  transition: transform 0.2s;
  margin-left: 2px;
}
.mode-flyout.open .mode-trigger { border-color: var(--accent); }
.mode-flyout.open .mode-trigger .chevron { transform: rotate(180deg); }

.flyout-panel {
  position: absolute;
  top: calc(100% + 10px);   /* drop DOWN from the trigger (trigger sits near top of page) */
  left: 50%;
  transform: translateX(-50%) translateY(-8px) scale(0.96);
  transform-origin: top center;
  width: min(320px, 88vw);
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 50;              /* above the sticky topbar (z-index 10) */
}
.mode-flyout.open .flyout-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0) scale(1);
}

.flyout-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 12px 14px;
  border: none;
  border-radius: 11px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.flyout-option:active { background: var(--surface-2); }
.flyout-option.active { background: var(--accent-2); }
.flyout-option .opt-name { font-size: 15px; font-weight: 700; }
.flyout-option .opt-desc { font-size: 12px; color: var(--text-dim); }
.flyout-option.active .opt-desc { color: rgba(255,255,255,0.8); }

.record-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 18px 0;
}
.record-btn {
  width: 116px; height: 116px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 46px;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(45,140,158,0.35);
  transition: transform 0.1s, background 0.2s;
  display: flex; align-items: center; justify-content: center;
}
.record-btn:active { transform: scale(0.94); }
.record-btn.recording {
  background: var(--red);
  box-shadow: 0 8px 28px rgba(220,60,60,0.45);
}
.record-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.record-hint { color: var(--text-dim); font-size: 14px; }
.timer { font-variant-numeric: tabular-nums; font-size: 18px; color: var(--text); min-height: 22px; }

.status {
  text-align: center;
  font-size: 14px;
  min-height: 20px;
  color: var(--text-dim);
}
.status.error { color: var(--orange); }

.result-section { display: flex; flex-direction: column; gap: 12px; flex: 1; }
.result {
  width: 100%;
  min-height: 180px;
  flex: 1;
  resize: vertical;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.1);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  font-family: inherit;
}

.result-actions { display: flex; gap: 10px; }
.action-btn {
  flex: 1;
  padding: 13px;
  border-radius: 11px;
  border: none;
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.action-btn:active { opacity: 0.8; }
.action-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.action-btn.primary { background: var(--accent); color: #fff; }
.action-btn.secondary { background: transparent; border: 1px solid rgba(255,255,255,0.15); }

/* Settings overlay */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: flex-end;
  z-index: 100;
}
.overlay.hidden { display: none; }
.sheet {
  background: var(--surface);
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  border-radius: 20px 20px 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 90dvh;
  overflow-y: auto;
}
.sheet-header { display: flex; align-items: center; justify-content: space-between; }
.sheet-header h2 { margin: 0; font-size: 20px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 14px; color: var(--text-dim); }
.field input, .field select {
  padding: 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px;
}
.field a { font-size: 13px; color: var(--accent); text-decoration: none; }

/* Prominent tappable link button to the API consoles */
.link-btn {
  display: block;
  padding: 13px 14px;
  border-radius: 10px;
  background: var(--accent-2);
  color: #fff !important;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  line-height: 1.35;
}
.link-btn:active { opacity: 0.85; }
.hint { font-size: 13px; color: var(--text-dim); line-height: 1.45; margin: 0; }
