/* ---------- themes ---------- */
:root {
  --sidebar-w: 280px;
  --list-w: 440px;
  --reader-font: Charter, "Iowan Old Style", Georgia, "PT Serif", serif;
  --ui-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --reader-size: 19px;
  --accent: #2bb24c; /* feedly green */
  --radius: 10px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}
[data-theme="light"] {
  --bg: #ffffff; --bg2: #f6f6f6; --bg3: #ececec; --fg: #1a1a1a; --fg2: #555; --fg3: #8a8a8a;
  --line: #e4e4e4; --link: #0a66c2; --code-bg: #f3f3f3; --hover: #f0f0f0;
}
[data-theme="sepia"] {
  --bg: #f8f1e3; --bg2: #efe6d3; --bg3: #e6dbc4; --fg: #3b2f20; --fg2: #6b5a43; --fg3: #9a876b;
  --line: #e0d4bc; --link: #8a4b0f; --code-bg: #efe4cf; --hover: #f0e6d2;
}
[data-theme="dark"] {
  --bg: #1c1c1e; --bg2: #232326; --bg3: #2c2c2f; --fg: #e8e8e8; --fg2: #a8a8a8; --fg3: #777;
  --line: #333336; --link: #6cb6ff; --code-bg: #2a2a2d; --hover: #2a2a2d;
  color-scheme: dark;
}
[data-theme="black"] {
  --bg: #000000; --bg2: #0b0b0b; --bg3: #161616; --fg: #d9d9d9; --fg2: #9a9a9a; --fg3: #666;
  --line: #1f1f1f; --link: #5aa9ff; --code-bg: #111; --hover: #121212;
  color-scheme: dark;
}
[data-theme="black"] .reader img, [data-theme="dark"] .reader img { filter: brightness(.9); }
[data-font="sans"] { --reader-font: var(--ui-font); }

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); }
body {
  font: 15px/1.45 var(--ui-font);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
a { color: var(--link); }
button { font: inherit; color: inherit; }
.muted { color: var(--fg3); }
.small { font-size: 12px; }
[hidden] { display: none !important; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 40px; height: 40px; padding: 0 8px;
  border: 0; border-radius: 8px; background: transparent; color: var(--fg2);
  font-size: 18px; cursor: pointer; text-decoration: none;
}
.icon-btn:hover { background: var(--hover); color: var(--fg); }
.icon-btn.is-on { color: var(--accent); }
.btn { border: 0; border-radius: 8px; padding: 9px 16px; background: var(--accent); color: #fff; cursor: pointer; }
.btn--ghost { background: var(--bg3); color: var(--fg); }

/* ---------- layout: sidebar | list | reader ---------- */
.app { display: flex; height: 100%; height: 100dvh; overflow: hidden; }

.sidebar {
  width: var(--sidebar-w); flex: none; display: flex; flex-direction: column;
  background: var(--bg2); border-right: 1px solid var(--line);
  padding-top: var(--safe-top); padding-left: var(--safe-left);
}
.sidebar__head { display: flex; align-items: center; justify-content: space-between; padding: 10px 8px 10px 18px; }
.logo { font-weight: 700; font-size: 20px; letter-spacing: -.02em; }
.logo::before { content: "●"; color: var(--accent); margin-right: 6px; font-size: 14px; vertical-align: 2px; }
.sidebar__foot { padding: 10px 18px calc(10px + var(--safe-bottom)); display: flex; justify-content: space-between; gap: 8px; border-top: 1px solid var(--line); }
.net-status { font-size: 12px; color: var(--accent); }
.net-status.off { color: #e5a50a; }

.nav { flex: 1; overflow-y: auto; padding: 4px 8px 20px; -webkit-overflow-scrolling: touch; }
.nav__item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 7px 10px; border: 0; border-radius: 6px; background: none;
  color: var(--fg); text-align: left; cursor: pointer; text-decoration: none; font-size: 14px;
}
.nav__item:hover { background: var(--hover); }
.nav__item.is-active { background: var(--bg3); font-weight: 600; }
.nav__item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav__item .count { color: var(--fg3); font-size: 12px; font-variant-numeric: tabular-nums; }
.nav__item.has-error .name { color: var(--fg3); text-decoration: line-through; text-decoration-color: var(--fg3); }
.nav__section { margin: 16px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--fg3); }
.nav__cat > summary { list-style: none; }
.nav__cat > summary::-webkit-details-marker { display: none; }
.nav__cat > summary .chev { width: 14px; color: var(--fg3); transition: transform .15s; font-size: 10px; }
.nav__cat[open] > summary .chev { transform: rotate(90deg); }
.nav__feeds { padding-left: 18px; }
.favicon { width: 16px; height: 16px; border-radius: 3px; flex: none; object-fit: cover; background: var(--bg3); }
.letter { width: 16px; height: 16px; border-radius: 3px; flex: none; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; color: #fff; }

.list-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.bar {
  display: flex; align-items: center; gap: 4px; flex: none;
  padding: calc(6px + var(--safe-top)) calc(8px + var(--safe-right)) 6px 12px;
  border-bottom: 1px solid var(--line); background: var(--bg);
}
.bar__title { flex: 1; margin: 0 6px; font-size: 18px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar__actions { display: flex; gap: 2px; margin-left: auto; }

.progress { height: 2px; background: var(--bg3); flex: none; }
.progress__bar { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* ---------- entry list ---------- */
.entries { list-style: none; margin: 0; padding: 0 0 calc(40px + var(--safe-bottom)); overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.entry { display: flex; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--line); cursor: pointer; }
.entry:hover { background: var(--hover); }
.entry.is-current { background: var(--bg3); box-shadow: inset 3px 0 var(--accent); }
.entry.is-read .entry__title { color: var(--fg3); font-weight: 400; }
.entry__body { flex: 1; min-width: 0; }
.entry__title { margin: 0 0 4px; font-size: 16px; font-weight: 600; line-height: 1.3; }
.entry__summary { margin: 0 0 6px; color: var(--fg2); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.entry__meta { display: flex; align-items: center; gap: 6px; color: var(--fg3); font-size: 12px; white-space: nowrap; }
.entry__meta > * { flex: none; }
.entry__meta .feed { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.entry__meta .iv { color: var(--accent); font-weight: 600; }
.entry__meta .saved { color: #f5b400; }
.entry__thumb { width: 110px; height: 76px; flex: none; border-radius: 6px; object-fit: cover; background: var(--bg3); }
.layout-titles .entry { padding: 9px 18px; }
.layout-titles .entry__summary, .layout-titles .entry__thumb { display: none; }
.layout-titles .entry__title { font-size: 15px; margin: 0; }
.layout-titles .entry__body { display: flex; gap: 12px; align-items: baseline; }
.layout-titles .entry__title { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.empty { padding: 60px 20px; text-align: center; color: var(--fg3); }

/* ---------- reader / instant view ---------- */
.reader-pane { display: flex; flex-direction: column; background: var(--bg); min-width: 0; }
.reader { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 28px 22px calc(80px + var(--safe-bottom)); }
.reader > * { max-width: 40rem; margin-left: auto; margin-right: auto; }
.reader__feed { display: flex; align-items: center; gap: 8px; color: var(--fg3); font-size: 13px; margin-bottom: 10px; text-decoration: none; }
.reader__title { font: 700 30px/1.2 var(--ui-font); letter-spacing: -.01em; margin: 0 auto 10px; }
.reader__title a { color: inherit; text-decoration: none; }
.reader__meta { color: var(--fg3); font-size: 13px; margin-bottom: 26px; }
.reader__notice { padding: 14px 16px; border-radius: var(--radius); background: var(--bg2); color: var(--fg2); font-size: 14px; }

.content { font-family: var(--reader-font); font-size: var(--reader-size); line-height: 1.62; overflow-wrap: break-word; }
.content p, .content ul, .content ol, .content blockquote, .content pre, .content figure, .content table { margin: 0 0 1.1em; }
.content h1, .content h2, .content h3, .content h4 { font-family: var(--ui-font); line-height: 1.25; margin: 1.6em 0 .6em; }
.content h1 { font-size: 1.4em; } .content h2 { font-size: 1.25em; } .content h3 { font-size: 1.1em; }
.content img, .content video, .content picture { display: block; max-width: 100%; height: auto; margin: 0 auto; border-radius: 6px; }
.content iframe { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; border: 0; border-radius: 6px; }
.content figure { margin-left: 0; margin-right: 0; }
.content figcaption { font: 13px/1.4 var(--ui-font); color: var(--fg3); text-align: center; margin-top: 6px; }
.content blockquote { margin-left: 0; padding: 2px 0 2px 18px; border-left: 3px solid var(--accent); color: var(--fg2); }
.content pre { background: var(--code-bg); padding: 14px; border-radius: 8px; overflow-x: auto; font-size: 14px; line-height: 1.5; }
.content code { font-family: var(--mono); font-size: .85em; background: var(--code-bg); padding: .1em .35em; border-radius: 4px; }
.content pre code { background: none; padding: 0; font-size: inherit; }
.content table { display: block; overflow-x: auto; border-collapse: collapse; font: 14px/1.4 var(--ui-font); }
.content td, .content th { border: 1px solid var(--line); padding: 6px 10px; }
.content hr { border: 0; text-align: center; margin: 2em 0; }
.content hr::after { content: "• • •"; color: var(--fg3); letter-spacing: .5em; }
.content details { background: var(--bg2); border-radius: 8px; padding: 10px 14px; margin-bottom: 1em; }
.content summary { cursor: pointer; font-family: var(--ui-font); }

.reader__actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--line); }

/* comments */
.comments { margin-top: 40px; }
.comments > summary { cursor: pointer; font-weight: 700; font-size: 17px; padding: 10px 0; list-style: none; }
.comments > summary::-webkit-details-marker { display: none; }
.comment { padding: 10px 0 10px 12px; border-left: 2px solid var(--line); margin-top: 6px; font-size: 15px; }
.comment__head { display: flex; gap: 8px; color: var(--fg3); font-size: 12px; margin-bottom: 4px; }
.comment__author { color: var(--fg2); font-weight: 600; }
.comment__score.pos { color: var(--accent); }
.comment__score.neg { color: #e5534b; }
.comment .content { font-family: var(--ui-font); font-size: 15px; line-height: 1.5; }
.comment .content p { margin: 0 0 .5em; }
.comment .content img, .comment .content video { max-height: 320px; width: auto; margin: 0; }

/* ---------- dialog, toast ---------- */
.dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--bg2); color: var(--fg); padding: 20px 22px; width: min(420px, 92vw); }
.dialog::backdrop { background: rgba(0, 0, 0, .6); }
.dialog h2 { margin: 0 0 16px; font-size: 18px; }
.dialog label { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.dialog select { background: var(--bg3); color: var(--fg); border: 1px solid var(--line); border-radius: 6px; padding: 6px; font: inherit; }
.dialog__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translateX(-50%);
  background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 20px; font-size: 14px; z-index: 50;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .35);
}
.scrim { display: none; }
.login { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 20px; }
.login__form { width: min(340px, 100%); display: flex; flex-direction: column; gap: 12px; }
.login__form .logo { font-size: 28px; text-align: center; margin-bottom: 12px; }
.login__form input { font: inherit; font-size: 17px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg2); color: var(--fg); }
.login__form .btn { padding: 12px; font-size: 16px; }
.login__error { color: #e5534b; min-height: 1.2em; margin: 0; text-align: center; font-size: 14px; }
.only-mobile { display: none; }

/* ---------- responsive ---------- */
/* Wide: 3 columns like Feedly with the reader on the right. */
@media (min-width: 1100px) {
  .list-pane.has-reader { flex: 0 0 var(--list-w); border-right: 1px solid var(--line); }
  .reader-pane { flex: 1; }
  .list-pane.has-reader .entry__thumb { width: 72px; height: 54px; }
}
/* Medium: reader covers the list. */
@media (max-width: 1099px) {
  .reader-pane { position: fixed; inset: 0 0 0 var(--sidebar-w); z-index: 10; }
}
/* Phone: one pane at a time, sidebar is a drawer. */
@media (max-width: 760px) {
  .only-mobile { display: inline-flex; }
  .sidebar {
    position: fixed; z-index: 30; inset: 0 auto 0 0; width: min(86vw, 320px);
    transform: translateX(-100%); transition: transform .22s ease;
  }
  .app.sidebar-open .sidebar { transform: none; }
  .app.sidebar-open .scrim { display: block; position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .5); }
  .reader-pane { inset: 0; animation: slide-in .18s ease; }
  .reader { padding-left: calc(18px + var(--safe-left)); padding-right: calc(18px + var(--safe-right)); }
  .reader__title { font-size: 25px; }
  .bar__actions .icon-btn { min-width: 36px; padding: 0 4px; }
  .bar--reader [data-action="prev"], .bar--reader [data-action="next"] { display: none; }
  .entry { padding: 12px 14px; gap: 12px; }
  .entry__thumb { width: 84px; height: 64px; }
  .entry__title { font-size: 15.5px; }
}
@keyframes slide-in { from { transform: translateX(30%); opacity: .4; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
