:root {
  --bg: #14101c;
  --bg2: #1c1628;
  --card: #241d33;
  --ink: #f0eaf7;
  --dim: #9d91b3;
  --accent: #ff5c8a;
  --accent2: #8a5cff;
  --me: #3d2f66;
  --them: #2a2140;
  --radius: 18px;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.45 -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; }
input { font: inherit; }

/* ---------- setup ---------- */
#setup, #share {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
}
.setup-card, .share-card {
  width: 100%; max-width: 340px; text-align: center;
  background: var(--bg2); border-radius: var(--radius); padding: 32px 24px;
  display: grid; gap: 14px;
}
.setup-logo { font-size: 44px; }
.setup-card input {
  background: var(--card); color: var(--ink); border: 1px solid #ffffff18;
  border-radius: 12px; padding: 12px 14px; outline: none;
}
.setup-card input:focus { border-color: var(--accent2); }
.setup-card button, .share-actions .primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 12px; padding: 12px; font-weight: 600;
}
.error { color: var(--accent); min-height: 1.2em; font-size: 13px; }
.share-preview {
  background: var(--card); border-radius: 12px; padding: 14px;
  color: var(--dim); word-break: break-all; font-size: 13px; min-height: 60px;
}
.share-actions { display: flex; gap: 10px; }
.share-actions button {
  flex: 1; border-radius: 12px; padding: 12px; background: var(--card);
}

/* ---------- main ---------- */
#main { display: flex; flex-direction: column; height: 100dvh; max-width: 720px; margin: 0 auto; }
#bar {
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  border-bottom: 1px solid #ffffff10;
}
.bar-title { font-weight: 700; letter-spacing: .04em; }
.streak {
  display: flex; align-items: center; gap: 4px;
  background: var(--card); border-radius: 999px; padding: 4px 12px;
  font-weight: 700;
}
.streak .flame { filter: saturate(1.2); }
.streak.dead .flame { filter: grayscale(1) opacity(.45); }
.streak-state { font-size: 11px; font-weight: 500; color: var(--dim); margin-left: 4px; }
.streak.pending { outline: 1px solid var(--accent); }
#bar .spacer { flex: 1; }
.streak { margin-left: auto; }
.icon-btn, .who {
  background: var(--card); border-radius: 999px;
  padding: 6px 10px; font-size: 13px; color: var(--dim);
}
.who { font-weight: 600; }

#feed {
  flex: 1; overflow-y: auto; padding: 16px 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.day-divider {
  align-self: center; font-size: 11px; color: var(--dim);
  background: var(--bg2); border-radius: 999px; padding: 4px 12px; margin: 6px 0;
}
.msg { max-width: 82%; display: flex; flex-direction: column; gap: 4px; }
.msg.them { align-self: flex-start; }
.msg.me { align-self: flex-end; align-items: flex-end; }
.bubble {
  border-radius: var(--radius); padding: 10px 14px;
  overflow-wrap: anywhere; white-space: pre-wrap;
}
.msg.them .bubble { background: var(--them); border-bottom-left-radius: 6px; }
.msg.me .bubble { background: var(--me); border-bottom-right-radius: 6px; }
.meta { font-size: 11px; color: var(--dim); padding: 0 6px; }
.reacts { display: flex; gap: 6px; }
.reacts .pill {
  background: var(--card); border-radius: 999px; padding: 3px 9px; font-size: 12px;
}
.react-btn {
  align-self: flex-start; background: transparent; border-radius: 999px;
  padding: 2px 8px; font-size: 13px; opacity: .35; transition: opacity .15s;
}
.msg:hover .react-btn, .react-btn.on { opacity: 1; }
.msg.me .react-btn { align-self: flex-end; }

/* tiktok card */
.tt-card {
  background: var(--them); border-radius: var(--radius); overflow: hidden;
  width: min(320px, 78vw);
}
.msg.me .tt-card { background: var(--me); }
.tt-thumb {
  position: relative; display: block; width: 100%; aspect-ratio: 9/12;
  background: #000 center/cover no-repeat; max-height: 420px;
}
.tt-thumb .play {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 46px; color: #fff; text-shadow: 0 2px 12px #000c;
}
.tt-info { padding: 10px 12px; display: grid; gap: 2px; }
.tt-title { font-size: 13px; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tt-author { font-size: 11px; color: var(--dim); }
.tt-player { width: 100%; aspect-ratio: 325/578; border: 0; display: block; background: #000; }
.tt-open { font-size: 11px; color: var(--dim); padding: 0 12px 10px; display: block; text-decoration: none; }
.tt-open:hover { color: var(--ink); }

/* composer */
#composer {
  display: flex; gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid #ffffff10;
}
#composer-input {
  flex: 1; background: var(--card); color: var(--ink);
  border: 1px solid #ffffff14; border-radius: 999px;
  padding: 12px 16px; outline: none;
}
#composer-input:focus { border-color: var(--accent2); }
#composer-send {
  width: 46px; height: 46px; border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  font-size: 16px;
}
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: var(--card); border: 1px solid #ffffff1a; color: var(--ink);
  border-radius: 999px; padding: 8px 16px; font-size: 13px; z-index: 9;
}
