/* Diskman Messenger — styles */
:root {
  --teal: #00b7c5; --teal-dark: #0097a3; --teal-soft: #e0f7f9;
  --navy: #1a355c; --navy-deep: #0f173f; --ink: #212934;
  --bg: #ffffff; --bg-2: #f0f2f5; --bg-3: #e4e6eb; --line: #e6e8ec;
  --text: #050505; --muted: #65676b; --danger: #d93025; --yellow: #FDD314;
  --bubble-them: #e9ebee; --bubble-me: var(--teal); --bubble-me-text: #fff;
  --sidebar-w: 360px; --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #18191a; --bg-2: #242526; --bg-3: #3a3b3c; --line: #2f3031;
    --text: #e4e6eb; --muted: #b0b3b8; --bubble-them: #3a3b3c; --teal-soft: #0e3a3e;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; position: fixed; inset: 0; width: 100%; }
body { font-family: 'Nunito Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.35; -webkit-font-smoothing: antialiased; overscroll-behavior: none; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--teal-dark); }
[hidden] { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 13px; } .center { text-align: center; } .spacer { flex: 1; }
.error { color: var(--danger); font-size: 14px; margin: 8px 0 0; }
.screen { position: fixed; top: 0; left: 0; right: 0; height: 100%; height: 100dvh; }
/* JS sets --vvh to the visual viewport height while the on-screen keyboard is open (iOS PWA) */
#app.kb { height: var(--vvh); top: var(--vvt, 0px); }

/* ---------- buttons / avatars ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px; border-radius: 12px; font-weight: 700; background: var(--bg-3); color: var(--text); }
.btn.primary { background: var(--teal); color: #fff; } .btn.primary:hover { background: var(--teal-dark); }
.btn.danger { background: #fde8e6; color: var(--danger); } .btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.block { width: 100%; } .btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: var(--teal-dark); flex: none; }
.icon-btn:hover { background: var(--bg-2); }
.icon-btn svg { width: 22px; height: 22px; fill: currentColor; }
.avatar { position: relative; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--navy); color: #fff; font-weight: 800; overflow: visible; flex: none; letter-spacing: .5px; }
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.avatar.sm { width: 36px; height: 36px; font-size: 13px; } .avatar.md { width: 44px; height: 44px; font-size: 15px; } .avatar.lg { width: 56px; height: 56px; font-size: 20px; } .avatar.xl { width: 96px; height: 96px; font-size: 34px; } .avatar.xs { width: 28px; height: 28px; font-size: 11px; } .avatar.xxs { width: 16px; height: 16px; font-size: 8px; }
.avatar .dot { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%; background: #31a24c; border: 2px solid var(--bg); display: none; }
.avatar.online .dot { display: block; }
.avatar.group { background: var(--teal-dark); }
.avatar-btn { border-radius: 50%; }

/* ---------- auth ---------- */
#auth { background: linear-gradient(160deg, var(--navy) 0%, var(--navy-deep) 100%); overflow: auto; }
.auth-wrap { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: max(24px, var(--safe-top)) 16px calc(56px + var(--safe-bottom)); }
.auth-card { width: 100%; max-width: 400px; background: var(--bg); border-radius: 20px; padding: 28px 24px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.brand { text-align: center; margin-bottom: 20px; } .brand-logo { width: 220px; max-width: 80%; height: auto; margin-bottom: 8px; }
.brand h1 { margin: 10px 0 4px; font-size: 24px; font-weight: 800; color: var(--navy); } @media (prefers-color-scheme: dark) { .brand h1 { color: #fff; } }
.brand p { margin: 0; }
.auth-form h2 { font-size: 18px; margin: 0 0 4px; }
.auth-form label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin: 14px 0 0; }
.auth-form input, .field input, .field textarea { display: block; width: 100%; margin-top: 6px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-2); outline: none; font-size: 16px; }
.auth-form input:focus, .field input:focus { border-color: var(--teal); background: var(--bg); }
.auth-form .btn { width: 100%; margin-top: 20px; }
.auth-form .center { margin: 16px 0 0; }
#sidebar .powered { margin-top: auto; }
.powered { margin: 0; padding: 6px 12px calc(4px + var(--safe-bottom) * 0.45); text-align: center; font-size: 11px; line-height: 1.2; color: var(--muted); border-top: 1px solid var(--line); flex: none; }   /* sits just above the iPhone home indicator, not above the whole safe area */
.powered a { color: var(--teal); font-weight: 800; text-decoration: none; }
.powered a:hover { text-decoration: underline; }
.auth-foot { position: fixed; left: 0; right: 0; bottom: 0; margin: 0; border-top: 0; color: rgba(255,255,255,.7); background: linear-gradient(to top, rgba(15,23,63,.9), rgba(15,23,63,0)); padding-bottom: calc(4px + var(--safe-bottom) * 0.45); }
.invite-banner { background: var(--teal-soft); border-radius: 12px; padding: 12px 14px; font-size: 14px; }
.invite-banner b { color: var(--teal-dark); }

/* ---------- app layout ---------- */
#app { display: flex; background: var(--bg); }
#sidebar { width: 100%; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--bg); }
#main { flex: 1; display: none; flex-direction: column; min-width: 0; }
@media (min-width: 768px) {
  #sidebar { width: var(--sidebar-w); }
  #main { display: flex; }
  .back { display: none; }
}
#app.show-conv #sidebar { display: none; } #app.show-conv #main { display: flex; }
@media (min-width: 768px) { #app.show-conv #sidebar { display: flex; } }
.side-head { display: flex; align-items: center; gap: 6px; padding: calc(10px + var(--safe-top)) 10px 8px 14px; }
.side-head h1 { font-size: 24px; font-weight: 800; margin: 0 0 0 6px; }
.search-wrap { padding: 4px 14px 10px; }
.search-wrap input { width: 100%; padding: 10px 14px; border-radius: 20px; border: 0; background: var(--bg-2); outline: none; font-size: 15px; }
.list-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.chat-list, #people-results { padding: 0 8px 12px; }
.chat-item { display: flex; align-items: center; gap: 12px; padding: 10px 10px; border-radius: 12px; width: 100%; text-align: left; }
.chat-item:hover, .chat-item.active { background: var(--bg-2); }
.chat-item .txt { flex: 1; min-width: 0; }
.chat-item .row1 { display: flex; align-items: baseline; gap: 8px; }
.chat-item .name { font-weight: 700; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .time { font-size: 12px; color: var(--muted); flex: none; }
.chat-item .snip { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; display: flex; align-items: center; gap: 6px; }
.chat-item .snip span { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.chat-item.unread .name, .chat-item.unread .snip { color: var(--text); font-weight: 800; }
.chat-item .badge { min-width: 10px; height: 10px; border-radius: 50%; background: var(--teal); flex: none; }
.chat-item .seen-mini { width: 16px; height: 16px; }
.list-empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.list-empty .btn { margin-top: 8px; }
.install-hint { margin: 0 14px 10px; padding: 10px 12px; border-radius: 12px; background: var(--teal-soft); font-size: 13px; display: flex; gap: 10px; align-items: center; }
.install-hint b { display: block; }
.empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 20px; }
.empty-state .empty-icon { width: 84px; border-radius: 22px; margin-bottom: 8px; } .empty-state .empty-logo { width: 200px; margin: 6px 0 4px; }
.empty-state h2 { margin: 4px 0; }

/* ---------- conversation ---------- */
#conv { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.conv-head { display: flex; align-items: center; gap: 10px; padding: calc(6px + var(--safe-top)) 8px 6px; border-bottom: 1px solid var(--line); background: var(--bg); }
.conv-title { min-width: 0; } .conv-title .name { font-weight: 800; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.messages { flex: 1; overflow-y: auto; padding: 12px 12px 4px; display: flex; flex-direction: column; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.messages > :first-child { margin-top: auto; }   /* short conversations sit against the composer, not the top */
.msg-loading { text-align: center; color: var(--muted); font-size: 12px; padding: 8px; }
.day-sep { text-align: center; font-size: 12px; color: var(--muted); font-weight: 700; margin: 14px 0 8px; }
.sysmsg { text-align: center; font-size: 12px; color: var(--muted); margin: 8px 0; }
.mrow { display: flex; align-items: flex-end; gap: 8px; margin: 1px 0; max-width: 100%; }
.mrow.me { flex-direction: row-reverse; }
.mrow .av { width: 28px; flex: none; }
.mrow .av .avatar { visibility: hidden; } .mrow.last .av .avatar { visibility: visible; }
.mrow.me .av { display: none; }
.mcol { max-width: min(75%, 560px); display: flex; flex-direction: column; align-items: flex-start; position: relative; }
.mrow.me .mcol { align-items: flex-end; }
.sender { font-size: 11px; color: var(--muted); margin: 6px 0 2px 12px; }
.bubble { position: relative; padding: 8px 12px; border-radius: var(--radius); background: var(--bubble-them); color: var(--text); word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap; max-width: 100%; }
.mrow.me .bubble { background: var(--bubble-me); color: var(--bubble-me-text); }
.mrow.me .bubble a { color: #fff; }
.mrow.them.mid .bubble, .mrow.them.last .bubble { border-top-left-radius: 6px; } .mrow.them.first .bubble, .mrow.them.mid .bubble { border-bottom-left-radius: 6px; }
.mrow.me.mid .bubble, .mrow.me.last .bubble { border-top-right-radius: 6px; } .mrow.me.first .bubble, .mrow.me.mid .bubble { border-bottom-right-radius: 6px; }
.bubble.deleted { font-style: italic; color: var(--muted); background: transparent; border: 1px solid var(--line); }
.mrow.me .bubble.deleted { color: var(--muted); }
.bubble.img { padding: 0; background: transparent; overflow: hidden; border-radius: 16px; }
.bubble.img img { display: block; max-width: 100%; max-height: 360px; border-radius: 16px; cursor: zoom-in; }
.bubble.emoji-only { background: transparent !important; font-size: 40px; padding: 2px 4px; line-height: 1.1; }
.bubble .file { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.bubble .file .fi { width: 36px; height: 36px; border-radius: 10px; background: rgba(0,0,0,.12); display: flex; align-items: center; justify-content: center; font-size: 18px; }
.bubble .file .fn { font-weight: 700; } .bubble .file .fs { font-size: 12px; opacity: .8; }
.replyq { font-size: 12px; opacity: .8; border-left: 3px solid rgba(0,0,0,.2); padding: 2px 8px; margin-bottom: 6px; border-radius: 4px; background: rgba(0,0,0,.05); }
.mrow.me .replyq { border-left-color: rgba(255,255,255,.6); background: rgba(255,255,255,.15); }
.replyq b { display: block; font-size: 11px; }
.reacts { display: flex; gap: 2px; margin-top: -8px; margin-left: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 1px 6px; font-size: 13px; z-index: 1; box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.mrow.me .reacts { margin-left: 0; margin-right: 8px; }
.reacts .n { font-size: 11px; color: var(--muted); margin-left: 2px; }
.mactions { display: none; position: absolute; top: 50%; transform: translateY(-50%); gap: 2px; }
.mrow.them .mactions { left: 100%; margin-left: 4px; } .mrow.me .mactions { right: 100%; margin-right: 4px; }
@media (hover: hover) { .mcol:hover .mactions { display: flex; } }
.mactions button { width: 28px; height: 28px; border-radius: 50%; color: var(--muted); font-size: 15px; display: flex; align-items: center; justify-content: center; }
.mactions button:hover { background: var(--bg-2); }
.mtime { font-size: 11px; color: var(--muted); margin: 2px 8px; display: none; } .mcol.show-time .mtime { display: block; }
.seen-row { display: flex; justify-content: flex-end; gap: 2px; margin: 2px 0 4px; min-height: 16px; }
.seen-row .avatar { border: 1px solid var(--bg); }
.status-txt { font-size: 11px; color: var(--muted); text-align: right; margin: 2px 6px 4px; }
.typing-row { padding: 2px 12px 6px 48px; font-size: 12px; color: var(--muted); }
.typing-row .dots span { display: inline-block; width: 6px; height: 6px; margin-right: 3px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing-row .dots span:nth-child(2) { animation-delay: .2s; } .typing-row .dots span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }
.reply-bar, .upload-bar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-top: 1px solid var(--line); font-size: 13px; background: var(--bg-2); }
.reply-bar .txt, .upload-bar .txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-bar b { color: var(--teal-dark); }
.composer { display: flex; align-items: flex-end; gap: 6px; padding: 10px 8px calc(10px + var(--safe-bottom)); border-top: 1px solid var(--line); background: var(--bg); }
.input-wrap { flex: 1; position: relative; display: flex; align-items: flex-end; background: var(--bg-2); border: 2px solid var(--line); border-radius: 24px; padding: 4px 4px 4px 16px; min-height: 48px; transition: border-color .15s, box-shadow .15s; }
.input-wrap:focus-within { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(0,183,197,.18); background: var(--bg); }
@media (prefers-color-scheme: dark) { .input-wrap { background: #2b2c2e; border-color: #4a4b4d; } .input-wrap:focus-within { background: #1e1f21; } }
.input-wrap textarea { flex: 1; resize: none; border: 0; background: transparent; outline: none; max-height: 140px; padding: 9px 0; font-size: 17px; line-height: 1.3; }
.input-wrap textarea::placeholder { color: var(--muted); opacity: 1; }
.emoji-btn { width: 36px; height: 36px; font-size: 20px; }
.emoji-pop { position: absolute; right: 0; bottom: 48px; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.18); padding: 8px; display: grid; grid-template-columns: repeat(8, 34px); gap: 2px; z-index: 5; }
.emoji-pop button { width: 34px; height: 34px; font-size: 22px; border-radius: 8px; } .emoji-pop button:hover { background: var(--bg-2); }
.send-btn { width: 46px; height: 46px; border-radius: 50%; background: var(--teal); color: #fff; display: inline-flex; align-items: center; justify-content: center; flex: none; transition: opacity .15s, transform .1s; margin-bottom: 2px; }
.send-btn svg { width: 20px; height: 20px; fill: currentColor; margin-left: 2px; }
.send-btn:disabled { opacity: .35; cursor: default; } .send-btn:not(:disabled):active { transform: scale(.92); }

/* ---------- modal / sheet / lightbox / toast ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
@media (min-width: 600px) { .modal { align-items: center; } }
.modal-card { width: 100%; max-width: 480px; max-height: 92vh; background: var(--bg); border-radius: 20px 20px 0 0; display: flex; flex-direction: column; animation: up .18s ease-out; }
@media (max-width: 599px) { .modal-card { max-height: 100dvh; height: 100dvh; border-radius: 0; } }
@media (min-width: 600px) { .modal-card { border-radius: 20px; } }
@keyframes up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-card header { display: flex; align-items: center; gap: 8px; padding: calc(10px + var(--safe-top)) 10px 10px 20px; border-bottom: 1px solid var(--line); flex: none; }
.modal-card header .close-btn { width: 44px; height: 44px; border-radius: 50%; background: var(--bg-2); color: var(--text); font-size: 20px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.modal-card header .close-btn:active { background: var(--bg-3); }
.modal-card header .done-btn { padding: 8px 14px; border-radius: 10px; font-weight: 800; color: var(--teal-dark); }
.modal-card header h2 { flex: 1; font-size: 18px; margin: 0; }
.modal-body { overflow-y: auto; padding: 16px 20px calc(20px + var(--safe-bottom)); }
.field { margin-bottom: 14px; } .field label { font-size: 13px; font-weight: 700; color: var(--muted); }
.field .row { display: flex; gap: 8px; align-items: center; }
.menu-item { display: flex; align-items: center; gap: 14px; width: 100%; padding: 12px 6px; border-radius: 12px; text-align: left; font-size: 16px; }
.menu-item:hover { background: var(--bg-2); } .menu-item .ic { width: 36px; height: 36px; border-radius: 50%; background: var(--bg-2); display: flex; align-items: center; justify-content: center; font-size: 18px; }
.menu-item.danger { color: var(--danger); }
.person { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 6px; border-radius: 12px; text-align: left; }
.person:hover { background: var(--bg-2); } .person .pn { flex: 1; min-width: 0; } .person .pn b { display: block; } .person .pn span { font-size: 12px; color: var(--muted); }
.person input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--teal); }
.pill { display: inline-block; padding: 2px 8px; border-radius: 10px; background: var(--bg-2); font-size: 12px; color: var(--muted); }
.pill.on { background: var(--teal-soft); color: var(--teal-dark); }
.invite-card { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; }
.invite-card .url { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; word-break: break-all; background: var(--bg-2); padding: 8px 10px; border-radius: 8px; margin: 8px 0; }
.invite-card .meta { font-size: 12px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.invite-card .acts { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.section-title { font-size: 13px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin: 18px 0 8px; }
.profile-top { text-align: center; padding: 6px 0 14px; } .profile-top .avatar { margin: 0 auto 8px; } .profile-top h3 { margin: 4px 0 0; }
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.sheet-card { width: 100%; max-width: 480px; background: var(--bg); border-radius: 20px 20px 0 0; padding: 10px 10px calc(14px + var(--safe-bottom)); animation: up .15s ease-out; }
.sheet-card .sheet-close { display: block; width: 100%; margin-top: 6px; padding: 12px; border-radius: 12px; background: var(--bg-2); font-weight: 800; text-align: center; }
.sheet-card .reactrow { display: flex; justify-content: space-around; padding: 6px 4px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.sheet-card .reactrow button { font-size: 30px; width: 46px; height: 46px; border-radius: 50%; } .sheet-card .reactrow button.on { background: var(--teal-soft); }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 70; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; }
.lightbox img { max-width: 96vw; max-height: 84vh; border-radius: 6px; } .lightbox .btn { color: #fff; border-color: rgba(255,255,255,.4); }
.toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 100; box-shadow: 0 6px 20px rgba(0,0,0,.3); max-width: 90vw; }
.notice { background: var(--teal-soft); padding: 10px 12px; border-radius: 12px; font-size: 13px; margin-bottom: 12px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; } .table td, .table th { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
label.person { cursor: pointer; } label.person input[type=checkbox] { margin-right: 4px; }
