:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --text: #14171f;
  --muted: #5b6372;
  --border: #dfe3ea;
  --accent: #0b6e4f;
  --accent-text: #ffffff;
  --accent-soft: #e3f3ec;
  --warn-soft: #fff6e0;
  --warn-border: #f0d48a;
  --error: #b42318;
  --error-soft: #fdecea;
  --focus: #2563eb;
  --liked: #c2185b;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1218; --surface: #171b23; --text: #e8ebf1; --muted: #a2aab8;
    --border: #2b313d; --accent: #3ccf91; --accent-text: #08130e; --accent-soft: #15291f;
    --warn-soft: #2a2414; --warn-border: #5c4c1f; --error: #ff8a80; --error-soft: #3a1714;
    --focus: #7aa2ff; --liked: #ff6fa5;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1218; --surface: #171b23; --text: #e8ebf1; --muted: #a2aab8;
  --border: #2b313d; --accent: #3ccf91; --accent-text: #08130e; --accent-soft: #15291f;
  --warn-soft: #2a2414; --warn-border: #5c4c1f; --error: #ff8a80; --error-soft: #3a1714;
  --focus: #7aa2ff; --liked: #ff6fa5;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

.wrap { max-width: 860px; margin: 0 auto; padding: 0 16px; }
.wrap.narrow { max-width: 480px; }

.topbar { border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 10; }
.topbar .wrap { display: flex; align-items: center; gap: 12px; min-height: 58px; flex-wrap: wrap; }
.brand { font-weight: 800; font-size: 1.1rem; text-decoration: none; color: var(--text); margin-right: auto; }
.brand span { color: var(--accent); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a, .nav button { font: inherit; font-size: 0.93rem; padding: 7px 11px; border-radius: 8px; text-decoration: none; color: var(--muted); background: none; border: 0; cursor: pointer; }
.nav a[aria-current="page"], .nav a:hover, .nav button:hover { color: var(--text); background: var(--bg); }

main { padding: 28px 0 56px; }
h1 { font-size: 1.7rem; letter-spacing: -0.01em; margin: 0 0 6px; }
.lead { color: var(--muted); margin: 0 0 22px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 22px; }
.stack > * + * { margin-top: 14px; }

.field { margin-bottom: 14px; }
label.lbl { display: block; font-weight: 600; font-size: 0.93rem; margin-bottom: 6px; }
.opt { font-weight: 400; color: var(--muted); }
input[type="email"], input[type="password"], input[type="text"], input[type="url"], input[type="date"], select, textarea {
  width: 100%; padding: 10px 12px; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 9px;
}
textarea { min-height: 110px; resize: vertical; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .row { grid-template-columns: 1fr; } }
.hint { font-size: 0.84rem; color: var(--muted); margin-top: 4px; }

.check { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 10px; font-size: 0.92rem; }
.check input { margin-top: 4px; width: 18px; height: 18px; flex: none; accent-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.chips label { display: flex; gap: 6px; align-items: center; font-size: 0.9rem; }
.chips input { accent-color: var(--accent); }

fieldset { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin: 0 0 14px; }
legend { font-weight: 700; padding: 0 6px; }
.group-title { font-size: 0.76rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 6px 0 8px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; font: inherit; font-weight: 700; border-radius: 10px; border: 1px solid transparent; cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-danger { background: var(--surface); color: var(--error); border-color: var(--border); }
.btn-small { padding: 6px 11px; font-size: 0.86rem; font-weight: 600; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: progress; }

.msg { border-radius: 10px; padding: 10px 14px; font-size: 0.92rem; margin: 12px 0; }
.msg.error { background: var(--error-soft); color: var(--error); }
.msg.ok { background: var(--accent-soft); color: var(--text); }
.msg.info { background: var(--warn-soft); border: 1px solid var(--warn-border); }

.notice { background: var(--warn-soft); border: 1px solid var(--warn-border); border-radius: 10px; padding: 10px 14px; font-size: 0.88rem; }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.tabs button { font: inherit; font-weight: 600; padding: 10px 14px; background: none; border: 0; border-bottom: 3px solid transparent; color: var(--muted); cursor: pointer; }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }

.toolbar { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.seg button { font: inherit; font-size: 0.88rem; padding: 7px 12px; border: 0; background: var(--surface); color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--text); font-weight: 600; }

.item { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px; margin-bottom: 14px; }
.item h3 { margin: 6px 0 6px; font-size: 1.1rem; line-height: 1.35; }
.item .body { white-space: pre-wrap; margin: 0 0 10px; }
.meta { font-size: 0.82rem; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tag { display: inline-block; font-size: 0.74rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--text); }
.tag.unverified { background: var(--warn-soft); border: 1px solid var(--warn-border); }
.tag.hidden { background: var(--error-soft); color: var(--error); }
.source { font-size: 0.9rem; margin: 0 0 10px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; border-top: 1px solid var(--border); padding-top: 10px; }
.like[aria-pressed="true"] { color: var(--liked); border-color: var(--liked); }

.comments { margin-top: 12px; border-top: 1px dashed var(--border); padding-top: 12px; }
.comment { padding: 8px 0; border-bottom: 1px solid var(--border); }
.comment:last-of-type { border-bottom: 0; }
.comment .who { font-weight: 600; font-size: 0.88rem; }
.comment .text { white-space: pre-wrap; font-size: 0.95rem; margin: 2px 0 4px; }
.comment-form { display: flex; gap: 8px; margin-top: 10px; }
.comment-form textarea { min-height: 44px; height: 44px; }

.empty { text-align: center; color: var(--muted); padding: 36px 16px; border: 1px dashed var(--border); border-radius: 14px; }

dialog { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); padding: 22px; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); }
dialog::backdrop { background: rgba(0, 0, 0, 0.5); }

footer { border-top: 1px solid var(--border); padding: 22px 0 36px; font-size: 0.84rem; color: var(--muted); }

.filters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; flex: 1; min-width: 0; }
@media (max-width: 600px) { .filters { grid-template-columns: 1fr; } }

/* Bottom tab bar (logged-in pages) */
body.has-tabbar { padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center; gap: 4px;
  background: var(--surface); border-top: 1px solid var(--border); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
.tabbar a { flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; border-radius: 10px;
  text-decoration: none; color: var(--muted); font-size: 0.74rem; font-weight: 600; }
.tabbar a svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
.tabbar a:hover { color: var(--text); }
.seg a[aria-current="page"] { background: var(--accent-soft); color: var(--text); }
.seg a { color: var(--muted); background: var(--surface); text-decoration: none; }

/* ---------- familiar app patterns ---------- */
.nav.appbar-icons { gap: 2px; }
.icon-link { position: relative; display: inline-flex; width: 40px; height: 40px; align-items: center; justify-content: center; border-radius: 50%; color: var(--text); }
.icon-link:hover { background: var(--bg); }
.icon-link svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.badge { position: absolute; top: 3px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #e5383b; color: #fff;
  font-size: 0.7rem; font-weight: 800; display: grid; place-items: center; border: 2px solid var(--surface); }
.chips-row { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; margin-bottom: 6px; scrollbar-width: none; }
.chips-row::-webkit-scrollbar { display: none; }
.chip { flex: none; font: inherit; font-size: 0.88rem; font-weight: 600; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.card-head .who { flex: 1; min-width: 0; line-height: 1.25; }
.card-head .who b { display: block; font-size: 0.95rem; }
.card-head .who small { color: var(--muted); font-size: 0.8rem; }
.avatar-sm { width: 38px; height: 38px; border-radius: 50%; color: #fff; display: grid; place-items: center; font-weight: 800; flex: none; }
.new-dot { display: inline-block; font-size: 0.7rem; font-weight: 800; color: #fff; background: #e5383b; border-radius: 999px; padding: 2px 7px; margin-left: 6px; vertical-align: 2px; }
.icon-actions { display: flex; align-items: center; gap: 4px; border-top: 1px solid var(--border); padding-top: 6px; margin-top: 6px; }
.icon-btn { display: inline-flex; align-items: center; gap: 5px; font: inherit; font-size: 0.9rem; font-weight: 600; color: var(--muted);
  background: none; border: 0; padding: 8px 10px; border-radius: 999px; cursor: pointer; min-height: 40px; }
.icon-btn:hover { background: var(--bg); color: var(--text); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn[aria-pressed="true"].like-btn { color: var(--liked); }
.icon-btn[aria-pressed="true"].like-btn svg { fill: currentColor; }
.icon-btn[aria-pressed="true"].save-btn { color: var(--accent); }
.icon-btn[aria-pressed="true"].save-btn svg { fill: currentColor; }
.icon-actions .spacer { flex: 1; }
.more { position: relative; }
.more summary { list-style: none; cursor: pointer; padding: 6px 10px; border-radius: 999px; color: var(--muted); font-size: 1.2rem; line-height: 1; }
.more summary::-webkit-details-marker { display: none; }
.more[open] summary { background: var(--bg); }
.more .menu-pop { position: absolute; right: 0; top: 100%; z-index: 5; background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18); min-width: 170px; padding: 6px; }
.more .menu-pop button, .more .menu-pop a { display: block; width: 100%; text-align: left; font: inherit; background: none; border: 0; padding: 9px 10px; border-radius: 8px; cursor: pointer; color: var(--text); text-decoration: none; }
.more .menu-pop button:hover, .more .menu-pop a:hover { background: var(--bg); }
.heart-pop { position: absolute; left: 50%; top: 40%; transform: translate(-50%,-50%) scale(0.4); font-size: 64px; opacity: 0; pointer-events: none; transition: transform .35s, opacity .35s; }
.heart-pop.show { opacity: 1; transform: translate(-50%,-50%) scale(1); }
.item { position: relative; }
.fab { position: fixed; right: 18px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 25; width: 58px; height: 58px; border-radius: 18px; border: 0;
  background: var(--accent); color: var(--accent-text); box-shadow: 0 6px 18px rgba(0,0,0,0.25); cursor: pointer; display: grid; place-items: center; }
.fab svg { width: 28px; height: 28px; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; fill: none; }
.toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; z-index: 40;
  background: #1f2329; color: #fff; border-radius: 10px; padding: 12px 16px; display: flex; gap: 18px; align-items: center; font-size: 0.93rem;
  box-shadow: 0 6px 20px rgba(0,0,0,0.3); transition: transform .25s, opacity .25s; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast button { background: none; border: 0; color: #7fe0b5; font: inherit; font-weight: 800; cursor: pointer; padding: 0; }
.skel .skel-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.skel-circle { width: 38px; height: 38px; border-radius: 50%; }
.skel-line { display: block; height: 12px; border-radius: 6px; margin-bottom: 9px; }
.skel-circle, .skel-line { background: linear-gradient(90deg, var(--border) 25%, var(--bg) 50%, var(--border) 75%); background-size: 200% 100%; animation: skel 1.2s infinite; }
@keyframes skel { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.ptr { height: 0; overflow: hidden; text-align: center; font-size: 0.85rem; color: var(--muted); display: flex; align-items: flex-end; justify-content: center; transition: height .2s; }
.list-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 8px; border-bottom: 1px solid var(--border); text-decoration: none; color: inherit; }
.list-row:last-child { border-bottom: 0; }
.list-row.unread { background: var(--accent-soft); border-radius: 10px; }
.list-row .txt { flex: 1; min-width: 0; }
.list-row .txt b { display: block; }
.list-row .txt small { color: var(--muted); }
.searchbar { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 4px 6px 4px 14px; margin-bottom: 14px; }
.searchbar input { flex: 1; border: 0; background: transparent; padding: 10px 0; font: inherit; color: var(--text); outline: none; }

.body.clamp { display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.see-more { background: none; border: 0; padding: 0; margin: -4px 0 10px; font: inherit; font-weight: 700; color: var(--muted); cursor: pointer; }
.see-more:hover { color: var(--text); }

.shortcuts { display: flex; gap: 14px; overflow-x: auto; padding: 4px 2px 14px; margin: 0 0 4px; scrollbar-width: none; }
.shortcuts::-webkit-scrollbar { display: none; }
.shortcuts a { flex: none; width: 64px; display: flex; flex-direction: column; align-items: center; gap: 6px; text-decoration: none; color: var(--text); font-size: 0.74rem; font-weight: 600; text-align: center; }
.sc-icon { width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; font-size: 1.6rem; box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
/* Sponsored cards in the feed */
.item.sponsored { border-color: color-mix(in srgb, var(--border) 60%, #b26a00); }
.item.sponsored .who small { font-weight: 600; }
.sponsor-cta { display: inline-block; text-decoration: none; }

/* Home: "Coming up" strip of changes starting soon */
.coming-up { margin: 0 0 16px; }
.coming-up h2 { font-size: 1rem; margin: 0 0 8px; }
.cu-item { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); text-decoration: none; margin-bottom: 8px; }
.cu-date { flex: none; width: 46px; text-align: center; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-size: 0.75rem; text-transform: uppercase; padding: 4px 0; line-height: 1.1; }
.cu-date b { display: block; font-size: 1.2rem; }
.cu-text { display: flex; flex-direction: column; font-weight: 600; line-height: 1.3; }
.cu-text small { font-weight: 400; color: var(--muted); margin-top: 2px; }
