* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --tbg: #fdeef6; --tbar: #f3c6dd; --ttxt: #7a2a52; --tacc: #d4537e;
  --tchat: rgba(244,192,209,.55); --tbub1: #d4537e; --tbub1t: #fff;
  --tbub2: #fff; --tbub2t: #72243e; --tinput: rgba(255,255,255,.85);
}
body {
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background-color: var(--tbg);
  background-image: var(--tpat, none);
  background-size: 44px 44px;
  min-height: 100vh; min-height: 100dvh;
  color: var(--ttxt);
  transition: background-color .3s;
}
body.has-bgimg {
  background-image: var(--tbgimg);
  background-size: cover; background-position: center; background-attachment: fixed;
}
.screen { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* --- prihlásenie --- */
#screen-join { align-items: center; justify-content: center; }
.card {
  background: rgba(255,255,255,.92); border-radius: 24px; padding: 36px 28px;
  width: min(92vw, 360px); text-align: center; box-shadow: 0 12px 40px rgba(0,0,50,.25);
  color: #223;
}
.logo { font-size: 64px; }
.card h1 { margin: 8px 0 20px; color: var(--tacc); }
.card input {
  width: 100%; padding: 14px; margin: 8px 0; font-size: 18px;
  border: 2px solid #ccd; border-radius: 14px; text-align: center;
}
.card input:focus { outline: none; border-color: var(--tacc); }
.err { color: #d33; margin-top: 10px; min-height: 1.2em; font-weight: 600; }

/* --- tlačidlá --- */
button.big, label.big {
  font-size: 18px; font-weight: 700; padding: 14px 22px; border: none;
  border-radius: 18px; cursor: pointer; color: #fff; margin-top: 12px;
  transition: transform .1s; touch-action: manipulation; display: inline-block;
}
button.big.slim { font-size: 16px; padding: 11px 18px; margin-top: 0; flex: 1; }
button.big:active, label.big:active { transform: scale(.96); }
button.big:disabled { opacity: .45; cursor: default; }
.green { background: #2eb872; }
.red { background: #e85454; }
.gray { background: #8a94a6; }
.violet { background: #7a5bd6; }
button.round {
  width: 54px; height: 54px; border-radius: 50%; border: none; font-size: 22px;
  background: #eef; color: #334; cursor: pointer;
  transition: transform .1s; touch-action: manipulation;
}
button.round:active { transform: scale(.92); }
button.round.off { background: #8a94a6; filter: grayscale(1); }
button.round.red-bg { background: #e85454; }
.icon-btn { border: none; background: none; font-size: 20px; cursor: pointer; padding: 4px; }

/* --- header --- */
header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; background: var(--tbar); color: var(--ttxt);
  font-weight: 600; font-size: 15px; gap: 10px;
}
.hdr-title { font-weight: 700; }
.hdr-btns { display: flex; align-items: center; gap: 8px; }
.hdr-contact { display: flex; align-items: center; gap: 10px; flex: 1; line-height: 1.2; }
.status.online { color: #1d8a4f; }
.status.offline { opacity: .6; }
#conn-status.dead { filter: grayscale(1); opacity: .4; }

/* --- avatary --- */
.avatar {
  width: 46px; height: 46px; border-radius: 50%; background: var(--tacc); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; flex-shrink: 0;
}
.avatar.sm { width: 36px; height: 36px; font-size: 16px; }

/* --- domovská obrazovka --- */
.me-row {
  display: flex; align-items: center; gap: 12px; margin: 14px 14px 6px;
  background: var(--tchat); border-radius: 18px; padding: 12px 16px;
}
#me-name {
  flex: 1; border: none; background: none; font-size: 18px; font-weight: 700;
  color: var(--ttxt); min-width: 0;
}
#me-name:focus { outline: none; border-bottom: 2px solid var(--tacc); }
.me-hint { opacity: .5; font-size: 14px; }
#contact-list { display: flex; flex-direction: column; gap: 10px; margin: 10px 14px; }
.contact {
  display: flex; align-items: center; gap: 12px; background: var(--tchat);
  border-radius: 18px; padding: 12px 16px; cursor: pointer; border: none;
  font: inherit; color: var(--ttxt); text-align: left; transition: transform .1s;
}
.contact:active { transform: scale(.98); }
.contact .cname { font-size: 18px; font-weight: 700; flex: 1; }
.contact .cstat { font-size: 13px; }
.badge {
  background: #e85454; color: #fff; font-size: 13px; font-weight: 700;
  min-width: 24px; height: 24px; border-radius: 12px; display: inline-flex;
  align-items: center; justify-content: center; padding: 0 7px;
}

/* --- chat obrazovka --- */
.call-btn-row { display: flex; gap: 10px; margin: 12px 14px 0; }
#chat {
  flex: 1; display: flex; flex-direction: column; margin: 12px 14px 14px;
  background: var(--tchat); border-radius: 18px; overflow: hidden;
  min-height: 140px; backdrop-filter: blur(3px);
}
#chat-log { flex: 1; overflow-y: auto; padding: 14px; }
.load-older {
  display: block; margin: 0 auto 10px; border: none; background: rgba(255,255,255,.7);
  color: #556; font-size: 13px; padding: 7px 16px; border-radius: 14px; cursor: pointer;
}
.msg { margin: 6px 0; max-width: 80%; padding: 10px 14px; border-radius: 16px; word-wrap: break-word; }
.msg.me { background: var(--tbub1); color: var(--tbub1t); margin-left: auto; border-bottom-right-radius: 4px; }
.msg.them { background: var(--tbub2); color: var(--tbub2t); border-bottom-left-radius: 4px; }
.msg.sys { background: none; color: var(--ttxt); opacity: .65; font-size: 13px; text-align: center; max-width: 100%; }
.msg.callinfo {
  background: rgba(255,255,255,.75); color: #445; font-size: 13px; font-weight: 600;
  text-align: center; max-width: 100%; margin: 8px auto; width: fit-content;
  border-radius: 14px; padding: 7px 16px;
}
.msg.callinfo.missed { color: #c33; }
.msg .who { font-size: 12px; font-weight: 700; opacity: .75; }
#chat-input-row { display: flex; align-items: center; border-top: 1px solid rgba(0,0,0,.08); background: var(--tinput); }
.input-side {
  border: none; background: none; font-size: 22px; cursor: pointer;
  padding: 8px 4px 8px 12px; line-height: 1;
}
#emoji-panel {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 2px; padding: 10px; background: var(--tinput);
  border-top: 1px solid rgba(0,0,0,.08); max-height: 180px; overflow-y: auto;
}
#emoji-panel button {
  border: none; background: none; font-size: 24px; cursor: pointer;
  padding: 4px; border-radius: 8px;
}
#emoji-panel button:hover { background: rgba(0,0,0,.06); }
.msg.has-img { padding: 4px; background: none; }
.msg.has-img img {
  max-width: min(60vw, 260px); max-height: 260px; border-radius: 14px;
  display: block; cursor: pointer;
}
#lightbox { background: rgba(0,0,10,.85); cursor: zoom-out; }
#lightbox img { max-width: 94vw; max-height: 92vh; border-radius: 10px; }
#chat-input { flex: 1; border: none; padding: 14px; font-size: 16px; background: none; color: #223; min-width: 0; }
#chat-input:focus { outline: none; }
#btn-send { border: none; background: var(--tacc); color: #fff; font-size: 20px; padding: 0 22px; cursor: pointer; }

/* --- overlay + modaly --- */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,20,.55); z-index: 50;
  display: flex; align-items: center; justify-content: center;
}
.mbox {
  background: #fff; color: #223; border-radius: 24px; padding: 28px 24px;
  width: min(92vw, 380px); text-align: center; box-shadow: 0 16px 50px rgba(0,0,30,.4);
}
.mbox.call { width: min(94vw, 620px); padding: 16px; }
.mbox p { font-size: 18px; font-weight: 600; margin: 10px 0; }
.pulse { font-size: 56px; animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.25); } }
.row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; align-items: center; }
.controls { margin-top: 12px; }

/* --- video --- */
#video-box {
  position: relative; border-radius: 16px; overflow: hidden;
  background: #14141c; aspect-ratio: 16 / 10; width: 100%;
}
#remote-video { width: 100%; height: 100%; object-fit: cover; }
#remote-placeholder {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; font-size: 48px; color: #8a8a99;
}
#remote-placeholder small { font-size: 13px; margin-top: 4px; }
#remote-video.live + #remote-placeholder { display: none; }
#local-video {
  position: absolute; width: 84px; height: 112px; object-fit: cover;
  border-radius: 12px; border: 2px solid var(--tacc); background: #2e2e3c;
  cursor: pointer; transition: all .25s;
}
#local-video.corner-br { right: 10px; bottom: 10px; top: auto; left: auto; }
#local-video.corner-bl { left: 10px; bottom: 10px; top: auto; right: auto; }
#local-video.corner-tr { right: 10px; top: 10px; bottom: auto; left: auto; }
#local-video.corner-tl { left: 10px; top: 10px; bottom: auto; right: auto; }
#call-timer {
  position: absolute; left: 10px; top: 10px; background: rgba(0,0,0,.45);
  color: #fff; font-size: 12px; padding: 3px 10px; border-radius: 10px;
}

/* --- panel vzhľadu --- */
#theme-panel { align-items: flex-end; }
#theme-sheet {
  background: #fff; color: #223; border-radius: 24px 24px 0 0;
  padding: 24px 20px 28px; width: min(100vw, 480px); text-align: center;
}
#theme-sheet h3 { margin-bottom: 6px; }
.lbl { font-size: 13px; color: #778; margin: 14px 0 6px; font-weight: 600; }
#theme-swatches, #pat-btns { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.swatch {
  width: 46px; height: 46px; border-radius: 50%; cursor: pointer; border: 3px solid transparent;
  display: flex; align-items: center; justify-content: center;
}
.swatch.sel { border-color: #223; }
.swatch span { width: 18px; height: 18px; border-radius: 50%; display: block; }
.pat-btn {
  width: 42px; height: 42px; border-radius: 12px; border: 2px solid #dde;
  background: #f6f7fb; font-size: 18px; cursor: pointer;
}
.pat-btn.sel { border-color: #223; }
.file-btn { text-align: center; }
#theme-close { width: 100%; color: #fff; }
