/* TM Llamadas. Deep navy with frosted glass, in the portal's brand:
   Manrope for titles, DM Sans for text (self-hosted: Google Fonts does not
   load in mainland China), TM blue as the only action colour. */
@font-face { font-family: "Manrope"; font-style: normal; font-weight: 200 800; font-display: swap; src: url("/assets/fonts/manrope.woff2") format("woff2"); }
@font-face { font-family: "DM Sans"; font-style: normal; font-weight: 100 1000; font-display: swap; src: url("/assets/fonts/dm-sans.woff2") format("woff2"); }

:root {
  --blue: #0a72b9;
  --blue-hi: #1a8ad6;
  --sky: #7cc4f5;
  --ink: #17364b;
  --muted: #4a6578;
  --accent: #f5e425;
  --on-dark: #f2f7fb;
  --on-dark-2: #a9c0d2;
  --line: #ffffff24;
  --glass-dark: #ffffff0f;
  --title: "Manrope", "DM Sans", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  --icon-phone: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M22 16.9v3a2 2 0 0 1-2.2 2 19.8 19.8 0 0 1-8.6-3.1 19.5 19.5 0 0 1-6-6A19.8 19.8 0 0 1 2.1 4.2 2 2 0 0 1 4.1 2h3a2 2 0 0 1 2 1.7c.1 1 .4 1.9.7 2.8a2 2 0 0 1-.5 2.1L8.1 9.9a16 16 0 0 0 6 6l1.3-1.3a2 2 0 0 1 2.1-.4c.9.3 1.8.6 2.8.7a2 2 0 0 1 1.7 2Z'/%3E%3C/svg%3E");
  font-family: "DM Sans", "Segoe UI", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  min-height: 100dvh;
  background:
    radial-gradient(900px 620px at 12% -8%, #1f76b866 0%, transparent 62%),
    radial-gradient(820px 720px at 104% 108%, #0a72b94d 0%, transparent 60%),
    linear-gradient(160deg, #0c2c44 0%, #081c2c 55%, #05121d 100%);
  background-attachment: fixed;
}
/* A whisper of grain, so the gradients do not band */
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .05; z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
body > section { position: relative; z-index: 1; }
:focus-visible { outline: 2px solid var(--sky); outline-offset: 3px; }
[hidden] { display: none !important; }
h1, h2 { font-family: var(--title); text-wrap: balance; }

/* ---------- Pages with a card ---------- */
.page { width: min(520px, 100%); margin: 0 auto; padding: 40px 16px 44px; display: grid; gap: 20px; align-content: center; min-height: 100dvh; }
.card {
  background: linear-gradient(165deg, #fffffff2 0%, #f4f9fde6 100%);
  -webkit-backdrop-filter: blur(22px) saturate(1.5);
  backdrop-filter: blur(22px) saturate(1.5);
  border: 1px solid #ffffffd9;
  border-radius: 28px;
  box-shadow: 0 44px 100px -24px #010a12cc, 0 12px 28px -14px #010a1280, inset 0 1px 0 #fff;
  padding: 34px 30px 30px;
  display: grid;
  gap: 16px;
}
.hero-card { text-align: center; justify-items: center; }
.hero-card > * { width: 100%; }
.hero-card .plaque, .hero-card .availability { width: auto; }
.card h1 { margin: 4px 0 0; font-size: 29px; font-weight: 800; letter-spacing: -.025em; line-height: 1.16; color: #10293b; }
.card h2 { margin: 0; font-size: 18px; font-weight: 750; letter-spacing: -.01em; color: #10293b; }
.lead { margin: 0; font-size: 16px; line-height: 1.55; color: var(--muted); }
.hint { margin: 0; font-size: 13.5px; line-height: 1.5; color: #5d7689; }
.error { margin: 0; font-size: 14px; font-weight: 500; color: #a32b2a; }
.error:empty { display: none; }
.foot { margin: 0; text-align: center; font-size: 13px; color: #7f9bb0; letter-spacing: .01em; }

/* TM logo on its own plate */
.plaque {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 20px; border-radius: 20px;
  background: linear-gradient(160deg, #ffffff 0%, #eef5fb 100%);
  border: 1px solid #ffffff;
  box-shadow: 0 16px 34px -14px #0a2c4566, 0 0 0 1px #0a72b914, inset 0 1px 0 #fff;
}
.plaque img { display: block; width: 112px; height: auto; }
.plaque.small { padding: 6px 10px; border-radius: 13px; box-shadow: 0 8px 18px -8px #010a1299; }
.plaque.small img { width: 52px; }

/* Language switch: one control, two options */
.langbar { display: grid; gap: 10px; justify-items: center; color: var(--on-dark); }
.langbar-label { font-size: 14px; font-weight: 500; color: var(--on-dark-2); }
.flags { display: inline-flex; gap: 4px; padding: 4px; border-radius: 999px; background: #ffffff12; border: 1px solid var(--line); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.flag {
  display: inline-flex; align-items: center; gap: 8px; font: inherit; font-size: 15.5px; font-weight: 600;
  padding: 9px 18px; border-radius: 999px; cursor: pointer; color: #d7e6f2; background: none; border: 0;
  transition: background .18s, color .18s;
}
.flag:hover { color: #fff; }
.flag[aria-pressed=true] { background: #fff; color: var(--ink); box-shadow: 0 8px 20px -8px #010a12b3; }
.flag-emoji { font-size: 20px; line-height: 1; }

/* Forms */
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 7px; font-size: 14px; font-weight: 600; text-align: left; color: #2c4a5f; }
input[type=text], input[type=password] {
  font: inherit; font-size: 17px; font-weight: 400; color: var(--ink);
  border: 1px solid #17364b24; border-radius: 14px; padding: 14px 16px; background: #fff; width: 100%;
  box-shadow: inset 0 1px 2px #0a2c450f;
  transition: border-color .15s, box-shadow .15s;
}
input[type=text]:focus, input[type=password]:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px #0a72b926; }

/* Availability, as a pill */
.availability { margin: 0; font-size: 14.5px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 9px; padding: 7px 14px 7px 12px; border-radius: 999px; background: #eaf0f4; color: #4a6578; }
.availability::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: #9fb3c2; flex: none; }
.availability[data-kind=ok] { background: #e2f5ea; color: #17633a; }
.availability[data-kind=ok]::before { background: #23b566; box-shadow: 0 0 0 4px #23b56633; }
.availability[data-kind=error] { background: #fbe9e8; color: #a32b2a; }
.availability[data-kind=error]::before { background: #e05553; }

/* Buttons */
button { font: inherit; cursor: pointer; border: 0; border-radius: 14px; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
.primary {
  background: linear-gradient(180deg, var(--blue-hi) 0%, #0a68ab 100%); color: #fff;
  font-family: var(--title); font-weight: 700; font-size: 16px; padding: 14px 20px;
  box-shadow: 0 16px 30px -12px #0a72b9cc, inset 0 1px 0 #ffffff40;
  transition: transform .12s, filter .15s, box-shadow .15s;
}
.primary:hover:not(:disabled) { filter: brightness(1.06); }
.primary:active:not(:disabled) { transform: scale(.985); }
.primary:disabled { background: #b4c5d2; box-shadow: none; color: #f4f8fb; }
.big { padding: 18px 22px; font-size: 18px; border-radius: 18px; }
.call-btn { width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 10px; }
.call-btn::before {
  content: ""; width: 20px; height: 20px; background: currentColor; flex: none;
  -webkit-mask: var(--icon-phone) center / contain no-repeat; mask: var(--icon-phone) center / contain no-repeat;
}
.secondary { background: #fff; color: var(--ink); border: 1px solid #17364b24; padding: 13px 18px; font-weight: 600; font-size: 15px; box-shadow: 0 1px 2px #0a2c4514; transition: background .15s; }
.secondary:hover { background: #f4f8fb; }
.ghost { background: #ffffff14; color: #fff; border: 1px solid var(--line); padding: 13px 28px; font-weight: 600; font-size: 15px; border-radius: 999px; -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.ghost:hover { background: #ffffff24; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1 1 150px; }
.link-box { margin: 0; padding: 13px 15px; border-radius: 14px; background: #eaf3fa; border: 1px solid #cfe2f1; font-size: 15px; font-weight: 600; color: var(--blue); word-break: break-all; }

/* ---------- Calling / incoming call: like a phone ---------- */
.rings { position: relative; display: inline-grid; place-items: center; padding: 26px; }
.rings::before, .rings::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid #ffffff8c; animation: ripple 2.2s cubic-bezier(.2, .6, .3, 1) infinite; }
.rings::after { animation-delay: 1.1s; }
@keyframes ripple { from { transform: scale(.72); opacity: .85; } to { transform: scale(1.3); opacity: 0; } }
.calling { display: grid; justify-items: center; gap: 22px; text-align: center; color: var(--on-dark); }
.calling h1 { margin: 0; font-size: 27px; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; }
.calling .rings { width: 264px; height: 264px; padding: 0; }

.ring { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 20px; background: #030d16d9; -webkit-backdrop-filter: blur(18px) saturate(1.3); backdrop-filter: blur(18px) saturate(1.3); animation: fade .25s ease both; }
.ring-card { width: min(440px, 100%); display: grid; justify-items: center; gap: 14px; text-align: center; color: var(--on-dark); }
.ring-card h1 { margin: 10px 0 0; font-size: 30px; font-weight: 800; letter-spacing: -.025em; line-height: 1.15; }
.chip { margin: 0; display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 999px; background: #ffffff14; border: 1px solid var(--line); font-size: 15px; font-weight: 500; color: #d7e6f2; }
.ring-actions { display: grid; grid-template-columns: 1fr 1.25fr; gap: 12px; width: 100%; margin-top: 22px; }
.pill { display: inline-flex; align-items: center; justify-content: center; gap: 10px; padding: 19px 20px; border-radius: 999px; color: #fff; font-family: var(--title); font-size: 18px; font-weight: 700; transition: transform .12s, filter .15s; }
.pill svg { width: 22px; height: 22px; flex: none; }
.pill:hover { filter: brightness(1.07); }
.pill:active { transform: scale(.98); }
.pill.decline { background: linear-gradient(180deg, #e2534e, #c63a36); box-shadow: 0 16px 32px -14px #d9443fcc, inset 0 1px 0 #ffffff33; }
.pill.accept { background: linear-gradient(180deg, #27b469, #188a4c); box-shadow: 0 16px 32px -14px #1f9d5acc, inset 0 1px 0 #ffffff33; position: relative; }
.pill.accept::after { content: ""; position: absolute; inset: -5px; border-radius: 999px; border: 2px solid #3fd885; animation: beckon 1.6s ease-out infinite; }
@keyframes beckon { from { opacity: .9; transform: scale(.98); } to { opacity: 0; transform: scale(1.06, 1.22); } }
@keyframes fade { from { opacity: 0; } }

/* Round portrait with the first letter of the name */
.avatar { width: 132px; height: 132px; border-radius: 50%; display: grid; place-items: center; font-family: var(--title); font-size: 54px; font-weight: 800; color: #fff; background: linear-gradient(150deg, #2192de 0%, #0a4f82 100%); border: 3px solid #ffffff33; box-shadow: 0 24px 50px -16px #010a12cc, inset 0 2px 0 #ffffff40; }

/* ---------- Call ---------- */
body.in-call { overflow: hidden; }
.call { height: 100dvh; display: flex; flex-direction: column; width: min(1320px, 100%); margin: 0 auto; padding: 14px 16px max(14px, env(safe-area-inset-bottom)); gap: 12px; }
.glass-bar { background: var(--glass-dark); border: 1px solid var(--line); border-radius: 20px; -webkit-backdrop-filter: blur(18px) saturate(1.3); backdrop-filter: blur(18px) saturate(1.3); box-shadow: inset 0 1px 0 #ffffff14; }
.call-head { display: flex; align-items: center; gap: 12px; padding: 9px 14px 9px 10px; color: #fff; }
.call-head-text { min-width: 0; flex: 1; }
.call-head h1 { margin: 0; font-size: 17px; font-weight: 750; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status { margin: 2px 0 0; font-size: 13.5px; color: var(--on-dark-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status::before { content: ""; display: inline-block; vertical-align: middle; margin: -2px 8px 0 3px; width: 8px; height: 8px; border-radius: 50%; background: #9fb8cc; }
.status[data-kind=ok]::before { background: #3fd885; box-shadow: 0 0 0 3px #3fd88533; }
.status[data-kind=live]::before { background: var(--accent); animation: blink 1s ease-in-out infinite; }
.status[data-kind=error] { color: #ffc9c8; }
.status[data-kind=error]::before { background: #ff7b79; }
@keyframes blink { 50% { transform: scale(1.5); opacity: .6; } }
.timer { flex: none; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; color: #d7e6f2; padding: 6px 12px; border-radius: 999px; background: #ffffff12; border: 1px solid var(--line); }

.call-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 372px); gap: 12px; }
.stage { position: relative; min-height: 0; border-radius: 26px; overflow: hidden; background: radial-gradient(700px 480px at 50% 38%, #18507c 0%, #0b2a41 60%, #071c2c 100%); border: 1px solid #ffffff26; box-shadow: 0 34px 80px -30px #010a12e6, inset 0 1px 0 #ffffff1f; transition: box-shadow .25s; }
.stage.speaking { box-shadow: 0 0 0 2px #56c6ff, 0 0 44px -6px #56c6ff80, 0 34px 80px -30px #010a12e6; }
.stage::after { content: ""; position: absolute; inset: auto 0 0 0; height: 42%; background: linear-gradient(to top, #020c15b3, transparent); pointer-events: none; opacity: 0; transition: opacity .3s; }
.stage.has-video::after { opacity: 1; }
.stage video.remote { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .35s; }
.stage.has-video video.remote { opacity: 1; }
.no-video { position: absolute; inset: 0; display: grid; place-items: center; }
.stage.has-video .no-video { display: none; }
.name-chip { position: absolute; left: 14px; top: 14px; z-index: 2; max-width: 60%; padding: 6px 12px; border-radius: 999px; background: #020c1599; border: 1px solid #ffffff26; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); color: #fff; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.name-chip:empty { display: none; }
.stage video.self { position: absolute; right: 14px; top: 14px; z-index: 2; width: 22%; max-width: 230px; min-width: 96px; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 16px; border: 1.5px solid #ffffffb3; box-shadow: 0 16px 34px -10px #010a12e6; background: #0a2639; transform: scaleX(-1); }
.caption { position: absolute; left: 50%; bottom: 18px; z-index: 2; transform: translateX(-50%); width: max-content; max-width: min(92%, 780px); margin: 0; padding: 12px 20px; border-radius: 18px; text-align: center; font-size: 22px; font-weight: 600; line-height: 1.35; color: #fff; background: #030d16c7; border: 1px solid #ffffff1f; -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); box-shadow: 0 16px 34px -14px #010a12e6; text-wrap: balance; }

/* Conversation, in dark glass */
.convo { min-height: 0; display: flex; flex-direction: column; padding: 4px 10px 10px; border-radius: 26px; background: var(--glass-dark); border: 1px solid var(--line); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); box-shadow: inset 0 1px 0 #ffffff14; }
.lines { list-style: none; margin: 0; padding: 18px 2px 4px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; scrollbar-width: thin; scrollbar-color: #ffffff33 transparent; -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 26px); mask-image: linear-gradient(to bottom, transparent 0, #000 26px); }
.empty { margin: auto; color: var(--on-dark-2); text-align: center; font-size: 15.5px; line-height: 1.55; padding: 0 18px; max-width: 520px; }
.line { max-width: 92%; padding: 10px 14px 11px; border-radius: 18px; background: #ffffff17; border: 1px solid #ffffff1f; color: var(--on-dark); animation: rise .22s ease both; }
.line.theirs { align-self: flex-start; border-top-left-radius: 6px; }
.line.mine { align-self: flex-end; border-top-right-radius: 6px; background: linear-gradient(160deg, #0f7ac4d9, #0a5c97d9); border-color: #56b1ec59; }
.who { font-size: 12px; font-weight: 700; color: var(--on-dark-2); margin-bottom: 3px; }
.line.mine .who { color: #cfe6f7; }
.translation { font-size: 18px; font-weight: 600; line-height: 1.38; color: #fff; }
.translation.sub { font-size: 14px; font-weight: 500; color: #d3e7f6; margin-top: 4px; }
.piece.pending::after { content: " …"; opacity: .7; }
.piece.problem { color: #ffb3b1; font-size: 14px; }
.original { font-size: 13.5px; color: var(--on-dark-2); line-height: 1.45; margin-top: 4px; }
.original.main { font-size: 17px; font-weight: 600; color: #fff; margin-top: 0; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* Controls: a glass dock of round buttons, each with its name */
.call-foot { display: grid; gap: 6px; justify-items: center; }
.live-mine { margin: 0; width: 100%; min-height: 20px; color: var(--on-dark-2); font-size: 14px; font-style: italic; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.controls { display: inline-flex; justify-content: center; gap: 10px; padding: 12px 16px 10px; border-radius: 30px; background: var(--glass-dark); border: 1px solid var(--line); -webkit-backdrop-filter: blur(20px) saturate(1.3); backdrop-filter: blur(20px) saturate(1.3); box-shadow: 0 24px 50px -22px #010a12e6, inset 0 1px 0 #ffffff1a; }
.ctl { background: none; padding: 0; display: grid; justify-items: center; gap: 6px; color: #dbe9f4; font-size: 12.5px; font-weight: 600; width: 86px; border-radius: 16px; }
.ctl-icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: #ffffff1c; border: 1px solid #ffffff33; transition: background .15s, transform .1s; }
.ctl-icon svg { width: 24px; height: 24px; }
.ctl .i-off, #muteBtn[aria-pressed=true] .i-on, #camBtn[aria-pressed=true] .i-on { display: none; }
.ctl[aria-pressed=true] .i-off { display: block; }
.ctl:hover .ctl-icon { background: #ffffff30; }
.ctl:active .ctl-icon { transform: scale(.93); }
.ctl-label { line-height: 1.25; text-align: center; }
#muteBtn[aria-pressed=true] .ctl-icon, #camBtn[aria-pressed=true] .ctl-icon { background: #fff; color: #b3322f; border-color: #fff; }
#headBtn[aria-pressed=true] .ctl-icon { background: linear-gradient(180deg, var(--blue-hi), #0a68ab); border-color: #56b1ec; }
.ctl-end .ctl-icon { background: linear-gradient(180deg, #e2534e, #c63a36); border-color: #ee746f; box-shadow: 0 12px 26px -10px #d9443fcc; }
.ctl-end:hover .ctl-icon { background: linear-gradient(180deg, #d84a45, #b8332f); }

@media (max-width: 760px) {
  .page { padding: 26px 14px 30px; gap: 16px; }
  .card { padding: 28px 22px 24px; border-radius: 26px; }
  .card h1 { font-size: 26px; }
  .call { padding: 8px 8px max(8px, env(safe-area-inset-bottom)); gap: 8px; }
  .call-head { padding: 7px 10px 7px 8px; gap: 10px; border-radius: 18px; }
  .call-head h1 { font-size: 15.5px; }
  .status { font-size: 13px; }
  .plaque.small img { width: 42px; }
  .timer { font-size: 13px; padding: 5px 10px; }
  .call-body { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1.3fr) minmax(0, 1fr); gap: 8px; }
  .stage, .convo { border-radius: 22px; }
  .stage video.self { width: 28%; right: 10px; top: 10px; border-radius: 14px; }
  .name-chip { left: 10px; top: 10px; }
  .caption { font-size: 18px; bottom: 10px; padding: 10px 16px; }
  .avatar { width: 96px; height: 96px; font-size: 40px; }
  .convo { padding: 2px 8px 8px; }
  .translation { font-size: 17px; }
  .controls { gap: 2px; padding: 10px 8px 8px; border-radius: 26px; }
  .ctl { width: 78px; font-size: 12px; }
  .ctl-icon { width: 52px; height: 52px; }
  .ring-card h1 { font-size: 26px; }
  .ring-actions { grid-template-columns: 1fr; }
  .ring-actions .accept { order: -1; }
}
@media (prefers-reduced-motion: reduce) {
  .line, .ring, .rings::before, .rings::after, .pill.accept::after, .status[data-kind=live]::before { animation: none; }
  .rings::before { opacity: .5; }
}
