/* Colors. The page carries data-mode ("light" or "dark") and data-scheme, set before the first paint by the
   snippet in index.html and changed under Settings → Appearance. A scheme only redefines what it changes. */
:root {
  --bg: #ffffff;
  --bg-sidebar: #f6f7f8;
  --bg-hover: #eceef0;
  --bg-active: #e1f3e8;
  --bg-elev: #ffffff;
  --text: #1d2125;
  --text-muted: #6b7278;
  --text-read: #8a9096;
  --border: #e3e6e8;
  --accent: #1f9d55;
  --accent-hover: #188246;
  --accent-text: #ffffff;
  --danger: #d0372f;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.08);
  --sidebar-w: 272px;
  --radius: 8px;
  color-scheme: light;
}

:root[data-mode="dark"] {
  --bg: #17191b;
  --bg-sidebar: #1e2124;
  --bg-hover: #2a2e32;
  --bg-active: #1f3a2a;
  --bg-elev: #24272b;
  --text: #e6e8ea;
  --text-muted: #9aa1a7;
  --text-read: #767d83;
  --border: #30343a;
  --accent: #2fb866;
  --accent-hover: #3fcb77;
  --accent-text: #0c1a12;
  --danger: #ef5b52;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

/* Each scheme repaints the whole app — backgrounds, sidebar, text and borders — not just the accent. */

:root[data-scheme="slate"] {
  --bg: #f7f8fa; --bg-sidebar: #1f2430; --bg-hover: #e8eaef; --bg-active: #dfe6f5; --bg-elev: #ffffff;
  --text: #1a1e27; --text-muted: #5a6172; --text-read: #848b9b; --border: #dde0e7;
  --accent: #3d6df0; --accent-hover: #2f59cc; --accent-text: #ffffff;
}
:root[data-scheme="slate"][data-mode="dark"] {
  --bg: #171a21; --bg-sidebar: #12151b; --bg-hover: #242936; --bg-active: #22304f; --bg-elev: #1d212a;
  --text: #e4e7ee; --text-muted: #98a0b3; --text-read: #727a8c; --border: #2b303c;
  --accent: #6b93ff; --accent-hover: #86a8ff; --accent-text: #0a1020;
}

:root[data-scheme="nord"] {
  --bg: #f8fafc; --bg-sidebar: #e5e9f0; --bg-hover: #dee4ee; --bg-active: #d4e2f2; --bg-elev: #ffffff;
  --text: #2e3440; --text-muted: #5f6b7d; --text-read: #7b869a; --border: #d6dce6;
  --accent: #5e81ac; --accent-hover: #4c6a90; --accent-text: #ffffff; --danger: #bf616a;
}
:root[data-scheme="nord"][data-mode="dark"] {
  --bg: #2e3440; --bg-sidebar: #272c36; --bg-hover: #3b4252; --bg-active: #3b4a5f; --bg-elev: #343b48;
  --text: #e5e9f0; --text-muted: #a7b0c0; --text-read: #808b9e; --border: #3f4757;
  --accent: #88c0d0; --accent-hover: #9fd2e0; --accent-text: #16202b; --danger: #bf616a;
}

:root[data-scheme="solarized"] {
  --bg: #fdf6e3; --bg-sidebar: #eee8d5; --bg-hover: #e6dfc6; --bg-active: #dcefef; --bg-elev: #fffbf0;
  --text: #073642; --text-muted: #657b83; --text-read: #93a1a1; --border: #e0d8bf;
  --accent: #268bd2; --accent-hover: #1f72ad; --accent-text: #ffffff; --danger: #dc322f;
}
:root[data-scheme="solarized"][data-mode="dark"] {
  --bg: #002b36; --bg-sidebar: #00242e; --bg-hover: #073642; --bg-active: #0b4553; --bg-elev: #04303c;
  --text: #eee8d5; --text-muted: #93a1a1; --text-read: #708c8c; --border: #0e4653;
  --accent: #2aa198; --accent-hover: #37bfb4; --accent-text: #00252e; --danger: #cb4b16;
}

:root[data-scheme="gruvbox"] {
  --bg: #fbf1c7; --bg-sidebar: #ebdbb2; --bg-hover: #e4d5a8; --bg-active: #e8d3a0; --bg-elev: #fdf6da;
  --text: #3c3836; --text-muted: #6f6355; --text-read: #928374; --border: #e0d0a4;
  --accent: #af3a03; --accent-hover: #922f02; --accent-text: #ffffff; --danger: #9d0006;
}
:root[data-scheme="gruvbox"][data-mode="dark"] {
  --bg: #282828; --bg-sidebar: #1d2021; --bg-hover: #3c3836; --bg-active: #45403a; --bg-elev: #32302f;
  --text: #ebdbb2; --text-muted: #a89984; --text-read: #857c6d; --border: #423d38;
  --accent: #fabd2f; --accent-hover: #ffd75f; --accent-text: #282010; --danger: #fb4934;
}

:root[data-scheme="dracula"] {
  --bg: #f7f5fb; --bg-sidebar: #e9e4f5; --bg-hover: #e2dcf2; --bg-active: #e4dcfb; --bg-elev: #ffffff;
  --text: #282a36; --text-muted: #635f7d; --text-read: #8b87a3; --border: #ddd6ef;
  --accent: #7b4bd8; --accent-hover: #6837c4; --accent-text: #ffffff; --danger: #d63b6a;
}
:root[data-scheme="dracula"][data-mode="dark"] {
  --bg: #282a36; --bg-sidebar: #21222c; --bg-hover: #343746; --bg-active: #3b3357; --bg-elev: #2e3040;
  --text: #f8f8f2; --text-muted: #a9adc8; --text-read: #7c819c; --border: #3a3d4e;
  --accent: #bd93f9; --accent-hover: #d0b0ff; --accent-text: #201432; --danger: #ff5555;
}

:root[data-scheme="rose"] {
  --bg: #fdf7f8; --bg-sidebar: #f3e6e9; --bg-hover: #efdde1; --bg-active: #f6dde4; --bg-elev: #ffffff;
  --text: #3b2b30; --text-muted: #7d6068; --text-read: #a08890; --border: #ecdadf;
  --accent: #b4436c; --accent-hover: #99355a; --accent-text: #ffffff;
}
:root[data-scheme="rose"][data-mode="dark"] {
  --bg: #211a1d; --bg-sidebar: #1a1416; --bg-hover: #2f2428; --bg-active: #422732; --bg-elev: #281f22;
  --text: #f0e4e8; --text-muted: #b39aa2; --text-read: #8b757c; --border: #3a2c31;
  --accent: #eb6f9b; --accent-hover: #ff8fb4; --accent-text: #2a0e18;
}

:root[data-scheme="sepia"] {
  --bg: #fbf6ec; --bg-sidebar: #f0e6d5; --bg-hover: #eadfcc; --bg-active: #e7dcc2; --bg-elev: #fffaf1;
  --text: #33291d; --text-muted: #7a6a54; --text-read: #9c8d78; --border: #e0d3bd;
  --accent: #9a6b34; --accent-hover: #82592a; --accent-text: #ffffff;
}
:root[data-scheme="sepia"][data-mode="dark"] {
  --bg: #1d1a15; --bg-sidebar: #17140f; --bg-hover: #2f2b23; --bg-active: #3b3223; --bg-elev: #27231c;
  --text: #ece3d4; --text-muted: #a3947f; --text-read: #8d8171; --border: #3a342a;
  --accent: #d0a05e; --accent-hover: #e0b473; --accent-text: #201709;
}

:root[data-scheme="forest"] {
  --bg: #f5f8f4; --bg-sidebar: #e3ece1; --bg-hover: #d9e4d7; --bg-active: #d8ead5; --bg-elev: #ffffff;
  --text: #1f2a22; --text-muted: #5b6b5e; --text-read: #869088; --border: #d7e0d5;
  --accent: #2f7d4f; --accent-hover: #256640; --accent-text: #ffffff;
}
:root[data-scheme="forest"][data-mode="dark"] {
  --bg: #141a16; --bg-sidebar: #0f1411; --bg-hover: #202a23; --bg-active: #1e3a29; --bg-elev: #19211b;
  --text: #e2ebe4; --text-muted: #94a599; --text-read: #708077; --border: #27322a;
  --accent: #58c98a; --accent-hover: #74dda2; --accent-text: #0a1a10;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
input, select { font: inherit; color: var(--text); }
.muted { color: var(--text-muted); }
svg.i { width: 18px; height: 18px; flex: none; display: block; }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); background: var(--bg-elev);
  padding: 7px 14px; border-radius: 6px; cursor: pointer; text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); }
.btn-sm { padding: 5px 10px; font-size: 14px; }
.btn-lg { padding: 11px 22px; font-size: 16px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
.btn-danger:hover { filter: brightness(1.08); background: var(--danger); }
.btn:disabled { opacity: .6; cursor: default; }
.btn .i { width: 16px; height: 16px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border: 0; background: transparent; border-radius: 6px;
  cursor: pointer; color: var(--text-muted); flex: none;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn.on { color: var(--accent); }
.spin .i { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ layout */
.app { display: flex; height: 100vh; height: 100dvh; }
.sidebar {
  width: var(--sidebar-w); flex: none; display: flex; flex-direction: column;
  background: var(--bg-sidebar); border-right: 1px solid var(--border);
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 14px 10px 16px; }
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; font-weight: 700; font-size: 17px; text-decoration: none; }
.brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-head .dropdown { flex: none; }
/* The sidebar can be narrow, so its menus hang from the button's right edge instead of running off-screen. */
.sidebar-head .menu, .nav-section .menu { left: auto; right: 0; }
.nav { flex: 1; overflow-y: auto; padding: 4px 8px 16px; }
.sidebar-foot { border-top: 1px solid var(--border); padding: 8px; }
.user { display: flex; align-items: center; gap: 8px; padding: 6px 8px 2px; }
.avatar { width: 26px; height: 26px; border-radius: 50%; }
.user-name { flex: 1; font-size: 13px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user .version { font-size: 11px; color: var(--text-read); font-variant-numeric: tabular-nums; white-space: nowrap; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.toolbar {
  display: flex; align-items: center; gap: 12px; padding: 10px 24px;
  border-bottom: 1px solid var(--border); min-height: 60px;
}
.title-block { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 10px; }
.title-block h1 { font-size: 21px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.title-block .muted { font-size: 14px; white-space: nowrap; }
.actions { display: flex; align-items: center; gap: 6px; }
.menu-toggle { display: none; }
.content { flex: 1; overflow-y: auto; outline: none; }
.scrim { display: none; }
.sidebar { position: relative; }
.sidebar-resize { position: absolute; top: 0; bottom: 0; right: -4px; width: 8px; cursor: col-resize; z-index: 5; }
.sidebar-resize:hover, body.resizing .sidebar-resize { background: color-mix(in srgb, var(--accent) 35%, transparent); }
body.resizing { cursor: col-resize; user-select: none; }

/* ------------------------------------------------------------------ sidebar nav */
.nav-row {
  display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 4px 8px;
  border-radius: 6px; text-decoration: none; cursor: pointer; position: relative; user-select: none;
}
.nav-row:hover { background: var(--bg-hover); }
.nav-row.active { background: var(--bg-active); font-weight: 600; }
.nav-row.drop-target { outline: 2px dashed var(--accent); outline-offset: -2px; }
.nav-row.drop-before, .folder.drop-before { box-shadow: inset 0 3px 0 var(--accent); }
.nav-row.drop-after, .folder.drop-after { box-shadow: inset 0 -3px 0 var(--accent); }
.nav-icon { width: 18px; display: flex; justify-content: center; color: var(--text-muted); flex: none; }
.nav-icon img { width: 16px; height: 16px; border-radius: 3px; }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.nav-row.zero .nav-label { color: var(--text-muted); }
.nav-row .more { width: 26px; height: 26px; display: none; margin-right: -4px; }
.nav-row:hover .more, .nav-row .more:focus-visible { display: inline-flex; }
.nav-row:hover .nav-count { display: none; }
.nav-row .warn { color: var(--danger); display: flex; }
.nav-row .warn .i { width: 14px; height: 14px; }
.chevron { width: 20px; height: 20px; margin-left: -4px; display: flex; align-items: center; justify-content: center; color: var(--text-muted); border-radius: 4px; }
.chevron:hover { background: var(--border); }
.chevron .i { width: 14px; height: 14px; transition: transform .15s; }
.folder.collapsed .chevron .i { transform: rotate(-90deg); }
.folder.collapsed .folder-feeds { display: none; }
.folder-feeds .nav-row { padding-left: 30px; }
.folder-feeds .nav-empty { padding: 4px 8px 6px 34px; }
.nav-section {
  display: flex; align-items: center; justify-content: space-between;
  margin: 18px 8px 4px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted);
}
.nav-section:first-child { margin-top: 4px; }
.nav-section .icon-btn { width: 24px; height: 24px; }
.nav-empty { padding: 8px; font-size: 13px; color: var(--text-muted); }

/* ------------------------------------------------------------------ menus */
.dropdown { position: relative; }
.menu { max-width: min(320px, calc(100vw - 24px)); max-height: 70vh; overflow-y: auto; }
.menu {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 50; min-width: 220px;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 6px;
}
.menu button {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  border: 0; background: transparent; padding: 7px 10px; border-radius: 5px; cursor: pointer; font-size: 14px;
}
.menu button:hover { background: var(--bg-hover); }
.menu button.danger { color: var(--danger); }
.menu button .check { width: 16px; color: var(--accent); display: flex; }
.menu-label { padding: 8px 10px 2px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.menu-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.context-menu { position: fixed; top: 0; left: 0; right: auto; }

/* ------------------------------------------------------------------ article list */
/* Zero-height sticky row so the "new articles" pill floats over the list without shifting it. */
.new-banner-wrap { position: sticky; top: 0; height: 0; z-index: 6; display: flex; justify-content: center; align-items: flex-start; }
.new-banner {
  margin-top: 12px; border: 0; border-radius: 999px; padding: 7px 16px; cursor: pointer;
  background: var(--accent); color: var(--accent-text); font-weight: 600; font-size: 14px; box-shadow: var(--shadow);
}
.new-banner:hover { background: var(--accent-hover); }
.articles { max-width: 860px; margin: 0 auto; padding: 8px 24px 0; }
.item { border-bottom: 1px solid var(--border); }
.item-row { display: flex; gap: 16px; padding: 16px 4px; cursor: pointer; position: relative; }
.item-row:hover { background: color-mix(in srgb, var(--bg-hover) 55%, transparent); }
.item.active > .item-row { box-shadow: inset 3px 0 0 var(--accent); }
.thumb { width: 150px; height: 96px; object-fit: cover; border-radius: 6px; flex: none; background: var(--bg-hover); }
.item-main { flex: 1; min-width: 0; }
.item-title { font-size: 17px; font-weight: 650; line-height: 1.35; margin: 0 0 4px; }
.item.read .item-title { color: var(--text-read); font-weight: 500; }
.item-title .item-link { color: inherit; text-decoration: none; }
.item-title .item-link:hover { color: inherit; text-decoration: none; }
.item-meta { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); min-width: 0; }
.item-meta img { width: 14px; height: 14px; border-radius: 3px; }
.item-meta .feed-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.item-summary { font-size: 14px; color: var(--text-muted); margin: 6px 0 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item.read .item-summary { color: var(--text-read); }
.item-tools { display: flex; gap: 2px; position: absolute; right: 4px; top: 10px; opacity: 0; background: var(--bg); border-radius: 6px; }
.item-row:hover .item-tools, .item-tools .on { opacity: 1; }
.item-row:hover .item-tools { opacity: 1; }
.item-tools .icon-btn { width: 30px; height: 30px; }
.star-flag { color: var(--accent); display: inline-flex; }
.star-flag .i { width: 14px; height: 14px; }

/* titles-only layout */
.layout-titles .item-row { padding: 9px 4px; align-items: center; gap: 12px; }
.layout-titles .thumb { display: none; }
.layout-titles .item-main { display: flex; align-items: baseline; gap: 12px; }
.layout-titles .item-meta { order: -1; width: 170px; flex: none; }
.layout-titles .item-meta .age, .layout-titles .item-meta .author, .layout-titles .item-meta .dot { display: none; }
.layout-titles .item-title { font-size: 15px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: none; max-width: 60%; }
.layout-titles .item-summary { margin: 0; -webkit-line-clamp: 1; flex: 1; min-width: 0; font-size: 14px; }
.layout-titles .age-right { display: block; }
.age-right { display: none; font-size: 13px; color: var(--text-muted); flex: none; min-width: 32px; text-align: right; }
.layout-titles .item-row:hover .age-right { visibility: hidden; }
.item.open > .item-row { display: none; }

/* expanded article */
.reader { padding: 22px 4px 30px; }
.reader-title { font-size: 26px; line-height: 1.25; margin: 0 0 8px; }
.reader-title a { text-decoration: none; }
.reader-title a:hover { text-decoration: underline; }
.reader-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 14px; color: var(--text-muted); margin-bottom: 14px; }
.reader-meta img { width: 16px; height: 16px; border-radius: 3px; }
.reader-bar { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 20px; }
.reader-body { font-size: 17px; line-height: 1.7; overflow-wrap: anywhere; }
.reader-body img, .reader-body video { display: block; max-width: 100%; height: auto; border-radius: 4px; margin: 14px 0; }
.reader-body figure { margin: 1.2em 0; }
.reader-body pre { overflow-x: auto; background: var(--bg-sidebar); padding: 12px; border-radius: 6px; font-size: 14px; }
.reader-body code { font-size: .9em; }
.reader-body blockquote { margin: 1em 0; padding-left: 16px; border-left: 3px solid var(--border); color: var(--text-muted); }
.reader-body a { color: var(--accent); }
.reader-body table { display: block; overflow-x: auto; border-collapse: collapse; }
.reader-body td, .reader-body th { border: 1px solid var(--border); padding: 4px 8px; }
.reader-foot { display: flex; gap: 6px; margin-top: 26px; }
.reader-loading { color: var(--text-muted); padding: 10px 0; }

.list-end { max-width: 860px; margin: 0 auto; padding: 28px 24px; text-align: center; color: var(--text-muted); }
/* A full screen of room after the last article so it can scroll past the top (and be marked read). */
.list-end.done { min-height: 100vh; min-height: 100dvh; }
.list-end.done.empty { min-height: 0; }
.list-end .big { font-size: 18px; color: var(--text); font-weight: 600; margin: 18px 0 4px; }
.list-end .i { width: 42px; height: 42px; margin: 24px auto 0; color: var(--accent); }
.list-end .btn .i { width: 16px; height: 16px; margin: 0; color: inherit; }

/* ------------------------------------------------------------------ organize */
.organize { max-width: 980px; margin: 0 auto; padding: 24px; }
/* Explanations run the width of the page; the buttons sit underneath them. */
.org-head { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.org-head p { margin: 0; max-width: 90ch; font-size: 14px; }
.org-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.organize h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin: 28px 0 8px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.org-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.org-table th { text-align: left; font-weight: 600; color: var(--text-muted); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--border); background: var(--bg-sidebar); }
.org-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.org-table tr:last-child td { border-bottom: 0; }
.org-table input[type=text], .org-table select { width: 100%; min-width: 140px; padding: 5px 8px; border: 1px solid transparent; border-radius: 5px; background: transparent; }
.org-table input[type=text]:hover, .org-table select:hover { border-color: var(--border); }
.org-table input[type=text]:focus, .org-table select:focus { border-color: var(--accent); outline: none; background: var(--bg); }
.org-table input.url { color: var(--text-muted); font-size: 12px; max-width: 420px; text-overflow: ellipsis; }
.org-table input.url:focus { color: var(--text); }
.org-table .status-err { color: var(--danger); font-size: 12px; }
.org-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.org-table .row-actions { white-space: nowrap; text-align: right; }
.org-table .order { white-space: nowrap; width: 1%; padding-right: 0; }
.org-table .order .icon-btn { width: 26px; height: 26px; }
.org-table .order .icon-btn:disabled { opacity: .25; cursor: default; background: transparent; }
.org-table .feed-cell { display: flex; align-items: center; gap: 8px; }
.org-table .feed-cell img { width: 16px; height: 16px; border-radius: 3px; }
.org-table .feed-cell .grow { flex: 1; min-width: 0; }
.reader-meta a { text-decoration: none; }
.reader-meta a:hover { text-decoration: underline; }
.org-filter { width: 100%; max-width: 320px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); margin-bottom: 10px; }

/* ------------------------------------------------------------------ stash */
.stash-head { max-width: 860px; margin: 0 auto; padding: 16px 24px 4px; display: flex; flex-direction: column; gap: 10px; }
.stash-search { width: 100%; max-width: 420px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); }
.stash-search:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.tag-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--border); background: var(--bg-elev); color: var(--text-muted); border-radius: 999px; padding: 3px 10px; font-size: 13px; cursor: pointer; }
.chip .i { width: 13px; height: 13px; }
.chip span { opacity: .7; font-variant-numeric: tabular-nums; }
.chip:hover { background: var(--bg-hover); color: var(--text); }
.chip.active { background: var(--bg-active); border-color: var(--accent); color: var(--text); font-weight: 600; }
.type-badge { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.type-badge .i { width: 13px; height: 13px; }
.item-meta { flex-wrap: wrap; }
.item-meta .tag { color: var(--accent); }
.item-meta .source { white-space: nowrap; }
.stash-text { white-space: pre-wrap; font-size: 16px; line-height: 1.6; }
.stash-body img { max-height: 70vh; width: auto; }
.saved-page { margin-top: 18px; }
.saved-page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px 0 8px; border-top: 1px solid var(--border); font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); }
.saved-page-head .muted { font-weight: 400; letter-spacing: 0; text-transform: none; }
.saved-page-head .btn { margin-left: auto; font-weight: 500; letter-spacing: 0; text-transform: none; }
.list-search { width: 200px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; font-size: 14px; }
.list-search:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.actions .btn:disabled { opacity: .5; cursor: default; }

/* stash folders, smart lists and rules */
.stash-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.folder-name { display: inline-flex; align-items: center; gap: 4px; }
.folder-name .i { width: 14px; height: 14px; }
.folder-pick { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); }
.folder-pick select { padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-elev); max-width: 180px; }
.nav-row.drop-target { outline: 2px solid var(--accent); outline-offset: -2px; }
.check-cell .check { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.rule-when { font-weight: 600; }
.rule-then { display: flex; flex-wrap: wrap; gap: 6px; }
.rule-then .chip { cursor: default; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 8px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 999px; background: var(--bg-elev); font-size: 14px;
}
.swatch span { width: 16px; height: 16px; border-radius: 50%; display: block; }
.swatch:hover { background: var(--bg-hover); }
.swatch.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

/* Settings → Email */
.mail-form { display: grid; gap: 12px; max-width: 520px; margin-top: 12px; }
.mail-form label { display: grid; gap: 4px; font-size: 14px; }
.mail-form input, .mail-form select {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text);
}
.mail-form input:focus, .mail-form select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.mail-form p { margin: 0; font-size: 13px; }
.mail-form details { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; }
.mail-form details[open] { padding-bottom: 12px; }
.mail-form summary { cursor: pointer; font-size: 14px; color: var(--text-muted); }
.mail-form details label { margin-top: 10px; }

/* Spacing of the article and stash rows (View options → Spacing). */
:root[data-density="compact"] .item-row { padding: 7px 4px; gap: 12px; }
:root[data-density="compact"] .item-title { font-size: 15px; }
:root[data-density="compact"] .item-summary { display: none; }
:root[data-density="compact"] .thumb { width: 104px; height: 68px; }
:root[data-density="comfortable"] .item-row { padding: 20px 4px; gap: 20px; }
:root[data-density="comfortable"] .item-title { font-size: 19px; }
:root[data-density="comfortable"] .item-meta { margin-top: 5px; }
:root[data-density="comfortable"] .thumb { width: 180px; height: 116px; }
.stash-links { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 15px; }
.stash-links li { overflow-wrap: anywhere; }
.link-host { margin-left: 8px; font-size: 13px; color: var(--text-muted); }
.link-count { white-space: nowrap; }
.field-group { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.field-label small, .modal-body label small { font-weight: 400; }
.link-rows { display: flex; flex-direction: column; gap: 6px; }
.link-row { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr) auto auto; gap: 6px; align-items: center; }
.link-row .icon-btn { width: 30px; height: 30px; }
.link-row:first-child [data-link=up] { visibility: hidden; }
.link-add { align-self: flex-start; }
@media (max-width: 520px) {
  .link-row { grid-template-columns: minmax(0, 1fr) auto auto; }
  .link-row .link-url { grid-column: 1 / -1; }
}
.stash-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 20px; }
.menu button span[data-icon] { display: inline-flex; }
.menu .kbd { margin-left: auto; font-size: 11px; color: var(--text-muted); border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; }

/* capture dialog */
dialog.modal { width: min(520px, calc(100vw - 32px)); }
.type-switch { display: flex; gap: 6px; }
.modal-body .type-option {
  position: relative; flex: 1; flex-direction: row; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); border-radius: 8px; padding: 8px; cursor: pointer; color: var(--text); font-weight: 500;
}
.type-option input { position: absolute; opacity: 0; pointer-events: none; }
.type-option .i { width: 16px; height: 16px; }
.type-option:has(input:checked) { border-color: var(--accent); background: var(--bg-active); font-weight: 600; }
.type-option:has(input:focus-visible) { outline: 2px solid var(--accent); }
.modal-body textarea { padding: 9px 11px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); font: inherit; font-weight: 400; resize: vertical; }
.modal-body textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.capture-image { display: flex; flex-direction: column; gap: 6px; }
.capture-preview { max-width: 100%; max-height: 200px; object-fit: contain; border-radius: 6px; border: 1px solid var(--border); align-self: flex-start; }

/* settings */
.setup { font-size: 14px; line-height: 1.6; }
.setup code, .org-table code { background: var(--bg-sidebar); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; font-size: 13px; }
.setup ul { padding-left: 20px; }
.setup li { margin: 6px 0; }
.token-app { display: inline-flex; align-items: center; gap: 6px; }
.token-app .i { width: 14px; height: 14px; color: var(--text-muted); }

/* ------------------------------------------------------------------ dialogs & toast */
dialog.modal {
  border: 1px solid var(--border); border-radius: 12px; padding: 0; width: min(460px, calc(100vw - 32px));
  background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow);
}
dialog.modal::backdrop { background: rgba(0, 0, 0, .4); }
dialog.modal form { padding: 22px; }
dialog.modal h2 { margin: 0 0 16px; font-size: 19px; }
.modal-body { display: flex; flex-direction: column; gap: 14px; }
.modal-body label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--text-muted); }
.modal-body label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; color: var(--text); font-size: 14px; }
.modal-body input[type=text], .modal-body input[type=url], .modal-body input[type=email], .modal-body input[type=password], .modal-body select {
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); font-weight: 400; font-size: 15px;
}
.modal-body input:focus, .modal-body select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.modal-body p { margin: 0; }
.modal-error { color: var(--danger); font-size: 14px; margin: 14px 0 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100;
  display: flex; align-items: center; gap: 14px; max-width: calc(100vw - 32px);
  background: #26292c; color: #f1f3f4; padding: 10px 12px 10px 18px; border-radius: 8px; box-shadow: var(--shadow); font-size: 14px;
}
.toast button { background: transparent; border: 0; color: #5fdc93; font-weight: 700; cursor: pointer; padding: 4px 8px; border-radius: 4px; }
.toast button:hover { background: rgba(255, 255, 255, .08); }
.toast.error { background: #5b1d1a; }

/* ------------------------------------------------------------------ login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; background: var(--bg-sidebar); }
.login-card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 14px; padding: 40px 36px; text-align: center; width: 100%; max-width: 380px; box-shadow: var(--shadow); }
.login-card h1 { margin: 14px 0 2px; }
.login-card .muted { margin: 0 0 26px; }
.login-error { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); padding: 10px; border-radius: 6px; font-size: 14px; }
.login-form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.login-form label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--text-muted); }
.login-form label small { font-weight: 400; }
.login-form input { padding: 9px 11px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); font: inherit; font-size: 15px; font-weight: 400; }
.login-form input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.login-form .login-error { margin: 0; }
.login-options { display: flex; flex-direction: column; gap: 10px; }
.login-options:empty { display: none; }
.login-or { display: flex; align-items: center; gap: 10px; margin: 18px 0; color: var(--text-muted); font-size: 13px; }
.login-or::before, .login-or::after { content: ""; flex: 1; border-top: 1px solid var(--border); }

/* ------------------------------------------------------------------ import saved links */
.import-plan tr.excluded td { color: var(--text-muted); }
.import-plan .nowrap { white-space: nowrap; }
.import-plan input[type=text] { min-width: 120px; }
.import-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0 4px; }

/* ------------------------------------------------------------------ settings rows */
.setting-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 14px 0 0; }
.setting-row select { padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); font: inherit; }
.setting-row select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.setting-row .muted { flex-basis: 100%; margin: 0; font-size: 13px; }

/* ------------------------------------------------------------------ mobile */
@media (max-width: 820px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  body.nav-open .sidebar { transform: none; }
  .sidebar-resize { display: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 30; }
  .menu-toggle { display: inline-flex; margin-left: -8px; }
  .toolbar { padding: 8px 16px; gap: 6px; }
  .title-block { flex-direction: column; gap: 0; }
  .title-block h1 { font-size: 18px; max-width: 100%; }
  .title-block .muted { font-size: 12px; }
  .hide-sm { display: none; }
  .list-search { width: 110px; }
  .articles { padding: 4px 16px 0; }
  .thumb { width: 88px; height: 64px; }
  .item-title { font-size: 16px; }
  .item-summary { display: none; }
  .item-tools { display: none; }
  .layout-titles .item-main { display: block; }
  .layout-titles .item-meta { width: auto; }
  .layout-titles .item-title { white-space: normal; max-width: none; }
  .reader-title { font-size: 22px; }
  .reader-body { font-size: 16px; }
  .organize { padding: 16px; }
  .nav-row .more { display: inline-flex; }
  .nav-row:hover .nav-count { display: inline; }
  .stash-head { padding: 12px 16px 4px; }
}
