/* ============================================================
   Messages — iOS 26 look (dark), liquid glass chrome
   ============================================================ */
:root {
  --bg: #000;
  --blue: #0a84ff;
  --bub-top: #2f94ff;
  --bub-bot: #0b78f0;
  --recv: #26262a;
  --text: #fff;
  --muted: #8d8d93;
  --muted2: #636366;
  --sep: rgba(84, 84, 88, 0.6);
  --glass-bg: rgba(44, 44, 48, 0.58);
  --glass-bg-strong: rgba(36, 36, 40, 0.78);
  --glass-border: rgba(255, 255, 255, 0.13);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --hdr-h: 98px;
  --composer-h: 58px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
*::-webkit-scrollbar { display: none; }
* { scrollbar-width: none; }

html, body { height: 100%; overflow: hidden; overscroll-behavior: none; background: var(--bg); }
body {
  font-family: var(--font); color: var(--text); display: flex; justify-content: center;
  -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased; touch-action: manipulation;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; touch-action: manipulation; }
svg.ic { display: block; fill: none; }

.app {
  position: relative; width: 100%; max-width: 430px; height: 100vh; height: 100dvh;
  background: var(--bg); overflow: hidden; isolation: isolate;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
/* keyboard up (set from visualViewport): the app fills exactly what's visible */
.app.kb { height: var(--app-h); transform: translateY(var(--app-y)); }
@media (min-width: 500px) {
  body { background: #0c0c0d; align-items: center; }
  .app:not(.kb) { height: min(100dvh - 32px, 880px); border-radius: 48px; box-shadow: 0 0 0 10px #1a1a1c, 0 0 0 11px #2a2a2d, 0 40px 100px rgba(0,0,0,.7); }
}

.view { position: absolute; inset: 0; z-index: 1; }
.view[hidden] { display: none !important; }

/* ---------- glass ---------- */
.glass {
  position: relative; color: var(--text);
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(28px) saturate(170%); backdrop-filter: blur(28px) saturate(170%);
  border: 0.5px solid var(--glass-border);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.16), inset 0 -0.5px 0 rgba(255,255,255,.05), 0 8px 26px rgba(0,0,0,.38);
}
.glass::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(120% 90% at 18% 0%, rgba(255,255,255,.14), rgba(255,255,255,0) 58%);
}
.glass > * { position: relative; }
button.glass:active { background: rgba(84, 84, 90, .66); }
.circle { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--blue); }
.pill { border-radius: 999px; }
.text-btn { height: 44px; padding: 0 17px; font-size: 17px; color: var(--blue); display: flex; align-items: center; }

/* ============================================================
   conversation list
   ============================================================ */
.list-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 3; pointer-events: none;
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(var(--sat) + 6px) 14px 8px;
}
.list-top > * { pointer-events: auto; }
.list-top::before, .dash-top::before { content: ""; position: absolute; inset: 0 0 -6px; background: linear-gradient(var(--bg) 58%, rgba(0,0,0,0)); pointer-events: none; }
.list-scroll {
  position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: calc(var(--sat) + 62px) 0 calc(var(--sab) + 96px);
}
.big-title { font-size: 34px; font-weight: 700; letter-spacing: .25px; padding: 0 20px 10px; line-height: 41px; }
.session-row { display: flex; align-items: center; gap: 12px; padding: 9px 12px 9px 20px; position: relative; cursor: pointer; }
.session-row::after { content: ""; position: absolute; left: 82px; right: 0; bottom: 0; height: 0.5px; background: var(--sep); }
.session-row:active { background: #121214; }
.session-info { flex: 1; min-width: 0; }
.session-line { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.session-name { font-size: 17px; font-weight: 600; letter-spacing: -.3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-time { font-size: 15px; color: var(--muted); display: flex; align-items: center; gap: 2px; flex-shrink: 0; letter-spacing: -.2px; }
.session-time svg { color: #5a5a5f; }
.session-preview { font-size: 15px; color: var(--muted); line-height: 20px; max-height: 40px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; letter-spacing: -.2px; margin-top: 1px; padding-right: 14px; }
.empty-state { white-space: pre-line; text-align: center; color: var(--muted2); padding: 60px 30px; font-size: 15px; line-height: 22px; }

.avatar {
  width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0; color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1;
  background: linear-gradient(180deg, #a9a9b1 0%, #78787f 100%); box-shadow: inset 0 -1px 2px rgba(0,0,0,.15);
}
.avatar.lv1 { background: linear-gradient(180deg, #74d781, #35a94c); }
.avatar.lv2 { background: linear-gradient(180deg, #ffc35a, #e38a00); }
.avatar.lv3 { background: linear-gradient(180deg, #ff8276, #df3f36); }
.av-count { font-size: 19px; font-weight: 600; letter-spacing: -.3px; }
.avatar-lg { width: 52px; height: 52px; }
.avatar-lg .av-count { font-size: 19px; }
.av-bac { font-size: 8.5px; font-weight: 600; opacity: .9; margin-top: 2px; font-variant-numeric: tabular-nums; letter-spacing: -.1px; }

.list-bottom { position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; padding: 8px 14px calc(var(--sab) + 10px); }
.search-pill { height: 50px; display: flex; align-items: center; gap: 8px; padding: 0 16px; color: var(--muted); font-size: 17px; }
.search-pill span { flex: 1; }

/* ============================================================
   conversation
   ============================================================ */
.messages {
  position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: calc(var(--sat) + var(--hdr-h) + 6px) 14px calc(var(--composer-h) + var(--sab) + 14px);
  display: flex; flex-direction: column; align-items: stretch;
  transition: padding-bottom .25s cubic-bezier(.2,.8,.2,1);
}
.chat-view.kb-open .messages { padding-bottom: calc(var(--composer-h) + 12px); }
.messages::after { content: ""; flex: 0 0 1px; }

.chat-header {
  position: absolute; top: 0; left: 0; right: 0; z-index: 3;
  height: calc(var(--sat) + var(--hdr-h));
  padding: calc(var(--sat) + 6px) 12px 0;
  display: flex; align-items: flex-start; justify-content: space-between;
  background: rgba(10,10,12,.62);
  -webkit-backdrop-filter: blur(30px) saturate(160%); backdrop-filter: blur(30px) saturate(160%);
  border-bottom: 0.5px solid rgba(255,255,255,.07);
}
.header-center { display: flex; flex-direction: column; align-items: center; cursor: pointer; padding-top: 2px; }
.header-name { font-size: 11px; color: var(--text); margin-top: 5px; display: flex; align-items: center; gap: 2px; letter-spacing: -.1px; }
.header-name svg { color: var(--muted); }

/* bubbles */
.msg {
  position: relative; max-width: 76%; padding: 7px 12px 7px 12px; border-radius: 18px;
  font-size: 17px; line-height: 22px; letter-spacing: -.3px; white-space: pre-wrap; overflow-wrap: anywhere;
  margin-top: 1.5px; -webkit-user-select: none; user-select: none; cursor: default;
  --bub: var(--blue);
}
.msg.gs { margin-top: 9px; }
.msg.sent { align-self: flex-end; background: var(--bub); color: #fff; }
.msg.recv { align-self: flex-start; background: var(--recv); color: #fff; }
.msg.sent.tail::before { content: ""; position: absolute; right: -7px; bottom: 0; width: 20px; height: 20px; background: var(--bub); border-bottom-left-radius: 16px 14px; }
.msg.sent.tail::after  { content: ""; position: absolute; right: -26px; bottom: 0; width: 26px; height: 20px; background: var(--bg); border-bottom-left-radius: 10px; }
.msg.recv.tail::before { content: ""; position: absolute; left: -7px; bottom: 0; width: 20px; height: 20px; background: var(--recv); border-bottom-right-radius: 16px 14px; }
.msg.recv.tail::after  { content: ""; position: absolute; left: -26px; bottom: 0; width: 26px; height: 20px; background: var(--bg); border-bottom-right-radius: 10px; }
.msg.selected { filter: brightness(1.25); }
.msg.sent:active { filter: brightness(1.08); }

.caption { font-size: 11px; color: var(--muted); font-weight: 500; margin: 3px 5px 0; letter-spacing: -.1px; }
.caption.r { align-self: flex-end; }
.caption.l { align-self: flex-start; }
.caption.reveal { animation: fadeIn .18s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }
.divider { text-align: center; font-size: 11px; color: var(--muted); margin: 16px 0 6px; letter-spacing: -.1px; }
.divider b { font-weight: 600; }
.divider.service { margin: 10px 0 0; color: var(--muted2); font-size: 11px; }

.typing { align-self: flex-start; position: relative; background: var(--recv); border-radius: 18px; padding: 13px 15px; display: flex; gap: 5px; margin-top: 9px; }
.typing::before { content: ""; position: absolute; left: -1px; bottom: -2px; width: 11px; height: 11px; border-radius: 50%; background: var(--recv); }
.typing::after { content: ""; position: absolute; left: -7px; bottom: -8px; width: 5px; height: 5px; border-radius: 50%; background: var(--recv); }
.typing i { width: 9px; height: 9px; border-radius: 50%; background: #8d8d93; animation: ty 1.3s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }
@keyframes ty { 0%, 60%, 100% { opacity: .35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* composer */
.composer {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 4;
  display: flex; align-items: flex-end; gap: 10px;
  padding: 6px 10px calc(var(--sab) + 8px);
  transition: padding .25s cubic-bezier(.2,.8,.2,1);
}
.chat-view.kb-open .composer { padding-bottom: 8px; background: rgba(32,32,34,.86); -webkit-backdrop-filter: blur(24px) saturate(160%); backdrop-filter: blur(24px) saturate(160%); }
.plus-btn { color: var(--text); }
.plus-btn.pending { color: var(--blue); }
.field { flex: 1; min-height: 40px; border-radius: 22px; padding: 8px 42px 8px 16px; display: flex; align-items: center; cursor: text; }
/* 17px keeps iOS from zooming the page when the field takes focus */
.field-input {
  flex: 1; width: 100%; display: block; background: transparent; border: 0; outline: none; resize: none;
  color: var(--text); caret-color: var(--blue); font: inherit; font-size: 17px; line-height: 22px; letter-spacing: -.3px;
  height: 22px; max-height: 120px; padding: 0; margin: 0; overflow-y: auto;
  -webkit-user-select: text; user-select: text; -webkit-appearance: none; appearance: none;
}
.field-input::placeholder { color: var(--muted); opacity: 1; }
.field-audio { position: absolute; right: 6px; bottom: 5px; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.send-btn { position: absolute; right: 5px; bottom: 5px; width: 30px; height: 30px; border-radius: 50%; background: var(--blue); color: #fff; display: none; align-items: center; justify-content: center; }
.send-btn:active { filter: brightness(1.15); }
.field.has-text .send-btn { display: flex; }
.field.has-text .field-audio { display: none; }

/* ============================================================
   sheets (action menu / picker / rename)
   ============================================================ */
.scrim { position: absolute; inset: 0; z-index: 40; background: rgba(0,0,0,.42); }
.scrim[hidden], .sheet[hidden] { display: none !important; }
.sheet {
  position: absolute; left: 10px; right: 10px; z-index: 45; border-radius: 28px; padding: 14px 14px 12px;
  bottom: calc(var(--sab) + 10px);
  background: var(--glass-bg-strong);
  animation: sheetIn .26s cubic-bezier(.2,.8,.2,1);
}
@keyframes sheetIn { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-title { font-size: 13px; color: var(--muted); text-align: center; padding: 2px 10px 12px; line-height: 18px; }
.sheet-title b { color: var(--text); font-weight: 600; font-size: 15px; display: block; margin-bottom: 2px; }
.sheet-btn { display: flex; align-items: center; justify-content: center; width: 100%; height: 52px; border-radius: 16px; background: rgba(255,255,255,.08); font-size: 17px; color: var(--blue); margin-top: 8px; letter-spacing: -.3px; }
.sheet-btn:active { background: rgba(255,255,255,.16); }
.sheet-btn.danger { color: #ff453a; }
.sheet-btn.primary { background: var(--blue); color: #fff; font-weight: 600; }
.sheet-btn.primary:active { filter: brightness(1.12); }
.sheet-btn.cancel { background: transparent; color: var(--text); font-weight: 600; }
.sheet-row { display: flex; gap: 8px; }
.sheet-row .sheet-btn { flex: 1; }
.sheet .field { margin: 2px 0 6px; padding-right: 16px; min-height: 44px; }
.sheet .field .field-audio, .sheet .field .send-btn { display: none !important; }
.sheet-field-wrap { position: relative; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; padding: 2px 0 8px; }
.chip { height: 34px; padding: 0 14px; border-radius: 999px; background: rgba(255,255,255,.08); color: var(--text); font-size: 15px; display: flex; align-items: center; }
.chip:active, .chip.on { background: rgba(10,132,255,.35); }
.picker-live { text-align: center; font-size: 15px; color: var(--muted); padding-bottom: 4px; }

/* wheel picker */
.wheel { display: flex; height: 180px; position: relative; margin: 4px 0 8px; }
.wheel::before { content: ""; position: absolute; left: 4px; right: 4px; top: 50%; height: 34px; transform: translateY(-50%); background: rgba(255,255,255,.09); border-radius: 10px; pointer-events: none; }
.wheel-col {
  flex: 1; overflow-y: scroll; scroll-snap-type: y mandatory; -webkit-overflow-scrolling: touch; text-align: center; position: relative;
  -webkit-mask-image: linear-gradient(transparent, #000 28%, #000 72%, transparent); mask-image: linear-gradient(transparent, #000 28%, #000 72%, transparent);
  overscroll-behavior: contain; touch-action: pan-y;
}
.wheel-col.day { flex: 1.9; }
.wheel-col.ampm { flex: .8; }
.wheel-item { height: 34px; line-height: 34px; scroll-snap-align: center; font-size: 21px; letter-spacing: -.3px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 4px; }
.wheel-pad { height: 73px; }

/* ============================================================
   dashboard
   ============================================================ */
.dash-view { z-index: 20; background: var(--bg); display: flex; flex-direction: column; }
.dash-top { position: absolute; top: 0; left: 0; right: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: calc(var(--sat) + 6px) 14px 8px; pointer-events: none; }
.dash-top > * { pointer-events: auto; }
.dash-top::before { z-index: -1; }
.list-top::before { z-index: -1; }
.dash-title { font-size: 17px; font-weight: 600; position: absolute; left: 0; right: 0; text-align: center; pointer-events: none; top: calc(var(--sat) + 18px); color: var(--muted); display: none; }
.dash-seg { display: flex; padding: 4px; gap: 2px; height: 44px; }
.dash-seg button { height: 34px; padding: 0 14px; border-radius: 999px; font-size: 14px; font-weight: 500; color: var(--muted); }
.dash-seg button.on { background: rgba(255,255,255,.14); color: var(--text); }
.dash-scroll { position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: calc(var(--sat) + 60px) 14px calc(var(--sab) + 30px); }
.dash-h1 { font-size: 34px; font-weight: 700; letter-spacing: .25px; padding: 0 6px 2px; line-height: 41px; }
.dash-sub { font-size: 15px; color: var(--muted); padding: 0 6px 14px; }
.card { background: #1c1c1e; border-radius: 22px; padding: 16px; margin-bottom: 12px; position: relative; }
.card-title { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 10px; }
.card-note { font-size: 12px; color: var(--muted2); margin-top: 8px; line-height: 16px; }
.hero { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.hero-num { font-size: 56px; font-weight: 700; letter-spacing: -1.5px; line-height: 1; }
.hero-unit { font-size: 15px; color: var(--muted); padding-bottom: 8px; line-height: 18px; }
.delta { font-size: 13px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: rgba(255,255,255,.08); color: var(--text); display: inline-flex; align-items: center; gap: 4px; margin-bottom: 8px; }
.delta.up { color: #ff9f0a; }
.delta.down { color: #30d158; }
.now-line { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 15px; color: var(--muted); }
.now-dot { width: 9px; height: 9px; border-radius: 50%; background: #30d158; box-shadow: 0 0 0 3px rgba(48,209,88,.18); }
.now-dot.buzz { background: #ff9f0a; box-shadow: 0 0 0 3px rgba(255,159,10,.18); }
.now-dot.hot { background: #ff453a; box-shadow: 0 0 0 3px rgba(255,69,58,.18); }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi { background: #1c1c1e; border-radius: 20px; padding: 14px 15px; min-height: 92px; display: flex; flex-direction: column; justify-content: space-between; }
.kpi-label { font-size: 13px; color: var(--muted); font-weight: 500; line-height: 16px; }
.kpi-value { font-size: 28px; font-weight: 700; letter-spacing: -.8px; line-height: 1.05; margin-top: 8px; }
.kpi-value small { font-size: 13px; font-weight: 500; color: var(--muted); letter-spacing: 0; margin-left: 3px; }
.kpi-sub { font-size: 12px; color: var(--muted2); margin-top: 4px; line-height: 15px; }
.chart { width: 100%; display: block; overflow: visible; font-family: var(--font); }
.chart text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .grid { stroke: #2c2c2e; stroke-width: 1; }
.chart .base { stroke: #3a3a3c; stroke-width: 1; }
.chart .lbl { fill: #fff; font-weight: 600; }
.chart .ref { stroke: #ff9f0a; stroke-width: 1; }
.chart .ref-t { fill: #ff9f0a; font-weight: 600; }
.chart .bar { fill: var(--blue); }
.chart .bar.dim { fill: #3b7bd1; opacity: .55; }
.chart .bar.hit { fill: transparent; }
.chart .line { fill: none; stroke: var(--blue); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--blue); opacity: .1; }
.chart .cross { stroke: #8d8d93; stroke-width: 1; }
.chart .dot { fill: var(--blue); stroke: #1c1c1e; stroke-width: 2; }
.tip { position: absolute; pointer-events: none; background: rgba(60,60,64,.96); color: #fff; font-size: 12px; line-height: 16px; padding: 6px 9px; border-radius: 10px; box-shadow: 0 6px 18px rgba(0,0,0,.4); white-space: nowrap; transform: translate(-50%, -100%); z-index: 2; }
.tip b { font-weight: 600; }
.hbar-row { display: grid; grid-template-columns: 96px 1fr 44px; align-items: center; gap: 10px; height: 30px; font-size: 14px; }
.hbar-name { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-transform: capitalize; }
.hbar-track { height: 14px; border-radius: 4px; position: relative; }
.hbar-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--blue); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar-val { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
.slist { display: flex; flex-direction: column; }
.srow { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 0.5px solid var(--sep); }
.srow:last-child { border-bottom: 0; }
.srow .avatar { width: 38px; height: 38px; }
.srow .avatar .av-count { font-size: 15px; }
.srow-main { flex: 1; min-width: 0; }
.srow-name { font-size: 16px; font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.srow-name span:last-child { color: var(--muted); font-weight: 400; font-size: 14px; }
.srow-sub { font-size: 13px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fact { background: #1c1c1e; border-radius: 20px; padding: 14px 15px; min-height: 96px; display: flex; flex-direction: column; justify-content: space-between; }
.fact-emoji { font-size: 22px; line-height: 1; }
.fact-big { font-size: 22px; font-weight: 700; letter-spacing: -.5px; margin-top: 10px; line-height: 1.1; }
.fact-text { font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 15px; }
.table-toggle { font-size: 13px; color: var(--blue); margin-top: 10px; display: inline-block; }
.dtable { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 13px; font-variant-numeric: tabular-nums; }
.dtable th { text-align: left; color: var(--muted); font-weight: 500; padding: 4px 0; border-bottom: 0.5px solid var(--sep); }
.dtable td { padding: 5px 0; border-bottom: 0.5px solid rgba(84,84,88,.3); }
.dtable td:not(:first-child), .dtable th:not(:first-child) { text-align: right; }
.dash-empty { text-align: center; color: var(--muted); padding: 60px 20px; font-size: 15px; line-height: 22px; }
.dash-foot { font-size: 11px; color: var(--muted2); text-align: center; padding: 10px 20px 0; line-height: 15px; }

.loading { opacity: .55; transition: opacity .2s; }
