/* linkbox — one stylesheet for all pages.
   Theme: Settings → Appearance. "System" follows the device; Light/Dark set data-theme on <html> (rendered by the server). */

:root {
  --bg: #f6f6f8;
  --surface: #ffffff;
  --surface-2: #f0f0f3;
  --text: #18181b;
  --muted: #6b6b76;
  --line: #e4e4e9;
  --accent: #a16207;
  --accent-fill: #facc15;
  --on-accent: #1c1917;
  --accent-soft: #fef6c7;
  --dot: #eab308;
  --danger: #dc2626;
  --ok: #16a34a;
  --mark: #fde68a;
  --remind: #0369a1;
  --remind-bg: color-mix(in srgb, #0284c7 14%, transparent);
  --shadow: 0 1px 2px rgb(0 0 0 / .04), 0 4px 16px rgb(0 0 0 / .06);
  --shadow-lg: 0 8px 32px rgb(0 0 0 / .14);
  --ph-bg: 92%;
  --ph-fg: 82%;
  --ph-ink: 28%;
  --chars: 68;          /* characters per line in the reader (Text menu) */
  --reader-scale: 1.125; /* article text size in rem, kept in step with --reader-size by app.js */
  --reader-width: calc(var(--chars) * 1ch * var(--reader-scale));
  --reader-size: 1.125rem;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --reader-font: var(--sans);
  color-scheme: light;
}

/* Dark: when the device prefers it (unless Light was chosen), or when Dark was chosen. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0e11;
    --surface: #17171b;
    --surface-2: #222228;
    --text: #ececf1;
    --muted: #9d9daa;
    --line: #2a2a31;
    --accent: #facc15;
    --accent-soft: #3a3110;
    --dot: #facc15;
    --danger: #f87171;
    --ok: #4ade80;
    --mark: #854d0e;
    --remind: #7dd3fc;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 4px 16px rgb(0 0 0 / .3);
    --shadow-lg: 0 8px 32px rgb(0 0 0 / .5);
    --ph-bg: 16%;
    --ph-fg: 30%;
    --ph-ink: 88%;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e0e11;
  --surface: #17171b;
  --surface-2: #222228;
  --text: #ececf1;
  --muted: #9d9daa;
  --line: #2a2a31;
  --accent: #facc15;
  --accent-soft: #3a3110;
  --dot: #facc15;
  --danger: #f87171;
  --ok: #4ade80;
  --mark: #854d0e;
  --remind: #7dd3fc;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 4px 16px rgb(0 0 0 / .3);
  --shadow-lg: 0 8px 32px rgb(0 0 0 / .5);
  --ph-bg: 16%;
  --ph-fg: 30%;
  --ph-ink: 88%;
  color-scheme: dark;
}

[data-font="serif"] { --reader-font: Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif; }

* { box-sizing: border-box; }
/* Anything the app hides (removed links, filtered tags) must stay hidden even if its own rule sets display. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
h1, h2, h3 { letter-spacing: -.01em; }
button { font: inherit; }
details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }

input, textarea {
  font: inherit; color: inherit; width: 100%;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.i.big { width: 40px; height: 40px; }
.i.logo { color: var(--accent-fill); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.hint { color: var(--muted); font-size: .86rem; margin: 0; }
kbd { font: 600 .72rem ui-monospace, monospace; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; color: var(--muted); }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 2px; }

/* ------------------------------------------------------------ buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 14px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-weight: 550; font-size: .9rem; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn .i { width: 17px; height: 17px; }
.btn.primary { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { height: 30px; padding: 0 10px; font-size: .82rem; border-radius: 8px; }
.btn.large { height: 46px; padding: 0 22px; font-size: 1rem; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--accent); }
.btn.ghost:hover { background: var(--accent-soft); }
.btn[data-danger] { color: var(--danger); }

.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0; flex: none;
  border-radius: 10px; border: 0; background: transparent; color: var(--muted); cursor: pointer; text-decoration: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.small { width: 32px; height: 32px; border-radius: 8px; }
.icon-btn.small .i { width: 17px; height: 17px; }
.icon-btn.text { width: auto; min-width: 38px; padding: 0 8px; font-weight: 650; font-size: .9rem; }

/* ------------------------------------------------------------ app shell */

.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100dvh; }
.main { min-width: 0; }

.sidebar {
  position: sticky; top: 0; height: 100dvh; overflow: hidden; display: flex; flex-direction: column;
  padding: 14px 10px; background: var(--surface); border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 16px; color: var(--text); text-decoration: none; font-weight: 750; font-size: 1.12rem; }
.brand .logo { width: 28px; height: 28px; }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px;
  color: var(--text); text-decoration: none; font-size: .92rem; min-width: 0;
}
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item .i { width: 18px; height: 18px; color: var(--muted); }
.nav-item.active .i, .unread-nav .i { color: var(--accent); }
.nav-item .count { margin-left: auto; color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
.side-label { font-size: .72rem; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 18px 10px 6px; }
.hash { color: var(--muted); width: 18px; text-align: center; flex: none; }
.tag-item > span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Only the tag list scrolls; the filters above and Dashboard / Tags / Settings below always stay visible. */
.sidebar > .brand, .sidebar > .nav, .sidebar > .side-label { flex: none; }
.sidebar > .tags-nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.side-foot { flex: none; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.connector > summary { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; font-size: .92rem; }
.connector > summary:hover { background: var(--surface-2); }
.connector > summary .i { width: 18px; height: 18px; color: var(--muted); }
.connector p { font-size: .8rem; color: var(--muted); margin: 6px 10px; }
.connector input { font-size: .75rem; margin: 0 10px; width: calc(100% - 20px); }
.backdrop { display: none; }

.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 24px;
  background: var(--bg); border-bottom: 1px solid var(--line); /* solid: iPad Safari can drop blurred sticky bars */
}
.search {
  flex: 1 1 160px; max-width: 640px; display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 10px 0 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search .i { width: 18px; height: 18px; color: var(--muted); }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; padding: 0; box-shadow: none; }
.search input::-webkit-search-cancel-button { cursor: pointer; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
/* Menu, search and Add stay together; when the bar wraps, the view controls start a row of their own at the
   left instead of floating right with a gap before them. */
.topbar > .search { order: 1; }
.topbar > .add-menu { order: 2; }
.topbar > .toolbar { order: 3; }
.segmented { display: flex; align-items: stretch; height: 38px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.segmented a { display: inline-flex; align-items: center; gap: 6px; padding: 0 11px; color: var(--muted); text-decoration: none; font-size: .85rem; font-weight: 550; }
.segmented a + a { border-left: 1px solid var(--line); }
.segmented a:hover { color: var(--text); background: var(--surface-2); }
.segmented a.on { background: var(--accent-soft); color: var(--accent); }
.segmented .i { width: 17px; height: 17px; }
.seg-label { display: flex; align-items: center; padding: 0 8px 0 11px; font-size: .78rem; color: var(--muted); border-right: 1px solid var(--line); }
.select-field { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 4px 0 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--muted); font-size: .8rem; }
.select-field select { height: 100%; border: 0; background: transparent; color: var(--text); font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; }
.toolbar:not([data-group="date"]) .sort-for[data-for="date"],
.toolbar:not([data-group="site"]) .sort-for[data-for="site"],
.toolbar:not([data-group="tag"]) .sort-for[data-for="tag"] { display: none; }
/* Tag editor: removable pills, + opens a picker of existing tags (or creates a new one). */
.tag-editor { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px; min-height: 44px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-weight: 400; }
.tag-pill { display: inline-flex; align-items: center; gap: 2px; height: 30px; padding: 0 2px 0 11px; border-radius: 999px;
  background: var(--accent-soft); color: var(--text); font-size: .88rem; }
.tag-pill button { display: grid; place-items: center; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%;
  background: transparent; color: var(--muted); font-size: 1.1rem; line-height: 1; cursor: pointer; }
.tag-pill button:hover { background: var(--surface-2); color: var(--text); }
.tag-add { width: 30px; height: 30px; padding: 0; border: 1px dashed var(--line); border-radius: 50%; background: transparent;
  color: var(--muted); font-size: 1.1rem; cursor: pointer; }
.tag-add:hover { border-color: var(--accent); color: var(--accent); }
.tag-picker { flex: 1 1 100%; display: flex; flex-direction: column; gap: 6px; }
.tag-picker input { width: 100%; }
.tag-suggest { display: flex; flex-direction: column; max-height: 220px; overflow-y: auto; }
.tag-suggest .sg-item { padding: 7px 10px; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .9rem; }
.tag-editor { cursor: text; }

.connector-list { display: flex; flex-direction: column; gap: 14px; margin: 4px 0 10px; }
.connector-url { display: flex; flex-direction: column; gap: 6px; }
.selecting [data-select-mode] { background: var(--accent-soft); color: var(--accent); }
.add-menu { position: relative; }
.popover {
  position: absolute; top: calc(100% + 8px); z-index: 30; display: flex; flex-direction: column; gap: 10px; padding: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg);
}
.add-menu .popover { right: 0; width: min(420px, calc(100vw - 24px)); }
.popover-label { font-size: .75rem; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.add-menu label { font-weight: 600; font-size: .9rem; }

.results { padding: 18px 24px 140px; max-width: 1440px; }

@media (max-width: 899px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 50; width: min(300px, 86vw);
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg);
  }
  .nav-open .sidebar { transform: none; }
  .nav-open .backdrop { display: block; position: fixed; inset: 0; z-index: 40; background: rgb(0 0 0 / .4); }
  /* Row 1: menu, search, Add. Row 2: view/group controls in one sideways-scrolling strip. */
  .topbar { padding: 10px 12px; gap: 8px; }
  .search { flex: 1 1 0; order: 1; max-width: none; }
  .add-menu { order: 2; }
  .toolbar { order: 3; width: 100%; margin-left: 0; gap: 6px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .toolbar > * { flex: none; }
  .toolbar .btn, .segmented, .select-field { height: 34px; }
  .segmented a { padding: 0 9px; }
  .segmented .i { display: none; }
  .toolbar [data-select-mode] .i { display: none; }
  .results { padding: 12px 12px 160px; }
  .desktop-only { display: none; }
}
@media (min-width: 900px) {
  .mobile-only { display: none; }
  .sidebar-collapsed .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar-collapsed .sidebar { display: none; }
}

/* ------------------------------------------------------------ results */

.heading { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 4px 0 18px; }
.heading h1 { font-size: 1.5rem; margin: 0; }
.heading .hint { flex-basis: 100%; }
.heading .hash { width: auto; }
.rename form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.rename input { width: 180px; height: 32px; padding: 0 10px; }
.rename .hint { flex-basis: 100%; }

.day { margin-bottom: 30px; }
.day-label { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: .78rem; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.day-label .count { font-weight: 500; }

.batch { margin: 12px 0; padding: 2px 12px 12px; border: 1px dashed var(--line); border-radius: 16px; }
.batch > summary { display: flex; align-items: center; gap: 8px; padding: 8px 0; font-size: .88rem; }
.batch > summary .i { width: 18px; height: 18px; color: var(--accent); }
.batch-title { font-weight: 650; }
.batch-meta { color: var(--muted); }
.batch > summary .btn { margin-left: auto; }
.batch:not([open]) { padding-bottom: 2px; }
.batch > summary::before {
  content: ""; flex: none; width: 7px; height: 7px; margin: 0 4px 0 2px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform .15s;
}
.batch[open] > summary::before { transform: rotate(45deg); }

.toast {
  display: flex; align-items: center; gap: 10px; width: fit-content; max-width: 100%; margin-bottom: 16px; padding: 8px 8px 8px 14px;
  border-radius: 12px; background: var(--text); color: var(--bg); font-size: .9rem;
}
.toast .i { width: 18px; height: 18px; }
.toast .btn { background: transparent; color: inherit; border-color: color-mix(in srgb, var(--bg) 35%, transparent); }

.empty { text-align: center; color: var(--muted); padding: 72px 16px; }
.empty .i { color: var(--accent); opacity: .7; }
.empty h2 { color: var(--text); font-size: 1.15rem; margin: 12px 0 4px; }
.empty p { margin: 0; }
.pager { display: flex; justify-content: center; gap: 10px; margin: 28px 0; }

/* ------------------------------------------------------------ items (shared) */

.item { position: relative; }
.cover { display: block; overflow: hidden; background: hsl(var(--hue) 55% var(--ph-bg)); }
.cover > img { display: block; width: 100%; height: 100%; object-fit: cover; }
.placeholder { display: grid; place-items: center; height: 100%; }
.ph-icon { width: 44px; height: 44px; border-radius: 12px; object-fit: contain; }
.letter { display: inline-grid; place-items: center; font-weight: 750; background: hsl(var(--hue) 50% var(--ph-fg)); color: hsl(var(--hue) 45% var(--ph-ink)); }
.ph-icon.letter { font-size: 1.3rem; }
.body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.meta { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--muted); font-size: .78rem; }
.meta .site { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta time, .meta .reading-time { white-space: nowrap; }
/* Phones: saved / read / reading time don't fit beside the site on one line, so the line wraps; the ⋯ button
   stays in the top right corner instead of wrapping onto a line of its own. */
@media (max-width: 599px) {
  .meta { flex-wrap: wrap; row-gap: 2px; position: relative; padding-right: 30px; }
  .meta .site { max-width: 45vw; }
  .meta .more, .item.unread .meta .more { position: absolute; top: -5px; right: -6px; margin: 0; }
}
.favicon { width: 16px; height: 16px; border-radius: 4px; flex: none; object-fit: contain; }
.favicon.letter { font-size: .6rem; }
.title { margin: 0; font-size: 1rem; line-height: 1.35; font-weight: 600; overflow-wrap: anywhere; }
.title a { color: var(--text); text-decoration: none; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.title a:hover { color: var(--accent); }
.item.unread .title { font-weight: 700; }
.unread-dot { display: none; width: 8px; height: 8px; margin-left: auto; border-radius: 50%; background: var(--dot); flex: none; }
.item.unread .unread-dot { display: block; }
.summary, .snippet {
  margin: 0; color: var(--muted); font-size: .86rem; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: .74rem; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); text-decoration: none; }
.chip:hover { background: var(--accent-soft); color: var(--accent); }
.badge { display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px; border-radius: 999px; font-size: .72rem; font-weight: 600; white-space: nowrap; }
.badge .i { width: 12px; height: 12px; }
.badge.pending { background: var(--accent-soft); color: var(--accent); }
.badge.error { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.btn .short { display: none; }
.item.leaving { opacity: 0; transform: scale(.97); transition: opacity .18s, transform .18s; }
.pick { display: none; position: absolute; top: 10px; left: 10px; z-index: 2; width: 22px; height: 22px; margin: 0; accent-color: var(--accent-fill); cursor: pointer; }
.selecting .pick { display: block; }
.selecting .items .body { padding-left: 42px; }
.item:has(.pick:checked) { outline: 2px solid var(--accent); outline-offset: -2px; }

/* The feed: one link per row, text on the left, thumbnail on the right (like a compact Reddit feed). */
.items { display: flex; flex-direction: column; gap: 10px; }
.items .item {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "body cover";
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
}
.items .cover { grid-area: cover; width: 124px; aspect-ratio: 4 / 3; margin: 10px 10px 10px 0; border-radius: 10px; align-self: start; }
.items .body { grid-area: body; padding: 9px 12px 11px; gap: 4px; }
.items .title { font-size: .97rem; }
.items .ph-icon { width: 32px; height: 32px; }
.items .item.status-error { border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
@media (max-width: 599px) { .items .cover { width: 92px; } }
.site-summary { margin: -4px 0 14px; }
.site-group > summary .favicon { width: 18px; height: 18px; }

/* ------------------------------------------------------------ bulk bar */

.bulkbar {
  display: none; position: fixed; z-index: 30; left: calc(50% + 124px); bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  align-items: center; gap: 8px; max-width: calc(100vw - 280px); padding: 8px 8px 8px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg);
}
.selecting .bulkbar { display: flex; }
.sel-count { font-weight: 650; font-size: .88rem; white-space: nowrap; }
.bulk-actions { display: flex; align-items: center; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.tag-field input { width: 110px; height: 30px; padding: 0 8px; font-size: .85rem; }
@media (max-width: 899px) {
  .bulkbar { left: 10px; right: 10px; transform: none; max-width: none; flex-wrap: wrap; padding: 10px; }
  .bulkbar [data-clear-selection] { margin-left: auto; }
  .bulk-actions { order: 3; flex-basis: 100%; }
}

/* ------------------------------------------------------------ reader */

.reader-page { background: var(--surface); }
.reader-page { padding-top: calc(54px + env(safe-area-inset-top)); }
.reader-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40; min-height: 54px; box-sizing: border-box;
  padding-top: max(8px, env(safe-area-inset-top)); display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: var(--surface); border-bottom: 1px solid var(--line); /* solid: iPad Safari can drop blurred fixed bars */
  transform: translateZ(0); /* own layer, so it stays put while Safari's address bar collapses */
}
.reader-site { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--muted); font-size: .88rem; }
.reader-tools { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.btn.ghost-plain { border-color: transparent; background: transparent; }
.text-menu { position: relative; }
.text-menu .popover { right: 0; width: 250px; }
.text-menu .row-buttons { margin: 0; justify-content: flex-start; }
.text-menu .row-buttons .btn { flex: 1; }
.font-serif { font-family: Georgia, serif; }
[data-font="serif"] .font-serif, [data-font="sans"] .font-sans { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.reader { max-width: calc(var(--reader-width) + 48px); margin: 0 auto; padding: 36px 24px 96px; }
.reader-meta { margin: 0; color: var(--muted); font-size: .85rem; }
.reader h1 { margin: .25em 0 .4em; font-size: clamp(1.6rem, 4.5vw, 2.4rem); line-height: 1.18; letter-spacing: -.02em; }
.lede { margin: 0 0 12px; font-size: 1.12rem; color: var(--muted); }
.saved-info { margin: 20px 0 30px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); font-size: .86rem; }
.saved-info > summary { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.saved-info > summary .i { width: 17px; height: 17px; }
.saved-info .hint { margin: 8px 0; }
.files { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.files li { display: flex; justify-content: space-between; gap: 12px; }
.files a { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.files .i { width: 15px; height: 15px; }
.files span { color: var(--muted); }
.hero { width: 100%; border-radius: 12px; margin: 0 0 28px; }
.prose { font-family: var(--reader-font); font-size: var(--reader-size); line-height: 1.75; overflow-wrap: break-word; }
.prose img { max-width: 100%; height: auto; border-radius: 8px; }
.prose a { color: var(--accent); text-underline-offset: 2px; }
.prose h1, .prose h2, .prose h3, .prose h4 { line-height: 1.3; margin: 1.8em 0 .6em; font-family: var(--sans); }
.prose blockquote { margin: 1.4em 0; padding-left: 16px; border-left: 3px solid var(--line); color: var(--muted); }
.prose code { font-size: .88em; background: var(--surface-2); padding: .1em .35em; border-radius: 5px; }
.prose pre { overflow-x: auto; padding: 14px 16px; background: var(--surface-2); border-radius: 10px; font-size: .85em; line-height: 1.55; }
.prose pre code { background: none; padding: 0; }
.prose table { display: block; overflow-x: auto; border-collapse: collapse; font-size: .9em; }
.prose th, .prose td { padding: 6px 10px; border: 1px solid var(--line); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.reader .chips { margin-top: 8px; }
.pdf-view { display: flex; flex-direction: column; gap: 12px; }
.pdf-page { width: 100%; background: #fff; border: 1px solid var(--line); border-radius: 6px; overflow: hidden;
  display: grid; place-items: center; color: #666; font-size: .85rem; }
.pdf-page canvas { display: block; width: 100%; height: auto; }
/* Table of contents: docked beside the text when there's room (app.js sets .toc-docked), otherwise a drawer that
   slides out over the text from the Contents button in the reader's toolbar. */
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc a { display: block; padding: 5px 10px; border-left: 2px solid var(--line); color: var(--muted); text-decoration: none;
  font-size: .84rem; line-height: 1.35; }
.toc a:hover { color: var(--text); }
.toc a.active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.toc .toc-l2 a { padding-left: 22px; }
.toc .toc-l3 a { padding-left: 34px; font-size: .8rem; }
.toc-title { margin: 0 0 8px 12px; font-size: .72rem; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.toc-side {
  position: fixed; z-index: 45; top: calc(62px + env(safe-area-inset-top)); right: 12px; bottom: calc(16px + env(safe-area-inset-bottom)); width: min(320px, calc(100vw - 24px));
  overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; padding: 14px 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg);
  transform: translateX(calc(100% + 24px)); visibility: hidden; transition: transform .2s ease, visibility .2s;
}
.toc-open .toc-side { transform: none; visibility: visible; }
.toc-open .toc-btn, .toc-docked:not(.toc-collapsed) .toc-btn { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
/* Docked: in the free space right of the centred text; Contents in the toolbar hides or shows it. */
.toc-docked .toc-side {
  top: 84px; bottom: auto; right: auto; left: calc(50% + var(--reader-width) / 2 + 36px); width: min(260px, calc(50vw - var(--reader-width) / 2 - 52px));
  max-height: calc(100dvh - 120px); padding: 0; background: none; border: 0; box-shadow: none; transform: none; visibility: visible; transition: none;
}
.toc-docked.toc-collapsed .toc-side { display: none; }
.prose :is(h1, h2, h3)[id] { scroll-margin-top: 72px; } /* clear the sticky reader bar */
.chars-row { display: flex; align-items: center; gap: 8px; }
.chars-row output { flex: 1; text-align: center; font-variant-numeric: tabular-nums; font-size: .85rem; color: var(--muted); }
.reader-foot { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 56px; padding-top: 24px; border-top: 1px solid var(--line); }
.read-toggle[aria-pressed="false"] .i { opacity: .35; }
.read-toggle[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
@media (max-width: 599px) {
  .reader { padding: 24px 18px 72px; }
  .reader-site, .reader-bar .ghost-plain span { display: none; }
  .reader-bar { justify-content: space-between; }
  /* One row on phones: icons only, except the read toggle, which keeps its word. */
  .reader-tools { flex-wrap: nowrap; }
  .reader-tools .btn:not(.read-toggle) span { display: none; }
}

/* ------------------------------------------------------------ standalone pages */

.plain { display: grid; place-items: center; min-height: 100dvh; padding: 16px; }
.center-card {
  width: min(440px, 100%); display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 28px;
  text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
}
.center-card.wide { width: min(560px, 100%); align-items: stretch; text-align: left; }
.center-card h1 { margin: 4px 0; font-size: 1.4rem; }
.center-card > p { margin: 0 0 8px; color: var(--muted); }
.center-card .i.logo { width: 52px; height: 52px; }
.check-circle { width: 64px; height: 64px; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.check-circle .i { width: 32px; height: 32px; stroke-width: 2.5; }
.saved-list { list-style: none; width: 100%; max-height: 50vh; overflow-y: auto; margin: 8px 0; padding: 0; text-align: left; border: 1px solid var(--line); border-radius: 12px; }
.saved-list li { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--line); font-size: .88rem; }
.saved-list li:last-child { border-bottom: 0; }
.saved-title { flex: 1; }
.saved-status { font-size: .75rem; font-weight: 600; white-space: nowrap; color: var(--muted); }
.saved-list .status-pending .saved-status { color: var(--accent); }
.saved-list .status-done .saved-status { color: var(--ok); }
.saved-list .status-error .saved-status { color: var(--danger); }
.row-buttons { display: flex; justify-content: flex-end; gap: 10px; width: 100%; margin-top: 8px; }
.saved .row-buttons { justify-content: center; }
.saved .row-buttons .btn { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
.stack label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .88rem; }
.stack label .hint { font-weight: 400; font-size: .8rem; }
.signin-form { width: 100%; text-align: left; }
.hint.block { display: block; font-weight: 400; margin-top: 2px; }
.row-buttons.inline { width: auto; margin-top: 0; flex-wrap: wrap; }
.import-form { display: flex; flex-direction: column; gap: 12px; padding-top: 14px; margin-top: 4px; border-top: 1px solid var(--line); }
.import-form label { display: flex; flex-direction: column; gap: 6px; font-size: .92rem; }
.import-form input[type="file"] { font: inherit; font-size: .88rem; }
.import-form .row-buttons { margin-top: 0; }
.version { text-align: center; margin: 8px 0 24px; }
.signin-form .btn { width: 100%; }
.center-card > .btn.large { width: 100%; }
.center-card .or { display: flex; align-items: center; gap: 10px; width: 100%; }
.center-card .or::before, .center-card .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.error { margin: 0; color: var(--danger); font-size: .86rem; font-weight: 600; }
[aria-invalid="true"] { border-color: var(--danger) !important; }

/* ------------------------------------------------------------ swipe (touch) */

.items .item { touch-action: pan-y; overflow: hidden; }
.items .item > * { transition: transform .2s ease; }
.items .item.swiping > * { transform: translateX(var(--dx, 0)); transition: none; }
.items .item::before {
  content: attr(data-swipe-label); position: absolute; inset: 0; display: flex; align-items: center; padding: 0 20px;
  font-weight: 650; font-size: .9rem; color: #fff; opacity: 0; pointer-events: none; background: var(--muted);
}
.items .item.swiping::before { opacity: .55; }
.items .item.swipe-armed::before { opacity: 1; }
.items .item[data-swipe-dir="left"]::before { justify-content: flex-end; }
.items .item[data-swipe-action="read"]::before { background: var(--accent-fill); color: var(--on-accent); }
.items .item[data-swipe-action="delete"]::before { background: var(--danger); }
.items .item[data-swipe-action="none"]::before { background: var(--surface-2); }

dialog.sheet {
  width: min(380px, calc(100vw - 32px)); padding: 20px; border: 1px solid var(--line); border-radius: 18px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
dialog.sheet::backdrop { background: rgb(0 0 0 / .45); }
dialog.sheet h2 { margin: 0 0 14px; font-size: 1.1rem; }
.sheet-options { display: flex; flex-direction: column; gap: 8px; }
.sheet-options .btn { width: 100%; height: 44px; }
dialog.sheet .hint { margin: 12px 0 6px; }
dialog.sheet > .btn.ghost { width: 100%; }

/* ------------------------------------------------------------ settings (sidebar) */

.settings .setting { display: flex; flex-direction: column; gap: 4px; margin: 6px 10px; font-size: .8rem; color: var(--muted); }
.settings select { font: inherit; font-size: .85rem; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }

/* ------------------------------------------------------------ search suggestions */

.search { position: relative; }
.suggest {
  position: absolute; left: -1px; right: -1px; top: calc(100% + 6px); z-index: 40; max-height: min(60vh, 440px); overflow-y: auto;
  padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg);
}
.sg-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px;
  background: transparent; color: var(--text); text-align: left; cursor: pointer; font-size: .9rem;
}
.sg-item:hover, .sg-item.active { background: var(--accent-soft); }
.sg-label { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg-hint { color: var(--muted); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sg-count { margin-left: auto; color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
.sg-foot { padding: 8px 10px 4px; border-top: 1px solid var(--line); margin-top: 4px; color: var(--muted); font-size: .75rem; }
.sg-foot code { font-size: .72rem; background: var(--surface-2); padding: 1px 4px; border-radius: 4px; }
@media (max-width: 899px) { .sg-foot { display: none; } }

/* ------------------------------------------------------------ per-link ⋯ menu */

.meta .more { margin-left: auto; width: 28px; height: 28px; margin-right: -6px; }
.item.unread .meta .more { margin-left: 4px; }
.meta .more .i { width: 18px; height: 18px; }
.more[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent); }
.item-menu {
  position: fixed; z-index: 60; display: flex; flex-direction: column; min-width: 200px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg);
}
.item-menu .btn { justify-content: flex-start; width: 100%; height: 40px; padding: 0 12px; border: 0; background: transparent; color: var(--text); font-size: .9rem; }
.item-menu .btn:hover, .item-menu .btn:focus-visible { background: var(--surface-2); outline: none; }
.item-menu .btn:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.item-menu .menu-sep { height: 1px; margin: 5px 6px; background: var(--line); }
.bulk-actions .menu-sep { align-self: stretch; width: 1px; margin: 4px 2px; background: var(--line); flex: none; }
.item-actions .menu-sep { display: none; }
.item-menu .btn[data-danger] { color: var(--danger); }
.item-menu .short { display: none; }
.item-menu .long { display: inline; }

/* ------------------------------------------------------------ condensed layout */

.results { padding: 14px 20px 120px; }
.heading { margin: 0 0 12px; }
.day { margin-bottom: 18px; }
.day-label { margin-bottom: 8px; }
.batch { margin: 8px 0; padding: 0 10px 10px; }
.batch > summary { padding: 6px 0; }

@media (max-width: 899px) {
  /* Phone: edge-to-edge like a native feed. */
  .results { padding: 6px 0 120px; }
  .heading, .day-label, .site-summary, .pager, .empty { padding-left: 12px; padding-right: 12px; }
  .toast { margin-left: 12px; }
  .day { margin-bottom: 12px; }
  .day-label { margin-bottom: 4px; }
  .batch { margin: 4px 0 8px; padding: 0; border: 0; border-radius: 0; }
  .batch > summary { padding: 6px 12px; }
  .items { gap: 6px; }
  .items .item { border-radius: 0; border-left: 0; border-right: 0; }
}

/* ------------------------------------------------------------ sheets, reminders, two-stage swipe */

dialog.sheet { max-height: 90dvh; overflow-y: auto; }
dialog.sheet .stack { margin-top: 0; }
dialog.sheet .stack .row-buttons { margin-top: 4px; }
/* Phones: sheets slide up from the bottom, full width, thumb-reachable. */
@media (max-width: 599px) {
  dialog.sheet {
    width: 100%; max-width: 100%; margin: auto 0 0; padding: 18px 16px max(18px, env(safe-area-inset-bottom));
    border-radius: 20px 20px 0 0; border-bottom: 0; animation: sheet-up .18s ease-out;
  }
  dialog.sheet input, dialog.sheet textarea { font-size: 16px; } /* no zoom-on-focus on iOS */
}
/* Editing a link: wide enough for a comfortable summary and plenty of tags. */
dialog.sheet.edit-sheet { width: min(720px, calc(100vw - 32px)); }
dialog.sheet.edit-sheet textarea { min-height: 9em; resize: vertical; line-height: 1.5; }
dialog.sheet.edit-sheet .tag-editor { min-height: 56px; padding: 8px; }
dialog.sheet.edit-sheet .tag-suggest { max-height: 260px; }
@media (max-width: 599px) { dialog.sheet.edit-sheet { width: 100%; } }
/* Bulk tags: one row per tag; ticked = all selected links, dash = some, empty = none. */
dialog.sheet .tag-search { width: 100%; margin-bottom: 10px; }
.tag-checks { display: flex; flex-direction: column; gap: 2px; max-height: min(52dvh, 420px); overflow-y: auto; margin-bottom: 14px; }
.tag-check { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 6px 8px; border: 0; border-radius: 8px;
  background: transparent; color: var(--text); font: inherit; font-size: .92rem; text-align: left; cursor: pointer; }
.tag-check:hover { background: var(--surface-2); }
.tag-check .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-check .hint { font-size: .78rem; }
.tag-check .box { flex: none; width: 20px; height: 20px; border: 2px solid var(--muted); border-radius: 5px; display: grid; place-items: center; }
.tag-check[data-state="all"] .box { background: var(--accent-fill); border-color: var(--accent-fill); }
.tag-check[data-state="all"] .box::after { content: ""; width: 5px; height: 10px; border: solid var(--on-accent); border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg); }
.tag-check[data-state="some"] .box::after { content: ""; width: 10px; height: 2px; background: var(--muted); }
.tag-check.create .name { color: var(--accent); }
/* Add links stays centered on every screen, so the keyboard doesn't cover it on phones. */
dialog.sheet.add-sheet { width: min(460px, calc(100vw - 24px)); margin: auto; border-radius: 18px; border-bottom: 1px solid var(--line); animation: none; }
.add-form { display: flex; flex-direction: column; gap: 10px; }
.add-form label { font-weight: 600; font-size: .9rem; }
@media (max-width: 599px) { dialog.sheet.add-sheet { margin: 12vh auto auto; padding: 18px 16px; } }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }

.sheet .preset { justify-content: space-between; }
.sheet .preset .hint { font-weight: 400; font-size: .8rem; }
.custom-date { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; font-size: .85rem; font-weight: 600; color: var(--muted); }
.custom-date .row { display: flex; gap: 8px; }
.custom-date input { flex: 1; min-width: 0; }

.badge.remind { background: var(--remind-bg); color: var(--remind); }

.items .item[data-swipe-action="remind"]::before { background: #0284c7; }
.items .item[data-swipe-action="ask"]::before { background: var(--muted); }
.items .item.swipe-long::before { font-size: 1rem; letter-spacing: .01em; }

/* Swipe that removes the link: the content keeps going off-screen, the colored label stays until it's gone. */
.items .item.swipe-out > * { transform: translateX(var(--dx)); transition: transform .15s ease-in; }
.items .item.swipe-out::before { opacity: 1; }

/* ------------------------------------------------------------ dedicated pages (tags, dashboard, settings) */

.page { padding: 14px 20px 120px; max-width: 1000px; }
.page-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 16px; }
.page-toolbar .filter { flex: 0 1 280px; height: 38px; }
.tags-label { display: flex; align-items: center; gap: 8px; }
.tags-label .tag-sort { display: inline-flex; margin-left: auto; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.tags-label .tag-sort a, .tags-label .all-tags { padding: 1px 6px; color: var(--muted); text-decoration: none; font-size: .68rem; letter-spacing: .03em; }
.tags-label .tag-sort a + a { border-left: 1px solid var(--line); }
.tags-label .tag-sort a.on, .tags-label .all-tags.on { background: var(--accent-soft); color: var(--accent); }
.tags-label .all-tags:hover, .tags-label .tag-sort a:hover { color: var(--text); }
.tag-section { margin-bottom: 18px; }
.tag-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.tag-card {
  display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--text); text-decoration: none;
}
.tag-card:hover { border-color: var(--accent); }
.tag-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-name .hash { width: auto; margin-right: 1px; }
.tag-meta { color: var(--muted); font-size: .8rem; }
@media (max-width: 899px) { .page { padding: 10px 12px 120px; } }

/* ------------------------------------------------------------ settings page */

.card { margin: 0 0 14px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; max-width: 720px; }
.card h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; font-size: 1.02rem; }
.card h2 .i { width: 18px; height: 18px; color: var(--accent); }
.card > .hint { margin-bottom: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; font-weight: 600; }
.form-grid select, .settings-page select {
  font: inherit; font-weight: 400; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px;
}
.setting-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; }
.setting-row + .setting-row { border-top: 1px solid var(--line); }
.steps { margin: 6px 0 10px; padding-left: 20px; font-size: .9rem; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; font-size: .8rem; font-family: ui-monospace, monospace; }
@media (max-width: 899px) { .card { border-radius: 0; border-left: 0; border-right: 0; margin: 0 -12px 10px; } }

/* ------------------------------------------------------------ dashboard */

.dashboard { max-width: 1100px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat {
  display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--text); text-decoration: none;
}
.stat:hover { border-color: var(--accent); }
.stat-value { font-size: 1.8rem; font-weight: 750; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { font-weight: 600; font-size: .88rem; }
.stat-sub { color: var(--muted); font-size: .76rem; }
.chart-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.chart-row .card, .dashboard > .card { max-width: none; }
.chart h2 { margin-bottom: 2px; }

/* columns: one bar per day, 4px rounded tops on a baseline, 2px gaps */
.cols { display: flex; align-items: flex-end; gap: 2px; height: 120px; margin-top: 10px; border-bottom: 1px solid var(--line); }
.col { flex: 1; height: 100%; display: flex; align-items: flex-end; position: relative; }
.col > span { display: block; width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; }
.col:hover > span { filter: brightness(1.15); }
.col-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: .72rem; margin-top: 4px; }

/* horizontal bars with direct labels */
.hbars { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.hbar { display: grid; grid-template-columns: minmax(80px, 34%) 1fr auto; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-size: .85rem; position: relative; }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 10px; border-radius: 0 4px 4px 0; background: var(--surface-2); overflow: hidden; }
.hbar-fill { display: block; height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; }
.hbar-value { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 2ch; text-align: right; }
.hbar:hover .hbar-label { color: var(--accent); }

/* heatmap: weekday rows × 24 hours, one hue mixed into the neutral surface */
.heat { display: grid; grid-template-columns: 34px repeat(24, minmax(0, 1fr)); gap: 2px; margin-top: 10px; font-size: .68rem; color: var(--muted); }
.heat-cell { aspect-ratio: 1; border-radius: 3px; background: color-mix(in srgb, var(--accent) var(--mix), var(--surface-2)); position: relative; }
.heat-day { align-self: center; }
.heat-hour { text-align: left; }

/* tag bubbles: one hue; size is the measure */
.bubbles { display: block; width: 100%; height: auto; max-height: 460px; margin-top: 10px; }
.bubbles circle { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.5; }
.bubbles a:hover circle { fill: var(--accent-fill); }
.bubbles text { fill: var(--text); text-anchor: middle; font-weight: 650; pointer-events: none; }
.bubbles text.n { fill: var(--muted); font-weight: 500; }
.bubbles a:hover text, .bubbles a:hover text.n { fill: #1a1a1a; }

/* tag overlap: lower-triangle matrix, same cells as the weekday heatmap, column labels written upwards */
.overlap-wrap { overflow-x: auto; margin-top: 10px; }
.overlap { display: grid; grid-template-columns: max-content repeat(var(--n), minmax(20px, 1fr)); gap: 2px; font-size: .72rem; color: var(--muted); }
.overlap-row { align-self: center; padding-right: 6px; color: var(--text); text-decoration: none; white-space: nowrap; }
.overlap-row:hover { color: var(--accent); }
.overlap .heat-cell { min-width: 20px; }
.overlap-col { display: flex; justify-content: center; }
.overlap-col span { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; padding-top: 4px; }

/* word cloud: word size = frequency; three steps of ink */
.word-cloud { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; gap: 2px 12px; margin-top: 12px; line-height: 1.15; }
.word-cloud a { text-decoration: none; position: relative; }
.word-cloud .w1 { color: var(--muted); }
.word-cloud .w2 { color: var(--text); }
.word-cloud .w3 { color: var(--accent); font-weight: 650; }
.word-cloud a:hover { text-decoration: underline; }

/* tooltips for chart marks */
[data-tip]:hover::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); z-index: 20;
  padding: 3px 8px; border-radius: 6px; background: var(--text); color: var(--bg); font-size: .75rem; font-weight: 500; white-space: nowrap; pointer-events: none;
}
.hbar[data-tip]:hover::after { left: auto; right: 0; transform: none; }

/* The summary / search excerpt opens the link too, like the title. */
.summary-link { display: block; color: inherit; text-decoration: none; }
.summary-link:hover .summary, .summary-link:hover .snippet { color: var(--text); }

/* Endless scrolling: the "Older" link turns into a quiet loading hint while the next page loads. */
.pager.loading a[data-more] { pointer-events: none; opacity: .5; }
.pager.loading a[data-more]::after { content: "…"; }
.pager:empty { display: none; }
.main > .toast { margin: 14px 20px 0; }
@media (max-width: 899px) { .main > .toast { margin: 8px 12px 0; } }

/* ------------------------------------------------------------ badges for kinds, thin copies, dead originals, duplicates */

.badge.kind { background: var(--surface-2); color: var(--muted); }
.badge.thin { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.badge.dead { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.badge.duplicate { background: var(--surface-2); color: var(--muted); text-decoration: none; }
.badge.duplicate:hover { color: var(--accent); }

/* Reading progress on the thumbnail: a thin bar along the bottom. */
.cover { position: relative; }
.cover .progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgb(0 0 0 / .25); }
.cover .progress::after { content: ""; display: block; height: 100%; width: var(--p, 0%); background: var(--accent-fill); }

/* Keyboard cursor in lists (j / k). */
.item.kbd-focus { outline: 2px solid var(--accent); outline-offset: -2px; }
.items .item.kbd-focus { box-shadow: 0 0 0 3px var(--accent-soft); }

/* Saved searches in the sidebar: the link fills the row, × removes it. */
.saved-item { padding: 0; gap: 0; }
.saved-item .saved-link { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 7px 10px; color: inherit; text-decoration: none; border-radius: 8px; }
.saved-item .saved-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-item .inline-delete { margin: 0; }
.saved-item .inline-delete .icon-btn { width: 28px; height: 28px; opacity: 0; }
.saved-item:hover .inline-delete .icon-btn, .saved-item .inline-delete .icon-btn:focus-visible { opacity: 1; }
.save-search input { width: 200px; height: 32px; padding: 0 10px; }
.heading code { font-size: .8rem; background: var(--surface-2); padding: 1px 6px; border-radius: 5px; }
.more-in-group { margin: 6px 0 0; }

/* Notices in the reader (thin copy, original gone, duplicate). */
.notice { display: flex; gap: 10px; align-items: flex-start; margin: 14px 0 0; padding: 10px 14px; border-radius: 12px; background: var(--accent-soft); color: var(--text); font-size: .88rem; }
.notice .i { flex: none; color: var(--accent); margin-top: 2px; }
.notice a { color: var(--accent); }

/* Highlights and notes under the article. */
.notes { margin-top: 48px; padding-top: 20px; border-top: 1px solid var(--line); }
.notes h2 { display: flex; align-items: center; gap: 8px; font-size: 1.05rem; margin: 18px 0 10px; }
.notes h2 .i { width: 18px; height: 18px; color: var(--accent); }
.notes h2 .hint { font-weight: 400; font-size: .8rem; }
.highlights { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.highlights:empty::before { content: "Nothing highlighted yet."; color: var(--muted); font-size: .86rem; }
.highlight { position: relative; padding: 10px 12px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); cursor: pointer; }
.highlight blockquote { margin: 0; padding-left: 12px; border-left: 3px solid var(--accent-fill); font-size: .92rem; white-space: pre-wrap; }
.highlight-note { margin: 8px 0 0 15px; color: var(--muted); font-size: .86rem; }
.highlight .inline-delete { position: absolute; top: 6px; right: 6px; margin: 0; opacity: 0; }
.highlight:hover .inline-delete, .highlight .inline-delete:focus-within { opacity: 1; }
.highlight .inline-delete .btn span { display: none; }
::highlight(lb-highlight) { background: var(--mark); color: inherit; }
.highlight-btn { position: absolute; z-index: 45; display: flex; gap: 6px; padding: 6px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg); }
.notes-form { display: flex; flex-direction: column; gap: 8px; }
.notes-form textarea { min-height: 7em; font-family: var(--sans); }
.notes-form .row-buttons { align-items: center; margin: 0; }
.notes-form .notes-status { margin-right: auto; }
.notes-preview { margin-top: 10px; padding: 10px 14px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); font-size: .95rem; }
.more-menu .popover { width: 220px; }
.more-menu .popover .btn { justify-content: flex-start; }

/* Settings: rules, tokens, sign-in providers. */
.rule-list { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.rule { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.rule.off { opacity: .6; }
.rule-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: .92rem; }
.rule-form { padding-top: 14px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; }
.form-grid label.check { flex-direction: row; align-items: center; gap: 8px; align-self: end; }
.form-grid label.check input { width: auto; }
.plain-table { width: 100%; border-collapse: collapse; font-size: .88rem; margin: 6px 0 14px; }
.plain-table th { text-align: left; font-weight: 600; color: var(--muted); font-size: .78rem; padding: 4px 8px 6px 0; }
.plain-table td { padding: 6px 8px 6px 0; border-top: 1px solid var(--line); vertical-align: middle; }
.plain-table td:last-child { text-align: right; }
.token-new { margin: 6px 0 14px; padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); display: flex; flex-direction: column; gap: 8px; }
.token-new p { margin: 0; font-size: .9rem; }
.token-new .hint { overflow-wrap: anywhere; }
.token-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.token-form input { flex: 1 1 200px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.providers { gap: 8px; width: 100%; }
.providers .btn { width: 100%; }
@media (max-width: 599px) { .highlight .inline-delete { opacity: 1; } .saved-item .inline-delete .icon-btn { opacity: 1; } }
