@font-face { font-family: Vazirmatn; src: url(Vazirmatn-Regular.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url(Vazirmatn-Bold.woff2) format('woff2'); font-weight: 700; font-display: swap; }

/* ---------- tokens ---------- */
/* Warm base; --accent / --accent2 / --on-accent are set from the user's colour choice. */
:root {
  --mist: #FBF2EE; --paper: #FFFFFF; --ink: #2B1E2B; --hush: #8E7A89; --line: #EEDDDD;
  --accent: #FF6B5B; --accent2: #FF9F5A; --on-accent: #FFFFFF;
  --indigo: var(--accent);
  --mood: #B8A9B3; --danger: #E0475B;
  --shadow: 0 1px 1px rgba(60, 25, 40, .05), 0 3px 12px rgba(60, 25, 40, .06);
  --fs: 16px;
  color-scheme: light;
}
:root[data-theme=dark] {
  --mist: #1A1319; --paper: #2A2028; --ink: #F7ECEF; --hush: #AE9AA6; --line: #3B2D38;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35); color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    --mist: #1A1319; --paper: #2A2028; --ink: #F7ECEF; --hush: #AE9AA6; --line: #3B2D38;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35); color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--mist); color: var(--ink);
  font: 400 var(--fs)/1.6 Vazirmatn, Tahoma, sans-serif; overflow: hidden; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }
input, textarea { font: inherit; color: var(--ink); }
svg { width: 24px; height: 24px; display: block; }
.hidden { display: none !important; }
.screen { position: relative; height: 100%; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- buttons ---------- */
.btn-primary { width: 100%; padding: 14px; border-radius: 16px; background: linear-gradient(135deg, var(--accent), var(--accent2)); color: var(--on-accent); font-weight: 700; font-size: 16px; }
.btn-primary:disabled { opacity: .55; }
.btn-soft { width: 100%; padding: 13px; border-radius: 14px; background: var(--mist); }
.btn-danger { width: 100%; padding: 13px; border-radius: 14px; color: var(--danger); background: color-mix(in srgb, var(--danger) 9%, transparent); }
.ic { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: var(--hush); flex-shrink: 0; }
.ic:active { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.ic.sm { width: 32px; height: 32px; } .ic.sm svg { width: 18px; height: 18px; }
.hint { font-size: 13px; color: var(--hush); margin: 0; }
.err { color: var(--danger); font-size: 14px; min-height: 1.4em; margin: 0; }

/* ---------- setup ---------- */
#setup { overflow-y: auto; display: flex; padding: 28px 22px; }
.setup-card { margin: auto; width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 14px; }
.setup-mark { width: 64px; height: 64px; border-radius: 22px; background: linear-gradient(135deg, var(--accent), var(--accent2)); display: grid; place-items: center;
  box-shadow: 0 10px 30px color-mix(in srgb, var(--indigo) 35%, transparent); }
.setup-mark span { color: #fff; font-size: 34px; font-weight: 700; line-height: 1; }
.setup-card h1 { margin: 6px 0 0; font-size: 32px; font-weight: 700; letter-spacing: -.5px; }
.lead { margin: 0 0 6px; color: var(--hush); }
.field { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.field label { font-size: 13px; color: var(--hush); }
.field input, .code-input, #mood-note { width: 100%; padding: 13px 14px; border-radius: 14px; border: 1.5px solid var(--line);
  background: var(--paper); outline: none; transition: border-color .15s; }
.field input:focus, .code-input:focus, #mood-note:focus { border-color: var(--indigo); }
.field-row { display: flex; gap: 10px; }
.seg { display: flex; background: color-mix(in srgb, var(--ink) 6%, transparent); border-radius: 14px; padding: 4px; margin-top: 4px; }
.seg button { flex: 1; padding: 10px; border-radius: 11px; color: var(--hush); font-size: 15px; }
.seg button.on { background: var(--paper); color: var(--ink); font-weight: 700; box-shadow: var(--shadow); }
.pane { display: flex; flex-direction: column; gap: 10px; }
.code { font: 700 clamp(15px, 4.6vw, 20px)/1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .5px; white-space: nowrap; text-align: center; padding: 20px 10px;
  border-radius: 16px; background: var(--paper); border: 1.5px dashed color-mix(in srgb, var(--indigo) 45%, transparent); user-select: all; }
.code-input { font-family: ui-monospace, Menlo, monospace; text-align: center; letter-spacing: 1px; text-transform: uppercase; }

/* ---------- chat frame ---------- */
#chat { display: flex; flex-direction: column; }
/* The friend's mood colours the room: a soft light falling from the top of the screen. */
.glow { position: absolute; inset: 0 0 auto 0; height: 60%; pointer-events: none; z-index: 0; mix-blend-mode: normal;
  background: radial-gradient(120% 70% at 50% -10%, color-mix(in srgb, var(--mood) 38%, transparent), transparent 70%);
  transition: background 1.2s ease; }

.top { position: relative; z-index: 2; display: flex; align-items: center; gap: 4px;
  padding: max(10px, env(safe-area-inset-top)) 8px 10px; }
.peer { flex: 1; display: flex; align-items: center; gap: 12px; min-width: 0; padding-inline-start: 4px; }
.orb { position: relative; width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center;
  background: var(--paper); box-shadow: 0 0 0 3px var(--mood), 0 6px 18px color-mix(in srgb, var(--mood) 45%, transparent);
  transition: box-shadow 1.2s ease; }
.orb img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.orb > #h-initial { font-size: 20px; font-weight: 700; color: var(--ink); }
.orb-emoji { position: absolute; bottom: -6px; left: -6px; font-size: 20px; line-height: 1;
  width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: var(--paper); box-shadow: var(--shadow); }
.orb-emoji:empty { display: none; }
.peer-text { min-width: 0; }
.peer-name { font-weight: 700; font-size: 17px; line-height: 1.3; }
.peer-status { font-size: 13px; color: var(--hush); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.peer-status.typing { color: var(--indigo); }
.peer-status.off::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); margin-inline-end: 6px; vertical-align: 1px; }
.mine-mood { width: 42px; height: 42px; border-radius: 50%; background: var(--paper); box-shadow: var(--shadow); font-size: 22px; display: grid; place-items: center; }

/* ---------- messages ---------- */
#msgs { position: relative; z-index: 1; flex: 1; overflow-y: auto; padding: 6px 12px 10px;
  display: flex; flex-direction: column; overscroll-behavior: contain; }
#msgs::before { content: ""; margin-top: auto; } /* keep messages at the bottom when few */
.empty { margin: auto; text-align: center; color: var(--hush); font-size: 14px; max-width: 260px; }
.day { align-self: center; font-size: 12px; color: var(--hush); padding: 3px 12px; margin: 14px 0 8px; border-radius: 20px;
  background: color-mix(in srgb, var(--paper) 70%, transparent); backdrop-filter: blur(8px); }

.b { position: relative; max-width: min(78%, 420px); margin-top: 2px; padding: 7px 13px 6px; border-radius: 22px;
  box-shadow: var(--shadow); word-wrap: break-word; animation: pop .18s ease-out; }
@keyframes pop { from { transform: translateY(6px) scale(.98); opacity: 0; } }
.b.me { align-self: flex-start; background: linear-gradient(140deg, var(--accent), var(--accent2)); color: var(--on-accent); }
.b.them { align-self: flex-end; background: var(--paper); }
.b.first { margin-top: 8px; }
.b.me.last { border-bottom-right-radius: 6px; }
.b.them.last { border-bottom-left-radius: 6px; }
.b.pending { opacity: .7; }
.b.flash { animation: flash 1s ease; }
@keyframes flash { 30% { box-shadow: 0 0 0 3px var(--mood); } }

.txt { white-space: pre-wrap; }
.foot { display: flex; align-items: center; justify-content: flex-end; gap: 3px; font-size: 11px; line-height: 1; margin-top: 3px;
  opacity: .7; direction: ltr; }
.ticks { font-size: 12px; letter-spacing: -4px; padding-right: 4px; }
.ticks.read { opacity: 1; font-weight: 700; }
.b.media { padding: 4px; }
.b.media .foot { position: absolute; bottom: 9px; left: 10px; background: rgba(0, 0, 0, .45); color: #fff; padding: 3px 7px; border-radius: 10px; opacity: 1; }
.photo { display: block; width: 260px; max-width: 100%; border-radius: 16px; background: color-mix(in srgb, var(--ink) 8%, transparent); min-height: 90px; object-fit: cover; }

.quote { display: block; text-align: right; width: 100%; margin: 2px 0 5px; padding: 4px 9px; border-radius: 10px; font-size: 13px; line-height: 1.45;
  border-inline-start: 3px solid currentColor; background: color-mix(in srgb, currentColor 10%, transparent); overflow: hidden; }
.b.them .quote { color: var(--indigo); }
.quote b { display: block; font-size: 12px; }
.quote span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); opacity: .8; }
.b.me .quote span { color: var(--on-accent); }

.filechip { display: flex; align-items: center; gap: 10px; text-align: right; padding: 4px 2px; }
.filechip svg { width: 40px; height: 40px; flex-shrink: 0; }
.filechip b { display: block; font-size: 14px; max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.filechip small { opacity: .75; font-size: 12px; }

.voice { display: flex; align-items: center; gap: 10px; padding: 2px 0; min-width: 210px; direction: ltr; }
.voice .pp { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  background: currentColor; }
.voice .pp svg { color: var(--paper); width: 20px; height: 20px; }
.b.me .voice .pp svg { color: var(--accent); }
.b.them .voice { color: var(--indigo); }
.bars { flex: 1; height: 30px; display: flex; align-items: center; gap: 2px; }
.bars i { flex: 1; border-radius: 2px; background: currentColor; opacity: .35; min-height: 3px; }
.bars i.on { opacity: 1; }
.voice .dur { font-size: 12px; min-width: 32px; color: inherit; opacity: .8; }

/* ---------- dock ---------- */
.dock { position: relative; z-index: 2; padding: 6px 10px max(10px, env(safe-area-inset-bottom)); }
.composer { display: flex; align-items: flex-end; gap: 4px; background: var(--paper); border-radius: 26px; padding: 4px;
  box-shadow: 0 2px 14px rgba(28, 27, 58, .08); }
.composer textarea { flex: 1; resize: none; border: 0; outline: none; background: none; padding: 9px 4px; max-height: 140px; line-height: 1.5; }
.act { width: 42px; height: 42px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent2)); color: var(--on-accent); display: grid; place-items: center; flex-shrink: 0;
  transition: transform .12s; }
.act:active { transform: scale(.92); }
.act svg { width: 22px; height: 22px; }
.reply-bar { display: flex; align-items: center; gap: 8px; background: var(--paper); border-radius: 18px; padding: 6px 12px 6px 6px;
  margin-bottom: 6px; box-shadow: var(--shadow); }
.reply-line { flex: 1; min-width: 0; border-inline-start: 3px solid var(--indigo); padding-inline-start: 9px; font-size: 13px; }
.reply-line b { display: block; color: var(--indigo); font-size: 12px; }
.reply-line span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--hush); }
.rec { align-items: center; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); margin-inline-start: 4px; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .25; } }
.rec-time { font-variant-numeric: tabular-nums; min-width: 42px; font-size: 15px; }
.rec-wave { flex: 1; min-width: 0; height: 32px; color: var(--indigo); }

/* ---------- context menu, sheets, viewer, toast ---------- */
.ctx { position: fixed; z-index: 30; background: var(--paper); border-radius: 14px; padding: 6px; min-width: 150px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .2); animation: pop .12s ease-out; }
.ctx button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border-radius: 10px; font-size: 15px; }
.ctx button:active { background: var(--mist); }
.ctx svg { width: 20px; height: 20px; color: var(--hush); }

.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(15, 14, 35, .45); display: flex; align-items: flex-end; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.sheet-body { width: 100%; background: var(--paper); border-radius: 26px 26px 0 0; padding: 8px 18px max(20px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px; max-height: 92%; overflow-y: auto; animation: rise .22s cubic-bezier(.2, .9, .3, 1.1); }
@keyframes rise { from { transform: translateY(40%); } }
.grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line); align-self: center; margin-bottom: 4px; }
.sheet h2 { margin: 0; font-size: 19px; }
.mood-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.mood-opt { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 2px 9px; border-radius: 18px;
  background: color-mix(in srgb, var(--h) 12%, transparent); border: 2px solid transparent; transition: transform .12s, border-color .12s; }
.mood-opt .e { font-size: 30px; line-height: 1.1; }
.mood-opt .l { font-size: 12px; color: var(--hush); text-align: center; line-height: 1.35; }
.mood-opt.sel { border-color: var(--h); transform: scale(1.04); }
.mood-opt.sel .l { color: var(--ink); font-weight: 700; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch i { width: 46px; height: 28px; border-radius: 14px; background: var(--line); position: relative; flex-shrink: 0; transition: background .15s; }
.switch i::after { content: ""; position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: var(--shadow); transition: transform .15s; }
.switch input:checked + i { background: var(--indigo); }
.switch input:checked + i::after { transform: translateX(-18px); }
.switch input:focus-visible + i { outline: 2px solid var(--indigo); outline-offset: 2px; }

.viewer { position: fixed; inset: 0; z-index: 40; background: #000; display: grid; place-items: center; animation: fade .15s; }
.viewer img { max-width: 100%; max-height: 100%; }
.toast { position: fixed; z-index: 50; bottom: 90px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--mist);
  padding: 9px 16px; border-radius: 20px; font-size: 14px; animation: fade .15s; }

/* ---------- wallpapers ---------- */
.wall { position: absolute; inset: 0; z-index: 0; pointer-events: none; background: var(--mist); background-size: cover; background-position: center; }
.wall.dots { background: radial-gradient(color-mix(in srgb, var(--accent) 22%, transparent) 1.3px, transparent 1.6px) 0 0 / 22px 22px, var(--mist); }
.wall.blobs { background:
  radial-gradient(40% 30% at 85% 75%, color-mix(in srgb, var(--accent2) 22%, transparent), transparent 70%),
  radial-gradient(45% 35% at 10% 40%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%), var(--mist); }
.wall.dusk { background: linear-gradient(175deg, var(--mist) 25%, color-mix(in srgb, var(--accent) 20%, var(--mist)) 100%); }
.wall.photo::after { content: ""; position: absolute; inset: 0; background: color-mix(in srgb, var(--mist) 35%, transparent); }

/* ---------- reactions ---------- */
.reacts { display: inline-flex; gap: 2px; margin-top: 4px; padding: 1px 7px; border-radius: 12px; font-size: 15px; line-height: 1.5;
  background: color-mix(in srgb, var(--paper) 85%, transparent); color: var(--ink); box-shadow: var(--shadow); }
.b.me .reacts { background: color-mix(in srgb, #fff 25%, transparent); color: var(--on-accent); box-shadow: none; }
.react-row { display: flex; gap: 2px; padding: 2px 2px 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.react-row button { width: 40px; height: 40px; border-radius: 50%; font-size: 24px; display: grid; place-items: center; transition: transform .1s; padding: 0; }
.react-row button:active { transform: scale(1.25); }
.react-row button.on { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.ctx { min-width: 0; }

/* ---------- view-once ---------- */
.oncechip { display: flex; align-items: center; gap: 10px; padding: 4px 2px; text-align: right; }
.oncechip .oi { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  background: color-mix(in srgb, currentColor 14%, transparent); }
.b.them .oncechip .oi { color: var(--accent); }
.oncechip b { display: block; font-size: 14px; }
.oncechip small { opacity: .75; font-size: 12px; }
.oncechip.used .oi { opacity: .5; }
.once { position: fixed; inset: 0; z-index: 45; background: #000; display: flex; flex-direction: column; animation: fade .15s; }
.once img { flex: 1; min-height: 0; object-fit: contain; width: 100%; }
.once-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #ddd; font-size: 14px;
  padding: 12px 16px max(14px, env(safe-area-inset-bottom)); }
.once-close { background: #fff; color: #000; padding: 9px 22px; border-radius: 20px; font-weight: 700; }

/* ---------- attach sheet ---------- */
.attach-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.attach-grid button { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 10px 4px; font-size: 14px; border-radius: 16px; }
.attach-grid button:active { background: var(--mist); }
.ai { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; color: var(--on-accent);
  background: linear-gradient(135deg, var(--accent), var(--accent2)); }
.ai.once { background: var(--ink); color: var(--paper); }

/* ---------- personalize sheet ---------- */
.me-row { display: flex; align-items: center; gap: 14px; }
.avatar-pick { width: 64px; height: 64px; border-radius: 50%; flex-shrink: 0; position: relative; overflow: hidden;
  background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); font-size: 28px; display: grid; place-items: center;
  box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px color-mix(in srgb, var(--accent) 45%, transparent); }
.avatar-pick img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.me-text b { display: block; }
.group { display: flex; flex-direction: column; gap: 8px; }
.glabel { font-size: 13px; color: var(--hush); }
.swatches { display: flex; gap: 12px; flex-wrap: wrap; }
.swatch { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg, var(--a), var(--b)); position: relative; }
.swatch.on { box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--a); }
.walls { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 6px; }
.wtile { width: 64px; height: 92px; border-radius: 14px; flex-shrink: 0; position: relative; overflow: hidden;
  border: 1.5px solid var(--line); background-size: cover; background-position: center; font-size: 12px; color: var(--hush); }
.wtile .wall { position: absolute; }
.wtile span { position: absolute; inset: auto 0 6px; text-align: center; z-index: 1; }
.wtile.on { border: 2.5px solid var(--accent); }
.wtile.add { display: grid; place-items: center; }
.wtile.add b { font-size: 26px; font-weight: 400; color: var(--accent); margin-bottom: 14px; }
#p-text button, #p-theme button { font-size: 14px; }

:root[data-text=s] { --fs: 14.5px; } :root[data-text=l] { --fs: 18px; }

/* ================= new features ================= */
.row2 { display: flex; gap: 10px; } .row2 > * { flex: 1; }
.sheet textarea { width: 100%; padding: 12px 14px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--paper); outline: none; resize: none; }
.react-row .more { font-size: 20px; color: var(--hush); }
.b.pinned::after { content: "📌"; position: absolute; top: -8px; inset-inline-end: -4px; font-size: 14px; }

/* emoji picker */
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; max-height: 46vh; overflow-y: auto; }
.emoji-grid button { font-size: 26px; height: 44px; border-radius: 10px; }
.emoji-grid button:active { background: var(--mist); }
.emoji-slots { display: flex; justify-content: center; gap: 8px; }
.emoji-slots button { width: 46px; height: 46px; border-radius: 50%; font-size: 24px; background: var(--mist); }
.emoji-slots button.on { box-shadow: 0 0 0 2.5px var(--accent); }

/* full page */
.page { position: fixed; inset: 0; z-index: 35; background: var(--mist); display: flex; flex-direction: column; animation: fade .15s; }
.page-top { display: flex; align-items: center; gap: 6px; padding: max(10px, env(safe-area-inset-top)) 10px 10px; }
.page-top h2 { margin: 0; font-size: 19px; }
.page-body { flex: 1; overflow-y: auto; padding: 4px 14px 24px; }
.page-body .empty { margin: 60px auto; }
.gal { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; align-content: start; }
.gal-month { grid-column: 1 / -1; margin: 14px 2px 4px; font-size: 14px; color: var(--hush); font-weight: 400; }
.gal-tile { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: color-mix(in srgb, var(--ink) 8%, transparent); }
.gal-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gal-play { position: absolute; inset: 0; margin: auto; width: 44px; height: 44px; border-radius: 50%; background: rgba(0, 0, 0, .5); color: #fff; display: grid; place-items: center; font-size: 18px; padding-left: 3px; }
.vid { position: relative; display: block; }
.vid .photo { min-height: 150px; }
.row { display: block; width: 100%; text-align: right; background: var(--paper); border-radius: 16px; padding: 10px 14px; margin-bottom: 8px; box-shadow: var(--shadow); }
.row b { font-size: 13px; color: var(--accent); display: block; }
.row span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row small { color: var(--hush); font-size: 12px; }
.search-in { width: 100%; padding: 13px 16px; border-radius: 16px; border: 1.5px solid var(--line); background: var(--paper); outline: none; margin-bottom: 12px; }
.search-in:focus { border-color: var(--accent); }

/* stickers */
.b.sticker { background: none !important; box-shadow: none; padding: 0; }
.b.sticker .foot { color: var(--hush); }
.b.sticker .stk { width: 150px; height: 150px; object-fit: contain; display: block; }
.sticker-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; max-height: 42vh; overflow-y: auto; }
.stk-cell, .stk-add { aspect-ratio: 1; border-radius: 14px; background: var(--mist); display: grid; place-items: center; overflow: hidden; }
.stk-cell .stk { width: 84%; height: 84%; object-fit: contain; }
.stk-add { font-size: 28px; color: var(--accent); }
.tg-row { display: flex; gap: 8px; }
.tg-row input { flex: 1; min-width: 0; padding: 11px 12px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--paper); outline: none; }
.tg-row button { width: auto; padding: 0 16px; white-space: nowrap; }

/* stories */
.orb.has-story { box-shadow: 0 0 0 2.5px var(--paper), 0 0 0 5px var(--line); cursor: pointer; }
.orb.has-story.new-story { box-shadow: 0 0 0 2.5px var(--paper), 0 0 0 5.5px var(--accent), 0 0 16px color-mix(in srgb, var(--accent) 60%, transparent); }
.story { position: fixed; inset: 0; z-index: 44; background: #000; color: #fff; display: flex; flex-direction: column; animation: fade .15s; }
.story-bars { display: flex; gap: 4px; padding: max(10px, env(safe-area-inset-top)) 10px 0; direction: ltr; }
.story-bars i { flex: 1; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, .3); }
.story-bars i.done, .story-bars i.now { background: #fff; }
.story-top { display: flex; align-items: center; gap: 10px; padding: 8px 14px; }
.story-top span { opacity: .7; font-size: 13px; flex: 1; }
.story-top .ic { color: #fff; }
.story-top #story-del { color: #ff8d8d; font-size: 14px; padding: 6px 10px; }
.story-stage { flex: 1; min-height: 0; position: relative; display: grid; place-items: center; overflow: hidden; }
.story-stage img, .story-stage video { max-width: 100%; max-height: 100%; grid-area: 1 / 1; }
.story-stage.txt { background: linear-gradient(150deg, var(--accent), var(--accent2)); margin: 0 10px; border-radius: 22px; }
.story-stage.txt p { font-size: 26px; font-weight: 700; text-align: center; padding: 24px; line-height: 1.7; color: var(--on-accent); white-space: pre-wrap; margin: 0; }
.story-stage .cap { position: absolute; bottom: 14px; left: 14px; right: 14px; margin: 0; padding: 8px 12px; border-radius: 14px; background: rgba(0, 0, 0, .55); text-align: center; }
.story-foot { text-align: center; font-size: 13px; opacity: .75; padding: 10px 10px max(14px, env(safe-area-inset-bottom)); min-height: 44px; }

/* rewards */
.gift { display: flex; align-items: center; gap: 12px; padding: 6px 2px; min-width: 210px; }
.gift-box { font-size: 44px; line-height: 1; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .18)); }
.gift:not(.open) .gift-box { animation: wiggle 2.6s ease-in-out infinite; }
@keyframes wiggle { 0%, 86%, 100% { transform: rotate(0); } 90% { transform: rotate(-9deg); } 94% { transform: rotate(9deg); } 97% { transform: rotate(-5deg); } }
.gift-text b { display: block; font-size: 15px; }
.gift-text small { display: block; opacity: .8; font-size: 12px; margin: 2px 0 6px; }
.gift-btn { padding: 6px 18px; border-radius: 16px; font-weight: 700; font-size: 14px; background: var(--paper); color: var(--accent); box-shadow: var(--shadow); }
.b.them .gift-btn { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: var(--on-accent); }
.b.gift-pop .gift-box { animation: giftpop .9s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes giftpop { 0% { transform: scale(.3) rotate(-30deg); } 60% { transform: scale(1.5) rotate(10deg); } 100% { transform: scale(1); } }

/* pet */
.pet-chip { width: 44px; height: 44px; flex-shrink: 0; border-radius: 50%; }
.pet-chip svg { width: 44px; height: 44px; }
.pet-body { align-items: center; text-align: center; }
.pet-body .row2 { width: 100%; }
.pet-art { width: 190px; height: 190px; }
.pet-art svg { width: 100%; height: 100%; overflow: visible; }
.pet-art .pet-body { animation: breathe 3.2s ease-in-out infinite; transform-origin: 100px 180px; }
@keyframes breathe { 50% { transform: scale(1.03, .97); } }
.pet-art .pet-tail { animation: tail 2.4s ease-in-out infinite; transform-origin: 150px 150px; }
@keyframes tail { 50% { transform: rotate(14deg); } }
.pet-art .pet-bulb { animation: blink 2s infinite; }
.pet-art.jump svg { animation: jump .7s ease; }
@keyframes jump { 30% { transform: translateY(-34px) rotate(-6deg); } 60% { transform: translateY(0) rotate(4deg); } 80% { transform: translateY(-10px); } }
.pet-art.munch svg { animation: munch .8s ease; }
@keyframes munch { 20%, 60% { transform: scale(1.06, .92); } 40%, 80% { transform: scale(.96, 1.05); } }
.pet-name { font-size: 22px; font-weight: 700; }
.pet-line { margin: 0; color: var(--hush); }
.pet-bar { width: 100%; height: 10px; border-radius: 5px; background: var(--mist); overflow: hidden; direction: ltr; }
.pet-bar i { display: block; height: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .5s; }
.btn-soft:disabled { opacity: .45; }
.viewer video { max-width: 100%; max-height: 100%; }
.toast { pointer-events: none; }
.viewer-x { position: absolute; top: max(12px, env(safe-area-inset-top)); left: 12px; width: 42px; height: 42px; border-radius: 50%; background: rgba(0, 0, 0, .5); color: #fff; display: grid; place-items: center; }

/* pairing */
.pin-input { width: 100%; font: 700 40px/1 ui-monospace, Menlo, monospace; letter-spacing: 18px; text-align: center; padding: 16px 0 16px 18px;
  border-radius: 18px; border: 1.5px solid var(--line); background: var(--paper); outline: none; }
.pin-input:focus { border-color: var(--accent); }
.pair { align-items: center; text-align: center; }
.pair h2 { margin: 0; font-size: 20px; }
.pin-show { font: 700 64px/1 ui-monospace, Menlo, monospace; letter-spacing: 14px; padding: 18px 10px 18px 24px; border-radius: 22px;
  background: var(--paper); box-shadow: var(--shadow); direction: ltr; }
.pair-status { color: var(--hush); margin: 0; min-height: 1.6em; }
.pair-emoji { font-size: 40px; letter-spacing: 10px; }
.pair-dots::after { content: "…"; animation: blink 1.2s infinite; }
img.setup-mark { display: block; object-fit: cover; background: none; }
.setup-card h1[dir=ltr] { text-align: right; }
