:root {
  --bg: #000;
  --surface: #262626;
  --surface-2: #1a1a1a;
  --line: #363636;
  --ink: #f5f5f5;
  --muted: #a8a8a8;
  --blue: #0095f6;
  --green: #1fbf5f;
  --paper: #f6f3ec;
  --paper-ink: #1b1b1b;
  --ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: "Instrument Serif", "Times New Roman", serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; background: #000; color: var(--ink); font-family: var(--ui); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
#app { position: relative; height: 100dvh; max-width: 480px; margin: 0 auto; overflow: hidden; background: var(--bg); }
@media (min-width: 560px) {
  body { display: grid; place-items: center; background: #0b0b0b; }
  #app { height: min(900px, 100dvh - 40px); width: 420px; border-radius: 44px; border: 1px solid #222; box-shadow: 0 30px 80px rgba(0,0,0,.6); }
}

/* ---------- DM thread ---------- */
.thread { display: flex; flex-direction: column; height: 100%; }
.dm-head { display: flex; align-items: center; gap: 12px; padding: calc(var(--safe-top) + 14px) 16px 10px; border-bottom: .5px solid #1f1f1f; }
.dm-head .back { width: 24px; height: 24px; opacity: .95; }
.dm-head .who { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.dm-head .name { font-weight: 600; font-size: 16px; letter-spacing: -.01em; }
.dm-head .sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.dm-head .icons { display: flex; gap: 18px; }
.dm-head .icons svg { width: 24px; height: 24px; }

.avatar { width: 32px; height: 32px; border-radius: 50%; flex: none; overflow: hidden; background: #111; display: grid; place-items: center; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mark { background: var(--paper); color: var(--paper-ink); font-family: var(--serif); font-style: italic; font-size: 20px; line-height: 1; }
.mark span { transform: translateY(1px); }

.scroll { flex: 1; overflow-y: auto; padding: 18px 12px 10px; display: flex; flex-direction: column; gap: 2px; scroll-behavior: smooth; }
.scroll::-webkit-scrollbar { display: none; }
.intro-card { text-align: center; padding: 18px 0 26px; }
.intro-card .avatar { width: 88px; height: 88px; margin: 0 auto 12px; }
.intro-card .avatar.mark { font-size: 52px; }
.intro-card h1 { font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.intro-card p { font-size: 13px; color: var(--muted); margin-top: 3px; }
.stamp { text-align: center; font-size: 12px; color: var(--muted); margin: 14px 0 10px; font-weight: 500; }

.row { display: flex; align-items: flex-end; gap: 8px; }
.row.me { justify-content: flex-end; }
.row .avatar { width: 28px; height: 28px; visibility: hidden; }
.row.last .avatar { visibility: visible; }
.row.last .avatar.mark { font-size: 17px; }
.bubble { max-width: 74%; padding: 9px 14px; border-radius: 22px; font-size: 15px; line-height: 1.32; letter-spacing: -.005em; word-wrap: break-word; animation: pop .28s cubic-bezier(.2,.9,.3,1.2) both; }
.them .bubble { background: var(--surface); }
.them:not(.last) .bubble { border-bottom-left-radius: 6px; }
.them + .them .bubble { border-top-left-radius: 6px; }
.me .bubble { background: linear-gradient(180deg, #7b4dff 0%, #3c7cf4 100%); background-attachment: fixed; color: #fff; }
.me + .me .bubble { border-top-right-radius: 6px; }
.me:not(.last) .bubble { border-bottom-right-radius: 6px; }
.gap { height: 10px; }
.emoji-big { font-size: 44px; line-height: 1.05; background: none !important; padding: 2px 0; }
.typing { display: inline-flex; gap: 4px; padding: 13px 14px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: #8e8e8e; animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
.seen { align-self: flex-end; font-size: 11px; color: var(--muted); margin: 3px 6px 0; }

/* shared-profile card (Instagram-style profile share) */
.profile-card { width: 238px; background: var(--surface); border-radius: 18px; overflow: hidden; animation: pop .3s cubic-bezier(.2,.9,.3,1.2) both; }
.profile-card .top { display: flex; flex-direction: column; align-items: center; padding: 18px 14px 14px; }
.profile-card .pfp { width: 64px; height: 64px; border-radius: 50%; overflow: hidden; background: #3a3a3a; display: grid; place-items: center; font-size: 26px; font-weight: 600; }
.profile-card .pfp img { width: 100%; height: 100%; object-fit: cover; }
.profile-card .n { font-weight: 600; font-size: 15px; margin-top: 10px; }
.profile-card .h { font-size: 13px; color: var(--muted); margin-top: 1px; }
.profile-card .stats { font-size: 12px; color: var(--muted); margin-top: 8px; }
.profile-card .bio { font-size: 12.5px; color: #dcdcdc; margin-top: 8px; text-align: center; line-height: 1.35; white-space: pre-line; max-height: 3.9em; overflow: hidden; }
.profile-card .act { border-top: .5px solid #3a3a3a; text-align: center; padding: 11px; font-size: 14px; font-weight: 600; }

/* quick replies + composer */
.dock { padding: 8px 12px calc(var(--safe-bottom) + 12px); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; margin-bottom: 10px; }
.chip { padding: 9px 16px; border-radius: 20px; border: 1px solid var(--line); font-size: 14px; font-weight: 600; animation: pop .3s both; }
.chip.primary { background: var(--ink); color: #000; border-color: var(--ink); }
.chip:active { transform: scale(.97); }
.composer { display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: 24px; padding: 6px 6px 6px 6px; min-height: 46px; }
.composer .cam { width: 34px; height: 34px; border-radius: 50%; background: var(--blue); display: grid; place-items: center; flex: none; }
.composer .cam span { font-weight: 700; font-size: 16px; }
.composer input { flex: 1; background: none; border: 0; outline: 0; font-size: 15px; min-width: 0; }
.composer input::placeholder { color: var(--muted); }
.composer .send { color: var(--blue); font-weight: 600; font-size: 15px; padding: 0 10px; opacity: 0; pointer-events: none; transition: opacity .15s; }
.composer.has .send { opacity: 1; pointer-events: auto; }
.fine { text-align: center; font-size: 11px; color: #6e6e6e; margin-top: 10px; line-height: 1.4; }
/* @-mention style suggestion (like Instagram's username autocomplete) */
.suggest { background: var(--surface-2); border: .5px solid #2a2a2a; border-radius: 16px; margin-bottom: 8px; overflow: hidden; animation: pop .22s both; }
.sug-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; text-align: left; }
.sug-row:active { background: #222; }
.sug-row .pfp { width: 44px; height: 44px; border-radius: 50%; overflow: hidden; background: #3a3a3a; display: grid; place-items: center; font-weight: 600; flex: none; }
.sug-row .pfp img { width: 100%; height: 100%; object-fit: cover; }
.sug-row .t { display: flex; flex-direction: column; min-width: 0; }
.sug-row b { font-size: 14px; font-weight: 600; }
.sug-row small { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Story (quiz + result) ---------- */
.story { position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--sbg, #111); transition: background .45s ease; overflow: hidden; }
.story::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .18; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='.55'/></svg>"); }
.bars { display: flex; gap: 4px; padding: calc(var(--safe-top) + 10px) 10px 0; position: relative; z-index: 2; }
.bars div { flex: 1; height: 2.5px; border-radius: 2px; background: rgba(255,255,255,.35); overflow: hidden; }
.bars div.on { background: #fff; }
.bars div.cur i { display: block; height: 100%; width: 60%; background: #fff; }
.story-head { display: flex; align-items: center; gap: 9px; padding: 12px 14px; position: relative; z-index: 2; }
.story-head .avatar { width: 32px; height: 32px; }
.story-head b { font-size: 14px; font-weight: 600; }
.story-head small { font-size: 14px; color: rgba(255,255,255,.7); }
.story-head .x { margin-left: auto; font-size: 26px; line-height: 1; opacity: .9; padding: 0 4px; }
.story-body { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 0 26px 60px; position: relative; z-index: 2; }
.story-text { font-family: var(--serif); font-size: 40px; line-height: 1.02; text-align: center; letter-spacing: -.01em; margin-bottom: 26px; text-wrap: balance; }
.story-text em { font-style: italic; }
.step { position: absolute; bottom: calc(var(--safe-bottom) + 22px); left: 0; right: 0; text-align: center; font-size: 12px; color: rgba(255,255,255,.7); font-weight: 500; z-index: 2; }

/* poll sticker */
.sticker { background: #fff; color: #111; border-radius: 18px; width: 100%; max-width: 300px; box-shadow: 0 8px 30px rgba(0,0,0,.25); animation: drop .45s cubic-bezier(.2,.9,.3,1.25) both; }
.poll .q { font-weight: 700; font-size: 16px; text-align: center; padding: 16px 16px 12px; letter-spacing: -.01em; }
.poll .opts { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid #ececec; }
.poll .opt { padding: 18px 10px; font-weight: 800; font-size: 18px; text-transform: none; position: relative; overflow: hidden; }
.poll .opt + .opt { border-left: 1px solid #ececec; }
.poll .opt span { position: relative; z-index: 1; background: linear-gradient(90deg, #8a3ffc, #e1306c 55%, #fd8d32); -webkit-background-clip: text; background-clip: text; color: transparent; }
.poll .opt.picked { background: #f3f3f3; }
.poll .opt .pct { display: block; font-size: 13px; color: #8e8e8e; -webkit-text-fill-color: #8e8e8e; margin-top: 2px; }

/* quiz sticker */
.quiz .q { background: var(--qc, #8a3ffc); color: #fff; border-radius: 18px 18px 0 0; padding: 16px; font-weight: 700; font-size: 16px; text-align: center; }
.quiz .opts { padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.quiz .opt { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 12px; background: #f2f2f2; font-weight: 600; font-size: 15px; text-align: left; transition: background .2s, color .2s; }
.quiz .opt b { width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid #c7c7c7; display: grid; place-items: center; font-size: 12px; flex: none; color: #8e8e8e; }
.quiz .opt.picked { background: var(--qc, #8a3ffc); color: #fff; }
.quiz .opt.picked b { border-color: #fff; color: #fff; }

/* emoji slider sticker */
.slider { padding: 18px 20px 24px; text-align: center; }
.slider .q { font-weight: 700; font-size: 16px; margin-bottom: 22px; }
.slider .track { position: relative; height: 8px; border-radius: 4px; background: #e6e6e6; }
.slider .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: linear-gradient(90deg, #fd8d32, #e1306c, #8a3ffc); }
.slider input[type=range] { position: absolute; inset: -18px 0; width: 100%; opacity: 0; cursor: pointer; }
.slider .thumb { position: absolute; top: 50%; font-size: 38px; transform: translate(-50%, -54%); pointer-events: none; transition: font-size .1s; filter: drop-shadow(0 3px 4px rgba(0,0,0,.15)); }
.slider .ends { display: flex; justify-content: space-between; font-size: 12px; color: #8e8e8e; margin-top: 14px; font-weight: 600; }
.slider .go { margin-top: 18px; width: 100%; padding: 12px; border-radius: 12px; background: #111; color: #fff; font-weight: 700; }

/* result */
.result .story-body { justify-content: flex-start; padding-top: 1.5vh; padding-bottom: 150px; }
.ring { width: 112px; height: 112px; border-radius: 50%; padding: 4px; background: var(--green); position: relative; animation: drop .5s both; }
.ring .in { width: 100%; height: 100%; border-radius: 50%; border: 4px solid var(--sbg, #111); overflow: hidden; background: #333; display: grid; place-items: center; font-size: 48px; font-weight: 600; }
.ring img { width: 100%; height: 100%; object-fit: cover; }
.ring .star { position: absolute; right: 0; bottom: 2px; width: 30px; height: 30px; border-radius: 50%; background: var(--green); border: 3px solid var(--sbg, #111); display: grid; place-items: center; font-size: 15px; }
.r-handle { margin-top: 10px; font-size: 14px; color: rgba(255,255,255,.75); font-weight: 500; }
.r-kicker { margin-top: 12px; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; font-weight: 700; color: rgba(255,255,255,.7); }
.r-name { font-family: var(--serif); font-style: italic; font-size: 48px; line-height: .98; text-align: center; margin-top: 8px; text-wrap: balance; animation: rise .6s .15s both; }
.r-tag { font-size: 15px; line-height: 1.36; text-align: center; color: rgba(255,255,255,.88); margin-top: 10px; max-width: 320px; animation: rise .6s .25s both; }
.code { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: 100%; max-width: 330px; margin-top: 16px; }
.code div { background: rgba(255,255,255,.1); border-radius: 14px; padding: 10px 4px 9px; text-align: center; animation: rise .5s both; }
.code b { display: block; font-family: var(--serif); font-size: 30px; line-height: 1; }
.code span { display: block; font-size: 11px; font-weight: 600; margin-top: 4px; color: rgba(255,255,255,.8); }
.r-actions { position: absolute; left: 0; right: 0; bottom: calc(var(--safe-bottom) + 18px); padding: 0 16px; display: flex; flex-direction: column; gap: 10px; z-index: 3; }
.btn { width: 100%; padding: 15px; border-radius: 14px; font-weight: 700; font-size: 15.5px; text-align: center; }
.btn.white { background: #fff; color: #000; }
.btn.ghost { background: rgba(255,255,255,.14); color: #fff; }
.r-note { text-align: center; font-size: 12px; color: rgba(255,255,255,.65); }

/* receipt slip (brand signature) */
.slip { position: relative; width: 100%; max-width: 300px; margin-top: 22px; background: var(--paper); color: var(--paper-ink); font-family: var(--mono); font-size: 11.5px; line-height: 1.55; padding: 14px 16px 18px; transform: rotate(-1.2deg); box-shadow: 0 10px 30px rgba(0,0,0,.35); animation: print .7s .45s cubic-bezier(.2,.8,.2,1) both;
  -webkit-mask: linear-gradient(#000 0 0) top / 100% calc(100% - 8px) no-repeat, conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / 12px 8px repeat-x;
          mask: linear-gradient(#000 0 0) top / 100% calc(100% - 8px) no-repeat, conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / 12px 8px repeat-x; }
.slip .hd { text-align: center; font-weight: 600; letter-spacing: .12em; font-size: 11px; }
.slip .sub { text-align: center; font-size: 10px; color: #6b665c; margin-bottom: 8px; }
.slip .ln { display: flex; gap: 6px; }
.slip .ln span:first-child { white-space: nowrap; }
.slip .ln i { flex: 1; border-bottom: 1.5px dotted #b5ae9f; transform: translateY(-4px); }
.slip .ln span:last-child { white-space: nowrap; font-weight: 600; }
.slip hr { border: 0; border-top: 1.5px dashed #b5ae9f; margin: 8px 0; }
.slip .tot { display: flex; justify-content: space-between; font-weight: 600; font-size: 12px; }
@keyframes print { from { opacity: 0; transform: translateY(-18px) rotate(-1.2deg); clip-path: inset(0 0 100% 0); } to { opacity: 1; transform: rotate(-1.2deg); clip-path: inset(0 0 0 0); } }

/* motion */
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes drop { from { opacity: 0; transform: translateY(-14px) scale(.92) rotate(-2deg); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes blink { 0%, 60%, 100% { opacity: .35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-2px); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.still * { animation: none !important; transition: none !important; }
