:root {
  --bg: #F4F2EF; --card: #FFFFFF; --ink: #1B1A19; --muted: #6E6A65; --line: #E6E2DC; --soft: #EFEBE6;
  --accent: #F2602B; --accent-ink: #FFFFFF; --accent-soft: #FDE6DC; --ok: #1E9E5A; --danger: #D23C3C;
  --radius: 18px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  color-scheme: light;
}
html[data-app="gf"] { --accent: #E0457B; --accent-soft: #FBE1EA; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121110; --card: #1D1C1A; --ink: #F3F0EC; --muted: #A39E97; --line: #2E2C29; --soft: #262422;
    --accent-soft: #3A2219; color-scheme: dark;
  }
  html[data-app="gf"]:not([data-theme="light"]) { --accent-soft: #3A1B27; }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased; min-height: 100dvh;
  padding: env(safe-area-inset-top) 0 calc(76px + env(safe-area-inset-bottom));
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
.hidden { display: none !important; }

/* ---------- header and tabs ---------- */
header.top {
  position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  display: flex; align-items: center; justify-content: space-between; padding: 12px 16px;
}
header.top h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.iconbtn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--card); box-shadow: var(--shadow); font-size: 18px; }
nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
nav.tabs button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); padding: 4px 0; position: relative; }
nav.tabs button .ic { font-size: 22px; line-height: 1; filter: grayscale(1); opacity: .7; }
nav.tabs button[aria-selected="true"] { color: var(--accent); font-weight: 600; }
nav.tabs button[aria-selected="true"] .ic { filter: none; opacity: 1; }
nav.tabs .dot { position: absolute; top: 2px; left: calc(50% + 8px); width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

main { max-width: 560px; margin: 0 auto; padding: 4px 16px 16px; }
section.tab { display: none; }
section.tab.on { display: block; }

/* ---------- cards ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.card h2 { margin: 0 0 10px; font-size: 15px; color: var(--muted); font-weight: 600; letter-spacing: .01em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px; border-radius: 14px; font-weight: 600; background: var(--soft); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.block { width: 100%; }
.btn.small { min-height: 34px; padding: 0 12px; border-radius: 10px; font-size: 14px; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; }
.btn:active:not(:disabled) { transform: scale(.98); }

input.field, textarea.field, select.field {
  width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: 12px 14px; outline: none;
}
input.field:focus, textarea.field:focus { border-color: var(--accent); }
label.lbl { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 6px; }

.seg { display: flex; background: var(--soft); border-radius: 12px; padding: 3px; }
.seg button { flex: 1; padding: 7px 0; border-radius: 9px; font-size: 14px; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 12px; border-radius: 999px; background: var(--soft); font-size: 14px; }
.chip[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; outline: 2px solid var(--accent); }

/* ---------- today ---------- */
.ringwrap { display: grid; place-items: center; position: relative; margin: 6px auto 4px; width: 220px; height: 220px; }
.ringwrap svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ringwrap .track { stroke: var(--soft); }
.ringwrap .fill { stroke: var(--accent); transition: stroke-dashoffset .6s cubic-bezier(.2,.8,.2,1); }
.ringwrap .center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ringwrap .big { font-size: 56px; font-weight: 800; letter-spacing: -.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.ringwrap .of { color: var(--muted); font-size: 15px; margin-top: 4px; }
.status { text-align: center; font-weight: 600; margin: 4px 0 14px; }
.quick { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 12px; }
.quick button { min-height: 52px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 17px; }
.quick button:active { transform: scale(.96); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; gap: 4px; }
.stats b { display: block; font-size: 26px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stats span { font-size: 12px; color: var(--muted); }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.x { width: 30px; height: 30px; border-radius: 50%; background: var(--soft); color: var(--muted); font-size: 16px; }

.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 4px; }
.heat i { aspect-ratio: 1; border-radius: 4px; background: var(--soft); display: block; }
.heat i.p { background: color-mix(in srgb, var(--accent) calc(var(--p) * 70% + 15%), var(--soft)); }
.heat i.d { background: var(--accent); }
.heat i.t { outline: 2px solid var(--ink); outline-offset: 1px; }
.heat i.f { visibility: hidden; }
.legend { display: flex; gap: 6px; align-items: center; justify-content: flex-end; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; background: var(--soft); }

/* ---------- rewards ---------- */
.reward { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.reward:first-child { border-top: 0; }
.reward .em { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; font-size: 26px; background: var(--soft); flex: none; }
.reward.unlocked .em { background: var(--accent-soft); }
.reward.locked .em { filter: grayscale(.8); opacity: .7; }
.reward .t { font-weight: 600; }
.bar { height: 6px; border-radius: 3px; background: var(--soft); overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--soft); color: var(--muted); }
.tag.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.tag.hot { background: var(--accent-soft); color: var(--accent); }

/* ---------- videos ---------- */
.vid { margin-bottom: 14px; }
.vid video { width: 100%; max-height: 70vh; border-radius: 14px; background: #000; display: block; }
.vid .meta { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.heart { font-size: 22px; display: inline-flex; align-items: center; gap: 4px; }
.heart b { font-size: 15px; }
.progress { height: 10px; border-radius: 5px; background: var(--soft); overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* ---------- messages ---------- */
.thread { display: flex; flex-direction: column-reverse; gap: 6px; }
.bubble { max-width: 80%; padding: 9px 13px; border-radius: 18px; background: var(--soft); align-self: flex-start; word-wrap: break-word; white-space: pre-wrap; }
.bubble.mine { background: var(--accent); color: var(--accent-ink); align-self: flex-end; }
.bubble time { display: block; font-size: 11px; opacity: .7; margin-top: 2px; }
.compose { display: flex; gap: 8px; margin-top: 12px; }

/* ---------- overlays ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0;
  transition: all .25s; z-index: 30; max-width: calc(100% - 32px); text-align: center; pointer-events: none;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.4); display: flex; align-items: flex-end; justify-content: center; }
.sheet > div {
  background: var(--card); width: 100%; max-width: 560px; border-radius: 22px 22px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  max-height: 90dvh; overflow: auto; animation: up .25s cubic-bezier(.2,.8,.2,1);
}
.sheet h3 { margin: 0 0 12px; font-size: 20px; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.celebrate { text-align: center; padding: 10px 0; }
.celebrate .boom { font-size: 72px; animation: pop .6s cubic-bezier(.2,1.6,.4,1); }
@keyframes pop { from { transform: scale(.2); } }
.confetti { position: fixed; top: -40px; z-index: 40; font-size: 26px; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }

/* ---------- sign in ---------- */
.login { min-height: 80dvh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 380px; text-align: center; padding: 28px 20px; }
.login .logo { font-size: 56px; }
.login h1 { margin: 6px 0 4px; }
.err { color: var(--danger); font-size: 14px; min-height: 20px; margin: 8px 0 0; }
.banner { background: var(--accent-soft); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; }
.banner b { color: var(--accent); }
