/* Two themes: the landing and text pages are light and plain; the call screen is dark (video). */
:root {
  --font: "IBM Plex Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* call screen (dark) */
  --bg: #0c0c0d;
  --panel: #1a1a1c;
  --line: #2c2c2f;
  --text: #f2f2f2;
  --muted: #a1a1a6;
  --danger: #e5484d;

  /* landing (light) */
  --paper: #f6f5f2;
  --ink: #141414;
  --ink-2: #5f5f5c;
  --rule: #dcdad4;
  --field: #ffffff;
}

* { box-sizing: border-box; }
/* No pinch or double-tap zoom (scrolling still works). */
html, body { touch-action: pan-x pan-y; }
button, a, input, textarea, label { touch-action: manipulation; }
/* iPhones zoom into text boxes with text under 16px; keep them at 16px or more. */
input, textarea, select { font-size: max(16px, 1em) !important; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
body:has(#landing:not([hidden])), body:has(.doc) { background: var(--paper); color: var(--ink); }
[hidden] { display: none !important; }

button {
  font: inherit; border: 0; border-radius: 10px; padding: 10px 16px; cursor: pointer;
  color: var(--text); background: var(--panel);
}
button:disabled { opacity: .35; cursor: not-allowed; }
.ghost { background: transparent; border: 1px solid var(--line); }
.small { padding: 6px 12px; font-size: 14px; }

/* ---------- landing ---------- */
.landing { max-width: 460px; margin: 0 auto; padding: 20px 20px 28px; min-height: 100%; display: flex; flex-direction: column; }
.top { display: flex; justify-content: space-between; align-items: center; }
.logo { font-weight: 700; font-size: 20px; letter-spacing: -.3px; }
.lang-switch { display: flex; gap: 4px; }
.lang-switch button { background: none; color: var(--ink-2); padding: 4px 6px; font-size: 14px; border-radius: 6px; }
.lang-switch button.active { color: var(--ink); font-weight: 600; text-decoration: underline; text-underline-offset: 4px; }

.landing-body { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 48px 0 32px; }
.hero h1 { font-size: 34px; line-height: 1.3; font-weight: 700; margin: 0 0 14px; white-space: pre-line; letter-spacing: -.3px; }
.sub { color: var(--ink-2); font-size: 16px; line-height: 1.6; margin: 0 0 12px; }
.online { color: var(--ink-2); font-size: 14px; margin: 0; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #1f9d55; margin-right: 8px; vertical-align: 1px; }

.card { margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--rule); }
.login-title { margin: 0 0 16px; font-size: 16px; font-weight: 600; }
.note { color: var(--ink-2); font-size: 13px; line-height: 1.55; margin: 14px 0 0; }
.error { color: var(--danger); font-size: 14px; margin: 12px 0 0; white-space: pre-line; }

.login-buttons { display: flex; flex-direction: column; gap: 10px; }
.sso {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  background: var(--field); color: var(--ink); border: 1px solid var(--rule); font-weight: 500; padding: 13px;
}
.sso:hover { border-color: #b9b6ad; }
.sso svg { width: 18px; height: 18px; flex: none; }
.dev-login { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.dev-code { margin: 0; font-size: 13px; color: var(--ink-2); }
.dev-login input {
  font: inherit; color: var(--ink); background: var(--field); border: 1px solid var(--rule); border-radius: 10px; padding: 12px;
}
.dev-login .ghost { border-color: var(--rule); color: var(--ink); }

.account-links { display: flex; gap: 14px; }
.account { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 14px; color: var(--ink-2); }
#whoami { color: var(--ink); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linkish { background: none; border: 0; padding: 0; color: var(--ink-2); text-decoration: underline; font-size: 13px; flex: none; border-radius: 0; }
.dob { margin: 20px 0 0; display: flex; flex-direction: column; gap: 6px; }
.dob label { font-weight: 600; color: var(--ink); }
.dob input {
  font: inherit; font-size: 16px; color: var(--ink); background: var(--field); border: 1px solid var(--rule);
  border-radius: 10px; padding: 11px 12px; max-width: 240px;
}
.dob-note { margin: 0; font-size: 13px; color: var(--ink-2); }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 20px 0 0; color: var(--ink-2); font-size: 14px; line-height: 1.5; }
.check input { width: 17px; height: 17px; margin-top: 2px; accent-color: var(--ink); flex: none; cursor: pointer; }
.check a { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }
.start { width: 100%; margin-top: 20px; padding: 15px; font-size: 17px; font-weight: 600; background: var(--ink); color: #fff; }
.start:not(:disabled):hover { background: #2c2c2c; }

.foot { color: var(--ink-2); font-size: 13px; }

/* Your camera inside the card (phones only; tablets/desktop show it on the right). */
.self-card { margin-top: 16px; border-radius: 12px; overflow: hidden; background: #1e1e20; aspect-ratio: 4 / 3; }
.self-video { transform: scaleX(-1); display: block; }
.self-card .self-video { width: 100%; height: 100%; object-fit: contain; }
.foot a { color: inherit; }

/* Thai letters look smaller than Latin at the same size, so Thai body text is set a bit larger. */
html[lang="th"] .sub { font-size: 18px; }
html[lang="th"] .online { font-size: 15.5px; }
html[lang="th"] .check { font-size: 15.5px; }
html[lang="th"] .note { font-size: 14.5px; }
html[lang="th"] .login-title { font-size: 18px; }
html[lang="th"] .account, html[lang="th"] .linkish { font-size: 15px; }
html[lang="th"] .start { font-size: 19px; }
html[lang="th"] .sso { font-size: 16.5px; }

/* Latin letters look bigger than Thai at the same size, so the English title is set smaller. */
html[lang="en"] .hero h1 { font-size: 29px; letter-spacing: -.5px; }

.preview { display: none; }

/* Tablet and desktop: wider page, text + login on the left, a call preview on the right. */
@media (min-width: 820px) {
  .landing { max-width: 1120px; padding: 28px 40px 32px; }
  .top { padding-bottom: 20px; border-bottom: 1px solid var(--rule); }
  .landing-body {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 64px; align-items: center;
    padding: 56px 0;
  }
  .intro { max-width: 460px; }
  .hero h1 { font-size: clamp(32px, 4.1vw, 52px); }
  html[lang="en"] .hero h1 { font-size: clamp(28px, 3.2vw, 42px); }
  .sub { font-size: 17px; }
  html[lang="th"] .sub { font-size: 19px; }
  .foot { padding-top: 20px; border-top: 1px solid var(--rule); }

  .preview { display: block; }
  .pv-screen {
    position: relative; aspect-ratio: 4 / 3; max-height: 72vh; margin-left: auto; border-radius: 14px; overflow: hidden;
    background: #1e1e20; color: #f2f2f2; font-size: 13px;
  }
  .pv-screen > .pv-person { position: absolute; left: 10%; right: 10%; bottom: 0; width: 80%; fill: #3a3a3e; }
  .pv-screen .self-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #1e1e20; }
  .self-card { display: none; }
}
@media (min-width: 1100px) {
  .landing-body { gap: 96px; }
}

/* ---------- text pages (terms, privacy) ---------- */
.doc { max-width: 680px; margin: 0 auto; padding: 24px 20px 48px; line-height: 1.7; }
.doc a { color: var(--ink); }
.doc h2 { margin-top: 28px; font-size: 18px; }

/* ---------- call screen: same layout as OmeTV ----------
   Computer / sideways: two videos edge to edge (stranger left, you right) filling the top 75%;
   the bottom 25% has the big buttons on the left and the chat on the right.
   Phone held upright: stranger on the top half, you on the bottom half; buttons and chat float
   over your half. Each video box has the exact shape of the picture it shows (--cam = yours,
   --rcam = the stranger's, width / height), so nothing is trimmed: both people see exactly the
   same two pictures, in every orientation. Leftover space is plain dark. */
.chat { position: fixed; inset: 0; background: #000; overflow: hidden; display: grid; grid-template-rows: 75% 25%; }
.stage { --cam: 4 / 3; position: relative; display: grid; grid-template-columns: 1fr 1fr; place-items: center; min-height: 0; container-type: size; }
.remote-wrap, .local {
  position: relative; min-height: 0; overflow: hidden; background: #151517;
  --r: var(--cam); width: min(50cqw, 100cqh * (var(--r))); height: min(100cqh, 50cqw / (var(--r)));
}
.remote-wrap { --r: var(--rcam, var(--cam)); }
#remote { width: 100%; height: 100%; object-fit: cover; display: block; transition: filter .2s; }
#remote.blurred { filter: blur(40px) brightness(.7); }
.local { object-fit: cover; transform: scaleX(-1); } /* mirrored, like a selfie */
.status {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 24px; color: var(--muted); font-size: 17px; pointer-events: none; white-space: pre-line;
}
/* No stranger video yet (searching, or they just left): grey with a spinner, not black. */
.remote-wrap.waiting { background: #2c2c30; }
.remote-wrap.waiting #remote { visibility: hidden; }
.remote-wrap.waiting .status { flex-direction: column; gap: 14px; color: #d0d0d4; }
.remote-wrap.waiting .status::before {
  content: ""; width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.2); border-top-color: #fff; animation: spin 1s linear infinite;
}
.remote-wrap.waiting .status:empty::before { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Call paused (someone dropped or froze): big, clear pause screen over the video. */
.paused {
  position: absolute; inset: 0; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; text-align: center; padding: 24px; background: #1c1c1f; color: #fff; pointer-events: none;
}
/* Pause icon plus one line: wait, or press Next. */
.paused .pause-title { display: none; }
.pause-icon {
  width: 88px; height: 88px; border-radius: 50%; border: 3px solid rgba(255,255,255,.85); display: flex; align-items: center;
  justify-content: center; gap: 12px; animation: pause-pulse 1.6s ease-in-out infinite;
}
.pause-icon span { width: 10px; height: 34px; border-radius: 3px; background: #fff; }
@keyframes pause-pulse { 50% { transform: scale(1.08); opacity: .75; } }
.pause-title { font-size: 26px; font-weight: 700; }
.pause-sub { font-size: 16px; color: #d6d6d9; margin-top: 12px; }

/* Bottom panel (computer): big buttons on the left half, chat on the right half. */
.overlay {
  display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: minmax(0, 1fr) auto; min-height: 0;
  grid-template-areas: "controls messages" "controls form"; background: #0e0e0f; border-top: 1px solid #1f1f22;
}
.bar { display: contents; }
/* 3 columns: [mic over report] [stop] [next] */
.controls {
  grid-area: controls; display: grid; grid-template-columns: auto 1fr 1fr; grid-template-rows: repeat(2, 46px);
  align-content: center; gap: 10px; padding: 14px;
}
.controls .mic { grid-column: 1; grid-row: 1; }
.controls .report-btn { grid-column: 1; grid-row: 2; }
.controls #stop { grid-column: 2; grid-row: 1 / span 2; }
.controls #next { grid-column: 3; grid-row: 1 / span 2; }
.controls button { font-size: 20px; font-weight: 700; color: #fff; border-radius: 10px; }
.controls #stop { background: #d93c41; }
.controls #next { background: #1f9d55; }
.controls .mic, .controls .icon-btn { display: flex; align-items: center; justify-content: center; background: #1c1c1e; border: 1px solid rgba(255,255,255,.12); padding: 0 22px; }
.mic svg, .icon-btn svg { width: 24px; height: 24px; fill: currentColor; flex: none; overflow: visible; }
.controls .report-btn { color: #f0b429; } /* report: amber flag */
.mic .slash { display: none; }
/* Muted: red mic with a red slash. */
.mic.off .slash { display: inline; stroke: #ff3b3b; stroke-width: 3px; stroke-linecap: round; }
.controls .mic.off { border-color: #ff4d4f; color: #ff3b3b; }

/* LINE-style chat: my messages on the right, the stranger's on the left. */
.messages {
  grid-area: messages; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 12px 14px 6px;
  border-left: 1px solid #1f1f22; scrollbar-width: thin;
}
/* Messages sit at the bottom, right above the message box; older ones move up. */
.messages > :first-child { margin-top: auto; }
.msg { max-width: 75%; padding: 6px 12px; border-radius: 14px; word-wrap: break-word; background: #1f1f22; font-size: 15px; }
.msg.them { align-self: flex-start; }
.msg.me { align-self: flex-end; background: #06c755; color: #fff; }
.msg.sys { align-self: center; background: none; color: #a8a8ad; font-size: 13px; padding: 2px 4px; }
.chat-form { grid-area: form; display: flex; gap: 8px; padding: 8px 14px 12px; border-left: 1px solid #1f1f22; }
.chat-form input {
  flex: 1; min-width: 0; font: inherit; color: var(--text); background: #1c1c1e;
  border: 1px solid rgba(255,255,255,.12); border-radius: 10px; padding: 10px 14px;
}
.chat-form .ghost { background: #1c1c1e; border-color: rgba(255,255,255,.12); }

/* Phone held upright: stranger on top, you below, and the buttons + message box in their own strip
   underneath. Chat bubbles show just above the message box and fade after a few seconds. */
@media (max-aspect-ratio: 1/1) {
  .chat { --panel-h: calc(152px + env(safe-area-inset-bottom)); grid-template-rows: minmax(0, 1fr) var(--panel-h); }
  .stage { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
  .remote-wrap, .local { width: min(100cqw, 50cqh * (var(--r))); height: min(50cqh, 100cqw / (var(--r))); }
  .overlay {
    display: flex; flex-direction: column; justify-content: flex-start; border-top: 1px solid #1f1f22;
    padding: 10px 12px max(10px, env(safe-area-inset-bottom));
  }
  .bar { display: flex; flex-direction: column; gap: 8px; }
  .chat-form { padding: 0; border: 0; }
  .controls { padding: 0; grid-template-columns: auto 1fr 1.6fr; grid-template-rows: repeat(2, 38px); gap: 8px; }
  .controls button { font-size: 16px; padding: 0 8px; }
  .controls .mic, .controls .icon-btn { padding: 0 14px; }
  /* Chat bubbles float just above the message box (bottom of your own video). */
  .messages {
    grid-area: auto; /* the computer layout's grid spot would push it off screen here */
    position: absolute; left: 12px; right: 12px; z-index: 2; pointer-events: none;
    bottom: calc(var(--panel-h) + 8px); max-height: calc((100dvh - var(--panel-h)) / 2 * 0.45);
    padding: 0; border: 0; scrollbar-width: none;
  }
  .messages::-webkit-scrollbar { display: none; }
  .messages.overflowing { mask-image: linear-gradient(to bottom, transparent, #000 24px); }
  .msg { background: rgba(28,28,30,.85); }
  .msg.sys { color: #e4e4e7; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
  .msg { transition: opacity .6s; }
  .msg.old { opacity: 0; }
  .messages.reading .msg.old { opacity: 1; }
}

/* Report pop-up */
.modal {
  position: absolute; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.55); padding: 16px;
}
.sheet {
  width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px;
  display: flex; flex-direction: column; gap: 8px;
}
.sheet h2 { margin: 0; font-size: 18px; }
.sheet-sub { margin: 0 0 8px; color: var(--muted); font-size: 14px; }
.reasons { display: flex; flex-direction: column; gap: 6px; }
.reason { text-align: left; background: var(--bg); border: 1px solid var(--line); padding: 12px 14px; }
.reason:hover { border-color: #d9a13b; }
.sheet > .ghost { margin-top: 6px; }
.other-form { display: flex; flex-direction: column; gap: 8px; }
.other-form textarea {
  font: inherit; font-size: 15px; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px; resize: vertical; min-height: 96px;
}
.other-form textarea:focus { outline: none; border-color: #d9a13b; }
.report-send { background: #d9a13b; color: #141414; font-weight: 600; padding: 12px; }
@media (max-width: 700px) {
  .modal { align-items: flex-end; padding: 0; }
  .sheet { max-width: none; border-radius: 14px 14px 0 0; padding-bottom: max(20px, env(safe-area-inset-bottom)); }
}

/* Ban / kick notice: full screen, over everything */
.notice {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(10,10,10,.82);
}
.notice-box {
  width: 100%; max-width: 420px; background: #fff; color: #141414; border-radius: 16px; padding: 28px 24px 22px;
  text-align: center; border-top: 6px solid #d93c41;
}
.notice.kick .notice-box { border-top-color: #d9a13b; }
.notice-icon {
  width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 50%; display: grid; place-items: center;
  background: #d93c41; color: #fff; font-size: 30px; font-weight: 700;
}
.notice.kick .notice-icon { background: #d9a13b; }
.notice h2 { margin: 0 0 10px; font-size: 24px; }
.notice-msg { margin: 0 0 10px; font-size: 16px; line-height: 1.55; }
.notice-until { margin: 0 0 20px; font-size: 14px; color: #5f5f5c; }
.notice button { width: 100%; padding: 13px; background: #141414; color: #fff; font-weight: 600; font-size: 16px; }
