/* rsska -- three panes, one column on a phone.
   Everything is one stylesheet: there is no build step and there does not
   need to be one. */

:root {
  --topbar: 46px;
  --sidebar-w: 260px;
  --list-w: 380px;

  --bg: #ffffff;
  --bg-sunk: #f4f5f7;
  --bg-raised: #ffffff;
  --line: #e2e5ea;
  --ink: #1c1f24;
  --ink-soft: #5c6470;
  --ink-faint: #8b939f;
  --accent: #2f6fd0;
  --accent-soft: #e8f0fc;
  --warn: #b06000;
  --bad: #b3261e;
  --star: #e8a33d;
  --radius: 8px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --bg-sunk: #14171d;
    --bg-raised: #191d24;
    --line: #262b34;
    --ink: #e6e9ee;
    --ink-soft: #a4acb9;
    --ink-faint: #737c8a;
    --accent: #6aa2f0;
    --accent-soft: #1b2637;
    --warn: #d9a24b;
    --bad: #e4796f;
    --star: #f0b64c;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; }
.muted { color: var(--ink-soft); }
.small { font-size: 13px; }
.bad { color: var(--bad); }
.warn { color: var(--warn); }
.grow { flex: 1; }
.num { text-align: right; }
kbd {
  font: 12px var(--mono);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 5px;
  background: var(--bg-sunk);
}
code { font: 13px var(--mono); }

/* ------------------------------------------------------------- top bar */

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--topbar);
  padding: 0 12px;
  padding-left: max(12px, env(safe-area-inset-left));
  padding-right: max(12px, env(safe-area-inset-right));
  border-bottom: 1px solid var(--line);
  background: var(--bg-raised);
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand {
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  font-size: 17px;
}
.brand:hover { text-decoration: none; color: var(--accent); }

.search { flex: 1; min-width: 0; max-width: 460px; }
.search input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-sunk);
  color: inherit;
  font: inherit;
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.topnav { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.topnav a, .linklike {
  color: var(--ink-soft);
  font-size: 14px;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  cursor: pointer;
}
.topnav a.on { color: var(--ink); font-weight: 600; }
.topnav a:hover, .linklike:hover { color: var(--accent); text-decoration: none; }
.inline { display: inline; }

/* --------------------------------------------------------------- panes */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) var(--list-w) minmax(0, 1fr);
  height: calc(100dvh - var(--topbar));
}

.pane { overflow-y: auto; overscroll-behavior: contain; min-width: 0; }
.pane-sidebar { background: var(--bg-sunk); border-right: 1px solid var(--line); }
.pane-list { border-right: 1px solid var(--line); }
.pane-article { background: var(--bg); }

.scrim { display: none; }

/* -------------------------------------------------------------- sidebar */

.sidebar { padding: 10px 8px 24px; }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.side-head {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  margin: 18px 8px 6px;
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  color: var(--ink);
  font-size: 14px;
}
.row:hover { background: var(--bg-raised); text-decoration: none; }
.row.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.row-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row.broken .row-name { color: var(--warn); }

.count {
  font-size: 12px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.count.muted { color: var(--ink-faint); }
.count:empty { display: none; }

.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ink-faint);
  flex: none;
}

.tree .feeds { margin-left: 18px; display: none; }
.folder.open .feeds { display: block; }
.folder-head { display: flex; align-items: center; }
.twisty {
  border: 0; background: none; color: var(--ink-faint);
  cursor: pointer; padding: 4px 2px; font-size: 11px;
  transition: transform .12s ease;
}
.folder.open .twisty { transform: rotate(90deg); }

.side-foot {
  margin: 20px 8px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}

/* ------------------------------------------------------------- the list */

.list-head {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.list-title h1 { margin: 0; font-size: 16px; }
.list-title .sub { margin: 2px 0 0; font-size: 12px; color: var(--ink-faint); }
.list-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.segmented { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.segmented a {
  padding: 3px 10px;
  font-size: 12px;
  color: var(--ink-soft);
  background: var(--bg);
}
.segmented a.on { background: var(--accent); color: #fff; }
.segmented a:hover { text-decoration: none; }

.item {
  display: flex;
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.item.is-active { background: var(--accent-soft); }
.item:hover { background: var(--bg-sunk); }
.item.is-active:hover { background: var(--accent-soft); }

.item-body {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
  flex: 1;
  min-width: 0;
  padding: 9px 4px 9px 12px;
  color: inherit;
}
.item-body:hover { text-decoration: none; }
.item-source {
  grid-column: 1;
  font-size: 11px;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.item-when {
  grid-column: 2; grid-row: 1;
  font-size: 11px;
  color: var(--ink-faint);
  white-space: nowrap;
}
.item-title {
  grid-column: 1 / -1;
  font-weight: 600;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.item-snippet {
  grid-column: 1 / -1;
  font-size: 13px;
  color: var(--ink-soft);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.item-snippet mark { background: transparent; color: var(--accent); font-weight: 600; }

.item.is-read .item-title { font-weight: 400; color: var(--ink-soft); }
.item.is-read .item-source { opacity: .7; }

.item-actions { display: flex; gap: 2px; padding: 8px 8px 8px 0; }

.more { padding: 16px; text-align: center; color: var(--ink-faint); font-size: 13px; }
.empty { padding: 32px 16px; color: var(--ink-faint); text-align: center; }

/* ---------------------------------------------------------- the article */

.article { max-width: 44rem; margin: 0 auto; padding: 14px 20px 80px; }
.article-head { border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 18px; }
.article-actions { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.article-title { font-size: 26px; margin: 6px 0 8px; line-height: 1.2; letter-spacing: -0.01em; }
.article-title a { color: var(--ink); }
.article-meta { margin: 0; font-size: 13px; color: var(--ink-soft); }
.article-labels { margin: 8px 0 0; display: flex; gap: 6px; flex-wrap: wrap; }

.article-body {
  font: 17px/1.65 var(--serif);
  overflow-wrap: break-word;
}
.article-body img, .article-body video, .article-body iframe {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}
.article-body figure { margin: 1.4em 0; }
.article-body figcaption { font: 13px/1.4 var(--sans); color: var(--ink-faint); margin-top: 6px; }
.article-body pre {
  background: var(--bg-sunk);
  padding: 12px;
  border-radius: var(--radius);
  overflow-x: auto;
  font: 13px/1.5 var(--mono);
}
.article-body code { background: var(--bg-sunk); padding: 1px 4px; border-radius: 4px; }
.article-body pre code { background: none; padding: 0; }
.article-body blockquote {
  margin: 1.2em 0;
  padding-left: 14px;
  border-left: 3px solid var(--line);
  color: var(--ink-soft);
}
.article-body table { width: 100%; border-collapse: collapse; font: 14px/1.4 var(--sans); }
.article-body th, .article-body td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; }
.article-body hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }

.enclosures { margin-top: 28px; font-size: 14px; }
.enclosures h2 { font-size: 13px; text-transform: uppercase; color: var(--ink-faint); }
.enclosures ul { list-style: none; padding: 0; }

.labeller { margin-top: 28px; font-size: 14px; }
.labeller summary { cursor: pointer; color: var(--ink-soft); }
.labeller form { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.empty-pane { padding-top: 15vh; text-align: center; color: var(--ink-faint); }

.tag {
  display: inline-block;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  vertical-align: middle;
}
.tag.warn { background: transparent; border: 1px solid var(--warn); color: var(--warn); }

/* -------------------------------------------------------------- buttons */

.btn {
  font: inherit;
  font-size: 13px;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-raised);
  color: var(--ink);
  cursor: pointer;
  display: inline-block;
}
.btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); color: #fff; }
.btn.subtle { background: none; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); color: var(--bad); }

.icon-btn {
  font: inherit;
  line-height: 1;
  border: 0;
  background: none;
  color: var(--ink-faint);
  cursor: pointer;
  padding: 5px 7px;
  border-radius: 6px;
}
.icon-btn:hover { background: var(--bg-sunk); color: var(--ink); }
.icon-btn.star.on { color: var(--star); }
.icon-btn.dot.on { color: var(--ink-faint); opacity: .35; }
.icon-btn.dot { color: var(--accent); }

.spinner {
  display: inline-block;
  width: 12px; height: 12px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.htmx-request .article-body { opacity: .45; transition: opacity .2s; }

/* ------------------------------------------------- management pages */

.shell {
  max-width: 60rem;
  margin: 0 auto;
  padding: 20px 16px 80px;
}
.shell h1 { font-size: 22px; margin-top: 0; }

.card {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 16px 0;
}
.card h2 { font-size: 15px; margin: 0 0 12px; }

.stack { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.stack label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-soft); width: 100%; max-width: 30rem; }
.stack label.check { flex-direction: row; align-items: center; width: auto; }
.row-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 10px 0 0; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }

input[type=text], input[type=search], input[type=password], input[type=number],
input[type=file], select {
  font: inherit;
  font-size: 14px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
  max-width: 100%;
}
input:focus, select:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.hint { font-size: 12px; color: var(--ink-faint); margin: 4px 0 0; }

.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
.grid th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  border-bottom: 1px solid var(--line);
  padding: 6px 8px;
}
.grid td { border-bottom: 1px solid var(--line); padding: 8px; vertical-align: top; }
.grid tr.off { opacity: .55; }
.grid tr.broken td { border-left: 2px solid var(--warn); }
.grid summary { cursor: pointer; }
.grid summary strong { font-weight: 600; }

.folder-list { list-style: none; padding: 0; margin: 12px 0 0; }
.folder-list li { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }

.stats { list-style: none; padding: 0; margin: 0; display: flex; gap: 18px; flex-wrap: wrap; font-size: 14px; }
.stats b { font-size: 18px; display: block; font-variant-numeric: tabular-nums; }

.flash { padding: 9px 12px; border-radius: var(--radius); font-size: 14px; margin: 12px 0; }
.flash.ok { background: var(--accent-soft); color: var(--accent); }
.flash.bad { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); }

/* ---------------------------------------------------------------- login */

.login { max-width: 22rem; margin: 12vh auto; padding: 0 16px; }
.login h1 { margin: 0 0 4px; font-size: 24px; letter-spacing: -0.02em; }
.login .card { display: flex; flex-direction: column; gap: 6px; }
.login label { font-size: 13px; color: var(--ink-soft); margin-top: 8px; }
.login input { width: 100%; }
.login .btn { margin-top: 16px; }
.version { text-align: center; font-size: 12px; }

/* --------------------------------------------------------------- overlay */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 16px;
}
.overlay[hidden] { display: none; }
.overlay-card {
  background: var(--bg-raised);
  border-radius: var(--radius);
  padding: 20px 24px;
  max-width: 26rem;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}
.overlay-card h2 { margin-top: 0; font-size: 16px; }
.shortcuts { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; margin: 0 0 16px; }
.shortcuts dt { font: 12px var(--mono); color: var(--ink-soft); white-space: nowrap; }
.shortcuts dd { margin: 0; }

/* ------------------------------------------------------------ responsive */

.only-narrow { display: none; }

@media (max-width: 1100px) {
  :root { --list-w: 340px; }
  .app { grid-template-columns: var(--list-w) minmax(0, 1fr); }
  .pane-sidebar {
    position: fixed;
    top: var(--topbar);
    bottom: 0;
    left: 0;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform .18s ease;
    z-index: 40;
  }
  body.sidebar-open .pane-sidebar { transform: none; }
  body.sidebar-open .scrim {
    display: block;
    position: fixed;
    inset: var(--topbar) 0 0 0;
    background: rgba(0, 0, 0, .35);
    z-index: 35;
  }
  .only-narrow { display: inline-block; }
  .topnav a { display: none; }
  .topnav a.on { display: inline; }
}

@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .pane-list, .pane-article { grid-column: 1; grid-row: 1; }
  .app[data-pane="list"] .pane-article { display: none; }
  .app[data-pane="article"] .pane-list { display: none; }
  .article { padding: 12px 16px 80px; }
  .article-title { font-size: 22px; }
  .article-body { font-size: 17px; }
  .topnav { gap: 10px; }
  .search { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
