/* Apex Mobile Portal - premium dark UI, iPhone-16-Pro first. */

:root {
  --bg: #0a0a0c;
  --bg-elev: #141418;
  --bg-elev-2: #1c1c22;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-hi: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.08);
  --border-hi: rgba(255, 255, 255, 0.14);
  --text: #f4f4f6;
  --text-dim: #a0a0aa;
  --text-faint: #6b6b76;
  --accent: #f5a623;          /* amber */
  --accent-2: #a07cff;        /* violet */
  --accent-grad: linear-gradient(135deg, #f5a623, #a07cff);
  --danger: #ff5d5d;
  --online: #3ddc84;
  --radius: 16px;
  --radius-sm: 11px;
  --tap: 44px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --header-h: 52px;
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

body { position: fixed; inset: 0; overflow: hidden; }

.app { height: 100%; width: 100%; position: relative; overflow: hidden; }

button { font-family: inherit; color: inherit; cursor: pointer; border: none; background: none; }
input, textarea { font-family: inherit; }

/* ---------- boot splash ---------- */
.boot {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: var(--bg);
}
.boot-logo {
  width: 72px; height: 72px; border-radius: 20px;
  background: var(--accent-grad);
  display: grid; place-items: center;
  font-weight: 800; font-size: 38px; color: #0a0a0c;
  animation: pulse 1.6s ease-in-out infinite;
  box-shadow: 0 12px 40px rgba(245, 166, 35, 0.3);
}
@keyframes pulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(0.94); opacity: 0.7; } }

/* ---------- screen stack ---------- */
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  background: var(--bg);
  animation: screen-in 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}
.screen.is-sub { animation: screen-push 0.32s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes screen-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes screen-push { from { transform: translateX(28px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ---------- header ---------- */
.hdr {
  position: relative; z-index: 5;
  padding-top: var(--safe-t);
  background: rgba(10, 10, 12, 0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--border);
}
.hdr-row {
  height: var(--header-h);
  display: flex; align-items: center; gap: 8px;
  padding: 0 8px;
}
.hdr-title { flex: 1; font-size: 17px; font-weight: 650; text-align: center; letter-spacing: -0.01em; }
.hdr-title.lead { text-align: left; padding-left: 8px; font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.hdr-btn {
  min-width: var(--tap); height: var(--tap);
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 12px; color: var(--accent);
  font-size: 16px; font-weight: 550;
  padding: 0 10px;
  transition: background 0.15s, transform 0.1s;
}
.hdr-btn:active { background: var(--surface-hi); transform: scale(0.94); }
.hdr-btn.icon { font-size: 22px; }
.hdr-sub { font-size: 12px; color: var(--text-dim); text-align: center; padding-bottom: 6px; margin-top: -2px; }

/* ---------- scroll body ---------- */
.body {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

/* ---------- presence banner ---------- */
.banner {
  display: flex; align-items: center; gap: 8px;
  margin: 10px 14px 0; padding: 10px 14px;
  background: rgba(255, 93, 93, 0.1);
  border: 0.5px solid rgba(255, 93, 93, 0.28);
  color: #ffb0b0; border-radius: 12px;
  font-size: 13px; font-weight: 500;
  animation: drop 0.3s ease;
}
.banner .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
@keyframes drop { from { transform: translateY(-6px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ---------- chats list ---------- */
.ptr {
  height: 0; display: grid; place-items: center;
  color: var(--text-faint); font-size: 12px; overflow: hidden;
  transition: height 0.2s ease;
}
.ptr.show { height: 40px; }
.ptr .spin { width: 18px; height: 18px; }

.list { padding: 6px 0 calc(20px + var(--safe-b)); }
.cell {
  display: flex; gap: 12px; align-items: center;
  padding: 12px 16px;
  position: relative;
  transition: background 0.12s;
}
.cell:active { background: var(--surface); }
.cell + .cell::before {
  content: ''; position: absolute; top: 0; left: 60px; right: 0;
  height: 0.5px; background: var(--border);
}
.avatar {
  width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
  background: var(--bg-elev-2); border: 0.5px solid var(--border);
  display: grid; place-items: center;
  font-size: 18px; font-weight: 700; color: var(--accent-2);
}
.cell-main { flex: 1; min-width: 0; }
.cell-top { display: flex; align-items: baseline; gap: 8px; }
.cell-title { flex: 1; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-time { font-size: 12px; color: var(--text-faint); flex-shrink: 0; }
.cell-prev { font-size: 14px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; }
.cell-meta { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.chip {
  font-size: 11px; font-weight: 600; color: var(--text-dim);
  background: var(--surface); border: 0.5px solid var(--border);
  padding: 2px 8px; border-radius: 7px;
  max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip.model { color: var(--accent-2); }
.unread { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }

/* streaming shimmer */
.shimmer {
  font-size: 14px; margin-top: 3px;
  background: linear-gradient(90deg, var(--text-faint) 30%, var(--text) 50%, var(--text-faint) 70%);
  background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- FAB ---------- */
.fab {
  position: absolute; right: 18px; bottom: calc(20px + var(--safe-b));
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--accent-grad);
  display: grid; place-items: center;
  color: #0a0a0c; font-size: 30px; font-weight: 400;
  box-shadow: 0 10px 30px rgba(245, 166, 35, 0.34);
  z-index: 20;
  transition: transform 0.15s;
}
.fab:active { transform: scale(0.9); }

/* ---------- empty / loading ---------- */
.empty { padding: 80px 30px; text-align: center; color: var(--text-faint); }
.empty .big { font-size: 40px; margin-bottom: 12px; opacity: 0.6; }
.empty .t { font-size: 17px; color: var(--text-dim); font-weight: 600; }
.empty .s { font-size: 14px; margin-top: 6px; }

.skel { padding: 12px 16px; display: flex; gap: 12px; }
.skel .sq { width: 42px; height: 42px; border-radius: 12px; background: var(--surface); }
.skel .ln { flex: 1; }
.skel .b { height: 12px; border-radius: 6px; background: var(--surface); margin-bottom: 8px; }
.skel .b.s { width: 40%; }
.skel-anim .sq, .skel-anim .b { animation: breathe 1.4s ease-in-out infinite; }
@keyframes breathe { 0%,100% { opacity: 0.5; } 50% { opacity: 1; } }

/* ---------- chat view ---------- */
.thread { padding: 14px 14px calc(18px + var(--safe-b)); display: flex; flex-direction: column; gap: 12px; }
.msg { display: flex; max-width: 100%; }
.msg.user { justify-content: flex-end; }
.bubble {
  max-width: 82%;
  padding: 10px 14px; border-radius: 18px;
  font-size: 15.5px; line-height: 1.42;
  white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere;
}
.msg.user .bubble {
  background: var(--accent-grad); color: #100c02;
  border-bottom-right-radius: 5px; font-weight: 500;
}
.msg.assistant { flex-direction: column; gap: 8px; max-width: 100%; }
.msg.assistant .bubble {
  background: var(--bg-elev); border: 0.5px solid var(--border);
  border-bottom-left-radius: 5px; max-width: 100%;
}
.bubble.empty-stream { color: var(--text-faint); }
.cursor { display: inline-block; width: 8px; height: 16px; background: var(--accent); border-radius: 2px; vertical-align: text-bottom; animation: blink 1s steps(2) infinite; margin-left: 2px; }
@keyframes blink { 50% { opacity: 0; } }

/* thinking + tools */
.foldable { border: 0.5px solid var(--border); border-radius: 12px; background: var(--surface); overflow: hidden; }
.fold-head {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; font-size: 13px; font-weight: 600; color: var(--text-dim);
  width: 100%; text-align: left;
}
.fold-head .caret { transition: transform 0.2s; color: var(--text-faint); font-size: 11px; }
.foldable.open .fold-head .caret { transform: rotate(90deg); }
.fold-head .ic { font-size: 13px; }
.fold-body {
  display: none; padding: 0 12px 11px; font-size: 13.5px; line-height: 1.45;
  color: var(--text-dim); white-space: pre-wrap; word-wrap: break-word;
}
.foldable.open .fold-body { display: block; }
.tool-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px; border-radius: 11px;
  background: var(--surface); border: 0.5px solid var(--border);
  font-size: 13px; color: var(--text-dim); font-weight: 500;
  max-width: 100%;
}
.tool-chip .ic { color: var(--accent-2); }
.tool-chip .nm { color: var(--text); font-weight: 600; }
.tool-chip .sm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool-chip.done .ic { color: var(--online); }

.usage {
  align-self: flex-start; font-size: 11px; color: var(--text-faint);
  background: var(--surface); border: 0.5px solid var(--border);
  padding: 4px 9px; border-radius: 8px; font-variant-numeric: tabular-nums;
}
.err-line { color: var(--danger); font-size: 13px; padding: 4px 2px; }

/* ---------- composer ---------- */
.composer {
  padding: 8px 10px calc(8px + var(--safe-b));
  background: rgba(10, 10, 12, 0.82);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--border);
}
.comp-row { display: flex; align-items: flex-end; gap: 8px; }
.comp-field {
  flex: 1; display: flex; align-items: flex-end;
  background: var(--bg-elev); border: 0.5px solid var(--border-hi);
  border-radius: 22px; padding: 4px 4px 4px 16px;
  transition: border-color 0.15s;
}
.comp-field:focus-within { border-color: var(--accent); }
.comp-input {
  flex: 1; border: none; outline: none; background: none; color: var(--text);
  font-size: 16px; line-height: 1.4; resize: none;
  max-height: 130px; padding: 8px 0; min-height: 22px;
}
.comp-send {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent-grad); color: #0a0a0c;
  display: grid; place-items: center; font-size: 18px;
  transition: transform 0.12s, opacity 0.15s;
}
.comp-send:active { transform: scale(0.88); }
.comp-send:disabled { opacity: 0.32; }
.comp-send.stop { background: var(--danger); color: #fff; }
.steer-btn {
  height: 34px; padding: 0 12px; border-radius: 17px;
  background: var(--surface); border: 0.5px solid var(--border);
  color: var(--text-dim); font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all 0.15s;
}
.steer-btn.on { background: rgba(160, 124, 255, 0.16); border-color: var(--accent-2); color: var(--accent-2); }
.comp-tools { display: flex; gap: 8px; padding: 0 4px 8px; align-items: center; }
.comp-hint { font-size: 11px; color: var(--text-faint); margin-left: auto; }

/* ---------- login ---------- */
.login { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 0 28px calc(40px + var(--safe-b)); }
.login-brand { text-align: center; margin-bottom: 38px; }
.login-logo {
  width: 80px; height: 80px; border-radius: 22px; margin: 0 auto 18px;
  background: var(--accent-grad); display: grid; place-items: center;
  font-size: 42px; font-weight: 800; color: #0a0a0c;
  box-shadow: 0 14px 44px rgba(245, 166, 35, 0.3);
}
.login-brand h1 { font-size: 30px; font-weight: 800; margin: 0; letter-spacing: -0.02em; }
.login-brand p { color: var(--text-dim); font-size: 14.5px; margin: 8px 0 0; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--text-faint); font-weight: 600; margin: 0 0 6px 4px; text-transform: uppercase; letter-spacing: 0.04em; }
.field input {
  width: 100%; height: 52px; padding: 0 16px;
  background: var(--bg-elev); border: 0.5px solid var(--border-hi);
  border-radius: 14px; color: var(--text); font-size: 16px;
  transition: border-color 0.15s;
}
.field input:focus { outline: none; border-color: var(--accent); }
.btn-primary {
  width: 100%; height: 54px; border-radius: 14px; margin-top: 8px;
  background: var(--accent-grad); color: #0a0a0c;
  font-size: 17px; font-weight: 700;
  display: grid; place-items: center;
  transition: transform 0.12s, opacity 0.15s;
}
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; }
.login-err { color: var(--danger); font-size: 13.5px; text-align: center; margin-top: 14px; min-height: 18px; }
.login-foot { text-align: center; color: var(--text-faint); font-size: 12px; margin-top: 22px; }
.login-presence { display: inline-flex; align-items: center; gap: 6px; }
.login-presence .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); }
.login-presence.online .dot { background: var(--online); }

/* ---------- sheet (new session) ---------- */
.sheet-scrim {
  position: absolute; inset: 0; z-index: 40;
  background: rgba(0, 0, 0, 0.5);
  animation: fade 0.2s ease;
  display: flex; align-items: flex-end;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  width: 100%;
  background: var(--bg-elev); border-top-left-radius: 22px; border-top-right-radius: 22px;
  border-top: 0.5px solid var(--border-hi);
  padding: 8px 18px calc(24px + var(--safe-b));
  animation: sheet-up 0.34s cubic-bezier(0.22, 1, 0.36, 1);
  max-height: 86%; overflow-y: auto;
}
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-grab { width: 38px; height: 5px; border-radius: 3px; background: var(--border-hi); margin: 0 auto 16px; }
.sheet h2 { font-size: 21px; font-weight: 800; margin: 0 0 4px; letter-spacing: -0.01em; }
.sheet .sub { color: var(--text-dim); font-size: 14px; margin: 0 0 20px; }
.opt-label { font-size: 12px; color: var(--text-faint); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; margin: 16px 4px 8px; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opt {
  padding: 11px 15px; border-radius: 13px;
  background: var(--surface); border: 0.5px solid var(--border);
  font-size: 14.5px; font-weight: 600; color: var(--text-dim);
  transition: all 0.15s;
}
.opt.sel { background: rgba(245, 166, 35, 0.14); border-color: var(--accent); color: var(--accent); }
.opt:active { transform: scale(0.96); }

/* ---------- toast ---------- */
.toast-wrap { position: absolute; top: calc(var(--safe-t) + 8px); left: 0; right: 0; z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  max-width: 92%; padding: 12px 16px; border-radius: 14px;
  background: var(--bg-elev-2); border: 0.5px solid var(--border-hi);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes toast-in { from { transform: translateY(-16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.toast .tt { font-size: 14px; font-weight: 700; }
.toast .tb { font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.toast.success { border-color: rgba(61, 220, 132, 0.4); }
.toast.error { border-color: rgba(255, 93, 93, 0.4); }
.toast.error .tt { color: #ffb0b0; }

/* ---------- conn pill ---------- */
.conn-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-dim);
}
.conn-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); transition: background 0.2s; }
.conn-pill.online .dot { background: var(--online); box-shadow: 0 0 8px var(--online); }
.conn-pill.connecting .dot { background: var(--accent); animation: pulse 1s ease-in-out infinite; }

/* spinner */
.spin { border: 2px solid rgba(255,255,255,0.2); border-top-color: var(--text); border-radius: 50%; animation: rot 0.7s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
.btn-spin { width: 20px; height: 20px; border-top-color: #0a0a0c; border-color: rgba(10,10,12,0.3); }

/* ---------- header actions group + svg icon buttons ---------- */
.hdr-actions { display: flex; align-items: center; gap: 2px; }
.hdr-btn.icon svg { display: block; }
.hdr-btn.icon { color: var(--accent); }

/* ---------- files screen ---------- */
.crumbs {
  display: flex; align-items: center; gap: 4px;
  padding: 10px 14px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  border-bottom: 0.5px solid var(--border); white-space: nowrap;
}
.crumbs::-webkit-scrollbar { display: none; }
.crumb {
  flex-shrink: 0; padding: 6px 10px; border-radius: 9px;
  background: var(--surface); border: 0.5px solid var(--border);
  color: var(--text-dim); font-size: 13px; font-weight: 600;
  max-width: 150px; overflow: hidden; text-overflow: ellipsis;
}
.crumb.root { color: var(--accent-2); }
.crumb:active { background: var(--surface-hi); }
.crumb-sep { flex-shrink: 0; color: var(--text-faint); display: inline-flex; }
.crumb-sep svg { display: block; opacity: 0.6; }

.files-list { padding: 4px 0 calc(24px + var(--safe-b)); }
.file-cell { gap: 14px; }
.file-cell + .file-cell::before { left: 56px; }
.file-ic {
  width: 38px; height: 38px; flex-shrink: 0;
  display: grid; place-items: center; border-radius: 11px;
  background: var(--surface); border: 0.5px solid var(--border);
}
.file-ic.dir { color: var(--accent); }
.file-ic.file { color: var(--text-dim); }
.file-ic svg { display: block; }
.file-main { flex: 1; min-width: 0; }
.file-name { font-size: 15.5px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-sub { font-size: 12px; color: var(--text-faint); margin-top: 3px; font-variant-numeric: tabular-nums; }
.file-caret { color: var(--text-faint); display: inline-flex; flex-shrink: 0; opacity: 0.55; }
.file-caret svg { display: block; }

.file-view { padding: 12px 14px calc(24px + var(--safe-b)); }
.file-view-path { font-size: 12px; color: var(--text-faint); margin-bottom: 10px; word-break: break-all; }
.file-text {
  margin: 0; padding: 14px;
  background: var(--bg-elev); border: 0.5px solid var(--border); border-radius: 14px;
  font-family: 'SF Mono', 'Menlo', 'Consolas', ui-monospace, monospace;
  font-size: 12.5px; line-height: 1.55; color: var(--text);
  white-space: pre; overflow-x: auto; -webkit-overflow-scrolling: touch;
  max-height: calc(100vh - 200px);
}
.file-img {
  width: 100%; height: auto; border-radius: 14px;
  border: 0.5px solid var(--border); background: var(--bg-elev);
}
.file-trunc { font-size: 12px; color: var(--text-faint); text-align: center; margin-top: 10px; }

/* ---------- desktop browser view ---------- */
.browser-stage {
  flex: 1; position: relative; overflow: hidden;
  background: #000; display: grid; place-items: center;
  touch-action: none;
}
.browser-img { max-width: 100%; max-height: 100%; display: block; user-select: none; -webkit-user-drag: none; }
.browser-wait {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  color: var(--text-faint); font-size: 13px; pointer-events: none;
}
.browser-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px calc(8px + var(--safe-b));
  background: rgba(10, 10, 12, 0.82);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--border);
}
.browser-field {
  flex: 1; background: var(--bg-elev); border: 0.5px solid var(--border-hi);
  border-radius: 22px; padding: 0 16px; transition: border-color 0.15s;
}
.browser-field:focus-within { border-color: var(--accent); }
.browser-key { width: 100%; height: 44px; border: none; outline: none; background: none; color: var(--text); font-size: 16px; }
.browser-enter {
  height: 44px; padding: 0 18px; border-radius: 22px; flex-shrink: 0;
  background: var(--surface); border: 0.5px solid var(--border-hi);
  color: var(--text); font-size: 15px; font-weight: 600;
  transition: transform 0.12s;
}
.browser-enter:active { transform: scale(0.94); }

/* ---------- composer attachments ---------- */
.att-btn {
  height: 34px; width: 38px; border-radius: 17px; flex-shrink: 0;
  background: var(--surface); border: 0.5px solid var(--border);
  color: var(--text-dim);
  display: inline-flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.att-btn:active { transform: scale(0.92); background: var(--surface-hi); }
.att-btn svg { display: block; }
.att-chips { display: none; flex-wrap: wrap; gap: 8px; padding: 2px 4px 10px; }
.att-chip {
  position: relative; width: 60px; height: 60px; border-radius: 12px; overflow: hidden;
  border: 0.5px solid var(--border-hi); background: var(--bg-elev);
  animation: drop 0.2s ease;
}
.att-chip img { width: 100%; height: 100%; object-fit: cover; display: block; }
.att-x {
  position: absolute; top: 3px; right: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(0, 0, 0, 0.62); color: #fff;
  display: grid; place-items: center; font-size: 13px; font-weight: 700; line-height: 1;
}
.att-x:active { transform: scale(0.88); }

/* user message image attachments */
.msg-atts { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; margin-bottom: 6px; max-width: 82%; }
.msg-att { width: 130px; max-width: 60vw; height: auto; border-radius: 14px; border: 0.5px solid var(--border); display: block; }

/* ---------- chat header chips (model / effort / fast / workspace) ---------- */
.hdr-sub.chips {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  flex-wrap: wrap; padding: 0 12px 7px; margin-top: -2px;
}
.hdr-sub.chips:empty { display: none; }
.hsub-chip {
  font-size: 11px; font-weight: 600; color: var(--text-dim);
  background: var(--surface); border: 0.5px solid var(--border);
  padding: 2px 9px; border-radius: 8px; line-height: 1.5;
  max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hsub-chip.model { color: var(--accent-2); border-color: rgba(160,124,255,0.3); }
.hsub-chip.fast { color: var(--accent); border-color: rgba(245,166,35,0.35); }
.hsub-chip.dir { color: var(--text-faint); }

/* ---------- browser frame (smoother) ---------- */
.browser-img { object-fit: contain; image-rendering: auto; opacity: 0; transition: opacity 0.18s ease; }
.browser-img.live { opacity: 1; }

/* ---------- new-session / controls sheet extras ---------- */
.browse-row { display: flex; align-items: center; gap: 8px; }
.browse-btn {
  flex: 1; display: flex; align-items: center; gap: 10px;
  padding: 13px 14px; border-radius: 14px;
  background: var(--surface); border: 0.5px solid var(--border-hi);
  color: var(--text); font-size: 15px; font-weight: 600;
  transition: background 0.15s, transform 0.1s;
}
.browse-btn:active { background: var(--surface-hi); transform: scale(0.99); }
.browse-ic { color: var(--accent); display: inline-flex; flex-shrink: 0; }
.browse-ic svg { display: block; }
.browse-val { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.browse-go { color: var(--text-faint); display: inline-flex; flex-shrink: 0; opacity: 0.6; }
.browse-go svg { display: block; }
.browse-clear {
  flex-shrink: 0; padding: 0 14px; height: 46px; border-radius: 14px;
  background: var(--surface); border: 0.5px solid var(--border);
  color: var(--text-dim); font-size: 14px; font-weight: 600;
  display: inline-flex; align-items: center;
}
.browse-clear:active { background: var(--surface-hi); }

/* fast toggle (claude only) */
.fast-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; }
.fast-title { font-size: 15px; font-weight: 650; }
.fast-desc { font-size: 12.5px; color: var(--text-faint); margin-top: 2px; }
.fast-toggle {
  width: 50px; height: 30px; border-radius: 16px; flex-shrink: 0;
  background: var(--surface-hi); border: 0.5px solid var(--border-hi);
  position: relative; transition: background 0.2s;
}
.fast-toggle .fast-knob {
  position: absolute; top: 3px; left: 3px;
  width: 24px; height: 24px; border-radius: 50%;
  background: #fff; transition: transform 0.2s cubic-bezier(0.22,1,0.36,1);
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
.fast-toggle.on { background: var(--accent); border-color: var(--accent); }
.fast-toggle.on .fast-knob { transform: translateX(20px); }

/* ---------- files: drives root + pick mode ---------- */
.crumb.root.on { color: var(--accent-2); background: rgba(160,124,255,0.14); border-color: var(--accent-2); }
.file-cell.dimmed { opacity: 0.38; }
.file-cell.dimmed .file-name { color: var(--text-faint); }

.pick-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px calc(12px + var(--safe-b));
  background: rgba(10, 10, 12, 0.86);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--border-hi);
}
.pick-path {
  flex: 1; min-width: 0; font-size: 12px; color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: rtl; text-align: left;
  font-variant-numeric: tabular-nums;
}
.btn-primary.pick-use {
  width: auto; height: 46px; margin: 0; padding: 0 22px;
  font-size: 15px; border-radius: 14px; flex-shrink: 0;
}
.btn-primary.pick-use:disabled { opacity: 0.4; }

/* Grouped model picker (declutter): provider sub-labels + compact pill rows */
.model-pick { display: flex; flex-direction: column; gap: 4px; }
.model-grp { font-size: 10.5px; color: var(--text-faint); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; margin: 8px 4px 2px; }
.model-pick .opts { margin-bottom: 2px; }

/* Quick-open app buttons (Develop / Vantage / ELXR) in the new-chat sheet */
.quick-apps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.quick-app {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center;
  gap: 2px; padding: 11px 12px; min-height: var(--tap);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); text-align: left; cursor: pointer; transition: transform 0.12s, border-color 0.12s, background 0.12s;
}
.quick-app:active { transform: scale(0.96); }
.quick-app:hover { border-color: var(--border-hi); background: var(--surface-hi); }
.quick-app .qa-name { font-size: 14px; font-weight: 650; }
.quick-app .qa-sub { font-size: 11px; color: var(--text-faint); }

/* Draggable sheet handle (iOS swipe-down-to-dismiss). Bigger hit area + no
   browser scroll-steal while dragging the grab bar. */
.sheet-handle { touch-action: none; cursor: grab; padding: 8px 0 2px; margin: -4px 0 0; }
.sheet-handle:active { cursor: grabbing; }
.sheet { will-change: transform; }

/* Long-press session menu: no iOS selection callout on cells, full-width actions */
.cell { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.sheet-actions { display: flex; flex-direction: column; gap: 8px; }
.sheet-action {
  width: 100%; text-align: left; padding: 13px 14px; min-height: var(--tap);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-size: 15px; font-weight: 550; cursor: pointer; transition: transform 0.12s, background 0.12s, border-color 0.12s;
}
.sheet-action:active { transform: scale(0.98); }
.sheet-action:hover { background: var(--surface-hi); border-color: var(--border-hi); }
.sheet-action.danger { color: var(--danger); }
.sheet-action.danger:hover { background: rgba(255, 93, 93, 0.08); border-color: rgba(255, 93, 93, 0.3); }
