@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:     #0a0a0a;
  --s1:     #111;
  --s2:     #161616;
  --b:      rgba(255,255,255,0.08);
  --b2:     rgba(255,255,255,0.13);
  --t1:     #e6e6e6;
  --t1-5:   #a0a0a0;
  --t2:     #606060;
  --t3:     #383838;
  --accent: #7eb9ff;
  --mono:   'JetBrains Mono', monospace;
  --sans:   'Inter', -apple-system, sans-serif;
  --rail:   64px;
}

html, body { height: 100%; width: 100%; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--t1);
  -webkit-font-smoothing: antialiased;
}

/* ── Rail ────────────────────────────────── */

.rail {
  width: var(--rail);
  min-height: 100vh;
  position: fixed; top: 0; left: 0; bottom: 0;
  border-right: 0.5px solid var(--b);
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 100;
  background: var(--bg);
}

.rail-wordmark {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  padding: 20px 0 16px;
  user-select: none;
  flex-shrink: 0;
}

.rail-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding: 4px 0;
  gap: 2px;
}

.rail-btn {
  width: 100%;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-top: 0.5px solid transparent;
  border-bottom: 0.5px solid transparent;
  cursor: pointer;
  color: var(--t3);
  transition: color 0.12s, background 0.12s;
  position: relative;
}

.rail-btn:hover { color: var(--t1-5); }

.rail-btn.active {
  color: var(--accent);
  background: rgba(126,185,255,0.06);
}

/* Left-edge active indicator */
.rail-btn.active::before {
  content: '';
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 2px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.rail-spacer { flex: 1; }

.rail-foot {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0 16px;
  gap: 8px;
}

/* Tooltip */
.rail-btn[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--s2);
  border: 0.5px solid var(--b2);
  border-radius: 4px;
  padding: 5px 9px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--t1-5);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 200;
}

.rail-btn[data-tip]:hover::after { opacity: 1; }

/* ── Main ────────────────────────────────── */

.main {
  margin-left: var(--rail);
  width: calc(100% - var(--rail));
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Feed ────────────────────────────────── */

.feed { flex: 1; }

/* ── Breadcrumb ──────────────────────────── */

.breadcrumb {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 20px 24px 14px;
  border-bottom: 0.5px solid var(--b);
}

.breadcrumb-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--t1);
}

.breadcrumb-count {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--t3);
}

/* ── Row ─────────────────────────────────── */

.row {
  display: flex;
  align-items: center;
  border-bottom: 0.5px solid rgba(255,255,255,0.06);
  cursor: pointer;
  transition: background 0.12s;
  position: relative;
}

.row:hover { background: var(--s1); }

.row--active { background: var(--s2); }
.row--active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--accent);
}

.row--read .row-title { color: var(--t2); }
.row--read .row-img, .row--read .row-no-img { opacity: 0.45; }
.row--read .row-excerpt { color: var(--t3); }

.row-reading-time {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--t3);
}

.row-thumb {
  flex-shrink: 0;
  padding: 14px 0 14px 24px;
}

.row-img {
  width: 96px;
  height: 64px;
  object-fit: cover;
  border-radius: 2px;
  border: 0.5px solid var(--b);
  display: block;
  transition: opacity 0.12s;
}

.row:hover .row-img { opacity: 0.88; }

.row-no-img {
  width: 96px;
  height: 64px;
  border-radius: 2px;
  border: 0.5px solid var(--b);
  background: var(--s1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.row-no-img span {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--t3);
  letter-spacing: 0.08em;
}

.row-body {
  flex: 1;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.row-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--t3);
  overflow: hidden;
  white-space: nowrap;
}

.row-label {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--t1-5);
  background: rgba(255,255,255,0.06);
  padding: 2px 5px;
  border-radius: 2px;
  flex-shrink: 0;
}

.row-dot   { color: var(--t3); }
.row-src   { overflow: hidden; text-overflow: ellipsis; }

.row-title {
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.45;
  color: var(--t1);
  letter-spacing: -0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color 0.12s;
}

.row:hover .row-title { color: #fff; }

.row-excerpt {
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--t2);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.row-score {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--t3);
  white-space: nowrap;
}

.row-save-wrap {
  flex-shrink: 0;
  padding: 0 14px 0 4px;
  display: flex;
  align-items: center;
}

.row-save {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--t3);
  padding: 4px;
  border-radius: 3px;
  display: flex;
  opacity: 0;
  transition: color 0.1s, opacity 0.1s;
}

.row:hover .row-save { opacity: 1; }
.row-save:hover { color: var(--t1); }
.row-save.saved { color: var(--t2); opacity: 1; }

/* ── Article Panel ───────────────────────── */

.article-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 300;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.article-overlay.open { display: block; }

.article-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 440px;
  background: var(--bg);
  border-left: 0.5px solid var(--b2);
  z-index: 301;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.22s cubic-bezier(0.4,0,0.2,1);
}
.article-panel.open { transform: none; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 0.5px solid var(--b);
  flex-shrink: 0;
}

.panel-meta {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--t2);
  display: flex;
  gap: 5px;
  align-items: center;
  overflow: hidden;
}
.panel-meta-dot { color: var(--t3); }

.panel-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--t3);
  display: flex;
  padding: 4px;
  flex-shrink: 0;
  transition: color 0.1s;
}
.panel-close:hover { color: var(--t1); }

.panel-image-wrap { flex-shrink: 0; }
.panel-image {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-bottom: 0.5px solid var(--b);
  display: block;
  mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--b2) transparent;
}

.panel-title {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--t1);
  letter-spacing: -0.02em;
}

/* ── Panel one-liner & tags ──────────────── */

.panel-oneliner {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--t1);
  font-style: italic;
  padding: 10px 14px;
  border-left: 2px solid var(--accent);
  background: rgba(126,185,255,0.04);
  border-radius: 0 4px 4px 0;
}

.panel-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.panel-tag {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--t2);
  background: rgba(255,255,255,0.05);
  border: 0.5px solid var(--b);
  padding: 3px 7px;
  border-radius: 2px;
}


.panel-summary-label {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}

.panel-summary-text {
  font-size: 13px;
  line-height: 1.7;
  color: var(--t1-5);
}

.panel-skeleton { display: flex; flex-direction: column; gap: 8px; }

.skeleton {
  height: 11px;
  background: linear-gradient(90deg,
    rgba(255,255,255,0.04) 25%,
    rgba(255,255,255,0.09) 50%,
    rgba(255,255,255,0.04) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 2px;
}
.skeleton.s60 { width: 60%; }
.skeleton.s80 { width: 80%; }

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.panel-footer {
  padding: 16px 20px;
  border-top: 0.5px solid var(--b);
  flex-shrink: 0;
}

.panel-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  color: var(--t1);
  text-decoration: none;
  padding: 7px 12px;
  border: 0.5px solid var(--b2);
  border-radius: 4px;
  background: var(--s1);
  transition: background 0.12s, border-color 0.12s;
}
.panel-link:hover {
  background: var(--s2);
  border-color: rgba(255,255,255,0.2);
}

/* ── Empty ───────────────────────────────── */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 280px;
  gap: 10px;
  color: var(--t3);
}

.empty-text { font-size: 12px; font-family: var(--mono); }

/* ── Toast ───────────────────────────────── */

.toast {
  position: fixed;
  bottom: 18px; right: 18px;
  background: var(--s2);
  border: 0.5px solid var(--b2);
  border-radius: 4px;
  padding: 8px 13px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--t2);
  box-shadow: 0 2px 16px rgba(0,0,0,0.8);
  transform: translateY(8px);
  opacity: 0;
  transition: transform 0.15s ease, opacity 0.15s ease;
  z-index: 9999;
  pointer-events: none;
}

.toast.show { transform: none; opacity: 1; }

/* ── Subscribe popup ─────────────────────── */

.sub-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 400;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.sub-overlay.open { display: block; }

.sub-modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -48%) scale(0.96);
  width: min(440px, calc(100vw - 40px));
  background: var(--s1);
  border: 0.5px solid var(--b2);
  border-radius: 10px;
  padding: 36px 32px 28px;
  z-index: 401;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.2s cubic-bezier(0.4,0,0.2,1), opacity 0.2s;
}
.sub-modal.open {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.sub-close {
  position: absolute; top: 14px; right: 14px;
  background: none; border: none; cursor: pointer;
  color: var(--t3); padding: 4px;
  display: flex; border-radius: 3px;
  transition: color 0.1s;
}
.sub-close:hover { color: var(--t1); }

.sub-icon {
  color: var(--accent);
  margin-bottom: 4px;
}

.sub-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--t1);
  letter-spacing: -0.02em;
  text-align: center;
  line-height: 1.35;
}

.sub-desc {
  font-size: 13px;
  color: var(--t2);
  text-align: center;
  line-height: 1.6;
  max-width: 300px;
  margin-bottom: 4px;
}

.sub-form {
  width: 100%;
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.sub-input {
  flex: 1;
  background: var(--bg);
  border: 0.5px solid var(--b2);
  border-radius: 5px;
  padding: 9px 13px;
  font-size: 13px;
  font-family: var(--sans);
  color: var(--t1);
  outline: none;
  transition: border-color 0.12s;
}
.sub-input::placeholder { color: var(--t3); }
.sub-input:focus { border-color: var(--accent); }

.sub-btn {
  background: var(--accent);
  color: #0a0a0a;
  border: none;
  border-radius: 5px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--sans);
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.12s;
}
.sub-btn:hover { opacity: 0.88; }
.sub-btn:disabled { opacity: 0.5; cursor: default; }

.sub-note {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--t3);
  text-align: center;
  margin-top: 2px;
}

/* ── Subscribe bar ───────────────────────── */

.sub-bar {
  position: fixed;
  bottom: 24px; right: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--s2);
  border: 0.5px solid var(--b2);
  border-radius: 24px;
  padding: 8px 8px 8px 16px;
  z-index: 200;
  box-shadow: 0 4px 24px rgba(0,0,0,0.6);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
}
.sub-bar.visible {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.sub-bar.hidden { display: none; }

.sub-bar-text {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--t2);
  white-space: nowrap;
}

.sub-bar-btn {
  background: var(--accent);
  color: #0a0a0a;
  border: none;
  border-radius: 16px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--sans);
  cursor: pointer;
  transition: opacity 0.12s;
}
.sub-bar-btn:hover { opacity: 0.88; }

@media (max-width: 640px) {
  .sub-bar {
    bottom: 68px; /* above bottom nav */
    right: 12px;
  }
  .sub-modal { padding: 28px 20px 22px; }
}

/* ── Bottom nav (mobile only) ────────────── */

.bottom-nav { display: none; }

@media (max-width: 640px) {
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 56px;
    background: rgba(10,10,10,0.96);
    backdrop-filter: blur(20px);
    border-top: 0.5px solid var(--b);
    z-index: 200;
    align-items: stretch;
  }

  .bnav-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--t3);
    min-height: 44px;
    transition: color 0.1s;
    -webkit-tap-highlight-color: transparent;
    position: relative;
  }

  .bnav-btn.active { color: var(--accent); }
  .bnav-btn.active::before {
    content: '';
    position: absolute;
    top: 0; left: 20%; right: 20%;
    height: 2px;
    background: var(--accent);
    border-radius: 0 0 2px 2px;
  }

  /* ── Rail off ── */
  .rail { display: none; }

  /* ── Main full width ── */
  .main {
    margin-left: 0;
    width: 100%;
    padding-bottom: 56px;
  }

  /* ── Breadcrumb ── */
  .breadcrumb { padding: 14px 16px 10px; }

  /* ── Rows ── */
  .row-thumb { padding: 12px 0 12px 16px; }
  .row-img, .row-no-img { width: 72px; height: 48px; }
  .row-body { padding: 12px 10px; gap: 4px; }
  .row-excerpt { display: none; }
  .row-save-wrap { padding: 0 12px 0 4px; }

  /* ── Mobile panel full-screen ── */
  .article-panel { width: 100%; border-left: none; }

  /* ── Mobile close button tap target ── */
  .panel-close { padding: 12px; margin: -8px -8px -8px 0; }
}

/* ── Tablet ──────────────────────────────── */

@media (min-width: 641px) and (max-width: 900px) {
  .row-thumb { padding: 12px 0 12px 16px; }
  .row-img, .row-no-img { width: 80px; height: 56px; }
  .row-body  { padding: 12px 12px; }
  .row-save-wrap { padding: 0 12px 0 4px; }
  .breadcrumb { padding: 16px 16px 12px; }
  .row-excerpt { display: none; }
}

/* ── Desktop 2-column grid ───────────────── */

@media (min-width: 901px) {
  #feed {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    align-items: start;
  }
  #feed .empty {
    grid-column: 1 / -1;
  }
}
