/* POV Chat — mobile-first. Tokens per BRAND.md: ink + lime, semantic colours for status only. */
:root{
  --bg:#F2F2F7; --surface:#FFF; --surface2:#F9F9FB; --surface3:#F2F2F7;
  --border:rgba(0,0,0,.08); --border-md:rgba(0,0,0,.14);
  --text:#1C1C1E; --text-2:#636366; --text-3:#AEAEB2;
  /* brand */
  --ink:#16181B; --ink-2:#212429;
  --lime:#D6FF3F; --lime-soft:rgba(214,255,63,.20); --lime-line:rgba(160,200,20,.45);
  /* semantic — status only */
  --blue:#3B66C9; --blue-soft:rgba(59,102,201,.10);
  --green:#2E9E68; --green-soft:rgba(46,158,104,.12);
  --red:#D2544C; --red-soft:rgba(210,84,76,.10);
  --amber:#CF9230; --amber-soft:rgba(207,146,48,.13);
  --r:12px; --r-lg:16px;
  --topbar-h:52px; --bottomnav-h:60px;
  --safe-b:env(safe-area-inset-bottom,0px);
  --safe-t:env(safe-area-inset-top,0px);
}
*{box-sizing:border-box;margin:0;-webkit-tap-highlight-color:transparent}
html,body{height:100%}
body{font:15px/1.45 -apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;background:var(--bg);color:var(--text);overscroll-behavior-y:none}
[hidden]{display:none !important}
button,input,select,textarea{font:inherit;color:inherit}

/* ---------- boot + toast ---------- */
.boot{position:fixed;inset:0;background:var(--bg);display:flex;align-items:center;justify-content:center;z-index:9000}
.spinner{width:30px;height:30px;border:3px solid var(--border-md);border-top-color:var(--ink);border-radius:50%;animation:spin .7s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}
.toast{position:fixed;left:50%;transform:translateX(-50%);bottom:calc(var(--bottomnav-h) + var(--safe-b) + 14px);
  background:var(--ink);color:#fff;padding:11px 18px;border-radius:10px;z-index:9500;max-width:90vw;
  box-shadow:0 8px 26px rgba(0,0,0,.22);font-size:14px;text-align:center}
.toast.err{background:var(--red)}
.toast.ok{background:var(--ink)}

/* ---------- sign in ---------- */
.signin{position:fixed;inset:0;display:flex;align-items:center;justify-content:center;padding:24px;background:var(--bg);z-index:8000}
.signin-card{background:var(--surface);border:1px solid var(--border);border-radius:var(--r-lg);padding:30px 24px;width:100%;max-width:360px;box-shadow:0 10px 40px rgba(0,0,0,.09)}
.signin-logo{font-size:22px;font-weight:800;text-align:center}
.signin-logo span{color:var(--ink);border-bottom:3px solid var(--lime)}
.signin-sub{color:var(--text-2);font-size:13.5px;text-align:center;margin:6px 0 20px}
.form-error{color:var(--red);font-size:13px;margin-top:12px;min-height:18px;text-align:center}

/* ---------- shell ---------- */
.app{display:flex;flex-direction:column;height:100%}
.topbar{display:flex;align-items:center;gap:10px;height:calc(var(--topbar-h) + var(--safe-t));padding:var(--safe-t) 14px 0;
  background:var(--surface);border-bottom:1px solid var(--border);flex:0 0 auto;position:sticky;top:0;z-index:60}
.brand{font-weight:800;font-size:17px}
.brand span{color:var(--ink);border-bottom:2.5px solid var(--lime)}
.topbar-right{margin-left:auto;display:flex;align-items:center;gap:6px}
.pill{font-size:10.5px;font-weight:700;padding:3px 9px;border-radius:999px;background:var(--surface3);color:var(--text-2);white-space:nowrap}
.pill.live{background:var(--green-soft);color:var(--green)}
.pill.mock{background:var(--amber-soft);color:var(--amber)}
.icon-btn{background:none;border:0;font-size:19px;line-height:1;padding:8px;border-radius:10px;cursor:pointer;color:var(--text-2);min-width:40px;min-height:40px}
.icon-btn:hover{background:var(--surface3);color:var(--text)}
.icon-btn:disabled{opacity:.4}

.main{flex:1;min-height:0;overflow:hidden;position:relative}
.screen{display:none;height:100%;overflow:hidden}
.screen.active{display:block}

/* ---------- nav ---------- */
.tabs{display:flex;gap:4px;padding:8px 14px;background:var(--surface);border-bottom:1px solid var(--border);overflow-x:auto;flex:0 0 auto}
.tabs button{background:none;border:0;padding:8px 15px;border-radius:999px;color:var(--text-2);font-size:13.5px;font-weight:550;cursor:pointer;white-space:nowrap;transition:background .15s,color .15s}
.tabs button:hover{background:var(--surface3);color:var(--text)}
.tabs button.active{background:var(--ink);color:#fff;font-weight:650}
.bottomnav{display:flex;flex:0 0 auto;background:var(--ink);border:0;border-radius:24px;
  margin:0 10px calc(10px + var(--safe-b));height:var(--bottomnav-h);z-index:60;
  box-shadow:0 10px 30px rgba(0,0,0,.22);overflow:hidden}
.bottomnav button{flex:1;background:none;border:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;
  color:rgba(255,255,255,.52);font-size:10px;font-weight:550;cursor:pointer;padding:0;position:relative}
.bottomnav button .bn-ico{font-size:19px;line-height:1}
.bottomnav button.active{color:#fff;font-weight:700}
.bottomnav button.active::before{content:'';position:absolute;top:9px;width:5px;height:5px;border-radius:50%;background:var(--lime)}

/* ---------- generic page ---------- */
.page{height:100%;overflow-y:auto;padding:16px 14px calc(20px + var(--safe-b));-webkit-overflow-scrolling:touch}
.page-head{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-bottom:12px}
.page-head h1{font-size:21px;font-weight:750}
.head-actions{margin-left:auto;display:flex;gap:8px;flex-wrap:wrap}
.section-title{font-size:14px;color:var(--text-2);margin:18px 0 8px;font-weight:650}
.card{background:var(--surface);border:1px solid var(--border);border-radius:var(--r-lg);padding:18px;margin-bottom:14px}
.card h2{font-size:15.5px;font-weight:700;margin-bottom:4px}
.hint{color:var(--text-2);font-size:12.5px;line-height:1.55;margin:6px 0 12px}
.muted{color:var(--text-3)}
code{background:var(--surface3);padding:1px 6px;border-radius:5px;font-size:12px}
pre{background:var(--surface3);border:1px solid var(--border);border-radius:9px;padding:12px;font-size:11.5px;overflow-x:auto;margin-top:10px;line-height:1.7}

/* ---------- forms ---------- */
.field{display:block;margin-bottom:12px}
.field>span{display:block;font-size:12px;font-weight:650;color:var(--text-2);margin-bottom:5px}
.field.end{display:flex;align-items:flex-end}
input,select,textarea{width:100%;background:var(--surface);border:1px solid var(--border-md);border-radius:12px;padding:12px 14px;font-size:15px}
input:focus,select:focus,textarea:focus{outline:none;border-color:var(--ink);box-shadow:0 0 0 3px var(--lime-soft)}
textarea{resize:vertical;line-height:1.5}
.row{display:flex;gap:10px;flex-wrap:wrap}
.row>.field{flex:1;min-width:130px}
.field.small{flex:0 1 150px}
.check{display:flex;align-items:center;gap:9px;font-size:14px;margin:4px 0 12px;cursor:pointer}
.check input{width:19px;height:19px;flex:0 0 auto}
.search{border-radius:999px;background:var(--surface2);border-color:transparent;padding-left:16px}
.search.wide{margin-bottom:12px}
.actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:4px}
.btn{background:var(--surface);border:1px solid var(--border-md);border-radius:12px;padding:11px 17px;font-size:14px;font-weight:600;cursor:pointer;min-height:44px;transition:background .15s,border-color .15s,transform .06s}
.btn:hover{background:var(--surface3);border-color:rgba(0,0,0,.2)}
.btn:active{transform:translateY(1px)}
.btn.primary{background:var(--ink);border-color:var(--ink);color:#fff;box-shadow:0 2px 8px rgba(22,24,27,.18)}
.btn.primary:hover{background:var(--ink-2);border-color:var(--ink-2)}
.btn.danger{background:var(--red);border-color:var(--red);color:#fff}
.btn.block{width:100%}
.btn:disabled{opacity:.55;cursor:not-allowed;transform:none}
.btn.busy{position:relative;color:transparent !important}
.btn.busy::after{content:'';position:absolute;inset:0;margin:auto;width:16px;height:16px;border:2px solid rgba(255,255,255,.5);border-top-color:#fff;border-radius:50%;animation:spin .7s linear infinite}
.btn:not(.primary):not(.danger).busy::after{border-color:var(--border-md);border-top-color:var(--text-2)}
.result{margin-top:12px;padding:12px;border-radius:10px;background:var(--surface2);border:1px solid var(--border);font-size:13px;line-height:1.6}

/* ---------- lists / cards ---------- */
.cards{display:flex;flex-direction:column;gap:8px}
.cards.flush{margin-top:10px}
.item{background:var(--surface);border:1px solid var(--border);border-radius:var(--r-lg);padding:14px 15px;display:flex;gap:12px;align-items:center}
.item .grow{flex:1;min-width:0}
.item .t{font-weight:650;font-size:14.5px}
.item .s{color:var(--text-2);font-size:12.5px;margin-top:3px;overflow-wrap:anywhere}
.badge{font-size:10.5px;font-weight:650;padding:4px 10px;border-radius:999px;white-space:nowrap}
.badge.ok{background:var(--green-soft);color:var(--green)}
.badge.warn{background:var(--amber-soft);color:var(--amber)}
.badge.bad{background:var(--red-soft);color:var(--red)}
.badge.info{background:var(--blue-soft);color:var(--blue)}
.tag{display:inline-block;background:var(--blue-soft);color:var(--blue);border-radius:999px;padding:2px 9px;font-size:11px;margin:2px 4px 2px 0}
.empty{text-align:center;color:var(--text-3);padding:34px 18px;font-size:13.5px;line-height:1.6}
.empty b{display:block;color:var(--text-2);font-size:15px;margin-bottom:5px}
.checklist div{padding:7px 0;font-size:14px;border-bottom:1px solid var(--border)}
.checklist div:last-child{border:0}

/* ---------- avatars ---------- */
.av{width:42px;height:42px;border-radius:50%;display:flex;align-items:center;justify-content:center;color:#fff;font-weight:700;font-size:14.5px;flex:0 0 auto}
.av.sm{width:34px;height:34px;font-size:12px}
.av.lg{width:66px;height:66px;font-size:23px}
.av-wrap{position:relative;flex:0 0 auto}
.dot{position:absolute;right:-1px;bottom:-1px;width:12px;height:12px;border-radius:50%;border:2px solid var(--surface)}
.dot.on{background:var(--green)}.dot.off{background:var(--text-3)}

/* ---------- chats ---------- */
.split{display:flex;height:100%;min-height:0}
.pane{display:flex;flex-direction:column;min-height:0;background:var(--surface)}
.list-pane{width:100%;border-right:1px solid var(--border)}
.pane-head{padding:12px 14px;border-bottom:1px solid var(--border);flex:0 0 auto}
.scroll{flex:1;overflow-y:auto;-webkit-overflow-scrolling:touch}
.convo{display:flex;gap:11px;align-items:center;padding:11px 13px;border-bottom:1px solid var(--border);cursor:pointer}
.convo:active{background:var(--surface2)}
.convo.sel{background:var(--surface2);box-shadow:inset 3px 0 0 var(--ink)}
.convo .top{display:flex;justify-content:space-between;gap:8px;align-items:baseline}
.convo .nm{font-weight:650;font-size:14.5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.convo .tm{font-size:11px;color:var(--text-3);flex:0 0 auto}
.convo .pv{color:var(--text-2);font-size:13px;margin-top:2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.sim{border-top:1px solid var(--border);flex:0 0 auto;background:var(--surface2)}
.sim summary{padding:11px 14px;font-size:12.5px;color:var(--text-2);cursor:pointer}
.sim-body{padding:0 14px 14px;display:flex;flex-direction:column;gap:8px}

.thread-pane{flex:1;display:none}
.thread-head{display:flex;align-items:center;gap:8px;padding:9px 12px;border-bottom:1px solid var(--border);flex:0 0 auto;min-height:56px}
.thread-who{flex:1;min-width:0;display:flex;align-items:center;gap:10px}
.thread-who .nm{font-weight:700;font-size:15px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.thread-who .sub{font-size:12px;color:var(--text-2)}
.messages{flex:1;overflow-y:auto;padding:16px 14px;display:flex;flex-direction:column;gap:9px;background:var(--surface2);-webkit-overflow-scrolling:touch}
.msg{max-width:80%;padding:8px 12px 6px;border-radius:15px;font-size:14.5px;line-height:1.45;box-shadow:0 1px 1px rgba(0,0,0,.05)}
.msg.in{background:var(--surface);border:1px solid var(--border);align-self:flex-start;border-bottom-left-radius:5px}
.msg.out{background:#ECEDF2;align-self:flex-end;border-bottom-right-radius:5px}
.msg .who{font-size:11px;font-weight:700;color:var(--text-2);margin-bottom:2px}
.msg .tx{white-space:pre-wrap;overflow-wrap:anywhere}
.msg .mt{font-size:10px;color:var(--text-3);margin-top:3px}
.window-note{padding:9px 14px;font-size:12px;text-align:center;flex:0 0 auto}
.window-note.ok{background:var(--green-soft);color:var(--green)}
.window-note.warn{background:var(--amber-soft);color:var(--amber)}
.composer{display:flex;gap:8px;align-items:center;padding:10px 12px calc(10px + var(--safe-b));border-top:1px solid var(--border);background:var(--surface);flex:0 0 auto}
.composer .icon-btn{background:var(--surface2);border:1px solid var(--border);border-radius:50%;width:42px;height:42px;min-width:42px;font-size:17px;display:flex;align-items:center;justify-content:center}
.composer .icon-btn:hover{background:var(--surface3)}
#sendBtn{width:46px;min-width:46px;height:46px;padding:0;border-radius:50%;font-size:0;position:relative;flex:0 0 auto}
#sendBtn::after{content:'➤';font-size:16px;color:#fff;position:absolute;inset:0;display:flex;align-items:center;justify-content:center}
#sendBtn.busy::after{content:''}
.composer-input{flex:1;position:relative}
.composer-input input{border-radius:999px;background:var(--surface2);border-color:transparent;padding:12px 18px}
.qr-picker{position:absolute;bottom:48px;left:0;right:0;background:var(--surface);border:1px solid var(--border-md);border-radius:12px;overflow:hidden;z-index:70;box-shadow:0 -6px 24px rgba(0,0,0,.14);max-height:210px;overflow-y:auto}
.qr-opt{padding:11px 13px;font-size:13.5px;border-bottom:1px solid var(--border);cursor:pointer}
.qr-opt:active{background:var(--surface2)}
.qr-opt b{color:#fff;background:var(--ink);padding:2px 7px;border-radius:6px;margin-right:8px;font-size:11.5px}
.info-pane{display:none;width:280px;border-left:1px solid var(--border);overflow-y:auto}
.info-hero{padding:22px 16px 18px;text-align:center;border-bottom:1px solid var(--border);display:flex;flex-direction:column;align-items:center;gap:7px}
.info-block{padding:14px 16px;border-bottom:1px solid var(--border)}
.info-label{font-size:11px;font-weight:750;text-transform:uppercase;letter-spacing:.05em;color:var(--text-3);margin-bottom:8px}
.note{background:var(--surface2);border:1px solid var(--border);border-radius:9px;padding:9px 11px;font-size:13px;margin-bottom:6px}
.note .d{font-size:10px;color:var(--text-3);margin-top:4px}

/* ---------- bottom sheet (mobile dialogs) ---------- */
.sheet{position:fixed;inset:0;background:rgba(0,0,0,.42);z-index:9200;display:flex;align-items:flex-end;justify-content:center}
.sheet-card{background:var(--surface);width:100%;max-width:460px;border-radius:18px 18px 0 0;padding:20px 18px calc(20px + var(--safe-b));max-height:88vh;overflow-y:auto}
.sheet-card h3{font-size:17px;font-weight:750;margin-bottom:4px}

/* ---------- mobile behaviour ---------- */
.only-desktop{display:none}
body.thread-open .list-pane{display:none}
body.thread-open .thread-pane{display:flex}

/* ---------- desktop ---------- */
@media (min-width:860px){
  .only-mobile{display:none !important}
  .only-desktop{display:flex}
  .list-pane{width:330px;flex:0 0 auto}
  .thread-pane{display:flex}
  .info-pane{display:block}
  body.thread-open .list-pane{display:flex}
  .page{padding:22px 24px 40px;max-width:960px;margin:0 auto}
  .toast{bottom:24px}
  .sheet{align-items:center}
  .sheet-card{border-radius:18px;max-width:480px}
  .messages{padding:18px 20px}
  .msg{max-width:68%}
}
