/* ── App shell ────────────────────────────────────────────────────────────── */

.app-root {
  display: flex;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg-sunken);
  color: var(--fg);
  font-family: var(--font-sans);
}

/* ── Rail ─────────────────────────────────────────────────────────────────── */

.rail {
  width: 52px;
  flex-shrink: 0;
  background: var(--bg-sunken);
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: hidden;
  transition: width 0.18s ease;
}

.rail[data-expanded="true"] {
  width: 200px;
  padding: 12px;
}

/* Brand / pin button */
.rail-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px;
  margin-bottom: 4px;
  cursor: pointer;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
}
.rail-brand:hover { background: var(--bg-hover); }

.rail-glyph {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--fg);
  color: var(--bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  font-style: italic;
  flex-shrink: 0;
}

.rail-name {
  font-weight: 600;
  font-size: 13.5px;
  letter-spacing: -0.01em;
  color: var(--fg);
  white-space: nowrap;
  display: none;
}
.rail[data-expanded="true"] .rail-name { display: block; }

/* Nav groups */
.rail-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.rail-group-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: var(--label-spacing);
  text-transform: var(--label-transform);
  color: var(--fg-subtle);
  padding: 6px 8px 2px;
  white-space: nowrap;
  visibility: hidden; /* occupies space even when collapsed, preventing vertical icon shift */
}
.rail[data-expanded="true"] .rail-group-label { visibility: visible; }

/* Nav items — shared by <a> and <button> */
.rail-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: var(--fg-muted);
  font-size: 12.5px;
  font-family: var(--font-sans);
  text-align: left;
  width: 100%;
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s, color 0.1s;
}
.rail-item:hover { background: var(--bg-hover); color: var(--fg); }
.rail-item[data-active="true"] {
  background: var(--bg-elev);
  color: var(--fg);
  font-weight: 500;
  box-shadow: 0 1px 0 var(--border);
}

.rail-item > svg {
  width: 15px; height: 15px;
  flex-shrink: 0;
}

.rail-item > span {
  display: none;
}
.rail[data-expanded="true"] .rail-item > span {
  display: block;
  flex: 1;
}

/* Collapsed: center the icon — no gap needed with single child */
.rail[data-expanded="false"] .rail-item  { justify-content: center; padding: 7px; gap: 0; }
.rail[data-expanded="false"] .rail-brand { justify-content: center; gap: 0; }
.rail[data-expanded="false"] .rail-user  { justify-content: center; padding: 7px; gap: 0; }

/* Bottom section: sticks to the bottom of the rail */
.rail-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

/* Rail footer: divider + user block */
.rail-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
  flex-shrink: 0;
}

.rail-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.rail-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  flex-shrink: 0;
  display: block;
}

.rail-userblock {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.rail[data-expanded="false"] .rail-userblock { display: none; }

.rail-username {
  font-size: 12px;
  font-weight: 500;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── App content area ─────────────────────────────────────────────────────── */

.app-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}


/* ── List pane ────────────────────────────────────────────────────────────── */

.list-pane {
  width: 380px;
  flex-shrink: 0;
  background: var(--bg-elev);
  display: flex;
  flex-direction: column;
  border-left: var(--border-w) solid var(--border);
  border-right: var(--border-w) solid var(--border);
  overflow: hidden;
}

/* Wide mode: expands to fill available space when there's no detail pane */
.list-pane-wide {
  flex: 1;
  width: auto;
  border-right: none;
}

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 8px;
  flex-shrink: 0;
}

.list-title {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
  min-width: 0;
  flex: 1;
  flex-wrap: wrap;
}

.list-title-filters {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  margin-left: auto;
}

.list-title-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font: inherit;
  font-size: 11px;
  font-weight: 500;
  color: var(--fg-muted);
  background: var(--bg-subtle);
  border: none;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  letter-spacing: 0;
  cursor: pointer;
}
.list-title-tag:hover { color: var(--fg); background: var(--bg-hover); }

.list-count {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--fg-subtle);
  font-weight: 400;
}

.list-tools {
  display: inline-flex;
  gap: 2px;
  align-items: center;
}

/* Shared small icon button */
.icon-btn {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-subtle);
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--fg); }
.icon-btn[data-on] { color: var(--accent); }

.toolbar-sep {
  width: 1px;
  height: 16px;
  background: var(--border);
  margin: 0 4px;
  flex-shrink: 0;
}

/* Search bar */
.list-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  margin: 0 12px 6px;
  background: var(--bg-sunken);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--fg-subtle);
  flex-shrink: 0;
}
.list-search input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font: inherit;
  color: var(--fg);
  font-size: 12.5px;
  padding: 6px 0;
}
.list-search input::placeholder { color: var(--fg-subtle); }
.list-search kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  background: var(--bg-elev);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  color: var(--fg-muted);
}

/* Scrollable item list */
.list-items {
  flex: 1;
  min-height: 0; /* allow flex item to shrink and enable scroll */
  padding: 4px 8px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.list-items::-webkit-scrollbar       { width: 8px; }
.list-items::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }

/* ── List rows ────────────────────────────────────────────────────────────── */

.list-row {
  position: relative;
  padding: var(--pad-y) 12px var(--pad-y) 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-bottom: 1px;
}
.list-row:hover { background: var(--bg-hover); }
.list-row[data-selected="true"] { background: var(--accent-soft); }

/* Unread indicator dot */
.row-indicator {
  position: absolute;
  left: 6px;
  top: 14px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--fg-subtle);
  opacity: 0;
}
.list-row[data-unread="true"] .row-indicator {
  opacity: 1;
  background: var(--accent);
}

.row-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--fg-subtle);
  margin-bottom: 3px;
}
.row-source { color: var(--fg-muted); font-weight: 500; }
.row-date   { font-family: var(--font-mono); font-size: 10.5px; }

.row-title {
  font-family: var(--row-title-family);
  font-size: 13px;
  font-weight: var(--row-title-weight);
  letter-spacing: -0.005em;
  line-height: 1.3;
  margin: 0 0 var(--gap);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.list-row[data-unread="false"] .row-title { color: var(--fg-muted); }

.row-excerpt {
  font-size: 11.5px;
  color: var(--fg-muted);
  margin: 0;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Wide-mode row adjustments (no detail pane) */
.list-pane-wide .list-row     { padding: 12px 16px 14px 22px; }
.list-pane-wide .row-title    { font-size: 14px; -webkit-line-clamp: 1; }
.list-pane-wide .row-excerpt  { font-size: 12.5px; -webkit-line-clamp: 2; }

.row-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  gap: 8px;
}

.row-tags { display: flex; align-items: center; gap: 6px; }
.row-tag {
  font-size: 10.5px;
  color: var(--fg-muted);
  background: var(--bg-sunken);
  padding: 2px 7px;
  border-radius: 999px;
}

.row-readtime { font-family: var(--font-mono); font-size: 10px; color: var(--fg-subtle); }

.row-actions {
  display: inline-flex;
  gap: 1px;
  opacity: 0;
  transition: opacity 0.12s;
}
.list-row:hover .row-actions { opacity: 1; }
.row-actions button {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-subtle);
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  cursor: pointer;
}
.row-actions button:hover           { background: var(--bg-active); color: var(--fg); }
.row-actions button[data-on="true"] { color: var(--accent); }

/* Anchor used as an action button (e.g. feed → inbox link) */
.row-action-link {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-subtle);
  border-radius: var(--radius-sm);
  text-decoration: none;
}
.row-action-link:hover { background: var(--bg-active); color: var(--fg); }

/* Feed fetch-error indicator */
.list-row.feed-error .row-title { color: var(--accent); }

/* Empty state inside list */
.list-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 20px;
  color: var(--fg-subtle);
  font-size: 13px;
  text-align: center;
}
.list-empty p { margin: 0; }

.list-footer {
  padding: 10px 16px;
  border-top: var(--border-w) solid var(--border);
}
.list-footer-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--fg-muted);
  text-decoration: none;
}
.list-footer-link:hover { color: var(--fg); }

/* ── Detail pane ──────────────────────────────────────────────────────────── */

.detail-pane {
  flex: 1;
  min-width: 0;
  min-height: 0; /* flex item: prevent content-size min-height from defeating scroll */
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.detail-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  border-bottom: var(--border-w) solid var(--border);
  flex-shrink: 0;
}

.detail-crumb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--fg-subtle);
}
.detail-crumb-sep { margin: 0 2px; }

.detail-actions { display: inline-flex; gap: 2px; align-items: center; }

.detail-body {
  flex: 1;
  min-height: 0; /* allow flex item to shrink and enable scroll */
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.detail-body::-webkit-scrollbar       { width: 8px; }
.detail-body::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }

.detail-content {
  max-width: 620px;
  margin: 0 auto;
  padding: 48px 32px 80px;
}

.detail-eyebrow {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: var(--label-spacing);
  text-transform: var(--label-transform);
  color: var(--fg-subtle);
  margin-bottom: 14px;
}

.detail-title {
  font-family: var(--font-display);
  font-weight: var(--title-weight);
  font-size: var(--title-size);
  line-height: 1.18;
  letter-spacing: var(--title-spacing);
  margin: 0 0 12px;
  text-wrap: balance;
}

.detail-byline {
  font-size: 12.5px;
  color: var(--fg-muted);
  margin-bottom: 28px;
}
.detail-byline span { color: var(--fg-subtle); margin: 0 4px; }

.detail-lede {
  font-family: var(--font-display);
  font-size: 17px;
  line-height: 1.55;
  color: var(--fg);
  margin: 0 0 18px;
}

.detail-p {
  font-family: var(--font-display);
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--fg-muted);
  margin: 0 0 16px;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: var(--border-w) solid var(--border);
}

.detail-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-muted);
  padding: 2px 8px;
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius-sm);
}

/* ── Annotations section inside bookmark detail ───────────────────────────── */

.bookmark-annotations {
  max-width: 620px;
  margin: 0 auto;
  padding: 0 32px 60px;
}

.bookmark-annotations-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: -0.01em;
  color: var(--fg);
  padding: 20px 0 8px;
  border-top: var(--border-w) solid var(--border);
  margin-bottom: 4px;
}

/* ── Connected bookmarks inside interest detail ────────────────────────────── */

.interest-bookmarks-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.interest-bookmark-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 0;
  text-decoration: none;
  border-bottom: var(--border-w) solid var(--border);
  color: inherit;
}
.interest-bookmark-row:last-child { border-bottom: none; }
.interest-bookmark-row:hover .row-title { color: var(--link); }

.interest-bookmark-row .row-source {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--fg-subtle);
  flex-shrink: 0;
  white-space: nowrap;
}
.interest-bookmark-row .row-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  /* override the default display: none from .row-title in collapsed rail */
  display: block;
}

/* ── Suggestion panel ─────────────────────────────────────────────────────── */

.suggestion-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
}

.suggestion-hint {
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 400;
  color: var(--fg-subtle);
}

.interest-bookmark-suggested {
  align-items: center;
}

.interest-bookmark-suggested a {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}

.score-pill {
  display: inline-flex;
  align-items: baseline;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  padding: 3px 7px;
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  border: var(--border-w) solid var(--border);
  color: var(--fg-subtle);
  min-width: 40px;
  justify-content: center;
  flex-shrink: 0;
}
.score-pill small { font-size: 9px; opacity: 0.6; margin-left: 1px; }
.score-pill[data-tone="high"] {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
}
.score-pill[data-tone="mid"] { color: var(--fg); }

.connect-suggestion {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--fg-subtle);
  font-size: 11.5px;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
}
.connect-suggestion:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
}

/* ── Entry HTML content (raw feed content rendered inside detail pane) ────── */

.entry-html {
  font-family: var(--font-display);
  font-size: 15.5px;
  line-height: 1.65;
  color: var(--fg-muted);
}

.entry-html p        { margin: 0 0 1.1em; }
.entry-html p:first-child {
  font-size: 17px;
  line-height: 1.55;
  color: var(--fg);
}

.entry-html a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.entry-html a:hover { opacity: 0.8; }

/* Hide anchor-only links (footnote back-links, etc.) */
.entry-html a[href*='#'] *  { display: none; }

.entry-html h1,
.entry-html h2,
.entry-html h3,
.entry-html h4,
.entry-html h5 {
  font-family: var(--font-display);
  font-weight: 500;
  color: var(--fg);
  margin: 1.4em 0 0.5em;
  line-height: 1.25;
}
.entry-html h1 { font-size: 1.5em; }
.entry-html h2 { font-size: 1.3em; }
.entry-html h3 { font-size: 1.1em; }
.entry-html h4,
.entry-html h5 { font-size: 1em; font-weight: 600; }

.entry-html img,
.entry-html figure {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
}
.entry-html figure { margin: 1.5em 0; }
.entry-html figcaption {
  font-family: var(--font-sans);
  font-size: 11.5px;
  color: var(--fg-subtle);
  margin-top: 6px;
  text-align: center;
}

.entry-html blockquote {
  border-left: 3px solid var(--border-strong);
  margin: 1.2em 0;
  padding: 0.5em 0 0.5em 1.2em;
  color: var(--fg-muted);
  font-style: italic;
}

.entry-html code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--bg-sunken);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
}
.entry-html pre {
  background: var(--bg-sunken);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  overflow-x: auto;
  margin: 1.2em 0;
}
.entry-html pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 13px;
  line-height: 1.55;
}

.entry-html ul,
.entry-html ol {
  padding-left: 1.4em;
  margin: 0 0 1em;
}
.entry-html li { margin-bottom: 0.3em; }

.entry-html hr {
  border: none;
  border-top: var(--border-w) solid var(--border);
  margin: 2em 0;
}

/* ── Mobile ───────────────────────────────────────────────────────────────── */

@media (max-width: 767px) {

  .rail { display: none; }

  .app-content {
    overflow-y: auto;
    padding-bottom: 90px; /* clear the floating tab bar */
  }

  /* Floating tab bar */
  .m-tabbar {
    position: fixed;
    bottom: 26px;
    left: 12px;
    right: 12px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    background: var(--bg-elev);
    border: var(--border-w) solid var(--border);
    border-radius: var(--radius);
    padding: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    z-index: 100;
  }
  html.theme-dark .m-tabbar {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  }

  .m-tabbar a,
  .m-tabbar button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 6px;
    border-radius: var(--radius-sm);
    color: var(--fg-subtle);
    font-size: 10.5px;
    font-weight: 500;
    font-family: var(--font-sans);
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
  }
  .m-tabbar a[data-active="true"],
  .m-tabbar button[data-active="true"] {
    color: var(--fg);
    background: var(--bg-sunken);
  }

}

/* Hide mobile tab bar on desktop */
@media (min-width: 768px) {
  .m-tabbar { display: none; }
}

/* ── Large desktop: always-expanded rail ─────────────────────────────────── */
/* On wide viewports the rail is permanently open; hover expand/contract only  */
/* kicks in on narrower desktop windows (768px–1279px). Touch/tablet (<768px)  */
/* keeps the collapsed rail via the mobile rules above.                         */
@media (min-width: 1280px) {
  .rail {
    width: 200px;
    padding: 12px;
  }
  .rail .rail-name        { display: block; }
  .rail .rail-group-label { visibility: visible; }
  .rail .rail-item > span { display: block; flex: 1; }
  .rail .rail-userblock   { display: flex; }

  /* Undo collapsed centering that JS applies on mouse-out */
  .rail[data-expanded="false"] .rail-item      { justify-content: flex-start; padding: 6px 8px; gap: 10px; }
  .rail[data-expanded="false"] .rail-brand     { justify-content: flex-start; gap: 10px; }
  .rail[data-expanded="false"] .rail-user      { justify-content: flex-start; padding: 6px 8px; gap: 10px; }
  .rail[data-expanded="false"] .rail-userblock { display: flex; }
}

/* ── Mobile top bar ───────────────────────────────────────────────────────── */

.m-topbar { display: none; }

@media (max-width: 767px) {
  .m-topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 12px; height: 52px; flex-shrink: 0;
    background: var(--bg); border-bottom: var(--border-w) solid var(--border);
    position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  }
  .m-topbar-title {
    font-size: 14px; font-weight: 600; letter-spacing: -0.01em; color: var(--fg);
  }
  .m-topbar-btn {
    width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
    background: none; border: none; cursor: pointer; color: var(--fg-muted); border-radius: var(--radius);
  }
  .m-topbar-btn:hover { background: var(--bg-hover); color: var(--fg); }
  .app-root { padding-top: 52px; }
}

/* ── Mobile hamburger drawer ──────────────────────────────────────────────── */

.m-backdrop {
  position: fixed; inset: 0; z-index: 110;
  background: rgba(20, 15, 10, 0.4);
  backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none;
  transition: opacity 200ms;
}
.m-backdrop.is-open { opacity: 1; pointer-events: auto; }

.m-drawer {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 120;
  width: 84%; max-width: 320px;
  background: var(--bg); border-right: var(--border-w) solid var(--border-strong);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.18);
  display: flex; flex-direction: column;
  transform: translateX(-100%);
  visibility: hidden;
  transition: transform 200ms cubic-bezier(.2, .7, .3, 1), visibility 0s 200ms;
}
.m-drawer.is-open {
  transform: translateX(0); visibility: visible;
  transition: transform 200ms cubic-bezier(.2, .7, .3, 1), visibility 0s 0s;
}

.m-drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 14px; border-bottom: var(--border-w) solid var(--border); flex-shrink: 0;
}
.m-drawer-brand { display: flex; align-items: center; gap: 10px; }
.m-drawer-name  { font-weight: 600; font-size: 14px; color: var(--fg); }

.m-drawer-body {
  flex: 1; overflow-y: auto;
  padding: 14px 12px;
  display: flex; flex-direction: column; gap: 14px;
}
.m-drawer-group { display: flex; flex-direction: column; gap: 1px; }
.m-drawer-glabel {
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: var(--label-spacing); text-transform: var(--label-transform);
  color: var(--fg-subtle); padding: 4px 10px 6px;
}
.m-drawer-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--fg-muted); font-size: 13.5px;
  text-decoration: none; background: none; border: none;
  cursor: pointer; width: 100%; text-align: left; font-family: inherit;
}
.m-drawer-item span { flex: 1; }
.m-drawer-item:hover { background: var(--bg-hover); color: var(--fg); }
.m-drawer-item[data-active="true"] {
  background: var(--bg-elev); color: var(--fg); font-weight: 500;
  box-shadow: 0 1px 0 var(--border);
}
.m-drawer-count { font-family: var(--font-mono); font-size: 11px; color: var(--fg-subtle); }

.m-drawer-foot {
  border-top: var(--border-w) solid var(--border);
  padding: 14px 16px 20px; flex-shrink: 0;
}
.m-drawer-user {
  display: flex; align-items: center; gap: 12px; margin-bottom: 12px;
}
.m-drawer-actions { display: flex; flex-direction: column; gap: 2px; }
.m-drawer-action {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--fg-muted); font-size: 13px;
  text-decoration: none; background: none; border: none;
  cursor: pointer; font-family: inherit; text-align: left; width: 100%;
}
.m-drawer-action:hover { background: var(--bg-hover); color: var(--fg); }

/* ── Auth pages (login / signup) ──────────────────────────────────────────── */

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 20px;
}

.auth-card {
  width: 320px;
  background: var(--bg-elev);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius);
  padding: 28px 28px 24px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}
.auth-app-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--fg);
}

.auth-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--fg);
  margin: 0 0 18px;
}

.auth-error {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 12.5px;
  margin-bottom: 14px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.auth-field label {
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-muted);
}
.auth-field input {
  background: var(--bg-sunken);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font: inherit;
  font-size: 13.5px;
  color: var(--fg);
  outline: none;
  width: 100%;
}
.auth-field input:focus { border-color: var(--border-strong); }

.auth-submit {
  margin-top: 4px;
  padding: 9px;
  background: var(--fg);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
}
.auth-submit:hover { opacity: 0.85; }

.auth-footer {
  margin-top: 16px;
  font-size: 12.5px;
  color: var(--fg-subtle);
  text-align: center;
}
.auth-footer a { color: var(--link); text-decoration: none; }
.auth-footer a:hover { text-decoration: underline; }

/* ── Interest edit form ────────────────────────────────────────────────────── */

.interest-edit-header {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.interest-edit-title {
  flex: 1;
  background: var(--bg-sunken);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  color: var(--fg);
  outline: none;
}
.interest-edit-title:focus { border-color: var(--border-strong); }

.interest-edit-tag {
  width: 120px;
  flex-shrink: 0;
  background: var(--bg-sunken);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font: inherit;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--fg);
  outline: none;
}
.interest-edit-tag:focus { border-color: var(--border-strong); }

/* ── Settings layout ───────────────────────────────────────────────────────── */

.settings-layout {
  display: flex;
  gap: 28px;
  align-items: flex-start;
}

.settings-nav {
  width: 160px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
}

.settings-panels { flex: 1; min-width: 0; }

.settings-section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--fg);
  margin: 0 0 16px;
}

.settings-desc {
  font-size: 13px;
  color: var(--fg-muted);
  margin-bottom: 12px;
}

.settings-form { max-width: 400px; }

/* Appearance picker */
.appearance-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  max-width: 480px;
}
.appearance-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-elev);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin: 0;
}
.appearance-option:hover { border-color: var(--border-strong); }
.appearance-option input[type="radio"] {
  accent-color: var(--fg);
  cursor: pointer;
  flex-shrink: 0;
}
.appearance-option[data-selected="true"] {
  border-color: var(--fg);
  background: var(--bg-hover);
}
.appearance-swatch {
  display: inline-flex;
  gap: 3px;
  flex-shrink: 0;
}
.appearance-swatch span {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid var(--border);
}
.appearance-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--fg);
}

/* ── Admin select controls ────────────────────────────────────────────────── */

.admin-select {
  background: var(--bg-sunken);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  font: inherit;
  font-size: 12px;
  color: var(--fg-muted);
  outline: none;
  cursor: pointer;
}
.admin-select:focus { border-color: var(--border-strong); color: var(--fg); }

/* ── Pagination ───────────────────────────────────────────────────────────── */

.list-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px 8px 8px;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  width: 28px;
  height: 28px;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--fg-muted);
  text-decoration: none;
  background: none;
}
.page-btn:hover { background: var(--bg-hover); color: var(--fg); }
.page-btn-disabled { opacity: 0.3; pointer-events: none; }

.page-info {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-subtle);
  padding: 0 8px;
}

/* ── Briefing ─────────────────────────────────────────────────────────────── */

.briefing-section {
  margin-bottom: 32px;
}

.briefing-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: var(--label-spacing);
  text-transform: var(--label-transform);
  color: var(--fg-subtle);
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: var(--border-w) solid var(--border);
}

.briefing-count {
  font-size: 11px;
  color: var(--fg-subtle);
  letter-spacing: 0;
  text-transform: none;
}

.briefing-section-desc {
  font-size: 12.5px;
  color: var(--fg-subtle);
  margin-bottom: 10px;
  line-height: 1.5;
}

.briefing-group { margin-bottom: 16px; }

.briefing-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.briefing-group-title { font-size: 13px; font-weight: 600; color: var(--fg); }
.briefing-group-link {
  font-size: 11.5px;
  color: var(--link);
  text-decoration: none;
  letter-spacing: 0;
  text-transform: none;
}
.briefing-group-link:hover { text-decoration: underline; }

.briefing-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 7px 0;
  border-bottom: var(--border-w) solid var(--border);
  text-decoration: none;
  color: inherit;
}
.briefing-item:last-child { border-bottom: none; }
.briefing-item:hover .briefing-item-title { color: var(--link); }

.briefing-item-title {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.briefing-item-source {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--fg-subtle);
  flex-shrink: 0;
  white-space: nowrap;
}

.briefing-idle {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--accent);
  flex-shrink: 0;
}

.briefing-overflow {
  display: block;
  padding: 8px 0;
  font-size: 12.5px;
  color: var(--link);
  text-decoration: none;
}
.briefing-overflow:hover { text-decoration: underline; }

.briefing-empty {
  font-size: 13.5px;
  color: var(--fg-subtle);
  line-height: 1.6;
}
.briefing-empty p { margin: 0 0 8px; }

/* ── Dashboard ────────────────────────────────────────────────────────────── */

.dash-stats {
  display: flex;
  gap: 10px;
  margin-bottom: 32px;
}

.dash-stat {
  flex: 1;
  background: var(--bg-elev);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius);
  padding: 16px 12px;
  text-align: center;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.1s;
}
.dash-stat:hover { border-color: var(--border-strong); }

.dash-stat-num {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 500;
  color: var(--fg);
  line-height: 1.1;
}

.dash-stat-label {
  font-size: 11px;
  color: var(--fg-subtle);
  margin-top: 5px;
}

.dash-interest-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: var(--border-w) solid var(--border);
  text-decoration: none;
  color: inherit;
}
.dash-interest-row:last-child { border-bottom: none; }
.dash-interest-row:hover .dash-interest-name { color: var(--link); }

.dash-interest-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dash-interest-name {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--fg);
}

.dash-interest-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-subtle);
  letter-spacing: 0.08em;
}

.dash-interest-excerpt {
  font-size: 11.5px;
  color: var(--fg-subtle);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-interest-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-subtle);
  flex-shrink: 0;
  white-space: nowrap;
}

.dash-cta {
  display: inline-block;
  margin-top: 12px;
  padding: 8px 16px;
  background: var(--fg);
  color: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}
.dash-cta:hover { opacity: 0.85; }

/* ── Welcome page (public) ────────────────────────────────────────────────── */

.welcome-dl dt {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
  margin-top: 14px;
}
.welcome-dl dd {
  font-size: 13.5px;
  color: var(--fg-muted);
  margin-left: 0;
  line-height: 1.55;
}

/* ── Native dialog modal ──────────────────────────────────────────────────── */

dialog.binder-modal {
  padding: 0;
  border: none;
  border-radius: var(--radius);
  background: var(--bg-elev);
  color: var(--fg);
  box-shadow: 0 8px 32px rgba(0,0,0,.18), 0 2px 8px rgba(0,0,0,.10);
  min-width: 320px;
  max-width: min(560px, 92vw);
  width: 100%;
}

dialog.binder-modal::backdrop {
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(2px);
}

.binder-modal-content {
  display: flex;
  flex-direction: column;
}

.binder-modal-content.binder-modal-scrollable .binder-modal-body {
  max-height: 60vh;
  overflow-y: auto;
}

.binder-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 12px;
  border-bottom: var(--border-w) solid var(--border);
}

.binder-modal-title {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
  color: var(--fg);
}

.binder-modal-close {
  background: none;
  border: none;
  font-size: 16px;
  line-height: 1;
  color: var(--fg-subtle);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
}
.binder-modal-close:hover { color: var(--fg); background: var(--bg-hover); }

.binder-modal-body {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.binder-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px 16px;
  border-top: var(--border-w) solid var(--border);
}

/* ── Bootstrap replacement ────────────────────────────────────────────────── */

@keyframes spin { to { transform: rotate(360deg); } }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font: inherit; font-size: 13.5px; font-weight: 500;
  cursor: pointer; text-decoration: none; line-height: 1.4;
  white-space: nowrap;
}
.btn:disabled, .btn.btn-disabled { opacity: 0.4; cursor: default; pointer-events: none; }
.btn-sm { padding: 4px 9px; font-size: 12.5px; border-radius: var(--radius-sm); }
.btn-lg { padding: 9px 18px; font-size: 15px; }
.btn-secondary { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.btn-secondary:hover { opacity: 0.85; }
.btn-transparent { background: transparent; color: var(--fg-muted); border-color: transparent; }
.btn-transparent:hover { background: var(--bg-hover); color: var(--fg); }
.btn-outline-secondary {
  background: transparent; color: var(--fg-muted);
  border-color: var(--border-strong);
}
.btn-outline-secondary:hover { background: var(--bg-hover); color: var(--fg); }
.btn-toolbar { display: flex; flex-wrap: wrap; gap: 6px; }
.btn-group { display: inline-flex; border-radius: var(--radius-sm); overflow: hidden; }
.btn-group > .btn { border-radius: 0; border-right-width: 0; }
.btn-group > .btn:first-child { border-top-left-radius: 5px; border-bottom-left-radius: 5px; }
.btn-group > .btn:last-child { border-top-right-radius: 5px; border-bottom-right-radius: 5px; border-right-width: 1px; }

/* Forms */
.form-control {
  display: block; width: 100%; box-sizing: border-box;
  padding: 6px 10px;
  background: var(--bg-sunken); border: var(--border-w) solid var(--border); border-radius: var(--radius-sm);
  font: inherit; font-size: 13.5px; color: var(--fg); outline: none;
}
.form-control:focus { border-color: var(--border-strong); }
.form-control:disabled { opacity: 0.6; cursor: not-allowed; }
.form-group { margin-bottom: 0; }
.form-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 4px; color: var(--fg-muted); }
.form-text { font-size: 12px; color: var(--fg-subtle); margin-top: 4px; display: block; }
.form-check { display: flex; align-items: flex-start; gap: 8px; padding: 0; }
.form-check-input { margin-top: 3px; flex-shrink: 0; accent-color: var(--fg); cursor: pointer; }
.form-check-label { font-size: 13.5px; cursor: pointer; }

/* Alert */
.alert {
  padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px;
  display: flex; align-items: center; gap: 8px;
  border: 1px solid transparent;
}
.alert-info    { background: var(--bg-hover);    border-color: var(--border);   color: var(--fg-muted); }
.alert-success {
  background: color-mix(in srgb, #22c55e 10%, var(--bg));
  border-color: color-mix(in srgb, #22c55e 28%, transparent);
  color: var(--fg);
}
.alert-danger {
  background: color-mix(in srgb, var(--accent) 10%, var(--bg));
  border-color: color-mix(in srgb, var(--accent) 28%, transparent);
  color: var(--accent);
}

/* Spinner */
.spinner-border {
  display: inline-block; flex-shrink: 0;
  width: 1.25rem; height: 1.25rem;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .65s linear infinite;
}
.spinner-border-sm { width: .875rem; height: .875rem; border-width: 1.5px; }

/* Badge */
.badge {
  display: inline-block; padding: 2px 7px;
  font-size: 11px; font-weight: 600; line-height: 1.4;
  border-radius: var(--radius);
}
.badge-secondary { background: var(--bg-hover); color: var(--fg-muted); }

/* Dropdown */
.dropdown { position: relative; display: inline-flex; }
.dropdown-menu {
  display: none; position: absolute; top: calc(100% + 4px); right: 0; z-index: 200;
  min-width: 168px; padding: 4px 0;
  background: var(--bg-elev); border: var(--border-w) solid var(--border); border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,.12), 0 1px 4px rgba(0,0,0,.06);
  list-style: none; margin: 0;
}
.dropdown-menu.show { display: block; }
.dropdown-menu-end { right: 0; left: auto; }
.dropdown-item {
  display: block; width: 100%; padding: 7px 14px;
  font: inherit; font-size: 13px;
  background: none; border: none; text-align: left;
  cursor: pointer; color: var(--fg); text-decoration: none; white-space: nowrap;
}
.dropdown-item:hover { background: var(--bg-hover); }
.dropdown-header {
  padding: 4px 14px 2px; font-size: 11px; font-weight: 600;
  color: var(--fg-subtle); text-transform: var(--label-transform); letter-spacing: var(--label-spacing);
  margin: 0;
}
.dropdown-divider { border: none; border-top: var(--border-w) solid var(--border); margin: 4px 0; }

/* Settings tabs */
.tab-content > .tab-pane { display: none; }
.tab-content > .tab-pane.active { display: block; }
.list-group { display: flex; flex-direction: column; gap: 1px; }
.list-group-item {
  padding: 8px 12px; border-radius: var(--radius-sm);
  font-size: 13.5px; color: var(--fg-muted); text-decoration: none;
  cursor: pointer; border: none; background: none;
}
.list-group-item:hover { background: var(--bg-hover); color: var(--fg); }
.list-group-item.active { background: var(--bg-hover); color: var(--fg); font-weight: 500; }

/* Utility classes */
.d-flex  { display: flex !important; }
.d-none  { display: none !important; }
.gap-2   { gap: 8px !important; }
.mb-1    { margin-bottom: 4px !important; }
.mb-2    { margin-bottom: 8px !important; }
.mb-3    { margin-bottom: 16px !important; }
.mb-4    { margin-bottom: 24px !important; }
.mt-0    { margin-top: 0 !important; }
.me-2    { margin-right: 8px !important; }
.px-1   { padding-left: 4px !important; padding-right: 4px !important; }
.align-items-center    { align-items: center !important; }
.justify-content-between { justify-content: space-between !important; }
.text-danger    { color: var(--accent) !important; }
.text-reset     { color: inherit !important; }
.bg-warning     { background: color-mix(in srgb, #f59e0b 18%, var(--bg)) !important; }
.font-weight-bold { font-weight: 600 !important; }
