/* schnews layout — colors come from themes.css (shared with snotes) */

* { box-sizing: border-box; }

/* font family + size come from fonts.css (--font-ui / --font-headline / --ui-font-size) */
html { font-size: var(--ui-font-size); }

/* headlines: story titles and pane headings; same as the UI font unless one is chosen */
.a-title, .tl-title, .reader h1, .list-header h2, .modal-head h2 {
  font-family: var(--font-headline);
}

body {
  margin: 0;
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Top bar ─────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--top-bg, var(--surface));
  color: var(--top-fg, inherit);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--primary);
}
.brand-icon { height: 60px; border-radius: 4px; }

/* Theme-aware logo switching */
.brand-icon-dark { display: none; }
.brand-icon-light { display: inline-block; }

html[data-mode="dark"] .brand-icon-light { display: none; }
html[data-mode="dark"] .brand-icon-dark { display: inline-block; }
.spacer { flex: 1; }
.topbar-search { flex: 0 1 360px; min-width: 160px; }
.topbar-search input {
  width: 100%;
  padding: 6px 10px;
  border-radius: var(--r-pill);
  background: var(--input-bg);
}
.topbar-search input:focus { border-color: var(--primary); outline: none; }
select, input, button {
  font: inherit;
  color: var(--text);
  background: var(--input-bg);
  border: var(--bw) solid;
  border-color: var(--sunken-bc);
  border-radius: var(--r-ctl);
  box-shadow: var(--sunken-sh);
  padding: 5px 8px;
}
button {
  cursor: pointer;
  background: var(--btn-bg, var(--bg-hover));
  border-color: var(--raised-bc);
  box-shadow: none;
}
button:hover { border-color: var(--hover-bc); }
/* bordered buttons get the theme's raised edge; the borderless ones (stars, row actions) stay flat */
.btn:not(.ghost), .icon-btn, .theme-btn, .tab, .mini, .loadmore, .login button { box-shadow: var(--raised-sh); }
html { scrollbar-color: var(--sb, auto); }
html[data-mode="dark"] { color-scheme: dark; }
html[data-mode="light"] { color-scheme: light; }
button.primary {
  background: var(--primary-bg);
  border-color: var(--primary-bg);
  color: var(--on-primary);
}

/* ── Three-pane layout ────────────────────────────────── */
.layout {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: min(var(--sidebar-w, 240px), 30vw) 7px min(var(--list-w, 380px), 40vw) 7px minmax(0, 1fr);
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}
.sidebar, .listpane, .reader, .calendarpane {
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
}
.reader { padding: 16px 22px; }

/* Reader panel hidden entirely: collapse the grid to sidebar + list. */
body.reader-off .reader,
body.reader-off .col-resizer[data-target="list"] {
  display: none;
}
@media (min-width: 901px) {
  body.reader-off .layout {
    grid-template-columns: min(var(--sidebar-w, 240px), 30vw) 7px minmax(0, 1fr);
  }
}

/* Timeline: no reader pane, the list pane takes its place as one wide column. */
body.timeline .reader,
body.timeline .col-resizer[data-target="list"] {
  display: none;
}
@media (min-width: 901px) {
  body.timeline .layout {
    grid-template-columns: min(var(--sidebar-w, 240px), 30vw) 7px minmax(0, 1fr);
  }
}

/* Calendar: no list or reader, the month takes the room beside the sidebar. */
body.calendar-mode .listpane,
body.calendar-mode .reader,
body.calendar-mode .col-resizer[data-target="list"] {
  display: none;
}
@media (min-width: 901px) {
  body.calendar-mode .layout {
    grid-template-columns: min(var(--sidebar-w, 240px), 30vw) 7px minmax(0, 1fr);
  }
}

/* ── Column resizers ──────────────────────────────────── */
.col-resizer {
  cursor: col-resize;
  touch-action: none;
  background: linear-gradient(to right, transparent 3px, var(--border) 3px, var(--border) 4px, transparent 4px);
}
.col-resizer:hover, .col-resizer.dragging {
  background: linear-gradient(to right, transparent 2px, var(--primary-bg) 2px, var(--primary-bg) 5px, transparent 5px);
}
body.resizing { user-select: none; cursor: col-resize; }
body.resizing .reader .r-content { pointer-events: none; }

/* ── Sidebar ──────────────────────────────────────────── */
.sidebar { background: var(--surface); padding: 10px 8px; }
.side-heading {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 6px 4px;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.side-heading .grow { flex: 1; }
.side-heading .mini {
  font-size: 1.25rem;
  line-height: 1;
  min-width: 32px;
  min-height: 32px;
  padding: 4px 8px;
  text-transform: none;
}
.node {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: var(--r-ctl);
  cursor: pointer;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.node:hover { background: var(--bg-hover); }
.node.active { background: var(--primary-bg); color: var(--on-primary); }
.node .label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.node .count {
  font-size: .8rem;
  color: var(--muted);
  background: var(--bg-hover);
  border-radius: var(--r-pill);
  padding: 0 6px;
}
.node.active .count { background: transparent; color: var(--on-primary); }
.node .favicon { width: 16px; height: 16px; flex: 0 0 16px; border-radius: 3px; }
.favicon-fallback {
  display: flex; align-items: center; justify-content: center;
  font-size: .65rem; font-weight: 700;
  color: var(--muted);
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 3px;
}
.node .favicon-fallback { width: 16px; height: 16px; flex: 0 0 16px; }
.node .star-toggle { visibility: hidden; background: none; border: none; padding: 0 2px; }
.node:hover .star-toggle, .node.starred .star-toggle { visibility: visible; }
.node .del { visibility: hidden; background: none; border: none; padding: 0 2px; }
.node .topic-refresh { visibility: hidden; background: none; border: none; padding: 0 2px; font-size: .8rem; }
.node:hover .topic-refresh, .node.active .topic-refresh { visibility: visible; }
.node:hover .del { visibility: visible; }
.kids { margin-left: 10px; border-left: 1px solid var(--border); padding-left: 4px; }

.mini {
  font-size: .8rem;
  padding: 2px 6px;
  border-radius: var(--r-ctl);
  color: var(--muted);
}
.mini:hover { color: var(--hover-fg); }
.node .markall { visibility: hidden; background: none; border: none; padding: 0 2px; font-size: .8rem; }
.node:hover .markall { visibility: visible; }
.node .twisty { width: 10px; font-size: .65rem; color: var(--muted); }
.favicon-fallback.topic { background: var(--primary); color: var(--on-primary); }
.empty.small { font-size: .86rem; padding: 4px 6px; text-align: left; }
.loadmore {
  display: block;
  width: calc(100% - 24px);
  margin: 10px 12px;
  color: var(--muted);
}

/* ── New-articles pill ────────────────────────────────── */
.new-articles {
  position: fixed;
  top: 84px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  background: var(--primary);
  color: var(--on-primary);
  border: none;
  border-radius: var(--r-pill);
  padding: 8px 16px;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--float-sh);
}
.new-articles:hover { filter: brightness(1.08); }

/* ── Article list ─────────────────────────────────────── */
.listpane { background: var(--bg); }
.list-header {
  position: sticky;
  top: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 2;
}
.list-header h2 {
  font-size: 1rem;
  margin: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.article {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.article:hover { background: var(--bg-hover); }
.article.active { background: var(--primary-bg); }
.article.read .a-title { font-weight: 400; color: var(--muted); }
.article.read .a-source, .article.read .a-time { color: var(--muted); }
/* the selected row wins over the read/unread dimming */
.article.active, .article.active .a-title,
.article.active .a-snippet, .article.active .a-source,
.article.active .a-time, .article.active .a-star,
.article.active .count { color: var(--on-primary); }
.a-body { flex: 1; min-width: 0; }
.a-title { font-weight: 600; margin-bottom: 2px; }
.a-snippet {
  color: var(--muted);
  font-size: .86rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.a-snippet mark {
  background: var(--accent-soft, rgba(255, 214, 0, .35));
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}
.a-meta {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: .8rem;
  color: var(--muted);
  margin-top: 3px;
}
.a-star { background: none; border: none; padding: 0 2px; color: var(--secondary); }
.a-favicon { width: 16px; height: 16px; flex: 0 0 16px; border-radius: 3px; margin-top: 2px; }
.empty { padding: 24px 12px; color: var(--muted); text-align: center; }

/* ── Login ────────────────────────────────────────────── */
.login {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}
.login.hidden { display: none; }
.login form { display: flex; flex-direction: column; gap: 8px; width: 240px; }
.login h1 { margin: 0; font-size: 1.3rem; color: var(--primary); }
.error { color: var(--danger); min-height: 1em; margin: 0; font-size: .86rem; }
.hidden { display: none !important; }

/* ── Theme selector ────────────────────────────────────── */
.theme-selector { position: relative; }
.theme-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px; border: var(--bw) solid var(--raised-bc); border-radius: var(--r-ctl);
  background: var(--btn-bg, var(--surface)); color: var(--text);
  font-size: .93rem; font-family: inherit; cursor: pointer;
  transition: background 0.15s;
}
.theme-btn:hover { background: var(--btn-bg-hover, var(--bg-hover)); }
.theme-label { color: var(--muted); white-space: nowrap; }
/* S chip on the top-bar theme button while a super theme is active */
.super-badge {
  padding: 0 4px; border-radius: 3px;
  background: var(--primary-bg); color: var(--on-primary);
  font-size: .6rem; font-weight: 800; line-height: 1.6;
}
.font-swatch { font-family: var(--font-ui); font-weight: 700; line-height: 1; }
.chevron { font-size: .65rem; color: var(--muted); }
.theme-popover {
  position: absolute; top: calc(100% + 6px); right: 0;
  background: var(--surface); border: var(--bwp) var(--bsp) var(--panel-bc);
  border-radius: var(--radius);
  box-shadow: var(--pop-sh);
  padding: 10px; min-width: 200px; z-index: 60;
}
.font-selector .theme-popover { min-width: 300px; max-height: calc(100vh - 80px); overflow-y: auto; }
.theme-pop-header {
  font-size: .8rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.6px;
  margin-bottom: 8px; padding: 0 4px;
}
.theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.theme-section {
  grid-column: 1 / -1;
  font-size: .8rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.6px;
  margin: 6px 4px 2px; padding-top: 6px;
  border-top: 1px solid var(--border);
}
.theme-section:first-child { border-top: none; padding-top: 0; margin-top: 0; }
.theme-option {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 8px; border: 1px solid transparent; border-radius: var(--r-btn);
  background: var(--bg); cursor: pointer; font-family: inherit;
  font-size: .93rem; color: var(--text);
  transition: background 0.12s, border-color 0.12s;
}
.theme-option:hover { border-color: var(--border); }
.theme-option.active { border-color: var(--primary); }
.theme-swatch { display: flex; gap: 2px; flex-shrink: 0; }
.theme-dot { width: 10px; height: 10px; border-radius: 2px; }
.mode-row {
  display: flex; gap: 4px; margin-bottom: 8px;
  background: var(--bg); padding: 3px; border-radius: var(--r-ctl);
  border: var(--bw) solid var(--sunken-bc); box-shadow: var(--sunken-sh);
}
.mode-btn {
  flex: 1; padding: 5px 0; border: none; border-radius: var(--r-btn);
  background: transparent; color: var(--muted); font-family: inherit;
  font-size: .86rem; cursor: pointer; transition: background 0.12s, color 0.12s;
}
.mode-btn.active { background: var(--surface); color: var(--text); }
.mode-btn { text-transform: var(--btn-case); letter-spacing: var(--btn-track); }
.font-list { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.font-option {
  display: flex; align-items: baseline; gap: 8px; width: 100%;
  padding: 5px 8px; border: 1px solid transparent; border-radius: var(--r-btn);
  background: transparent; color: var(--text); font-family: inherit;
  text-align: left; cursor: pointer; transition: background 0.12s, border-color 0.12s;
}
.font-option:hover { background: var(--bg-hover); }
.font-option.active { border-color: var(--primary); }
.font-option-label {
  flex: 0 0 8.2rem; color: var(--muted);
  font-size: .78rem; letter-spacing: 0.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.font-option-sample {
  flex: 1; min-width: 0; font-size: calc(var(--ui-font-size) * 1.15); line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.auto-panel { display: flex; flex-direction: column; gap: 4px; }
.auto-label { font-size: .8rem; color: var(--muted); padding: 0 4px; }

/* ── Theme panel: mode switch, thumbnail per theme, palette variants ── */
.theme-pop-wide { width: min(430px, calc(100vw - 16px)); max-height: calc(100vh - 80px); overflow-y: auto; }
.theme-panel { display: flex; flex-direction: column; gap: 10px; }
.theme-panel .mode-row { margin-bottom: 0; }
.theme-hint { margin: 0; padding: 0 4px; font-size: .8rem; color: var(--muted); }
.tn-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.theme-panel.settings .tn-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }
.tn-card {
  display: flex; flex-direction: column; gap: 6px; padding: 5px;
  background: transparent; border: 2px solid transparent; border-radius: var(--r-btn);
  box-shadow: none; color: var(--text); font-size: .8rem; text-align: center;
}
.tn-card:hover { background: var(--bg-hover); border-color: var(--border); }
.tn-card.active { border-color: var(--primary); }
.tn-card.active .tn-name { font-weight: 700; }
.tn-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* super-theme cards: an S badge and an Aa chip in the theme's own headline
   face; the .tn wrapper carries data-style/data-theme, so these read the
   card's tokens rather than the page's */
.tn-super {
  position: absolute; top: 3px; right: 3px; z-index: 2;
  padding: 0 5px; border: 1px solid var(--border); border-radius: 3px;
  background: var(--primary-bg); color: var(--on-primary);
  font-size: .6rem; font-weight: 800; line-height: 1.6;
}
.tn-font {
  position: absolute; top: 3px; left: 4px; z-index: 2;
  font-size: .72rem; line-height: 1.4; color: var(--primary);
}


/* A miniature three-column reader. The layers carry their own data-theme and
   data-style, so every colour and shape comes from the same tokens as the app. */
.tn { position: relative; display: block; aspect-ratio: 16 / 10; }
.tn-layer {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: min(var(--radius), 6px);
  box-shadow: var(--tn-sh);
}
/* Auto mode: light on the upper left, dark on the lower right. */
.tn-layer.alt { clip-path: polygon(100% 0, 100% 100%, 0 100%); }
.tn-layer i, .tn-layer b { display: block; }
.tn-top {
  flex: 0 0 19%; display: flex; align-items: center; gap: 4px; padding: 0 5px;
  background: var(--bar-bg, var(--top-bg, var(--surface)));
  border-bottom: 1px solid var(--border);
}
.tn-brand { flex: 0 0 15%; height: 38%; background: var(--bar-fg, var(--primary)); border-radius: 1px; }
.tn-search {
  flex: 0 1 38%; height: 52%; margin: 0 auto;
  background: var(--input-bg); border: 1px solid var(--border);
  border-radius: min(var(--r-pill), 5px);
}
.tn-btn {
  flex: 0 0 8%; height: 52%;
  background: var(--btn-bg, var(--bg-hover)); border: 1px solid var(--border);
  border-radius: min(var(--r-ctl), 2px);
}
.tn-body { flex: 1; display: grid; grid-template-columns: 25% 30% minmax(0, 1fr); min-height: 0; }
.tn-side {
  display: flex; flex-direction: column; gap: 3px; padding: 5px 4px;
  background: var(--surface); border-right: 1px solid var(--border);
}
.tn-n { height: 4px; width: 80%; background: var(--muted); opacity: .5; border-radius: 1px; }
.tn-n.on { width: 100%; height: 6px; background: var(--primary-bg); opacity: 1; border-radius: min(var(--r-ctl), 2px); }
.tn-n.s { width: 40%; background: var(--secondary); opacity: 1; }
.tn-list { display: flex; flex-direction: column; background: var(--bg); border-right: 1px solid var(--border); }
.tn-a { padding: 3px 4px 2px; border-bottom: 1px solid var(--border); }
.tn-a b { height: 3px; width: 90%; margin-bottom: 2px; background: var(--text); opacity: .75; }
.tn-a b + b { width: 65%; background: var(--muted); opacity: .5; }
.tn-a.on { background: var(--primary-bg); }
.tn-a.on b { background: var(--on-primary); opacity: .9; }
.tn-read { display: flex; flex-direction: column; gap: 3px; padding: 5px; background: var(--bg); }
.tn-read b { height: 3px; background: var(--muted); opacity: .55; }
.tn-read .tn-h { height: 5px; width: 72%; margin-bottom: 2px; background: var(--text); opacity: .85; }
.tn-read .w { width: 80%; }
.tn-read .tn-lk { width: 38%; background: var(--primary); opacity: 1; }

/* ── Icon buttons ──────────────────────────────────────── */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  flex: 0 0 2rem;
  padding: 0;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--muted);
  background: var(--btn-bg, var(--bg-hover));
  border: var(--bw) solid var(--raised-bc);
  border-radius: var(--r-icon);
}
.icon-btn:hover { color: var(--hover-fg); border-color: var(--hover-bc); }
.mini.primary { background: var(--primary-bg); border-color: var(--primary-bg); color: var(--on-primary); }
.mini.danger:hover { color: var(--danger); border-color: var(--danger); }
#menu-button { display: none; }

/* ── Modals ────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--scrim);
}
.modal-card {
  display: flex;
  flex-direction: column;
  width: min(440px, 100%);
  max-height: min(85vh, 720px);
  background: var(--surface);
  color: var(--text);
  border: var(--bwp) var(--bsp) var(--panel-bc);
  border-radius: var(--radius);
  box-shadow: var(--panel-sh);
  overflow: hidden;
}
.modal-card.manage {
  width: min(1100px, 100%);
  height: min(90vh, 880px);
  max-height: none;
}
.modal-card.settings {
  width: min(860px, 100%);
  height: min(85vh, 640px);
}
.modal-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bar-bg, transparent);
  color: var(--bar-fg, inherit);
  flex: 0 0 auto;
}
.modal-head h2 { margin: 0; font-size: 1.05rem; flex: 1; }
.modal-body {
  padding: 12px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Settings form ─────────────────────────────────────── */
.group + .group { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.group-title {
  margin: 0 0 10px;
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}
.field { display: block; margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.field-label { display: block; margin-bottom: 5px; font-size: .9rem; font-weight: 600; }
.field.row .field-label { margin-bottom: 0; }
.field-row { display: flex; align-items: center; gap: 8px; }
.field-row input[type="text"], .field-row input[type="number"] { flex: 1; min-width: 0; }
.field-row input[type="number"] { max-width: 7rem; }
.unit { color: var(--muted); font-size: .86rem; }
.hint { display: block; margin-top: 5px; color: var(--muted); font-size: .8rem; }
.control { margin-top: 2px; }
.switch { flex: 0 0 auto; width: 1.15rem; height: 1.15rem; accent-color: var(--primary); }
.auto-panel { display: flex; flex-direction: column; gap: 4px; }
.auto-panel + .auto-panel { margin-top: 8px; }
.auto-label { font-size: .8rem; color: var(--muted); }

/* ── Keyboard shortcuts help ───────────────────────────── */
.kbd-list { display: flex; flex-direction: column; gap: 14px; }
.kbd-group { display: flex; flex-direction: column; gap: 6px; }
.kbd-row { display: flex; align-items: center; gap: 8px; font-size: .9rem; }
.kbd-row > span:last-child { color: var(--text); }
.kbd-row em { color: var(--muted); font-style: normal; font-size: .82rem; }
.kbd {
  display: inline-block;
  min-width: 1.4rem;
  padding: 2px 7px;
  text-align: center;
  font-family: var(--font-mono, ui-monospace, "SF Mono", Menlo, Consolas, monospace);
  font-size: .78rem;
  color: var(--text);
  background: var(--surface-2, var(--surface));
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: var(--r-btn);
}

/* ── Subscription management ───────────────────────────── */
/* Folder-style tabs: the active one shares its background with the panel
   below and has no bottom edge, so it reads as part of the same sheet. */
.tabs {
  display: flex;
  gap: 2px;
  flex: 0 0 auto;
  padding: 10px 16px 0;
  overflow-x: auto;
  background: var(--bg);
  box-shadow: inset 0 -1px 0 var(--border);
}
.tab {
  flex: 0 0 auto;
  padding: 9px 20px;
  border: var(--bw) solid var(--raised-bc);
  border-radius: var(--r-tab) var(--r-tab) 0 0;
  background: var(--btn-bg, var(--bg-hover));
  color: var(--muted);
  font-size: .92rem;
  cursor: pointer;
  text-transform: var(--btn-case);
  letter-spacing: var(--btn-track);
}
.tab:hover { color: var(--text); border-color: var(--raised-bc); background: var(--surface); }
.tab.active,
.tab.active:hover {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  border-bottom-color: var(--surface);
  box-shadow: inset 0 3px 0 var(--tab-accent);
}
.manage-body { flex: 1 1 auto; min-height: 0; padding: 16px 20px 20px; }
.manage-error {
  flex: 0 0 auto;
  margin: 0;
  padding: 8px 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--danger);
}
.manage-error:empty { display: none; }
.tab-intro {
  margin: 0 0 16px;
  padding: 10px 14px;
  background: var(--bg);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.4;
}
.tab-intro strong { color: var(--text); }

/* Settings rows: what it is on the left, the control on the right. */
.setting {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(14rem, 26rem);
  gap: 6px 32px;
  align-items: center;
  padding: 16px 0;
}
.setting + .setting { border-top: 1px solid var(--border); }
.setting-text .field-label { margin-bottom: 3px; }
.setting-text .hint { margin: 0; }
.setting-control { min-width: 0; }
.setting-control .field-row input { padding: 8px 10px; }
.setting-control .control { margin: 0; }
.setting-control .auto-panel + .auto-panel { margin-top: 10px; }
.setting.stacked { grid-template-columns: minmax(0, 1fr); align-items: start; }
.setting.stacked .setting-control > input { width: 100%; padding: 8px 10px; }
.setting.stacked .form-actions { margin-top: 10px; flex-wrap: wrap; }
.setting.stacked .toolbar-count { margin-left: 4px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn:disabled:hover { border-color: var(--raised-bc); color: var(--text); background: var(--btn-bg, var(--surface)); }

/* Buttons: solid for the main action, outlined for the rest, red on hover for delete. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: var(--bw) solid var(--raised-bc);
  border-radius: var(--r-btn);
  background: var(--btn-bg, var(--surface));
  color: var(--text);
  font-size: .92rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  text-transform: var(--btn-case);
  letter-spacing: var(--btn-track);
}
.btn:hover { border-color: var(--hover-bc); color: var(--hover-fg); background: var(--btn-bg-hover, var(--bg-hover)); }
.btn.sm { padding: 6px 12px; font-size: .86rem; }
.btn.solid { background: var(--primary-bg); border-color: var(--primary-bg); color: var(--on-primary); }
.btn.solid:hover { background: var(--primary-bg); border-color: var(--primary-bg); color: var(--on-primary); filter: brightness(1.12); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); font-weight: 500; }
.btn.ghost:hover { background: var(--bg-hover); border-color: var(--border); color: var(--text); box-shadow: none; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { color: var(--danger); border-color: var(--danger); background: transparent; }

/* Forms: add/edit cards with a title and the buttons at the bottom. */
.add-form, .edit-form, .form-card {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 14px 16px;
  margin-bottom: 16px;
  background: var(--bg);
  border: var(--bw) solid var(--border);
  border-radius: var(--radius);
}
.add-form input, .edit-form input, .add-form select, .edit-form select {
  padding: 8px 10px;
}
.add-form > input { flex: 1 1 14rem; min-width: 0; }
.edit-form input { flex: 1 1 14rem; min-width: 0; }
.cat-select { max-width: 14rem; }
.form-title { margin: 0; font-size: 1rem; font-weight: 700; }
.form-actions { display: flex; gap: 8px; align-items: center; }
.form-actions.form-wide { margin-top: 4px; }

/* full-width row inside a wrapping form, used by the alert scope picker */
.form-wide { flex: 0 0 auto; width: 100%; min-width: 0; }

/* checkbox + label pairs in the bots form */
.check { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; cursor: pointer; }
.check-row { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.form-note { margin: 0; font-size: .82rem; color: var(--muted); line-height: 1.4; }

/* Bot form: two labelled columns, options underneath, actions last. */

/* ═══ nom-nom ═══════════════════════════════════════════════ */
.brand-icon { height: 58px; width: auto; border-radius: 0; display: block; }
.brand { text-decoration: none; }
.toolbar-count { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.placeholder { color: var(--muted); }
.reader a { color: var(--primary); }
.reader { container-type: inline-size; }

/* ── Recipe list ──────────────────────────────────────── */
.a-thumb {
  width: 58px; height: 58px; flex: 0 0 58px;
  border-radius: var(--r-btn); object-fit: cover; background: var(--bg-hover);
}
.a-thumb.favicon-fallback { font-size: 1.3rem; border-radius: var(--r-btn); }
.article.active .a-thumb.favicon-fallback { background: transparent; color: var(--on-primary); border-color: currentColor; }
.a-title { line-height: 1.25; }
.a-flag.fav { color: var(--secondary); }
.a-flag.want { color: var(--primary); font-size: .8em; }
.article.active .a-flag { color: inherit; }
.sort-select { font-size: .8rem; padding: 3px 6px; max-width: 8.5rem; }
mark { background: var(--accent-soft, rgba(255, 214, 0, .4)); color: inherit; border-radius: 2px; padding: 0 1px; }

/* ── Recipe reader ────────────────────────────────────── */
.r-content.recipe { max-width: 1100px; margin: 0 auto; }
.reader h1 { font-size: 1.7rem; line-height: 1.2; margin: 0 0 8px; font-family: var(--font-headline); }
.reader h2 {
  font-family: var(--font-headline); font-size: 1.05rem; margin: 0 0 10px;
  text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}
.r-head { margin-bottom: 14px; }
.r-meta { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; color: var(--muted); font-size: .86rem; }
.chip {
  font-size: .78rem; padding: 2px 9px; border-radius: var(--r-pill);
  background: var(--bg-hover); color: var(--text); border: 1px solid var(--border);
}
.chip.static { cursor: default; background: transparent; color: var(--primary); border-color: var(--primary); }
button.chip:hover { border-color: var(--primary); }
.offscreen { position: fixed; top: 0; left: -9999px; opacity: 0; }
.r-actions { margin-left: auto; display: inline-flex; gap: 6px; align-items: center; }
.fav-btn.on { color: var(--secondary); border-color: var(--secondary); }
.chip.planned { color: var(--primary); border-color: var(--primary); background: transparent; cursor: pointer; }

.r-gallery { margin: 0 0 16px; }
.r-photo {
  display: block; width: 100%; aspect-ratio: 3 / 2; max-height: 420px; object-fit: cover;
  border-radius: var(--radius); background: var(--bg-hover);
}
.r-top { display: grid; gap: 14px 24px; margin-bottom: 4px; }
.r-top-main { min-width: 0; }
@container (min-width: 720px) {
  .r-top.has-photo { grid-template-columns: minmax(0, 1fr) minmax(220px, 320px); align-items: start; }
  .r-top.has-photo .r-gallery { order: 2; margin: 0; }
}
.r-thumbs { display: flex; gap: 8px; margin-top: 8px; }
.r-thumb {
  width: 64px; height: 64px; object-fit: cover; cursor: pointer;
  border-radius: var(--r-btn); border: 2px solid transparent; opacity: .75;
}
.r-thumb:hover { opacity: 1; }
.r-thumb.active { border-color: var(--primary); opacity: 1; }

.r-facts { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 0 0 14px; padding: 10px 0; border-block: 1px solid var(--border); }
.r-top-main > :last-child { margin-bottom: 0; }
.fact { display: flex; flex-direction: column; gap: 1px; }
.fact-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.fact-value { font-weight: 600; }
.r-desc { color: var(--muted); font-style: italic; margin: 0 0 4px; max-width: 75ch; line-height: 1.5; }
.r-desc.clamped { display: -webkit-box; -webkit-line-clamp: 4; line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.r-desc-wrap { margin-bottom: 14px; }
.desc-toggle { padding-left: 0; color: var(--primary); }

.r-controls {
  display: flex; flex-wrap: wrap; gap: 12px 26px; align-items: flex-end;
  padding: 12px 14px; margin-bottom: 18px;
  background: var(--surface); border: var(--bw) solid var(--border); border-radius: var(--radius);
}
.ctl { display: flex; flex-direction: column; gap: 5px; }
.ctl-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.ctl .mode-row { margin-bottom: 0; }
.ctl .mode-btn { padding: 5px 12px; }
.stepper { display: inline-flex; align-items: center; gap: 8px; }
.stepper .icon-btn { font-size: 1.25rem; }
.stepper-value { min-width: 2.2rem; text-align: center; font-size: 1.25rem; }

.r-cols { display: grid; gap: 22px 36px; align-items: start; grid-template-columns: minmax(0, 1fr); }
@container (min-width: 720px) {
  .r-cols { grid-template-columns: minmax(260px, 2fr) minmax(0, 3fr); }
  .r-ingredients { position: sticky; top: 0; }
}

.ingredients { list-style: none; margin: 0; padding: 0; }
.ing, .ing-head { line-height: 1.45; }
.ing {
  display: flex; gap: 10px; align-items: baseline; padding: 6px 4px;
  border-bottom: 1px solid var(--border); cursor: pointer; border-radius: var(--r-btn);
}
.ing:hover { background: var(--bg-hover); }
.ing:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.tick {
  flex: 0 0 .95rem; height: .95rem; align-self: center;
  border: 2px solid var(--border); border-radius: 4px;
}
.ing.done .tick { background: var(--primary); border-color: var(--primary); box-shadow: inset 0 0 0 2px var(--surface); }
.ing.done .ing-text { text-decoration: line-through; color: var(--muted); }
.ing-head {
  margin: 14px 0 2px; font-weight: 700; color: var(--primary);
  font-family: var(--font-headline);
}
.ing-head:first-child { margin-top: 0; }
.chg {
  background: color-mix(in srgb, var(--primary) 16%, transparent);
  border-radius: 3px; padding: 0 2px; font-weight: 600;
}

.method { counter-reset: none; }
.step { display: flex; gap: 12px; margin: 0 0 14px; }
.step p { margin: 0; line-height: 1.6; max-width: 70ch; }
.step-n {
  flex: 0 0 1.7rem; height: 1.7rem; display: flex; align-items: center; justify-content: center;
  font-size: .85rem; font-weight: 700; border-radius: var(--r-round);
  background: var(--primary-bg); color: var(--on-primary);
}
.step-head { font-family: var(--font-headline); margin: 20px 0 10px; color: var(--primary); font-size: 1.05rem; }
.step-head:first-child { margin-top: 0; }

.r-notes, .r-nutrition { margin-top: 26px; max-width: 75ch; }
.prose p { margin: 0 0 .7em; line-height: 1.55; }
.nutrition { display: grid; grid-template-columns: max-content 1fr; gap: 3px 18px; margin: 0; }
.nutrition dt { font-weight: 600; }
.nutrition dd { margin: 0; color: var(--muted); }
.r-foot { margin-top: 30px; padding-top: 12px; border-top: 1px solid var(--border); color: var(--muted); font-size: .82rem; display: flex; flex-direction: column; gap: 5px; }
.r-foot-row { display: flex; gap: 8px; align-items: center; }
.r-foot-label { flex: 0 0 84px; text-transform: uppercase; letter-spacing: .04em; font-size: .7rem; }
.r-foot-url { overflow-wrap: anywhere; }

.r-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; min-height: 60%; text-align: center; padding: 30px 10px; }
.r-empty-logo { width: min(220px, 50%); height: auto; opacity: .9; }
.empty .btn { margin-top: 8px; }

/* ── Calendar ─────────────────────────────────────────── */
.calendarpane { background: var(--bg); padding: 16px 22px; container-type: inline-size; }
.cal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.cal-head h2 { margin: 0; flex: 1; font-family: var(--font-headline); font-size: 1.4rem; }
.cal-nav { display: flex; gap: 6px; align-items: center; }
.cal-nav .icon-btn { font-size: 1.25rem; line-height: 1; padding: 2px 12px; }
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.cal-dow {
  background: var(--surface); padding: 5px 8px; text-align: center;
  font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
}
.cal-cell {
  position: relative; display: flex; flex-direction: column; gap: 3px;
  min-height: 104px; padding: 4px 5px 5px; background: var(--bg); cursor: pointer; min-width: 0;
}
.cal-cell:hover { background: var(--bg-hover); }
.cal-cell.out { background: var(--surface); }
.cal-cell.out .cal-num { color: var(--muted); opacity: .7; }
.cal-cell.selected { box-shadow: inset 0 0 0 2px var(--primary); }
.cal-cell:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.cal-num {
  align-self: flex-start; min-width: 1.5rem; height: 1.5rem; padding: 0 5px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .82rem; font-weight: 600; border-radius: var(--r-pill);
}
.cal-cell.today .cal-num { background: var(--primary-bg); color: var(--on-primary); }
.cal-count { display: none; }
.cal-chips { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cal-chip {
  display: block; width: 100%; text-align: left; font-size: .76rem; line-height: 1.3;
  padding: 1px 6px; border-radius: var(--r-btn); border: none; box-shadow: none;
  background: color-mix(in srgb, var(--primary) 16%, transparent); color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-chip:hover { background: var(--primary-bg); color: var(--on-primary); }
.cal-more { font-size: .72rem; color: var(--muted); padding-left: 6px; }

.agenda { margin-top: 20px; max-width: 720px; }
.agenda-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.agenda-head h3 { margin: 0; flex: 1; font-family: var(--font-headline); font-size: 1.05rem; }
.agenda-row { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); }
.agenda-open {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 6px 4px; background: none; border: none; box-shadow: none; border-radius: var(--r-btn);
}
.agenda-open:hover { background: var(--bg-hover); }
.agenda-title { overflow: hidden; text-overflow: ellipsis; }
.a-thumb.sm { width: 40px; height: 40px; flex: 0 0 40px; font-size: 1rem; }
.mini.danger { font-size: 1.1rem; line-height: 1; padding: 2px 8px; }

.pick-input { width: 100%; margin-bottom: 8px; }
.modal-card.pick { height: min(85vh, 640px); }
.pick-results { display: flex; flex-direction: column; }
.pick-row {
  display: flex; align-items: center; gap: 10px; text-align: left; width: 100%;
  padding: 6px 4px; background: none; border: none; box-shadow: none;
  border-bottom: 1px solid var(--border); border-radius: 0;
}
.pick-row:hover { background: var(--bg-hover); }
.pick-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.pick-state { color: var(--primary); font-size: .82rem; white-space: nowrap; }
.pick-row.added .pick-title { color: var(--muted); }

.plan-recipe { margin: 0 0 12px; font-weight: 600; }
.plan-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.plan-form input { flex: 1 1 10rem; }
.plan-title { margin-top: 18px; }
.plan-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.plan-day { flex: 1; }
.plan-day.past { color: var(--muted); }

/* ── Import ───────────────────────────────────────────── */
.modal-card.import { width: min(620px, 100%); }
.import-form { display: flex; gap: 10px; align-items: center; margin: 12px 0; flex-wrap: wrap; }
.import-form input[type="file"] { flex: 1 1 14rem; min-width: 0; }
.import-progress { margin: 10px 0; }
.bar { height: 8px; background: var(--bg-hover); border-radius: var(--r-pill); overflow: hidden; border: 1px solid var(--border); }
.bar-fill { height: 100%; width: 0; background: var(--primary); transition: width .2s; }
.bar-fill.indeterminate { width: 40% !important; animation: slide 1.1s ease-in-out infinite alternate; }
@keyframes slide { from { margin-left: 0; } to { margin-left: 60%; } }
.import-history { display: flex; flex-direction: column; }
.import-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 2px 12px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: .86rem; }
.import-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.import-when { color: var(--muted); text-align: right; }
.import-sum { grid-column: 1 / -1; color: var(--muted); }
.import-sum.bad { color: var(--danger); }
code { font-family: var(--font-mono, ui-monospace, Menlo, monospace); font-size: .9em; background: var(--bg-hover); padding: 0 4px; border-radius: 3px; }

/* ── Mobile ───────────────────────────────────────────── */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar, .listpane, .reader, .calendarpane { grid-area: 1 / 1; }
  .col-resizer { display: none; }
  #menu-button { display: inline-flex; }

  /* one pane at a time: the browse drawer, the recipe list, or an open recipe */
  .sidebar, .reader { display: none; }
  body.nav-open .sidebar { display: block; }
  body.nav-open .listpane, body.nav-open .calendarpane { display: none; }
  body.reader-open .reader { display: block; }
  body.reader-open .listpane { display: none; }
  body.reader-open .sidebar { display: none; }

  .topbar { padding: 6px 8px; gap: 6px; position: relative; }
  .brand-icon { height: 34px; }
  .topbar-search { flex: 1 1 auto; }
  .topbar > .spacer { display: none; }
  .theme-label, .font-swatch, .theme-btn .chevron { display: none; }
  .theme-btn, .icon-btn { padding: 4px 8px; }
  .theme-selector { position: static; }
  .theme-popover { left: 8px; right: 8px; min-width: 0; }
  .theme-pop-wide { width: auto; }
  #help-button { display: none; }

  .node { padding: 9px 8px; }
  .article { padding: 11px 12px; }
  .list-header { padding: 8px 10px; flex-wrap: wrap; }
  .reader { padding: 12px 14px; }
  .reader h1 { font-size: 1.4rem; }
  .r-photo { aspect-ratio: 16 / 9; max-height: 220px; }
  .r-controls { gap: 12px 18px; }
  .reader-back { display: inline-flex; margin-bottom: 8px; }

  .calendarpane { padding: 10px 8px; }
  .cal-head h2 { font-size: 1.15rem; }
  .cal-cell { min-height: 52px; align-items: center; padding: 3px 2px; }
  .cal-chips { display: none; }
  .cal-count {
    display: inline-block; font-size: .7rem; line-height: 1; padding: 2px 6px;
    border-radius: var(--r-pill); background: color-mix(in srgb, var(--primary) 22%, transparent);
  }
  .cal-num { align-self: center; }
  .r-actions { margin-left: 0; }

  .modal { padding: 0; align-items: stretch; }
  .modal-card, .modal-card.import { width: 100%; max-width: none; max-height: 100%; height: 100%; border: none; border-radius: 0; }
  .modal-body { padding: 12px 14px calc(16px + env(safe-area-inset-bottom)); }
  .modal-head { padding: 10px 14px; }
}
@media (min-width: 901px) {
  .reader-back { display: none; }
  .reader-back.to-calendar { display: inline-flex; }
}

/* ── Print: just the recipe ───────────────────────────── */
@media print {
  html, body { height: auto; overflow: visible; background: #fff; color: #000; }
  .topbar, .sidebar, .listpane, .calendarpane, .col-resizer, .reader-back, .r-actions, .chip.planned, .r-controls, .r-thumbs, .modal { display: none !important; }
  body { display: block; }
  .layout { display: block; overflow: visible; }
  .reader { display: block !important; overflow: visible; padding: 0; }
  .r-cols { display: block; }
  .r-photo { max-height: 220px; }
  .ing { border-color: #ccc; break-inside: avoid; }
  .step { break-inside: avoid; }
  .chg { background: none; font-weight: inherit; }
  .reader a { color: inherit; text-decoration: none; }
}

/* command-line client modal */
.modal-card.cli { width: min(640px, 100%); }
.cli-install-row { display: flex; align-items: stretch; gap: 8px; margin: 8px 0; }
.cli-install-cmd { flex: 1; min-width: 0; padding: 8px 12px; border-radius: 6px; background: var(--bg); border: 1px solid var(--border); font-family: ui-monospace, monospace; font-size: .85rem; user-select: all; overflow-x: auto; white-space: nowrap; }
.cli-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.cli-table td { padding: 5px 8px 5px 0; vertical-align: top; border-bottom: 1px solid var(--border); }
.cli-table td:first-child { white-space: nowrap; }

/* Share-link page: just the recipe */
body.shared-mode .sidebar,
body.shared-mode .listpane,
body.shared-mode .col-resizer,
body.shared-mode .topbar-search,
body.shared-mode #menu-button,
body.shared-mode #import-button,
body.shared-mode #cli-button,
body.shared-mode #help-button {
  display: none;
}
body.shared-mode .layout { grid-template-columns: minmax(0, 1fr); }
body.shared-mode .reader { display: block; }

/* share modal */
.modal-card.send { width: min(620px, 100%); }
.send-expiry { display: flex; align-items: center; gap: 8px; }
.send-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid var(--border); }
.send-url { flex: 1 1 14rem; min-width: 0; font-family: var(--font-mono, ui-monospace, Menlo, monospace); font-size: .85rem; }
.send-meta { flex: 1 0 100%; color: var(--muted); font-size: .82rem; }
