:root[data-theme="light"] {
  --bg: #fafaf7;
  --panel: #ffffff;
  --panel-2: #f7f6f1;
  --ink: #111111;
  --ink-soft: #2a2a2a;
  --muted: #6b7280;
  --line: #e7e5df;
  --line-soft: #f0eee8;
  --chip-bg: #f3f3ee;
  --chip-bg-hover: #ebeae3;
  --chip-bg-active: #111;
  --chip-fg-active: #fff;
  --tag-topic-bg: #eef4ff;
  --tag-topic-fg: #1e3a8a;
  --tag-topic-border: #dbe5ff;
  --tag-bg: #f3f3ee;
  --tag-fg: #4b5563;
  --tag-border: #ececec;
  --accent: #2a3aff;
  --accent-soft: rgba(42, 58, 255, 0.12);
  --unread-dot: #2a3aff;
  --hover-title: #2a3aff;
  --tier-s: #0f5132;
  --tier-a: #1f6feb;
  --tier-b: #6f42c1;
  --tier-c: #92400e;
  --tier-d: #6b7280;
  --selection: #ddebff;
  --shadow: 0 12px 40px rgba(0,0,0,0.10), 0 2px 6px rgba(0,0,0,0.06);
  --reader-bg: #ffffff;
  --reader-prose: #1f1f1f;
}
:root[data-theme="dark"] {
  --bg: #0a0a0a;
  --panel: #141414;
  --panel-2: #181818;
  --ink: #ededed;
  --ink-soft: #d4d4d4;
  --muted: #888888;
  --line: #262626;
  --line-soft: #1c1c1c;
  --chip-bg: #1f1f1f;
  --chip-bg-hover: #2a2a2a;
  --chip-bg-active: #ededed;
  --chip-fg-active: #0a0a0a;
  --tag-topic-bg: #1a2542;
  --tag-topic-fg: #93b4ff;
  --tag-topic-border: #243561;
  --tag-bg: #1f1f1f;
  --tag-fg: #a8a8a8;
  --tag-border: #2a2a2a;
  --accent: #6b8aff;
  --accent-soft: rgba(107, 138, 255, 0.18);
  --unread-dot: #6b8aff;
  --hover-title: #93b4ff;
  --tier-s: #4ade80;
  --tier-a: #60a5fa;
  --tier-b: #c084fc;
  --tier-c: #fbbf24;
  --tier-d: #888;
  --selection: #233054;
  --shadow: 0 14px 48px rgba(0,0,0,0.55), 0 2px 6px rgba(0,0,0,0.4);
  --reader-bg: #141414;
  --reader-prose: #ededed;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); }
body {
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
  transition: background 0.15s ease, color 0.15s ease;
  min-height: 100vh;
  /* iPhone notch / Dynamic Island padding when launched as a PWA */
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
}
/* iOS PWA install hint (only shows when not yet installed) */
.ios-install-hint {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 110; padding: 12px 14px; border-radius: 12px;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); box-shadow: var(--shadow);
  font-size: 13px; display: none; align-items: center; gap: 10px;
}
.ios-install-hint.show { display: flex; }
.ios-install-hint .label { flex: 1; line-height: 1.35; }
.ios-install-hint .label strong { color: var(--accent); }
.ios-install-hint .close {
  background: transparent; border: none; color: var(--muted);
  font-size: 18px; line-height: 1; cursor: pointer; padding: 4px 6px;
}
::selection { background: var(--selection); }
a { color: inherit; text-decoration: none; }
button { font: inherit; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background 0.1s, border-color 0.1s;
}
.btn:hover { background: var(--chip-bg); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.primary:hover { opacity: 0.92; }
.btn.ghost { background: transparent; }
.btn svg { width: 14px; height: 14px; }

.icon-btn {
  background: var(--panel); border: 1px solid var(--line); color: var(--ink);
  width: 34px; height: 34px; border-radius: 8px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0; transition: background 0.12s;
}
.icon-btn:hover { background: var(--chip-bg); }
.icon-btn svg { width: 16px; height: 16px; }

.kbd, kbd {
  display: inline-block; padding: 1px 6px; border: 1px solid var(--line);
  border-bottom-width: 2px; border-radius: 4px; background: var(--panel);
  font: 600 11px ui-monospace, "SF Mono", Menlo, monospace; color: var(--muted);
}

/* ----- topbar ----- */
.topbar {
  position: sticky; top: 0; z-index: 60;
  background: var(--bg); border-bottom: 1px solid var(--line);
  backdrop-filter: saturate(180%) blur(8px);
}
.topbar-inner {
  max-width: 1480px; margin: 0 auto; padding: 0 18px;
  display: flex; align-items: center; gap: 14px; height: 60px;
}
.brand {
  font-weight: 700; letter-spacing: -0.015em; font-size: 17px;
  display: flex; align-items: center; gap: 8px; min-width: 92px;
}
.brand .logo {
  display: inline-block; width: 11px; height: 11px; border-radius: 2px;
  background: var(--ink); transform: rotate(45deg); position: relative;
}
.brand .logo::after {
  content: ""; position: absolute; inset: 2px; background: var(--bg); border-radius: 1px;
}
.search-wrap {
  flex: 1; max-width: 540px;
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 0 10px; height: 36px;
  position: relative;
}
.search-wrap:focus-within { border-color: var(--accent); }
.search-icon { width: 14px; height: 14px; color: var(--muted); flex-shrink: 0; }
#search-input {
  flex: 1; border: none; outline: none; background: transparent; color: var(--ink);
  font-size: 14px; height: 100%;
}
.search-wrap .kbd { display: inline-block; }

.top-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.live-pill {
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line);
  font-size: 12px; color: var(--muted); background: var(--panel);
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.live-dot {
  width: 7px; height: 7px; border-radius: 50%; background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6);
  animation: pulse 2.4s infinite;
}
.live-dot.refreshing { background: #f59e0b; }
.live-dot.error { background: #ef4444; animation: none; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(34,197,94,0.5); }
  70% { box-shadow: 0 0 0 8px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}
.sidebar-toggle { display: none; }

/* ----- topic strip ----- */
.topic-strip {
  position: sticky; top: 60px; z-index: 55;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px;
  padding: 12px 18px;
  overflow-x: auto;
  scrollbar-width: none;
}
.topic-strip::-webkit-scrollbar { display: none; }
.topic-strip-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.18em;
  color: var(--muted); font-weight: 600; flex-shrink: 0;
}
.topic-chips {
  display: flex; gap: 8px; align-items: center; flex-wrap: nowrap;
}
.topic-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px; height: 30px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  cursor: pointer; user-select: none; white-space: nowrap;
  transition: color 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.topic-chip:hover { color: var(--ink); border-color: var(--ink-soft); }
.topic-chip.active {
  color: var(--ink); border-color: var(--ink);
  background: var(--chip-bg);
}
.topic-chip svg { width: 13px; height: 13px; flex-shrink: 0; opacity: 0.85; }
.topic-chip.active svg { opacity: 1; }
@media (max-width: 720px) {
  .topic-strip { padding: 10px 14px; gap: 10px; }
  .topic-chip { padding: 5px 11px; font-size: 10px; }
}

/* ----- layout ----- */
.layout {
  max-width: 1480px; margin: 0 auto; padding: 0 18px;
  display: grid; grid-template-columns: 240px 1fr; gap: 32px;
  align-items: start;
}
.sidebar {
  position: sticky; top: 76px; height: calc(100vh - 92px); overflow-y: auto;
  padding: 24px 0 60px; display: flex; flex-direction: column; gap: 26px;
}
.sidebar-section { display: flex; flex-direction: column; gap: 4px; }
.sidebar-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--muted); font-weight: 600; padding: 0 8px; margin-bottom: 4px;
}
.nav-list { display: flex; flex-direction: column; gap: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 7px; cursor: pointer;
  color: var(--ink-soft); font-size: 14px;
  border: 1px solid transparent;
  transition: background 0.1s;
}
.nav-item:hover { background: var(--chip-bg); }
.nav-item.active { background: var(--chip-bg); color: var(--ink); font-weight: 600; }
.nav-item .count {
  margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 500;
}
.nav-item.active .count { color: var(--accent); font-weight: 700; }
.nav-item .count.zero { color: var(--muted); opacity: 0.55; }
.nav-item.active .count.zero { opacity: 0.85; }
.nav-item .badge {
  margin-left: auto; font-size: 11px; padding: 1px 7px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-weight: 700;
}
.tier-pip {
  display: inline-block; min-width: 18px; padding: 1px 5px; border-radius: 4px;
  text-align: center; font-size: 10px; font-weight: 700; color: #fff;
  letter-spacing: 0.04em;
}
.tier-pip.S { background: var(--tier-s); }
.tier-pip.A { background: var(--tier-a); }
.tier-pip.B { background: var(--tier-b); }
.tier-pip.C { background: var(--tier-c); }
.top-sites { display: flex; flex-direction: column; gap: 2px; padding: 0 8px; }
.top-site {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 0; font-size: 13px; color: var(--ink-soft); cursor: pointer;
}
.top-site:hover { color: var(--accent); }
.top-site .pct {
  font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums;
}

/* ----- main ----- */
.main { padding: 24px 0 80px; min-width: 0; }
.view-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 16px;
}
.view-header h1 {
  font-size: 28px; line-height: 1.15; letter-spacing: -0.02em;
  margin: 0 0 4px; font-weight: 700;
}
.view-sub { color: var(--muted); margin: 0; font-size: 14px; }
.view-actions { display: flex; gap: 8px; }

.filters { padding: 4px 0 6px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 4px 0; }
.filter-row .label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--muted); min-width: 76px;
}
.chip {
  padding: 4px 10px; border-radius: 999px; background: var(--chip-bg);
  color: var(--ink-soft); font-size: 13px; cursor: pointer; user-select: none;
  border: 1px solid transparent; transition: all 0.1s ease;
}
.chip:hover { background: var(--chip-bg-hover); }
.chip.active { background: var(--chip-bg-active); color: var(--chip-fg-active); }

.feed-meta {
  display: flex; align-items: center; justify-content: space-between;
  color: var(--muted); font-size: 13px; padding: 12px 0 10px; gap: 12px; flex-wrap: wrap;
}

/* ----- cards ----- */
.feed-list { display: flex; flex-direction: column; gap: 0; }
.card {
  display: grid; grid-template-columns: 18px 56px 1fr auto; gap: 16px;
  padding: 18px 4px; border-bottom: 1px solid var(--line);
  align-items: start; position: relative; cursor: pointer;
  border-left: 3px solid transparent; padding-left: 8px; margin-left: -10px;
  border-radius: 4px;
}
.card:hover { background: var(--panel-2); }
.card.selected {
  border-left-color: var(--accent); background: var(--panel-2);
}
.card.read { opacity: 0.55; }
.card.read:hover { opacity: 0.82; }
.card .body .title { transition: color 0.1s; }
.card:hover .title { color: var(--hover-title); }

.read-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--unread-dot); margin-top: 8px;
  box-shadow: 0 0 0 3px var(--accent-soft);
  flex-shrink: 0;
}
.read-dot.is-read { background: transparent; box-shadow: none; }

.score { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.score .n { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.score .t {
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em; padding: 1px 7px;
  border-radius: 4px; color: #fff;
}
.t.S { background: var(--tier-s); }
.t.A { background: var(--tier-a); }
.t.B { background: var(--tier-b); }
.t.C { background: var(--tier-c); }
.t.D { background: var(--tier-d); }
:root[data-theme="dark"] .t.S,
:root[data-theme="dark"] .t.A,
:root[data-theme="dark"] .t.B,
:root[data-theme="dark"] .t.C { color: #0a0a0a; }

.card .body { min-width: 0; }
.card .body .meta {
  display: flex; gap: 8px; align-items: center; color: var(--muted);
  font-size: 12px; margin-bottom: 5px; flex-wrap: wrap;
}
.meta .source { font-weight: 600; color: var(--ink); }
.meta .dot-sep { width: 3px; height: 3px; border-radius: 50%; background: var(--muted); opacity: 0.5; }
.meta .eng { color: var(--accent); font-weight: 600; }
.title {
  font-size: 17px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.3;
  margin: 0 0 5px; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.summary { color: var(--ink-soft); font-size: 14px; line-height: 1.55; margin: 0 0 8px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tag {
  font-size: 11px; padding: 2px 8px; border-radius: 4px;
  background: var(--tag-bg); color: var(--tag-fg); border: 1px solid var(--tag-border);
}
.tag.topic { background: var(--tag-topic-bg); color: var(--tag-topic-fg); border-color: var(--tag-topic-border); }
.tag.read-state { background: transparent; border-color: var(--line); color: var(--muted); }
.tag.read-state.unread { color: var(--accent); border-color: var(--accent); }

.right-col {
  text-align: right; color: var(--muted); font-size: 12px; min-width: 110px;
  display: flex; flex-direction: column; align-items: flex-end; gap: 6px;
}
.card-actions {
  display: flex; gap: 4px; opacity: 0; transition: opacity 0.1s;
}
.card:hover .card-actions, .card.selected .card-actions { opacity: 1; }
.card-actions .icon-btn {
  width: 28px; height: 28px;
}
.card-actions .icon-btn svg { width: 13px; height: 13px; }
.icon-btn.is-unread { border-color: var(--accent); color: var(--accent); }
.icon-btn.is-unread:hover { background: var(--accent-soft); }
.icon-btn.is-read { border-color: var(--line); color: var(--muted); opacity: 0.85; }
.icon-btn.is-read:hover { color: var(--ink); border-color: var(--ink-soft); opacity: 1; }
#mark-all-read-btn {
  display: inline-flex; align-items: center; gap: 7px;
  border-color: var(--accent); color: var(--accent);
}
#mark-all-read-btn:hover { background: var(--accent-soft); }
#mark-all-read-btn svg { width: 14px; height: 14px; }

/* ----- Tag editor (in reader drawer) ----- */
.tag-editor {
  max-width: 720px; margin: 0 auto 22px;
  padding: 12px 16px 14px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--line);
}
.tag-editor-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px; gap: 12px;
}
.tag-editor-head .md-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.18em;
  color: var(--muted); font-weight: 700;
}
.tag-editor-head .small { font-size: 11px; }
.tag-chips {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 4px 3px 10px; border-radius: 999px;
  background: var(--tag-topic-bg); color: var(--tag-topic-fg);
  border: 1px solid var(--tag-topic-border);
  font-size: 12px; font-weight: 500;
}
.tag-chip .tag-remove {
  width: 18px; height: 18px; padding: 0; border: none; background: transparent;
  color: var(--tag-topic-fg); opacity: 0.6; cursor: pointer; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; line-height: 1;
}
.tag-chip .tag-remove:hover { opacity: 1; background: rgba(0,0,0,0.08); }
:root[data-theme="dark"] .tag-chip .tag-remove:hover { background: rgba(255,255,255,0.1); }
.tag-input {
  flex: 1; min-width: 130px; max-width: 260px;
  padding: 5px 10px; border: 1px dashed var(--line); border-radius: 999px;
  background: transparent; color: var(--ink); font-size: 13px; outline: none;
  font-family: inherit;
}
.tag-input:focus { border-color: var(--accent); border-style: solid; }
.tag-input::placeholder { color: var(--muted); }

.tag.user-tag {
  background: var(--tag-topic-bg); color: var(--tag-topic-fg);
  border-color: var(--tag-topic-border);
  display: inline-flex; align-items: center; gap: 1px;
}
.tag.user-tag .tag-remove {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; padding: 0; margin-left: 2px;
  background: transparent; border: none; color: inherit;
  cursor: pointer; font-size: 13px; line-height: 1;
  opacity: 0; transition: opacity 0.1s, background 0.1s;
  border-radius: 50%;
}
.card .tag.user-tag:hover .tag-remove,
.tag.user-tag:focus-within .tag-remove { opacity: 0.7; }
.tag.user-tag .tag-remove:hover { opacity: 1; background: rgba(0,0,0,0.08); }
:root[data-theme="dark"] .tag.user-tag .tag-remove:hover { background: rgba(255,255,255,0.1); }

.tag.tag-add {
  background: transparent;
  border: 1px dashed var(--line);
  color: var(--muted);
  cursor: pointer;
  padding: 1px 9px;
  font-size: 11px;
  font-family: inherit;
  transition: color 0.1s, border-color 0.1s, border-style 0.1s, background 0.1s;
}
.tag.tag-add:hover {
  border-color: var(--accent);
  color: var(--accent);
  border-style: solid;
  background: var(--accent-soft);
}
.tag-add-input {
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 1px 7px;
  font-size: 11px;
  outline: none;
  color: var(--ink);
  width: 110px;
  font-family: inherit;
  height: 22px;
}

/* ----- "Your take" (editable summary) ----- */
.take-block {
  max-width: 720px; margin: 0 auto 22px;
  padding: 16px 20px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
}
.take-block.empty { border-left-color: var(--line); background: transparent; }
.take-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 6px;
}
.take-head .md-label {
  font-size: 11px; color: var(--accent); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.18em; margin: 0;
}
.take-block.empty .take-head .md-label { color: var(--muted); }
.take-display p.take-text {
  margin: 0; line-height: 1.55; color: var(--ink-soft); white-space: pre-wrap;
}
.take-display.is-empty p.take-text { color: var(--muted); font-style: italic; }
.take-edit textarea {
  width: 100%; min-height: 130px; resize: vertical;
  background: var(--panel); border: 1px solid var(--line); color: var(--ink);
  border-radius: 8px; padding: 10px 12px; outline: none;
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
}
.take-edit textarea:focus { border-color: var(--accent); }
.take-actions {
  display: flex; gap: 10px; margin-top: 10px; align-items: center;
  flex-wrap: wrap;
}
.take-actions .muted { font-size: 11px; }
#take-hint { margin-right: auto; color: var(--muted); }
#take-hint kbd { padding: 0 5px; font-size: 10px; border-bottom-width: 1px; }
.btn.small { padding: 4px 10px; font-size: 12px; }
@media (max-width: 720px) {
  #take-hint { display: none; }
}

/* ----- reader notes ----- */
.note-section { margin: 8px 0 4px; }
.note-toggle {
  display: inline-flex; align-items: center; gap: 7px;
  background: transparent;
  border: 1px solid #ff5a3c;
  color: #ff5a3c;
  padding: 4px 12px; border-radius: 6px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.note-toggle:hover { background: rgba(255, 90, 60, 0.10); }
.note-toggle svg { width: 12px; height: 12px; transition: transform 0.18s ease; }
.note-toggle.open svg { transform: rotate(180deg); }
.note-toggle.open { background: rgba(255, 90, 60, 0.10); }

.note-body {
  margin-top: 12px; padding: 14px 16px 12px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-left: 3px solid #ff5a3c;
  border-radius: 8px;
  color: var(--ink-soft); font-size: 14px; line-height: 1.6;
}
.note-body p { margin: 0.5em 0; }
.note-body p:first-child { margin-top: 0; }
.note-body p:last-child { margin-bottom: 0; }
.note-body ul { padding-left: 18px; margin: 0.4em 0; }
.note-body li { margin: 4px 0; }
.note-body strong { color: var(--ink); }
.note-body code {
  background: var(--bg); padding: 1px 5px; border-radius: 3px;
  font: 0.92em ui-monospace, "SF Mono", Menlo, monospace;
}
.note-body a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.note-body blockquote {
  border-left: 2px solid var(--line); margin: 0.6em 0; padding: 0 0 0 12px;
  color: var(--muted); font-style: italic;
}
.note-body h3, .note-body h4, .note-body h5 {
  margin: 0.8em 0 0.3em; line-height: 1.3; font-size: 1em; font-weight: 700;
  color: var(--ink);
}
.note-body .md-label,
.reader-note .md-label {
  font-size: 11px; color: #ff7a5c;
  text-transform: uppercase; letter-spacing: 0.18em;
  font-weight: 700; margin: 14px 0 6px;
}
.note-body .md-label:first-child { margin-top: 0; }

.reader-note {
  max-width: 720px; margin: 0 auto 28px;
  padding: 18px 20px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-left: 3px solid #ff5a3c;
}
.reader-note .md-label { color: #ff7a5c; margin-bottom: 8px; }
.reader-note .note-body {
  margin: 0; padding: 0; background: transparent; border: none; border-left: none;
}

.empty, .loading {
  text-align: center; padding: 80px 0; color: var(--muted); font-size: 14px;
}

/* ----- modal ----- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  backdrop-filter: blur(2px); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 14vh 16px;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  width: min(560px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow); padding: 18px;
}
.modal.small { width: min(420px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h2 { margin: 0; font-size: 18px; letter-spacing: -0.01em; }
.modal-row { display: flex; gap: 12px; margin-top: 12px; }
.modal-row label, .modal-row .grow {
  display: flex; flex-direction: column; gap: 4px; flex: 1; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
}
.modal-foot { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.modal-foot .muted { margin-right: auto; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.modal input, .modal select {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--ink);
  border-radius: 8px; padding: 9px 11px; font-size: 14px; outline: none;
  width: 100%; text-transform: none; letter-spacing: 0; font-weight: 400;
}
.modal input:focus, .modal select:focus { border-color: var(--accent); }
#save-url { font-family: ui-monospace, "SF Mono", Menlo, monospace; }

.shortcuts { width: 100%; border-collapse: collapse; }
.shortcuts td { padding: 6px 4px; font-size: 13px; color: var(--ink-soft); }
.shortcuts td:first-child { white-space: nowrap; padding-right: 16px; }

/* ----- reader drawer ----- */
.reader-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.32);
  z-index: 90; backdrop-filter: blur(2px);
}
.reader-backdrop[hidden] { display: none; }
.reader-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(820px, 92vw);
  background: var(--reader-bg); border-left: 1px solid var(--line);
  box-shadow: var(--shadow); z-index: 95;
  display: flex; flex-direction: column;
  animation: slidein 0.22s ease-out;
}
.reader-drawer[hidden] { display: none; }
@keyframes slidein { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.reader-head {
  display: grid; grid-template-columns: auto 1fr auto; gap: 14px; padding: 14px 18px;
  border-bottom: 1px solid var(--line); align-items: center;
}
.reader-meta { min-width: 0; }
.reader-meta .source-line {
  font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center;
  margin-bottom: 2px;
}
.reader-meta .reader-title {
  font-size: 16px; font-weight: 600; letter-spacing: -0.01em;
  color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.reader-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.reader-actions select {
  background: var(--panel); border: 1px solid var(--line); color: var(--ink);
  border-radius: 8px; padding: 6px 8px; font-size: 13px; outline: none;
}
.reader-body {
  flex: 1; overflow-y: auto; padding: 28px clamp(20px, 4vw, 56px) 80px;
  color: var(--reader-prose);
}
.prose { max-width: 720px; margin: 0 auto; line-height: 1.65; font-size: 17px; }
.prose h1, .prose h2, .prose h3 { line-height: 1.25; margin: 1.6em 0 0.5em; }
.prose h1 { font-size: 1.6em; }
.prose h2 { font-size: 1.3em; }
.prose h3 { font-size: 1.12em; }
.prose p { margin: 0.85em 0; }
.prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.prose img { max-width: 100%; height: auto; border-radius: 6px; }
.prose pre {
  background: var(--panel-2); padding: 14px; border-radius: 8px; overflow-x: auto;
  font: 13px ui-monospace, "SF Mono", Menlo, monospace;
}
.prose code {
  background: var(--panel-2); padding: 1px 5px; border-radius: 4px;
  font: 0.92em ui-monospace, "SF Mono", Menlo, monospace;
}
.prose blockquote {
  border-left: 3px solid var(--line); margin: 1em 0; padding: 0.2em 0 0.2em 14px;
  color: var(--muted); font-style: italic;
}
.prose hr { border: none; border-top: 1px solid var(--line); margin: 2em 0; }

.prose-meta {
  max-width: 720px; margin: 0 auto 24px; padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.prose-meta h1 {
  font-size: 28px; line-height: 1.18; letter-spacing: -0.02em; margin: 0 0 10px;
}
.prose-meta .submeta {
  display: flex; gap: 8px; align-items: center; font-size: 13px;
  color: var(--muted); flex-wrap: wrap;
}
.prose-meta .score-pill {
  display: inline-flex; align-items: center; gap: 6px; font-weight: 600;
}

/* ----- toasts ----- */
.toasts {
  position: fixed; bottom: 24px; right: 24px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 10px 14px; border-radius: 10px; background: var(--panel);
  border: 1px solid var(--line); box-shadow: var(--shadow);
  font-size: 13px; max-width: 320px; color: var(--ink);
  animation: toast-in 0.18s ease-out;
}
.toast.error { border-color: #ef4444; color: #ef4444; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ----- bottom tabbar (mobile) ----- */
.mobile-tabbar {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 80;
  background: var(--bg);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom)) 4px;
  backdrop-filter: saturate(180%) blur(12px);
}
.tabbar-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  gap: 2px; padding: 6px 4px; background: transparent; border: none;
  color: var(--muted); cursor: pointer; font: inherit;
  border-radius: 8px; transition: color 0.15s, background 0.15s;
  min-height: 50px;
}
.tabbar-btn.active { color: var(--accent); }
.tabbar-btn:active { background: var(--chip-bg); }
.tabbar-icon {
  position: relative; width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
}
.tabbar-icon svg { width: 22px; height: 22px; }
.tabbar-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.02em;
  text-transform: uppercase;
}
.tabbar-badge {
  position: absolute; top: -3px; right: -8px;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--accent); color: #fff;
  border-radius: 999px; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}

/* ----- tablet (sidebar collapses to drawer) ----- */
@media (max-width: 920px) {
  .layout { grid-template-columns: 1fr; gap: 0; }
  .sidebar {
    position: fixed; left: 0; top: 60px; bottom: 0; width: 280px;
    background: var(--bg); border-right: 1px solid var(--line);
    padding: 18px 14px; z-index: 70; transform: translateX(-100%);
    transition: transform 0.2s ease; height: calc(100vh - 60px);
    overflow-y: auto;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: inline-flex; }
  .topbar-inner { padding: 0 12px; }
  .live-pill { display: none; }
  .search-wrap .kbd { display: none; }
  .main { padding: 18px 0 80px; }
  .top-actions .btn span { display: none; }
}

/* ----- phone ----- */
@media (max-width: 720px) {
  /* Bottom tabbar replaces the sidebar Library section as primary nav */
  .mobile-tabbar { display: flex; }
  .sidebar [data-mobile-hide], .sidebar > .sidebar-section:first-child { display: none; }

  /* Account for tabbar height so content isn't hidden behind it */
  .main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .feed { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

  /* Trim the topbar — flex sizing is deterministic so search can't push
     past the action buttons */
  .topbar-inner { gap: 6px; padding: 0 10px; height: 56px; }
  .brand { font-size: 15px; min-width: auto; flex-shrink: 0; }
  .brand .logo { width: 9px; height: 9px; }
  .live-pill { display: none; }
  .icon-btn#refresh-btn { display: none; }

  /* Search: flexes within the leftover space, fixed lower bound */
  .search-wrap {
    flex: 1 1 0;
    min-width: 0;
    max-width: none;
    height: 36px;
    padding: 0 8px;
    gap: 6px;
  }
  .search-wrap .kbd { display: none; }
  .search-icon { width: 13px; height: 13px; }
  #search-input { font-size: 14px; min-width: 0; }
  #search-input::placeholder { font-size: 13px; }

  /* Action buttons stay at the right and never shrink */
  .top-actions { gap: 4px; flex-shrink: 0; }
  .top-actions .btn { padding: 0; width: 36px; height: 36px; justify-content: center; }
  .top-actions .btn svg { width: 16px; height: 16px; }
  .icon-btn { width: 36px; height: 36px; }
  .icon-btn svg { width: 16px; height: 16px; }
  .sidebar-toggle { width: 36px; height: 36px; }

  /* Hero — used on desktop, hidden on phone */
  .hero { display: none; }

  /* Topic strip — bigger touch targets, snap scroll */
  .topic-strip {
    top: 56px; gap: 10px; padding: 10px 14px;
    scroll-snap-type: x mandatory;
  }
  .topic-strip-label { display: none; }
  .topic-chip { padding: 8px 14px; font-size: 11px; height: 34px; }
  .topic-chip svg { width: 14px; height: 14px; }

  /* View header: compact on phone — sub + action buttons in a single row,
     title shrinks; the bottom tabbar already tells you which location you're in */
  .view-header { gap: 8px; margin-bottom: 8px; align-items: center; }
  .view-header h1 { font-size: 18px; line-height: 1.2; }
  .view-header .view-sub { font-size: 12px; margin-top: 2px; }
  .view-actions { flex-shrink: 0; flex-wrap: nowrap; gap: 6px; }
  .view-actions .btn {
    white-space: nowrap; padding: 7px 10px; font-size: 12px; line-height: 1.2;
  }
  #mark-all-read-btn { padding: 7px 10px; }

  /* Filters: keep labels but shrink them so each row's purpose is clear */
  .filters { padding: 6px 0 8px; }
  .filter-row { padding: 4px 0; gap: 8px; flex-wrap: nowrap; overflow-x: auto;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .filter-row::-webkit-scrollbar { display: none; }
  .filter-row .label {
    display: inline-block; flex-shrink: 0;
    font-size: 10px; min-width: 56px; padding-right: 4px;
    letter-spacing: 0.08em; color: var(--muted);
  }
  .chip { padding: 8px 14px; font-size: 13px; height: 32px;
    display: inline-flex; align-items: center; flex-shrink: 0; }

  /* Cards — vertical stack, no fixed columns, generous tap area */
  .card {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    padding: 16px 4px 14px 4px; margin-left: 0;
    border-left: none;
    gap: 8px;
  }
  .card.selected { border-left: none; }
  .card .read-dot { position: absolute; top: 18px; right: 6px; margin: 0; }
  .card .score {
    grid-column: 1; grid-row: 1;
    flex-direction: row; gap: 8px; align-items: center;
    margin-bottom: -4px;
  }
  .card .score .n { font-size: 16px; font-weight: 700; }
  .card .score .t { padding: 1px 6px; font-size: 9px; }
  .card .body { grid-column: 1; grid-row: 2; }
  .card .right-col {
    grid-column: 1; grid-row: 3;
    flex-direction: row; align-items: center;
    justify-content: flex-start; padding-top: 0;
    min-width: 0; text-align: left;
  }
  .card .right-col > div:first-child { display: none; }
  .card .title { font-size: 17px; -webkit-line-clamp: 3; }
  .card .summary { -webkit-line-clamp: 3; font-size: 14px; }
  .card .meta { font-size: 12px; }
  .card .tags { gap: 5px; }
  .tag { padding: 4px 10px; font-size: 11px; height: 24px; }
  .tag.tag-add { padding: 3px 11px; font-size: 11px; height: 24px; }

  /* Action buttons row — show as a horizontal row at the bottom of each card */
  .card .body::after { content: none; }

  /* Reader drawer as bottom sheet */
  .reader-drawer {
    width: 100% !important; max-width: 100%;
    top: 5vh !important; left: 0 !important; right: 0; bottom: 0;
    border-radius: 18px 18px 0 0; border-left: none;
    animation: slideup 0.22s ease-out;
  }
  @keyframes slideup {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
  }
  .reader-drawer::before {
    content: ""; display: block; position: absolute; left: 50%;
    top: 8px; transform: translateX(-50%);
    width: 36px; height: 4px; border-radius: 2px;
    background: var(--line);
  }
  /* Reader drawer header: stack close+title above the action toolbar */
  .reader-head {
    grid-template-columns: 40px 1fr;
    grid-template-rows: auto auto;
    padding: 26px 12px 10px;
    gap: 6px 10px;
    align-items: center;
  }
  .reader-head > .icon-btn:first-child { grid-column: 1; grid-row: 1; }
  .reader-meta { grid-column: 2; grid-row: 1; min-width: 0; }
  .reader-meta .reader-title { font-size: 15px; line-height: 1.25; }
  .reader-meta .source-line { font-size: 11px; }
  .reader-actions {
    grid-column: 1 / -1; grid-row: 2;
    margin-top: 4px; padding-top: 10px;
    border-top: 1px solid var(--line);
    flex-wrap: nowrap; gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .reader-actions::-webkit-scrollbar { display: none; }
  .reader-actions .icon-btn { width: 40px; height: 40px; flex-shrink: 0; }
  .reader-actions .icon-btn svg { width: 18px; height: 18px; }
  .reader-actions select {
    flex-shrink: 0; padding: 8px 12px; font-size: 13px;
    min-height: 40px; max-width: 130px;
  }
  .reader-body { padding: 20px 18px calc(80px + env(safe-area-inset-bottom)); }
  .prose { font-size: 16px; }

  /* Modals: bottom-sheet style */
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal { border-radius: 18px 18px 0 0; }

  /* iOS install hint — sit above the tabbar */
  .ios-install-hint { bottom: calc(80px + env(safe-area-inset-bottom)); }

  /* Bigger icon buttons for thumbs */
  .icon-btn { width: 38px; height: 38px; }
  .icon-btn svg { width: 17px; height: 17px; }
  .card-actions { opacity: 1; gap: 6px; }
  .card-actions .icon-btn { width: 34px; height: 34px; }
  .card-actions .icon-btn svg { width: 14px; height: 14px; }

  /* Move card actions to a new row visible at all times on mobile */
  .feed-list .card .body { position: relative; }
}
