:root {
  --bg: #ffffff;
  --bg-elev: #ffffff;
  --bg-soft: #f5f5f5;
  --text: #101010;
  --muted: #8a8a8a;
  --line: #e6e6e6;
  --accent: #3b82f6;
  --saved: #16a34a;
  --like: #ff3040;
  --overlay: rgba(0, 0, 0, 0.35);
  --lv1: #16a34a;
  --lv2: #d97706;
  --lv3: #dc2626;
  --ok-bg: #dcfce7;
  --bad-bg: #fee2e2;
  --tabbar-h: 60px;
  --maxw: 620px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101010;
    --bg-elev: #181818;
    --bg-soft: #1e1e1e;
    --text: #f3f5f7;
    --muted: #777777;
    --line: #2a2a2a;
    --accent: #60a5fa;
    --saved: #4ade80;
    --overlay: rgba(0, 0, 0, 0.6);
    --lv1: #4ade80;
    --lv2: #fbbf24;
    --lv3: #f87171;
    --ok-bg: #14532d;
    --bad-bg: #7f1d1d;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
button:disabled { cursor: default; }
a { color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  position: relative;
  max-width: var(--maxw); margin: 0 auto; height: 52px;
  display: flex; align-items: center; justify-content: center;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand.compact .logo { display: none; }
.logo { font-family: Georgia, serif; font-size: 28px; font-weight: 700; line-height: 1; }
.topbar-title { font-size: 16px; margin: 0; font-weight: 700; }
.back-btn { position: absolute; left: 8px; top: 4px; }
.goal-chip {
  position: absolute; right: 12px; top: 10px;
  display: flex; align-items: center; gap: 4px; padding: 3px 10px 3px 4px;
  border-radius: 999px; background: var(--bg-soft); font-size: 13px; font-weight: 700;
}
.ring { width: 24px; height: 24px; transform: rotate(-90deg); }
.ring-bg { stroke: var(--line); stroke-width: 3; }
.ring-fg { stroke: var(--lv2); stroke-width: 3; transition: stroke-dashoffset 0.5s ease; }
.ring-fg.done { stroke: var(--saved); }

main { max-width: var(--maxw); margin: 0 auto; }

/* ---------- Home ---------- */
.feed-tabs { display: flex; border-bottom: 1px solid var(--line); }
.feed-tab {
  flex: 1; text-align: center; padding: 12px 0 10px; font-weight: 700; color: var(--muted);
  border-bottom: 1.5px solid transparent;
}
.feed-tab.active { color: var(--text); border-bottom-color: var(--text); }

.composer-prompt {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  border-bottom: 1px solid var(--line); color: var(--muted); cursor: pointer;
}
.sentinel { height: 1px; }
.divider {
  text-align: center; color: var(--muted); font-size: 13px; font-weight: 600;
  padding: 18px 16px; border-bottom: 1px solid var(--line); background: var(--bg-soft);
}

/* ---------- Posts ---------- */
.post { display: flex; gap: 12px; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }

.post-left { position: relative; display: flex; flex-direction: column; align-items: center; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 20px;
  background: var(--bg-soft);
}
.avatar.sm { width: 30px; height: 30px; font-size: 16px; }
.avatar.lg { width: 72px; height: 72px; font-size: 38px; }
.avatar-btn { display: block; border-radius: 50%; flex: none; }
.follow-plus {
  position: absolute; top: 24px; left: 22px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--text); color: var(--bg); border: 2px solid var(--bg);
  display: grid; place-items: center;
}
.follow-plus svg { width: 12px; height: 12px; stroke-width: 3; }
.thread-line { width: 2px; flex: 1; margin-top: 6px; background: var(--line); border-radius: 2px; min-height: 12px; }
.post.full .thread-line { display: none; }

.post-main { flex: 1; min-width: 0; }
.post-head { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.post-name { font-weight: 700; }
.post-handle, .post-time { color: var(--muted); font-size: 14px; }
.post-tags { display: flex; gap: 6px; margin: 2px 0 4px; flex-wrap: wrap; }
.tag { font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--bg-soft); color: var(--muted); }
button.tag:active { color: var(--text); }
.level-tag { font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; border: 1px solid currentColor; white-space: nowrap; }
.level-tag.lv1 { color: var(--lv1); }
.level-tag.lv2 { color: var(--lv2); }
.level-tag.lv3 { color: var(--lv3); }

.post-text { white-space: pre-wrap; word-wrap: break-word; margin: 2px 0 6px; cursor: pointer; }
.post.full .post-text { font-size: 16px; cursor: default; }
.vocab {
  font: inherit; color: var(--accent); font-weight: 600;
  text-decoration: underline dotted; text-underline-offset: 3px;
  cursor: pointer; padding: 0; display: inline;
}
.vocab.saved { color: var(--saved); text-decoration-style: solid; }

.translate-btn { color: var(--muted); font-size: 13px; font-weight: 600; margin: 0 0 6px; }
.translation {
  white-space: pre-wrap; font-size: 14px; color: var(--muted);
  border-left: 2px solid var(--line); padding: 2px 0 2px 10px; margin: 0 0 8px;
}
.used-words { font-size: 13px; color: var(--saved); font-weight: 600; margin: 0 0 6px; }

.actions { display: flex; gap: 4px; margin-left: -8px; }
.act {
  display: inline-flex; align-items: center; gap: 4px; padding: 6px 8px;
  border-radius: 999px; color: var(--text); font-size: 13px;
}
.act:active { background: var(--bg-soft); }
.act.liked { color: var(--like); }
.act.liked svg { fill: var(--like); stroke: var(--like); }
.act.bookmarked svg { fill: currentColor; }
.act.pop svg { animation: pop 0.35s ease; }
@keyframes pop { 40% { transform: scale(1.35); } 100% { transform: scale(1); } }
.act-count { min-width: 1ch; }

.empty { text-align: center; color: var(--muted); padding: 48px 24px; }
.empty.small { padding: 24px 16px; font-size: 14px; }
.empty .big { font-size: 40px; display: block; margin-bottom: 8px; }

/* ---------- Quiz card ---------- */
.quiz {
  margin: 12px 16px; padding: 16px; border-radius: 18px;
  border: 1.5px solid var(--line); background: var(--bg-elev);
}
.quiz.win { border-color: var(--saved); animation: win 0.5s ease; }
@keyframes win { 30% { transform: scale(1.02); } 100% { transform: scale(1); } }
.quiz-head { font-size: 12px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--lv2); }
.quiz-q { font-weight: 700; margin-top: 6px; }
.quiz-word { font-size: 24px; font-weight: 800; margin: 6px 0 10px; }
.quiz-word .muted { font-size: 14px; font-weight: 400; }
.quiz-prompt { font-size: 16px; margin: 6px 0 2px; }
.quiz-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.quiz-opt {
  padding: 12px 10px; border-radius: 12px; background: var(--bg-soft);
  font-weight: 600; text-align: center; font-size: 14px;
}
.quiz-opt.correct { background: var(--ok-bg); color: var(--saved); }
.quiz-opt.wrong { background: var(--bad-bg); color: var(--like); }
.quiz-result { margin-top: 12px; font-size: 14px; display: grid; gap: 4px; }
.quiz-result .ok { color: var(--saved); }
.quiz-result .bad { color: var(--like); }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: center;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.tab {
  position: relative; flex: 1; max-width: 120px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
}
.tab svg { width: 27px; height: 27px; }
.tab.active { color: var(--text); }
.tab.active svg { stroke-width: 2.4; }
.badge {
  position: absolute; top: 8px; left: calc(50% + 6px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--like); color: #fff; font-size: 11px; line-height: 18px; text-align: center;
}

/* ---------- Word sheet ---------- */
.overlay { position: fixed; inset: 0; background: var(--overlay); z-index: 40; animation: fade 0.2s ease; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  max-width: var(--maxw); margin: 0 auto;
  background: var(--bg-elev); border-radius: 20px 20px 0 0;
  padding: 8px 20px calc(20px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.15);
  animation: slideUp 0.25s cubic-bezier(.2, .8, .2, 1);
  max-height: 85vh; overflow-y: auto;
}
@keyframes slideUp { from { transform: translateY(100%); } }
.sheet-handle { width: 36px; height: 4px; border-radius: 4px; background: var(--line); margin: 0 auto 14px; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; }
.sheet-head h2 { margin: 0; font-size: 28px; }
.sheet-meta { color: var(--muted); display: flex; gap: 8px; align-items: center; margin-top: 2px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: var(--bg-soft);
}
.icon-btn.plain { background: none; }
.sheet-zh { font-size: 20px; font-weight: 700; margin: 14px 0; }
.sheet-example { background: var(--bg-soft); border-radius: 14px; padding: 12px 14px; margin-bottom: 16px; }
.sheet-example p { margin: 4px 0; }
.sheet-actions { display: grid; gap: 8px; }
.label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.primary-btn {
  width: 100%; padding: 14px; border-radius: 12px; font-weight: 700; text-align: center;
  background: var(--text); color: var(--bg);
}
.primary-btn:disabled { opacity: 0.35; }
.primary-btn.done { background: var(--bg-soft); color: var(--saved); }
.outline-btn {
  flex: 1; padding: 10px; border: 1px solid var(--line); border-radius: 10px;
  font-weight: 600; font-size: 14px; text-align: center;
}

/* ---------- Composer ---------- */
.composer {
  position: fixed; inset: 0; z-index: 60; background: var(--bg);
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top);
  animation: slideUp 0.25s cubic-bezier(.2, .8, .2, 1);
}
.composer > * { width: 100%; max-width: var(--maxw); margin-left: auto; margin-right: auto; }
.composer-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.composer-top .spacer { width: 52px; }
.text-btn { font-weight: 500; }
.text-btn.small { font-size: 13px; color: var(--accent); font-weight: 600; }
.challenge { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.challenge-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); font-weight: 600; }
.challenge-words { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.challenge-word { padding: 6px 12px; border-radius: 999px; background: var(--bg-soft); font-weight: 600; font-size: 14px; }
.challenge-word.used { background: color-mix(in srgb, var(--saved) 18%, transparent); color: var(--saved); }
.challenge-word small { color: var(--muted); font-weight: 400; margin-left: 4px; }
.composer-body { display: flex; gap: 12px; padding: 14px 16px; flex: 1; overflow-y: auto; }
.composer-main { flex: 1; min-width: 0; }
.composer-main .name { font-weight: 700; }
.composer textarea {
  width: 100%; border: 0; outline: 0; resize: none; background: transparent;
  color: var(--text); font: inherit; font-size: 16px; padding: 4px 0;
}
.composer-detect { font-size: 13px; color: var(--saved); font-weight: 600; min-height: 20px; }
.composer-bottom {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line);
}
.post-btn { padding: 8px 20px; border-radius: 999px; background: var(--text); color: var(--bg); font-weight: 700; }
.post-btn.small { padding: 6px 14px; font-size: 14px; }
.post-btn:disabled { opacity: 0.35; }

/* ---------- Search ---------- */
.search-bar {
  display: flex; align-items: center; gap: 8px; margin: 10px 16px; padding: 10px 14px;
  border-radius: 14px; background: var(--bg-soft); color: var(--muted);
}
.search-bar svg { width: 18px; height: 18px; flex: none; }
.search-bar input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  color: var(--text); font: inherit; font-size: 16px;
}
.topic-grid { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px; }
.chip {
  flex: none; padding: 6px 14px; border-radius: 999px;
  border: 1px solid var(--line); font-size: 13px; font-weight: 600; color: var(--muted);
}
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.section-title { padding: 12px 16px; font-weight: 700; border-bottom: 1px solid var(--line); border-top: 1px solid var(--line); margin-top: -1px; }

.person-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.person-info { flex: 1; min-width: 0; display: grid; gap: 1px; }
.person-info .muted { font-size: 13px; }
.bio { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.follow-btn {
  flex: none; padding: 6px 16px; border-radius: 10px; font-weight: 700; font-size: 14px;
  background: var(--text); color: var(--bg); border: 1px solid var(--text); text-align: center;
}
.follow-btn.on { background: transparent; color: var(--muted); border-color: var(--line); }
.follow-btn.wide { flex: 1; padding: 9px; }

/* ---------- Review ---------- */
.segmented { display: flex; margin: 12px 16px; padding: 3px; background: var(--bg-soft); border-radius: 12px; }
.seg { flex: 1; padding: 8px; border-radius: 10px; font-weight: 600; font-size: 14px; color: var(--muted); text-align: center; }
.seg.active { background: var(--bg); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }

.review-summary { padding: 0 16px 8px; color: var(--muted); font-size: 13px; }
.word-item { border-bottom: 1px solid var(--line); }
.word-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; width: 100%; text-align: left; }
.word-results .word-row { border-bottom: 1px solid var(--line); }
.word-row .w { font-weight: 700; font-size: 16px; }
.word-row .z { color: var(--muted); font-size: 14px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.word-detail { padding: 0 16px 14px; font-size: 14px; }
.word-detail p { margin: 4px 0; }
.row-actions { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 8px; }
.link { color: var(--accent); font-weight: 600; font-size: 13px; text-decoration: none; }
.link.danger { color: var(--like); }
.push { margin-left: auto; }

.flash-wrap { padding: 8px 16px 24px; }
.flash-progress { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.flashcard {
  width: 100%; min-height: 280px; border-radius: 22px; padding: 24px;
  border: 1px solid var(--line); background: var(--bg-elev);
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.06);
}
.flashcard .fw { font-size: 32px; font-weight: 800; }
.flashcard .fpos { color: var(--muted); margin-top: 4px; }
.flashcard .fhint { color: var(--muted); font-size: 13px; margin-top: 24px; }
.flashcard .fzh { font-size: 22px; font-weight: 700; margin-top: 14px; }
.flashcard .fex { font-size: 14px; margin-top: 14px; }
.flashcard .fexzh { font-size: 13px; color: var(--muted); margin-top: 4px; }
.flashcard.flip { animation: flip 0.3s ease; }
@keyframes flip { 50% { transform: scaleX(0.02); } }
.flash-buttons { display: flex; gap: 12px; margin-top: 16px; }
.flash-buttons button { flex: 1; padding: 14px; border-radius: 14px; font-weight: 700; text-align: center; }
.btn-again { background: var(--bg-soft); }
.btn-got { background: var(--text); color: var(--bg); }

/* ---------- Profiles ---------- */
.profile-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 16px 8px; }
.profile-head h2 { margin: 0; font-size: 24px; }
.profile-head .handle { color: var(--muted); }
.profile-bio { margin: 0 16px 8px; }
.profile-stats { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 0 16px 12px; color: var(--muted); font-size: 14px; }
.profile-stats b { color: var(--text); }
.profile-edit { padding: 0 16px 16px; display: flex; gap: 8px; }
.edit-form { padding: 0 16px 16px; display: grid; gap: 10px; }
.edit-form label { font-size: 13px; color: var(--muted); font-weight: 600; display: grid; gap: 4px; }
.edit-form input {
  font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg-soft); color: var(--text);
}
.emoji-picks { display: flex; gap: 6px; flex-wrap: wrap; }
.emoji-pick { width: 40px; height: 40px; border-radius: 50%; background: var(--bg-soft); font-size: 20px; text-align: center; }
.emoji-pick.active { outline: 2px solid var(--text); }

.card { margin: 0 16px 14px; padding: 14px; border-radius: 16px; background: var(--bg-soft); }
.card.account { display: grid; gap: 10px; font-size: 14px; }
.goal-top { display: flex; justify-content: space-between; align-items: baseline; }
.goal-bar { height: 8px; border-radius: 8px; background: var(--line); margin: 10px 0 14px; overflow: hidden; }
.goal-bar i { display: block; height: 100%; background: var(--saved); border-radius: 8px; transition: width 0.4s ease; }
.bars { display: flex; justify-content: space-between; align-items: flex-end; height: 84px; gap: 6px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); }
.bar { width: 100%; max-width: 26px; border-radius: 6px 6px 3px 3px; background: var(--line); }
.bar.met { background: var(--saved); }
.goal-pick { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.goal-card p { margin: 10px 0 0; }

.following-strip { display: flex; gap: 14px; overflow-x: auto; padding: 12px 16px; scrollbar-width: none; }
.following-strip::-webkit-scrollbar { display: none; }
.mini-person { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); flex: none; width: 56px; text-align: center; }
.mini-person .avatar { width: 48px; height: 48px; font-size: 24px; }

/* ---------- Thread & replies ---------- */
#view-thread { padding-bottom: 70px; }
.comment { display: flex; gap: 10px; padding: 12px 16px 6px; }
.comment-main { flex: 1; min-width: 0; }
.comment .post-text { cursor: default; margin-bottom: 4px; }
.char-reply { padding-left: 40px; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.dots { display: none; gap: 4px; padding: 8px 0; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1s infinite; }
.dots i:nth-child(2) { animation-delay: 0.15s; }
.dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 50% { opacity: 0.2; } }
.char-reply.typing .dots { display: flex; }
.char-reply.typing .post-text { display: none; }

.reply-bar {
  position: fixed; left: 0; right: 0; z-index: 25;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  max-width: var(--maxw); margin: 0 auto;
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  background: var(--bg); border-top: 1px solid var(--line);
}
.reply-bar input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: var(--bg-soft); color: var(--text);
  font: inherit; font-size: 16px; padding: 8px 14px; border-radius: 999px;
}

/* ---------- Onboarding ---------- */
.onboard { position: fixed; inset: 0; z-index: 80; background: var(--bg); overflow-y: auto; }
.onboard-inner {
  max-width: 520px; margin: 0 auto; min-height: 100%;
  padding: calc(20px + env(safe-area-inset-top)) 20px calc(20px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column;
}
.ob-dots { display: flex; justify-content: center; gap: 6px; margin-bottom: 20px; }
.ob-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.ob-dots i.on { background: var(--text); width: 22px; border-radius: 8px; }
.ob-content { flex: 1; }
.ob-content h2 { font-size: 26px; margin: 8px 0; }
.ob-content .topic-grid { padding: 12px 0; }
.ob-hero { font-family: Georgia, serif; font-size: 64px; font-weight: 700; text-align: center; margin: 12px 0; }
.ob-options { display: grid; gap: 10px; margin-top: 18px; }
.ob-opt { display: grid; gap: 2px; padding: 14px 16px; border-radius: 14px; border: 1.5px solid var(--line); }
.ob-opt span { color: var(--muted); font-size: 13px; }
.ob-opt.on { border-color: var(--text); background: var(--bg-soft); }
.ob-people { display: grid; gap: 4px; margin-top: 12px; }
.ob-person { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.ob-check {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none;
  border: 1.5px solid var(--line); font-weight: 700;
}
.ob-person.on .ob-check { background: var(--text); color: var(--bg); border-color: var(--text); }
.ob-nav { display: flex; gap: 10px; margin-top: 20px; position: sticky; bottom: 0; background: var(--bg); padding-top: 10px; }
.ob-nav > * { flex: 1; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 90;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 600; transition: all 0.25s ease;
  max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
body.in-thread .toast { bottom: calc(var(--tabbar-h) + 72px + env(safe-area-inset-bottom)); }

/* ---------- Toefl-Tofu additions ---------- */
:root { --tofu: #FFD66B; --tofu-soft: #FFF6E0; }
@media (prefers-color-scheme: dark) { :root { --tofu-soft: #2a2416; } }
.logo.tofu { display: block; }
.tofu { display: inline-block; vertical-align: middle; stroke: none; fill: none; }
.ob-hero { font-family: inherit; }
.ob-hero .tofu { animation: wobble 2.4s ease-in-out infinite; transform-origin: 50% 90%; }
@keyframes wobble { 0%, 100% { transform: rotate(0) scaleY(1); } 25% { transform: rotate(-3deg) scaleY(0.97); } 75% { transform: rotate(3deg) scaleY(1.02); } }
.empty .tofu { margin-bottom: 6px; }

.notice {
  display: flex; gap: 10px; align-items: flex-start; margin: 10px 16px 0; padding: 12px 14px;
  border-radius: 14px; background: var(--tofu-soft); border: 1px solid var(--tofu); font-size: 14px;
}
.notice-text { flex: 1; }
.notice-x { color: var(--muted); padding: 0 4px; }

.act.reading { color: var(--accent); }
.act.reading svg { animation: pop 0.8s ease infinite; }

.srs-card { display: flex; align-items: center; gap: 12px; justify-content: space-between; margin-top: 4px; }
.due { font-size: 12px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.due.now { color: var(--like); }


.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-top: 10px; }
.badge-item {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px;
  padding: 10px 6px; border-radius: 12px; background: var(--bg); font-size: 12px; opacity: 0.55;
}
.badge-item.on { opacity: 1; box-shadow: inset 0 0 0 1.5px var(--tofu); }
.badge-item .b-icon { font-size: 26px; }
.badge-item b { font-size: 12px; }
.badge-item .muted { font-size: 11px; line-height: 1.3; }

.profile-tabs { margin-top: 8px; border-top: 1px solid var(--line); }
.profile-tabs .muted { font-weight: 500; font-size: 13px; }
#profileList > .badges { padding: 6px 16px 24px; }
.settings-top { display: flex; align-items: center; justify-content: space-between; padding: 4px 16px 10px; border-top: 1px solid var(--line); padding-top: 12px; }
.ring-fg { stroke: #E0A800; }
.ob-nav-col { flex-direction: column; }
.google-btn { display: flex; align-items: center; justify-content: center; gap: 10px; }
.google-btn svg { width: 20px; height: 20px; background: #fff; border-radius: 50%; padding: 2px; box-sizing: content-box; }
.muted-link { color: var(--muted); text-align: center; padding: 8px; }
.ob-content .notice { margin: 14px 0 0; }

/* ---------- Profiles with photos ---------- */
.avatar { overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.has-photo { background: var(--bg-soft); }
.photo-row { display: flex; align-items: center; gap: 16px; }
.photo-actions { display: grid; gap: 8px; justify-items: start; }
.file-btn { cursor: pointer; display: inline-block; padding: 9px 14px; }
.edit-form textarea, .edit-form select {
  font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 10px; resize: vertical;
  border: 1px solid var(--line); background: var(--bg-soft); color: var(--text);
}
.edit-form label { position: relative; }
.edit-form #bioCount { position: absolute; right: 0; top: 0; font-weight: 500; }
.emoji-picks { max-height: 150px; overflow-y: auto; }
.profile-edit.flush { padding: 4px 0 0; }

/* ---------- Notifications ---------- */
.toggle-list { display: grid; gap: 2px; margin: 8px 0; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; font-size: 14px; }
.toggle input { width: 20px; height: 20px; accent-color: #E0A800; }
#notifCard p { margin: 8px 0 12px; }

/* ---------- Install (PWA) ---------- */
.install-card { display: flex; align-items: center; gap: 12px; background: var(--tofu-soft); box-shadow: inset 0 0 0 1px var(--tofu); }
#installSlot .install-card { margin: 12px 16px 0; }
.install-text { flex: 1; display: grid; gap: 2px; min-width: 0; }
.steps { padding-left: 22px; margin: 12px 0; display: grid; gap: 12px; }
.steps li { line-height: 1.5; }
.share-ico { width: 20px; height: 20px; vertical-align: -4px; color: var(--accent); }
#installGuide h2 { margin: 0 0 6px; }

/* ---------- KK phonetics ---------- */
.kk { font-family: "Lucida Sans Unicode", "Arial Unicode MS", "Noto Sans", "Segoe UI", sans-serif; color: var(--muted); letter-spacing: 0.02em; }
.sheet-head .kk { font-size: 17px; margin: 2px 0 2px; color: var(--text); opacity: 0.75; }
.flashcard .kk { font-size: 18px; margin-top: 4px; }
.word-detail .kk { display: block; font-size: 15px; margin-bottom: 4px; }
.word-row .z .kk { font-size: 13px; }

/* Sharing */
.profile-edit .icon-only { flex: 0 0 auto; padding-left: 14px; padding-right: 14px; }
.join-card { display: flex; align-items: center; gap: 12px; margin: 12px 16px 4px; background: var(--tofu-soft); box-shadow: inset 0 0 0 1px var(--tofu); }
.join-card .install-text { display: flex; flex-direction: column; gap: 2px; }
.vocab-demo { text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 3px; }
.join-bar .primary-btn { flex: 1; margin: 0; padding: 11px; }
.join-bar .outline-btn { flex: none; }

/* Reposts, quotes, replies tab */
.act.reposted { color: var(--saved); }
.repost-line { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 600; margin: 0 0 6px 30px; flex-basis: 100%; }
.repost-line svg { width: 14px; height: 14px; }
.post.has-repost { flex-wrap: wrap; }
.avatar.xs { width: 20px; height: 20px; font-size: 11px; }
.quote-card { border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; margin: 8px 0 4px; cursor: pointer; }
.quote-card.missing { cursor: default; }
.quote-head { display: flex; align-items: center; gap: 6px; font-size: 14px; margin-bottom: 4px; }
.quote-head .post-handle { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quote-text { font-size: 14px; line-height: 1.45; color: var(--text); overflow-wrap: anywhere; }
#composerQuote .quote-card { cursor: default; margin-top: 10px; }
.reply-item { padding: 12px 16px 6px; border-bottom: 1px solid var(--line); }
.reply-item .quote-card { margin: 0 0 4px; }
.reply-item .comment { padding: 6px 0 4px; cursor: pointer; }
.profile-tabs { overflow-x: auto; scrollbar-width: none; }
.profile-tabs::-webkit-scrollbar { display: none; }
.profile-tabs .feed-tab { flex: none; padding-left: 14px; padding-right: 14px; white-space: nowrap; }
.repost-sheet { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.sheet-option { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 6px; font-size: 17px; font-weight: 600; border-bottom: 1px solid var(--line); text-align: left; }
.sheet-option svg { width: 22px; height: 22px; }
.sheet-option.danger { color: var(--like); }
.sheet-cancel { width: 100%; margin-top: 14px; }

/* Reporting, legal */
.more-btn { margin-left: auto; color: var(--muted); font-size: 18px; line-height: 1; padding: 0 4px; letter-spacing: 1px; }
.sheet-title { margin: 0 0 4px; font-size: 18px; }
.ob-legal { text-align: center; margin: 10px 0 0; }
