/* ---------- Landing ---------- */
.site-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 1160px; margin: 0 auto; padding: 16px 20px; }
.site-header .actions { display: flex; gap: 8px; }
.hero-wrap { background: radial-gradient(55% 60% at 88% 18%, color-mix(in srgb, var(--cyan) 16%, transparent), transparent 72%); }
.hero { display: grid; gap: 56px; align-items: center; max-width: 1160px; margin: 0 auto; padding: 32px 20px 80px; }
@media (min-width: 900px) { .hero { grid-template-columns: 1.05fr .95fr; padding-top: 72px; } }
.hero h1 { font-size: clamp(3.25rem, 10vw, 5.75rem); font-weight: 800; line-height: .96; letter-spacing: -.05em; }
.hero h1 span { display: block; }
.hero-lede { max-width: 31rem; margin-top: 26px; color: var(--ink-2); font-size: 1.1875rem; line-height: 1.55; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }
.hero-note { margin-top: 16px; color: var(--ink-3); font-size: .875rem; }

.convo { width: 100%; max-width: 410px; margin: 0 auto; overflow: hidden; border: 1px solid var(--line); border-radius: 26px; background: var(--surface); box-shadow: var(--shadow-pop); }
.convo-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.convo-head strong { display: block; font-weight: 700; line-height: 1.2; }
.convo-head small { display: flex; align-items: center; gap: 6px; color: var(--ink-3); font-size: .8125rem; }
.dot-online { width: 8px; height: 8px; border-radius: 50%; background: var(--cyan); }
.convo-body { display: grid; gap: 6px; align-content: start; min-height: 300px; padding: 18px 16px; background: var(--bg); }
.msg { max-width: 80%; padding: 9px 14px; border-radius: 18px; font-size: .9375rem; line-height: 1.4; opacity: 0; animation: msg-in .35s ease-out forwards; }
.msg--in { justify-self: start; border: 1px solid var(--line); border-bottom-left-radius: 6px; background: var(--surface); }
.msg--out { justify-self: end; border-bottom-right-radius: 6px; background: var(--primary); color: var(--on-primary); }
.convo-body > .msg:nth-child(1) { animation-delay: .4s; }
.convo-body > .msg:nth-child(2) { animation-delay: 1.1s; }
.convo-body > .msg:nth-child(3) { animation-delay: 1.8s; }
.turn { display: grid; }
.turn > * { grid-area: 1 / 1; }
.typing { align-self: start; justify-self: start; display: flex; gap: 4px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 18px 18px 18px 6px; background: var(--surface); opacity: 0; animation: typing-show 1.5s 2.6s forwards; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); animation: bounce 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
.turn .msg { animation-delay: 4.1s; }
@keyframes msg-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes typing-show { 0%, 99% { opacity: 1; } 100% { opacity: 0; } }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-4px); } }
.convo-foot { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.fake-input { flex: 1; display: flex; align-items: center; min-height: 40px; padding: 0 16px; border-radius: 99px; background: var(--sunken); color: var(--ink-3); font-size: .9375rem; }
.fake-send { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--primary); color: #fff; }

.features { max-width: 1160px; margin: 0 auto; padding: 24px 20px 88px; }
.features h2 { max-width: 20ch; font-size: clamp(1.9rem, 4.5vw, 2.75rem); letter-spacing: -.035em; }
.feature-list { display: grid; grid-template-columns: 1fr; gap: 0 56px; margin-top: 40px; }
@media (min-width: 760px) { .feature-list { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1040px) { .feature-list { grid-template-columns: repeat(3, 1fr); } }
.feature { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; padding: 24px 0 26px; border-top: 1px solid var(--line-strong); }
.feature .icon { width: 24px; height: 24px; margin-top: 2px; color: var(--primary); }
.feature h3 { font: 700 1.125rem/1.3 var(--font-ui); letter-spacing: 0; }
.feature p { grid-column: 2; color: var(--ink-2); }
.site-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; max-width: 1160px; margin: 0 auto; padding: 24px 20px 40px; border-top: 1px solid var(--line); color: var(--ink-3); font-size: .875rem; }
.site-footer nav { display: flex; gap: 20px; }
.site-footer a { color: var(--ink-2); }

/* ---------- Auth ---------- */
.auth { display: grid; min-height: 100vh; min-height: 100dvh; }
@media (min-width: 960px) { .auth { grid-template-columns: minmax(380px, 5fr) 6fr; } }
.auth-brand { display: none; flex-direction: column; justify-content: space-between; padding: 48px; color: #fff; background: linear-gradient(165deg, #2A21B8 0%, #15113F 100%); }
@media (min-width: 960px) { .auth-brand { display: flex; } }
.auth-brand h2 { max-width: 12ch; font-size: clamp(2.5rem, 4vw, 3.5rem); font-weight: 800; line-height: 1; letter-spacing: -.045em; }
.auth-brand p { max-width: 26rem; margin-top: 20px; color: #C9CCF5; font-size: 1.0625rem; }
.auth-brand small { color: #9EA3E6; }
.auth-main { display: grid; place-items: center; padding: 20px 20px 48px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-mobile-brand { margin-bottom: 32px; }
@media (min-width: 960px) { .auth-mobile-brand { display: none; } }
.auth-card h1 { font-size: 2rem; letter-spacing: -.035em; }
.auth-card .lede { margin-top: 8px; color: var(--ink-2); }
.auth-card .form { margin-top: 28px; }
.form-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.auth-alt { margin-top: 24px; color: var(--ink-2); font-size: .9375rem; text-align: center; }
.auth-back { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 24px; color: var(--ink-2); font-weight: 600; text-decoration: none; }

/* ---------- Legal ---------- */
.prose { max-width: 680px; margin: 0 auto; padding: 24px 20px 80px; }
.prose h1 { font-size: 2.25rem; letter-spacing: -.035em; }
.prose h2 { margin-top: 32px; font-size: 1.25rem; }
.prose p, .prose li { margin-top: 12px; color: var(--ink-2); }
.prose ul { padding-left: 20px; }
.prose .meta { margin-top: 8px; color: var(--ink-3); font-size: .9375rem; }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: 1fr; min-height: 100vh; min-height: 100dvh; }
@media (min-width: 1024px) { .shell { grid-template-columns: 248px 1fr; } }
.sidebar { display: none; }
@media (min-width: 1024px) {
  .sidebar { position: sticky; top: 0; display: flex; flex-direction: column; gap: 24px; height: 100vh; height: 100dvh; padding: 20px 14px; border-right: 1px solid var(--line); background: var(--surface); }
  .sidebar .brand { padding-left: 8px; }
}
.side-nav { display: grid; gap: 2px; }
.side-link { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 12px; color: var(--ink-2); font-weight: 600; text-decoration: none; }
.side-link:hover { background: var(--sunken); color: var(--ink); }
.side-link.is-active { background: var(--primary-soft); color: var(--primary); }
.side-me { display: flex; align-items: center; gap: 10px; margin-top: auto; padding: 8px; border-radius: 12px; color: var(--ink); text-decoration: none; }
.side-me:hover { background: var(--sunken); }
.side-me-text { min-width: 0; }
.side-me-text strong, .side-me-text small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-me-text small { color: var(--ink-3); }
.shell-main { display: flex; flex-direction: column; min-width: 0; }
.appbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 60px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px 20px; border-bottom: 1px solid var(--line); background: var(--bg); }
.appbar-title { font-size: 1.375rem; letter-spacing: -.03em; }
.appbar-actions { display: flex; align-items: center; gap: 4px; }
.content { flex: 1; padding-bottom: calc(76px + env(safe-area-inset-bottom)); outline: none; }
@media (min-width: 1024px) { .content { padding-bottom: 0; } }
.tabbar { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr); padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid var(--line); background: var(--surface); }
@media (min-width: 1024px) { .tabbar { display: none; } }
.tab { display: grid; justify-items: center; align-content: center; gap: 2px; min-height: 60px; padding: 6px 4px; color: var(--ink-3); font-size: .75rem; font-weight: 600; text-decoration: none; }
.tab .icon { width: 24px; height: 24px; }
.tab.is-active { color: var(--primary); box-shadow: inset 0 2px 0 var(--primary); }

.split { display: grid; min-height: calc(100dvh - 60px); }
@media (min-width: 1024px) { .split { grid-template-columns: 360px 1fr; } }
.pane-list { background: var(--surface); border-right: 1px solid var(--line); }
.pane-detail { display: none; }
@media (min-width: 1024px) { .pane-detail { display: grid; place-items: center; } }
.list-tools { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.list-tools a { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 14px; border-radius: 99px; background: var(--sunken); color: var(--ink-3); text-decoration: none; }

.page { max-width: 720px; margin: 0 auto; padding: 20px; }
.panel { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.panel + .panel { margin-top: 16px; }
.panel-section { padding: 20px; }
.panel-section + .panel-section { border-top: 1px solid var(--line); }
.section-title { font: 700 1rem/1.3 var(--font-ui); letter-spacing: 0; }
.section-lede { margin-top: 2px; color: var(--ink-2); font-size: .875rem; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-top: 1px solid var(--line); }
.setting:first-of-type { border-top: 0; }
.setting-text strong { display: block; font-weight: 600; }
.setting-text small { color: var(--ink-3); font-size: .875rem; }
.setting select { width: auto; min-width: 140px; }
.profile-head { display: flex; align-items: center; gap: 18px; }
.avatar-edit { position: relative; }
.avatar-edit .icon-btn { position: absolute; right: -6px; bottom: -6px; width: 36px; height: 36px; border: 2px solid var(--surface); background: var(--primary); color: #fff; }
.avatar-edit .icon-btn:hover { background: var(--primary-hover); color: #fff; }
.profile-head h2 { font-size: 1.375rem; }
.profile-head p { color: var(--ink-3); }
.profile-card { display: grid; justify-items: center; gap: 4px; padding: 28px 20px 8px; text-align: center; }
.profile-card h2 { margin-top: 10px; font-size: 1.375rem; }
.profile-card .bio { margin-top: 8px; max-width: 30ch; color: var(--ink-2); }
.search { position: relative; }
.search .icon { position: absolute; left: 14px; top: 14px; color: var(--ink-3); }
.search .input { padding-left: 44px; }
.results { margin-top: 12px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.counter { color: var(--ink-3); font-size: .8125rem; text-align: right; }
.session-icon { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 12px; background: var(--sunken); color: var(--ink-2); }
.panel-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.list-plain { margin-top: 8px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-md); }
.list-plain .row { cursor: default; }
.list-plain .row:hover { background: none; }
.inline { display: inline-flex; align-items: center; gap: 8px; }

/* ---------- Conversation ---------- */
.chat-screen { display: flex; flex-direction: column; height: 100dvh; background: var(--bg); }
.chat-head { display: flex; align-items: center; gap: 10px; padding: calc(8px + env(safe-area-inset-top)) 8px 8px 8px; border-bottom: 1px solid var(--line); background: var(--surface); }
.chat-head-text { flex: 1; min-width: 0; display: grid; }
.chat-head-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head-text small { color: var(--ink-3); font-size: .8125rem; }
.chat-body { flex: 1; overflow-y: auto; padding: 14px 14px 4px; display: flex; flex-direction: column; gap: 2px; }
.chat-load-older { display: flex; justify-content: center; padding: 4px 0 12px; }
.day-sep { align-self: center; margin: 14px 0 10px; padding: 4px 12px; border-radius: 99px; background: var(--sunken); color: var(--ink-3); font-size: .75rem; font-weight: 600; }
.bubble-row { display: flex; margin-top: 2px; }
.bubble-row.mine { justify-content: flex-end; }
.bubble { max-width: 78%; padding: 8px 12px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); position: relative; }
.bubble-row.mine .bubble { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.bubble-row.grouped .bubble { margin-top: 2px; }
.bubble-row:not(.grouped) { margin-top: 10px; }
.bubble-row.mine .bubble { border-bottom-right-radius: 5px; }
.bubble-row:not(.mine) .bubble { border-bottom-left-radius: 5px; }
.bubble p { font-size: .9375rem; line-height: 1.4; white-space: pre-wrap; word-break: break-word; }
.bubble.is-deleted p { color: var(--ink-3); font-style: italic; }
.bubble-row.mine .bubble.is-deleted p { color: rgba(255,255,255,.75); }
.bubble-meta { display: flex; align-items: center; gap: 4px; margin-top: 3px; font-size: .6875rem; color: var(--ink-3); }
.bubble-row.mine .bubble-meta { color: rgba(255,255,255,.7); justify-content: flex-end; }
.bubble-reply { display: block; margin-bottom: 5px; padding: 5px 9px; border-left: 3px solid var(--primary); border-radius: 6px; background: rgba(0,0,0,.04); font-size: .8125rem; }
.bubble-row.mine .bubble-reply { border-left-color: rgba(255,255,255,.7); background: rgba(255,255,255,.14); }
.bubble-reply strong { display: block; font-size: .75rem; }
.bubble-reactions { display: flex; gap: 3px; margin-top: 4px; flex-wrap: wrap; }
.reaction-chip { display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px; border-radius: 99px; background: var(--sunken); border: 1px solid var(--line); font-size: .75rem; }
.bubble-row.mine .reaction-chip { background: rgba(255,255,255,.18); border-color: transparent; color: #fff; }
.bubble-actions { position: absolute; top: -14px; right: 6px; display: none; gap: 2px; padding: 2px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-pop); }
.bubble-row.mine .bubble-actions { right: auto; left: 6px; }
.bubble-row:hover .bubble-actions { display: flex; }
.bubble-actions button { width: 26px; height: 26px; border: 0; border-radius: 7px; background: none; color: var(--ink-2); cursor: pointer; font-size: .875rem; display: grid; place-items: center; }
.bubble-actions button:hover { background: var(--sunken); }
.typing-row { padding: 4px 0 8px; }
.typing-dots { display: inline-flex; gap: 4px; padding: 9px 13px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); }
.typing-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); animation: bounce 1s infinite; }
.typing-dots i:nth-child(2) { animation-delay: .15s; } .typing-dots i:nth-child(3) { animation-delay: .3s; }

.chat-composer { border-top: 1px solid var(--line); background: var(--surface); padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
.reply-preview { display: flex; align-items: center; gap: 8px; padding: 6px 10px; margin-bottom: 6px; border-radius: 10px; background: var(--sunken); }
.reply-preview-text { flex: 1; min-width: 0; font-size: .8125rem; }
.reply-preview-text strong { display: block; color: var(--primary); }
.reply-preview-text span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.composer-row { display: flex; align-items: flex-end; gap: 8px; }
.composer-input { flex: 1; max-height: 140px; padding: 11px 14px; border: 1px solid var(--line-strong); border-radius: 20px; background: var(--bg); font: inherit; font-size: .9375rem; resize: none; line-height: 1.4; }
.composer-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.composer-send { flex: none; width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; cursor: pointer; }
.composer-send:disabled { opacity: .5; cursor: not-allowed; }

.chat-row-link { text-decoration: none; color: inherit; }
.chat-row-time { color: var(--ink-3); font-size: .75rem; flex: none; align-self: flex-start; margin-top: 2px; }
.chat-row-unread { flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--primary); color: #fff; font-size: .6875rem; font-weight: 700; display: grid; place-items: center; }