
:root{
  --blue:#075d91;
  --blue2:#0b78ad;
  --text:#172536;
  --muted:#718391;
  --line:#e6edf1;
  --soft:#f2f6f8;
  --danger:#e94663;
}

*{
  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;
  overscroll-behavior:none;
  background:#fff;
  color:var(--text);
  font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Arial,sans-serif;
}

body{
  touch-action:none;
}

.chat-screen{
  position:fixed;
  inset:0;
  width:100%;
  height:100svh;
  max-height:100svh;
  overflow:hidden;

  display:grid;
  grid-template-rows:
    auto
    auto
    minmax(92px, 25svh)
    auto
    auto
    minmax(0, 1fr);

  gap:8px;
  padding:
    calc(10px + env(safe-area-inset-top))
    14px
    calc(8px + env(safe-area-inset-bottom));
  background:#fff;
}

.chat-header{
  min-width:0;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}

.chat-header-copy{
  min-width:0;
}

.eyebrow{
  display:block;
  margin:0 0 1px;
  color:#83939e;
  font-size:11px;
  line-height:1.1;
  font-weight:850;
  letter-spacing:.07em;
  text-transform:uppercase;
}

.chat-header h1{
  margin:0;
  color:var(--blue);
  font-size:25px;
  line-height:1.05;
  letter-spacing:-.02em;
}

.header-actions{
  flex:0 0 auto;
  display:flex;
  align-items:center;
  gap:7px;
}

.icon-btn,
.back-btn{
  text-decoration:none;
  display:grid;
  place-items:center;
  height:40px;
  border-radius:12px;
  font-weight:850;
  touch-action:manipulation;
}

.icon-btn{
  width:40px;
  background:#edf6fb;
  font-size:19px;
}

.back-btn{
  padding:0 12px;
  background:#f3a61b;
  color:#fff;
  font-size:12px;
}

.search-box{
  min-width:0;
  height:42px;
  display:flex;
  align-items:center;
  gap:8px;
  border:1px solid #e0e8ed;
  border-radius:13px;
  padding:0 12px;
  background:var(--soft);
  touch-action:manipulation;
}

.search-box>span{
  color:#6c8190;
  font-size:21px;
  line-height:1;
}

.search-box input{
  width:100%;
  min-width:0;
  height:100%;
  margin:0;
  padding:0;
  border:0;
  outline:0;
  background:transparent;
  color:var(--text);
  font:inherit;
  font-size:16px;
  -webkit-appearance:none;
  touch-action:manipulation;
}

.thread-pane,
.member-pane{
  min-width:0;
  min-height:0;
  overflow-y:auto;
  overflow-x:hidden;
  -webkit-overflow-scrolling:touch;
  overscroll-behavior:contain;
  touch-action:pan-y;
  scrollbar-width:thin;
}

.thread-pane{
  border:1px solid #e4edf2;
  border-radius:14px;
  background:#fff;
  padding:4px 8px 10px;
}

.member-pane{
  border-top:1px solid var(--line);
  padding:0 2px calc(28px + env(safe-area-inset-bottom)) 0;
  scroll-padding-bottom:28px;
}

.thread-pane *,
.member-pane *{
  touch-action:pan-y;
}

.conversation-row,
.member-row{
  color:var(--text);
  text-decoration:none;
  display:flex;
  align-items:center;
  gap:10px;
  min-width:0;
}

.conversation-row{
  min-height:58px;
  padding:8px 4px;
  border-bottom:1px solid #edf1f4;
}

.conversation-row:last-child{
  border-bottom:0;
}

.global-row{
  margin:2px 0 4px;
  padding:8px;
  border:1px solid #d8eaf4;
  border-radius:12px;
  background:#f5fbff;
}

.avatar{
  width:44px;
  height:44px;
  flex:0 0 44px;
  overflow:hidden;
  border-radius:50%;
  display:grid;
  place-items:center;
  background:linear-gradient(145deg,#dff1f9,#d9e6ff);
  color:var(--blue);
  font-size:13px;
  font-weight:900;
}

.avatar.has-photo{
  background:#e6edf1;
}

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

.global-avatar{
  font-size:21px;
  background:linear-gradient(145deg,#c9eaff,#e8dcff);
}

.conversation-copy{
  min-width:0;
  flex:1;
}

.conversation-top,
.conversation-bottom{
  min-width:0;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
}

.conversation-top strong{
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  font-size:14px;
}

.conversation-top time{
  flex:0 0 auto;
  color:#8b99a4;
  font-size:10px;
}

.conversation-bottom{
  margin-top:2px;
}

.conversation-bottom small{
  min-width:0;
  flex:1;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  color:#748793;
  font-size:11px;
}

.unread[hidden]{
  display:none!important;
}

.unread{
  min-width:20px;
  height:20px;
  padding:0 6px;
  border-radius:999px;
  display:grid;
  place-items:center;
  flex:0 0 auto;
  background:var(--danger);
  color:#fff;
  font-size:10px;
  font-style:normal;
  font-weight:900;
}

.members-head{
  min-width:0;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding-top:2px;
}

.members-head h2{
  margin:0;
  color:var(--blue);
  font-size:18px;
  line-height:1.05;
}

.members-icon{
  width:34px;
  height:34px;
  flex:0 0 34px;
  border-radius:50%;
  display:grid;
  place-items:center;
  background:#edf6fb;
  font-size:16px;
}

.member-search{
  height:40px;
}

.member-row{
  min-height:58px;
  margin:0;
  padding:7px 7px;
  border-bottom:1px solid #edf1f4;
}

.member-row:last-child{
  margin-bottom:22px;
  border-bottom:0;
}

.member-copy{
  min-width:0;
  flex:1;
}

.member-copy strong,
.member-copy small{
  display:block;
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.member-copy strong{
  font-size:14px;
}

.member-copy small{
  margin-top:2px;
  color:#7d8e99;
  font-size:11px;
}

.arrow{
  flex:0 0 auto;
  color:#9aabb5;
  font-size:24px;
  line-height:1;
}

.empty{
  margin:10px 4px;
  color:#83929c;
  font-size:12px;
}

/* większe ekrany */
@media(min-width:651px){
  html,body{
    position:static;
    height:auto;
    min-height:100%;
    overflow:auto;
    background:#eef3f6;
  }

  body{
    touch-action:auto;
  }

  .chat-screen{
    position:relative;
    inset:auto;
    width:min(760px,calc(100% - 32px));
    height:min(900px,calc(100vh - 32px));
    max-height:900px;
    margin:16px auto;
    border-radius:18px;
    box-shadow:0 8px 30px #14324b18;
  }
}

/* awaryjny fallback */
@supports not (height:100svh){
  .chat-screen{
    height:100vh;
    max-height:100vh;
  }
}
