/* mailz layout. Base (topbar, panes, sidebar, modals, buttons) is shared with schnews and
   reads the same design tokens, so every theme style in theme-styles.css applies. */
* { 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 */
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 {
  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. */
@media (min-width: 901px) {
  
}
/* ── 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 .del { visibility: hidden; background: none; border: none; padding: 0 2px; }
.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 .twisty { width: 10px; font-size: .65rem; color: var(--muted); }
.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 ────────────────────────────────── */
/* ── 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;
  flex-direction: column;
  gap: 6px;
  z-index: 2;
}
.list-header h2 {
  font-size: 1rem;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.list-actions:empty { display: none; }
.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 */
.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;
}
.empty { padding: 24px 12px; color: var(--muted); text-align: center; }
/* ── Reader ───────────────────────────────────────────── */
.reader h1 { font-size: 1.45rem; margin: 0 0 4px; }
.r-head { border-bottom: 1px solid var(--border); padding-bottom: 10px; margin-bottom: 14px; }
.r-meta { color: var(--muted); font-size: .86rem; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
/* Story body styling, shared by the reader's own body and by the focused post
   inside a Mastodon thread — both render sanitized entry HTML with media, link
   cards and quotes, so the rules cannot be scoped to one of them. */
.reader a { color: var(--primary); }
/* the status the reader is on — the one the conversation is anchored to */
.placeholder { color: var(--muted); }
/* ── 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; }
/* the ▾ is missing from pixel and display faces (VT323 and the like) and falls back to a speck */
.chevron { font-family: system-ui, "Segoe UI Symbol", "DejaVu Sans", sans-serif; 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); }
/* ── 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); }
/* ── 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); }
/* ── 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.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. */
.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. */
.form-head { margin-bottom: 16px; }
.form-head .form-title { font-size: 1.15rem; margin-bottom: 2px; }
/* Toolbar above a list: find field, count, bulk actions. Stays put while the list scrolls. */
.list-toolbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 4px 0 8px;
  background: var(--surface);
}
.list-toolbar .find { flex: 1 1 auto; min-width: 0; padding: 8px 12px; }
.toolbar-count { flex: 0 0 auto; color: var(--muted); font-size: .86rem; white-space: nowrap; }
.rows { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 14px;
  background: var(--bg);
  border: var(--bw) solid var(--border);
  border-radius: var(--radius);
}
.row.nested { margin-left: calc(var(--depth, 0) * 1.75rem); }
.row-main { display: flex; align-items: center; gap: 10px; flex: 1 1 auto; min-width: 0; }
.row-text { flex: 1; min-width: 0; }
.row-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub {
  color: var(--muted);
  font-size: .8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-error {
  color: var(--danger);
  font-size: .78rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-count {
  flex: 0 0 auto;
  font-size: .8rem;
  color: var(--muted);
  background: var(--bg-hover);
  border-radius: var(--r-pill);
  padding: 0 7px;
}
.row-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.row-actions .cat-select { padding: 5px 8px; max-width: 12rem; }
/* ── Mobile ────────────────────────────────────────────── */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar, .listpane, .reader { grid-area: 1 / 1; }
  .col-resizer { display: none; }
  .sidebar, .reader { display: none; }
  body.nav-open .sidebar { display: block; }
  body.nav-open .listpane { display: none; }
  body.reader-open .reader { display: block; }
  body.reader-open .listpane { display: none; }
  .topbar { padding: 6px 8px; gap: 6px; }
  .brand-icon { height: 30px; }
  .brand { display: none; }
  .topbar-search { flex: 1 1 auto; }
  .theme-label, .font-swatch, .theme-btn .chevron { display: none; }
  .theme-btn, .icon-btn { padding: 4px 8px; }
  .topbar { position: relative; }
  .theme-selector { position: static; }
  .theme-popover { left: 8px; right: 8px; min-width: 0; }
  .theme-pop-wide { width: auto; }
  .mini { padding: 6px 10px; font-size: .85rem; }
  .side-heading .mini { font-size: 1.4rem; min-width: 40px; min-height: 40px; padding: 6px 10px; }
  .node { padding: 9px 8px; }
  .article { padding: 11px 12px; }
  .list-header { padding: 8px 10px; }
  .reader { padding: 12px 14px; }
  .reader h1 { font-size: 1.25rem; }
  .reader .r-content { max-width: none; }
  .reader-back {
    display: inline-flex;
    margin-bottom: 8px;
    font-size: 1rem;
  }
  .modal { padding: 0; align-items: stretch; }
  .modal-card, .modal-card.manage, .modal-card.settings, .modal-card.stats {
    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; }
  .manage-body { padding-left: 14px; padding-right: 14px; }
  .setting { grid-template-columns: minmax(0, 1fr); }
  .tabs { padding: 8px 10px 0; }
  .tab { padding: 9px 14px; }
  .manage-error { padding: 8px 14px; }
  .form-actions .btn { flex: 1 1 auto; }
  .list-toolbar { flex-wrap: wrap; }
  .list-toolbar .find { flex: 1 1 100%; }
  .list-toolbar .btn { flex: 1 1 auto; }
  .row { flex-direction: column; align-items: stretch; gap: 10px; }
  .row-actions { gap: 8px; }
  .row-actions .btn, .row-actions .cat-select { flex: 1 1 auto; max-width: none; }
  .row-title, .row-sub, .row-error { white-space: normal; }
}
@media (min-width: 901px) {
  .reader-back { display: none; }
}
/* keep the layout usable in landscape phones */
@media (max-width: 900px) and (orientation: landscape) {
  .modal { align-items: center; }
  .modal-card { max-height: 92vh; height: auto; }
}
/* ── CLI install modal ─────────────────────────────────── */
/* ═══ mailz additions ═════════════════════════════════════ */
.brand { font-size: 1.1rem; }
.brand-icon { height: 46px; width: auto; display: block; border-radius: 0; }
.login-logo { width: 220px; max-width: 100%; align-self: center; margin-bottom: 8px; }
/* the logo's dark outline disappears on dark themes; give it a faint light edge */
html[data-mode="dark"] :is(.brand-icon, .login-logo) { filter: drop-shadow(0 0 1px rgba(255, 255, 255, .55)); }
#menu-button { display: none; }
.who { font-size: .85rem; }
.topbar-search { position: relative; display: flex; gap: 6px; align-items: center; }
.topbar-search input { flex: 1; }
.search-help {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 30; margin-top: 6px; padding: 10px 14px;
  background: var(--surface); border: var(--bwp) var(--bsp) var(--panel-bc); border-radius: var(--radius);
  box-shadow: var(--pop-sh); font-size: .88rem; min-width: 320px;
}
.search-help ul { margin: 6px 0; padding-left: 18px; }
.search-help li { margin: 3px 0; }
.search-help code { background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; cursor: pointer; margin-right: 4px; }
.muted { color: var(--muted); }
.error { color: var(--danger); }
.ok { color: var(--primary); }

/* virtualised message list: fixed-height absolutely positioned rows */
.vlist { position: relative; }
/* !important: theme styles restyle .article (margins, relative positioning), which would break
   the fixed-height row maths the virtual list depends on */
.listpane .vlist .article {
  position: absolute !important; left: 0 !important; right: 0 !important;
  height: 74px !important; margin: 0 !important; overflow: hidden;
  flex-direction: column; gap: 2px; justify-content: center;
}
#list-empty:empty { display: none; }
.m-top { display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.m-from { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-flags { font-size: .75rem; }
.a-time { font-size: .78rem; color: var(--muted); white-space: nowrap; }
.vlist .article .a-title { font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 0; }
.vlist .article .a-snippet { -webkit-line-clamp: 1; line-clamp: 1; font-size: .82rem; }
.vlist .article.active .a-time, .vlist .article.active .a-snippet { color: inherit; opacity: .85; }
.list-actions { font-size: .8rem; }

/* reader: header, toolbar, sandboxed body filling the pane */
.reader { flex-direction: column; overflow: hidden; padding: 14px 18px; }
@media (min-width: 901px) { .reader { display: flex; } }
.reader .r-head { flex: 0 0 auto; }
.r-meta { gap: 8px; align-items: baseline; margin-top: 1px; }
.r-k { flex: 0 0 4.5rem; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.r-toolbar { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 10px; flex: 0 0 auto; }
.r-toolbar .mini, .r-shot .mini { text-decoration: none; display: inline-flex; align-items: center; }
.r-shot { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 8px 10px; margin: 0 0 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); font-size: .88rem; flex: 0 0 auto; }
.r-shot.hidden { display: none; }
.r-panel { flex-direction: column; align-items: stretch; }
.r-panel.hidden { display: none; }
.frow2 { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 2px 0; }
.link-url { flex: 1 1 18rem; min-width: 0; font-family: ui-monospace, monospace; font-size: .8rem; }
.chk { display: inline-flex; gap: 6px; align-items: center; }
.r-atts { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 10px; flex: 0 0 auto; }
.chip { border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px; font-size: .82rem; background: var(--surface); }
.r-frame { flex: 1 1 auto; min-height: 240px; width: 100%; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.reader-back { display: none; }
.placeholder { padding: 24px; }

/* pages shown in modals */
.pg section { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; }
.pg h2 { margin: 14px 0 6px; font-size: 1.05rem; }
.pg h2:first-child { margin-top: 0; }
.pg table { width: 100%; border-collapse: collapse; }
.pg th, .pg td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.pg th { color: var(--muted); font-weight: 500; font-size: .82rem; }
.pg td.num, .pg th.num { text-align: right; font-variant-numeric: tabular-nums; }
.pg label { display: grid; gap: 3px; color: var(--muted); font-size: .82rem; }
.pg .frow { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin: 6px 0; }
.pg input, .pg select { padding: 6px 8px; }
.pg details { margin: 6px 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 8px; }
.card { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; background: var(--surface); }
.card b { display: block; font-size: 1.45rem; }
.chart { display: flex; align-items: flex-end; gap: 2px; height: 7rem; margin: 8px 0; }
.chart div { flex: 1; background: var(--primary); min-height: 1px; border-radius: 2px 2px 0 0; }
.seg { display: flex; gap: 6px; margin: 6px 0; flex-wrap: wrap; }
.seg button.active { background: var(--primary-bg); color: var(--on-primary); border-color: var(--primary-bg); }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 80; background: var(--primary-bg); color: var(--on-primary); padding: 8px 16px; border-radius: var(--radius); box-shadow: var(--pop-sh); }
.toast.click { cursor: pointer; }
.fb-group { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; margin: 6px 0; background: var(--bg); }
.fb-group.nested { margin-left: 18px; border-left: 3px solid var(--primary); background: var(--surface); }
.fb-group.err, .fb-rule.err { outline: 2px solid var(--danger); outline-offset: 1px; }
.fb-head, .fb-foot { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 4px 0; }
.fb-rule { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 5px 0; padding: 4px 0; border-bottom: 1px dashed var(--border); }
.fb-value { flex: 1 1 14rem; min-width: 8rem; }
.fb-msg { flex: 1 0 100%; font-size: .85rem; }
.pg .chk { display: inline-flex; gap: 4px; align-items: center; color: var(--text); font-size: .85rem; }
.toast.err { background: var(--danger); color: #fff; }

@media (max-width: 900px) {
  #menu-button { display: inline-flex; }
  body.reader-open .reader { display: flex; }
  .reader-back { display: inline-flex; margin-bottom: 8px; align-self: flex-start; }
  .who, #font-selector, .topbar .spacer, #search-help-btn { display: none; }
  .topbar { flex-wrap: wrap; }
  .topbar-search { flex: 1 1 140px; }
  #menu-button { order: -1; }
  .reader { padding: 10px 12px; }
  .r-frame { min-height: 50vh; }
}
@media print { .topbar, .sidebar, .listpane, .col-resizer, .r-toolbar, .r-shot, .reader-back { display: none !important; } }
