:root {
  color-scheme: light dark;
  --bg: #f3f4f6;
  --panel: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --danger: #b91c1c;
  --bar: rgba(255,255,255,.94);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f16;
    --panel: #131a24;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --line: #263241;
    --accent: #60a5fa;
    --danger: #f87171;
    --bar: rgba(11,15,22,.94);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: -apple-system,BlinkMacSystemFont,"Helvetica Neue","Yu Gothic UI","Yu Gothic",sans-serif; }
body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
button, input, select { font: inherit; }
button { color: inherit; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  min-height: calc(58px + env(safe-area-inset-top));
  padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bar); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line);
}
.app-title { font-weight: 800; font-size: 19px; line-height: 1.1; }
.app-subtitle { color: var(--muted); font-size: 11px; margin-top: 3px; }
.icon-button {
  width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel); font-size: 24px;
}
.content { max-width: 780px; margin: 0 auto; padding: 12px; }
.tabbar {
  position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
  height: calc(64px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(5,1fr);
  background: var(--bar); backdrop-filter: blur(16px); border-top: 1px solid var(--line);
}
.tab { border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); }
.tab span { font-size: 20px; line-height: 1; }
.tab small { font-size: 10px; }
.tab.active { color: var(--accent); font-weight: 700; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; margin-bottom: 10px; }
.section-title { font-size: 17px; font-weight: 800; margin: 4px 2px 10px; }
.toolbar { display: flex; gap: 8px; margin-bottom: 10px; overflow-x: auto; }
.pill { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 8px 12px; white-space: nowrap; }
.pill.active { background: var(--accent); color: white; border-color: var(--accent); }
.thread-row { width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); padding: 12px; background: var(--panel); }
.thread-row:last-child { border-bottom: 0; }
.thread-title { font-weight: 700; line-height: 1.45; overflow-wrap: anywhere; }
.thread-meta { margin-top: 6px; color: var(--muted); font-size: 12px; display: flex; gap: 10px; flex-wrap: wrap; }
.thread-head { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.back { flex: 0 0 auto; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); padding: 8px 10px; }
.thread-heading { font-weight: 800; font-size: 16px; line-height: 1.45; }
.favorite { margin-left: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); padding: 8px 10px; }
.favorite.on { color: #eab308; }
.post { padding: 12px; border-bottom: 1px solid var(--line); background: var(--panel); }
.post:last-child { border-bottom: 0; }
.post-head { color: var(--muted); font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.post-number { color: var(--accent); font-weight: 800; margin-right: 7px; }
.post-body { margin-top: 7px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.anchor { border: 0; padding: 0; background: transparent; color: var(--accent); text-decoration: underline; }
.external-link { color: var(--accent); text-decoration: underline; word-break: break-all; }
.form { padding: 12px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-weight: 700; font-size: 13px; margin-bottom: 6px; }
.input { width: 100%; border: 1px solid var(--line); background: var(--bg); color: var(--text); border-radius: 10px; padding: 11px 12px; min-height: 44px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.primary { width: 100%; border: 0; border-radius: 11px; background: var(--accent); color: white; font-weight: 800; padding: 12px; min-height: 46px; }
.secondary { width: 100%; border: 1px solid var(--line); border-radius: 11px; background: var(--panel); padding: 11px; }
.danger { color: var(--danger); }
.empty, .loading, .error { padding: 28px 16px; text-align: center; color: var(--muted); }
.error { color: var(--danger); }
.setting { padding: 13px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.setting:last-child { border-bottom: 0; }
.setting-text strong { display: block; }
.setting-text small { display: block; color: var(--muted); margin-top: 3px; line-height: 1.4; }
.switch { width: 22px; height: 22px; }
.toast {
  position: fixed; z-index: 50; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom));
  transform: translateX(-50%); max-width: min(90vw,480px);
  background: #111827; color: #fff; padding: 10px 14px; border-radius: 10px; font-size: 13px;
  box-shadow: 0 6px 30px rgba(0,0,0,.25);
}
.note { color: var(--muted); font-size: 12px; line-height: 1.55; margin: 8px 2px 14px; }
mark { padding: 0; background: #fde68a; color: #111827; }
