/* Shared design kit. All screens use these tokens and reusable components. */
:root {
  color-scheme: dark;
  --bg: #0e121d;
  --surface: #191e2c;
  --surface-raised: #222737;
  --glass: rgba(30, 35, 51, .76);
  --text: #f3f2f8;
  --muted: #a2a7ba;
  --subtle: #777f94;
  --line: rgba(202, 206, 243, .1);
  --accent: #a68afa;
  --accent-strong: #8c65e9;
  --accent-soft: rgba(150, 114, 242, .17);
  --success: #64d8a5;
  --danger: #ff8193;
  --shadow: 0 12px 36px rgba(0,0,0,.22);
  --radius: 20px;
  --radius-sm: 14px;
  --gutter: 18px;
  --safe-top: max(env(safe-area-inset-top, 0px), var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f4f9;
  --surface: #fff;
  --surface-raised: #eceef6;
  --glass: rgba(255, 255, 255, .79);
  --text: #202337;
  --muted: #717789;
  --subtle: #8e94a5;
  --line: rgba(53,61,99,.09);
  --accent: #8259da;
  --accent-strong: #8861e2;
  --accent-soft: rgba(137, 96, 227, .11);
  --shadow: 0 12px 36px rgba(34,36,71,.08);
}
* { box-sizing: border-box; }
body { margin: 0; background: #090c13; color: var(--text); font-size: 15px; line-height: 1.45; }
button, input, textarea, select { font: inherit; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
button, a { touch-action: manipulation; }
button { cursor: pointer; color: inherit; border: 0; background: transparent; padding: 0; }
button:disabled { cursor: default; opacity: .5; }
a { color: var(--accent); text-decoration: none; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
img { display: block; width: 100%; object-fit: cover; }
svg.icon { display: block; width: 23px; height: 23px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
h1,h2,h3,p { margin: 0; }
h1 { font-size: 25px; line-height: 1.2; font-weight: 700; letter-spacing: -.65px; }
h2 { font-size: 18px; line-height: 1.3; font-weight: 650; letter-spacing: -.3px; }
h3 { font-size: 16px; font-weight: 600; }
small,.caption { font-size: 13px; line-height: 1.35; }
.muted { color: var(--muted); }
.accent { color: var(--accent); }
.danger { color: var(--danger); }
.text-body { line-height: 1.55; overflow-wrap: anywhere; }
.app-shell { position: relative; width: 100%; max-width: 480px; margin: 0 auto; min-height: 100dvh; background: var(--bg); overflow-x: clip; padding-top: var(--safe-top); }
.page { padding-bottom: calc(114px + var(--safe-bottom)); }
.content { padding: 0 var(--gutter); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-lg { display: flex; flex-direction: column; gap: 22px; }
.row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.row-top { align-items: flex-start; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 20px 0 12px; }
.section-heading:first-child { margin-top: 0; }
.section-heading > button { flex-shrink: 0; }
.card { background: linear-gradient(135deg, color-mix(in srgb, var(--surface-raised) 35%, var(--surface)), var(--surface)); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.card-tight { padding: 5px 16px; }
.card-link { text-align: left; width: 100%; display: flex; align-items: center; gap: 12px; }
.card-link:hover { background: var(--surface-raised); }
.card > .section-heading { margin: 0 0 13px; }
.button { min-height: 44px; border-radius: var(--radius-sm); padding: 10px 15px; background: var(--surface-raised); display: inline-flex; justify-content: center; align-items: center; gap: 8px; font-weight: 500; line-height: 1.25; border: 1px solid var(--line); white-space: nowrap; }
.button .icon { width: 21px; height: 21px; }
.button-primary { color: #fff; border-color: rgba(216,195,255,.22); background: linear-gradient(125deg,#9e7aea,var(--accent-strong)); box-shadow: inset 0 1px rgba(255,255,255,.13),0 3px 14px rgba(129,77,224,.13); }
.button-ghost { background: transparent; border-color: transparent; color: var(--accent); padding: 6px 2px; min-height: 36px; }
.button-block { width: 100%; }
.icon-button { width: 42px; height: 42px; padding: 0; flex: 0 0 42px; background: transparent; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; }
.icon-button:hover { background: var(--accent-soft); }
.glass { background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(26px) saturate(155%); -webkit-backdrop-filter: blur(26px) saturate(155%); box-shadow: inset 0 1px rgba(255,255,255,.06); }
.avatar { width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0; position: relative; }
.avatar img { height: 100%; border-radius: inherit; }
.avatar-sm { width: 34px; height: 34px; }
.avatar-lg { width: 106px; height: 106px; border: 4px solid var(--bg); box-shadow: 0 0 0 1px rgba(208,191,255,.55); }
.avatar-online::after { content: ""; position: absolute; bottom: 3px; right: 3px; width: 12px; height: 12px; background: var(--success); border: 2px solid var(--bg); border-radius: 50%; }
.badge-icon { width: 43px; height: 43px; border-radius: 14px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; background: var(--accent-soft); color: var(--accent); }
.badge-icon.blue { color: #8abdf8; background: rgba(83,147,225,.16); }
.badge-icon.pink { color: #e2a4d9; background: rgba(200,118,180,.15); }
.premium { display: inline-flex; color: var(--accent); vertical-align: middle; margin-left: 4px; }
.premium .icon { width: 19px; height: 19px; fill: color-mix(in srgb,var(--accent) 25%,transparent); }
.appbar { height: 58px; padding: 8px 14px; display: flex; align-items: center; gap: 4px; }
.appbar-title { font-size: 18px; font-weight: 650; flex: 1; text-align: center; }
.appbar .icon-button:last-child { margin-left: auto; }
.page-title { padding: 10px var(--gutter) 20px; }
.profile-cover { height: 194px; background: #232239 url("assets/cover.jpg") 50% 45% / cover no-repeat; position: relative; }
.profile-cover::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg,rgba(8,12,22,.25),rgba(12,15,27,.05) 32%,var(--bg) 100%); }
.profile-cover .appbar { position: relative; z-index: 1; color: #fff; }
.profile-cover .icon-button { background: rgba(20,23,37,.21); backdrop-filter: blur(12px); }
.profile-cover .appbar-title { font-size: 14px; font-weight: 500; opacity: .9; }
.profile-identity { position: relative; margin-top: -80px; display: flex; align-items: flex-end; gap: 16px; padding: 0 var(--gutter); }
.profile-identity h1 { margin-bottom: 5px; font-size: 24px; }
.profile-identity .grow { padding-bottom: 8px; }
.profile-bio { padding: 17px var(--gutter) 0; white-space: pre-line; color: var(--muted); }
.profile-actions { padding: 19px var(--gutter) 0; display: flex; gap: 9px; }
.profile-actions .button:first-child { flex: 1; }
.profile-actions .icon-button { width: 44px; height: 44px; border-radius: var(--radius-sm); }
.profile-meta { display: flex; gap: 12px; padding: 14px var(--gutter) 0; color: var(--muted); font-size: 13px; flex-wrap: wrap; }
.profile-meta .row { gap: 5px; }
.profile-meta .icon { width: 15px; height: 15px; }
.tabs { display: flex; gap: 23px; padding: 0 var(--gutter); overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); }
.tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; background: none; padding: 17px 0 14px; color: var(--muted); flex-shrink: 0; font-size: 14px; white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--text); font-weight: 600; }
.tab[aria-selected="true"]::after { content: ""; position: absolute; bottom: 0; left: 0; right: 0; height: 3px; border-radius: 3px; background: var(--accent); box-shadow: 0 -2px 11px color-mix(in srgb,var(--accent) 45%,transparent); }
.profile-tabs { margin-top: 10px; margin-bottom: 19px; }
.composer { width: 100%; display: flex; align-items: center; gap: 11px; text-align: left; }
.composer > span:not(.avatar) { flex: 1; color: var(--muted); }
.composer > .icon { color: var(--muted); width: 22px; }
.post { padding: 15px; }
.post-text { margin-top: 14px; font-size: 15px; line-height: 1.55; white-space: pre-line; overflow-wrap: anywhere; }
.post-media { display: grid; gap: 5px; margin-top: 13px; border-radius: 14px; overflow: hidden; }
.post-media button { background: var(--surface-raised); padding: 0; overflow: hidden; }
.post-media img { height: 215px; }
.post-media.multiple { grid-template-columns: repeat(3,minmax(0,1fr)); }
.post-media.multiple img { height: 145px; }
.post-footer { display: flex; align-items: center; gap: 8px; margin-top: 13px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 7px 10px; min-height: 36px; border-radius: 20px; background: var(--surface-raised); border: 1px solid transparent; font-size: 13px; }
.pill .icon { width: 18px; height: 18px; }
.pill[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); border-color: color-mix(in srgb,var(--accent) 25%,transparent); }
.post-views { margin-left: auto; color: var(--subtle); display: flex; align-items: center; gap: 5px; font-size: 12px; }
.post-views .icon { width: 16px; height: 16px; }
.collection-strip { display: flex; gap: 9px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.collection { position: relative; width: 95px; height: 105px; border-radius: 16px; overflow: hidden; flex-shrink: 0; padding: 0; background: var(--surface); }
.collection img { height: 100%; }
.collection::after { content:""; position: absolute; inset: 0; background: linear-gradient(transparent 20%,rgba(7,9,16,.8)); }
.collection span { position: absolute; z-index: 1; bottom: 10px; left: 10px; right: 7px; color: #fff; font-size: 12px; text-align: left; }
.collection-add { border: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; align-items: center; justify-content: center; color: var(--muted); }
.collection-add::after { display: none; }
.collection-add span { position: static; color: var(--muted); text-align: center; }
.list-row { width: 100%; display: flex; align-items: center; gap: 12px; min-height: 61px; text-align: left; padding: 11px 0; background: transparent; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-row > .icon { color: var(--muted); flex-shrink: 0; }
.list-row .chevron { width: 17px; height: 17px; margin-left: auto; }
.list-row .grow > .muted { margin-top: 3px; font-size: 13px; }
.list-row .row h3 { flex: 1; }
.info-row { display: grid; grid-template-columns: 25px 100px minmax(0,1fr); align-items: start; gap: 9px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.info-row:last-child { border: 0; }
.info-row .icon { width: 21px; height: 21px; color: var(--muted); }
.info-row span:last-child { overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip { background: var(--surface-raised); padding: 5px 10px; border-radius: 18px; font-size: 12px; color: var(--muted); }
.chip:first-child { color: var(--accent); background: var(--accent-soft); }
.timeline { padding-left: 22px; position: relative; display: flex; flex-direction: column; gap: 20px; }
.timeline::before { content:""; position: absolute; top: 9px; bottom: 20px; width: 1px; left: 4px; background: var(--line); }
.timeline-item { position: relative; }
.timeline-item::before { content:""; position: absolute; top: 7px; left: -21px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.timeline-item p { font-size: 13px; color: var(--muted); margin-top: 3px; }
.project-tile { position: relative; padding: 0; height: 139px; border-radius: 14px; overflow: hidden; background: var(--surface-raised); text-align: left; }
.project-tile img { height: 100%; }
.project-tile::after { content:""; position: absolute; inset: 0; background: linear-gradient(transparent,rgba(10,12,22,.9)); }
.project-tile > span { position: absolute; z-index: 1; left: 12px; bottom: 11px; right: 10px; color: #fff; font-size: 13px; font-weight: 500; }
.project-tile small { display:block; opacity:.7; font-size:11px; margin-top:3px; }
.toggle { position: relative; width: 46px; height: 28px; flex-shrink: 0; border-radius: 18px; background: var(--surface-raised); border: 1px solid var(--line); padding: 3px; }
.toggle::after { content:""; display: block; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.18); transition: transform .2s; }
.toggle[aria-checked="true"] { background: var(--accent-strong); }
.toggle[aria-checked="true"]::after { transform: translateX(17px); }
.bottom-nav { position: fixed; z-index: 20; bottom: calc(15px + var(--safe-bottom)); left: 50%; transform: translateX(-50%); width: calc(min(100%,480px) - 32px); display: flex; padding: 7px; border-radius: 29px; box-shadow: var(--shadow), inset 0 1px rgba(255,255,255,.1); }
.nav-item { flex: 1; min-width: 0; min-height: 55px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border-radius: 22px; background: none; color: var(--muted); font-size: 11px; }
.nav-item .icon { width: 24px; height: 24px; }
.nav-item[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.nav-item[aria-current="page"] .icon { filter: drop-shadow(0 0 7px rgba(168,131,251,.3)); }
.search-field { position: relative; display: flex; align-items: center; gap: 9px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 0 12px; }
.search-field > .icon { width: 20px; color: var(--subtle); }
.search-field input { min-width:0; flex: 1; border: 0; background: transparent; color: var(--text); padding: 12px 0; outline: none; }
.field { display: flex; flex-direction: column; gap: 7px; font-size: 13px; color: var(--muted); }
.input { width: 100%; border-radius: 13px; background: var(--surface-raised); color: var(--text); border: 1px solid var(--line); padding: 12px; font-size: 16px; outline: none; }
textarea.input { resize: vertical; min-height: 110px; line-height: 1.5; }
.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--subtle); }
.unread { width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; background: var(--accent-strong); color: #fff; }
.status-dot { display:inline-block; width:7px; height:7px; border-radius:50%; background:var(--success); margin-right:5px; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty > .icon { width: 35px; height: 35px; margin: 0 auto 12px; color: var(--accent); }
.empty h3 { color: var(--text); margin-bottom: 6px; }
.overlay { position: fixed; z-index: 50; inset: 0; background: rgba(3,6,15,.65); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); display: flex; align-items: flex-end; justify-content: center; padding-top: 50px; animation: fade-in .16s ease-out; }
.sheet { width: 100%; max-width: 480px; max-height: calc(100dvh - 50px); overflow-y: auto; background: var(--bg); border: 1px solid var(--line); border-bottom: 0; border-radius: 28px 28px 0 0; padding: 10px var(--gutter) calc(24px + var(--safe-bottom)); box-shadow: 0 -10px 60px rgba(0,0,0,.23); animation: slide-in .2s ease-out; }
.sheet-handle { width: 34px; height: 4px; border-radius: 4px; background: var(--subtle); opacity:.4; margin: 0 auto 12px; }
.sheet-header { display:flex; justify-content:space-between; align-items:center; gap:12px; margin-bottom: 18px; }
.sheet-header .icon-button { width: 34px; height: 34px; flex-basis: 34px; background: var(--surface); }
.sheet-header h2 { font-size:20px; }
.sheet .stack { gap: 16px; }
.form-actions { display: flex; gap: 10px; padding-top: 6px; }
.form-actions .button { flex: 1; }
.toast { position:fixed; z-index:80; bottom:calc(105px + var(--safe-bottom)); left:50%; transform:translate(-50%,12px); padding:12px 18px; max-width:calc(100vw - 36px); color:var(--text); background:var(--surface-raised); border:1px solid var(--line); border-radius:16px; box-shadow:var(--shadow); opacity:0; pointer-events:none; transition:opacity .15s,transform .15s; white-space:normal; text-align:center; font-size:14px; }
.toast.visible { opacity:1; transform:translate(-50%,0); }
.media-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 5px; border-radius: 17px; overflow: hidden; }
.media-grid button { padding:0; background:var(--surface); }
.media-grid img { aspect-ratio:1; }
.lightbox { position:fixed; z-index:60; inset:0; background:rgba(4,7,13,.98); display:flex; align-items:center; justify-content:center; }
.lightbox img { width:100%; height:80dvh; max-width:800px; object-fit:contain; }
.lightbox .icon-button { position:absolute; top:calc(18px + var(--safe-top)); right:18px; color:#fff; background:rgba(255,255,255,.1); }
.note-preview { white-space: pre-line; font-size:14px; color:var(--muted); margin-top:7px; display:-webkit-box; -webkit-line-clamp:3; -webkit-box-orient:vertical; overflow:hidden; }
.space-header { padding: 26px var(--gutter) 24px; background: radial-gradient(ellipse at 80% 0%,rgba(132,104,214,.22),transparent 75%); }
.space-header .badge-icon { width:60px; height:60px; border-radius:20px; }
.space-header h1 { font-size:24px; margin:16px 0 7px; }
.chat-screen { min-height:100dvh; padding-bottom:180px; background:radial-gradient(ellipse at 90% 35%,rgba(117,97,177,.06),transparent 75%),var(--bg); }
.chat-screen .appbar { position:sticky; top:var(--safe-top); background:var(--glass); backdrop-filter:blur(20px); z-index:10; height:68px; border-bottom:1px solid var(--line); }
.chat-screen .appbar-title { text-align:left; font-size:16px; }
.chat-screen .appbar-title small { display:block; font-size:12px; color:var(--muted); font-weight:400; margin-top:2px; }
.chat-messages { padding:24px var(--gutter); display:flex; flex-direction:column; gap:12px; }
.chat-date { align-self:center; color:var(--muted); font-size:12px; margin:0 0 9px; padding:5px 12px; background:var(--surface); border-radius:20px; }
.bubble { max-width:87%; align-self:flex-start; background:var(--surface); border-radius:18px 18px 18px 5px; padding:11px 13px 8px; overflow-wrap:anywhere; white-space:pre-line; }
.bubble.own { align-self:flex-end; background:color-mix(in srgb,var(--accent-strong) 37%,var(--surface)); border-radius:18px 18px 5px 18px; }
.bubble small { display:flex; justify-content:flex-end; align-items:center; gap:3px; margin-top:4px; color:var(--muted); font-size:10px; }
.bubble small .icon { width:14px; height:14px; }
.message-input { position:fixed; z-index:15; bottom:calc(99px + var(--safe-bottom)); width:calc(min(100%,480px) - 32px); left:50%; transform:translateX(-50%); border-radius:26px; display:flex; gap:8px; padding:6px 7px 6px 16px; }
.message-input input { border:0; min-width:0; flex:1; color:var(--text); background:transparent; outline:none; }
.message-input .icon-button { background:var(--accent-strong); color:#fff; width:36px; height:36px; flex-basis:36px; }
.loading-screen { min-height:100dvh; display:flex; align-items:center; justify-content:center; gap:14px; color:var(--muted); }
.loading-orbit { width:24px; height:24px; border:2px solid var(--line); border-top-color:var(--accent); border-radius:50%; animation:orbit .8s linear infinite; }
.error-screen { padding:30dvh 24px 0; text-align:center; }
.error-screen .button { margin-top:20px; }
.avatar-pile { display:flex; padding-left:8px; }
.avatar-pile .avatar { border:2px solid var(--surface); margin-left:-8px; }
.form-error { color:var(--danger); font-size:13px; min-height:18px; }
.upload-preview { display:flex; gap:8px; overflow-x:auto; }
.upload-preview img { width:82px; height:82px; border-radius:12px; }
.link-copy { display:flex; gap:8px; align-items:center; }
.link-copy input { font-size:13px; }
.call-screen { text-align:center; padding:15px 0 25px; }
.call-screen .avatar { width:100px; height:100px; margin:0 auto 18px; }
.call-screen h2 { margin-bottom:8px; }
.call-screen .button { margin-top:28px; background:#cc536a; color:#fff; }
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
@keyframes orbit { to { transform:rotate(360deg); } }
@keyframes fade-in { from { opacity:0; } }
@keyframes slide-in { from { transform:translateY(30px); opacity:0; } }
@media(min-width:600px) { .app-shell { box-shadow:0 0 100px rgba(0,0,0,.35); border-left:1px solid var(--line); border-right:1px solid var(--line); } }
@media(max-width:359px) { :root { --gutter:14px; } .profile-identity { gap:12px; } .profile-identity h1 { font-size:21px; } .avatar-lg { width:92px; height:92px; } .tabs { gap:19px; } .profile-actions .button { padding:10px 11px; font-size:13px; } .info-row { grid-template-columns:22px 85px minmax(0,1fr); gap:7px; } }
@media(prefers-reduced-motion:reduce) { *,*::before,*::after { animation-duration:.01ms!important; transition-duration:.01ms!important; scroll-behavior:auto!important; } }

/* Shared spacing and content utilities. */
.mt-xs { margin-top:4px; }
.mt-sm { margin-top:8px; }
.mt { margin-top:12px; }
.mt-lg { margin-top:16px; }
.card-button { text-align:left; width:100%; }
.text-button { background:none; }
.image-preview { border-radius:16px; max-height:220px; }
