/* Vesper Blue. Liquid Light (light) and Deep Blue (dark, follows the phone). iMessage geometry from
   holler/docs/imessage-spec.md; blue light only where something is happening. Only transform and opacity animate. */
:root {
  --bg: #FFFFFF; --ink: #0B1220; --sub: #566173; --mute: #5F6B7A; --hair: rgba(11,18,32,0.09); --chev: #B9C3D1;
  --glass: rgba(255,255,255,0.6); --glass-solid: rgba(255,255,255,0.9);
  --glass-rim: inset 0 0 0 1px rgba(255,255,255,0.88), inset 0 1px 0 #FFFFFF; --glass-shadow: 0 6px 18px rgba(20,80,180,0.14);
  --recv: #EEF2F8; --recv-ink: #0B1220; --recv-rim: inset 0 0 0 0.5px rgba(255,255,255,0.9), 0 1px 3px rgba(15,40,90,0.07);
  --a1: rgba(46,139,255,0.55); --a2: rgba(0,198,255,0.5); --a3: rgba(91,92,255,0.26); --athread: 0.5;
  --av-bg: linear-gradient(160deg, #EAF3FF 0%, #CFE1FA 100%); --av-ink: #2A5FB8; --av-rim: inset 0 0 0 1px rgba(255,255,255,0.9), inset 0 -6px 10px rgba(46,139,255,0.14), 0 3px 8px rgba(20,80,180,0.12);
  --av-unknown: linear-gradient(160deg, #DCE9FB 0%, #B6CDEE 100%); --av-glyph: #FFFFFF;
  --field: rgba(255,255,255,0.96); --accent: #1F7BFF; --unread: #1F8BFF; --red: #D70015; --red-dot: #E0282E;
  --amber-bg: rgba(255,248,236,0.92); --amber-ink: #8A4B00;
  --light-edge: linear-gradient(100deg, #B5F0FF, #00C6FF, #2E8BFF, #7A7CFF);
  --font: -apple-system, 'SF Pro Text', 'Helvetica Neue', system-ui, sans-serif;
  --display: -apple-system, 'SF Pro Display', 'Helvetica Neue', system-ui, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, monospace;
  --app-h: 100dvh;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #050912; --ink: #F2F5FA; --sub: #97A3BA; --mute: #8592AB; --hair: rgba(255,255,255,0.08); --chev: #4A5670;
    --glass: rgba(255,255,255,0.07); --glass-solid: rgba(20,28,44,0.85);
    --glass-rim: inset 0 0 0 1px rgba(255,255,255,0.13), inset 0 1px 0 rgba(255,255,255,0.16); --glass-shadow: 0 8px 24px rgba(0,0,0,0.4);
    --recv: #151C2A; --recv-ink: #E9EDF5; --recv-rim: inset 0 0 0 0.5px rgba(255,255,255,0.09);
    --a1: rgba(20,80,255,0.55); --a2: rgba(0,184,255,0.34); --a3: rgba(91,61,255,0.3); --athread: 0.5;
    --av-bg: linear-gradient(160deg, #1A2A48 0%, #0D1526 100%); --av-ink: #9AD3FF; --av-rim: inset 0 0 0 1px rgba(120,175,255,0.28), inset 0 1px 0 rgba(255,255,255,0.12);
    --av-unknown: linear-gradient(160deg, #1A2A48 0%, #0D1526 100%); --av-glyph: #5E7CB0;
    --field: #0D1422; --accent: #5FD4FF; --unread: #2FC7FF; --red: #FF6B6B; --red-dot: #FF453A;
    --amber-bg: rgba(255,159,10,0.1); --amber-ink: #FFC46B;
    --light-edge: linear-gradient(100deg, #B5F0FF, #00D1FF, #2E8BFF, #7A7CFF);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--font); -webkit-font-smoothing: antialiased; overscroll-behavior: none; }
body { overflow: hidden; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#app { position: fixed; left: 0; right: 0; top: 0; height: var(--app-h); overflow: hidden; }
.screen { position: absolute; inset: 0; overflow: hidden; background: var(--bg); }

/* ---------- glass ---------- */
.glass { background: var(--glass); -webkit-backdrop-filter: blur(18px) saturate(170%); backdrop-filter: blur(18px) saturate(170%); box-shadow: var(--glass-rim), var(--glass-shadow); border: 0; }
.circle { width: 44px; height: 44px; border-radius: 22px; display: flex; align-items: center; justify-content: center; padding: 0; }
.orb { border: 0; padding: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; color: #fff;
  background: linear-gradient(160deg, #7FDBFF 0%, #2E8BFF 50%, #1A4FE6 100%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.35), inset 0 1.5px 0 rgba(255,255,255,0.6), 0 8px 20px rgba(30,100,255,0.4), 0 0 16px rgba(0,198,255,0.35); }
.orb.green { background: linear-gradient(160deg, #8BE59A 0%, #34C759 55%, #1E9E45 100%); box-shadow: inset 0 1.5px 0 rgba(255,255,255,0.55), 0 4px 12px rgba(30,160,70,0.4); }

/* ---------- aura ---------- */
.aura { position: absolute; left: 0; right: 0; top: 0; height: 440px; overflow: hidden; pointer-events: none; }
.aura i { position: absolute; border-radius: 50%; }
.aura .b1 { left: -90px; top: -120px; width: 360px; height: 330px; background: radial-gradient(closest-side, var(--a1), transparent); animation: d1 11s ease-in-out infinite alternate; }
.aura .b2 { right: -110px; top: -70px; width: 340px; height: 300px; background: radial-gradient(closest-side, var(--a2), transparent); animation: d2 13s ease-in-out infinite alternate; }
.aura .b3 { left: 110px; top: 40px; width: 260px; height: 220px; background: radial-gradient(closest-side, var(--a3), transparent); animation: d3 9s ease-in-out infinite alternate; }
.aura .fade { position: absolute; left: 0; right: 0; bottom: 0; height: 200px; background: linear-gradient(180deg, transparent, var(--bg)); }
.thread .aura { height: 270px; opacity: var(--athread); }
.base-glow { position: absolute; left: 50%; bottom: -130px; width: 440px; height: 250px; margin-left: -220px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(closest-side, rgba(46,139,255,0.2), transparent); }
@keyframes d1 { to { transform: translate(34px, 18px) scale(1.08); } }
@keyframes d2 { to { transform: translate(-30px, 22px) scale(1.12); } }
@keyframes d3 { to { transform: translate(18px, -16px); } }

/* ---------- inbox ---------- */
.inbox .top { position: absolute; left: 16px; right: 16px; top: calc(env(safe-area-inset-top) + 8px); height: 44px; display: flex; justify-content: flex-end; z-index: 3; }
.inbox .top .on { box-shadow: var(--glass-rim), var(--glass-shadow), 0 0 0 2px var(--unread); }
.brand { position: absolute; left: 16px; top: calc(env(safe-area-inset-top) + 62px); margin: 0; display: flex; align-items: center; gap: 11px; font-family: var(--display); font-size: 31px; line-height: 38px; letter-spacing: -0.4px; font-weight: 600; z-index: 2; }
.brand .blue { color: #1E6FFF; }
@media (prefers-color-scheme: dark) { .brand .blue { color: #4DA3FF; } }
.tile { position: relative; width: 36px; height: 36px; border-radius: 9px; overflow: hidden; flex: none; border: 1px solid transparent;
  background: radial-gradient(60% 50% at 50% 104%, rgba(0,225,255,0.55), rgba(0,225,255,0) 70%) padding-box, linear-gradient(165deg, #59C8FF 0%, #1E7BFF 52%, #1240D8 100%) padding-box, conic-gradient(from 200deg, #A8EEFF, #3B8BFF, #8F7BFF, #A8EEFF) border-box;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.5), 0 4px 10px rgba(20,90,230,0.28); }
.tile svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.pill { position: absolute; left: 16px; top: calc(env(safe-area-inset-top) + 110px); height: 28px; display: flex; align-items: center; gap: 9px; padding: 0 12px 0 10px; border-radius: 14px;
  font-family: var(--mono); font-size: 11px; line-height: 13px; color: var(--sub); z-index: 2; }
.pill b { font-weight: 700; letter-spacing: 0.1em; color: var(--ink); }
.pill .dot { position: relative; width: 7px; height: 7px; }
.pill .dot i, .pill .dot s { position: absolute; inset: 0; border-radius: 4px; background: #00B8F0; box-shadow: 0 0 6px rgba(0,198,255,0.9); }
.pill .dot s { animation: pulse 1.8s ease-out infinite; text-decoration: none; }
.pill.down { background: var(--amber-bg); color: var(--amber-ink); box-shadow: inset 0 0 0 1px rgba(255,159,10,0.35); -webkit-backdrop-filter: none; backdrop-filter: none; }
.pill.down b { color: var(--amber-ink); }
.pill.down .dot i { background: #FF9F0A; box-shadow: 0 0 6px rgba(255,159,10,0.8); }
.pill.down .dot s { display: none; }
.pill .why { font-family: var(--font); font-size: 12px; }
@keyframes pulse { from { transform: scale(1); opacity: 0.7; } to { transform: scale(2.6); opacity: 0; } }
.list { position: absolute; left: 0; right: 0; top: calc(env(safe-area-inset-top) + 150px); bottom: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 120px; }
.alerts { margin: 0 16px 8px; padding: 12px 14px; border-radius: 16px; font-size: 14px; line-height: 19px; display: flex; gap: 12px; align-items: center; }
.alerts p { margin: 0; flex: 1; color: var(--sub); }
.alerts button { border: 0; border-radius: 14px; height: 30px; padding: 0 14px; font-weight: 600; color: #fff; background: #1F7BFF; flex: none; }
.row { display: block; position: relative; height: 87px; text-decoration: none; color: inherit; }
.row:active { background: rgba(31,123,255,0.06); }
.row .ud { position: absolute; left: 7px; top: 18px; width: 9px; height: 9px; border-radius: 5px; background: var(--unread); box-shadow: 0 0 0 3px rgba(31,139,255,0.14), 0 0 10px rgba(31,139,255,0.7); }
.av { position: absolute; left: 24px; top: 12px; width: 46px; height: 46px; border-radius: 23px; background: var(--av-bg); box-shadow: var(--av-rim);
  display: flex; align-items: center; justify-content: center; color: var(--av-ink); font-family: ui-rounded, var(--font); font-size: 17px; font-weight: 600; overflow: hidden; }
.av.unknown { background: var(--av-unknown); align-items: flex-end; }
.av.unknown svg { fill: var(--av-glyph); }
.row .txt { position: absolute; left: 83px; right: 0; top: 0; bottom: 0; border-bottom: 0.5px solid var(--hair); }
.row .nm { position: absolute; left: 0; right: 110px; top: 11px; font-size: 17px; line-height: 22px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .tm { position: absolute; right: 34px; top: 13px; font-family: var(--mono); font-size: 12px; line-height: 18px; color: var(--mute); }
.row .chev { position: absolute; right: 18px; top: 16px; stroke: var(--chev); }
.row .pv { position: absolute; left: 0; right: 24px; top: 34px; font-size: 15px; line-height: 20px; color: var(--sub); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.empty { margin: 60px 32px; text-align: center; color: var(--sub); font-size: 15px; line-height: 21px; }
.bottom-fade { position: absolute; left: 0; right: 0; bottom: 0; height: 150px; background: linear-gradient(180deg, transparent 0%, var(--bg) 70%); pointer-events: none; }
.search { position: absolute; left: 16px; right: 76px; bottom: calc(env(safe-area-inset-bottom) + 12px); height: 48px; border-radius: 24px; display: flex; align-items: center; gap: 8px; padding: 0 14px; z-index: 3; }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; font-size: 17px; outline: none; }
.search svg { stroke: var(--mute); flex: none; }
.compose { position: absolute; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 12px); width: 48px; height: 48px; border-radius: 24px; z-index: 3; }

/* ---------- thread ---------- */
.msgs { position: absolute; left: 0; right: 0; top: 0; bottom: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 160px) 16px calc(env(safe-area-inset-bottom) + 84px); }
.msgs .spacer { flex: 1; }
.top-fade { position: absolute; left: 0; right: 0; top: 0; height: calc(env(safe-area-inset-top) + 150px); background: linear-gradient(180deg, var(--bg) 0%, color-mix(in srgb, var(--bg) 90%, transparent) 55%, transparent 100%); pointer-events: none; }
.back { position: absolute; left: 16px; top: calc(env(safe-area-inset-top) + 14px); z-index: 4; }
.back svg, .top svg { stroke: var(--ink); }
.who { position: absolute; left: 70px; right: 70px; top: calc(env(safe-area-inset-top) + 4px); display: flex; flex-direction: column; align-items: center; z-index: 4; }
.who .ring { position: relative; width: 70px; height: 70px; }
.who .ring .spin { position: absolute; inset: 0; border-radius: 35px; background: conic-gradient(from 0deg, rgba(0,198,255,0) 0deg, #00C6FF 80deg, #2E8BFF 150deg, rgba(122,124,255,0) 230deg);
  filter: drop-shadow(0 0 4px rgba(0,180,255,0.6)); animation: spin 5s linear infinite; opacity: 0; transition: opacity 0.4s; }
.who.busy .ring .spin { opacity: 1; }
.who .av { left: 5px; top: 5px; width: 60px; height: 60px; border-radius: 30px; font-size: 23px; box-shadow: var(--av-rim), 0 0 0 2px var(--bg); }
.who .name { margin-top: -7px; position: relative; height: 32px; max-width: 100%; padding: 0 12px 0 14px; border-radius: 16px; display: flex; align-items: center; gap: 5px; font-size: 15px; font-weight: 600; }
.who .name span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who .name svg { stroke: var(--mute); flex: none; }
.chip { margin: 6px 0 0; display: flex; align-items: center; gap: 5px; font-family: var(--mono); font-size: 10px; line-height: 12px; letter-spacing: 0.12em; font-weight: 700; color: var(--accent); }
.chip i { width: 5px; height: 5px; border-radius: 3px; background: var(--unread); box-shadow: 0 0 6px rgba(31,139,255,0.8); }
.chip.sms { color: #1E9E45; } .chip.sms i { background: #34C759; box-shadow: 0 0 6px rgba(52,199,89,0.7); }
@keyframes spin { to { transform: rotate(360deg); } }

.stamp { align-self: center; margin: 14px 0; font-family: var(--mono); font-size: 11px; line-height: 15px; letter-spacing: 0.08em; color: var(--mute); text-align: center; }
.stamp b { font-weight: 700; color: var(--ink); }
.b { position: relative; max-width: min(281px, 75%); padding: 9.5px 14px; border-radius: 20px; font-size: 17px; line-height: 21px; white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 3px; }
.b.first { margin-top: 10px; }
.b.them { align-self: flex-start; background: var(--recv); color: var(--recv-ink); box-shadow: var(--recv-rim); }
.b.me { align-self: flex-end; color: #fff; background-repeat: no-repeat; box-shadow: inset 0 1px 0 rgba(255,255,255,0.4); }
.b.me.blue { background-color: #0A84FF; }
.b.me.green { background-color: #34C759; }
.b a { color: inherit; text-decoration: underline; }
.b.tail.me::before { content: ""; position: absolute; bottom: -1.6px; right: -5.6px; height: 16px; transform: translateY(-1.6px); border-bottom-left-radius: 12.8px 11.2px; border-right: 16px solid var(--tail, #0A84FF); }
.b.tail.me::after { content: ""; position: absolute; bottom: -1.6px; right: -40px; width: 10px; height: 16px; background: var(--bg); border-bottom-left-radius: 8px; transform: translate(-30px, -2px); }
.b.tail.them::before { content: ""; position: absolute; bottom: -1.6px; left: -5.6px; height: 16px; transform: translateY(-1.6px); border-bottom-right-radius: 12.8px 11.2px; border-left: 16px solid var(--recv); }
.b.tail.them::after { content: ""; position: absolute; bottom: -1.6px; left: 20px; width: 10px; height: 16px; background: var(--bg); border-bottom-right-radius: 8px; transform: translate(-30px, -2px); }
.b.sending { border: 1px solid transparent; padding: 8.5px 13px; box-shadow: 0 0 0 3px rgba(0,198,255,0.12), 0 0 18px rgba(0,170,255,0.4); }
.b.sending .sweep { position: absolute; inset: 0; border-radius: 19px; overflow: hidden; pointer-events: none; }
.b.sending .sweep i { position: absolute; top: 0; bottom: 0; left: -90px; width: 70px; background: linear-gradient(100deg, transparent, rgba(255,255,255,0.5), transparent); animation: sweep 2.2s cubic-bezier(.4,0,.2,1) infinite; }
.b.sending > span { position: relative; }
.b.failed-row { margin-right: 32px; }
@keyframes sweep { 0% { transform: translateX(0); } 70%, 100% { transform: translateX(380px); } }
.b img { display: block; max-width: 240px; max-height: 320px; border-radius: 14px; margin: -4px -8px; }
.b.photo { padding: 0; background: none !important; box-shadow: none; }
.b.photo img { margin: 0; border-radius: 18px; }
.b.photo::before, .b.photo::after { display: none; }
.fail { position: absolute; right: -32px; top: 50%; margin-top: -12px; width: 24px; height: 24px; border-radius: 12px; border: 0; padding: 0; background: var(--red-dot); color: #fff; font-weight: 700; font-size: 16px; line-height: 24px; }
.rcpt { align-self: flex-end; margin: 5px 2px 0 0; font-family: var(--mono); font-size: 11px; line-height: 15px; letter-spacing: 0.06em; color: var(--mute); display: flex; align-items: center; gap: 6px; }
.rcpt b { font-weight: 700; color: var(--ink); }
.rcpt.live { color: var(--accent); font-weight: 700; letter-spacing: 0.08em; }
.rcpt.bad { color: var(--red); }
.rcpt.bad button { border: 0; background: none; color: inherit; font: inherit; padding: 0; text-decoration: underline; }
.segs { display: flex; gap: 3px; } .segs i { width: 10px; height: 3px; border-radius: 2px; background: #00B8F0; animation: seg 1.2s ease-in-out infinite; }
.segs i:nth-child(2) { background: #1F8BFF; animation-delay: .2s; } .segs i:nth-child(3) { background: #3F6BFF; animation-delay: .4s; }
@keyframes seg { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
.by { align-self: flex-end; margin: 3px 4px 0 0; font-size: 11px; color: var(--mute); }
.by.them { align-self: flex-start; margin-left: 4px; }

.bar { position: absolute; left: 16px; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 12px); display: flex; align-items: flex-end; gap: 10px; z-index: 4; }
html.kb-open .bar, html.kb-open .search, html.kb-open .compose { bottom: 8px; }
html.kb-open .msgs { padding-bottom: 64px; }
.field { flex: 1; min-height: 40px; border-radius: 20px; display: flex; align-items: flex-end; padding: 0 4px 0 15px; border: 1px solid transparent;
  background: var(--glass) padding-box; -webkit-backdrop-filter: blur(18px) saturate(170%); backdrop-filter: blur(18px) saturate(170%); box-shadow: var(--glass-rim), var(--glass-shadow); transition: box-shadow 0.25s; }
.field:focus-within { background: var(--field) padding-box, var(--light-edge) border-box; box-shadow: 0 0 0 3px rgba(0,198,255,0.1), 0 0 16px rgba(0,170,255,0.32), 0 0 34px rgba(46,139,255,0.18); }
.field textarea { flex: 1; min-width: 0; border: 0; background: transparent; resize: none; outline: none; font-size: 17px; line-height: 21px; padding: 9px 0; max-height: 132px; caret-color: #1F8BFF; }
.field textarea::placeholder { color: var(--mute); opacity: 0.8; }
.send { width: 30px; height: 30px; border-radius: 15px; margin: 4px 0; flex: none; }
.send[hidden] { display: none; }

/* ---------- new message ---------- */
.newmsg h1 { position: absolute; left: 70px; right: 70px; top: calc(env(safe-area-inset-top) + 19px); margin: 0; text-align: center; font-size: 17px; line-height: 22px; font-weight: 600; }
.to { position: absolute; left: 16px; right: 0; top: calc(env(safe-area-inset-top) + 68px); height: 46px; border-bottom: 0.5px solid var(--hair); display: flex; align-items: center; gap: 8px; padding-right: 16px; }
.to label { font-size: 17px; color: var(--mute); }
.to input { flex: 1; min-width: 0; border: 0; background: transparent; font-size: 17px; outline: none; color: var(--accent); }
.from { position: absolute; left: 16px; right: 16px; top: calc(env(safe-area-inset-top) + 124px); margin: 0; font-size: 13px; line-height: 17px; color: var(--mute); }
.err { position: absolute; left: 16px; right: 16px; top: calc(env(safe-area-inset-top) + 150px); margin: 0; font-size: 14px; color: var(--red); }

/* ---------- sheet, sign-in ---------- */
.veil { position: fixed; inset: 0; background: rgba(5,9,18,0.25); z-index: 20; display: flex; align-items: flex-end; }
.sheet { width: 100%; margin: 0 8px calc(env(safe-area-inset-bottom) + 8px); padding: 18px 16px 16px; border-radius: 28px; background: var(--glass-solid); -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px); box-shadow: var(--glass-rim), 0 20px 40px rgba(0,0,0,0.2); }
.sheet h2 { margin: 0 0 4px; font-size: 17px; text-align: center; }
.sheet p { margin: 0 0 12px; font-size: 13px; color: var(--mute); text-align: center; }
.sheet input { width: 100%; height: 44px; border-radius: 12px; border: 1px solid var(--hair); background: var(--bg); padding: 0 12px; font-size: 17px; outline: none; }
.sheet .acts { display: flex; gap: 10px; margin-top: 12px; }
.sheet .acts button { flex: 1; height: 44px; border-radius: 14px; border: 0; font-weight: 600; font-size: 17px; }
.sheet .acts .ok { background: #1F7BFF; color: #fff; } .sheet .acts .no { background: var(--recv); }
.signin { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 32px; }
.signin .big { width: 96px; height: 96px; border-radius: 22px; }
.signin h1 { margin: 0; font-family: var(--display); font-size: 30px; font-weight: 600; letter-spacing: -0.4px; }
.signin p { margin: 0; text-align: center; color: var(--sub); font-size: 15px; line-height: 21px; max-width: 300px; }
.signin form { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 10px; }
.signin input { height: 48px; border-radius: 14px; border: 1px solid var(--hair); background: var(--bg); padding: 0 14px; font-size: 16px; outline: none; }
.signin button { height: 48px; border-radius: 24px; font-weight: 600; font-size: 17px; }
.toast { position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 10px); transform: translateX(-50%); z-index: 30; padding: 10px 16px; border-radius: 18px; font-size: 14px; max-width: 90%; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
