/* Handpicked — personal reader */
:root {
  /* Palette after the Financial Times: paper, wheat, black-80 text, claret + teal */
  --fs: 19px;                       /* reader font size, set from settings */
  --bg: #fff1e5;                    /* FT paper */
  --bg-side: #f6e6d8;
  --bg-hover: #f0dccb;
  --bg-active: #ebd3bf;
  --bg-elev: #fff7f0;
  --text: #33302e;                  /* FT black-80 */
  --text-2: #4d4845;
  --text-3: #5f5955;                /* ≥4.5:1 on all light backgrounds */
  --accent-text: #0a5e66;           /* accent for small text on --accent-soft */
  --line: #ccc1b7;                  /* FT black-20 on paper */
  --line-soft: #e6d6c8;             /* between rows: quieter than borders */
  --rule: #33302e;                  /* heavy section rules */
  --accent: #0d7680;                /* FT teal */
  --accent-soft: #dde8e1;
  --claret: #990f3d;                /* FT claret: brand, unread, progress */
  --danger: #cc0000;
  --shadow: 0 8px 30px rgba(51, 48, 46, .16), 0 1px 4px rgba(51, 48, 46, .08);
  --radius: 2px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --serif: Georgia, "Iowan Old Style", Charter, Cambria, "Times New Roman", serif;
  --display: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --reader-font: var(--serif);      /* Aa menu: serif | sans */
  --measure: 34em;                  /* Aa menu: line length, in reader-size ems (about 68 characters) */
  --reader-w: min(780px, 56vw);     /* the reader beside the list on wide screens */
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #1d1b1a;
  --bg-side: #242120;
  --bg-hover: #2e2b29;
  --bg-active: #38322e;
  --bg-elev: #262321;
  --text: #f2e8de;
  --text-2: #cdc2b8;
  --text-3: #aba196;
  --accent-text: #7cccd3;
  --line: #45403c;
  --line-soft: #302c2a;
  --rule: #f2e8de;
  --accent: #4fb3bd;
  --accent-soft: #1d3537;
  --claret: #f0789c;
  --danger: #ff7a6e;
  --shadow: 0 10px 40px rgba(0, 0, 0, .5), 0 2px 8px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.5 var(--sans); background: var(--bg); color: var(--text); overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
a.btn { text-decoration: none; }
[hidden] { display: none !important; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.side-shade { display: none; }
.app { display: grid; grid-template-columns: var(--side-w, 264px) 1fr; height: 100vh; height: 100dvh; }

/* ------------------------------------------------ sidebar */
.side { position: relative; min-width: 0; background: var(--bg-side); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px 10px; font-weight: 700; font-size: 18px; letter-spacing: -.01em; }
.brand .logo { width: 26px; height: 26px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; color: #fff; }
.brand .logo svg { width: 16px; height: 16px; stroke-width: 2.4; }
.side-scroll { flex: 1; overflow-y: auto; padding: 6px 10px 20px; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; padding: 7px 10px; border-radius: 8px; text-align: left; color: var(--text); min-height: 34px; }
.nav-item:hover { background: var(--bg-hover); }
.nav-item.active { background: var(--bg-active); font-weight: 600; }
.nav-item .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .count { font-size: 13px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.nav-item.active .count { color: var(--text-2); }
.nav-item .err { color: var(--danger); font-size: 13px; }

/* favourite star on sidebar feeds: shown on hover, or always when it's a favourite */
.nav-item .fav-btn { display: none; place-items: center; width: 20px; height: 20px; margin: -4px -4px; border-radius: 5px; color: var(--text-3); flex: none; }
.nav-item .fav-btn .i { width: 14px; height: 14px; }
.nav-item .fav-btn:hover { background: var(--bg-active); color: var(--text); }
.nav-item .fav-btn.on { color: #d9a21b; }
.nav-item:hover .fav-btn { display: grid; }
/* open the source's website: next to the star on hover */
.nav-item .site-btn { display: none; place-items: center; width: 20px; height: 20px; margin: -4px -2px; border-radius: 5px; color: var(--text-3); flex: none; }
.nav-item .site-btn .i { width: 13px; height: 13px; }
.nav-item .site-btn:hover { background: var(--bg-active); color: var(--accent-text); }
.nav-item:hover .site-btn { display: grid; }
@media (hover: none) { .nav-item .fav-btn.on { display: grid; } }
.feed-row .btn.on { color: #d9a21b; }

/* drag to reorder */
.nav-item[draggable="true"] { cursor: grab; }
.nav-item.dragging { opacity: .4; }
.nav-item.drop-before { box-shadow: inset 0 2px 0 var(--accent); border-radius: 0; }
.nav-item.drop-after { box-shadow: inset 0 -2px 0 var(--accent); border-radius: 0; }
.nav-item.drop-into { background: var(--accent-soft); outline: 1px dashed var(--accent); }
.side-h { display: flex; align-items: center; justify-content: space-between; margin: 18px 10px 4px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.side-h button { border: 0; background: none; color: var(--text-3); padding: 2px; border-radius: 6px; display: grid; }
.side-h button:hover { color: var(--text); background: var(--bg-hover); }
.folder .chev { width: 14px; height: 14px; transition: transform .15s; color: var(--text-3); }
.folder.collapsed .chev { transform: rotate(-90deg); }
.folder.collapsed + .folder-feeds { display: none; }
.folder-feeds .nav-item { padding-left: 34px; }
.fav { width: 16px; height: 16px; border-radius: 4px; flex: none; object-fit: cover; }
.fav-letter { width: 16px; height: 16px; border-radius: 4px; flex: none; display: grid; place-items: center; font-size: 10px; font-weight: 700; color: #fff; }
.tag-item .hash { color: var(--text-3); width: 16px; text-align: center; }
.side-foot { border-top: 1px solid var(--line); padding: 8px 10px; display: flex; gap: 4px; }
.side-foot .nav-item { flex: 1; justify-content: center; }

/* ------------------------------------------------ main */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.toolbar { display: flex; align-items: center; gap: 8px; padding: 12px 20px; border-bottom: 1px solid var(--line); min-height: 60px; flex-wrap: wrap; }
.toolbar .titles { min-width: 0; flex: 0 1 auto; margin-right: 8px; }
.toolbar h1 { font-size: 21px; margin: 0; line-height: 1.25; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toolbar .subtitle { font-size: 13px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.toolbar .spacer { flex: 1; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--bg-elev); border-radius: 8px; padding: 6px 11px; color: var(--text); white-space: nowrap; min-height: 34px; }
.btn:hover { background: var(--bg-hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--danger); }
.btn.icon { padding: 6px; width: 34px; justify-content: center; }
.btn.ghost { border-color: transparent; background: none; }
.btn.ghost:hover { background: var(--bg-hover); }
.btn:disabled { opacity: .5; cursor: default; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--bg-elev); }
.seg button { border: 0; background: none; padding: 6px 9px; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; min-height: 32px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent-soft); color: var(--accent); }
.search { position: relative; }
.search input { width: 220px; border: 1px solid var(--line); background: var(--bg-elev); border-radius: 8px; padding: 6px 10px 6px 32px; min-height: 34px; }
.search svg { position: absolute; left: 9px; top: 8px; width: 16px; height: 16px; color: var(--text-3); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.menu-btn { display: none; }

.list-wrap { flex: 1; overflow-y: auto; }
.list { max-width: 980px; margin: 0 auto; padding: 8px 20px 80px; }
/* Bookmarks: topics (one per folder), open by default, with a quiet header that sticks while you scroll */
.topic { margin-top: 10px; }
.topic + .topic { margin-top: 22px; }
.topic-h { display: flex; align-items: baseline; gap: 10px; padding: 10px 6px 8px; cursor: pointer; user-select: none; border-bottom: 1px solid var(--line); }
.topic-h:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 6px; }
.topic-h .chev { width: 14px; height: 14px; flex: none; align-self: center; color: var(--text-3); transform: rotate(-90deg); transition: transform .15s; }
.topic.open .topic-h .chev { transform: none; }
.topic-name { font-weight: 650; font-size: 16px; color: var(--text); white-space: nowrap; }
.topic-count { font-size: 13px; color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.topic-srcs { flex: 1; min-width: 0; font-size: 13px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .85; }
.topic-h .btn.icon { width: 28px; height: 28px; min-height: 28px; flex: none; align-self: center; opacity: 0; transition: opacity .12s; color: var(--text-2); }
.topic-h:hover .btn.icon, .topic-h:focus-within .btn.icon { opacity: 1; }
@media (hover: none) { .topic-h .btn.icon { opacity: 1; } }
.topic-h:hover .topic-name { color: var(--accent-text); }
.topic.open { padding-bottom: 4px; }
.topic.open .topic-h { position: sticky; top: 0; z-index: 2; background: var(--bg); }
.topic:not(.open) .topic-h { border-bottom-color: var(--line-soft); }
@media (max-width: 640px) { .topic-srcs { display: none; } .topic-name { flex: 1; } }

.day-h { font-size: 13px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); padding: 18px 4px 6px; }
.empty { text-align: center; color: var(--text-2); padding: 80px 20px; }
.empty svg { width: 42px; height: 42px; color: var(--text-3); stroke-width: 1.4; }
.empty h2 { color: var(--text); font-size: 18px; margin: 12px 0 4px; }
.loading { text-align: center; color: var(--text-3); padding: 24px; }

/* items: shared */
.item { position: relative; cursor: pointer; border-radius: var(--radius); }
.item .title { font-weight: 600; color: var(--text); }
.item.read .title { font-weight: 400; color: var(--text-2); }
.item .meta { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-3); min-width: 0; }
.item .meta .src { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.item .excerpt { color: var(--text-2); }
.item.selected { box-shadow: inset 3px 0 0 var(--accent); background: var(--bg-hover); }
.item .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }
.item.read .dot { visibility: hidden; }
.item .star { color: var(--accent); }
.item .tags { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.chip { font-size: 12px; padding: 1px 7px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.item .quick { position: absolute; right: 8px; top: 8px; display: none; gap: 2px; background: var(--bg-elev); border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.item:hover .quick { display: flex; }
.quick button { border: 0; background: none; padding: 4px; border-radius: 6px; color: var(--text-2); display: grid; }
.quick button:hover { background: var(--bg-hover); color: var(--text); }

/* list layout: an unread dot, the title on one line, and under it source · time · one line of summary */
.layout-list .item { display: grid; grid-template-columns: 7px minmax(0, 1fr); align-items: start; column-gap: 12px; padding: 11px 12px 12px 10px; border-radius: 8px; }
.layout-list .item + .item { border-top: 1px solid var(--line-soft); }
.layout-list .item:hover + .item, .layout-list .item.selected + .item { border-top-color: transparent; }
.layout-list .item:hover { background: var(--bg-hover); }
.layout-list .item .dot { margin-top: calc(var(--fs) * .84 * .7 - 3.5px); }
.layout-list .item .line { min-width: 0; }
.layout-list .item .title { font-size: calc(var(--fs) * .84); font-weight: 650; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layout-list .item.read .title { font-weight: 450; color: var(--text-2); }
.layout-list .item .meta { margin-top: 3px; line-height: 20px; }
.layout-list .item .meta .src { flex: none; max-width: 190px; }
.layout-list .item .meta .time { flex: none; font-variant-numeric: tabular-nums; }
.layout-list .item .meta .excerpt { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-3); }
.layout-list .item .meta .excerpt::before { content: "—"; margin: 0 6px 0 2px; opacity: .6; }
.layout-list .item.read .meta .src { color: var(--text-3); }
.layout-list .item .quick { top: 50%; transform: translateY(-50%); }

/* magazine layout */
.layout-magazine .item { display: grid; grid-template-columns: 1fr 200px; gap: 20px; padding: 22px 14px; border-bottom: 1px solid var(--line-soft); border-radius: 0; }
.layout-magazine .item .title .dot { display: inline-block; vertical-align: middle; margin: -3px 9px 0 -16px; }
.layout-magazine .item .meta .sep { opacity: .6; }
.layout-magazine .item:hover { background: var(--bg-hover); }
.layout-magazine .item.noimg { grid-template-columns: 1fr; }
.layout-magazine .item { padding-left: 26px; }
.layout-magazine .item .title { font-size: calc(var(--fs) * 1.05); line-height: 1.3; margin-bottom: 6px; }
.layout-magazine .item .excerpt { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 6px; font-size: calc(var(--fs) * .8); }
.layout-magazine .thumb { width: 200px; height: 120px; border-radius: 8px; object-fit: cover; background: var(--bg-hover); }

/* cards layout */
.layout-cards .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 26px; padding-top: 14px; }
.layout-cards .item { background: var(--bg-elev); border: 1px solid var(--line); overflow: hidden; display: flex; flex-direction: column; transition: box-shadow .15s, transform .15s; }
.layout-cards .item:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.layout-cards .item.selected { outline: 2px solid var(--accent); box-shadow: none; }
.layout-cards .thumb { width: 100%; aspect-ratio: 16/9; object-fit: cover; background: var(--bg-hover); display: block; }
.layout-cards .thumb.ph { display: grid; place-items: center; font-size: 34px; font-weight: 700; color: #fff; opacity: .85; }
.layout-cards .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.layout-cards .item .title { font-size: calc(var(--fs) * .9); line-height: 1.3; }
.layout-cards .item .title .dot { display: none; }
.layout-cards .item .excerpt { font-size: 14px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ------------------------------------------------ reader */
.reader-backdrop { position: fixed; inset: 0; background: rgba(10, 15, 12, .28); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 20; }
.reader-backdrop.open { opacity: 1; pointer-events: auto; }
.reader { position: fixed; top: 0; right: 0; bottom: 0; width: min(820px, 100vw); background: var(--bg); box-shadow: var(--shadow); transform: translateX(102%); transition: transform .22s ease; z-index: 21; display: flex; flex-direction: column; }
.reader.open { transform: none; }
.reader-bar { position: relative; display: flex; align-items: center; gap: 4px; padding: 10px 14px; flex-wrap: wrap; }
.reader-progress { height: 2px; background: var(--line); flex: none; }
.reader-progress span { display: block; height: 100%; background: var(--accent); transform-origin: left; transform: scaleX(0); transition: transform .08s linear; }
.reader-bar .sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.reader-bar .btn.on { color: var(--accent); }
.reader-scroll { flex: 1; overflow-y: auto; }
.reader-body { font-size: var(--fs); max-width: calc(var(--measure) + 56px); margin: 0 auto; padding: 32px 28px 120px; }
.reader-body .r-src { font-size: 14px; color: var(--text-2); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.reader-body h1 { font-family: var(--reader-font); font-size: calc(var(--fs) * 1.6); font-weight: 700; line-height: 1.2; margin: 10px 0 8px; letter-spacing: -.015em; text-wrap: balance; }
[data-rfont="serif"] .reader-body h1 { font-weight: 600; letter-spacing: -.01em; }
.reader-body h1 a { color: inherit; text-decoration: none; }
.reader-body h1 a:hover { text-decoration: underline; }
.reader-body .r-meta { color: var(--text-3); font-size: 14px; margin-bottom: 24px; }
.content { font-family: var(--reader-font); font-size: var(--fs); line-height: 1.65; overflow-wrap: break-word; }
[data-rfont="sans"] { --reader-font: var(--sans); }
[data-rwidth="narrow"] { --measure: 29em; }
[data-rwidth="wide"] { --measure: 42em; }
.content img, .content video { max-width: 100%; height: auto; border-radius: 6px; }
.content pre { overflow-x: auto; background: var(--bg-side); padding: 12px 14px; border-radius: 8px; font-size: .8em; }
.content code { font-size: .88em; }
.content blockquote { margin: 1em 0; padding-left: 1em; border-left: 3px solid var(--line); color: var(--text-2); }
.content table { border-collapse: collapse; display: block; overflow-x: auto; }
.content td, .content th { border: 1px solid var(--line); padding: 4px 8px; }
.content h1, .content h2, .content h3 { font-family: var(--reader-font); line-height: 1.25; }
.content figure { margin: 1.2em 0; }
.content figcaption { font-size: .75em; color: var(--text-3); font-family: var(--sans); }
.notice { font-family: var(--sans); font-size: 14px; color: var(--text-2); background: var(--bg-side); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 16px 0; display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.bm-panel { font-family: var(--sans); font-size: 15px; background: var(--bg-side); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 26px; display: grid; gap: 10px; }
.bm-panel label { font-size: 13px; font-weight: 600; color: var(--text-2); display: grid; gap: 4px; }
.bm-panel textarea { min-height: 64px; resize: vertical; }

/* ------------------------------------------------ forms, modals */
.field { display: grid; gap: 5px; margin-bottom: 14px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 13px; color: var(--text-3); font-weight: 400; }
input[type=text], input[type=url], input[type=number], input[type=email], input[type=password], select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: var(--bg); min-height: 36px; }
.check { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--accent); }
.check small { display: block; color: var(--text-3); }
.row { display: flex; gap: 10px; align-items: center; }
.err-msg { color: var(--danger); font-size: 14px; min-height: 18px; }

dialog { border: 0; border-radius: 14px; padding: 0; background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow); width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 40px); }
dialog.wide { width: min(820px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(10, 15, 12, .4); }
.dlg-h { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 0; }
.dlg-h h2 { margin: 0; font-size: 18px; }
.dlg-b { padding: 16px 20px; overflow-y: auto; max-height: calc(100vh - 170px); }
.dlg-f { display: flex; justify-content: flex-end; gap: 8px; padding: 0 20px 18px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 20px; margin-top: 12px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 9px 12px; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.on { color: var(--text); border-color: var(--accent); font-weight: 600; }
.feed-row { display: grid; grid-template-columns: 1fr 160px auto; gap: 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.feed-row .fr-title { min-width: 0; }
.feed-row .fr-title small { display: block; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-row .fr-title small.e { color: var(--danger); }
.feed-row select { min-height: 32px; padding: 4px 6px; }
.range-row { display: flex; align-items: center; gap: 12px; }
.range-row input { flex: 1; accent-color: var(--accent); }
.preview-text { font-family: var(--serif); font-size: var(--fs); line-height: 1.6; padding: 12px 14px; border: 1px dashed var(--line); border-radius: 8px; color: var(--text-2); }
kbd { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--bg-side); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; align-items: center; }
.bookmarklet { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; background: var(--accent); color: #fff; text-decoration: none; font-weight: 600; cursor: grab; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; opacity: 0; transition: .2s; z-index: 50; pointer-events: none; max-width: calc(100vw - 32px); display: flex; align-items: center; gap: 14px; }
.toast.show.has-action { pointer-events: auto; padding-right: 8px; }
.toast-btn { border: 0; background: none; color: var(--accent-soft); font-weight: 700; padding: 6px 10px; border-radius: 7px; white-space: nowrap; }
[data-theme="dark"] .toast-btn { color: var(--accent); filter: brightness(.75); }
.toast-btn:hover { background: rgba(127,127,127,.18); }
.toast.show { opacity: 1; transform: translateX(-50%); }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------ mobile */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 30; transform: translateX(-100%); transition: transform .2s, visibility .2s; visibility: hidden; }
  .app.side-open .side { transform: none; visibility: visible; box-shadow: var(--shadow); }
  .side-shade { position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 29; display: none; }
  .app.side-open .side-shade { display: block; }
  .menu-btn { display: inline-flex; }
  .toolbar { padding: 10px 12px; }
  .search input { width: 150px; }
  .list { padding: 6px 10px 80px; }
  .layout-list .item .meta .src { max-width: 120px; }
  .layout-magazine .item { grid-template-columns: 1fr 110px; gap: 12px; }
  .layout-magazine .thumb { width: 110px; height: 80px; }
  .reader-body { padding: 22px 18px 100px; }
  .feed-row { grid-template-columns: 1fr 1fr; }
  .lbl-wide { display: none; }
}

/* ---- topics: paging */
.topic-more { display: block; margin: 4px 0 2px; padding: 8px 10px; border: 0; border-radius: 8px; background: none; color: var(--accent-text); font-weight: 600; font-size: 14px; text-align: left; }
.topic-more span { color: var(--text-3); font-weight: 400; }
.topic-more:hover { background: var(--bg-hover); }

/* ---- cards without an image: a text card */
.layout-cards .item.noimg .body { padding-top: 16px; }
.layout-cards .item.noimg .title { font-size: calc(var(--fs) * .95); }
.layout-cards .item.noimg .excerpt { -webkit-line-clamp: 7; }

/* ---- reader: never an empty page */
.reader-body .lede { font-size: 1.05em; color: var(--text-2); line-height: 1.6; }
.reader-body .fallback { display: grid; gap: 18px; justify-items: start; font-family: var(--sans); }
.reader-body .fallback p { margin: 0; }
.reader-body .loading { display: flex; align-items: center; justify-content: center; gap: 8px; font-family: var(--sans); }
.reader-body .loading .i { width: 16px; height: 16px; }

/* ---- favicons: black icons stay visible in dark mode */
[data-theme="dark"] .fav { background: #e8ebe9; padding: 1px; }

/* ---- settings → feeds */
.fr-tools { gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.fr-tools .search input { width: 240px; }
.fr-tip { color: var(--text-3); font-size: 14px; margin: 0 0 6px; }
.fr-group { display: flex; align-items: baseline; gap: 8px; margin: 18px 0 0; padding-bottom: 6px; border-bottom: 2px solid var(--line); font-weight: 650; color: var(--text); }
.fr-group small { color: var(--text-3); font-weight: 400; }
.fr-group[hidden], .feed-row[hidden] { display: none; }
.fr-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.folder-row { grid-template-columns: 1fr auto; }
.badge { font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--bg-hover); color: var(--text-2); white-space: nowrap; flex: none; }
.badge.busy { background: #fdf0d5; color: #7a4f00; }
[data-theme="dark"] .badge.busy { background: #3a2e14; color: #f2c56b; }
.tidy-row { padding: 6px 0; border-bottom: 1px solid var(--line); }
.tidy-row small { display: block; }

/* ---- toolbar: search toggle + More menu (shown on phones) */
.toolbar { position: relative; }
.search-toggle { display: none; }
.menu { position: absolute; right: 12px; top: calc(100% - 6px); z-index: 40; display: grid; min-width: 220px; padding: 6px; background: var(--bg-elev); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.menu[hidden] { display: none; }
.menu button { display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 10px; border-radius: 7px; color: var(--text); text-align: left; }
.menu button:hover { background: var(--bg-hover); }
.menu button.on { color: var(--accent-text); font-weight: 600; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 2px; }

@media (max-width: 720px) {
  .toolbar { flex-wrap: nowrap; gap: 6px; }
  .toolbar h1 { flex: 1 1 auto; }
  .toolbar .spacer { display: none; }
  .toolbar .search { display: none; }
  .search-toggle { display: inline-flex; }
  .bm-seg, #refresh-btn { display: none; }
  .toolbar h1 { font-size: 19px; }
  .toolbar .sub-date { display: none; }
  .toolbar .seg button { padding: 6px 8px; }
  /* searching: the box takes the whole bar */
  .toolbar.searching > :not(.search):not(.menu-btn) { display: none; }
  .toolbar.searching .search { display: block; flex: 1; }
  .toolbar.searching .search input { width: 100%; }
  /* reader: one row, Original as the main action */
  .reader-bar { flex-wrap: nowrap; gap: 2px; padding: 8px 10px; }
  .reader-bar .sep { margin: 0 2px; }
  .reader-bar .r-orig { padding: 6px 8px; }
  .fr-tools .search input { width: 100%; }
  .fr-tools .search { display: block; flex: 1 1 100%; }
  .feed-row { grid-template-columns: 1fr; }
}

/* ---- sidebar: hide/show and drag to resize (desktop) */
.brand .side-collapse { margin-left: auto; width: 30px; height: 30px; min-height: 30px; color: var(--text-3); }
.brand .side-collapse:hover { color: var(--text); }
.side-resizer { position: absolute; top: 0; right: -4px; width: 8px; height: 100%; cursor: col-resize; z-index: 6; touch-action: none; }
.side-resizer::after { content: ""; position: absolute; top: 0; bottom: 0; left: 3px; width: 2px; background: transparent; transition: background .15s; }
.side-resizer:hover::after, .side-resizer:focus-visible::after, .side-resizer.dragging::after { background: var(--accent); }
.side-resizer:focus-visible { outline: none; }
html.resizing, html.resizing * { cursor: col-resize !important; user-select: none !important; }
@media (min-width: 861px) {
  html.side-hidden .app { grid-template-columns: 1fr; }   /* the sidebar is out of the grid, so the main area is the only column */
  html.side-hidden .side { display: none; }
  html.side-hidden .menu-btn { display: inline-flex; }
}
@media (max-width: 860px) {
  .side-resizer, .brand .side-collapse { display: none; }
}

/* ---- settings: "how to export" help */
.howto { margin: 0 0 12px; color: var(--text-2); }
.howto summary { cursor: pointer; color: var(--accent-text); font-weight: 600; }
.howto ul { margin: 8px 0 0; padding-left: 20px; line-height: 1.8; }

/* ---- account (Settings → Account) */
.account-card { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 22px; }
.account-card .avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 16px; flex: none; }
.account-card b { display: block; word-break: break-all; }
.account-card small { color: var(--text-3); }
.pw-form { max-width: 360px; }
.acct-btn .avatar { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; }

/* sidebar ⋯ button and its menu (also opened with right-click) */
.nav-item .side-more { display: none; place-items: center; width: 22px; height: 22px; margin: -4px -6px -4px -2px; border-radius: 5px; color: var(--text-3); flex: none; }
.nav-item .side-more .i { width: 16px; height: 16px; }
.nav-item .side-more:hover { background: var(--bg-active); color: var(--text); }
.nav-item:hover .side-more, .nav-item.menu-open .side-more { display: grid; }
.nav-item:hover:has(.side-more) .count, .nav-item.menu-open .count { display: none; }
.nav-item.menu-open { background: var(--bg-hover); }
@media (hover: none) { .nav-item.active .side-more { display: grid; } .nav-item.active:has(.side-more) .count { display: none; } }
.side-menu { position: fixed; right: auto; top: 0; left: 0; min-width: 210px; z-index: 45; }
.menu button.danger { color: var(--danger); }
.menu button[disabled] { opacity: .45; cursor: default; background: none; }

/* People / Organizations inside each topic */
.src-group > .nav-item[data-src-head] { min-height: 28px; padding-top: 4px; padding-bottom: 4px; font-size: 12.5px; color: var(--text-2); }
.src-group > .nav-item[data-src-head].active { color: var(--text); }
.src-group > .nav-item[data-src-head] .i { width: 14px; height: 14px; color: var(--text-3); }
.folder-feeds .src-group > .nav-item:not([data-src-head]) { padding-left: 52px; }
.flat-feeds .src-group > .nav-item:not([data-src-head]) { padding-left: 28px; }
.src-group .src-chev { display: grid; margin: 0 -4px 0 -18px; }
.src-group .src-chev .chev { width: 13px; height: 13px; color: var(--text-3); transition: transform .15s; }
.src-group.collapsed .src-chev .chev { transform: rotate(-90deg); }
.flat-feeds .src-group > .nav-item[data-src-head] { padding-left: 26px; }
.src-h { cursor: pointer; user-select: none; border-radius: 6px; padding: 4px 4px; }
.src-h:hover { background: var(--bg-hover); color: var(--text-2); }
.src-h:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.src-h .chev { transition: transform .15s; }
.src-h.collapsed .chev { transform: rotate(-90deg); }
.src-h { display: flex; align-items: center; gap: 6px; margin: 14px 2px 6px; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); }
.src-h .i { width: 14px; height: 14px; }
.src-h small { font-weight: 500; letter-spacing: 0; }
.layout-cards .src-h { margin-top: 18px; }

/* ---- toolbar: View menu (what to show, layout, topics; Refresh on phones) */
.view-wrap { position: relative; }
.view-wrap .menu { right: 0; top: calc(100% + 6px); min-width: 230px; }
.menu-h { font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); padding: 8px 10px 4px; }
.menu button .tick { margin-left: auto; width: 16px; height: 16px; }
.menu button span { flex: 1; }
@media (min-width: 721px) { .menu .phone-only { display: none; } }


/* ---- the end of a list */
.list-end { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 40px 20px 20px; color: var(--text-3); text-align: center; }
.list-end b { color: var(--text-2); font-weight: 600; }
.list-end .btn { margin-top: 10px; }
.list-end.done svg { width: 28px; height: 28px; color: var(--accent); stroke-width: 2; margin-bottom: 4px; }
.list-end.done b { color: var(--text); font-size: 16px; }

/* ---- reader: Aa menu */
.aa-btn { font-weight: 700; font-family: var(--serif); font-size: 16px; padding: 6px 10px; }
.aa-menu { right: 14px; top: calc(100% + 2px); min-width: 250px; padding: 8px 10px 12px; gap: 2px; }
.aa-menu .menu-h { padding: 8px 2px 4px; }
.aa-menu .seg { display: flex; }
.aa-menu .seg button { flex: 1; justify-content: center; padding: 7px 8px; border-radius: 0; }
.aa-menu .seg .serif { font-family: var(--serif); }
.aa-size { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.aa-size b { font-variant-numeric: tabular-nums; }
.aa-size .btn { font-weight: 700; font-family: var(--serif); }

/* ---- wide screens: the reader sits beside the list instead of covering it */
@media (min-width: 1200px) {
  .reader { width: var(--reader-w); box-shadow: none; border-left: 1px solid var(--line); }
  .reader-backdrop { display: none; }
  html.reading .main { padding-right: var(--reader-w); }
  html.reading .item .excerpt, html.reading .thumb, html.reading .topic-srcs { display: none; }
  html.reading .layout-magazine .item { grid-template-columns: 1fr; padding-top: 14px; padding-bottom: 14px; }
  html.reading .layout-magazine .item .title { font-size: calc(var(--fs) * .86); margin-bottom: 2px; }
  html.reading .layout-cards .grid { grid-template-columns: 1fr; gap: 10px; }
  html.reading .list { padding-left: 12px; padding-right: 12px; }
  /* a narrow column: search behind its button, View without its label, one row */
  html.reading .toolbar { flex-wrap: nowrap; gap: 4px; }
  html.reading .toolbar .search, html.reading .bm-seg, html.reading .view-btn .lbl-wide, html.reading .toolbar .sub-date { display: none; }
  html.reading .search-toggle { display: inline-flex; }
  html.reading .toolbar.searching > :not(.search):not(.menu-btn) { display: none; }
  html.reading .toolbar.searching .search { display: block; flex: 1; }
  html.reading .toolbar.searching .search input { width: 100%; }
}
/* phones and narrow windows: the reader covers the screen; no shadow until it's open */
@media (max-width: 1199px) {
  .reader { box-shadow: none; }
  .reader.open { box-shadow: var(--shadow); }
}
@media (max-width: 420px) { .reader-bar .r-orig span, .reader-bar .sep { display: none; } }

/* ================================================================
   Newspaper look (after the Financial Times): paper background,
   serif headlines, heavy section rules, square corners, teal links.
   ================================================================ */
body { font-size: 15px; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
a { color: var(--accent-text); }
::selection { background: #f2c4a0; color: #33302e; }
[data-theme="dark"] ::selection { background: #5a3a2c; color: #f2e8de; }

/* square, quiet controls */
.btn, .seg, .search input, input[type=text], input[type=url], input[type=number], input[type=email], input[type=password], select, textarea,
.menu, .menu button, .nav-item, .item, .quick, .quick button, .topic-more, .notice, .bm-panel, .account-card,
.layout-list .item, .layout-cards .item, .layout-magazine .thumb, .content img, .content video, .content pre, .preview-text, .bookmarklet,
.toast, .toast-btn, kbd, .src-h, .chip, .badge { border-radius: var(--radius); }
dialog { border-radius: 4px; }
.btn { border-color: var(--line); background: transparent; font-weight: 500; }
.btn:hover { background: var(--bg-hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
[data-theme="dark"] .btn.primary { color: #10201f; }
.btn.primary:hover { filter: none; background: #0a5e66; border-color: #0a5e66; }
[data-theme="dark"] .btn.primary:hover { background: #7cccd3; border-color: #7cccd3; }
.seg { background: transparent; }
.seg button.on { background: var(--text); color: var(--bg); }
.search input, input[type=text], input[type=url], input[type=number], input[type=email], input[type=password], select, textarea { background: var(--bg-elev); border-color: var(--line); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.chip { background: transparent; border: 1px solid var(--line); color: var(--text-2); }

/* sidebar: a masthead and a wheat-coloured column */
.brand { font-family: var(--display); font-weight: 700; font-size: 22px; letter-spacing: -.01em; padding: 18px 18px 14px; border-bottom: 1px solid var(--line); margin: 0 0 6px; }
.brand .logo { border-radius: 2px; background: var(--claret); }
[data-theme="dark"] .brand .logo { background: #990f3d; }
.nav-item { font-size: 15px; }
.nav-item.active { background: var(--bg-active); font-weight: 600; box-shadow: inset 3px 0 0 var(--claret); }
.side-h { font-size: 12px; font-weight: 700; letter-spacing: .08em; color: var(--text); border-top: 1px solid var(--line); padding-top: 12px; margin-top: 16px; }
.side-h button { color: var(--text-3); }

/* toolbar: section title in the headline face */
.toolbar { border-bottom: 1px solid var(--line); min-height: 66px; }
.toolbar h1 { font-family: var(--display); font-weight: 400; font-size: 30px; letter-spacing: -.01em; line-height: 1.15; }
.toolbar .subtitle { font-size: 13px; color: var(--text-3); margin-top: 2px; }

/* topics: a heavy rule on top, headline-face name */
.list { max-width: 960px; padding-left: 24px; padding-right: 24px; }
.topic + .topic { margin-top: 30px; }
.topic-h { border-top: 3px solid var(--rule); border-bottom: 1px solid var(--line); padding: 10px 4px 9px; }
.topic:not(.open) .topic-h { border-bottom-color: transparent; }
.topic-name { font-family: var(--display); font-weight: 700; font-size: 21px; letter-spacing: -.005em; }
.topic-h:hover .topic-name { color: var(--claret); }
.topic.open .topic-h { background: var(--bg); }
.topic-more { color: var(--accent-text); }
.day-h { font-size: 12px; font-weight: 700; letter-spacing: .08em; color: var(--text); padding: 22px 4px 8px; border-bottom: 1px solid var(--line); margin-bottom: 2px; }

/* items: headlines in the serif face, regular weight; read ones fade back */
.item .title { font-family: var(--display); font-weight: 400; color: var(--text); letter-spacing: -.003em; }
.item.read .title { font-weight: 400; color: var(--text-3); }
.item .meta { font-size: 13px; }
.item .meta .src { color: var(--claret); font-weight: 600; }
.item.read .meta .src, .layout-list .item.read .meta .src { color: var(--text-3); font-weight: 500; }
.item .excerpt { font-family: var(--serif); color: var(--text-2); }
.item .dot { background: var(--claret); width: 6px; height: 6px; }
.item .star { color: var(--claret); }
.item.selected { box-shadow: inset 3px 0 0 var(--claret); background: var(--bg-active); }
.item:hover .title { color: var(--text-2); }
.item.read:hover .title { color: var(--text-2); }
.quick { background: var(--bg-elev); }

.layout-list .item { padding: 13px 12px 13px 10px; border-radius: 0; }
.layout-list .item + .item { border-top: 1px solid var(--line-soft); }
.layout-list .item .title { font-size: calc(var(--fs) * .95); font-weight: 400; line-height: 1.3; }
.layout-list .item.read .title { font-weight: 400; }
.layout-list .item .dot { margin-top: calc(var(--fs) * .95 * .65 - 3px); }
.layout-list .item .meta { margin-top: 4px; }
.layout-list .item .meta .excerpt { font-family: var(--sans); color: var(--text-3); }

.layout-magazine .item { padding: 22px 14px 22px 26px; border-bottom: 1px solid var(--line); }
.layout-magazine .item .title { font-size: calc(var(--fs) * 1.2); line-height: 1.2; letter-spacing: -.008em; }
.layout-magazine .item .excerpt { font-size: calc(var(--fs) * .85); line-height: 1.45; }
.layout-magazine .thumb { border-radius: 0; }
.layout-magazine .item .title .dot { margin: -3px 10px 0 -16px; }

.layout-cards .grid { gap: 28px 24px; }
.layout-cards .item { background: transparent; border: 0; border-top: 3px solid var(--rule); border-radius: 0; }
.layout-cards .item:hover { box-shadow: none; transform: none; background: var(--bg-hover); }
.layout-cards .item.selected { outline: 0; box-shadow: inset 0 -3px 0 var(--claret); }
.layout-cards .thumb { border-radius: 0; }
.layout-cards .body { padding: 12px 2px 14px; }
.layout-cards .item .title { font-size: calc(var(--fs) * 1.02); line-height: 1.25; }
.layout-cards .item .excerpt { font-size: 15px; line-height: 1.45; }

.src-h { color: var(--text); font-weight: 700; letter-spacing: .08em; }
.empty h2 { font-family: var(--display); font-weight: 400; font-size: 24px; }
.list-end.done svg { color: var(--claret); }
.list-end.done b { font-family: var(--display); font-weight: 400; font-size: 19px; }

/* reader: an article page */
.reader { background: var(--bg); }
.reader-bar { border-bottom: 1px solid var(--line); }
.reader-bar .btn { border-color: transparent; }
.reader-bar .btn:hover { border-color: var(--line); }
.reader-bar .btn.on { color: var(--claret); }
.reader-progress { height: 3px; background: transparent; }
.reader-progress span { background: var(--claret); }
.reader-body { padding-top: 36px; }
.reader-body .r-src { font-family: var(--sans); font-size: 14px; font-weight: 600; letter-spacing: .01em; }
.reader-body .r-src a, .reader-body .r-src span { color: var(--claret); text-decoration: none; }
.reader-body .r-src a:hover { text-decoration: underline; }
.reader-body h1, [data-rfont="serif"] .reader-body h1 { font-family: var(--display); font-weight: 400; font-size: calc(var(--fs) * 2); line-height: 1.12; letter-spacing: -.012em; margin: 12px 0 14px; color: var(--text); }
[data-rfont="sans"] .reader-body h1 { font-family: var(--sans); font-weight: 700; letter-spacing: -.02em; }
.reader-body .r-meta { font-family: var(--sans); font-size: 14px; color: var(--text-3); padding-bottom: 18px; margin-bottom: 26px; border-bottom: 1px solid var(--line); }
.reader-body .lede { font-family: var(--reader-font); font-size: 1.12em; line-height: 1.45; color: var(--text-2); }
.content { line-height: 1.62; color: var(--text); }
.content p { margin: 0 0 1.05em; }
.content a { color: var(--accent-text); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent-text) 45%, transparent); text-underline-offset: .18em; text-decoration-thickness: 1px; }
.content a:hover { color: var(--claret); text-decoration-color: currentColor; }
.content h1, .content h2, .content h3 { font-family: var(--display); font-weight: 700; letter-spacing: -.005em; margin: 1.6em 0 .5em; }
.content h2 { font-size: 1.25em; }
.content h3 { font-size: 1.08em; }
.content blockquote { border-left: 3px solid var(--claret); padding-left: 1.1em; color: var(--text-2); font-style: italic; }
.content img, .content video { border-radius: 0; }
.content figcaption { color: var(--text-3); margin-top: 6px; }
.content pre { background: var(--bg-side); border: 1px solid var(--line-soft); }
.content hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.content td, .content th { border-color: var(--line); }
.content th { background: var(--bg-side); text-align: left; }

/* dialogs and menus */
dialog { background: var(--bg); }
dialog::backdrop { background: rgba(51, 48, 46, .45); }
.dlg-h h2 { font-family: var(--display); font-weight: 400; font-size: 24px; }
.tabs button.on { border-color: var(--claret); }
.menu { background: var(--bg-elev); }
.menu button.on { color: var(--claret); }
.menu-h { color: var(--text); font-weight: 700; letter-spacing: .08em; }
.toast { border-radius: 2px; }
.toast-btn { color: #f2c4a0; }
.account-card .avatar, .acct-btn .avatar { background: var(--claret); }
[data-theme="dark"] .account-card .avatar, [data-theme="dark"] .acct-btn .avatar { background: #990f3d; }
.bookmarklet { background: var(--claret); }
[data-theme="dark"] .bookmarklet { background: #990f3d; }

/* Today, grouped by source: a rule and the source's name over its articles */
.source-h { display: flex; align-items: center; gap: 8px; text-transform: none; letter-spacing: 0; font-size: 15px; font-weight: 700;
  border-top: 3px solid var(--rule); border-bottom: 1px solid var(--line); padding: 10px 4px 9px; margin-top: 26px; }
.list > .source-h:first-child { margin-top: 10px; }
.source-h .fav, .source-h .fav-letter { width: 18px; height: 18px; }
.source-h small { color: var(--text-3); font-weight: 400; font-size: 13px; font-variant-numeric: tabular-nums; }

/* publish date on every article: easy to spot, numbers line up */
.item .meta .pub { flex: none; color: var(--text-2); font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.item.read .meta .pub { color: var(--text-3); font-weight: 400; }
.source-more { margin-left: auto; border: 0; background: none; padding: 3px 6px; border-radius: var(--radius); color: var(--accent-text); font-size: 13px; font-weight: 600; }
.source-more:hover { background: var(--bg-hover); text-decoration: underline; }
