:root {
  --bg: #08090c;
  --panel: rgba(255, 255, 255, .055);
  --panel-2: rgba(255, 255, 255, .09);
  --line: rgba(255, 255, 255, .1);
  --tx: #f2f4f8;
  --tx2: #9aa3b2;
  --tx3: #626b7a;
  --pink: #ff2d55;
  --cyan: #25f4ee;
  --grad: linear-gradient(100deg, #25f4ee, #7b6cff 48%, #ff2d55);
  --sans: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --top: calc(3.4rem + var(--sat));
  --bottom: calc(3.9rem + var(--sab));
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: var(--sans); color: var(--tx); background: var(--bg);
  -webkit-font-smoothing: antialiased; overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

#app { height: 100dvh; overflow: hidden; position: relative; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: fixed; z-index: 30; inset: 0 0 auto; height: var(--top);
  padding: var(--sat) 0.9rem 0;
  display: flex; align-items: center; gap: .7rem;
  background: linear-gradient(#08090cf2, #08090cc0 70%, transparent);
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: baseline; gap: .4rem; flex: 0 0 auto; }
.logo {
  font-size: 1.22rem; font-weight: 850; letter-spacing: -.04em;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.slogan { font-size: .63rem; color: var(--tx3); letter-spacing: .06em; }
.tabs { display: flex; gap: .1rem; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  padding: .38rem .6rem; font-size: .82rem; color: var(--tx3); border-radius: 99px;
  white-space: nowrap; transition: color .15s, background .15s;
}
.tabs button.on { color: var(--tx); background: var(--panel); font-weight: 650; }
.icon-btn { display: grid; place-items: center; width: 2rem; height: 2rem; color: var(--tx2); border-radius: 50%; }
.icon-btn:active { background: var(--panel); }

/* ---------- 信息流 ---------- */
.feed {
  position: fixed; inset: var(--top) 0 var(--bottom); overflow-y: auto;
  scroll-snap-type: y mandatory; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.feed::-webkit-scrollbar { display: none; }
.feed.single .card { padding-top: 3.6rem; }
.feed-loading, .feed-empty {
  display: grid; place-items: center; height: 100%; color: var(--tx3); font-size: .9rem;
}
.feed-empty { gap: .9rem; }

.card {
  position: relative; height: 100%; scroll-snap-align: start; scroll-snap-stop: always;
  display: flex; flex-direction: column; padding: 0.9rem 1rem 1.1rem;
  overflow: hidden;
}
.card::before {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(70% 45% at 50% 8%, var(--glow, rgba(37,244,238,.16)), transparent 70%),
    radial-gradient(60% 40% at 100% 100%, var(--glow2, rgba(255,45,85,.12)), transparent 70%);
}
.card[data-kind="counter"]   { --glow: rgba(37,244,238,.18);  --glow2: rgba(37,244,238,.07); }
.card[data-kind="checklist"] { --glow: rgba(123,108,255,.2);  --glow2: rgba(123,108,255,.08); }
.card[data-kind="dice"]      { --glow: rgba(255,159,67,.18);  --glow2: rgba(255,45,85,.08); }
.card[data-kind="timer"]     { --glow: rgba(255,45,85,.18);   --glow2: rgba(255,159,67,.08); }
.card[data-kind="tally"]     { --glow: rgba(81,207,102,.16);  --glow2: rgba(37,244,238,.07); }
.card[data-kind="poll"]      { --glow: rgba(123,108,255,.2);  --glow2: rgba(37,244,238,.08); }
.card[data-kind="note"]      { --glow: rgba(255,212,59,.13);  --glow2: rgba(255,159,67,.07); }
.card[data-kind="score"]     { --glow: rgba(255,159,67,.18);  --glow2: rgba(255,159,67,.06); }

.card-head { position: relative; z-index: 2; display: flex; align-items: center; gap: .55rem; min-height: 2.4rem; }
.avatar {
  width: 2.2rem; height: 2.2rem; border-radius: 50%; display: grid; place-items: center;
  font-size: 1.15rem; background: var(--panel-2); border: 1px solid var(--line); flex: 0 0 auto;
}
.who { display: flex; flex-direction: column; gap: .05rem; min-width: 0; }
.who b { font-size: .82rem; font-weight: 650; }
.who span { font-size: .66rem; color: var(--tx3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 12rem; }
.gen-badge {
  margin-left: auto; font-size: .64rem; color: var(--cyan);
  border: 1px solid rgba(37,244,238,.3); background: rgba(37,244,238,.08);
  padding: .16rem .45rem; border-radius: 99px; flex: 0 0 auto;
}
.gen-badge.zero { color: var(--tx3); border-color: var(--line); background: var(--panel); }

.retract-note {
  position: relative; z-index: 2; margin-top: .4rem; padding: .35rem .55rem;
  font-size: .7rem; color: var(--tx3); border: 1px dashed var(--line); border-radius: .6rem;
}
.card.retracted .stage { opacity: .55; }

.live {
  display: inline-flex; align-items: center; gap: .25rem; margin-left: .45rem;
  font-size: .6rem; color: var(--cyan); border: 1px solid rgba(37,244,238,.3);
  background: rgba(37,244,238,.08); padding: .08rem .38rem; border-radius: 99px;
}
.live::before {
  content: ""; width: .34rem; height: .34rem; border-radius: 50%;
  background: var(--cyan); animation: livepulse 1.6s infinite;
}
@keyframes livepulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }

.card.fresh::after {
  content: "刚发布"; position: absolute; z-index: 3; top: .8rem; right: 3.6rem;
  font-size: .6rem; color: #08090c; background: var(--cyan);
  padding: .12rem .4rem; border-radius: 99px;
}

.stage { position: relative; z-index: 2; flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; padding: .8rem 2.5rem .8rem 0; }
.panel {
  width: 100%; max-width: 26rem; max-height: 100%;
  background: linear-gradient(180deg, rgba(255,255,255,.075), rgba(255,255,255,.035));
  border: 1px solid var(--line); border-radius: 1.5rem;
  padding: 1.1rem; display: flex; flex-direction: column; gap: .9rem;
  box-shadow: 0 1.4rem 4rem rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.07);
  overflow: auto; scrollbar-width: none;
}
.panel::-webkit-scrollbar { display: none; }
.panel-label { font-size: .68rem; color: var(--tx3); letter-spacing: .1em; }
.big-num { font-family: var(--sans); font-size: 3.6rem; line-height: 1; font-weight: 700; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.big-num small { font-size: 1rem; color: var(--tx3); font-weight: 400; margin-left: .3rem; letter-spacing: 0; }
.bar { height: .42rem; border-radius: 99px; background: rgba(255,255,255,.09); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; border-radius: 99px; background: var(--grad); transition: width .3s; }
.row { display: flex; gap: .55rem; }
.btn {
  flex: 1; min-height: 2.9rem; border-radius: .9rem; border: 1px solid var(--line);
  background: var(--panel); font-weight: 650; font-size: .92rem; transition: transform .08s, background .15s;
}
.btn:active { transform: scale(.975); background: var(--panel-2); }
.btn.primary { background: var(--grad); color: #08090c; border: 0; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 2.2rem; font-size: .78rem; flex: 0 0 auto; padding: 0 .85rem; }
.btn:disabled { opacity: .45; }

/* counter */
.counter-plus { min-height: 4.2rem; font-size: 1.25rem; border-radius: 1.2rem; }
.counter-meta { display: flex; justify-content: space-between; font-size: .74rem; color: var(--tx3); }

/* checklist */
.check-list { display: flex; flex-direction: column; gap: .45rem; max-height: 14rem; overflow: auto; }
.check-item {
  display: flex; align-items: center; gap: .6rem; padding: .62rem .7rem;
  border-radius: .8rem; background: rgba(255,255,255,.04); border: 1px solid transparent;
  text-align: left; width: 100%;
}
.check-item .box {
  width: 1.15rem; height: 1.15rem; border-radius: .38rem; border: 1.6px solid var(--tx3);
  flex: 0 0 auto; display: grid; place-items: center;
}
.check-item .box svg { width: .8rem; height: .8rem; stroke: #08090c; stroke-width: 3; opacity: 0; }
.check-item.done { background: rgba(81,207,102,.08); }
.check-item.done .box { background: var(--cyan); border-color: var(--cyan); }
.check-item.done .box svg { opacity: 1; }
.check-item.done .txt { color: var(--tx3); text-decoration: line-through; }
.check-item .txt { font-size: .86rem; }
.add-row { display: flex; gap: .5rem; }
.add-row input {
  flex: 1; min-width: 0; background: rgba(255,255,255,.05); border: 1px solid var(--line);
  border-radius: .8rem; padding: .7rem .8rem; font-size: .85rem; outline: 0;
}
.add-row input:focus { border-color: rgba(37,244,238,.5); }

/* dice */
.dice-face {
  min-height: 7rem; border-radius: 1.2rem; display: grid; place-items: center; text-align: center;
  background: radial-gradient(70% 90% at 50% 0%, rgba(255,159,67,.18), transparent), rgba(255,255,255,.035);
  border: 1px solid var(--line); padding: .8rem;
}
.dice-face b { font-size: 1.7rem; letter-spacing: -.02em; }
.dice-face span { font-size: .72rem; color: var(--tx3); }
.rolling b { animation: shake .35s infinite; }
@keyframes shake { 0%,100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-6px) rotate(-3deg); } }

/* timer */
.timer-face { font-family: var(--mono); font-size: 3.4rem; text-align: center; letter-spacing: -.04em; }
.timer-face.run { color: var(--cyan); }
.timer-sub { text-align: center; font-size: .72rem; color: var(--tx3); }

/* tally */
.tally-total { font-family: var(--mono); font-size: 2.5rem; }
.tally-total small { font-size: .9rem; color: var(--tx3); }
.tally-list { display: flex; flex-direction: column; gap: .3rem; max-height: 8.5rem; overflow: auto; }
.tally-row { display: flex; justify-content: space-between; font-size: .8rem; padding: .35rem .1rem; border-bottom: 1px dashed var(--line); }
.tally-row span { color: var(--tx3); }
.tally-row b { font-family: var(--mono); }
.tally-form { display: flex; gap: .45rem; }
.tally-form input { width: 100%; min-width: 0; background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: .7rem; padding: .6rem .7rem; font-size: .85rem; outline: 0; }

/* poll */
.poll-opt { position: relative; overflow: hidden; width: 100%; text-align: left; padding: .78rem .85rem; border-radius: .8rem; border: 1px solid var(--line); background: rgba(255,255,255,.035); }
.poll-opt .fill { position: absolute; inset: 0 auto 0 0; width: 0; background: rgba(123,108,255,.25); transition: width .35s; }
.poll-opt .inner { position: relative; display: flex; justify-content: space-between; gap: .6rem; font-size: .86rem; }
.poll-opt .inner b { font-family: var(--mono); font-size: .78rem; color: var(--tx2); }
.poll-opt.mine { border-color: rgba(123,108,255,.6); }
.poll-opt:disabled { cursor: default; }

/* note */
.note-area {
  width: 100%; min-height: 8rem; resize: none; background: transparent; border: 0; outline: 0;
  font-size: .95rem; line-height: 1.65;
}
.note-meta { font-size: .68rem; color: var(--tx3); display: flex; justify-content: space-between; }

/* score */
.score-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: .4rem; }
.score-cell { aspect-ratio: 1; border-radius: .7rem; border: 1px solid var(--line); background: rgba(255,255,255,.035); font-family: var(--mono); font-size: .85rem; }
.score-cell.on { background: var(--grad); color: #08090c; border: 0; font-weight: 700; }
.score-hist { display: flex; align-items: flex-end; gap: .2rem; height: 2.6rem; }
.score-hist i { flex: 1; background: rgba(255,159,67,.55); border-radius: .2rem .2rem 0 0; min-height: 2px; }

/* caption */
.caption { position: relative; z-index: 2; padding-right: 4.2rem; }
.caption h1 { font-size: 1.15rem; letter-spacing: -.02em; margin-bottom: .3rem; }
.caption p { font-size: .8rem; color: var(--tx2); line-height: 1.5; }
.tags { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .45rem; }
.tags span { font-size: .68rem; color: var(--cyan); opacity: .85; }

/* right rail */
.rail { position: absolute; z-index: 3; right: .45rem; bottom: 6.2rem; display: flex; flex-direction: column; gap: .95rem; align-items: center; }
.rail-btn { display: flex; flex-direction: column; align-items: center; gap: .22rem; color: var(--tx); font-size: .64rem; }
.rail-btn .circle {
  width: 2.55rem; height: 2.55rem; border-radius: 50%; display: grid; place-items: center;
  background: rgba(20,22,28,.72); border: 1px solid var(--line); backdrop-filter: blur(6px);
}
.rail-btn svg { width: 1.2rem; height: 1.2rem; }
.rail-btn.liked .circle { background: rgba(255,45,85,.16); border-color: rgba(255,45,85,.5); color: var(--pink); }
.rail-btn.liked svg { fill: var(--pink); }
.rail-btn:active .circle { transform: scale(.92); }
.rail-btn .n { font-family: var(--mono); }

/* ---------- 底栏 ---------- */
.bottomnav {
  position: fixed; z-index: 30; inset: auto 0 0; height: var(--bottom);
  padding: 0 0 var(--sab); display: flex; align-items: center; justify-content: space-around;
  background: linear-gradient(transparent, #08090cf2 30%);
  backdrop-filter: blur(14px);
}
.bottomnav > button { display: flex; flex-direction: column; align-items: center; gap: .18rem; font-size: .6rem; color: var(--tx3); width: 3.6rem; padding-top: .35rem; }
.bottomnav > button.on { color: var(--tx); }
.bottomnav > button.plus { width: auto; flex-direction: row; gap: 0; }
.bottomnav .plus svg { width: 3rem; height: 2rem; padding: .28rem 0; stroke: #08090c; stroke-width: 2.6; background: var(--grad); border-radius: .85rem; box-shadow: 0 .4rem 1.4rem rgba(255,45,85,.28); }

/* ---------- 弹层 ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.sheet-mask { position: absolute; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(3px); animation: fade .2s; }
.sheet {
  position: relative; width: 100%; max-width: 32rem; max-height: 88dvh; display: flex; flex-direction: column;
  background: #101218; border: 1px solid var(--line); border-radius: 1.5rem 1.5rem 0 0;
  padding: .5rem .2rem calc(1rem + var(--sab)); animation: up .24s cubic-bezier(.2,.8,.2,1);
}
.sheet-grip { width: 2.4rem; height: .26rem; border-radius: 99px; background: var(--tx3); opacity: .5; margin: .3rem auto .2rem; }
.sheet-head { display: flex; align-items: center; padding: .3rem .9rem .5rem 1.15rem; }
.sheet-head h2 { font-size: 1.02rem; letter-spacing: -.01em; }
.sheet-head .icon-btn { margin-left: auto; font-size: .95rem; color: var(--tx3); }
.sheet-body { padding: .2rem 1.15rem 1.2rem; overflow-y: auto; }
.sheet-body p.hint { font-size: .76rem; color: var(--tx3); line-height: 1.55; margin-bottom: .75rem; }
.sheet textarea, .sheet input[type=text], .sheet input[type=number] {
  width: 100%; background: rgba(255,255,255,.05); border: 1px solid var(--line);
  border-radius: .9rem; padding: .85rem .9rem; font-size: .92rem; outline: 0; resize: vertical;
}
.sheet textarea:focus, .sheet input:focus { border-color: rgba(37,244,238,.5); }
.sheet textarea { min-height: 5.2rem; line-height: 1.55; }
.field { margin-bottom: .8rem; }
.field label { display: block; font-size: .72rem; color: var(--tx3); margin-bottom: .35rem; }
.field .inline { display: flex; gap: .5rem; }
.field .inline input { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .6rem 0 .2rem; }
.chips button { font-size: .74rem; color: var(--tx2); border: 1px solid var(--line); border-radius: 99px; padding: .36rem .65rem; }
.chips button:active { background: var(--panel); }
.preview-card {
  margin-top: .9rem; padding: .95rem; border-radius: 1.1rem; border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
}
.preview-card .pv-head { display: flex; align-items: center; gap: .55rem; margin-bottom: .5rem; }
.preview-card .pv-head .avatar { width: 1.9rem; height: 1.9rem; font-size: .95rem; }
.preview-card h3 { font-size: .98rem; }
.preview-card .pv-kind { font-size: .66rem; color: var(--tx3); }
.preview-card p { font-size: .78rem; color: var(--tx2); line-height: 1.5; }
.sheet-actions { display: flex; gap: .55rem; margin-top: 1rem; }
.sheet-actions .btn { min-height: 2.9rem; }
.lineage { display: flex; flex-direction: column; gap: 0; }
.lineage .node { display: flex; align-items: center; gap: .6rem; padding: .5rem 0; }
.lineage .node .dot { width: .55rem; height: .55rem; border-radius: 50%; background: var(--tx3); margin-left: .35rem; flex: 0 0 auto; }
.lineage .node.cur .dot { background: var(--cyan); box-shadow: 0 0 .7rem var(--cyan); }
.lineage .node b { font-size: .84rem; font-weight: 600; }
.lineage .node span { font-size: .66rem; color: var(--tx3); }
.lineage .arrow { margin-left: .57rem; border-left: 1px dashed var(--line); height: .55rem; }
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .55rem; margin: .2rem 0 .9rem; }
.stat-cell { background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: .8rem; padding: .7rem .8rem; }
.stat-cell b { display: block; font-family: var(--mono); font-size: 1.25rem; }
.stat-cell span { font-size: .66rem; color: var(--tx3); }
.mylist { display: flex; flex-direction: column; gap: .45rem; }
.mylist button { display: flex; align-items: center; gap: .55rem; text-align: left; padding: .55rem .6rem; border-radius: .7rem; background: rgba(255,255,255,.035); }
.mylist em { font-style: normal; font-size: .86rem; }
.mylist small { margin-left: auto; color: var(--tx3); font-size: .66rem; font-family: var(--mono); }

.toast {
  position: fixed; z-index: 90; left: 50%; bottom: calc(var(--bottom) + 2rem); transform: translate(-50%, 1rem);
  background: rgba(24,26,33,.96); border: 1px solid var(--line); color: var(--tx);
  padding: .55rem .9rem; border-radius: 99px; font-size: .78rem; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; max-width: 86vw; text-align: center;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

.back-chip {
  position: fixed; z-index: 35; top: calc(var(--top) + .4rem); left: .7rem;
  font-size: .74rem; color: var(--tx); background: rgba(24,26,33,.9);
  border: 1px solid var(--line); border-radius: 99px; padding: .38rem .75rem;
  backdrop-filter: blur(8px);
}
@media (min-width: 700px) { .back-chip { left: calc(50% - 15rem + .7rem); } }

@media (min-width: 700px) {
  #app { max-width: 30rem; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
  .topbar { left: 50%; transform: translateX(-50%); max-width: 30rem; }
  .bottomnav { left: 50%; transform: translateX(-50%); max-width: 30rem; }
  .feed { left: 50%; right: auto; transform: translateX(-50%); width: 30rem; }
  body { background: #050609; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
