/* Ibsby messages and notifications (phases 5 and 6). Uses the tokens from app.css; kept in its own
   file so changes to the shared styles stay separate. */

/* ---------- Messages: list + chat ---------- */
.chat-wrap{display:grid;grid-template-columns:minmax(260px,330px) minmax(0,1fr);gap:16px;align-items:start}
.chat-list{padding:0;position:sticky;top:76px;max-height:calc(100vh - 124px);max-height:calc(100dvh - 124px);overflow:auto}
.chat-list-head{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:16px 16px 10px;position:sticky;top:0;background:var(--card);z-index:1}
.chat-list-head h1{margin:0;font-size:24px}
.chat-empty{padding:4px 16px 16px}
.chat-rows{padding:0 8px 8px}
.chat-row{display:flex;align-items:center;gap:12px;padding:10px;border-radius:var(--r-ctl);color:var(--ink);font-weight:400}
.chat-row:hover{background:var(--tint);text-decoration:none}
.chat-row.on{background:var(--redsoft)}
.chat-row .tx{flex:1;display:grid;gap:1px}
.chat-row .tx>span:not(.top-line):not(.prev){font-size:14px;color:var(--soft)}
.top-line{display:flex;align-items:baseline;gap:8px}
.top-line b{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:700}
.top-line time{font-size:12px;color:var(--soft);flex:none}
.prev{font-size:14px;color:var(--soft);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.prev .kind{font-size:11px;font-weight:800;text-transform:uppercase;letter-spacing:.03em;background:var(--tint);border-radius:999px;padding:0 6px;margin-right:2px}
.chat-row.unread .top-line b{font-weight:800}
.chat-row.unread .prev{color:var(--ink);font-weight:700}
.chat-row .badge{flex:none}
.muted-ic{color:var(--soft);opacity:.6;display:grid}
.muted-ic .ic{width:16px;height:16px}
.group-av{position:relative;flex:none;display:inline-block}
.group-av .av{position:absolute;border:2px solid var(--card);box-sizing:content-box}
.group-av .av:first-child{top:0;left:0}
.group-av .av:nth-child(2){right:-2px;bottom:-2px}
.group-av .av:only-child{inset:0;width:100%!important;height:100%!important;border:0}
.group-av .av .ic{width:55%;height:55%}

.chat-pane{padding:0;display:flex;flex-direction:column;min-height:calc(100vh - 124px);min-height:calc(100dvh - 124px)}
.chat-pick{margin:auto;text-align:center;padding:40px 24px;max-width:360px}
.chat-pick-ic{display:inline-grid;place-items:center;width:64px;height:64px;border-radius:50%;background:var(--redsoft);color:var(--red);margin-bottom:12px}
.chat-pick-ic .ic{width:30px;height:30px}
.chat-head{display:flex;align-items:center;gap:12px;padding:12px 16px;border-bottom:1px solid var(--line);position:sticky;top:59px;background:var(--card);z-index:2;border-radius:var(--r-card) var(--r-card) 0 0}
.chat-head .who{flex:1}
.chat-head .who b a{color:var(--ink)}
.chat-head .who span{font-size:13px;color:var(--soft)}
.chat-back{display:none;font:600 32px/1 Fredoka,sans-serif;color:var(--ink);padding:0 6px 4px 0}
.chat-back:hover{text-decoration:none}

.thread{flex:1;padding:16px 16px 8px;display:flex;flex-direction:column}
.msgs{display:flex;flex-direction:column;gap:2px}
.earlier{align-self:center;font-size:14px;margin-bottom:12px}
.chat-start{text-align:center;margin:auto 0 16px;padding-top:24px;display:grid;justify-items:center;gap:4px}
.chat-start p{margin:0}
.msg-day{display:flex;align-items:center;gap:12px;color:var(--soft);font-size:12px;font-weight:800;margin:14px 0 8px;text-transform:uppercase;letter-spacing:.04em}
.msg-day::before,.msg-day::after{content:"";flex:1;height:1px;background:var(--line)}
.msg-note{align-self:center;text-align:center;font-size:13px;color:var(--soft);background:var(--tint);border-radius:999px;padding:4px 12px;margin:8px 0;max-width:90%}
.msg{display:flex;gap:8px;align-items:flex-end;max-width:min(78%,560px)}
.msg.first{margin-top:8px}
.msg.mine{align-self:flex-end;flex-direction:row-reverse}
.msg-av{width:32px;flex:none}
.msg-main{display:grid;gap:3px;min-width:0}
.msg.mine .msg-main{justify-items:end}
.msg-who{font-size:13px;font-weight:700;padding:0 12px;color:var(--soft)}
.msg-who a{color:var(--soft)}
.bubble{background:var(--tint);border-radius:18px;padding:8px 14px;overflow-wrap:anywhere;font-size:15px;line-height:1.45}
.msg.theirs .bubble{border-bottom-left-radius:6px}
.msg.mine .bubble{background:var(--red);color:#fff;border-bottom-right-radius:6px}
.msg.mine .bubble a{color:#fff;text-decoration:underline}
.bubble.gone{background:none!important;border:1px dashed var(--line);color:var(--soft)!important;font-style:italic}
.msg-meta{display:flex;gap:8px;align-items:center;font-size:12px;color:var(--soft);padding:0 8px;height:0;overflow:hidden;transition:height .12s}
.msg:hover .msg-meta,.msg:focus-within .msg-meta,.msg:target .msg-meta,.msg.last .msg-meta{height:18px}
.msg-del button{font-size:12px}
.msg-photos{display:grid;gap:3px;border-radius:14px;overflow:hidden;width:min(320px,62vw)}
.msg-photos.n1 img{max-height:340px;width:100%;height:auto;object-fit:cover;display:block}
.msg-photos.n2,.msg-photos.n4{grid-template-columns:1fr 1fr}
.msg-photos.n3{grid-template-columns:1fr 1fr 1fr}
.msg-photos:not(.n1) .ph{aspect-ratio:1}
.msg-photos:not(.n1) img{width:100%;height:100%;object-fit:cover;display:block}
.seen{align-self:flex-end;font-size:12px;color:var(--soft);margin:4px 4px 0;font-weight:700}
.newmsgs{position:sticky;bottom:84px;align-self:center;border:0;background:var(--blue);color:#fff;font:800 14px "Nunito Sans",sans-serif;border-radius:999px;padding:6px 14px;cursor:pointer;box-shadow:0 4px 14px rgba(0,0,0,.15);z-index:2}

.chat-compose{position:sticky;bottom:0;background:var(--card);border-top:1px solid var(--line);padding:10px 12px;border-radius:0 0 var(--r-card) var(--r-card);z-index:2}
.chat-compose-row{display:flex;gap:8px;align-items:flex-end}
.chat-compose textarea{flex:1;resize:none;background:var(--tint);border:1.5px solid transparent;border-radius:22px;padding:10px 16px;min-height:44px;max-height:180px;font-size:16px;line-height:1.4}
.chat-compose textarea:focus{background:var(--card);border-color:var(--blue)}
.chat-compose .cbtn{padding:10px 8px}
.chat-compose .send{border-radius:50%;width:44px;height:44px;padding:0;flex:none}
.chat-compose .send .ic{width:20px;height:20px}
.chat-compose .compose-previews{padding:0 0 10px}
.chat-error{color:var(--red-ink);font-weight:700;font-size:14px;margin:0 0 8px}
.chat-note{margin:0;padding:14px 16px;border-top:1px solid var(--line);color:var(--soft);text-align:center;font-weight:600}

/* Chat details and new message */
.chat-info-head{display:flex;gap:16px;align-items:center;margin-bottom:8px}
.chat-info-head h1{margin:0}
.opt-list{display:grid}
.opt{display:flex;align-items:center;gap:12px;padding:12px 0;border-top:1px solid var(--line);margin:0}
.opt:first-child{border-top:0}
.opt .tx{flex:1;display:grid;gap:2px}
.people-pick{display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:8px;margin-top:4px}
.person-opt{display:flex!important;align-items:center;gap:10px;border:1.5px solid var(--line);border-radius:var(--r-ctl);padding:8px 10px;margin:0!important;cursor:pointer;font-weight:400!important}
.person-opt:has(input:checked){border-color:var(--red);background:color-mix(in srgb,var(--redsoft) 45%,var(--card))}
.person-opt input{width:18px;height:18px;margin:0;accent-color:var(--red);flex:none}
.person-opt .tx{display:grid;line-height:1.25}
.person-opt .tx span{font-size:13px;color:var(--soft)}
.people-suggest{display:flex;flex-wrap:wrap;gap:6px}
.people-suggest button{display:inline-flex;align-items:center;gap:6px;border:1px solid var(--line);background:var(--card);border-radius:999px;padding:4px 10px 4px 4px;font:700 14px "Nunito Sans",sans-serif;color:var(--ink);cursor:pointer}
.people-suggest button:hover{border-color:var(--blue)}

/* ---------- Notifications ---------- */
.notif-card{padding-bottom:12px}
.notif-list{margin:0 -10px}
.notif{display:flex;align-items:center;gap:12px;padding:10px;border-radius:var(--r-ctl);color:var(--ink);font-weight:400}
.notif:hover{background:var(--tint);text-decoration:none}
.notif.unread{background:color-mix(in srgb,var(--bluesoft) 55%,var(--card))}
.notif.unread:hover{background:var(--bluesoft)}
.notif-av{position:relative;flex:none}
.notif-ic{position:absolute;right:-4px;bottom:-4px;width:22px;height:22px;border-radius:50%;display:grid;place-items:center;background:var(--blue);color:#fff;border:2px solid var(--card)}
.notif-ic .ic{width:12px;height:12px;stroke-width:2.6}
.notif-ic.t-like{background:var(--red)}
.notif-ic.t-like .ic{fill:#fff}
.notif-ic.t-request_approved,.notif-ic.t-member_joined{background:var(--green)}
.notif-ic.t-role_changed,.notif-ic.t-community_invite{background:var(--sun);color:#241c17}
.notif .tx{flex:1;display:grid;gap:2px}
.notif .line{overflow-wrap:anywhere;line-height:1.4}
.notif .when{font-size:13px;color:var(--soft)}
.notif .dot{width:10px;height:10px;border-radius:50%;background:var(--blue);flex:none}

/* Email switches */
.switches{display:grid;margin-top:8px}
.switch-row{display:flex!important;align-items:center;gap:16px;padding:14px 0;border-top:1px solid var(--line);margin:0!important;cursor:pointer;font-weight:400!important}
.switch-row:first-child{border-top:0}
.switch-row .tx{flex:1;display:grid;gap:2px}
.switch-row .tx b{font-weight:800}
input.switch{appearance:none;-webkit-appearance:none;width:46px;height:28px;border-radius:999px;background:var(--line);position:relative;cursor:pointer;flex:none;margin:0;transition:background .15s}
input.switch::after{content:"";position:absolute;top:3px;left:3px;width:22px;height:22px;border-radius:50%;background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.25);transition:transform .15s}
input.switch:checked{background:var(--green)}
input.switch:checked::after{transform:translateX(18px)}
input.switch:focus-visible{outline:3px solid var(--blue);outline-offset:2px}

[hidden]{display:none!important}

@media (max-width:900px){
  .chat-wrap{grid-template-columns:minmax(0,1fr)}
  .chat-wrap.has-chat .chat-list{display:none}
  .chat-wrap:not(.has-chat) .chat-pane{display:none}
  .chat-list{position:static;max-height:none}
  .chat-back{display:block}
}
@media (max-width:600px){
  body:has(.chat-wrap.has-chat) .tabbar{display:none}
  main:has(.chat-wrap.has-chat){padding:0}
  .chat-wrap.has-chat .chat-pane{border-radius:0;border:0;min-height:calc(100dvh - 55px)}
  .chat-head{top:55px;border-radius:0;padding:10px 12px}
  .chat-compose{border-radius:0;padding:8px 8px max(8px,env(safe-area-inset-bottom))}
  .msg{max-width:86%}
  .thread{padding:12px 10px 8px}
  .people-pick{grid-template-columns:1fr}
  .newmsgs{bottom:76px}
}
@media (prefers-reduced-motion:reduce){.msg-meta,input.switch,input.switch::after{transition:none}}
