/* Zuckers Messenger - mobile/web app (talk.zuckers.com). Phone first, two columns on wide screens. */
:root {
  --brand: #4A154B;
  --brand-2: #611f69;
  --brand-soft: #F4EDF4;
  --ink: #1D1C1D;
  --ink-2: #454245;
  --muted: #616061;
  --line: #E6E4E6;
  --bg: #FFFFFF;
  --bg-2: #F7F6F7;
  --green: #007A5A;
  --online: #2BAC76;
  --away: #E8A317;
  --busy: #E01E5A;
  --link: #1264A3;
  --read: #1D9BD1;
  --danger: #C4002B;
  --radius: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); overscroll-behavior: none; }
body { -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; font-size: 16px; color: var(--ink); }
a { color: var(--link); }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.i { width: 22px; height: 22px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.iconbtn { width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent; display: inline-flex; align-items: center; justify-content: center; }
.iconbtn:active { background: rgba(0,0,0,.08); }

/* ---------- sign in ---------- */
.login { min-height: 100dvh; display: flex; flex-direction: column; background: var(--brand); }
.login .hero { flex: 1; min-height: 220px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: #fff; padding: calc(32px + var(--safe-top)) 24px 24px; text-align: center; }
.login .logo { width: 72px; height: 72px; border-radius: 18px; background: #fff; color: var(--brand); display: flex; align-items: center; justify-content: center; }
.login .logo svg { width: 38px; height: 38px; }
.login h1 { margin: 0; font-size: 26px; }
.login .hero p { margin: 0; opacity: .85; font-size: 15px; }
.login form { background: #fff; border-radius: 24px 24px 0 0; padding: 28px 24px calc(28px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 480px; margin: 0 auto; }
.login h2 { margin: 0; font-size: 20px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
.field input { height: 48px; border: 1px solid #BBB; border-radius: 10px; padding: 0 14px; font-weight: 400; background: #fff; }
.field input:focus { outline: 2px solid var(--link); outline-offset: 0; border-color: transparent; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 14px; }
.check input { width: 20px; height: 20px; accent-color: var(--green); }
.btn { height: 48px; border: 0; border-radius: 10px; padding: 0 18px; font-weight: 700; font-size: 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn.primary { background: var(--green); color: #fff; }
.btn.primary:disabled { opacity: .6; }
.btn.ghost { background: var(--bg-2); color: var(--ink); }
.btn.danger { background: #FDECEF; color: var(--danger); }
.err { color: var(--danger); font-size: 14px; min-height: 0; }
.err:empty { display: none; }
.tip { display: flex; gap: 10px; align-items: center; background: #F4EDE4; border-radius: 10px; padding: 12px; font-size: 13px; color: var(--ink-2); }

/* ---------- layout ---------- */
.shell { height: 100dvh; display: flex; overflow: hidden; }
.side { width: 100%; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.pane { display: none; flex: 1; min-width: 0; flex-direction: column; background: var(--bg-2); }
.shell.open .side { display: none; }
.shell.open .pane { display: flex; }
@media (min-width: 900px) {
  .side { width: 360px; flex-shrink: 0; border-right: 1px solid var(--line); }
  .pane { display: flex; }
  .shell.open .side { display: flex; }
}

.topbar { background: var(--brand); color: #fff; padding: calc(10px + var(--safe-top)) 12px 12px; display: flex; flex-direction: column; gap: 10px; }
.topbar .row { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.topbar .title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar .title b { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .title span { font-size: 12px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .iconbtn { color: #fff; background: rgba(255,255,255,.12); }
.search { display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.16); border-radius: 10px; padding: 0 12px; height: 40px; }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; color: #fff; outline: none; }
.search input::placeholder { color: rgba(255,255,255,.75); }
.search svg.i { width: 16px; height: 16px; }

.chips { display: flex; gap: 8px; padding: 10px 12px 4px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { height: 32px; padding: 0 14px; border-radius: 16px; border: 1px solid #DDD; background: #fff; font-size: 13px; white-space: nowrap; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); font-weight: 600; }

.list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.item { width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 0; background: transparent; text-align: left; min-height: 68px; }
.item:active, .item.cur { background: var(--brand-soft); }
.item .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.item .l1, .item .l2 { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.item .name { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .time { font-size: 12px; color: var(--muted); flex-shrink: 0; }
.item .prev { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item.unread .name, .item.unread .prev { color: var(--ink); font-weight: 700; }
.item.unread .time { color: var(--brand); font-weight: 700; }
.badge { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--busy); color: #fff; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.section { padding: 16px 16px 6px; font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.empty { padding: 40px 24px; text-align: center; color: var(--muted); font-size: 15px; }

.av { position: relative; width: 46px; height: 46px; border-radius: 10px; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; flex-shrink: 0; }
.av.sm { width: 36px; height: 36px; border-radius: 8px; font-size: 13px; }
.av .dot { position: absolute; right: -3px; bottom: -3px; width: 13px; height: 13px; border-radius: 50%; border: 2px solid #fff; background: #fff; box-shadow: inset 0 0 0 2px #9E9E9E; }
.dot.online { background: var(--online); box-shadow: none; }
.dot.away { background: var(--away); box-shadow: none; }
.dot.busy { background: var(--busy); box-shadow: none; }
.topbar .av .dot { border-color: var(--brand); }

.tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--line); padding: 4px 8px calc(6px + var(--safe-bottom)); background: #fff; }
.tab { border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; font-size: 11px; color: var(--muted); position: relative; min-height: 50px; }
.tab.on { color: var(--brand); font-weight: 700; }
.tab .badge { position: absolute; top: 2px; left: calc(50% + 6px); min-width: 18px; height: 18px; font-size: 11px; padding: 0 5px; }

/* ---------- conversation ---------- */
.chead { background: var(--brand); color: #fff; padding: calc(8px + var(--safe-top)) 6px 8px; display: flex; align-items: center; gap: 8px; min-height: 60px; }
.chead .iconbtn { color: #fff; }
.chead .title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chead .title b { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chead .title span { font-size: 12px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (min-width: 900px) { .chead .back { display: none; } .chead { padding-left: 14px; } }

.msgs { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; }
.more { align-self: center; margin: 4px 0 8px; height: 34px; border-radius: 17px; border: 1px solid var(--line); background: #fff; padding: 0 14px; font-size: 13px; color: var(--muted); }
.day { align-self: center; margin: 10px 0 6px; font-size: 12px; color: var(--muted); background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 3px 12px; }
.sys { align-self: center; max-width: 94%; margin: 6px 0; display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--ink-2); background: #EFE8F0; border-radius: 10px; padding: 8px 12px; line-height: 1.4; }
.sys svg.i { width: 16px; height: 16px; margin-top: 1px; }
.m { display: flex; flex-direction: column; align-items: flex-start; max-width: 84%; }
.m.me { align-self: flex-end; align-items: flex-end; }
.m.first { margin-top: 8px; }
.m .who { font-size: 12px; font-weight: 700; color: var(--ink-2); margin: 0 0 3px 6px; }
.bubble { background: #fff; border: 1px solid var(--line); border-radius: 16px 16px 16px 4px; padding: 8px 12px; font-size: var(--fs, 15px); line-height: 1.42; overflow-wrap: anywhere; white-space: pre-wrap; }
.m.me .bubble { background: var(--brand); color: #fff; border-color: var(--brand); border-radius: 16px 16px 4px 16px; }
.m.me .bubble a { color: #fff; }
.mention { background: #FFF3C4; color: #6B4E00; border-radius: 4px; padding: 0 2px; font-weight: 600; }
.m.me .mention { background: rgba(255,255,255,.22); color: #fff; }
.meta { font-size: 11px; color: var(--muted); margin: 3px 6px 0; display: flex; gap: 6px; align-items: center; }
.ticks { font-weight: 700; color: #9E9E9E; letter-spacing: -2px; }
.ticks.read { color: var(--read); }
.reacts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.react { font-size: 12px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 1px 7px; }
.react.mine { border-color: var(--read); color: var(--link); }
.replies { font-size: 12px; color: var(--link); margin: 3px 6px 0; font-weight: 600; }
.file { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 8px 12px 8px 8px; max-width: 100%; text-align: left; min-height: 56px; }
.m.me .file { border-color: #D8C4D9; }
.file .ext { width: 40px; height: 40px; border-radius: 8px; background: var(--busy); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; text-transform: uppercase; }
.file .fn { display: flex; flex-direction: column; min-width: 0; }
.file .fn b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.file .fn span { font-size: 12px; color: var(--muted); }
.img { display: block; max-width: min(260px, 70vw); max-height: 320px; border-radius: 12px; border: 1px solid var(--line); background: #eee; min-width: 120px; min-height: 90px; object-fit: cover; }
.typing { font-size: 12px; color: var(--muted); padding: 0 16px 4px; min-height: 18px; }

.composer { border-top: 1px solid var(--line); background: #fff; padding: 8px 8px calc(8px + var(--safe-bottom)); display: flex; align-items: flex-end; gap: 6px; }
.composer textarea { flex: 1; min-height: 44px; max-height: 140px; resize: none; border: 1px solid #DDD; border-radius: 22px; padding: 11px 16px; line-height: 20px; outline: none; background: #fff; }
.composer textarea:focus { border-color: var(--link); }
.round { width: 44px; height: 44px; border-radius: 22px; border: 0; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.round.att { background: var(--bg-2); color: var(--ink-2); }
.round.send { background: var(--green); color: #fff; }
.round.send:disabled { background: #B7C9C2; }
.readonly { padding: 14px 16px calc(14px + var(--safe-bottom)); text-align: center; font-size: 13px; color: var(--muted); background: #fff; border-top: 1px solid var(--line); }
.uploads { padding: 6px 12px 0; display: flex; flex-direction: column; gap: 4px; }
.upl { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.upl progress { flex: 1; height: 6px; }
.pane .blank { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--muted); padding: 24px; text-align: center; }
.pane .blank svg.i { width: 48px; height: 48px; color: #C9C3C9; }

/* ---------- settings ---------- */
.card { margin: 12px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.card .row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 52px; border-top: 1px solid var(--line); }
.card .row:first-child { border-top: 0; }
.card .row .t { flex: 1; min-width: 0; }
.card .row .t small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; padding: 12px 14px; }
.seg button { height: 38px; border-radius: 19px; border: 1px solid #DDD; background: #fff; padding: 0 14px; display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.seg button.on { border-color: var(--ink); background: var(--ink); color: #fff; }
.seg .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.switch { appearance: none; -webkit-appearance: none; width: 46px; height: 28px; border-radius: 14px; background: #CFCFCF; position: relative; flex-shrink: 0; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch:checked { background: var(--green); }
.switch:checked::after { transform: translateX(18px); }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 16px 16px 24px; }

.toast { position: fixed; left: 50%; bottom: calc(84px + var(--safe-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 50; max-width: 90vw; box-shadow: 0 4px 16px rgba(0,0,0,.2); }
.offline { background: #FFF4D6; color: #6B4E00; font-size: 13px; text-align: center; padding: 6px 12px; }
.viewer { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 60; display: flex; align-items: center; justify-content: center; padding: calc(56px + var(--safe-top)) 8px calc(16px + var(--safe-bottom)); }
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer .x { position: absolute; top: calc(8px + var(--safe-top)); right: 8px; color: #fff; }

/* message formatting (same light markdown as the PC app) */
.bubble code { font-family: Consolas, "SF Mono", Menlo, monospace; font-size: .9em; background: #F2F2F2; color: #C01C4A; border-radius: 4px; padding: 0 3px; }
.bubble pre { font-family: Consolas, "SF Mono", Menlo, monospace; font-size: 13px; background: #F4F4F2; color: #222; border: 1px solid #E4E4E0; border-radius: 8px; padding: 8px 10px; margin: 4px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble .quote { display: inline-block; border-left: 3px solid #C9C8C3; padding-left: 8px; color: #555; }
.bubble .li { display: inline-block; padding-left: 6px; }
.m.me .bubble code, .m.me .bubble pre { background: rgba(255,255,255,.18); color: #fff; border-color: transparent; }
.m.me .bubble .quote { border-left-color: rgba(255,255,255,.6); color: inherit; }
