
:root{
  --blue:#0876b9;
  --dark:#172536;
  --line:#dde5eb;
  --bg:#eef3f6;
  --composer-h:68px;
}

*{
  box-sizing:border-box;
  -webkit-tap-highlight-color:transparent;
}

html,
body{
  position:fixed;
  inset:0;
  width:100%;
  height:100%;
  margin:0;
  padding:0;
  overflow:hidden;
  background:var(--bg);
  color:var(--dark);
  font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Arial,sans-serif;
}

body.zzk-chat-page{
  position:fixed;
  inset:0;
  width:100%;
  height:100svh;
  min-height:0;
  overflow:hidden;
  overscroll-behavior:none;
}

/* NAGŁÓWEK — zawsze u góry */
.zzk-chat-head{
  position:absolute;
  z-index:20;
  top:0;
  left:0;
  right:0;
  min-height:60px;
  display:flex;
  align-items:center;
  gap:10px;
  padding:
    calc(8px + env(safe-area-inset-top))
    12px
    8px;
  background:#fff;
  border-bottom:1px solid var(--line);
}

.zzk-chat-head>a{
  width:34px;
  flex:0 0 34px;
  color:#075d91;
  text-decoration:none;
  font-size:34px;
  line-height:1;
  text-align:center;
}

.zzk-chat-head strong,
.zzk-chat-head small{
  display:block;
}

.zzk-chat-head strong{
  font-size:15px;
}

.zzk-chat-head small{
  margin-top:1px;
  color:#768895;
  font-size:11px;
}

.chat-avatar{
  width:42px;
  height:42px;
  flex:0 0 42px;
  overflow:hidden;
  border-radius:50%;
  display:grid;
  place-items:center;
  background:#e5f1f7;
  color:#075d91;
  font-size:13px;
  font-weight:900;
}

.chat-avatar.has-photo img{
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
}

/* WIADOMOŚCI — tylko ten obszar się przewija */
.zzk-messages{
  position:absolute;
  z-index:1;
  top:calc(60px + env(safe-area-inset-top));
  left:0;
  right:0;
  bottom:calc(var(--composer-h) + env(safe-area-inset-bottom));
  min-height:0;

  overflow-y:auto;
  overflow-x:hidden;
  -webkit-overflow-scrolling:touch;
  overscroll-behavior-y:contain;

  display:flex;
  flex-direction:column;
  gap:7px;
  padding:14px 12px 18px;
}

/* PASEK PISANIA — NA STAŁE NA DOLE */
.zzk-composer{
  position:absolute;
  z-index:50;
  left:0;
  right:0;
  bottom:0;

  min-height:var(--composer-h);
  display:grid;
  grid-template-columns:44px 44px minmax(0,1fr) 46px;
  gap:7px;
  align-items:center;

  padding:
    8px
    10px
    max(8px,env(safe-area-inset-bottom));

  background:#fff;
  border-top:1px solid var(--line);
  box-shadow:0 -5px 18px rgba(18,52,76,.08);
}

.zzk-composer>input{
  width:100%;
  min-width:0;
  height:44px;
  margin:0;
  border:1px solid #cfd9e0;
  border-radius:999px;
  padding:0 14px;
  outline:none;
  background:#fff;
  color:var(--dark);
  font:inherit;
  font-size:16px;
  -webkit-appearance:none;
}

.zzk-composer>button,
.zzk-photo,
.zzk-emoji-btn{
  width:44px;
  height:44px;
  margin:0;
  padding:0;
  border:0;
  border-radius:50%;
  display:grid;
  place-items:center;
  font:inherit;
  font-size:22px;
}

.zzk-composer>button{
  background:var(--blue);
  color:#fff;
  font-weight:900;
}

.zzk-photo{
  background:#e6f1f7;
  color:#075d91;
  font-weight:900;
}

.zzk-emoji-btn{
  background:#fff3d6;
  color:var(--dark);
}

/* EMOJI — otwierają się NAD paskiem pisania */
.zzk-emoji-picker[hidden]{
  display:none!important;
}

.zzk-emoji-picker{
  position:absolute;
  z-index:100;
  left:10px;
  right:10px;
  bottom:calc(var(--composer-h) + 8px + env(safe-area-inset-bottom));
  max-width:520px;
  max-height:min(310px,40svh);
  margin:0 auto;
  overflow-y:auto;
  padding:10px;
  border:1px solid #dce5eb;
  border-radius:18px;
  background:#fff;
  box-shadow:0 14px 45px rgba(20,50,75,.25);

  display:grid;
  grid-template-columns:repeat(8,minmax(0,1fr));
  gap:5px;
}

.zzk-emoji-picker button{
  min-width:0;
  aspect-ratio:1;
  border:0;
  border-radius:10px;
  background:#f4f7fa;
  font-size:23px;
}

/* WIADOMOŚCI */
.zzk-msg{
  display:flex;
  flex-direction:column;
  max-width:84%;
}

.zzk-msg.mine{
  align-self:flex-end;
  align-items:flex-end;
}

.zzk-msg.theirs{
  align-self:flex-start;
}

.zzk-bubble{
  padding:9px 11px;
  border-radius:16px;
  background:#fff;
  box-shadow:0 2px 8px #17344c10;
  -webkit-user-select:none;
  user-select:none;
  -webkit-touch-callout:none;
  touch-action:none;
}

.zzk-msg.mine .zzk-bubble{
  background:var(--blue);
  color:#fff;
}

.zzk-bubble.retracted{
  background:#e8edf1!important;
  color:#788791!important;
  font-style:italic;
}

.zzk-bubble p{
  margin:0;
  white-space:pre-wrap;
  word-break:break-word;
}

.zzk-bubble>small{
  display:flex;
  justify-content:flex-end;
  align-items:center;
  gap:5px;
  margin-top:4px;
  font-size:9px;
  opacity:.78;
}

.zzk-bubble time{
  font-size:9px;
}

.zzk-sender{
  margin:0 0 2px 6px;
  color:#49667a;
  font-size:10px;
  font-weight:800;
}

.zzk-sender.mine-sender{
  margin-right:6px;
}

.zzk-receipt.read{
  color:#9cffbe;
}

.zzk-msg-img{
  display:block;
  max-width:min(280px,72vw);
  max-height:340px;
  margin-bottom:6px;
  border-radius:11px;
  object-fit:cover;
}

/* MENU WIADOMOŚCI */
.zzk-actions-overlay{
  position:fixed;
  inset:0;
  z-index:30000;
  display:flex;
  align-items:flex-end;
  padding:10px;
  background:transparent;
}

.zzk-actions-sheet{
  width:min(560px,100%);
  margin:0 auto;
  padding:8px;
  border-radius:20px;
  background:#fff;
  box-shadow:0 16px 55px #0003;
}

.zzk-actions-sheet button{
  width:100%;
  border:0;
  border-radius:12px;
  padding:15px;
  background:#fff;
  text-align:left;
  font:inherit;
  font-weight:800;
}

.zzk-actions-sheet button.danger{
  color:#b3213e;
}

/* PODGLĄD ZDJĘCIA */
.zzk-photo-viewer{
  position:fixed;
  inset:0;
  z-index:40000;
  display:grid;
  grid-template-rows:auto 1fr auto;
  place-items:center;
  padding:
    max(12px,env(safe-area-inset-top))
    12px
    max(14px,env(safe-area-inset-bottom));
  background:#07090ef2;
}

.zzk-photo-viewer>img{
  max-width:100%;
  max-height:76svh;
  object-fit:contain;
}

.zzk-photo-close{
  justify-self:end;
  width:44px;
  height:44px;
  border:0;
  border-radius:50%;
  background:#ffffff22;
  color:#fff;
  font-size:30px;
}

.zzk-photo-save{
  min-height:46px;
  padding:0 22px;
  border:0;
  border-radius:13px;
  background:#fff;
  color:#172536;
  font-weight:900;
}

/* Starszy iOS */
@supports not (height:100svh){
  body.zzk-chat-page{
    height:100vh;
  }
  .zzk-emoji-picker{
    max-height:40vh;
  }
}

/* Desktop */
@media(min-width:651px){
  body.zzk-chat-page{
    left:50%;
    width:min(760px,100%);
    transform:translateX(-50%);
    box-shadow:0 0 30px #17344c18;
  }
}
