:root {
  --orange: #f7931e;
  --blue: #2f7fd8;
  --blue-d: #1f63b3;
  --red: #d8261d;
  --you: #1a55c9;
  --text: #222;
  --muted: #666;
  --line: #c9c9c9;
  --page: #ececec;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--page); color: var(--text);
  font: 15px/1.45 Arial, Helvetica, "Liberation Sans", sans-serif;
  -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%;
  display: flex; flex-direction: column; min-height: 100dvh;
}
[hidden] { display: none !important; }
a { color: var(--blue-d); }
button { font: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }

/* ---------- header ---------- */
.header {
  display: flex; align-items: center; gap: 16px; flex: none;
  background: #fff; border-bottom: 1px solid var(--line);
  padding: calc(var(--sat) + 8px) calc(var(--sar) + 18px) 8px calc(var(--sal) + 18px);
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.logo { display: block; line-height: 0; margin-right: auto; }
.logo img { height: 64px; width: auto; display: block; }
.online { color: #1c66bd; font-size: 1.15rem; white-space: nowrap; }
.online b { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- home ---------- */
#home { flex: 1; width: 100%; max-width: 860px; margin: 0 auto; padding: 26px calc(var(--sar) + 16px) calc(var(--sab) + 16px) calc(var(--sal) + 16px); display: flex; flex-direction: column; }
.home-box { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 26px 28px; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.intro { margin: 0 0 22px; font-size: 1.08rem; color: #333; }
.home-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; align-items: start; }
.home-col h2 { font-size: 1.15rem; margin: 0 0 10px; font-weight: 700; color: #333; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 50px; padding: 6px; border: 1px solid #aaa; border-radius: 4px; background: #fff; box-shadow: inset 0 1px 3px rgba(0,0,0,.1); cursor: text; }
.chips:focus-within { border-color: var(--blue); }
.chips input { flex: 1; min-width: 150px; border: 0; outline: 0; font: inherit; font-size: 16px; padding: 4px; background: transparent; }
.chip { display: inline-flex; align-items: center; gap: 2px; padding: 3px 4px 3px 10px; border-radius: 3px; background: #e3eefb; border: 1px solid #a9c8ef; color: #1f4f8f; font-size: .95rem; }
.chip button { border: 0; background: none; color: #1f4f8f; cursor: pointer; font-size: 1.1rem; line-height: 1; padding: 0 4px; }
.start-buttons { display: flex; align-items: center; gap: 12px; }
.or { color: var(--muted); font-size: 1.05rem; }
.btn-start {
  flex: 1; min-width: 0; padding: 12px 18px; border-radius: 6px; cursor: pointer;
  font-size: 1.35rem; font-weight: 700; color: #fff; text-shadow: 0 -1px 0 rgba(0,0,0,.25);
  background: linear-gradient(#73b5f4, #3d8ae0 55%, #2f78cf); border: 1px solid #2563b4;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45), 0 1px 2px rgba(0,0,0,.15);
  transition: filter .15s, transform .05s; touch-action: manipulation;
}
.btn-start:hover { filter: brightness(1.07); }
.btn-start:active { transform: translateY(1px); filter: brightness(.95); }
.btn-start.small { flex: none; font-size: 1rem; padding: 8px 22px; }
.check { display: flex; gap: 8px; align-items: flex-start; margin-top: 22px; color: #444; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 1px 0 0; flex: none; accent-color: var(--blue); }
.form-error { color: var(--red); font-weight: 700; margin: 10px 0 0; }
.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.notice { margin: 18px 4px 0; color: #555; font-size: .93rem; }
/* SEO-Inhalt: schlicht wie der Rest der Seite */
.seo { margin: 30px 4px 0; color: #444; font-size: .97rem; }
.seo h1 { font-size: 1.35rem; color: #333; margin: 0 0 8px; }
.seo h2 { font-size: 1.1rem; color: #333; margin: 22px 0 6px; }
.seo p { margin: 0 0 10px; }
.seo ul { margin: 0; padding-left: 20px; }
.seo li { margin: 4px 0; }
.faq details { background: #fff; border: 1px solid var(--line); border-radius: 6px; margin: 0 0 6px; }
.faq summary { cursor: pointer; padding: 10px 14px; font-weight: 700; color: #333; list-style-position: inside; }
.faq details[open] summary { border-bottom: 1px solid #eee; }
.faq details p { padding: 10px 14px; margin: 0; }
.foot { margin-top: auto; padding-top: 24px; text-align: center; color: #555; font-size: .88rem; }
.foot a { color: #444; }

/* ---------- chat ---------- */
#chat {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: minmax(260px, 38%) 1fr; gap: 10px;
  padding: 10px calc(var(--sar) + 10px) calc(var(--sab) + 10px) calc(var(--sal) + 10px);
}
body.in-chat { height: 100dvh; overflow: hidden; }
.videos { display: grid; grid-template-rows: 1fr 1fr; gap: 10px; min-height: 0; }
.vbox { position: relative; min-height: 0; background: linear-gradient(#e2e2e2, #c8c8c8); border: 1px solid #b5b5b5; border-radius: 6px; overflow: hidden; }
.vbox video { width: 100%; height: 100%; object-fit: cover; display: block; }
.vbox.local video { transform: scaleX(-1); }
.vbox.local.env video { transform: none; }
.vstatus { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; padding: 16px; text-align: center; color: #555; font-weight: 700; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 4px solid rgba(0,0,0,.12); border-top-color: var(--blue); animation: spin .8s linear infinite; }
.vstatus.idle .spinner { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.vbtn.report { position: absolute; top: 8px; right: 8px; padding: 5px 10px; border-radius: 4px; border: 1px solid rgba(0,0,0,.25); background: rgba(255,255,255,.88); color: var(--red); font-weight: 700; font-size: .85rem; cursor: pointer; }
.vctrl { position: absolute; right: 8px; bottom: 8px; display: flex; gap: 6px; }
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; border: 1px solid rgba(0,0,0,.2); background: rgba(255,255,255,.88); color: #333; cursor: pointer; }
.icon-btn .off { display: none; }
.icon-btn[aria-pressed="false"] { background: var(--red); color: #fff; border-color: transparent; }
.icon-btn[aria-pressed="false"] .on { display: none; }
.icon-btn[aria-pressed="false"] .off { display: block; }

.panel { min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.log { flex: 1; min-height: 0; overflow-y: auto; background: #fff; border: 1px solid #b5b5b5; border-radius: 6px; padding: 12px 14px; overscroll-behavior: contain; font-size: 1rem; }
.line { margin: 0 0 6px; overflow-wrap: anywhere; white-space: pre-wrap; }
.line strong { font-weight: 700; }
.line .them { color: var(--red); }
.line .me { color: var(--you); }
.sys { margin: 0 0 8px; color: #555; font-weight: 700; }
.sys .tag { font-weight: 400; color: #333; }
.typing-line { color: #888; font-style: italic; margin: 0 0 6px; }

.composer { display: flex; gap: 8px; align-items: stretch; height: 84px; flex: none; }
.btn-disc, .btn-send {
  width: 96px; flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border-radius: 6px; border: 1px solid #999; cursor: pointer; color: #222;
  background: linear-gradient(#fff, #e6e6e6 60%, #d9d9d9);
  box-shadow: inset 0 1px 0 #fff, 0 1px 2px rgba(0,0,0,.12); touch-action: manipulation;
}
.btn-disc .lbl, .btn-send .lbl { font-size: 1.3rem; font-weight: 700; }
.key { font-size: .75rem; color: #777; }
.btn-disc:hover, .btn-send:not(:disabled):hover { background: linear-gradient(#fff, #eee 60%, #e2e2e2); }
.btn-disc:active, .btn-send:active { background: #d6d6d6; }
.btn-disc.confirm { background: linear-gradient(#ff7a6e, #e0352b); border-color: #b3271f; color: #fff; }
.btn-disc.confirm .key { color: #ffe1de; }
.btn-disc.new, .btn-disc.skip { background: linear-gradient(#73b5f4, #3d8ae0 55%, #2f78cf); border-color: #2563b4; color: #fff; text-shadow: 0 -1px 0 rgba(0,0,0,.25); }
.btn-disc.new .key, .btn-disc.skip .key { color: #dcebfb; }
.btn-send:disabled { opacity: .55; cursor: default; }
.msgwrap { flex: 1; min-width: 0; display: flex; }
#msg { flex: 1; resize: none; border: 1px solid #999; border-radius: 6px; padding: 10px 12px; font: inherit; font-size: 16px; background: #fff; box-shadow: inset 0 1px 3px rgba(0,0,0,.1); outline: 0; }
#msg:focus { border-color: var(--blue); }
#msg:disabled { background: #f3f3f3; }

#chat.text-mode { grid-template-columns: 1fr; max-width: 980px; width: 100%; margin: 0 auto; }
#chat.text-mode .videos { display: none; }

/* ---------- tablet portrait / phones ---------- */
@media (max-width: 860px), (orientation: portrait) and (max-width: 1100px) {
  .header { padding: calc(var(--sat) + 6px) calc(var(--sar) + 12px) 6px calc(var(--sal) + 12px); }
  .logo img { height: 46px; }
  .online { font-size: .95rem; }
  .online b { font-size: 1.15rem; }
  .home-cols { grid-template-columns: 1fr; gap: 20px; }
  .home-box { padding: 20px 18px; }
  #chat { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1.1fr) minmax(0, 1fr); gap: 8px; padding: 8px calc(var(--sar) + 8px) calc(var(--sab) + 8px) calc(var(--sal) + 8px); }
  .videos { grid-template-rows: 1fr; position: relative; }
  .vbox.remote { grid-area: 1 / 1; }
  .vbox.local { grid-area: 1 / 1; place-self: start end; width: clamp(100px, 28%, 180px); aspect-ratio: 3 / 4; margin: 8px; z-index: 2; border: 2px solid #fff; box-shadow: 0 2px 10px rgba(0,0,0,.3); }
  .vbox.local .vctrl { right: 4px; bottom: 4px; left: 4px; justify-content: center; gap: 4px; }
  .vbox.local .icon-btn { width: 30px; height: 30px; }
  .vbox.local .icon-btn svg { width: 16px; height: 16px; }
  .vbtn.report { right: auto; left: 8px; }
  .composer { height: 56px; gap: 6px; }
  .btn-disc, .btn-send { width: 70px; }
  .btn-disc .lbl, .btn-send .lbl { font-size: 1.05rem; }
  .key { display: none; }
  #chat.text-mode { grid-template-rows: 1fr; }
}
@media (orientation: landscape) and (max-height: 560px) {
  body.in-chat .header { display: none; }
  #chat { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); grid-template-rows: 1fr; }
  .vbox.local { width: clamp(90px, 24%, 140px); }
}
@media (max-width: 420px) {
  .online { font-size: .85rem; }
  .btn-start { font-size: 1.15rem; padding: 12px 10px; }
}

/* ---------- dialogs & toast ---------- */
.dlg { max-width: min(500px, calc(100vw - 32px)); width: 100%; border: 1px solid #999; border-radius: 8px; padding: 20px 22px; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.dlg::backdrop { background: rgba(0,0,0,.45); }
.dlg h2 { margin: 0 0 10px; font-size: 1.3rem; }
.dlg ul { padding-left: 20px; }
.dlg li { margin: 6px 0; }
.dlg form { margin-top: 14px; }
.report-form { display: grid; gap: 6px; }
.radio { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border: 1px solid var(--line); border-radius: 5px; cursor: pointer; }
.radio:has(input:checked) { border-color: var(--red); background: #fff3f2; }
.row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.btn-plain, .btn-danger { padding: 8px 16px; border-radius: 5px; font-weight: 700; cursor: pointer; }
.btn-plain { border: 1px solid #999; background: linear-gradient(#fff, #e3e3e3); }
.btn-danger { border: 1px solid #b3271f; background: linear-gradient(#ff7a6e, #e0352b); color: #fff; }
.toast { position: fixed; left: 50%; bottom: calc(var(--sab) + 110px); transform: translateX(-50%); background: #333; color: #fff; padding: 9px 16px; border-radius: 6px; z-index: 50; max-width: calc(100vw - 32px); text-align: center; box-shadow: 0 4px 16px rgba(0,0,0,.3); }
.noscript { text-align: center; padding: 20px; }
