:root {
  --bg: #0E0A14; --surface: #1B1424; --raised: #261C33; --coral: #FF3D7F; --orange: #FF8A4C;
  --muted: rgba(255,255,255,.62); --danger: #FF5A5A; --ok: #30D158;
  --grad: linear-gradient(35deg, #FF8A4C, #FF3D7F);
  --radius: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: #fff; font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--coral); }
h1 { font-size: 2rem; margin: 0 0 .5rem; } h2 { font-size: 1.4rem; margin: 0 0 .5rem; } h3 { font-size: 1.05rem; margin: 0 0 .4rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
.danger { color: var(--danger); } .ok { color: var(--ok); }
.boot { display: grid; place-items: center; min-height: 100vh; }
.boot-logo { width: 96px; height: 96px; border-radius: 22px; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.06); opacity: .8; } }

/* layout */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 20px; background: rgba(14,10,20,.92); backdrop-filter: blur(12px); border-bottom: 1px solid rgba(255,255,255,.08); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: 2px; text-decoration: none; color: #fff; }
.brand img { width: 34px; height: 34px; border-radius: 8px; }
.tabs { display: flex; gap: 4px; margin-left: 16px; }
.tab { background: none; border: 0; padding: 8px 14px; border-radius: 999px; cursor: pointer; color: var(--muted); font-weight: 600; text-decoration: none; }
.tab:hover { color: #fff; } .tab.active { color: #fff; background: var(--raised); }
.spacer { flex: 1; }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 6px; border-radius: 999px; background: var(--grad); font-size: .72rem; text-align: center; }
.page { max-width: 1100px; margin: 0 auto; padding: 20px; }
.narrow { max-width: 460px; margin: 0 auto; padding: 32px 20px; }
.card { background: var(--surface); border-radius: var(--radius); padding: 20px; }
.stack > * + * { margin-top: 14px; } .row { display: flex; gap: 10px; align-items: center; } .wrap { flex-wrap: wrap; }
.grow { flex: 1; }

/* form */
label.field { display: block; } label.field > span { display: block; margin: 0 0 6px; color: var(--muted); font-size: .9rem; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=search], select, textarea {
  width: 100%; padding: 13px 14px; background: var(--surface); border: 1px solid transparent; border-radius: 14px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--coral); }
textarea { resize: vertical; min-height: 84px; }
select option { background: #1B1424; }
.code { text-align: center; font: 700 2rem ui-monospace, Menlo, monospace; letter-spacing: .3em; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; } .check input { margin-top: 5px; accent-color: var(--coral); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 13px 22px; border-radius: 999px; border: 1px solid rgba(255,255,255,.25); background: none; cursor: pointer; font-weight: 700; text-decoration: none; color: #fff; }
.btn.primary { background: var(--grad); border-color: transparent; } .btn.block { display: flex; width: 100%; }
.btn.small { padding: 7px 14px; font-size: .88rem; } .btn.danger { color: var(--danger); border-color: var(--danger); }
.btn:disabled { opacity: .4; cursor: not-allowed; } .btn:hover:not(:disabled) { filter: brightness(1.1); }
.linkbtn { background: none; border: 0; color: var(--coral); cursor: pointer; padding: 0; }
.progress { height: 4px; background: var(--raised); border-radius: 4px; overflow: hidden; } .progress > i { display: block; height: 100%; background: var(--grad); }
.option { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; padding: 14px 16px; border-radius: 14px; background: var(--surface); border: 2px solid transparent; cursor: pointer; }
.option.sel { border-color: var(--coral); }
.seg { display: inline-flex; background: var(--surface); border-radius: 999px; padding: 4px; gap: 2px; flex-wrap: wrap; }
.seg button { padding: 8px 16px; border: 0; border-radius: 999px; background: none; cursor: pointer; color: var(--muted); font-weight: 600; }
.seg button.active { background: var(--raised); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; } .chip { padding: 3px 10px; border-radius: 999px; background: rgba(255,255,255,.14); font-size: .78rem; font-weight: 600; }
.chip.cat { cursor: pointer; border: 0; color: #fff; padding: 7px 13px; background: var(--raised); } .chip.cat.active { background: var(--grad); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }

/* grid + cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.pcard { position: relative; aspect-ratio: 3 / 4; border-radius: 20px; overflow: hidden; background: var(--raised); cursor: pointer; }
.pcard img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pcard .shade { position: absolute; inset: 0; background: linear-gradient(transparent 45%, rgba(0,0,0,.78)); }
.pcard .info { position: absolute; left: 0; right: 0; bottom: 0; padding: 12px; }
.pcard .name { font-weight: 700; } .pcard .story { position: absolute; top: 8px; right: 8px; width: 34px; height: 34px; border-radius: 50%; border: 0; cursor: pointer; background: var(--grad); color: #fff; }
.pcard .story.seen { background: rgba(120,120,120,.85); }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); } .empty h3 { color: #fff; }
.list > * { padding: 14px 0; border-bottom: 1px solid rgba(255,255,255,.08); }
.person { display: flex; gap: 12px; align-items: center; } .person img, .ava { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: var(--raised); flex: none; }
.storybar { display: flex; gap: 14px; overflow-x: auto; padding: 4px 2px 14px; }
.bubble { flex: none; width: 76px; text-align: center; background: none; border: 0; cursor: pointer; color: #fff; font-size: .75rem; }
.bubble .ring { width: 68px; height: 68px; margin: 0 auto 4px; border-radius: 50%; padding: 3px; background: var(--grad); display: grid; place-items: center; }
.bubble .ring.seen { background: rgba(255,255,255,.35); } .bubble .ring.none { background: var(--raised); font-size: 1.6rem; }
.bubble .ring img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 2px solid var(--bg); }

/* modal + toast */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.65); display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.modal { width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; background: var(--bg); border: 1px solid rgba(255,255,255,.1); border-radius: 22px; padding: 22px; } .modal.wide { max-width: 760px; }
.modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; } .modal-head h2 { margin: 0; flex: 1; }
.iconbtn { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--raised); cursor: pointer; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 80; background: var(--raised); padding: 12px 20px; border-radius: 999px; box-shadow: 0 8px 30px rgba(0,0,0,.5); max-width: 90vw; }
.toast.error { background: #5b1f2b; }

/* profile detail */
.hero { position: relative; aspect-ratio: 4 / 5; max-height: 460px; width: 100%; border-radius: 18px; overflow: hidden; background: var(--raised); }
.hero img { width: 100%; height: 100%; object-fit: cover; } .hero .nav { position: absolute; top: 50%; transform: translateY(-50%); width: 38px; height: 38px; border-radius: 50%; border: 0; background: rgba(0,0,0,.5); color: #fff; cursor: pointer; }
.hero .prev { left: 8px; } .hero .next { right: 8px; }
.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; } .pill { padding: 12px 6px; border-radius: 16px; border: 0; background: var(--surface); cursor: pointer; font-size: .85rem; } .pill.on { color: var(--coral); } .pill:disabled { opacity: .4; }
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; } .photos .ph { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--raised); }
.photos .ph img { width: 100%; height: 100%; object-fit: cover; } .photos .ph .tools { position: absolute; left: 4px; right: 4px; bottom: 4px; display: flex; gap: 4px; justify-content: space-between; }
.photos .ph .tools button { border: 0; border-radius: 8px; padding: 3px 8px; background: rgba(0,0,0,.65); color: #fff; cursor: pointer; font-size: .75rem; } .photos .add { display: grid; place-items: center; border: 2px dashed rgba(255,255,255,.25); border-radius: 12px; aspect-ratio: 1; cursor: pointer; font-size: 1.8rem; color: var(--muted); }
.rules h3 { color: var(--coral); margin-top: 14px; } .rules li { margin: 6px 0; }
.warnbox { background: var(--raised); border-radius: 14px; padding: 14px; font-weight: 600; }
.post { padding: 12px 0; border-bottom: 1px solid rgba(255,255,255,.08); } .post .who { font-size: .8rem; font-weight: 700; color: var(--coral); }

/* stories */
.story-overlay { position: fixed; inset: 0; z-index: 70; background: #000; display: grid; place-items: center; }
.story-frame { position: relative; height: min(100vh, calc(100vw * 16 / 9)); aspect-ratio: 9 / 16; background: var(--surface); overflow: hidden; border-radius: 14px; user-select: none; }
.story-frame > img, .story-frame > video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.story-frame svg, .story-frame canvas.draw { position: absolute; inset: 0; width: 100%; height: 100%; }
.story-text { position: absolute; transform: translate(-50%, -50%); font-weight: 800; text-align: center; max-width: 90%; text-shadow: 0 1px 6px rgba(0,0,0,.6); white-space: pre-wrap; }
.story-text.bg { text-shadow: none; padding: 6px 10px; border-radius: 8px; color: #000; }
.story-top, .story-bottom { position: absolute; left: 0; right: 0; z-index: 3; padding: 12px; }
.story-top { top: 0; background: linear-gradient(rgba(0,0,0,.6), transparent); } .story-bottom { bottom: 0; background: linear-gradient(transparent, rgba(0,0,0,.65)); }
.bars { display: flex; gap: 4px; margin-bottom: 10px; } .bars i { flex: 1; height: 3px; border-radius: 3px; background: rgba(255,255,255,.3); overflow: hidden; } .bars i b { display: block; height: 100%; background: #fff; width: 0; }
.story-zones { position: absolute; inset: 70px 0 120px; z-index: 2; display: flex; } .story-zones > div { flex: 1; cursor: pointer; }
.story-watermark { position: absolute; inset: 0; z-index: 1; display: grid; place-items: center; pointer-events: none; font-weight: 700; font-size: 1.1rem; color: rgba(255,255,255,.16); transform: rotate(-25deg); }
.reacts { display: flex; gap: 6px; margin-bottom: 8px; } .reacts button { border: 0; background: none; font-size: 1.4rem; padding: 4px 6px; border-radius: 50%; cursor: pointer; } .reacts button.on { background: rgba(255,255,255,.3); }
.creator-stage { position: relative; width: min(100%, 300px); aspect-ratio: 9 / 16; margin: 0 auto; background: #000; border-radius: 14px; overflow: hidden; touch-action: none; }
.creator-stage > img, .creator-stage > video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.creator-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; } .creator-stage .story-text { cursor: grab; touch-action: none; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; padding: 0; } .swatch.on { border-color: #fff; }

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; padding: 8px 12px; } .tabs { order: 3; width: 100%; margin: 0; overflow-x: auto; } .page { padding: 14px; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}
