/* USL Web Reader — TabNook-style three-pane RSS UI, USL theme tokens. */

#readerArea {
  --reader-sidebar-w: 280px;
}

.reader-page {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  min-height: 70vh;
}

.reader-sidebar {
  flex: 0 0 var(--reader-sidebar-w);
  width: var(--reader-sidebar-w);
  background: var(--usl-surface);
  border: 1px solid var(--usl-border);
  border-radius: 12px;
  padding: 14px;
  position: sticky;
  top: 12px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 24px);
}

.reader-feed-tree {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.reader-feed-list {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 80px;
}

.reader-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.reader-sidebar-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'Rajdhani', sans-serif;
  color: var(--usl-heading);
}

.reader-sidebar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.reader-sidebar-actions .btn {
  flex: 1 1 auto;
  font-size: 0.78rem;
  white-space: nowrap;
}

.reader-guest-note {
  font-size: 0.8rem;
  color: var(--usl-muted);
  background: var(--usl-surface-2);
  border: 1px solid var(--usl-border);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 10px;
  line-height: 1.4;
}

.reader-guest-note a { font-weight: 600; }

.reader-quick-views {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
  border-bottom: 1px solid var(--usl-border);
  padding-bottom: 10px;
}

.reader-view-item,
.reader-feed-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--usl-text);
  transition: background 0.12s ease;
}

.reader-view-item:hover,
.reader-feed-row:hover {
  background: var(--usl-surface-2);
}

.reader-view-item.active,
.reader-feed-row.active,
.reader-folder-header.active {
  background: var(--usl-surface-2);
  color: var(--usl-heading);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--usl-accent);
}

.reader-count {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 600;
  background: #1e4a58;
  color: #e7f6f8;
  border-radius: 999px;
  padding: 1px 7px;
  min-width: 20px;
  text-align: center;
}

html[data-theme="light"] .reader-count {
  background: #d2eef2;
  color: #163844;
}

.reader-count:empty,
.reader-count[data-count="0"] {
  display: none;
}

.reader-folder,
.reader-uncat {
  margin-top: 0;
  border-radius: 8px;
}

.reader-folder-header,
.reader-uncat-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--usl-muted);
  cursor: pointer;
}

.reader-uncat-header { cursor: default; }

.reader-folder-feeds { margin-left: 6px; min-height: 4px; }

.reader-folder-caret {
  font-size: 0.7rem !important;
  transition: transform 0.15s ease;
  cursor: pointer;
  padding: 2px;
}

.reader-folder-collapsed .reader-folder-caret { transform: rotate(-90deg); }
.reader-folder-collapsed .reader-folder-feeds { display: none; }

.reader-feed-row.reader-dragging { opacity: 0.45; }

.reader-folder.reader-drop-target,
.reader-uncat.reader-drop-target {
  background: var(--usl-surface-2);
  outline: 2px dashed #5ec4d4;
  outline-offset: -2px;
}

.reader-feed-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-feed-row .reader-feed-actions {
  display: none;
  margin-left: auto;
  gap: 2px;
}

.reader-feed-row:hover .reader-feed-actions { display: flex; }

.reader-folder-header .reader-feed-actions {
  display: flex;
  margin-left: auto;
  gap: 2px;
}

.reader-feed-actions .icon-btn {
  background: none;
  border: none;
  color: var(--usl-muted);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 0.8rem;
}
.reader-feed-actions .icon-btn:hover { color: var(--usl-accent); }
.reader-feed-actions .icon-btn.is-default { color: #5ec4d4; }

.reader-feed-favicon {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  object-fit: cover;
}

.reader-feed-row.has-error .reader-feed-title { color: #dc2626; }

.reader-main { flex: 1 1 auto; min-width: 0; }

.reader-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.reader-stream-title {
  margin: 0;
  font-weight: 700;
  font-family: 'Rajdhani', sans-serif;
  color: var(--usl-heading);
}

.reader-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.reader-search { position: relative; display: flex; align-items: center; }
.reader-search i {
  position: absolute;
  left: 9px;
  color: var(--usl-muted);
  font-size: 0.85rem;
  pointer-events: none;
}
.reader-search input {
  padding-left: 28px;
  width: 200px;
}

.reader-stream {
  --reader-font-size: 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  grid-auto-rows: 1fr;
  gap: 16px;
}
.reader-stream .reader-loading,
.reader-stream .reader-empty { grid-column: 1 / -1; }

.reader-article {
  display: flex;
  flex-direction: column;
  background: var(--usl-surface);
  border: 1px solid var(--usl-border);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.12s ease, transform 0.12s ease;
  font-size: var(--reader-font-size, 1rem);
}
.reader-article:hover {
  box-shadow: 0 6px 18px var(--usl-shadow);
  transform: translateY(-2px);
}
.reader-article.is-read { opacity: 0.6; }
.reader-article.is-read .reader-article-title { font-weight: 600; }

.reader-article-thumb-wrap {
  width: 100%;
  height: 168px;
  background: var(--usl-surface-2);
  overflow: hidden;
}
.reader-article-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.reader-article-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  padding: 14px 16px 12px;
  min-width: 0;
  min-height: 0;
}
.reader-article-main {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.reader-article-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.74em;
  color: var(--usl-muted);
  margin-bottom: 6px;
}
.reader-article-feed {
  font-weight: 600;
  color: #3aa8b8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.reader-article-title {
  margin: 0 0 7px;
  font-size: 1em;
  font-weight: 700;
  line-height: 1.35;
  color: var(--usl-heading);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.reader-article-excerpt {
  margin: 0;
  font-size: 0.85em;
  color: var(--usl-muted);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1 1 auto;
}
.reader-article-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--usl-border);
}
.reader-article-url {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 8px 0 2px;
  font-size: 0.72em;
  color: var(--usl-muted);
  background: linear-gradient(to bottom, transparent, var(--usl-surface) 45%);
}
.reader-article:hover .reader-article-url {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.reader-article-btn {
  background: none;
  border: 1px solid var(--usl-border-2);
  border-radius: 8px;
  color: var(--usl-muted);
  cursor: pointer;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  text-decoration: none;
}
.reader-article-btn:hover {
  border-color: #5ec4d4;
  color: #3aa8b8;
  background: var(--usl-surface-2);
}
.reader-article-btn.is-saved { color: #f59e0b; border-color: #f59e0b; }

.reader-stream.reader-font-serif .reader-article { font-family: Georgia, 'Times New Roman', serif; }
.reader-stream.reader-font-sans-serif .reader-article { font-family: Arial, Helvetica, sans-serif; }
.reader-stream.reader-font-newspaper .reader-article { font-family: 'Times New Roman', Times, serif; }
.reader-stream.reader-font-modern .reader-article { font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; }
.reader-stream.reader-font-readable .reader-article { font-family: Verdana, Geneva, sans-serif; }

.reader-empty,
.reader-loading {
  text-align: center;
  padding: 48px 16px;
  color: var(--usl-muted);
}
.reader-empty i { font-size: 2.2rem; display: block; margin-bottom: 10px; opacity: 0.6; }
.reader-load-more-wrap { grid-column: 1 / -1; text-align: center; padding: 12px 0; }

.reader-search-result {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--usl-border);
}
.reader-result-icon {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--usl-surface-2);
}
.reader-result-icon-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--usl-accent);
  font-size: 1.1rem;
}
.reader-result-body { flex: 1 1 auto; min-width: 0; }
.reader-result-title { font-weight: 600; font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-result-desc { font-size: 0.8rem; color: var(--usl-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-result-error { margin-top: 5px; font-size: 0.78rem; color: #dc2626; }
.reader-catalog-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #3aa8b8;
  margin-left: 6px;
}

.reader-spin { animation: reader-spin 0.8s linear infinite; }
@keyframes reader-spin { to { transform: rotate(360deg); } }

/* Reading pane — improvement over TabNook (which only opens the original). */
.reader-pane {
  position: fixed;
  inset: 0;
  z-index: 1080;
  display: none;
}
.reader-pane.is-open { display: block; }
.reader-pane-backdrop {
  position: absolute;
  inset: 0;
  background: var(--usl-overlay);
}
.reader-pane-sheet {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(760px, 100%);
  background: var(--usl-surface);
  box-shadow: -8px 0 32px var(--usl-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.reader-pane-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--usl-border);
  flex-shrink: 0;
}
.reader-pane-toolbar .spacer { flex: 1; }
.reader-pane-body {
  overflow-y: auto;
  padding: 24px 28px 48px;
  font-size: 1.05rem;
  line-height: 1.65;
}
.reader-pane-body h1,
.reader-pane-body h2 { font-family: 'Rajdhani', sans-serif; }
.reader-pane-body img { max-width: 100%; height: auto; border-radius: 8px; }
.reader-pane-meta { color: var(--usl-muted); font-size: 0.9rem; margin-bottom: 16px; }
.reader-pane-hero { width: 100%; border-radius: 10px; margin-bottom: 18px; }

@media (max-width: 768px) {
  .reader-page { flex-direction: column; }
  .reader-sidebar {
    flex-basis: auto;
    width: 100%;
    position: static;
    max-height: none;
  }
  .reader-search input { width: 140px; }
  .reader-stream { grid-template-columns: 1fr; }
}

.reader-wrap {
  max-width: 1280px;
  margin: 0 auto;
  padding: 10px 16px 40px;
}
.reader-hero h1 {
  font-size: 1.85rem;
  margin: 8px 0 6px;
  font-family: 'Rajdhani', sans-serif;
}
.reader-hero h1 span { color: var(--usl-accent); }
.reader-lede {
  color: var(--usl-muted);
  font-size: .95rem;
  max-width: 42rem;
  margin-bottom: 18px;
}
.btn-group.reader-filter-toggle .btn.active {
  background: #1e4a58 !important;
  border-color: #5ec4d4 !important;
  color: #e7f6f8 !important;
}

body.reader-pane-open { overflow: hidden; }

#readerPaneBody {
  font-size: var(--reader-font-size, 1rem);
  line-height: 1.6;
}
#readerPaneBody.reader-font-serif { font-family: Georgia, 'Times New Roman', serif; }
#readerPaneBody.reader-font-sans-serif { font-family: Arial, Helvetica, sans-serif; }
#readerPaneBody.reader-font-newspaper { font-family: 'Times New Roman', Times, serif; }
#readerPaneBody.reader-font-modern { font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; }
#readerPaneBody.reader-font-readable { font-family: Verdana, Geneva, sans-serif; }
#readerPaneSave.is-saved { color: #d4a017; }
