:root {
  --primary: #8B6914;
  --primary-light: #A68A3C;
  --bg: #FFF8EC;
  --card: #fff;
  --text: #3D2E0A;
  --muted: #9B8D6F;
  --success: #5B8C42;
  --radius: 14px;
  --shadow: 0 4px 18px rgba(139, 105, 20, 0.08);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --contact-footer-h: 72px;
  --tabbar-h: 52px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', sans-serif;
  background: var(--bg);
  color: var(--text);
}

body.has-contact-footer.has-tabbar {
  padding-bottom: calc(var(--tabbar-h) + var(--contact-footer-h) + var(--safe-bottom));
}
body.share-page.has-contact-footer {
  padding-bottom: calc(var(--contact-footer-h) + var(--safe-bottom));
}

.app-shell { max-width: 480px; margin: 0 auto; min-height: 100vh; }

.top-hero {
  background: linear-gradient(145deg, #8B6914, #A68A3C);
  color: #fff;
  padding: 18px 16px 24px;
  border-radius: 0 0 22px 22px;
}
.top-hero__eyebrow {
  font-size: 11px;
  background: rgba(255,255,255,.18);
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 8px;
}
.top-hero h1 { font-size: 22px; margin-bottom: 4px; }
.top-hero p { font-size: 13px; opacity: .92; }

.main { padding: 12px 14px 16px; }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
}
.muted { color: var(--muted); font-size: 13px; }
.center { text-align: center; }
.center-note { text-align: center; font-size: 13px; color: var(--muted); margin-top: 8px; }
.center-note.ok { color: var(--success); }
.pad { padding: 24px 0; }

.streak-row { display: flex; align-items: center; gap: 12px; }
.streak-num { font-size: 34px; font-weight: 800; color: var(--primary); line-height: 1; }
.streak-label { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
.sub { font-size: 12px; color: var(--muted); margin-top: 8px; }

.ring-wrap { display: flex; justify-content: center; padding: 8px 0; }
.ring {
  width: 118px; height: 118px; border-radius: 50%;
  background: conic-gradient(var(--success) var(--pct), #EBEDF0 0);
  display: flex; align-items: center; justify-content: center;
}
.ring span {
  width: 88px; height: 88px; border-radius: 50%; background: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; color: var(--primary);
}

.book-scroll { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.book-scroll::-webkit-scrollbar { display: none; }
.book-card {
  flex: 0 0 92px; border: none; background: none; text-align: center; cursor: pointer;
}
.book-card__title { font-size: 12px; font-weight: 600; margin-top: 6px; line-height: 1.3; }

.cover {
  width: 72px; height: 96px; margin: 0 auto;
  background: linear-gradient(145deg, #D4A853, #8B6914);
  border-radius: 8px; color: #fff; font-size: 24px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 10px rgba(139,105,20,.22);
}
.cover--sm { width: 48px; height: 64px; font-size: 16px; margin: 0; flex-shrink: 0; }

.progress { height: 4px; background: #EBEDF0; border-radius: 2px; margin-top: 6px; overflow: hidden; }
.progress__fill { height: 100%; background: var(--success); border-radius: 2px; }

.week-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.week-cell { text-align: center; }
.week-cell__label { font-size: 11px; color: var(--muted); display: block; margin-bottom: 4px; }
.week-cell__block { display: block; height: 28px; border-radius: 6px; margin: 0 auto; width: 100%; max-width: 36px; }
.week-cell__block.tall { height: 48px; }
.week-cell__min { font-size: 10px; color: var(--muted); margin-top: 2px; display: block; }

.feed { list-style: none; }
.feed li { padding: 10px 0; border-bottom: 1px solid #F0E8D8; font-size: 13px; line-height: 1.5; }
.feed li:last-child { border-bottom: none; }
.feed time { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }

.shelf-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.shelf-tab {
  flex: 1; padding: 9px; border: none; border-radius: 999px;
  background: #F5EFE0; color: var(--muted); font-size: 13px; cursor: pointer;
}
.shelf-tab.is-active { background: var(--primary); color: #fff; }

.book-list { display: grid; gap: 10px; }
.book-row {
  display: flex; gap: 12px; align-items: center; width: 100%;
  padding: 10px; border: none; border-radius: 12px; background: #FDF9F2; cursor: pointer; text-align: left;
}
.book-row__title { font-size: 14px; font-weight: 600; }
.book-row__sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tag {
  display: inline-block; margin-top: 6px; font-size: 10px;
  padding: 2px 8px; border-radius: 4px; background: rgba(139,105,20,.12); color: var(--primary);
}

.hero-mini { text-align: center; }
.hero-mini__title { font-size: 13px; color: var(--muted); }
.hero-mini__num { font-size: 42px; font-weight: 800; color: var(--primary); line-height: 1.1; margin: 8px 0 16px; }
.hero-mini__num span { font-size: 16px; color: var(--muted); font-weight: 500; }

.record-list { list-style: none; }
.record-list li { padding: 12px 0; border-bottom: 1px solid #F0E8D8; font-size: 13px; }
.record-list li:last-child { border-bottom: none; }
.record-list p { margin-top: 4px; color: var(--text); }

.podium { display: flex; align-items: flex-end; justify-content: center; gap: 8px; margin: 12px 0 16px; }
.podium__item { flex: 1; text-align: center; max-width: 96px; }
.podium__bar { border-radius: 10px 10px 0 0; padding-top: 8px; font-size: 22px; margin: 0 auto 6px; }
.podium__item.rank-1 .podium__bar { height: 88px; width: 64px; background: linear-gradient(#FFD700,#E6B800); }
.podium__item.rank-2 .podium__bar { height: 68px; width: 56px; background: linear-gradient(#C0C0C0,#A8A8A8); order: -1; }
.podium__item.rank-3 .podium__bar { height: 52px; width: 52px; background: linear-gradient(#CD7F32,#A0622A); }
.podium__name { font-size: 12px; font-weight: 600; }
.podium__score { font-size: 11px; color: var(--muted); }

.rank-list { display: grid; gap: 8px; }
.rank-row { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 10px; background: #FDF9F2; }
.rank-row.is-me { background: rgba(139,105,20,.12); border: 1px solid rgba(139,105,20,.18); }
.rank-row__no { width: 24px; font-weight: 700; color: var(--primary); }
.rank-row__name { font-size: 14px; font-weight: 600; }
.rank-row__sub { font-size: 11px; color: var(--muted); }

.profile-card { text-align: center; }
.avatar {
  width: 68px; height: 68px; border-radius: 50%; margin: 0 auto 8px;
  background: linear-gradient(135deg, #D4A853, #8B6914);
  display: flex; align-items: center; justify-content: center; font-size: 30px;
}
.level-pill {
  display: inline-block; margin-top: 8px; padding: 4px 14px; border-radius: 999px;
  background: var(--primary); color: #fff; font-size: 12px;
}
.profile-actions { display: flex; gap: 8px; margin-top: 14px; justify-content: center; flex-wrap: wrap; }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.stat-grid strong { display: block; font-size: 22px; color: var(--primary); }
.stat-grid span { font-size: 11px; color: var(--muted); }
.stat-grid--wide { grid-template-columns: repeat(2, 1fr); }

.badge-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.badge {
  text-align: center; padding: 12px 6px; border-radius: 10px; background: #F5EFE0; opacity: .45;
}
.badge.is-on { opacity: 1; background: #FDF9F2; box-shadow: inset 0 0 0 1px rgba(139,105,20,.15); }
.badge span { font-size: 26px; display: block; }
.badge small { font-size: 10px; color: var(--muted); }

.btn {
  border: none; border-radius: 12px; padding: 12px 16px; font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn--primary { background: var(--primary); color: #fff; width: 100%; }
.btn--outline { background: #fff; color: var(--primary); border: 1px solid rgba(139,105,20,.25); font-size: 13px; }
.ghost-btn, .link-btn {
  border: none; background: none; color: var(--primary); font-size: 13px; cursor: pointer; width: 100%; padding: 10px;
}

.tabbar {
  position: fixed; bottom: calc(var(--contact-footer-h) + var(--safe-bottom)); left: 0; right: 0; max-width: 480px; margin: 0 auto;
  display: flex; background: #fff; border-top: 1px solid rgba(139,105,20,.1);
  z-index: 90; height: var(--tabbar-h);
}
.tabbar__btn {
  flex: 1; border: none; background: none; padding: 8px 4px 10px;
  font-size: 11px; color: var(--muted); cursor: pointer;
}
.tabbar__btn.is-active { color: var(--primary); font-weight: 600; }
.tabbar__btn em { display: block; font-style: normal; font-size: 20px; margin-bottom: 2px; }

.fab {
  position: fixed;
  bottom: calc(var(--tabbar-h) + var(--contact-footer-h) + 12px + var(--safe-bottom));
  right: 16px;
  width: 54px; height: 54px; border-radius: 50%; border: none;
  background: linear-gradient(135deg, #8B6914, #A68A3C); color: #fff; font-size: 22px;
  box-shadow: 0 6px 18px rgba(139,105,20,.35); cursor: pointer; z-index: 40;
}
@media (min-width: 481px) { .fab { right: calc(50% - 240px + 16px); } }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: none; align-items: flex-end; z-index: 200; }
.modal.is-open { display: flex; }
.modal__panel {
  width: 100%; max-width: 480px; margin: 0 auto;
  background: #fff; border-radius: 20px 20px 0 0; padding: 20px 16px calc(20px + var(--safe-bottom));
}
.modal__panel h3 { margin-bottom: 14px; font-size: 18px; }
.form-row { margin-bottom: 12px; }
.form-row label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.form-row select, .form-row input, .form-row textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #E8DFC8; border-radius: 8px; background: #FDF9F2; font-size: 14px;
}
.form-row textarea { min-height: 72px; resize: vertical; }

#subview[hidden] { display: none !important; }
#subview {
  position: fixed; inset: 0; z-index: 120; background: var(--bg);
  max-width: 480px; margin: 0 auto; overflow-y: auto;
  padding-bottom: calc(var(--tabbar-h) + var(--contact-footer-h) + var(--safe-bottom));
}
.subhead {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  background: var(--primary); color: #fff; position: sticky; top: 0; z-index: 1;
}
.subhead button { border: none; background: rgba(255,255,255,.15); color: #fff; padding: 6px 10px; border-radius: 8px; cursor: pointer; }
.subbody { padding: 12px 14px 40px; }
.book-hero { display: flex; gap: 14px; align-items: flex-start; }
.book-hero h2 { font-size: 18px; margin-bottom: 4px; }
blockquote { margin: 8px 0; padding: 10px; background: #FDF9F2; border-radius: 8px; font-size: 13px; line-height: 1.5; }

.stat-hero { text-align: center; }
.stat-hero h2 { font-size: 40px; color: var(--primary); margin-top: 6px; }
.stat-hero h2 small { font-size: 16px; color: var(--muted); }

.contact-footer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 100;
  padding: 6px 12px calc(6px + var(--safe-bottom));
  background: rgba(255,255,255,.96);
  border-top: 1px solid rgba(139,105,20,.12);
  box-shadow: 0 -2px 10px rgba(139,105,20,.06);
  backdrop-filter: blur(8px);
}
.contact-footer__btns {
  display: flex; gap: 6px; justify-content: center; align-items: center; flex-wrap: wrap;
}
.contact-footer__cta, .contact-footer__btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 6px 12px; border-radius: 999px; font-size: 12px; font-weight: 600;
  text-decoration: none; white-space: nowrap;
}
.contact-footer__cta { background: #c41e1e; color: #fff; border: none; }
.contact-footer__btn {
  background: #fff; color: var(--text); border: 1px solid rgba(139,105,20,.18); cursor: pointer;
}
.contact-footer__brand { margin: 4px 0 0; text-align: center; font-size: 10px; color: var(--muted); }

.toast {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%);
  background: rgba(0,0,0,.78); color: #fff; padding: 12px 20px; border-radius: 8px;
  font-size: 14px; z-index: 300; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.toast.show { opacity: 1; }

.share-page { min-height: 100vh; background: var(--bg); }

.share-card {
  max-width: 480px; margin: 0 auto;
  padding: 20px 16px calc(var(--contact-footer-h) + 20px + var(--safe-bottom));
}
.share-card__eyebrow {
  text-align: center; font-size: 12px; color: var(--primary); font-weight: 600; margin-bottom: 16px;
}
.share-hero {
  display: flex; gap: 14px; align-items: center;
  background: var(--card); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); margin-bottom: 14px;
}
.share-hero__cover {
  width: 72px; height: 96px; flex-shrink: 0; border-radius: 8px;
  background: linear-gradient(145deg, #D4A853, #8B6914); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; font-weight: 700;
}
.share-hero__meta { flex: 1; min-width: 0; text-align: left; }
.share-hero__meta h1 { font-size: 20px; margin-bottom: 4px; }
.share-card__tagline { font-size: 13px; color: var(--primary); margin-bottom: 4px; }
.share-card__desc { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.share-book-line { font-size: 12px; color: var(--text); }

.share-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px;
}
.share-stat {
  background: var(--card); border-radius: 10px; padding: 10px 6px; text-align: center;
  box-shadow: var(--shadow);
}
.share-stat strong { display: block; font-size: 18px; color: var(--primary); line-height: 1.2; }
.share-stat span { font-size: 10px; color: var(--muted); }

.share-qr { display: block; margin: 0 auto 6px; border-radius: 8px; background: #fff; padding: 6px; box-shadow: var(--shadow); }
.share-qr-hint { text-align: center; font-size: 11px; color: var(--muted); margin-bottom: 16px; }

.btn--full { width: 100%; display: block; text-align: center; margin-bottom: 10px; text-decoration: none; }
.btn--outline {
  background: #fff; color: var(--primary); border: 1px solid rgba(139,105,20,.25);
}

.share-poster-panel {
  margin-top: 20px; padding-top: 20px; border-top: 1px dashed rgba(139,105,20,.2);
}
.share-poster-panel h2 { font-size: 16px; margin-bottom: 6px; text-align: center; }
.share-poster-hint { font-size: 12px; color: var(--muted); text-align: center; margin-bottom: 12px; }
.share-layouts { display: flex; gap: 8px; margin-bottom: 12px; }
.layout-btn {
  flex: 1; padding: 10px; border-radius: 10px; border: 1px solid rgba(139,105,20,.2);
  background: #FDF9F2; font-size: 13px; cursor: pointer; color: var(--text);
}
.layout-btn.is-active { background: var(--primary); color: #fff; border-color: var(--primary); }
.poster-wrap { margin: 12px 0; }

/* ── P1 ── */
.tag--gold { background: rgba(212,168,83,.25); color: #6B4F0A; }
.tag--p1 { font-size: 10px; background: rgba(91,140,66,.15); color: var(--success); }

.card--flat { padding: 0; overflow: hidden; }
.challenge-teaser {
  width: 100%; border: none; background: linear-gradient(135deg, #FDF9F2, #FFF8EC);
  padding: 16px; text-align: left; cursor: pointer;
}
.challenge-teaser__top { display: flex; justify-content: space-between; margin-bottom: 8px; }
.challenge-teaser strong { display: block; margin-bottom: 8px; font-size: 15px; }
.progress--lg { height: 8px; border-radius: 4px; margin: 8px 0; }

.inline-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.btn--sm { padding: 8px 12px; font-size: 13px; flex: 1; min-width: 120px; }

.feed-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid #F0E8D8; }
.feed-item:last-child { border-bottom: none; }
.feed-item__body { flex: 1; font-size: 13px; line-height: 1.5; }
.feed-item time { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; }

.like-btn {
  border: 1px solid rgba(139,105,20,.15); background: #fff; border-radius: 999px;
  padding: 4px 10px; font-size: 12px; cursor: pointer; white-space: nowrap;
}
.like-btn.is-liked { background: rgba(255,105,105,.12); border-color: rgba(255,80,80,.25); }
.like-btn--sm { padding: 2px 8px; font-size: 11px; }

.rank-row { display: flex; gap: 10px; align-items: center; }
.rank-row__main { flex: 1; min-width: 0; }

.review-card { padding: 12px 0; border-bottom: 1px solid #F0E8D8; }
.review-card:last-child { border-bottom: none; }
.review-card__head { margin-bottom: 6px; }
.review-card__actions { display: flex; gap: 10px; margin-top: 8px; align-items: center; }
.comments { margin-top: 10px; padding-left: 8px; border-left: 2px solid #F0E8D8; }
.comment { font-size: 13px; margin-bottom: 8px; line-height: 1.5; }
.comment.reply { margin-left: 12px; color: var(--muted); font-size: 12px; }

.bingo-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.bingo-cell {
  aspect-ratio: 1; border: 1px dashed rgba(139,105,20,.25); border-radius: 8px;
  background: #FDF9F2; font-size: 10px; padding: 4px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
}
.bingo-cell.is-done { background: rgba(91,140,66,.15); border-style: solid; border-color: var(--success); }
.bingo-cell span { line-height: 1.2; margin-top: 2px; }

.challenge-card__nums { display: flex; align-items: baseline; gap: 6px; margin-bottom: 8px; }
.challenge-card__nums strong { font-size: 28px; color: var(--primary); }

.p1-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.p1-tile {
  border: 1px solid rgba(139,105,20,.12); background: #FDF9F2; border-radius: 12px;
  padding: 16px 10px; font-size: 22px; cursor: pointer;
}
.p1-tile span { display: block; font-size: 12px; color: var(--text); margin-top: 6px; }
.p1-tile--link { display: block; text-align: center; text-decoration: none; color: inherit; }

.year-heat { display: flex; gap: 3px; overflow-x: auto; padding-bottom: 4px; }
.year-heat__col { display: flex; flex-direction: column; gap: 3px; }
.year-heat__cell { width: 10px; height: 10px; border-radius: 2px; display: block; }

.timer-overlay {
  position: fixed; inset: 0; z-index: 250; background: rgba(61,46,10,.92);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.timer-overlay[hidden] { display: none !important; }
.timer-overlay__inner { width: 100%; max-width: 360px; text-align: center; color: #fff; position: relative; }
.timer-close { position: absolute; top: -8px; right: 0; border: none; background: rgba(255,255,255,.15); color: #fff; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; }
.timer-label { font-size: 14px; opacity: .8; margin-bottom: 16px; }
.timer-breathe {
  width: 200px; height: 200px; margin: 0 auto 24px; border-radius: 50%;
  background: radial-gradient(circle, rgba(212,168,83,.35) 0%, rgba(139,105,20,.15) 70%);
  display: flex; align-items: center; justify-content: center;
  font-size: 42px; font-weight: 700; font-variant-numeric: tabular-nums;
  transition: transform 4s ease-in-out, box-shadow 4s ease-in-out;
}
.timer-breathe.is-running { animation: breathe 4s ease-in-out infinite; }
@keyframes breathe {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(212,168,83,.4); }
  50% { transform: scale(1.06); box-shadow: 0 0 40px 10px rgba(212,168,83,.25); }
}
.timer-presets { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 16px; }
.preset-btn {
  border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.08); color: #fff;
  padding: 8px 14px; border-radius: 999px; cursor: pointer; font-size: 13px;
}
.preset-btn.is-active { background: var(--primary-light); border-color: #fff; }
.timer-book-select {
  width: 100%; margin-bottom: 16px; padding: 10px; border-radius: 10px; border: none; font-size: 14px;
}
.timer-actions { display: grid; gap: 8px; }

.modal--poster { align-items: center; padding: 16px; }
.modal--poster.is-open { display: flex; }
.modal__panel--wide { border-radius: 16px; max-height: 90vh; overflow-y: auto; }
