/* LangTai translator (/) — the original two-card layout (owner's pick, 2026-10-20) with the new finish:
 * white page, two still pastel pools with film grain behind the cards, near-opaque glass cards,
 * language names coloured on the text itself, dark mic, and slow cross-fades when the direction swaps.
 * Nothing moves on its own; the level meter follows the real microphone only while recording. */

.tr-page {
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; background: var(--white);
  --fade: cubic-bezier(.45, 0, .25, 1);
  --south-ink: #B2477A; --central-ink: var(--accent);
  --south-wash: rgba(253, 243, 248, .9); --central-wash: rgba(242, 248, 255, .9);
}
.tr-main { position: relative; flex: 1; display: flex; overflow-x: clip; }

/* ---------- background: two pools of light with film grain ---------- */
.pools { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.pool { position: absolute; pointer-events: none; }
.pool-src { width: 720px; height: 520px; left: -6%; top: 2%; }
.pool-dst { width: 760px; height: 540px; right: -6%; bottom: -4%; }
.tint { position: absolute; inset: 0; border-radius: 50%; transition: opacity .9s var(--fade); }
.tint-pink { background: radial-gradient(closest-side, rgba(244, 196, 216, .95), rgba(248, 220, 232, .45) 55%, rgba(248, 220, 232, 0)); }
.tint-sky { background: radial-gradient(closest-side, rgba(196, 223, 252, 1), rgba(221, 238, 255, .5) 55%, rgba(221, 238, 255, 0)); }
.pool-src .tint-sky, .pool-dst .tint-pink { opacity: 0; }
.tr-page[data-src="central"] .pool-src .tint-pink, .tr-page[data-src="central"] .pool-dst .tint-sky { opacity: 0; }
.tr-page[data-src="central"] .pool-src .tint-sky, .tr-page[data-src="central"] .pool-dst .tint-pink { opacity: 1; }
.pool::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background-image: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .11  0 0 0 0 .11  0 0 0 0 .12  0 0 0 1.1 -.42'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
  background-size: 180px 180px; opacity: .55; mix-blend-mode: multiply;
  -webkit-mask-image: radial-gradient(closest-side, #000 25%, rgba(0, 0, 0, .55) 60%, transparent 100%);
          mask-image: radial-gradient(closest-side, #000 25%, rgba(0, 0, 0, .55) 60%, transparent 100%);
}

/* ---------- icon buttons ---------- */
.icon-btn {
  position: relative; width: 44px; height: 44px; flex: none; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 12px; background: transparent; color: var(--ink-2);
  transition: background-color .15s var(--ease), color .15s var(--ease), transform .15s var(--ease);
}
.icon-btn:not(:disabled):hover { background: rgba(29, 29, 31, .05); color: var(--ink); }
.icon-btn:not(:disabled):active { transform: scale(.96); }
.icon-btn:disabled { opacity: .32; cursor: default; }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn[aria-pressed="true"] { color: #A15C00; }
.icon-btn[aria-pressed="true"] svg { fill: #F3B53F; stroke: #A15C00; }
/* Signed out: stars look unavailable (grey) but stay tappable to open the Google sign-in prompt. */
.needs-login #starBtn:not(:disabled), .needs-login #openSaved .round-icon { color: #9AA0A6; opacity: .45; }
.needs-login #starBtn:not(:disabled):hover, .needs-login #openSaved:hover .round-icon { opacity: .7; }
.site-head .icon-btn[aria-expanded="true"] { background: rgba(29, 29, 31, .06); color: var(--ink); }
#copyBtn .check-icon { display: none; }
#copyBtn.is-done .copy-icon { display: none; }
#copyBtn.is-done .check-icon { display: block; color: #146C43; stroke-width: 2.2; }

/* ---------- stage + the two cards ---------- */
.stage {
  position: relative; z-index: 1; flex: 1; width: 100%; max-width: calc(1120px + var(--gutter) * 2);
  margin: 0 auto; padding: 40px var(--gutter) 56px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px;
  animation: tr-in .2s var(--ease) both;
}
@keyframes tr-in { from { opacity: 0; } }
.panels { position: relative; width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }

.card {
  position: relative; display: flex; flex-direction: column; gap: 16px; min-height: 400px; min-width: 0;
  padding: 22px 22px 22px 28px; border-radius: 28px;
  background: rgba(255, 255, 255, .94); border: 1px solid rgba(29, 29, 31, .08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .9), 0 1px 2px rgba(29, 29, 31, .04), 0 22px 56px rgba(29, 29, 31, .08);
  transition: background-color .8s var(--fade), box-shadow .2s var(--ease);
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .card { background: rgba(255, 255, 255, .82); backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%); }
}
/* The target card takes a whisper of its language colour. */
.card-dst { background: var(--central-wash); }
.tr-page[data-src="central"] .card-dst { background: var(--south-wash); }
/* Focus on the input: a clear ring on the source card. */
.card-src:has(.source:focus) { box-shadow: 0 0 0 2px var(--accent), 0 22px 56px rgba(29, 29, 31, .08); }
@supports not selector(:has(a)) { .card-src:focus-within { box-shadow: 0 0 0 2px var(--accent), 0 22px 56px rgba(29, 29, 31, .08); } }

.card-head { display: flex; align-items: center; justify-content: space-between; min-height: 44px; }
.lang { margin: 0; font-size: 17px; font-weight: 700; line-height: 1.3; transition: color .7s var(--fade); }
.tr-page[data-src="south"] .lang-from, .tr-page[data-src="central"] .lang-to { color: var(--south-ink); }
.tr-page[data-src="south"] .lang-to, .tr-page[data-src="central"] .lang-from { color: var(--central-ink); }

.card-body { flex: 1; display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.heard {
  align-self: flex-start; margin: 0; padding: 3px 12px; border-radius: 999px;
  background: rgba(255, 255, 255, .9); border: 1px solid var(--line-2); font-size: 13px; font-weight: 500; color: var(--ink-2); line-height: 1.6;
}
.source {
  display: block; width: 100%; flex: 1; min-height: 160px; margin: 0; padding: 0; border: 0; resize: none; overflow: hidden;
  background: transparent; color: var(--ink); font: inherit; font-weight: 600; line-height: 1.5;
  caret-color: var(--south-ink); transition: caret-color .7s var(--fade);
}
.tr-page[data-src="central"] .source { caret-color: var(--central-ink); }
.source::placeholder { color: var(--ink-3); font-weight: 500; opacity: 1; }
.source:focus, .source:focus-visible { outline: none; }

.result { margin: 0; min-height: 1.5em; font-weight: 600; line-height: 1.5; overflow-wrap: anywhere;
  color: var(--central-ink); transition: color .7s var(--fade); }
.tr-page[data-src="central"] .result { color: var(--south-ink); }
.result.loading { color: var(--ink-2); font-weight: 500; }
.result.reveal { animation: tr-fade .15s var(--ease) both; }
@keyframes tr-fade { from { opacity: 0; } }
.size-l { font-size: 32px; }
.size-m { font-size: 26px; }
.size-s { font-size: 21px; }

.note {
  display: flex; gap: 10px; align-items: flex-start; margin: 0; padding: 10px 12px; border-radius: 14px;
  background: rgba(255, 241, 191, .7); font-size: 15px; line-height: 1.6; color: var(--ink);
}
.note::before { content: ""; flex: none; width: 6px; height: 6px; margin-top: .7em; border-radius: 50%; background: #B7791F; }
.alts { display: flex; flex-direction: column; gap: 8px; }
.alts-label { margin: 0; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.alts-list { display: flex; flex-wrap: wrap; gap: 8px; }
.alt { display: inline-flex; align-items: baseline; gap: 8px; padding: 6px 14px; border-radius: 999px;
  background: rgba(255, 255, 255, .9); border: 1px solid var(--line-2); font-size: 16px; line-height: 1.5; }
.alt b { font-weight: 600; color: var(--ink); }
.alt span { font-size: 14px; color: var(--ink-2); }

.card-foot { display: flex; align-items: center; gap: 14px; min-height: 76px; }
.card-foot.end { justify-content: flex-end; gap: 4px; position: relative; }
.card-foot.end:has(#copyBtn:disabled) .icon-btn { visibility: hidden; }
.count { margin-left: auto; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.status { margin: 0; min-width: 0; font-size: 15px; line-height: 1.45; color: var(--ink-2); }
.status:empty { display: none; }
.status.error { color: var(--danger); }
.retry { flex: none; }
.speech-note { margin-right: auto; font-size: 12px; color: var(--ink-2); }
.speech-btn .speech-stop { display: none; }
.speech-btn[data-state="loading"] .speech-icon,
.speech-btn[data-state="playing"] .speech-icon { display: none; }
.speech-btn[data-state="loading"] .speech-stop,
.speech-btn[data-state="playing"] .speech-stop { display: block; }
.speech-btn[aria-pressed="true"] { color: #1257A8; background: rgba(18, 87, 168, .08); }
.speech-btn[aria-pressed="true"] svg { fill: none; stroke: currentColor; }
.action-note { margin-right: 4px; font-size: 14px; color: var(--ink-2); }

/* ---------- mic (dark) ---------- */
.mic {
  position: relative; width: 68px; height: 68px; flex: none; padding: 0; border: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; background: var(--ink); color: #fff;
  box-shadow: 0 1px 2px rgba(29, 29, 31, .16), 0 10px 24px rgba(29, 29, 31, .18);
  transition: background-color .15s var(--ease), box-shadow .18s var(--ease), transform .15s var(--ease);
}
.mic:not(:disabled):hover { background: #343437; }
.mic:not(:disabled):active { transform: scale(.98); }
.mic svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.mic .stop-icon { display: none; fill: currentColor; stroke: none; width: 22px; height: 22px; }
.mic.big { width: 84px; height: 84px; }
.mic.big .mic-icon { width: 32px; height: 32px; }
body.listening .mic { box-shadow: 0 0 0 7px var(--pink), 0 10px 24px rgba(29, 29, 31, .18); }
body.listening .mic .mic-icon { display: none; }
body.listening .mic .stop-icon { display: block; }
body.busy .mic { background: #55555A; cursor: progress; }

.meter { display: none; align-items: center; gap: 3px; height: 36px; flex: none; }
body.listening .meter { display: flex; }
.meter i { width: 3px; height: 4px; border-radius: 2px; background: #D9739F; transition: height 60ms linear; }
.meter i:nth-child(even) { background: #E9A9C4; }

/* ---------- swap (centred on the seam) ---------- */
.swap {
  position: absolute; left: 50%; top: 50%; z-index: 2; width: 60px; height: 60px; margin: -30px 0 0 -30px;
  border-radius: 50%; border: 1px solid rgba(29, 29, 31, .1); background: var(--white); color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 6px rgba(255, 255, 255, .7), 0 10px 26px rgba(29, 29, 31, .14);
  transition: transform .15s var(--ease), background-color .15s var(--ease);
}
.swap:hover { background: var(--paper); }
.swap:active { transform: scale(.96); }
.swap svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
  transform: rotate(calc(var(--base-turn, 0deg) + var(--turn, 0deg))); transition: transform .32s var(--ease); }

/* ---------- dock under the cards: History · mic · LiveTranslate ---------- */
/* The mic lives here on every size; the in-card copy of it is not shown. */
.card-src .card-foot .mic, .card-src .card-foot .meter, .card-src .card-foot .status { display: none; }
.dock { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 8px 0 0; }
.dock .meter { order: 2; display: flex; visibility: hidden; }
.dock .status { order: 3; text-align: center; min-height: 22px; padding: 0 16px; font-size: 14px; }
body.listening .dock .meter { visibility: visible; }
.dock-row { display: flex; align-items: flex-start; justify-content: center; gap: 28px; }
.dock-pill { padding: 8px; border-radius: 999px; background: rgba(255, 255, 255, .7); box-shadow: 0 10px 30px rgba(29, 29, 31, .1); }
/* Round side actions with their name underneath; circles line up with the mic's centre. */
.round-action {
  display: flex; flex-direction: column; align-items: center; gap: 6px; width: 92px; margin-top: 22px; padding: 0;
  border: 0; background: none; color: var(--ink); text-decoration: none; -webkit-tap-highlight-color: transparent;
}
/* Liquid glass: a clear lens (light top, darker rim), a specular highlight top-left and a soft
 * coloured caustic at the bottom; the pastel pools behind show through the blur. */
.round-icon {
  position: relative; width: 56px; height: 56px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(150deg, rgba(255, 255, 255, .86) 0%, rgba(255, 255, 255, .5) 55%, rgba(255, 255, 255, .7) 100%);
  border: 1px solid rgba(255, 255, 255, .85);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, .95), inset 0 -2px 4px rgba(29, 29, 31, .06), inset 0 0 0 .5px rgba(29, 29, 31, .05),
    0 1px 2px rgba(29, 29, 31, .06), 0 10px 26px rgba(29, 29, 31, .1);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .round-icon { backdrop-filter: blur(14px) saturate(180%); -webkit-backdrop-filter: blur(14px) saturate(180%); }
}
.round-icon::before, .round-icon::after { content: ""; position: absolute; inset: 0; border-radius: 50%; pointer-events: none; }
.round-icon::before { background: radial-gradient(120% 80% at 28% 10%, rgba(255, 255, 255, .95), rgba(255, 255, 255, 0) 46%); }
.round-icon::after { background: radial-gradient(70% 45% at 66% 96%, rgba(221, 238, 255, .9), rgba(221, 238, 255, 0) 70%); }
.round-icon svg { position: relative; z-index: 1; width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.round-action:hover .round-icon { transform: translateY(-1px); box-shadow: inset 0 1px 1px #fff, inset 0 -2px 4px rgba(29, 29, 31, .06), 0 2px 4px rgba(29, 29, 31, .06), 0 16px 34px rgba(29, 29, 31, .12); }
.round-action:active .round-icon { transform: scale(.95); }
.round-action[aria-expanded="true"] .round-icon { background: rgba(255, 255, 255, .95); }
.round-label { font-size: 13px; font-weight: 500; line-height: 1.4; color: var(--ink-2); white-space: nowrap; }
.round-live .round-icon::after { background: radial-gradient(75% 50% at 62% 96%, rgba(248, 220, 232, .95), rgba(248, 220, 232, 0) 70%); }
.round-live .round-icon .lt-logo { width: 34px; height: 34px; stroke: none; }
.round-action:focus-visible { outline: none; }
.round-action:focus-visible .round-icon { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---------- drawer: history / saved ---------- */
.backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(29, 29, 31, .18); animation: tr-fade .18s var(--ease) both; }
.sheet {
  position: fixed; z-index: 41; top: 12px; right: 12px; bottom: 12px; width: min(420px, calc(100vw - 24px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--white); border: 1px solid var(--line); border-radius: var(--r-panel); box-shadow: var(--shadow-2);
  animation: sheet-in .22s var(--ease) both;
}
@keyframes sheet-in { from { opacity: 0; transform: translateX(16px); } }
.sheet-head { display: flex; align-items: center; gap: 4px; padding: 14px 12px 0 24px; }
.sheet-head h2 { margin-right: auto; font-size: 19px; font-weight: 700; line-height: 1.4; }
.sheet-sub:empty { display: none; }
.sheet-sub { padding: 2px 24px 10px; font-size: 14px; color: var(--ink-2); }
.text-btn { min-height: 44px; padding: 0 12px; border: 0; border-radius: 12px; background: none; color: var(--accent); font-size: 15px; font-weight: 600; }
.text-btn:hover { background: rgba(18, 87, 168, .07); }
.sheet-list { flex: 1; overflow-y: auto; padding: 4px 12px 16px; overscroll-behavior: contain; }
.sheet-item { display: flex; align-items: center; gap: 2px; border-radius: 16px; }
.sheet-item + .sheet-item { margin-top: 2px; }
.sheet-item:hover { background: var(--paper); }
.sheet-open { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; padding: 12px; border: 0; border-radius: 16px; background: none; text-align: left; color: var(--ink); }
.sheet-open .from { font-size: 13px; color: var(--ink-2); }
.sheet-open .src { font-size: 16px; font-weight: 500; overflow-wrap: anywhere; }
.sheet-open .dst { font-size: 16px; font-weight: 600; color: var(--accent); overflow-wrap: anywhere; }
.sheet-empty { padding: 28px 24px; color: var(--ink-2); font-size: 15px; text-align: center; }

/* ---------- tablet / phone ---------- */
@media (max-width: 860px) {
  .stage { justify-content: flex-start; padding: 16px var(--gutter) 24px; gap: 0; }
  .panels { grid-template-columns: 1fr; row-gap: 6px; }
  .card { min-height: 210px; padding: 16px 14px 14px 20px; border-radius: 24px; gap: 10px; }
  .card-src { grid-row: 1; }
  .card-dst { grid-row: 3; min-height: 170px; }
  .swap { position: relative; grid-row: 2; left: auto; top: auto; justify-self: center; width: 54px; height: 54px; margin: -27px 0; }
  .swap svg { width: 22px; height: 22px; --base-turn: 90deg; }
  .source { min-height: 104px; }
  .size-l { font-size: 26px; }
  .size-m { font-size: 23px; }
  .size-s { font-size: 20px; }
  .lang { font-size: 16px; }
  .card-foot { min-height: 40px; gap: 10px; flex-wrap: wrap; }
  .card-dst .card-foot { min-height: 44px; }
  .dock { padding: 18px 0 8px; }
  .dock-row { gap: 14px; }
  .round-action { width: 84px; }
  .pool-src { width: 420px; height: 360px; left: -35%; top: 0; }
  .pool-dst { width: 460px; height: 380px; right: -40%; bottom: 0; }
  .sheet { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; max-height: min(78vh, 640px); animation-name: sheet-up; }
  @keyframes sheet-up { from { opacity: 0; transform: translateY(16px); } }
}
@media (max-width: 380px) {
  .size-l { font-size: 24px; }
}

/* No empty pill when the mic is hidden (Central→Southern is typing only). */
.dock-pill:has(.mic[hidden]) { display: none; }

/* ---------- Google Auth & User Profile ---------- */
.auth-bar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 4px;
}
.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 8px 3px 4px;
  background: rgba(29, 29, 31, .04);
  border: 1px solid var(--line-2);
  border-radius: 999px;
}
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--paper);
  border: 1px solid var(--line);
}
.logout-btn {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  font-family: inherit;
  transition: color .15s var(--ease), background-color .15s var(--ease);
}
.logout-btn:hover {
  color: #c92a2a;
  background: rgba(201, 42, 42, .06);
}

/* Prompt next to star when signed out */
/* Floats next to the tapped star (placed by app.js placeAuthPrompt), arrow points at it. */
.auth-prompt {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 60;
  width: max-content;
  max-width: min(320px, calc(100vw - 24px));
  padding: 12px 14px;
  background: var(--white);
  border: 1px solid var(--line-2);
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(29, 29, 31, .1), 0 1px 4px rgba(29, 29, 31, .04);
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: auth-prompt-in .15s var(--ease) both;
}
.auth-prompt::after {
  content: "";
  position: absolute;
  left: calc(var(--arrow-x, 50%) - 7px);
  top: 100%;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  background: var(--white);
  border: 1px solid var(--line-2);
  border-width: 0 1px 1px 0;
  transform: rotate(45deg);
}
.auth-prompt.below::after { top: auto; bottom: 100%; margin: 0 0 -6px; border-width: 1px 0 0 1px; }
@keyframes auth-prompt-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.auth-prompt-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.auth-prompt-text {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.4;
}
.auth-prompt-close {
  width: 24px;
  height: 24px;
  flex: none;
  border: 0;
  background: transparent;
  padding: 0;
  border-radius: 6px;
  color: var(--ink-3);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.auth-prompt-close:hover {
  background: rgba(29, 29, 31, .06);
  color: var(--ink);
}
.auth-prompt-close svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}
.gsi-prompt-btn, .gsi-header-btn {
  display: flex;
  align-items: center;
  min-height: 36px;
}
