/* LangTai product site — from the owner's design (desktop 1440 / mobile 390). */
:root {
  --ink: #0B2A4A;
  --ink-2: #2A4A6B;
  --ink-3: #34506F;
  --result: #0B3F80;
  --blue: #1F6FD1;
  --blue-deep: #1257A8;
  --sky: #38A8F5;
  --teal: #1BAE9C;
  --teal-2: #0E8F8C;
  /* One hue per language, so each side reads at a glance (the teal matches "Tai" in the logo). */
  --south: #0E8F8C;          /* fills, dots, mic */
  --south-ink: #0A5F5C;      /* text: 7:1 on white */
  --south-tint: rgba(27, 174, 156, .13);
  --south-soft: rgba(27, 174, 156, .16);
  --central: #1F6FD1;
  --central-ink: #0B3F80;
  --central-tint: rgba(31, 111, 209, .10);
  --central-soft: rgba(31, 111, 209, .13);
  --glass-edge: rgba(255, 255, 255, .55);
  --btn-bg: rgba(255, 255, 255, .45);
  --btn-edge: rgba(255, 255, 255, .75);
  --danger: #B42318;
  --card-shadow: inset 1px 1px 0 rgba(255,255,255,.9), inset -1px -1px 0 rgba(255,255,255,.35),
    inset 0 0 24px rgba(255,255,255,.28), 0 18px 48px rgba(11,42,74,.14), 0 2px 6px rgba(11,42,74,.06);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: 'IBM Plex Sans Thai', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: linear-gradient(170deg, #F4F8FF 0%, #FFFFFF 50%, #F6FAFF 100%);
  overflow-x: hidden;
}
button { font-family: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
button:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid #0B4C99; outline-offset: 3px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg { display: block; }

/* ---------- background decor ---------- */
.bg { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.glow { position: absolute; border-radius: 50%; }
.glow-a { left: -200px; top: -240px; width: 700px; height: 700px; background: radial-gradient(circle, rgba(31,111,209,.18) 0%, rgba(31,111,209,0) 68%); }
.glow-b { right: -180px; top: 60px; width: 620px; height: 620px; background: radial-gradient(circle, rgba(56,168,245,.16) 0%, rgba(56,168,245,0) 68%); }
.scenery { position: absolute; left: 10px; bottom: -40px; width: 440px; height: 528px; opacity: .1; }
.waves { position: absolute; left: 0; bottom: 0; width: 100%; height: 420px; }
.orb { position: absolute; border-radius: 50%; opacity: .35; }
.orb-a { left: 60px; top: 200px; width: 200px; height: 200px; background: radial-gradient(circle at 35% 30%, #9AD0FF 0%, #2F7FE0 55%, #1257A8 100%); }
.orb-b { right: 80px; top: 560px; width: 160px; height: 160px; background: radial-gradient(circle at 35% 30%, #D2EDFF 0%, #5CB8F7 50%, #1F7FD6 100%); }
.orb-c { left: calc(50% - 60px); top: 236px; width: 120px; height: 120px; opacity: .3; background: radial-gradient(circle at 35% 30%, #BFE2FF 0%, #38A8F5 55%, #1F6FD1 100%); }

/* ---------- shell ---------- */
.shell { position: relative; z-index: 1; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; padding: 20px 40px 0; }
.top { height: 68px; display: flex; align-items: center; justify-content: space-between; padding-left: 4px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.logo { width: 46px; height: 42px; filter: drop-shadow(0 2px 6px rgba(11,42,74,.18)); }
.wordmark { font-size: 28px; font-weight: 700; letter-spacing: -.5px; color: var(--ink); }
.accent { background: linear-gradient(90deg, var(--teal), var(--teal-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.top-actions { display: flex; gap: 8px; }

.icon-btn {
  width: 44px; height: 44px; min-width: 44px; padding: 0;
  border: 1px solid var(--btn-edge); border-radius: 22px;
  background: var(--btn-bg); box-shadow: inset 0 1px 0 rgba(255,255,255,.9);
  color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .15s, transform .1s;
}
.icon-btn:not(:disabled):hover { background: rgba(255,255,255,.75); }
.icon-btn:not(:disabled):active { transform: scale(.96); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.wide { width: auto; padding: 0 11px; font-size: 15px; font-weight: 600; }
.icon-btn[aria-pressed="true"] { color: #D08A00; }
.icon-btn[aria-pressed="true"] svg { fill: #F5B320; stroke: #D08A00; }

/* ---------- panels ---------- */
.stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px 0 24px; gap: 20px; }
.panels { position: relative; width: min(1120px, 100%); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }

.card {
  position: relative; overflow: hidden; min-height: 460px;
  padding: 24px 24px 28px 28px; border-radius: 34px;
  backdrop-filter: blur(30px) saturate(190%); -webkit-backdrop-filter: blur(30px) saturate(190%);
  border: 1px solid var(--glass-edge); box-shadow: var(--card-shadow);
  display: flex; flex-direction: column; gap: 20px;
}
.card::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(120% 60% at 15% 0%, rgba(255,255,255,.55), rgba(255,255,255,0) 60%); }
.card > * { position: relative; }
.card[data-lang="south"] { --lang: var(--south); --lang-ink: var(--south-ink); --lang-tint: var(--south-tint); --lang-soft: var(--south-soft); }
.card[data-lang="central"] { --lang: var(--central); --lang-ink: var(--central-ink); --lang-tint: var(--central-tint); --lang-soft: var(--central-soft); }
.card {
  background: linear-gradient(140deg, rgba(255,255,255,.78) 0%, rgba(255,255,255,.42) 100%), linear-gradient(var(--lang-tint), var(--lang-tint));
  border-color: color-mix(in srgb, var(--lang) 28%, white);
  transition: background .3s, border-color .3s;
}

.card-head { display: flex; justify-content: space-between; align-items: center; min-height: 44px; }
.chip {
  height: 32px; padding: 0 14px; border-radius: 999px;
  background: var(--lang-soft); border: 1px solid color-mix(in srgb, var(--lang) 30%, white);
  display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; color: var(--lang-ink);
}
.dot { width: 8px; height: 8px; border-radius: 4px; background: var(--lang); }

.card-body { flex: 1; display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.source {
  width: 100%; flex: 1; min-height: 160px; resize: none; border: 0; padding: 0; margin: 0;
  background: transparent; color: var(--lang-ink); font: inherit; font-weight: 500; line-height: 1.5;
}
.source::placeholder { color: var(--ink-3); font-weight: 400; opacity: 1; }
.source:focus { outline: none; }
.result { margin: 0; font-weight: 600; line-height: 1.5; color: var(--lang-ink); overflow-wrap: anywhere; }
.result.placeholder { color: var(--ink-3); font-weight: 400; }
.result.loading { color: var(--ink-3); font-weight: 400; }
.result.loading::after { content: ""; display: inline-block; width: 1.4em; text-align: left; animation: dots 1.2s steps(4) infinite; }
.size-l { font-size: 36px; }
.size-m { font-size: 28px; }
.size-s { font-size: 22px; }
.note { margin: 0; font-size: 15px; color: var(--ink-2); display: flex; gap: 8px; align-items: center; }
.note::before { content: ""; width: 6px; height: 6px; border-radius: 3px; background: #F5A524; flex: none; }
.alts { display: flex; flex-direction: column; gap: 8px; }
.alts-label { font-size: 13px; font-weight: 600; color: var(--ink-3); }
.alts-list { display: flex; flex-wrap: wrap; gap: 8px; }
.alt {
  border: 1px solid rgba(255,255,255,.85); background: rgba(255,255,255,.55); border-radius: 14px;
  padding: 6px 12px; font-size: 15px; color: var(--ink); display: inline-flex; gap: 6px; align-items: baseline;
}
.alt b { font-weight: 600; color: var(--lang-ink); }
.alt span { color: var(--ink-3); font-size: 13px; }

.card-foot { display: flex; align-items: center; gap: 16px; min-height: 76px; }
.card-foot.end { justify-content: flex-end; gap: 10px; }
.count { margin-left: auto; font-size: 13px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.status { font-size: 15px; color: var(--ink-2); }
.status.error { color: var(--danger); }

/* ---------- mic ---------- */
.mic {
  width: 72px; height: 72px; flex: none; border: 1px solid rgba(255,255,255,.6); border-radius: 50%;
  background: var(--mic); color: #fff; display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--mic) 30%, transparent); transition: box-shadow .2s, transform .1s, background .3s;
}
body { --mic: var(--south); --mic-ring: rgba(27,174,156,.25); }
body[data-src="central"] { --mic: var(--central); --mic-ring: rgba(56,168,245,.25); }
.mic:not(:disabled):hover { background: color-mix(in srgb, var(--mic) 88%, black); }
.mic:not(:disabled):active { transform: scale(.96); }
.mic svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.mic .stop-icon { width: 24px; height: 24px; fill: currentColor; display: none; }
.mic.big { width: 84px; height: 84px; }
.mic.big .mic-icon { width: 34px; height: 34px; }
body.listening .mic { box-shadow: 0 0 0 10px var(--mic-ring); animation: ring 1.6s ease-out infinite; }
body.listening .mic .mic-icon { display: none; }
body.listening .mic .stop-icon { display: block; }
.mic { position: relative; }
body.busy .mic::after { content: ""; position: absolute; inset: -7px; border-radius: 50%; border: 3px solid transparent; border-top-color: var(--mic); border-right-color: color-mix(in srgb, var(--mic) 40%, transparent); animation: spin .8s linear infinite; }

.meter { display: none; align-items: center; gap: 5px; height: 36px; }
body.listening .meter { display: flex; }
.meter i { width: 5px; height: 12px; border-radius: 3px; background: var(--mic); transition: height .08s linear; }
.meter i:nth-child(even) { background: color-mix(in srgb, var(--mic) 70%, white); }

/* ---------- swap ---------- */
.swap {
  position: absolute; left: 50%; top: 50%; width: 64px; height: 64px; margin: -32px 0 0 -32px; z-index: 2;
  border-radius: 50%; border: 1px solid #fff; background: rgba(255,255,255,.92); color: var(--blue);
  backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: 0 0 0 6px rgba(255,255,255,.45), 0 10px 28px rgba(11,42,74,.18);
  display: flex; align-items: center; justify-content: center; transition: transform .3s;
}
.swap svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  transform: rotate(calc(var(--base-turn, 0deg) + var(--turn, 0deg))); transition: transform .45s cubic-bezier(.3,1.4,.5,1); }
.swap { transition: transform .15s; }
.swap:hover { transform: scale(1.06); }
.swap:active { transform: scale(.94); }

/* ---------- mobile dock (mic lives here on phones) ---------- */
.dock { display: none; }

.fine { position: relative; text-align: center; font-size: 12px; color: var(--ink-3); padding: 0 16px 18px; }

/* ---------- sheet (history / saved) ---------- */
.backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(11,42,74,.18); backdrop-filter: blur(2px); }
.sheet {
  position: fixed; z-index: 21; top: 16px; right: 16px; bottom: 16px; width: min(420px, calc(100vw - 32px));
  border-radius: 28px; background: rgba(255,255,255,.92); border: 1px solid #fff; box-shadow: 0 24px 64px rgba(11,42,74,.22);
  backdrop-filter: blur(30px) saturate(190%); -webkit-backdrop-filter: blur(30px) saturate(190%);
  display: flex; flex-direction: column; overflow: hidden; animation: slide .22s ease-out;
}
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 16px 16px 12px 24px; }
.sheet-head h2 { margin: 0 auto 0 0; font-size: 20px; font-weight: 700; }
.text-btn { border: 0; background: none; color: var(--blue-deep); font-size: 14px; font-weight: 600; padding: 8px 10px; border-radius: 10px; }
.text-btn:hover { background: rgba(31,111,209,.08); }
.sheet-list { list-style: none; margin: 0; padding: 0 12px 16px; overflow-y: auto; flex: 1; }
.sheet-item { display: flex; align-items: center; gap: 4px; border-radius: 18px; }
.sheet-item:hover { background: rgba(31,111,209,.06); }
.sheet-open { flex: 1; min-width: 0; text-align: left; border: 0; background: none; padding: 12px; border-radius: 18px; color: var(--ink); display: flex; flex-direction: column; gap: 2px; }
.sheet-open .from { font-size: 13px; color: var(--ink-3); }
.sheet-open .src { font-size: 16px; font-weight: 500; overflow-wrap: anywhere; }
.sheet-open .src, .sheet-open .dst { padding-left: 10px; border-left: 3px solid var(--lang); }
.sheet-open [data-lang="south"] { --lang: var(--south); color: var(--south-ink); }
.sheet-open [data-lang="central"] { --lang: var(--central); color: var(--central-ink); }
.sheet-open .dst { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.sheet-item .icon-btn { border-color: transparent; background: transparent; box-shadow: none; }
.sheet-empty { margin: 0; padding: 32px 24px; text-align: center; color: var(--ink-3); }

.toast {
  position: fixed; z-index: 30; left: 50%; bottom: 28px; transform: translateX(-50%); max-width: calc(100vw - 32px);
  padding: 12px 18px; border-radius: 16px; background: #0B2A4A; color: #fff; font-size: 15px;
  box-shadow: 0 12px 32px rgba(11,42,74,.3); animation: rise .2s ease-out;
}


/* ---------- motion (transform/opacity only; off under prefers-reduced-motion) ---------- */
.top { animation: enterDown .55s cubic-bezier(.2,.8,.2,1) backwards; }
.card-src { animation: enterUp .6s .06s cubic-bezier(.2,.8,.2,1) backwards; }
.card-dst { animation: enterUp .6s .14s cubic-bezier(.2,.8,.2,1) backwards; }
.swap { animation: pop .5s .3s cubic-bezier(.3,1.5,.5,1) backwards; }
.dock-pill, .card-src .card-foot .mic { animation: pop .55s .28s cubic-bezier(.3,1.5,.5,1) backwards; }
.fine { animation: fade .8s .45s backwards; }
.result.reveal { animation: reveal .42s cubic-bezier(.2,.8,.2,1) backwards; }
.alt { animation: pop .35s cubic-bezier(.3,1.5,.5,1) backwards; }
.note { animation: fade .3s backwards; }
.panels.swapping .source, .panels.swapping .result, .panels.swapping .chip { animation: swapFade .32s ease backwards; }
.icon-btn.bump { animation: bump .38s cubic-bezier(.3,1.6,.5,1); }
.sheet-item { animation: enterUp .32s cubic-bezier(.2,.8,.2,1) backwards; }
@media (min-width: 861px) {
  .orb-a { animation: float 16s ease-in-out infinite; }
  .orb-b { animation: float 19s -6s ease-in-out infinite reverse; }
  .orb-c { animation: float 13s -3s ease-in-out infinite; }
}
@keyframes enterUp { from { opacity: 0; transform: translateY(18px) scale(.985); } }
@keyframes enterDown { from { opacity: 0; transform: translateY(-10px); } }
@keyframes pop { from { opacity: 0; transform: scale(.6); } }
@keyframes fade { from { opacity: 0; } }
@keyframes reveal { from { opacity: 0; transform: translateY(8px); } }
@keyframes swapFade { from { opacity: 0; transform: translateY(6px); } }
@keyframes bump { 40% { transform: scale(1.22); } 70% { transform: scale(.94); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
@keyframes float { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(18px, -22px); } }

@keyframes ring { 0% { box-shadow: 0 0 0 0 var(--mic-ring); } 100% { box-shadow: 0 0 0 18px transparent; } }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
@keyframes rise { from { transform: translate(-50%, 12px); opacity: 0; } }

/* ---------- tablet / phone ---------- */
@media (max-width: 860px) {
  .shell { padding: 14px 14px 0; }
  .top { height: 56px; padding-left: 6px; }
  .brand { gap: 8px; }
  .logo { width: 40px; height: 37px; }
  .wordmark { font-size: 22px; letter-spacing: -.4px; }
  .stage { justify-content: flex-start; padding: 14px 0 0; gap: 0; }
  .panels { grid-template-columns: 1fr; gap: 12px; }
  .card { min-height: 220px; padding: 16px 16px 16px 20px; border-radius: 28px; gap: 10px; }
  .chip { height: 28px; padding: 0 12px; font-size: 13px; gap: 6px; }
  .dot { width: 7px; height: 7px; }
  .source { min-height: 110px; }
  .size-l { font-size: 28px; }
  .size-m { font-size: 24px; }
  .size-s { font-size: 20px; }
  .card-src .card-foot { min-height: 0; }
  .card-src .card-foot .mic, .card-src .card-foot .meter, .card-src .card-foot .status { display: none; }
  .card-dst .card-foot { min-height: 44px; gap: 8px; }
  .icon-btn.wide { font-size: 14px; }
  /* Own zero-height grid row between the cards, so it stays on the seam whatever their heights. */
  .panels { row-gap: 6px; }
  .card-src { grid-row: 1; }
  .card-dst { grid-row: 3; }
  .swap { position: relative; grid-row: 2; left: auto; top: auto; justify-self: center; width: 56px; height: 56px; margin: -28px 0; }
  .swap svg { width: 24px; height: 24px; --base-turn: 90deg; }
  /* Mic sits just under the cards (not centred in the leftover height, which put it low on tall phones). */
  .dock { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 8px; padding: 14px 0 8px; min-height: 170px; }
  .dock .meter { order: 2; display: flex; visibility: hidden; opacity: 0; transition: opacity .2s; }  /* under the mic */
  .dock .status { order: 3; }
  body.listening .dock .meter { visibility: visible; opacity: 1; }
  .dock-pill {
    padding: 10px; border-radius: 999px; border: 1px solid rgba(255,255,255,.6);
    background: linear-gradient(135deg, rgba(255,255,255,.85), rgba(255,255,255,.5));
    backdrop-filter: blur(24px) saturate(190%); -webkit-backdrop-filter: blur(24px) saturate(190%);
    box-shadow: inset 1px 1px 0 rgba(255,255,255,.9), inset -1px -1px 0 rgba(255,255,255,.3), 0 10px 30px rgba(11,42,74,.12);
  }
  .dock .status { min-height: 22px; text-align: center; padding: 0 16px; }
  .scenery { left: -40px; bottom: -30px; width: 300px; height: 360px; }
  .waves { height: 360px; }
  .orb-a { left: -50px; top: 110px; width: 130px; height: 130px; }
  .orb-b { right: -40px; top: 410px; width: 110px; height: 110px; }
  .orb-c { left: 60%; top: 330px; width: 80px; height: 80px; }
  .sheet { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 78vh; animation-name: sheetUp; }
}
@keyframes sheetUp { from { transform: translateY(24px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
