:root {
  --bg: #fbf7f2; --card: #fff; --ink: #2b2420; --muted: #8a7d72; --line: #eee4da;
  --accent: #f08a4b; --accent-soft: #fde7d8; --meme: #e0534a; --meme-soft: #fbe1de;
  --green: #2f9e6e; --green-soft: #def3e9; --blue: #3a7bd5; --blue-soft: #e2edfb;
  --red: #c9563c; --red-soft: #f9e1da; --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.55;
  padding-bottom: calc(68px + env(safe-area-inset-bottom));
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--blue); }

/* header */
header { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 10px 14px 10px; padding-top: max(10px, env(safe-area-inset-top)); border-bottom: 1px solid var(--line); }
.top { display: flex; align-items: center; justify-content: space-between; max-width: 880px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; }
.brand img { width: 26px; height: 26px; }
.days { display: flex; background: #f1e9e1; border-radius: 10px; padding: 2px; }
.days button { border: 0; background: transparent; padding: 4px 10px; border-radius: 8px; font-size: 13px; color: var(--muted); cursor: pointer; }
.days button.on { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.switch { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-width: 880px; margin: 10px auto 0; }
.switch button { border: 2px solid var(--line); background: var(--card); border-radius: 12px; padding: 10px; font-size: 17px; font-weight: 700; cursor: pointer; position: relative; }
.switch button[data-col="cat"].on { border-color: var(--accent); background: var(--accent-soft); }
.switch button[data-col="meme"].on { border-color: var(--meme); background: var(--meme-soft); }
.switch i { font-style: normal; font-size: 12px; font-weight: 700; color: #fff; background: var(--ink); border-radius: 999px; padding: 0 7px; margin-left: 6px; vertical-align: 2px; }
.switch i:empty { display: none; }
body.shares-mode .switch, body.status-mode .switch { display: none; }
body.shares-mode .days, body.status-mode .days { visibility: hidden; }

/* bottom nav */
#tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(255,255,255,.96); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); backdrop-filter: blur(8px); }
#tabs button { border: 0; background: transparent; padding: 7px 0 8px; font-size: 12px; color: var(--muted); cursor: pointer; display: grid; justify-items: center; gap: 1px; }
#tabs button b { font-size: 19px; font-weight: 400; filter: grayscale(1); opacity: .6; }
#tabs button.on { color: var(--ink); font-weight: 600; }
#tabs button.on b { filter: none; opacity: 1; }

main { max-width: 880px; margin: 0 auto; padding: 8px 12px 30px; }
.tab { display: none; }
.tab.on { display: block; }

/* slot groups */
.slot { display: flex; align-items: baseline; gap: 8px; margin: 14px 2px 8px; }
.slot b { font-size: 20px; }
.slot span { color: var(--muted); font-size: 13px; }
.slot .new { color: #fff; background: var(--meme); border-radius: 6px; padding: 0 6px; font-size: 11px; font-weight: 700; }

/* idea card */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.card.done, .card.skip { opacity: .5; }
.card h2 { margin: 0; font-size: 18px; line-height: 1.35; }
.card .sub { color: var(--muted); font-size: 13px; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.badge { font-size: 12px; padding: 2px 9px; border-radius: 999px; background: #f2ece6; color: var(--muted); }
.badge.none { background: var(--green-soft); color: var(--green); font-weight: 600; }
.badge.emerging { background: var(--accent-soft); color: #c0612a; font-weight: 600; }
.badge.saturated { background: var(--red-soft); color: var(--red); }
.row { margin: 6px 0; }
.row b { display: inline-block; min-width: 62px; color: var(--muted); font-weight: 500; font-size: 13px; }
.caption { background: #faf6f1; border: 1px dashed var(--line); border-radius: 10px; padding: 9px 11px; margin: 10px 0; display: flex; gap: 10px; justify-content: space-between; align-items: flex-start; }
.caption span { white-space: pre-wrap; }
.caption button { flex: none; border: 0; background: var(--ink); color: #fff; border-radius: 8px; padding: 4px 10px; cursor: pointer; font-size: 13px; }
.actions { display: flex; gap: 8px; margin-top: 10px; }
.actions button { flex: 1; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 9px; cursor: pointer; }
.actions .done-btn.active { background: var(--green); border-color: var(--green); color: #fff; }
.actions .skip-btn.active { background: #9a8d82; border-color: #9a8d82; color: #fff; }

/* media strip in idea */
.refs { display: flex; gap: 8px; overflow-x: auto; margin: 10px -2px 2px; padding: 0 2px 4px; scroll-snap-type: x mandatory; }
.ref { flex: none; width: 150px; scroll-snap-align: start; font-size: 12px; }
.ref .m { width: 150px; height: 200px; border-radius: 10px; overflow: hidden; background: #efe7df center/cover no-repeat; position: relative; cursor: pointer; }
.ref .m video, .ref .m img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tag { position: absolute; left: 6px; top: 6px; background: rgba(0,0,0,.6); color: #fff; border-radius: 6px; padding: 0 6px; font-size: 11px; z-index: 1; }
.play.small { font-size: 13px; }
.play { position: absolute; inset: 0; display: grid; place-items: center; font-size: 34px; color: #fff; text-shadow: 0 1px 6px rgba(0,0,0,.5); pointer-events: none; }
.ref .meta { color: var(--muted); margin-top: 3px; display: flex; justify-content: space-between; }
.ref .meta a { color: var(--muted); }

/* post grid */
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 12px; }
.filters button { border: 1px solid var(--line); background: var(--card); padding: 5px 12px; border-radius: 999px; cursor: pointer; font-size: 14px; }
.filters button.on { border-color: var(--ink); background: var(--ink); color: #fff; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.post { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.post .m { aspect-ratio: 3/4; background: #efe7df center/cover no-repeat; position: relative; cursor: pointer; }
.post .m video, .post .m img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post .score { position: absolute; right: 6px; top: 6px; background: var(--accent); color: #fff; font-weight: 700; border-radius: 8px; padding: 1px 7px; font-size: 12px; z-index: 1; }
.post .hot { position: absolute; right: 6px; bottom: 6px; background: var(--meme); color: #fff; border-radius: 8px; padding: 1px 7px; font-size: 12px; z-index: 1; }
.post .body { padding: 8px 10px 10px; font-size: 13px; }
.post .txt { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.post .meta { color: var(--muted); font-size: 12px; margin-top: 4px; }
.post .links { display: flex; justify-content: space-between; margin-top: 6px; font-size: 12px; }
.mini { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 2px 8px; cursor: pointer; font-size: 12px; }

/* fullscreen viewer */
#viewer { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.92); display: grid; place-items: center; }
#viewer[hidden] { display: none; }
#viewer .vbox { max-width: 100vw; max-height: 100vh; }
#viewer video, #viewer img { max-width: 100vw; max-height: 92vh; display: block; }

.trends { margin-top: 18px; color: var(--muted); }
.trends summary { cursor: pointer; }
.share-form { display: grid; gap: 8px; margin: 4px 0; }
.share-form input { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--card); }
.share-form button, .primary { border: 0; background: var(--accent); color: #fff; border-radius: 10px; padding: 10px 14px; cursor: pointer; font-weight: 600; }
.primary:disabled { opacity: .6; }
.hint { color: var(--muted); font-size: 13px; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 6px 12px; margin-bottom: 14px; font-size: 14px; }
.kv > div:nth-child(odd) { color: var(--muted); }
.chip { display: inline-flex; gap: 2px; align-items: center; background: #f2ece6; border-radius: 999px; padding: 1px 4px 1px 10px; margin: 2px; font-size: 13px; }
.chip button { border: 0; background: transparent; cursor: pointer; color: var(--muted); }
details.run { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin: 6px 0; }
details.run summary { cursor: pointer; font-size: 14px; }
pre { background: #2b2420; color: #f3e9df; padding: 10px; border-radius: 8px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; margin: 8px 0 2px; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
#toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(140px); background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 999px; transition: transform .25s; font-size: 14px; z-index: 30; }
#toast.show { transform: translateX(-50%) translateY(0); }

/* login */
body.login { display: grid; place-items: center; min-height: 100vh; padding: 0; }
.login-box { display: grid; gap: 12px; justify-items: center; width: min(320px, 90vw); }
.login-box h1 { margin: 0; font-size: 20px; }
.login-box input, .login-box button { width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line); }
.login-box button { background: var(--accent); color: #fff; border: 0; font-weight: 600; cursor: pointer; }
.err { color: var(--red); min-height: 1em; margin: 0; }
