/* Softphone, the web test version. The Vibe Crafted Software app standard (app-standards plugin,
   frontend/style-and-theme.md "Style guide"): stock Fluent Compact neutrals, Thai royal blue as the one
   accent, the system font, 14px text and a 16px title, 4px corners (8px for a dialog), 32px buttons and 36px
   fields, no shadows, gradients or decorative pictures. On a phone (pointer: coarse) targets grow to 44px and
   fields to 16px text, as the portal's touch layer does. Light or dark with the device. */

:root{
  --side-w:320px;
  --background:#fafafa;--card:#fff;--background-alt:#f5f5f5;--muted:#f5f5f5;
  --border:#e0e0e0;--foreground:#242424;--muted-foreground:#616161;
  --primary:#1f4fa3;--primary-foreground:#fff;
  --destructive:#b42318;--destructive-bg:#fdecea;--success:#107c10;--success-bg:#dff6dd;--info-bg:#e8eef9;
  --radius:4px;--radius-dialog:8px;
  --font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Noto Sans Thai","Leelawadee UI",sans-serif;
}
@media (prefers-color-scheme:dark){:root{
  --background:#1f1f1f;--card:#292929;--background-alt:#141414;--muted:#3d3d3d;
  --border:#616161;--foreground:#fff;--muted-foreground:#adadad;
  --primary:#7fa2e6;--primary-foreground:#0b1b3a;
  --destructive:#f1707b;--destructive-bg:#3b1a1c;--success:#54b054;--success-bg:#1d3a1d;--info-bg:#1e2a40;
}}

*{box-sizing:border-box}
html,body{margin:0;height:100%}
body{background:var(--background);color:var(--foreground);font:14px/1.45 var(--font);-webkit-tap-highlight-color:transparent}
h1,h2,h3{font-size:16px;font-weight:600;line-height:1.3;margin:0}
p{margin:0}
button,input,textarea{font:inherit;color:inherit}
.hidden{display:none!important}
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
.skip{position:absolute;left:-999px}.skip:focus{left:8px;top:8px;background:var(--card);padding:6px 10px;border-radius:var(--radius);z-index:50}
.muted{color:var(--muted-foreground)}
.small{font-size:12px}
:focus-visible{outline:2px solid var(--primary);outline-offset:1px}
svg.i{width:20px;height:20px;flex:none;fill:none;stroke:currentColor;stroke-width:1.75;stroke-linecap:round;stroke-linejoin:round}
svg.i.sm{width:16px;height:16px}

/* ── controls ── */
.btn{display:inline-flex;align-items:center;justify-content:center;height:32px;min-width:80px;padding:0 12px;
  border-radius:var(--radius);border:1px solid transparent;font-weight:600;cursor:pointer;white-space:nowrap}
.btn:disabled{opacity:.45;cursor:default}
.btn.primary{background:var(--primary);color:var(--primary-foreground)}
.btn.primary:hover:not(:disabled){filter:brightness(1.08)}
.btn.outline{background:var(--card);border-color:var(--border)}
.btn.outline:hover:not(:disabled){background:var(--muted)}
.btn.danger{background:var(--destructive);color:#fff}
@media (prefers-color-scheme:dark){.btn.danger{color:#1f1f1f}}
.btn.text-danger{background:none;color:var(--destructive);min-width:0;padding:0 8px}
.btn.text-danger:hover{background:var(--destructive-bg)}
.icon-btn{display:inline-grid;place-items:center;width:32px;height:32px;border-radius:var(--radius);border:0;background:none;
  color:var(--muted-foreground);cursor:pointer;flex:none}
.icon-btn:hover{background:var(--muted);color:var(--foreground)}
.field{display:grid;gap:6px}
.field label{font-weight:600}
.input,textarea.input{width:100%;height:36px;padding:0 10px;border-radius:var(--radius);border:1px solid var(--border);
  background:var(--card);color:var(--foreground)}
.input::placeholder,textarea::placeholder{color:var(--muted-foreground)}
.input:focus,textarea:focus{outline:none;border-color:var(--primary);box-shadow:inset 0 0 0 1px var(--primary)}
.field:focus-within label{color:var(--primary)}

/* avatars: the person's picture, or their initials, on the neutral grey */
.av{--s:40px;width:var(--s);height:var(--s);border-radius:50%;flex:none;object-fit:cover;display:grid;place-items:center;
  background:var(--muted);color:var(--muted-foreground);font-weight:600;font-size:calc(var(--s) * .36);user-select:none;overflow:hidden}
@media (prefers-color-scheme:light){.av:not(img){background:#ebebeb}}
.av svg{width:55%;height:55%}
.av.s32{--s:32px}.av.s40{--s:40px}.av.s64{--s:64px}.av.s96{--s:96px}

/* ── messages: a bar across the top (the portal's kit: red error, green done, blue for anything else) ── */
.flash{position:fixed;left:50%;top:max(8px,env(safe-area-inset-top));transform:translateX(-50%);z-index:60;
  width:min(40rem,calc(100vw - 16px));display:flex;align-items:center;gap:8px;padding:8px 8px 8px 12px;
  border-radius:var(--radius);border:1px solid transparent}
.flash.is-info{background:var(--info-bg);color:var(--foreground);border-color:var(--primary)}
.flash.is-done{background:var(--success-bg);color:var(--foreground);border-color:var(--success)}
.flash.is-error{background:#b42318;color:#fff}
.flash span{flex:1}
/* On a laptop the bar spans the main column, under nothing and over the chat, as the portal kit measures <main>. */
@media (min-width:761px){.flash{left:calc(var(--side-w) + 16px);right:16px;width:auto;transform:none}}
.flash .icon-btn{color:inherit}

/* ── starting ── */
#v-loading{min-height:100dvh;display:grid;place-items:center;color:var(--muted-foreground)}

/* ── sign-up: one form, nothing decorative ── */
#v-signup{min-height:100dvh;display:grid;place-items:center;padding:24px 16px}
.signup{width:min(28rem,100%);background:var(--card);border:1px solid var(--border);border-radius:var(--radius);padding:24px;display:grid;gap:12px}
.signup-head{display:flex;align-items:center;gap:8px}
.app-mark{width:32px;height:32px;border-radius:var(--radius);background:var(--primary);color:var(--primary-foreground);display:grid;place-items:center;flex:none}
.app-mark svg{width:18px;height:18px}
.signup-head h1{flex:1}
.tag{font-size:12px;color:var(--muted-foreground);border:1px solid var(--border);border-radius:999px;padding:1px 8px}
.signup .lead{color:var(--muted-foreground)}
.points{margin:0;padding:0;list-style:none;display:grid;gap:8px}
.points li{display:flex;gap:8px;align-items:flex-start}
.points svg{color:var(--primary);margin-top:1px}
.pick{display:flex;align-items:center;gap:12px;margin-top:12px}
.pick-btn{border:0;background:none;padding:0;border-radius:50%;cursor:pointer}
.pick .btn{margin-left:auto}
.signup .actions{display:flex;justify-content:flex-end}
.fine{color:var(--muted-foreground);border-top:1px solid var(--border);padding-top:12px}
.fine summary{cursor:pointer;color:var(--foreground);font-weight:600}
.fine ul{margin:8px 0 0;padding-left:18px;display:grid;gap:6px}

/* ── the app: the chat list beside the chat ── */
#v-app{height:100dvh;display:grid;grid-template-columns:var(--side-w) 1fr}
.side{display:flex;flex-direction:column;min-height:0;background:var(--background-alt);border-right:1px solid var(--border)}
.head{display:flex;align-items:center;gap:8px;min-height:56px;padding:8px 12px;border-bottom:1px solid var(--border)}
.head h1{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.me-btn{border:0;background:none;padding:0;border-radius:50%;cursor:pointer;flex:none}
.find{padding:12px 12px 8px}
.find .input{height:32px}
.status-line{display:flex;align-items:center;gap:6px;margin:0 12px 8px;color:var(--muted-foreground);font-size:12px}
.list{flex:1;overflow-y:auto;padding:0 8px 12px}
.row{display:flex;align-items:center;gap:10px;width:100%;padding:8px;border:0;border-radius:var(--radius);background:none;text-align:left;cursor:pointer}
.row:hover{background:var(--muted)}
.row.on{background:var(--card);box-shadow:inset 3px 0 0 var(--primary)}
.row-mid{flex:1;min-width:0;display:grid}
.row-top{display:flex;align-items:baseline;gap:8px}
.row-top b{flex:1;min-width:0;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.row-time{font-size:12px;color:var(--muted-foreground);flex:none}
.row-sub{display:flex;align-items:center;gap:6px;color:var(--muted-foreground);min-width:0}
.row-sub span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1}
.row.unread .row-sub{color:var(--foreground)}
.count{min-width:20px;height:20px;padding:0 6px;border-radius:999px;background:var(--primary);color:var(--primary-foreground);
  font-size:12px;font-weight:600;display:grid;place-items:center;flex:none}
.list-empty{padding:24px 12px;color:var(--muted-foreground);display:grid;gap:12px;justify-items:start}

.main{min-width:0;min-height:0;display:flex;flex-direction:column;background:var(--background)}
.none{margin:auto;padding:24px;color:var(--muted-foreground);text-align:center}
.chat{flex:1;display:flex;flex-direction:column;min-height:0}
.chat .head{background:var(--background)}
.chat .who{flex:1;min-width:0;display:grid}
.chat .who b{font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.chat .who span{font-size:12px;color:var(--muted-foreground);display:inline-flex;align-items:center;gap:4px}
#chat-back{display:none}
.msgs{flex:1;overflow-y:auto;list-style:none;margin:0;padding:12px 16px 16px;display:flex;flex-direction:column;gap:2px}
.notice{align-self:stretch;display:flex;gap:8px;align-items:flex-start;margin-bottom:12px;padding:8px 12px;border-radius:var(--radius);
  background:var(--info-bg);border-left:3px solid var(--primary);color:var(--foreground);font-size:12px}
.day{align-self:center;margin:12px 0 6px;font-size:12px;color:var(--muted-foreground)}
.msg{max-width:min(34rem,78%);padding:6px 10px;border-radius:8px;display:flex;flex-wrap:wrap;align-items:flex-end;column-gap:8px;
  overflow-wrap:anywhere;white-space:pre-wrap}
.msg.mine{align-self:flex-end;background:var(--primary);color:var(--primary-foreground)}
.msg.theirs{align-self:flex-start;background:var(--card);border:1px solid var(--border)}
.msg.start{margin-top:8px}
.msg-text{flex:1 1 auto}
.msg-meta{margin-left:auto;display:inline-flex;align-items:center;gap:3px;font-size:11px;opacity:.75;white-space:nowrap}
.msg-meta svg{width:13px;height:13px}
.msg.failed{background:var(--destructive-bg);color:var(--destructive);border:1px solid var(--destructive)}
.msg-fail{flex-basis:100%;font-size:12px}
.composer{display:flex;align-items:flex-end;gap:8px;padding:8px 16px max(8px,env(safe-area-inset-bottom));border-top:1px solid var(--border);background:var(--background)}
.composer textarea{flex:1;resize:none;height:36px;min-height:36px;max-height:150px;padding:7px 10px;line-height:20px}
.waiting{margin:0 16px max(16px,env(safe-area-inset-bottom));padding:12px;border:1px solid var(--border);border-radius:var(--radius);
  background:var(--card);display:grid;gap:2px}
.waiting b{font-weight:600}
.waiting p{color:var(--muted-foreground)}
.wait-btns{display:flex;gap:8px;justify-content:flex-end;margin-top:10px}

/* ── dialogs: a title, a body, a footer with the way out; full screen on a phone ── */
dialog{border:1px solid var(--border);padding:0;background:var(--card);color:var(--foreground);border-radius:var(--radius-dialog);
  width:min(28rem,calc(100vw - 2rem));max-height:90vh;overflow:hidden}
dialog[open]{display:flex;flex-direction:column}
dialog::backdrop{background:rgb(0 0 0 / .4)}
.dlg-head{display:flex;align-items:center;gap:8px;padding:12px 12px 12px 16px;border-bottom:1px solid var(--border)}
.dlg-head h2{flex:1}
.dlg-body{flex:1;min-height:0;min-width:0;overflow:auto;padding:16px;display:grid;gap:12px;align-content:start}
.dlg-foot{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:8px;padding:12px 16px;border-top:1px solid var(--border)}
.tabs{display:flex;gap:16px;border-bottom:1px solid var(--border)}
.tabs button{border:0;background:none;padding:6px 0;font-weight:600;color:var(--muted-foreground);cursor:pointer;border-bottom:2px solid transparent;margin-bottom:-1px}
.tabs button[aria-selected="true"]{color:var(--foreground);border-bottom-color:var(--primary)}
[role="tabpanel"]{display:grid;gap:12px}
.code{display:grid;justify-items:center;gap:4px;text-align:center}
.code b{font-weight:600}
.code .id{color:var(--muted-foreground);font-variant-numeric:tabular-nums}
.qr{width:min(17rem,78vw);aspect-ratio:1;margin-top:8px;padding:12px;background:#fff;border:1px solid var(--border);border-radius:var(--radius)}
.qr svg{display:block;width:100%;height:100%}
.row-btns{display:flex;flex-wrap:wrap;gap:8px;justify-content:center}
.scan{border-radius:var(--radius);overflow:hidden;background:#000;aspect-ratio:1;position:relative}
.scan video{width:100%;height:100%;object-fit:cover;display:block}
.scan .frame{position:absolute;inset:20%;border:2px solid #fff;border-radius:var(--radius)}
.paste{display:flex;gap:8px;align-items:flex-end}
.paste .field{flex:1;min-width:0}
.me-head{display:flex;align-items:center;gap:12px}
.id-line{display:flex;align-items:center;gap:8px;padding:8px 8px 8px 12px;border:1px solid var(--border);border-radius:var(--radius)}
.id-line div{flex:1;display:grid}
.id-line span{font-size:12px;color:var(--muted-foreground)}
.id-line b{font-variant-numeric:tabular-nums;font-size:12px;overflow-wrap:anywhere}
.code .id{font-size:12px;overflow-wrap:anywhere}
.dlg-note{color:var(--muted-foreground);font-size:12px}
.dlg-foot .left{margin-right:auto}
/* A message about what was just done in a form or dialog, said where it happened (a bar would sit behind a dialog). */
.dlg-msg{padding:8px 12px;border-radius:var(--radius);border-left:3px solid}
.dlg-msg.err{background:var(--destructive-bg);color:var(--destructive);border-color:var(--destructive)}
.dlg-msg.ok{background:var(--success-bg);border-color:var(--success)}

/* ── a phone: one screen at a time, full-screen dialogs, 44px targets and 16px fields ── */
@media (max-width:760px){
  #v-app{grid-template-columns:1fr}
  .side{border-right:0}
  body.in-chat .side{display:none}
  body:not(.in-chat) .main{display:none}
  #chat-back{display:inline-grid}
  .head{padding-top:max(8px,env(safe-area-inset-top))}
  .msg{max-width:85%}
}
@media (max-width:640px){
  dialog{width:100vw;max-width:100vw;height:100dvh;max-height:100dvh;margin:0;border:0;border-radius:0}
  .dlg-foot{padding-bottom:max(12px,env(safe-area-inset-bottom))}
  .signup{border:0;padding:16px 0;background:none}
  #v-signup{place-items:start center}
}
@media (pointer:coarse){
  .btn{height:44px}.icon-btn{width:44px;height:44px}
  .input,textarea.input{height:44px;font-size:16px}
  .composer textarea{height:44px;min-height:44px;padding:11px 12px;font-size:16px}
  .find .input{height:44px}
  .row{min-height:60px}
}
@media (prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}
