.chat-page {
  --chat-gap: 10px;
  --chat-radius: 6px;
  --chat-composer-height: 84px;
  height: 100dvh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-size: 15px;
  line-height: 1.4;
}
.chat-page .container { width: calc(100% - var(--chat-gap) * 2); max-width: none; }
.chat-page .site-header { flex: 0 0 auto; }
.chat-page .header-inner { min-height: 67px; padding-block: 6px; gap: 10px; }
.chat-page .brand { max-width: none; font-size: 28px; gap: 6px; }
.chat-page .brand img { width: 40px; height: 40px; }
.chat-page .header-actions { display: flex !important; flex-direction: row-reverse; gap: 8px; }
.chat-page .header-live-status { font-size: 12px; }
.chat-page .icon-button { width: 44px; height: 44px; border: 0; background: var(--surface); }
.chat-page .site-nav { display: none !important; }
.chat-page .chat-main { display: flex; flex: 1; flex-direction: column; min-height: 0; padding: 0 0 var(--chat-gap); }
.chat-page .page-heading {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
}
.chat-page .app-container { display: flex; flex: 1; min-width: 0; min-height: 0; margin: 0 auto; padding: 0; }
#chat-app, .chat-layout { display: flex; flex: 1; min-width: 0; min-height: 0; margin: 0; }
#chat-app { color: var(--text); font: inherit; }
#chat-app [hidden] { display: none !important; }
.chat-room { position: relative; display: flex; flex: 1; flex-direction: column; min-width: 0; min-height: 0; }
.chat-room-header { position: absolute; width: 0; height: 0; }
.chat-sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; padding: 0; margin: -1px; clip-path: inset(50%); white-space: nowrap; border: 0; }
.chat-workspace, .chat-text-panel { position: relative; display: flex; flex: 1; flex-direction: column; min-width: 0; min-height: 0; }
.chat-conversation { position: relative; flex: 1; min-height: 0; padding: 16px; overflow-y: auto; overscroll-behavior: contain; background: var(--surface); border-radius: var(--chat-radius); }
.chat-info { margin-bottom: 12px; }
.chat-info .chat-status { margin: 0; font-weight: 700; }
.chat-country { margin: 4px 0 0; font-size: 14px; color: var(--muted); }
.chat-empty { display: flex; min-height: 100%; flex-direction: column; align-items: flex-start; justify-content: flex-start; text-align: left; }
.chat-info:not([hidden]) ~ .chat-empty { min-height: 0; }
.video-page #chat-app:not([data-phase=idle]) .chat-empty { display: none; }
#chat-app .chat-welcome h2 { margin: 0 0 8px; font-size: 18px; font-weight: 700; letter-spacing: -.025em; line-height: 1.3; }
.chat-welcome ul { list-style: none; margin: 0; padding: 0; font-size: 15px; line-height: 1.4; }
.chat-welcome li:first-child { color: var(--primary-2); font-weight: 700; }
.chat-welcome li:last-child { color: var(--muted); }
.chat-age-badge { display: inline-block; padding: 0 4px; margin-right: 4px; font-size: 11px; border-radius: 4px; background: var(--primary); color: var(--primary-fg); vertical-align: 1px; }
#chat-app:not([data-phase=idle]) .chat-welcome { display: none; }
#chat-app[data-mode=text]:is([data-phase=preparing], [data-phase=searching]) .chat-empty { align-items: center; justify-content: center; }
.chat-loading { display: none; width: 36px; height: 36px; flex: 0 0 auto; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: chat-spin .8s linear infinite; }
#chat-app:is([data-phase=preparing], [data-phase=searching]) .chat-loading,
#chat-app[data-media-state=loading] #chat-media-status .chat-loading { display: block; }
@keyframes chat-spin { to { transform: rotate(1turn); } }
#chat-transcript { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.chat-message { max-width: 88%; margin: 0; padding: 8px 12px; border-radius: 6px; background: var(--surface-soft); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; }
.chat-message-own { align-self: flex-end; background: var(--teal-soft); }
.chat-message-author { display: block; margin-bottom: 3px; color: var(--muted); font-size: 11px; font-weight: 700; }
.chat-typing { position: absolute; bottom: calc(var(--chat-composer-height) + var(--chat-gap)); left: 16px; margin: 0; padding: 2px 4px; background: var(--surface); color: var(--muted); font-size: 12px; }
.chat-typing:empty { display: none; }
.chat-composer { position: relative; display: flex; flex: 0 0 auto; align-items: stretch; gap: var(--chat-gap); height: var(--chat-composer-height); margin: var(--chat-gap) 0 0; }
.chat-session-controls { display: flex; flex: 0 0 auto; gap: 6px; }
#chat-app .button {
  appearance: none;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 44px;
  min-height: 44px;
  padding: 8px 12px;
  margin: 0;
  border: 0;
  border-radius: var(--chat-radius);
  background: var(--primary);
  color: var(--primary-fg);
  font: inherit;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  transition: background .15s ease-out;
}
#chat-app .button:hover:not(:disabled) { background: var(--primary-2); }
#chat-app .button:disabled { cursor: not-allowed; }
#chat-app .button-secondary { background: var(--surface-soft); color: var(--text); }
#chat-app :is(button, textarea, select):focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
#chat-app .chat-session-controls .button { width: 130px; height: 100%; flex-direction: column; font-size: 18px; background: var(--surface); color: var(--text); border: 1px solid var(--border); }
#chat-app .chat-session-controls .button:hover:not(:disabled) { background: var(--teal-soft); }
.chat-start kbd { font-family: inherit; font-size: 12px; }
#chat-app:not([data-phase=idle]) .chat-start,
#chat-app[data-phase=idle] :is(#chat-next, #chat-stop) { display: none; }
#chat-app[data-phase=idle][data-preview=on] #chat-stop { display: inline-flex; }
#chat-app .chat-session-controls #chat-stop { width: 64px; font-size: 14px; }
#chat-message {
  flex: 1;
  min-width: 0;
  width: 100%;
  height: 100%;
  min-height: 44px;
  padding: 12px 54px 12px 12px;
  resize: none;
  border: 1px solid transparent;
  border-radius: var(--chat-radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  line-height: 1.4;
}
#chat-message:focus { border-color: var(--primary); }
#chat-message::placeholder { color: var(--muted); opacity: 1; }
#chat-app #chat-send { position: absolute; right: 0; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; padding: 12px; background: transparent; color: var(--primary-2); }
#chat-app #chat-send:hover:not(:disabled) { background: var(--teal-soft); }
#chat-app #chat-send:disabled { color: var(--muted); opacity: .7; }
#chat-send svg, #chat-report svg { width: 20px; height: 20px; }
#chat-app #chat-report { position: absolute; right: 0; top: 0; z-index: 3; width: 44px; height: 44px; padding: 14px; background: transparent; color: var(--muted); }
#chat-app #chat-report:hover:not(:disabled) { background: var(--danger-soft); color: var(--danger); }
#chat-app #chat-report:disabled { opacity: .5; }
.chat-video-grid { display: grid; min-width: 0; min-height: 0; gap: var(--chat-gap); }
.chat-video-panel { position: relative; min-width: 0; min-height: 0; overflow: hidden; border-radius: var(--chat-radius); background: var(--surface-soft); }
.chat-video-panel video { display: block; width: 100%; height: 100%; object-fit: cover; }
.chat-local video { transform: scaleX(-1); }
.chat-video-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--surface-soft); }
.chat-watermark { position: absolute; bottom: 12px; left: 12px; display: flex; align-items: center; gap: 4px; font-size: 14px; font-weight: 700; color: var(--text); }
.chat-watermark img { width: 18px; height: 18px; }
#chat-app .chat-remote #chat-report { top: auto; bottom: 0; }
.video-page .chat-layout { container-type: size; }
.video-page .chat-room { display: grid; grid-template-columns: min(38%, calc((100cqh - var(--chat-gap)) * 2 / 3)) minmax(0, 1fr); gap: var(--chat-gap); }
.video-page .chat-video-grid { grid-template-rows: repeat(2, minmax(0, 1fr)); }
.chat-notice { flex: 0 0 auto; max-height: 25%; margin: 0 0 var(--chat-gap); padding: 10px; overflow-y: auto; border-radius: var(--chat-radius); background: var(--warning-soft); color: var(--warning); overflow-wrap: anywhere; }
.chat-captcha { flex: 0 0 auto; max-height: 50%; margin-bottom: var(--chat-gap); padding: 12px; overflow-y: auto; background: var(--surface); border-radius: var(--chat-radius); }
.chat-captcha p, .chat-help { font-size: 13px; color: var(--muted); }
#chat-captcha-widget { display: flex; justify-content: center; }
.chat-report-form { position: absolute; z-index: 4; left: 0; right: 0; bottom: calc(var(--chat-composer-height) + var(--chat-gap)); max-height: calc(100% - var(--chat-composer-height) - var(--chat-gap)); padding: 16px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--chat-radius); }
.chat-report-form label { display: block; margin-bottom: 8px; font-weight: 700; }
.chat-report-form select { width: 100%; min-height: 44px; margin-bottom: 8px; padding: 8px; border: 1px solid var(--control-border); border-radius: var(--chat-radius); background: var(--surface); color: var(--text); font: inherit; }
.chat-report-actions { display: flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 1149px) {
  .chat-page { --chat-composer-height: 77px; }
  .chat-page .header-inner { min-height: 57px; }
  .chat-page .brand { font-size: 25px; }
  .chat-page .brand img { width: 36px; height: 36px; }
  .video-page .chat-room { grid-template-columns: minmax(0, 1fr); grid-template-rows: min(calc((100cqw - var(--chat-gap)) * 3 / 8), calc((100cqh - var(--chat-gap)) * .6)) minmax(0, 1fr); }
  .video-page .chat-video-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: minmax(0, 1fr); }
  .video-page .chat-video-grid { width: min(100%, calc((100cqh - var(--chat-gap)) * .6 * 8 / 3 + var(--chat-gap))); justify-self: center; }
  #chat-app .chat-session-controls .button { width: 115px; }
}
@media (max-width: 599px) {
  .chat-page { --chat-gap: 10px; --chat-composer-height: 80px; }
  .chat-page .header-inner { min-height: 65px; padding-block: 4px; }
  .chat-page .brand { font-size: 28px; }
  .chat-page .brand img { width: 40px; height: 40px; }
  .chat-page .icon-button { width: 44px; height: 36px; }
  .chat-page .header-actions { gap: 4px; }
  .chat-page .header-live-status { font-size: 10px; }
  .chat-page .live-dot { width: 5px; height: 5px; }
  .video-page .chat-room { grid-template-rows: min(calc(100cqw * 3 / 4), calc((100cqh - var(--chat-composer-height) - var(--chat-gap) * 2) * .65)) minmax(0, 1fr); }
  .video-page .chat-video-grid { position: relative; display: block; width: 100%; container-type: size; }
  .video-page .chat-remote { height: 100%; }
  .video-page .chat-local { position: absolute; top: 5px; right: 5px; width: min(80px, 25%, calc((100cqh - 54px) * 4 / 3)); aspect-ratio: 4 / 3; }
  .chat-conversation { padding: 12px; }
  .video-page .chat-conversation { display: flex; flex-direction: column; }
  .video-page .chat-info { margin-top: auto; flex-shrink: 0; }
  .video-page #chat-app[data-phase=idle] .chat-empty { justify-content: flex-end; }
  #chat-app .chat-welcome h2 { font-size: 20px; margin-bottom: 8px; }
  .chat-welcome ul { font-size: 15px; }
  #chat-app .chat-session-controls .button { width: 106px; font-size: 16px; padding-inline: 6px; }
  #chat-app .chat-session-controls #chat-stop { width: 44px; font-size: 12px; }
  .chat-session-controls { gap: 4px; }
  .chat-start kbd { display: none; }
  #chat-message { font-size: 14px; padding: 10px 42px 10px 8px; }
  .chat-watermark { left: 8px; bottom: 10px; font-size: 14px; gap: 3px; }
  .chat-watermark img { width: 18px; height: 18px; }
  .chat-message { font-size: 14px; max-width: 95%; }
}
@media (max-width: 359px) {
  #chat-app .chat-session-controls .button { width: 54px; }
  #chat-app .chat-session-controls #chat-stop { width: 44px; }
  .chat-page .brand { font-size: 18px; }
}
@media (max-height: 540px) {
  .chat-page { --chat-composer-height: 44px; }
  .chat-page .header-inner { min-height: 44px; padding-block: 2px; }
  .chat-page .brand img { width: 30px; height: 30px; }
  .chat-page .brand { font-size: 21px; }
  #chat-app .chat-session-controls .button { font-size: 15px; }
  .chat-conversation { padding: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  #chat-app .button { transition: none; }
  .chat-loading { animation: none; }
}
