/* walk-and-talk — iOS-grade dark UI.
   HIG: Clarity · Deference · Depth. SF Pro type, spring motion, materials. */

:root {
  /* surfaces (layered depth) */
  --bg: #000005;
  --bg-grad-top: #0e0e12;
  --surface: #16161c;
  --surface-2: #1f1f27;
  --line: #2a2a32;
  --line-soft: #20202733;

  /* text */
  --text: #f5f5f7;
  --text-2: #aeaeb6;
  --text-3: #6e6e78;

  /* tint */
  --accent: #5eead4; /* live / mint */
  --accent-dim: rgba(94, 234, 212, 0.16);
  --agent: #c7ccff;
  --you: #f5f5f7;
  --danger: #ff5d57;
  --amber: #ffd166;

  /* motion */
  --spring: cubic-bezier(0.32, 0.72, 0, 1);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  /* metrics */
  --r-card: 20px;
  --r-btn: 16px;
  --pad: 20px;
}

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

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

body {
  background: radial-gradient(
      120% 60% at 50% -10%,
      var(--bg-grad-top) 0%,
      var(--bg) 60%
    )
    fixed;
}

main {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) var(--pad) env(safe-area-inset-bottom);
}

section[hidden],
[hidden] {
  display: none !important;
}

/* ---------- view transitions (push / pop) ---------- */
#home,
#conversation,
#frame,
#profile {
  animation: enterFwd 0.34s var(--ease) both;
}
.nav-back #home,
.nav-back #conversation,
.nav-back #frame,
.nav-back #profile {
  animation: enterBack 0.34s var(--ease) both;
}
@keyframes enterFwd {
  from {
    opacity: 0;
    transform: translateX(14px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
@keyframes enterBack {
  from {
    opacity: 0;
    transform: translateX(-12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
@media (prefers-reduced-motion: reduce) {
  #home,
  #conversation,
  #frame,
  #profile,
  .nav-back #home,
  .nav-back #conversation,
  .nav-back #frame,
  .nav-back #profile {
    animation: fade 0.2s ease both;
  }
  @keyframes fade {
    from {
      opacity: 0;
    }
    to {
      opacity: 1;
    }
  }
}

/* ---------- typography ---------- */
.kicker {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-3);
}
h1 {
  letter-spacing: -0.02em;
}

/* ---------- buttons ---------- */
.btn {
  width: 100%;
  padding: 17px 20px;
  border: none;
  border-radius: var(--r-btn);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition:
    transform 0.12s var(--ease),
    opacity 0.2s,
    background 0.2s,
    box-shadow 0.2s;
  will-change: transform;
}
.btn:active {
  transform: scale(0.965);
  opacity: 0.9;
}
.btn:disabled {
  opacity: 0.45;
  transform: none;
}
.btn-primary {
  background: linear-gradient(180deg, #ffffff 0%, #ededf0 100%);
  color: #08080c;
  box-shadow: 0 8px 24px -10px rgba(255, 255, 255, 0.5);
}
.btn-ghost {
  background: var(--surface-2);
  color: var(--text);
}
.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--line);
}

/* ============ HOME ============ */
#home {
  padding-top: max(env(safe-area-inset-top), 12px);
  overflow-y: auto;
  position: relative;
}
#homeInner {
  will-change: transform;
}
.ptr {
  position: absolute;
  top: max(env(safe-area-inset-top), 12px);
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  padding-top: 14px;
  opacity: 0;
  pointer-events: none;
}
.ptr-spin {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
}
.ptr.spinning .ptr-spin {
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.home-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 18px 0 22px;
}
.wordmark {
  margin: 0;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.profile-link {
  background: var(--surface-2);
  border: none;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.12s var(--ease);
}
.profile-link:active {
  transform: scale(0.94);
}

/* gate */
.gate {
  padding: 28px 0;
  animation: fadeUp 0.5s var(--spring) both;
}
.gate-copy {
  color: var(--text-2);
  font-size: 16px;
  line-height: 1.5;
  margin: 0 0 20px;
}
.text-input {
  width: 100%;
  padding: 17px;
  margin-bottom: 14px;
  border-radius: var(--r-btn);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 17px;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}
.text-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-dim);
}
.gate-err {
  color: var(--danger);
  font-size: 14px;
  margin-top: 12px;
}

/* new conversation split button */
.split-btn {
  display: flex;
  gap: 3px;
  margin-bottom: 26px;
}
.split-main {
  flex: 1;
  border-radius: var(--r-btn) 6px 6px var(--r-btn);
}
.split-caret {
  width: 58px;
  flex: none;
  border-radius: 6px var(--r-btn) var(--r-btn) 6px;
  font-size: 17px;
}

/* iOS segmented control (filter) */
.seg {
  display: flex;
  gap: 2px;
  padding: 3px;
  margin: 0 0 16px;
  background: var(--surface);
  border-radius: 12px;
}
.seg-btn {
  flex: 1;
  padding: 9px 0;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  border-radius: 9px;
  cursor: pointer;
  transition:
    color 0.2s,
    background 0.25s var(--ease),
    box-shadow 0.25s;
}
.seg-btn:active {
  transform: scale(0.97);
}
.seg-btn.active {
  background: var(--surface-2);
  color: var(--text);
  box-shadow:
    0 1px 1px rgba(0, 0, 0, 0.2),
    0 3px 8px rgba(0, 0, 0, 0.25);
}
.list-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 0 4px 12px;
}
.history {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.history-item-wrap {
  position: relative;
  border-radius: var(--r-card);
  overflow: hidden;
  animation: fadeUp 0.5s var(--spring) both;
}
.hi-delete,
.hi-share {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 56%;
  display: flex;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.hi-delete {
  right: 0;
  justify-content: flex-end;
  padding-right: 28px;
  background: var(--danger);
  color: #fff;
}
.hi-share {
  left: 0;
  justify-content: flex-start;
  padding-left: 28px;
  background: linear-gradient(90deg, #7af0dc, var(--accent));
  color: #06120f;
}
.swipe-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  opacity: 0;
  transform: scale(0.5);
  will-change: opacity, transform;
}
.swipe-ico {
  width: 24px;
  height: 24px;
  background: currentColor;
  -webkit-mask: center / contain no-repeat;
  mask: center / contain no-repeat;
}
.ico-trash {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M9 3a1 1 0 0 0-1 1v1H4v2h16V5h-4V4a1 1 0 0 0-1-1H9zm-3 6 1 11a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-11H6z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M9 3a1 1 0 0 0-1 1v1H4v2h16V5h-4V4a1 1 0 0 0-1-1H9zm-3 6 1 11a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-11H6z'/%3E%3C/svg%3E");
}
.ico-share {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M11 4.83 8.41 7.41 7 6l5-5 5 5-1.41 1.41L13 4.83V15h-2V4.83zM5 10h3v2H6v8h12v-8h-2v-2h3a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V11a1 1 0 0 1 1-1z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M11 4.83 8.41 7.41 7 6l5-5 5 5-1.41 1.41L13 4.83V15h-2V4.83zM5 10h3v2H6v8h12v-8h-2v-2h3a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V11a1 1 0 0 1 1-1z'/%3E%3C/svg%3E");
}
.history-item {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  cursor: pointer;
  touch-action: pan-y;
  transition:
    transform 0.3s var(--spring),
    background 0.2s;
}
.history-item:active {
  background: var(--surface-2);
}
.sheet-msg {
  margin: 0;
  padding: 16px;
  text-align: center;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-3);
  border-bottom: 1px solid var(--line-soft);
}
.menu-danger {
  color: var(--danger);
  font-weight: 600;
}
.hi-main {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.hi-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hi-meta {
  font-size: 13px;
  color: var(--text-3);
}
.hi-status {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-3);
  flex-shrink: 0;
}
.hi-active {
  color: var(--accent);
  background: var(--accent-dim);
}
.hi-paused {
  color: var(--amber);
  background: rgba(255, 209, 102, 0.14);
}

/* empty state — iOS ContentUnavailableView */
.empty {
  color: var(--text-3);
  font-size: 15px;
  text-align: center;
  line-height: 1.6;
  padding: 64px 24px;
  animation: fadeUp 0.5s var(--spring) both;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============ TOP BAR (material) ============ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 calc(var(--pad) * -1);
  padding: 14px var(--pad);
  background: rgba(10, 10, 14, 0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line-soft);
}
.back {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
  padding: 0 6px 0 0;
  margin: -4px 0;
  transition:
    transform 0.12s var(--ease),
    opacity 0.15s;
}
.back:active {
  transform: translateX(-3px);
  opacity: 0.6;
}
.status-label {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text-2);
}
.share {
  margin-left: auto;
  background: var(--surface-2);
  border: none;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.12s var(--ease);
}
.share:active {
  transform: scale(0.93);
}

/* status dot */
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-3);
  transition:
    background 0.3s,
    box-shadow 0.3s;
}
body[data-state="connecting"] .dot,
body[data-state="saving"] .dot {
  background: var(--amber);
  animation: blink 1s infinite;
}
body[data-state="paused"] .dot,
body[data-state="muted"] .dot {
  background: var(--amber);
}
body[data-state="saved"] .dot {
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-dim);
}
body[data-state="error"] .dot {
  background: var(--danger);
}
@keyframes blink {
  50% {
    opacity: 0.35;
  }
}

/* live equalizer — replaces the dot when recording */
.wave {
  display: none;
  align-items: flex-end;
  gap: 3px;
  height: 16px;
}
.wave i {
  width: 3px;
  height: 5px;
  border-radius: 2px;
  background: var(--accent);
  animation: eq 0.9s var(--ease) infinite;
}
.wave i:nth-child(2) {
  animation-delay: 0.15s;
}
.wave i:nth-child(3) {
  animation-delay: 0.3s;
}
.wave i:nth-child(4) {
  animation-delay: 0.45s;
}
.wave i:nth-child(5) {
  animation-delay: 0.6s;
}
@keyframes eq {
  0%,
  100% {
    height: 5px;
  }
  50% {
    height: 16px;
  }
}
body[data-state="live"] .wave {
  display: flex;
}
body[data-state="live"] .dot {
  display: none;
}
.elapsed {
  margin-left: auto;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
  letter-spacing: 0.02em;
}
.elapsed[hidden] {
  display: none;
}

/* ============ BRIEF / HEADER CONTENT ============ */
.brief {
  padding: 22px 0 14px;
  position: relative;
}
.brief-toggle {
  position: absolute;
  top: 20px;
  right: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: none;
  color: var(--text-2);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.32s var(--spring);
}
#conversation .brief-toggle {
  display: flex;
}
.brief.collapsed {
  padding: 14px 0 10px;
}
.brief.collapsed .brief-toggle {
  transform: rotate(180deg);
}
.brief.collapsed .kicker,
.brief.collapsed .goal,
.brief.collapsed .rename-btn {
  display: none;
}
.brief.collapsed #subject {
  font-size: 19px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 44px;
}
#subject,
#frame h1,
#profile h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.18;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.goal {
  margin: 12px 0 0;
  color: var(--text-2);
  font-size: 16px;
  line-height: 1.55;
}
.rename-btn {
  margin-top: 14px;
  background: var(--surface-2);
  border: none;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.12s var(--ease);
}
.rename-btn:active {
  transform: scale(0.94);
}

/* ============ TRANSCRIPT ============ */
/* Conversation & frame fill the viewport as fixed-height columns so only the
   transcript scrolls — the top bar (and back caret) stay pinned below the
   status bar instead of sliding under it. */
#conversation:not([hidden]),
#frame:not([hidden]) {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.transcript {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 0 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}
.line {
  font-size: 17px;
  line-height: 1.5;
  max-width: 88%;
  white-space: pre-wrap;
  padding: 12px 16px;
  border-radius: 20px;
  animation: bubbleIn 0.4s var(--spring) both;
}
.line-agent {
  color: var(--text);
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-bottom-left-radius: 7px;
}
.line-you {
  color: #06120f;
  align-self: flex-end;
  background: linear-gradient(180deg, #7af0dc, var(--accent));
  border-bottom-right-radius: 7px;
  font-weight: 500;
}
@keyframes bubbleIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ============ CONTROLS ============ */
.controls {
  padding: 16px 0 max(env(safe-area-inset-bottom), 22px);
}
.live-controls {
  display: flex;
  gap: 12px;
}
.live-controls .btn {
  flex: 1;
}
.hint {
  margin: 14px 0 0;
  text-align: center;
  font-size: 13.5px;
  color: var(--text-3);
  line-height: 1.5;
}

/* ============ ACTION SHEET (the ▾ menu) ============ */
#scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  animation: fade 0.25s ease both;
}
.menu {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: max(env(safe-area-inset-bottom), 12px);
  z-index: 50;
  border-radius: 22px;
  background: rgba(30, 30, 36, 0.86);
  backdrop-filter: saturate(180%) blur(28px);
  -webkit-backdrop-filter: saturate(180%) blur(28px);
  border: 1px solid var(--line);
  overflow: hidden;
  animation: sheetUp 0.4s var(--spring) both;
}
@keyframes sheetUp {
  from {
    opacity: 0;
    transform: translateY(60px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
.menu-item {
  display: block;
  width: 100%;
  text-align: center;
  padding: 18px 16px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--line-soft);
  color: var(--accent);
  font-size: 17px;
  font-weight: 500;
  cursor: pointer;
}
.menu-item:last-child {
  border-bottom: none;
}
.menu-item:active {
  background: rgba(255, 255, 255, 0.06);
}

/* ============ FRAME RESULT ============ */
.frame-result {
  margin: 0 0 14px;
  padding: 18px;
  border: 1px solid var(--accent-dim);
  border-radius: var(--r-card);
  background: var(--surface);
  animation: fadeUp 0.45s var(--spring) both;
}
.frame-title {
  margin: 8px 0 16px;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.frame-actions {
  display: flex;
  gap: 10px;
}
.frame-actions .btn {
  flex: 1;
  padding: 14px;
  font-size: 16px;
}

/* ============ PROFILE ============ */
#profile:not([hidden]) {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.profile-text {
  flex: 1;
  min-height: 240px;
  resize: none;
  margin: 6px 0 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
  color: var(--text);
  font-size: 17px;
  line-height: 1.6;
  font-family: inherit;
  -webkit-overflow-scrolling: touch;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}
.profile-text:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-dim);
}

#agentAudio {
  display: none;
}
