@font-face {
  font-family: "Cormorant Convex";
  src: url("/fonts/cormorant-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Cormorant Convex";
  src: url("/fonts/cormorant-500i.woff2") format("woff2");
  font-weight: 500;
  font-style: italic;
  font-display: swap;
}

:root {
  --bg: #0b0b10;
  --ink: #f4f0e9;
  --ink2: #d9d4cc;
  --muted: #a39fad;
  --faint: #6f6b7a;
  --line: rgba(255, 255, 255, 0.08);
  --card: rgba(255, 255, 255, 0.035);
  --card2: rgba(255, 255, 255, 0.06);
  --fr: #8ea6ff;
  --en: #ff9fb8;
  --lens: linear-gradient(120deg, #8ea6ff, #c3a6f3 55%, #ff9fb8);
  --serif: "Cormorant Convex", "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, system-ui, sans-serif;
  --st: env(safe-area-inset-top, 0px);
  --sb: env(safe-area-inset-bottom, 0px);
  --lvl: 0;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { opacity: 0.35; cursor: default; }
svg { display: block; }

.aurora {
  position: fixed; inset: -20%; z-index: -1; pointer-events: none;
  background:
    radial-gradient(45% 35% at 18% 12%, rgba(142, 166, 255, 0.16), transparent 70%),
    radial-gradient(40% 32% at 85% 88%, rgba(255, 159, 184, 0.13), transparent 70%),
    radial-gradient(30% 25% at 70% 30%, rgba(195, 166, 243, 0.07), transparent 70%);
  filter: saturate(110%);
}

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--st) + 10px) 18px 8px;
}
.brand { display: flex; align-items: center; gap: 11px; }
.mark { width: 42px; height: 28px; }
.mark.big { width: 84px; height: 56px; margin: 0 auto 18px; }
.wordmark { display: flex; flex-direction: column; line-height: 1; }
.wordmark.center { align-items: center; margin-bottom: 18px; }
.word { font-family: var(--serif); font-weight: 600; font-size: 27px; letter-spacing: 0.01em; }
.by { margin-top: 4px; font-size: 9.5px; letter-spacing: 0.26em; text-transform: uppercase; color: var(--muted); }
.top-actions { display: flex; gap: 6px; }
.icon {
  width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center;
  background: var(--card); border: 1px solid var(--line); color: var(--ink2);
}
.icon svg { width: 22px; height: 22px; }
.icon:active { transform: scale(0.96); }

/* ---------- conversation ---------- */
.live { position: relative; min-height: 0; display: flex; flex-direction: column; }
.feed {
  flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; gap: 12px;
  padding: 10px 16px 18px;
  mask-image: linear-gradient(to bottom, transparent 0, #000 22px, #000 100%);
}
.feed > :first-child { margin-top: auto; }
.empty { text-align: center; padding: 20px 22px 30px; color: var(--muted); }
.empty h1 { font-family: var(--serif); font-weight: 600; font-size: 31px; line-height: 1.1; color: var(--ink); margin: 0 0 12px; }
.empty p { margin: 0 auto 10px; max-width: 30em; font-size: 15.5px; }
.empty .hint { font-size: 13px; color: var(--faint); }

.turn {
  border-radius: 20px; padding: 13px 16px 15px;
  background: var(--card); border: 1px solid var(--line);
  transition: opacity 0.3s ease, background 0.3s ease;
  animation: rise 0.28s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.turn .meta { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--faint); letter-spacing: 0.06em; }
.turn .meta time { margin-left: auto; }
.turn .lat { min-width: 2.6em; text-align: right; color: var(--muted); }
.tag {
  font-size: 10px; font-weight: 600; letter-spacing: 0.12em; padding: 3px 7px 2px; border-radius: 99px;
  border: 1px solid currentColor; line-height: 1.2;
}
.tag[data-lang="fr"] { color: var(--fr); }
.tag[data-lang="en"] { color: var(--en); }
.tag[data-lang=""] { color: var(--faint); }
.arr { color: var(--faint); font-size: 13px; }
.turn .src { margin: 9px 0 0; color: var(--muted); font-size: 15px; line-height: 1.4; }
.turn .dst { margin: 7px 0 0; font-size: 20px; line-height: 1.3; font-weight: 500; color: var(--ink); letter-spacing: -0.005em; }
.turn .dst.pending::after {
  content: ""; display: inline-block; width: 46px; height: 0.75em; border-radius: 6px; vertical-align: -0.05em;
  background: linear-gradient(90deg, rgba(255,255,255,0.06), rgba(255,255,255,0.22), rgba(255,255,255,0.06));
  background-size: 200% 100%; animation: shimmer 1s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.turn:not(.latest) { opacity: 0.62; }
.turn:not(.latest) .dst { font-size: 17px; }
.turn.latest { background: var(--card2); border-color: rgba(255, 255, 255, 0.12); }
.turn.latest .dst { font-size: 25px; }
.turn.speaking { box-shadow: 0 0 0 1px rgba(195, 166, 243, 0.35), 0 12px 40px -18px rgba(195, 166, 243, 0.55); }
.turn.failed .dst { color: #ffb4a6; font-size: 15px; }
body.no-originals .turn .src { display: none; }

.caption {
  position: absolute; left: 14px; right: 14px; bottom: 8px;
  padding: 11px 15px 12px; border-radius: 18px;
  background: rgba(20, 20, 28, 0.88); border: 1px solid var(--line);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  transform: translateY(14px); opacity: 0; pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.caption.on { opacity: 1; transform: none; }
.caption .who { font-size: 10.5px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
.caption .who[data-lang="fr"] { color: var(--fr); }
.caption .who[data-lang="en"] { color: var(--en); }
.caption p { margin: 4px 0 0; font-size: 17px; line-height: 1.35; max-height: 4.1em; overflow: hidden; display: flex; flex-direction: column-reverse; }

/* ---------- dock ---------- */
.dock { padding: 6px 18px calc(var(--sb) + 14px); }
.status-row { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 26px; margin-bottom: 6px; }
.status { font-size: 12.5px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); }
.chip-btn { font-size: 11px; letter-spacing: 0.14em; padding: 4px 9px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); color: var(--ink2); }
.controls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; }
.side {
  justify-self: center; display: flex; flex-direction: column; align-items: center; gap: 5px;
  font-size: 11px; letter-spacing: 0.06em; color: var(--muted); min-width: 84px; padding: 6px 4px;
}
.side svg { width: 24px; height: 24px; padding: 11px; box-sizing: content-box; border-radius: 16px; background: var(--card); border: 1px solid var(--line); color: var(--ink2); }
.side:active svg { transform: scale(0.95); }

.mic {
  position: relative; width: 92px; height: 92px; border-radius: 50%;
  display: grid; place-items: center; color: #121219;
  background: var(--lens);
  box-shadow: 0 18px 50px -18px rgba(195, 166, 243, 0.75), inset 0 1px 0 rgba(255,255,255,0.4);
  transition: transform 0.15s ease;
}
.mic:active { transform: scale(0.96); }
.mic .ic { width: 34px; height: 34px; position: absolute; transition: opacity 0.15s; opacity: 0; }
.mic .halo, .mic .ring { position: absolute; inset: 0; border-radius: 50%; pointer-events: none; }
.mic .halo { inset: -10px; background: var(--lens); opacity: 0.18; filter: blur(10px); transform: scale(calc(1 + var(--lvl) * 0.5)); transition: transform 0.08s linear; }
.mic .ring { inset: -7px; border: 1.5px solid rgba(195, 166, 243, 0.5); opacity: 0; }
.mic .wave { position: absolute; display: flex; gap: 4px; align-items: center; height: 30px; opacity: 0; }
.mic .wave i { width: 4px; border-radius: 3px; background: #121219; height: 30%; animation: wave 0.9s ease-in-out infinite; }
.mic .wave i:nth-child(2) { animation-delay: 0.12s; } .mic .wave i:nth-child(3) { animation-delay: 0.24s; }
.mic .wave i:nth-child(4) { animation-delay: 0.36s; } .mic .wave i:nth-child(5) { animation-delay: 0.48s; }
@keyframes wave { 0%, 100% { height: 25%; } 50% { height: 95%; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0% { transform: scale(1); opacity: 0.7; } 100% { transform: scale(1.35); opacity: 0; } }

body[data-phase="idle"] .mic .ic-mic { opacity: 1; }
body[data-phase="connecting"] .mic .ic-mic { opacity: 0.5; }
body[data-phase="connecting"] .mic .ring { opacity: 1; border-color: transparent; border-top-color: #fff; animation: spin 0.8s linear infinite; }
body[data-phase="listening"] .mic .ic-pause { opacity: 1; }
body[data-phase="listening"] .mic .ring { opacity: 1; animation: pulse 1.8s ease-out infinite; }
body[data-phase="translating"] .mic .ic-pause { opacity: 0.55; }
body[data-phase="translating"] .mic .ring { opacity: 1; border-color: transparent; border-top-color: #fff; border-right-color: rgba(255,255,255,0.4); animation: spin 0.7s linear infinite; }
body[data-phase="speaking"] .mic .wave { opacity: 1; }
body[data-phase="paused"] .mic { filter: saturate(0.4) brightness(0.8); }
body[data-phase="paused"] .mic .ic-play { opacity: 1; }
body[data-phase="finishing"] .mic { filter: saturate(0.3) brightness(0.7); }
body[data-phase="finishing"] .mic .ic-mic { opacity: 0.6; }

/* ---------- big text ---------- */
.present {
  position: fixed; inset: 0; z-index: 30; background: #0b0b10;
  display: flex; flex-direction: column; padding: calc(var(--st) + 18px) 26px calc(var(--sb) + 18px);
}
.present-inner { flex: 1; display: flex; flex-direction: column; justify-content: center; transition: transform 0.35s ease; }
.present.flipped .present-inner { transform: rotate(180deg); }
.present-tag { align-self: flex-start; font-size: 12px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); margin-bottom: 14px; }
.present-text { margin: 0; font-size: clamp(30px, 8.6vw, 64px); line-height: 1.16; font-weight: 600; letter-spacing: -0.01em; }
.present-bar { display: flex; justify-content: space-between; }

/* ---------- sheets ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 20; background: rgba(11, 11, 16, 0.98);
  display: flex; flex-direction: column; animation: sheetIn 0.25s ease both;
}
@keyframes sheetIn { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: calc(var(--st) + 10px) 16px 10px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { flex: 1; margin: 0; font-family: var(--serif); font-weight: 600; font-size: 26px; }
.sheet-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 16px calc(var(--sb) + 30px); }
.muted { color: var(--muted); }

.rec {
  display: block; width: 100%; text-align: left; margin-bottom: 10px; padding: 14px 16px;
  border-radius: 18px; background: var(--card); border: 1px solid var(--line);
}
.rec-top { display: flex; gap: 10px; align-items: baseline; }
.rec-title { flex: 1; font-family: var(--serif); font-weight: 600; font-size: 21px; line-height: 1.15; }
.rec-n { font-size: 11px; color: var(--faint); letter-spacing: 0.08em; white-space: nowrap; }
.rec-meta { margin-top: 4px; font-size: 12px; color: var(--muted); letter-spacing: 0.03em; }
.rec-sum { margin: 8px 0 0; font-size: 14px; color: var(--ink2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.rec.live-tag .rec-n { color: var(--en); }

.detail-title { font-family: var(--serif); font-weight: 600; font-size: 31px; line-height: 1.1; margin: 4px 0 6px; outline: none; }
.detail-title:focus { text-decoration: underline; text-decoration-color: var(--faint); text-underline-offset: 6px; }
.detail-meta { font-size: 12.5px; color: var(--muted); letter-spacing: 0.04em; }
.actions { display: flex; gap: 8px; margin: 16px 0 6px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 11px 15px; border-radius: 14px;
  background: var(--card2); border: 1px solid var(--line); font-size: 14.5px; color: var(--ink);
}
.btn svg { width: 19px; height: 19px; }
.btn.primary, button.primary { background: var(--lens); color: #121219; border: 0; font-weight: 600; }
.btn.danger { color: #ffb4a6; }
.btn.danger.armed { background: #5a2323; border-color: #8a3a3a; color: #fff; }
.section { margin-top: 22px; }
.section h3 { margin: 0 0 8px; font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.section p { margin: 0; font-size: 16px; line-height: 1.55; color: var(--ink2); }
.section ul { margin: 0; padding-left: 18px; }
.section li { margin: 0 0 6px; font-size: 15.5px; line-height: 1.45; color: var(--ink2); }
.section li .sub { color: var(--muted); font-size: 13.5px; }
.tr { padding: 10px 0; border-top: 1px solid var(--line); }
.tr-meta { display: flex; gap: 6px; align-items: center; font-size: 11px; color: var(--faint); }
.tr-src { margin: 6px 0 0; font-size: 15px; color: var(--ink2); }
.tr-dst { margin: 4px 0 0; font-size: 15px; color: var(--muted); font-style: italic; }
.note { margin-top: 18px; font-size: 13px; color: var(--faint); }
.loading { display: flex; align-items: center; gap: 12px; color: var(--muted); padding: 30px 0; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.15); border-top-color: #c3a6f3; animation: spin 0.8s linear infinite; }

.field { margin: 18px 0; }
.field > label, .field > .lbl { display: block; font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.field .row { display: flex; gap: 8px; align-items: center; }
select, input[type="password"], input[type="text"] {
  flex: 1; width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: var(--card2);
  border: 1px solid var(--line); border-radius: 13px; padding: 11px 12px; -webkit-appearance: none; appearance: none;
}
input[type="range"] { width: 100%; accent-color: #c3a6f3; }
.seg { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 3px; }
.seg button { flex: 1; padding: 9px 6px; border-radius: 11px; font-size: 13.5px; color: var(--muted); }
.seg button.on { background: var(--card2); color: var(--ink); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08); }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); font-size: 15px; }
.toggle small { display: block; color: var(--faint); font-size: 12.5px; margin-top: 2px; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: rgba(255,255,255,0.12); transition: background 0.2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.switch input:checked + span { background: #9f8ff0; }
.switch input:checked + span::after { transform: translateX(20px); }
.tip { margin-top: 20px; padding: 13px 15px; border-radius: 15px; background: var(--card); border: 1px solid var(--line); font-size: 13.5px; color: var(--muted); line-height: 1.5; }

/* ---------- lock ---------- */
.lock { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 24px; background: rgba(11, 11, 16, 0.97); }
.lock-card { width: 100%; max-width: 380px; text-align: center; }
.lock-card p { color: var(--muted); font-size: 15px; }
.lock-card form { display: flex; gap: 8px; margin-top: 16px; }
.lock-card .primary { padding: 0 18px; border-radius: 13px; }
.lock-msg { min-height: 1.4em; font-size: 13px; color: #ffb4a6 !important; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--sb) + 150px); z-index: 50; max-width: calc(100% - 40px);
  transform: translate(-50%, 10px); opacity: 0; pointer-events: none;
  padding: 11px 16px; border-radius: 14px; background: rgba(30, 30, 40, 0.96); border: 1px solid var(--line);
  font-size: 14px; color: var(--ink); transition: opacity 0.2s, transform 0.2s; text-align: center;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 700px) {
  .feed, .dock, .top { max-width: 760px; margin: 0 auto; width: 100%; }
  .caption { left: 50%; right: auto; width: 720px; margin-left: -360px; }
}
