:root {
  --bg: #0F1114;
  --rail: #15181C;
  --col: #1C1F24;
  --col-2: #25292F;
  --rule: #2C3037;
  --text: #E4E7EB;
  --muted: #8A919B;
  --signal: #F2B544;
  --signal-ink: #1A1300;
  --link: #5DAEF0;
  --like: #E0245E;
  --danger: #F08A8A;
  --col-w: 310px;
  --radius: 4px;
  color-scheme: dark;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
:root[data-theme="light"] {
  --bg: #D9DEE4; --rail: #1C1F24; --col: #FFFFFF; --col-2: #F2F4F6; --rule: #E3E7EB;
  --text: #14171A; --muted: #657786; --signal: #B06A00; --signal-ink: #FFFFFF;
  --link: #1B75C4; --danger: #B3261E; color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]):not([data-theme="light"]) {
    --bg: #D9DEE4; --rail: #1C1F24; --col: #FFFFFF; --col-2: #F2F4F6; --rule: #E3E7EB;
    --text: #14171A; --muted: #657786; --signal: #B06A00; --signal-ink: #FFFFFF;
    --link: #1B75C4; --danger: #B3261E; color-scheme: light;
  }
}
*, *::before, *::after { box-sizing: inherit; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.4;
  display: flex; flex-direction: column; overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }

/* ---------- left rail ---------- */
.app { flex: 1; min-height: 0; display: flex; }
.rail {
  flex: none; width: 56px; background: var(--rail); color: #AAB2BD;
  display: flex; flex-direction: column; align-items: stretch; gap: 2px;
  padding: 8px 6px; overflow: hidden; transition: width 0.15s;
}
.rail.open { width: 200px; }
.rail-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; white-space: nowrap; }
.rail-collapse {
  margin-left: auto; flex: none; width: 30px; height: 30px; display: none; place-items: center;
  border: 0; border-radius: 6px; background: transparent; color: #AAB2BD; cursor: pointer;
}
.rail-collapse svg { width: 18px; height: 18px; }
.rail-collapse:hover { background: #262A31; color: #fff; }
.rail.open .rail-collapse { display: grid; }
.rail.open .rail-mark { cursor: default; }
.rail-mark {
  flex: none; width: 44px; height: 40px; display: grid; place-items: center; border: 0; cursor: pointer;
  font-weight: 700; font-size: 18px; color: #fff; background: var(--link); border-radius: 8px;
}
.brand-name { font-weight: 700; font-size: 17px; color: #fff; }
.rail-heading {
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: #7C8591; padding: 10px 12px 0; white-space: nowrap; height: 0; overflow: hidden;
}
.rail.open .rail-heading { height: auto; }
.col-glyph { display: grid; place-items: center; color: var(--accent, currentColor); }
.col-glyph svg { width: 20px; height: 20px; }
.rail-tip {
  position: fixed; z-index: 60; pointer-events: none;
  background: #0B0D10; color: #fff; font-size: 13px; font-weight: 500;
  padding: 6px 10px; border-radius: 6px; white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
}
.rail-tip::before {
  content: ""; position: absolute; left: -5px; top: 50%; transform: translateY(-50%);
  border: 5px solid transparent; border-left: 0; border-right-color: #0B0D10;
}
.rail-cols { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; min-height: 0; flex: 0 1 auto; border-top: 1px solid #2A2E35; border-bottom: 1px solid #2A2E35; padding: 4px 0; margin: 4px 0; }
.rail-cols:empty { display: none; }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.rail-btn {
  position: relative; display: flex; align-items: center; gap: 12px;
  height: 40px; padding: 0 12px; border: 0; border-radius: 6px;
  background: transparent; color: inherit; cursor: pointer; white-space: nowrap; text-align: left;
}
.rail-btn svg { flex: none; width: 20px; height: 20px; }
.rail-btn:hover { background: #262A31; color: #fff; }
.rail-btn[aria-current="true"] { color: #fff; box-shadow: inset 3px 0 0 var(--accent, var(--link)); background: #20242A; }
.rail-btn .label { font-size: 14px; opacity: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.rail.open .rail-btn .label { opacity: 1; }
.rail-btn .count {
  position: absolute; top: 4px; left: 26px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: var(--signal); color: var(--signal-ink); font-size: 10px; font-weight: 700;
  display: grid; place-items: center;
}
.rail-btn.spinning svg { animation: spin 0.9s linear infinite; }
#railExpand svg { transition: transform 0.15s; }
.rail.open #railExpand svg { transform: rotate(180deg); }

.pop {
  position: fixed; left: 64px; z-index: 40; width: 300px;
  background: var(--col); color: var(--text); border: 1px solid var(--rule); border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.45); padding: 10px; display: grid; gap: 8px;
}
.rail.open ~ * .pop, body.rail-open .pop { left: 208px; }
.pop form { display: grid; gap: 8px; }
.pop .deck-row { display: flex; align-items: center; gap: 4px; }
.pop .deck-row button:first-child { flex: 1; text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: 6px; cursor: pointer; color: var(--text); }
.pop .deck-row button:first-child:hover { background: var(--col-2); }
.pop .deck-row button[aria-current="true"] { font-weight: 700; box-shadow: inset 3px 0 0 var(--link); }
.pop .new-deck { border: 1px dashed var(--rule); background: transparent; color: var(--muted); border-radius: 6px; padding: 8px; cursor: pointer; }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px;
  border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--col-2); color: var(--text); }
.icon-btn.spinning svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.add-btn, .primary {
  border: 0; border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 600;
  background: var(--signal); color: var(--signal-ink);
}

/* ---------- deck and columns ---------- */
.deck {
  flex: 1; min-width: 0; min-height: 0;
  display: flex; gap: 8px; padding: 8px;
  overflow-x: auto; overflow-y: hidden; scroll-behavior: smooth; background: var(--bg);
}
.column {
  flex: none; width: var(--col-w);
  display: flex; flex-direction: column; min-height: 0;
  background: var(--col); border-radius: var(--radius); position: relative;
}
.column.narrow { --col-w: 270px; }
.column.wide { --col-w: 400px; }
.col-head {
  display: flex; align-items: center; gap: 6px; height: 50px; flex: none;
  padding: 0 4px 0 12px; border-bottom: 1px solid var(--rule);
}
.col-icon { flex: none; color: var(--accent, var(--muted)); display: grid; place-items: center; }
.col-icon svg { width: 19px; height: 19px; }
.col-title { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 6px; }
.col-title h2 { margin: 0; font-size: 16px; font-weight: 700; white-space: nowrap; flex: none; max-width: 70%; overflow: hidden; text-overflow: ellipsis; }
.col-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.col-sub .bad { color: var(--danger); }
.col-head .icon-btn { width: 30px; height: 30px; }
.col-head .icon-btn svg { width: 18px; height: 18px; }
.col-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--rule) transparent; }
.new-pill {
  position: absolute; top: 60px; left: 50%; transform: translateX(-50%);
  z-index: 2; border: 0; border-radius: 999px; padding: 5px 14px;
  background: var(--link); color: #fff; font-weight: 600; font-size: 13px;
  cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,0.35);
}

/* settings panel inside a column */
.col-settings {
  padding: 12px; border-bottom: 1px solid var(--rule); background: var(--col-2);
  display: grid; gap: 10px; font-size: 14px; max-height: 60%; overflow-y: auto;
}
.col-settings > *, .col-settings label, .col-settings .row > * { min-width: 0; }
.col-settings .src { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.col-settings .src span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-settings .src .state { flex: none; max-width: 55%; color: var(--muted); }
.col-settings .src .state.bad { color: var(--danger); }
.swatches { display: flex; gap: 6px; }
.swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.swatch[aria-pressed="true"] { border-color: var(--text); }

/* ---------- items: avatar, name line, text, media, action row ---------- */
.item {
  display: grid; grid-template-columns: 40px 1fr; column-gap: 10px;
  padding: 10px 12px 6px; border-bottom: 1px solid var(--rule); position: relative;
}
.item:hover { background: var(--col-2); }
.item.fresh { box-shadow: inset 3px 0 0 var(--link); }
.item-link { color: inherit; text-decoration: none; display: block; grid-column: 2; min-width: 0; }
.item-link::after { content: ""; position: absolute; inset: 0; }
.item-link:focus-visible { outline: none; }
.item:has(.item-link:focus-visible) { outline: 2px solid var(--link); outline-offset: -2px; }
.avatar {
  grid-row: 1 / span 3; width: 40px; height: 40px; border-radius: 50%; position: relative; overflow: hidden;
  display: grid; place-items: center; font-weight: 700; font-size: 16px; color: #fff;
  background: var(--av, #3A4A5E);
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #fff; padding: 7px; }
.meta { display: flex; align-items: baseline; gap: 5px; font-size: 13.5px; min-width: 0; line-height: 1.3; }
.meta .src-name { font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; min-width: 0; }
.meta .handle { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1 1 0; min-width: 0; }
.meta time { color: var(--muted); flex: none; font-size: 12.5px; }
.via { font-size: 12.5px; color: var(--muted); margin-bottom: 1px; }
.headline { font-weight: 400; font-size: 14.5px; line-height: 1.4; margin: 2px 0 0; overflow-wrap: anywhere; }
.post { font-size: 14.5px; line-height: 1.4; margin: 2px 0 0; white-space: pre-line; overflow-wrap: anywhere; }
.snippet { margin: 4px 0 0; font-size: 13.5px; color: var(--muted); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.thumb { grid-column: 2; display: block; width: 100%; max-height: 170px; object-fit: cover; border-radius: 6px; margin-top: 8px; background: var(--col-2); }
.item-actions { grid-column: 2; display: flex; gap: 18px; margin: 4px 0 0 -7px; z-index: 1; position: relative; width: max-content; }
.item-actions button { width: 28px; height: 26px; color: var(--muted); }
.item-actions button svg { width: 16px; height: 16px; }
.item-actions button:hover { color: var(--link); background: transparent; }
.item-actions button[aria-pressed="true"] { color: var(--like); }
.item-actions button[aria-pressed="true"] svg { fill: currentColor; }
.item.read .headline, .item.read .post { color: var(--muted); }
body.compact .snippet, body.compact .thumb { display: none; }
body.compact .item { padding-top: 7px; }

.empty { padding: 28px 16px; color: var(--muted); font-size: 14px; }
.empty strong { color: var(--text); display: block; margin-bottom: 4px; }
.skeleton { height: 64px; margin: 12px; border-radius: 6px; background: var(--col-2); }

.add-column-slot {
  flex: none; width: 190px; border: 1.5px dashed var(--rule); border-radius: var(--radius);
  background: transparent; color: var(--muted); cursor: pointer; font-weight: 600;
}
.add-column-slot:hover { color: var(--text); border-color: var(--muted); }

/* ---------- dialogs ---------- */
dialog.sheet {
  width: min(620px, 94vw); max-height: 88vh; padding: 0; border: 1px solid var(--rule);
  border-radius: 14px; background: var(--col); color: var(--text); overflow: hidden;
}
dialog.sheet[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: rgba(6, 12, 22, 0.6); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; }
.sheet-head h2 { margin: 0; font-size: 18px; }
.tabs { display: flex; gap: 4px; padding: 6px 12px 0; overflow-x: auto; border-bottom: 1px solid var(--rule); flex: none; }
.tabs button {
  border: 0; background: transparent; padding: 8px 10px; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500;
}
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--signal); }
.tabpanel, .settings-body { padding: 14px 16px 18px; display: grid; gap: 12px; overflow-y: auto; min-height: 0; flex: 1 1 auto; align-content: start; }
.hint { margin: 0; color: var(--muted); font-size: 14px; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
input:not([type=checkbox]), select, textarea {
  padding: 8px 10px; border-radius: 8px; border: 1px solid var(--rule);
  background: var(--col-2); color: var(--text); font-size: 15px; width: 100%;
}
.row { display: flex; gap: 10px; align-items: end; }
.row > * { flex: 1; }
.row > button { flex: none; }
.row.wrap { flex-wrap: wrap; }
.row.wrap > * { flex: none; }
.settings-body button, .file-btn {
  border: 1px solid var(--rule); background: var(--col-2); border-radius: 8px;
  padding: 8px 12px; cursor: pointer; color: var(--text); font-size: 14px; display: inline-block;
}
.settings-body button.danger { color: var(--danger); justify-self: start; }
.settings-body h3 { margin: 6px 0 0; font-size: 14px; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; font-size: 14px; }
.keys dt { font-weight: 700; }
.keys dd { margin: 0; color: var(--muted); }

.catalog { display: grid; gap: 14px; }
.catalog h3 { margin: 0 0 4px; font-size: 14px; }
.catalog .opt { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-radius: 6px; color: var(--text); font-size: 14px; }
.catalog .opt:hover { background: var(--col-2); }
.catalog .opt small { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.found { display: grid; gap: 8px; }
.found .opt { display: flex; align-items: center; gap: 10px; border: 1px solid var(--rule); border-radius: 8px; padding: 8px 10px; }
.found .opt span { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 14px; }

.toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 8px; font-size: 14px;
  transition: opacity 0.2s, transform 0.2s; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }


/* ---------- instant search ---------- */
.search-pop { width: 400px; max-height: min(78vh, 640px); overflow: hidden; display: flex; flex-direction: column; }
.search-pop form { flex: none; }
.search-results { overflow-y: auto; min-height: 0; flex: 1; display: grid; gap: 2px; align-content: start; margin: 0 -4px; }
.search-count { margin: 2px 4px 4px; font-size: 12px; color: var(--muted); }
.search-spin { display: inline-block; width: 10px; height: 10px; margin-left: 6px; border: 2px solid var(--muted); border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: -1px; }
.sr { display: grid; gap: 2px; padding: 8px; border-radius: 8px; color: var(--text); text-decoration: none; }
.sr:hover { background: var(--col-2); }
.sr-meta { display: flex; gap: 8px; font-size: 12px; color: var(--muted); }
.sr-meta strong { color: var(--text); font-weight: 600; }
.sr-meta time { margin-left: auto; }
.sr-title { font-size: 14px; line-height: 1.35; }
#searchAddCol { flex: none; }

/* ---------- appearance switch ---------- */
.field { display: grid; gap: 6px; }
.field-label { font-size: 13px; color: var(--muted); }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border-radius: 10px; background: var(--col-2); border: 1px solid var(--rule); }
.segmented button {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 7px; padding: 9px 8px; background: transparent; color: var(--muted);
  cursor: pointer; font-weight: 600; font-size: 14px;
}
.segmented button svg { width: 18px; height: 18px; }
.segmented button:hover { color: var(--text); }
.segmented button[aria-checked="true"] { background: var(--col); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.25); }
.hint.small { font-size: 12.5px; }

/* ---------- first-run setup ---------- */
dialog.onboard {
  width: 100vw; height: 100%; max-width: 100vw; max-height: 100%; margin: 0; padding: 0; border: 0;
  background: var(--bg); color: var(--text); overflow-y: auto;
}
dialog.onboard[open] { display: grid; place-items: center; }
dialog.onboard::backdrop { background: var(--bg); }
.ob-card { width: min(640px, 100%); padding: calc(28px + env(safe-area-inset-top, 0px)) 22px calc(28px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 18px; }
.ob-steps { display: flex; gap: 6px; }
.ob-steps span { flex: 1; height: 4px; border-radius: 2px; background: var(--rule); }
.ob-steps span.on { background: var(--link); }
#obBody { display: grid; gap: 16px; }
.ob-mark { width: 64px; height: 64px; border-radius: 16px; display: grid; place-items: center; background: var(--link); color: #fff; font-weight: 700; font-size: 32px; }
#obBody h1 { margin: 4px 0 0; font-size: clamp(26px, 5vw, 34px); line-height: 1.15; letter-spacing: -0.01em; }
.ob-lead { margin: 0; font-size: 17px; line-height: 1.5; color: var(--muted); max-width: 52ch; }
.ob-actions { display: grid; gap: 10px; margin-top: 6px; }
.ob-actions.row-actions { grid-template-columns: auto 1fr; }
.primary.big { padding: 13px 18px; font-size: 16px; }
.primary:disabled { opacity: 0.45; cursor: not-allowed; }
.ghost.big, .ob-actions .ghost { padding: 12px 16px; }
.ob-legal { margin: 0; font-size: 13px; color: var(--muted); }
button.link { border: 0; background: none; padding: 0; color: var(--link); cursor: pointer; font: inherit; text-decoration: underline; text-underline-offset: 2px; }
.ob-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); gap: 10px; }
.ob-tile > span:nth-child(2) { min-width: 0; overflow-wrap: break-word; hyphens: auto; }
#obTitle:focus { outline: none; }
.ob-tile {
  position: relative; display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 14px 36px 14px 14px; border-radius: 12px; border: 1.5px solid var(--rule);
  background: var(--col); color: var(--text); cursor: pointer; font-weight: 600; font-size: 15px; line-height: 1.25;
}
.ob-tile:hover { border-color: var(--muted); }
.ob-tile-icon { flex: none; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--col-2); color: var(--accent); }
.ob-check { position: absolute; top: 10px; right: 10px; width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--rule); display: grid; place-items: center; }
.ob-check svg { width: 14px; height: 14px; opacity: 0; stroke-width: 2.6; }
.ob-tile[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--col)); }
.ob-tile[aria-pressed="true"] .ob-check { background: var(--accent); border-color: var(--accent); color: #0B1320; }
.ob-tile[aria-pressed="true"] .ob-check svg { opacity: 1; }
.ob-edition { max-width: 340px; }
.ob-srcs { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-top: 2px; }
.ob-done { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: #2E9E6B; color: #fff; }
.ob-done svg { width: 30px; height: 30px; stroke-width: 2.6; }
.ob-tips { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.ob-tips li { display: flex; gap: 12px; align-items: flex-start; background: var(--col); border: 1px solid var(--rule); border-radius: 12px; padding: 12px 14px; font-size: 15px; line-height: 1.45; }
.tip-icon { flex: none; width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: var(--col-2); color: var(--link); }
.about p { margin: 0; font-size: 14.5px; line-height: 1.55; }
.about h3 { margin: 8px 0 0; scroll-margin-top: 10px; }
.settings-links { gap: 8px; }

/* ---------- drag to reorder ---------- */
.col-head { cursor: grab; touch-action: none; user-select: none; }
.col-head button { cursor: pointer; }
.column.dragging { z-index: 5; opacity: 0.92; box-shadow: 0 0 0 2px var(--accent, var(--link)), 0 14px 34px rgba(0,0,0,0.5); }
.column.dragging .col-head { cursor: grabbing; }
body.col-dragging, body.col-dragging * { cursor: grabbing !important; user-select: none; }
body.col-dragging .deck { scroll-behavior: auto; }
#railCols .rail-btn { touch-action: none; }
#railCols .rail-btn.dragging { background: #2A2F37; color: #fff; box-shadow: inset 3px 0 0 var(--accent, var(--link)), 0 6px 16px rgba(0,0,0,0.4); }

/* ---------- column builder ---------- */
dialog.builder { width: min(640px, 96vw); max-height: 92vh; }
.builder-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 8px 16px 16px; display: grid; gap: 14px; align-content: start; }
.b-quick { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-btn { border: 1px dashed var(--rule); background: transparent; color: var(--muted); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: 13px; }
.chip-btn:hover { color: var(--text); border-color: var(--muted); }
.b-section { display: grid; gap: 10px; border-top: 1px solid var(--rule); padding-top: 12px; }
.b-section h3 { margin: 0; font-size: 15px; }
.b-count { color: var(--muted); font-weight: 400; }
.b-sources { display: grid; gap: 6px; }
.b-src { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 10px; border: 1px solid var(--rule); border-radius: 8px; background: var(--col-2); }
.b-src.paused { opacity: 0.55; }
.b-kind { flex: none; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); border: 1px solid var(--rule); border-radius: 4px; padding: 2px 6px; }
.b-label { flex: 1; min-width: 0; display: grid; }
.b-label > span { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.b-label small { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.b-label small.bad { color: var(--danger); }
.b-add .tabs { padding: 0; border-bottom: 1px solid var(--rule); }
.b-add .tabpanel { padding: 4px 0 0; }
.b-add .catalog { max-height: 340px; overflow-y: auto; gap: 6px; padding-right: 2px; }
.cat-search { position: relative; }
.cat-search input { padding-right: 150px; }
.cat-total { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--muted); pointer-events: none; }
.cat-group { border: 1px solid var(--rule); border-radius: 10px; background: var(--col); }
.cat-group summary { display: flex; align-items: center; gap: 8px; padding: 10px 12px; cursor: pointer; list-style: none; font-weight: 600; font-size: 14.5px; }
.cat-group summary::-webkit-details-marker { display: none; }
.cat-group summary::before { content: ""; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform 0.15s; margin-right: 4px; }
.cat-group[open] summary::before { transform: rotate(45deg); }
.cat-name { flex: 1; }
.cat-count { font-size: 12px; font-weight: 500; color: var(--muted); }
.cat-group .opt { margin: 0 6px; }
.cat-group .opt span { flex: 1; min-width: 0; }
.cat-group[open] { padding-bottom: 6px; }
.cat-all { margin: 0 12px 6px; border: 0; background: none; color: var(--link); cursor: pointer; font-size: 13px; padding: 2px 0; }
dialog.builder.is-saved .b-section { display: none; }
.sheet-foot { flex: none; display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--rule); background: var(--col); }
.foot-left { display: flex; align-items: center; gap: 4px; margin-right: auto; }
.foot-left[hidden] + .ghost { margin-left: auto; }
.ghost { border: 1px solid var(--rule); background: transparent; color: var(--text); border-radius: 8px; padding: 8px 14px; cursor: pointer; }
.text-danger { border: 0; background: transparent; color: var(--danger); cursor: pointer; padding: 8px 6px; font-size: 14px; }
.text-danger.armed { background: var(--danger); color: #fff; border-radius: 8px; padding: 8px 10px; }

/* ---------- phone: rail becomes a bottom bar, one column per screen ---------- */
@media (max-width: 720px) {
  .app { flex-direction: column-reverse; }
  .rail, .rail.open { width: auto; flex-direction: row; align-items: center; padding: 4px 6px; overflow-x: auto; }
  .rail-brand, #railExpand, .rail .label, .rail-heading { display: none; }
  #railCols .rail-btn { padding: 0 10px; gap: 6px; }
  #railCols .rail-btn .label { display: inline; opacity: 1; font-size: 13px; max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
  .rail-cols { flex-direction: row; border: 0; margin: 0; padding: 0 4px; overflow: visible; border-left: 1px solid #2A2E35; border-right: 1px solid #2A2E35; }
  .rail-foot { margin: 0 0 0 auto; flex-direction: row; }
  .rail-btn { padding: 0 10px; gap: 0; }
  .rail-btn[aria-current="true"] { box-shadow: inset 0 -3px 0 var(--accent, var(--link)); }
  .col-head { cursor: default; touch-action: auto; }
  #railCols .rail-btn { touch-action: auto; }
  .deck { scroll-snap-type: x mandatory; padding: 6px; gap: 6px; }
  .column, .column.narrow, .column.wide { --col-w: calc(100vw - 12px); scroll-snap-align: center; }
  .add-column-slot { width: calc(100vw - 12px); scroll-snap-align: center; }
  .ob-tiles { grid-template-columns: 1fr 1fr; gap: 8px; }
  .ob-tile { padding: 12px 28px 12px 10px; font-size: 14px; gap: 8px; }
  .ob-tile-icon { width: 30px; height: 30px; }
  .ob-check { top: 8px; right: 8px; width: 18px; height: 18px; }
  dialog.builder { width: 100vw; max-width: 100vw; max-height: 100%; height: 100%; border-radius: 0; margin: 0; }
  .sheet-foot { padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
  .pop, body.rail-open .pop { left: 8px; right: 8px; width: auto; bottom: calc(60px + env(safe-area-inset-bottom, 0px)); top: auto !important; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
