/* DoomReader — dark-first, mobile-first */
* { box-sizing: border-box; }
:root {
  --bg: #15181d;
  --card: #1e2229;
  --card-read: #191c22;
  --border: #2c313a;
  --text: #d7dae0;
  --text-dim: #8b919c;
  --accent: #ff8a3d;
  --star: #ffcf4d;
  --chip: #262b34;
  --chip-active: #ff8a3d;
}
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- login ---------- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box {
  display: flex; flex-direction: column; gap: 14px; width: min(320px, 88vw);
  background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 28px;
}
.login-logo { font-size: 42px; text-align: center; }
.login-box h1 { margin: 0 0 6px; font-size: 22px; text-align: center; }
.login-box input {
  font-size: 17px; padding: 12px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text);
}
.login-box button {
  font-size: 17px; padding: 12px; border-radius: 9px; border: none;
  background: var(--accent); color: #1a1204; font-weight: 700; cursor: pointer;
}
.login-error { color: #ff6b6b; margin: 0; text-align: center; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10; background: rgba(21,24,29,0.96);
  backdrop-filter: blur(6px); border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  display: flex; align-items: center; gap: 8px;
  max-width: 640px; margin: 0 auto; padding: 10px 14px 6px;
}
.brand { font-weight: 800; font-size: 18px; flex: 1; cursor: pointer; user-select: none; }
.iconbtn {
  background: var(--chip); color: var(--text); border: 1px solid var(--border);
  border-radius: 9px; font-size: 17px; padding: 6px 12px; cursor: pointer; line-height: 1;
}
.iconbtn.active { background: var(--star); color: #201a04; border-color: var(--star); }
.chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 6px 14px 10px;
  max-width: 640px; margin: 0 auto; scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; background: var(--chip); border: 1px solid var(--border);
  color: var(--text-dim); border-radius: 999px; padding: 5px 13px; font-size: 13.5px;
  cursor: pointer; white-space: nowrap;
}
.chip.active { background: var(--chip-active); border-color: var(--chip-active); color: #1a1204; font-weight: 700; }

/* ---------- feed ---------- */
.feed { max-width: 640px; margin: 0 auto; padding: 10px 10px 40px; display: flex; flex-direction: column; gap: 10px; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px 16px; cursor: pointer; position: relative;
}
.card:active { background: #232833; }
.card.read { background: var(--card-read); opacity: 0.75; }
.card-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.tag {
  font-size: 12px; font-weight: 700; color: var(--accent);
  background: rgba(255,138,61,0.12); padding: 2px 9px; border-radius: 999px;
}
.tag.rss-tag { color: #6fb7ff; background: rgba(111,183,255,0.12); }
.card-meta { font-size: 12px; color: var(--text-dim); flex: 1; }
.starbtn {
  background: none; border: none; font-size: 21px; color: var(--text-dim);
  cursor: pointer; padding: 2px 6px; margin: -4px -6px -4px 0;
}
.starbtn.starred { color: var(--star); }
.card h2 { margin: 0 0 7px; font-size: 17px; line-height: 1.3; }
.card-snippet {
  margin: 0; font-size: 14.5px; line-height: 1.55; color: var(--text-dim);
  white-space: pre-line; display: -webkit-box; -webkit-line-clamp: 7;
  -webkit-box-orient: vertical; overflow: hidden;
}
.card-img { width: 100%; max-height: 260px; object-fit: cover; border-radius: 10px; margin-bottom: 8px; }
.card-progress { margin-top: 8px; height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; }
.card-progress > div { height: 100%; background: var(--accent); }
.sentinel { height: 2px; }
.feed-status { text-align: center; color: var(--text-dim); padding: 18px; font-size: 14px; }

/* card entrance */
@keyframes cardIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
.card { animation: cardIn 0.3s ease both; }
.card.no-anim { animation: none; }

/* star pop */
@keyframes starPop {
  0% { transform: scale(1); }
  45% { transform: scale(1.6) rotate(12deg); }
  100% { transform: scale(1); }
}
.starbtn.pop { animation: starPop 0.35s ease; }

/* pull-quote cards */
.quote-card { border-left: 3px solid var(--accent); }
.pull-quote {
  margin: 6px 0 8px; font-family: Georgia, "Times New Roman", serif;
  font-size: 19px; line-height: 1.5; font-style: italic; color: var(--text);
}
.pull-quote::before { content: '“'; color: var(--accent); font-size: 26px; }
.pull-quote::after { content: '”'; color: var(--accent); font-size: 26px; }
.quote-attrib { font-size: 13px; color: var(--text-dim); text-align: right; }

/* external-link buttons on RSS cards */
.extbtn {
  background: none; border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 7px; font-size: 12px; font-weight: 700; padding: 3px 8px;
  cursor: pointer; margin-left: 2px; flex-shrink: 0;
}
.extbtn:active { color: var(--accent); border-color: var(--accent); }

/* skeleton shimmer */
.skeleton { pointer-events: none; }
.sk-line {
  height: 12px; border-radius: 6px; margin: 10px 0;
  background: linear-gradient(90deg, var(--border) 25%, #3a4150 37%, var(--border) 63%);
  background-size: 400% 100%; animation: shimmer 1.2s infinite linear;
}
.sk-tag { width: 90px; height: 18px; }
.sk-title { width: 75%; height: 17px; }
.sk-short { width: 40%; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* fresh posts pill */
.fresh-pill {
  position: fixed; top: calc(64px + env(safe-area-inset-top)); left: 50%;
  transform: translateX(-50%); z-index: 50;
  background: var(--accent); color: #1a1204; font-weight: 700; font-size: 14px;
  border: none; border-radius: 999px; padding: 9px 18px; cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,0.45); animation: cardIn 0.25s ease both;
}
.fresh-pill.hidden { display: none; }

/* pull-to-refresh */
.ptr {
  height: 0; overflow: hidden; display: flex; align-items: flex-end;
  justify-content: center; transition: height 0.15s ease; color: var(--text-dim);
}
.ptr span { font-size: 20px; padding: 6px; transition: transform 0.2s ease; }
.ptr.armed span { transform: rotate(180deg); color: var(--accent); }
.ptr.spin span { animation: ptrSpin 0.8s linear infinite; }
@keyframes ptrSpin { to { transform: rotate(360deg); } }

/* ---------- reader ---------- */
.reader-body { overflow: hidden; height: 100dvh; display: flex; flex-direction: column; }
.readerbar {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  padding-top: calc(10px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--border); background: var(--bg); z-index: 20;
}
.reader-title {
  flex: 1; font-size: 15px; font-weight: 600; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
#viewer { flex: 1; position: relative; background: #fff; }
.reader-nav { position: fixed; inset: 0; top: 60px; bottom: 34px; display: flex; pointer-events: none; z-index: 5; }
.navzone { flex: 1; background: none; border: none; pointer-events: auto; cursor: pointer; }
.navzone#prevBtn { max-width: 28%; }
.reader-progress {
  padding: 7px 14px calc(7px + env(safe-area-inset-bottom));
  text-align: center; font-size: 12.5px; color: var(--text-dim); background: var(--bg);
}
.warmth-overlay {
  position: fixed; inset: 0; pointer-events: none; z-index: 100;
  background: #ff9a3c; opacity: 0; mix-blend-mode: multiply;
}

/* scroll reading mode: the page scrolls through the chapter */
.reader-body.scroll-flow { overflow-y: auto; height: auto; min-height: 100dvh; display: block; }
.reader-body.scroll-flow .readerbar { position: sticky; top: 0; }
.reader-body.scroll-flow #viewer { min-height: 60vh; }
.reader-body.scroll-flow .reader-progress {
  position: fixed; bottom: 0; left: 0; right: 0; opacity: 0.92;
}
.chapter-nav { display: none; }
.reader-body.scroll-flow .chapter-nav {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 16px 14px 46px;
}
.chapterbtn {
  padding: 10px 16px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--chip); color: var(--text); font-size: 14px; cursor: pointer;
}

/* settings panel */
.settings-panel {
  position: fixed; right: 10px; top: calc(56px + env(safe-area-inset-top)); z-index: 200;
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 16px 18px; width: min(320px, 92vw); display: flex; flex-direction: column; gap: 13px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5); max-height: 80dvh; overflow-y: auto;
}
.settings-panel.hidden { display: none; }
.settings-panel h3 { margin: 0; font-size: 16px; }
.settings-panel label { display: flex; flex-direction: column; gap: 5px; font-size: 13.5px; color: var(--text-dim); }
.settings-panel input[type=range] { width: 100%; accent-color: var(--accent); }
.settings-panel select {
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px; font-size: 15px;
}
.theme-row { display: flex; gap: 8px; }
.themebtn, .flowbtn {
  flex: 1; padding: 8px 0; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); cursor: pointer; font-size: 13.5px;
}
.themebtn.active, .flowbtn.active { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.fullbtn {
  padding: 11px; border-radius: 9px; border: none; background: var(--accent);
  color: #1a1204; font-weight: 700; font-size: 15px; cursor: pointer;
}

/* ---------- article reader ---------- */
.article-body { overflow-y: auto; display: block; height: auto; min-height: 100dvh; }
.article-body .readerbar { position: sticky; top: 0; }
.article-content {
  margin: 0 auto; padding: 20px 0 70px;
  font-size: 100%; line-height: 1.6;
}
.article-content h1 { font-size: 1.6em; line-height: 1.25; }
.article-content img { max-width: 100%; height: auto; border-radius: 8px; }
.article-content a { color: var(--accent); }
.article-content pre { overflow-x: auto; background: rgba(127,127,127,0.12); padding: 12px; border-radius: 8px; }
.article-content blockquote { border-left: 3px solid var(--accent); margin-left: 0; padding-left: 14px; color: var(--text-dim); }
.article-source { font-size: 0.85em; }
.article-source a { color: var(--text-dim); }

/* up-next chain at the end of articles */
.upnext {
  display: flex; align-items: center; gap: 12px; margin: 40px 0 10px;
  padding: 16px 18px; border-radius: 14px; text-decoration: none;
  background: rgba(255,138,61,0.1); border: 1px solid rgba(255,138,61,0.45);
}
.upnext-label {
  font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--accent); flex-shrink: 0;
}
.upnext-title { flex: 1; font-weight: 600; color: var(--text) !important; font-size: 0.95em; }
.upnext-arrow { color: var(--accent); font-size: 1.2em; }

/* article themes */
.article-body.theme-light { --bg: #fafafa; --card: #fff; --text: #1c1e21; --text-dim: #555b64; --border: #ddd; background: #fafafa; }
.article-body.theme-sepia { --bg: #f4ecd8; --card: #efe6cf; --text: #4b3a24; --text-dim: #7a6748; --border: #d9cdac; background: #f4ecd8; }
.article-body.theme-dark  { background: var(--bg); }
.article-body.font-serif .article-content { font-family: Georgia, "Times New Roman", serif; }
.article-body.font-sans .article-content { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
