@font-face {
  font-family: "Lora";
  src: url("/fonts/lora-regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Lora";
  src: url("/fonts/lora-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Lora";
  src: url("/fonts/lora-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Lora";
  src: url("/fonts/lora-700italic.woff2") format("woff2");
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

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

:root {
  --bg: #faf9f5;
  --text: #1a1a1a;
  --text-secondary: #666;
  --border: #e0ddd4;
  --hover: #f3f1ec;
  --accent: #b85c2a;
  --read-bg: #edeae3;
  --read-text: #aaa;
  --header-bg: #faf9f5;
  --header-text: #1a1a1a;
  --star-color: #f59e0b;
  --swipe-read: #22c55e;
  --swipe-star: #f59e0b;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  -webkit-user-select: none;
  user-select: none;
}

/* Header */
#header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--header-bg);
  color: var(--header-text);
}

#menu-btn {
  background: none;
  border: none;
  color: var(--header-text);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
}

#refresh-btn {
  background: none;
  border: none;
  -webkit-appearance: none;
  appearance: none;
  box-shadow: none;
  color: var(--header-text);
  font-size: 26px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

#header-title {
  font-size: 18px;
  font-weight: 600;
  flex: 1;
}

#entry-count {
  font-size: 14px;
  opacity: 0.7;
}

/* Sidebar */
#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  height: 100%;
  background: var(--bg);
  border-right: 1px solid var(--border);
  z-index: 200;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.2s ease;
}

#sidebar.open {
  transform: translateX(0);
}

#sidebar.hidden {
  display: block;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 199;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

#add-feed-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  color: var(--accent);
  padding: 0 2px;
}

/* Add feed modal */
.add-feed-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.add-feed-modal {
  background: var(--bg);
  border-radius: 12px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  overflow: hidden;
}

.add-feed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.add-feed-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0;
  line-height: 1;
}

.add-feed-body {
  padding: 20px;
}

.add-feed-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  box-sizing: border-box;
  margin-bottom: 12px;
}

.add-feed-input:focus {
  outline: none;
  border-color: var(--accent);
}

.add-feed-search-btn {
  width: 100%;
  padding: 10px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.add-feed-search-btn:disabled {
  opacity: 0.6;
}

.add-feed-results {
  margin-top: 16px;
}

.add-feed-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
}

.add-feed-result-info {
  flex: 1;
  min-width: 0;
}

.add-feed-confirm-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.add-feed-result-title {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.add-feed-result-url {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.add-feed-add-btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.add-feed-add-btn:disabled {
  opacity: 0.6;
}

.add-feed-message {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 8px 0 0;
}

.add-feed-success { color: #16a34a; }
.add-feed-error { color: #dc2626; }

.feed-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.feed-section-label--manage {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.feed-filter-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  box-sizing: border-box;
  margin-bottom: 8px;
}

.feed-filter-input:focus {
  outline: none;
  border-color: var(--accent);
}

.feed-list {
  max-height: 280px;
  overflow-y: auto;
}

.feed-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.feed-list-item:last-child {
  border-bottom: none;
}

.feed-list-info {
  flex: 1;
  min-width: 0;
}

.feed-list-title {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.feed-list-category {
  font-size: 12px;
  color: var(--text-secondary);
}

.feed-delete-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}

.feed-delete-btn--confirm {
  border-color: #dc2626;
  color: #dc2626;
}

.category-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.category-item:active,
.category-item.active {
  background: var(--hover);
  color: var(--accent);
}

.category-count {
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--hover);
  padding: 2px 8px;
  border-radius: 10px;
}

/* Entry list */
#entry-list {
  min-height: calc(100vh - 52px);
}

.entry-row {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}

.entry-swipe-bg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
}

.entry-swipe-bg .swipe-left-label {
  margin-left: auto;
  padding-right: 20px;
  background: var(--swipe-read);
  height: 100%;
  display: flex;
  align-items: center;
  width: 100%;
  justify-content: flex-end;
}

.entry-swipe-bg .swipe-right-label {
  padding-left: 20px;
  background: var(--swipe-star);
  height: 100%;
  display: flex;
  align-items: center;
  width: 100%;
}

.entry-content {
  position: relative;
  background: var(--bg);
  padding: 10px 16px;
  cursor: pointer;
  transition: transform 0.15s ease;
  display: flex;
  gap: 8px;
}

.entry-content:active {
  background: var(--hover);
}

.entry-text {
  flex: 1;
  min-width: 0;
}

.entry-title {
  font-family: ui-serif, Charter, "Lora", Georgia, serif;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.entry-meta {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entry-star {
  color: var(--star-color);
  font-size: 12px;
  flex-shrink: 0;
  align-self: center;
}

/* Toggle read/unread button */
.toggle-read-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 10px;
  cursor: pointer;
  padding: 6px;
  flex-shrink: 0;
  align-self: center;
  opacity: 0.6;
  line-height: 1;
}

.toggle-read-btn:hover {
  opacity: 1;
}

.entry-row.read .toggle-read-btn {
  color: var(--read-text);
}

.entry-row.read .entry-title {
  color: var(--read-text);
  font-weight: 400;
}

.entry-row.read .entry-content {
  background: var(--read-bg);
}

/* Read mode icons */
.read-mode-icon {
  display: inline-block;
  margin-left: 6px;
  font-size: 11px;
  cursor: pointer;
  padding: 1px 4px;
  border-radius: 3px;
  vertical-align: middle;
}

.read-mode-swiped {
  color: #999;
}

.read-mode-previewed {
  color: var(--accent);
}

.read-mode-clicked_through {
  color: var(--swipe-read);
}

.read-mode-popup {
  position: fixed;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  z-index: 300;
  min-width: 160px;
  overflow: hidden;
}

.read-mode-option {
  padding: 10px 14px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}

.read-mode-option:last-child {
  border-bottom: none;
}

.read-mode-option:active,
.read-mode-option.active {
  background: var(--hover);
  color: var(--accent);
}

/* Entry detail */
#entry-detail {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 150;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transform: translateX(0);
  transition: transform 0.15s ease;
}

#entry-detail.hidden {
  transform: translateX(100%);
  pointer-events: none;
}

.detail-header {
  position: sticky;
  top: -1px;
  background: var(--header-bg);
  color: var(--header-text);
  padding: 13px 16px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 10;
}

.detail-back {
  background: none;
  border: none;
  color: var(--header-text);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
}

.detail-title {
  font-size: 16px;
  font-weight: 600;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Read/unread toggle in detail header */
.detail-read-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--header-text);
  font-size: 13px;
  padding: 5px 10px;
  border-radius: 14px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  opacity: 0.75;
}

.detail-read-toggle[data-status="unread"] {
  opacity: 1;
  border-color: var(--header-text);
}

.detail-read-toggle:active {
  background: var(--hover);
}

.detail-read-toggle:disabled {
  opacity: 0.4;
}

/* Summary button */
.summary-btn {
  background: var(--hover);
  border: 1px solid var(--border);
  color: var(--header-text);
  font-size: 13px;
  padding: 5px 12px;
  border-radius: 14px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.summary-btn:active {
  background: var(--border);
}

.summary-btn:disabled {
  opacity: 0.5;
}

/* Detail body - Feedly-inspired clean reading */
.detail-body {
  padding: 0;
  background: var(--bg);
  animation: detail-body-in 0.25s ease-out both;
  animation-delay: 0.08s;
}

@keyframes detail-body-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.detail-container {
  max-width: 680px;
  margin: 0 auto;
  padding: 28px 20px 60px;
  -webkit-user-select: text;
  user-select: text;
}

.detail-body h1 {
  font-family: ui-serif, Charter, "Lora", Georgia, serif;
  font-size: 26px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.01em;
  margin-bottom: 16px;
  color: var(--text);
  font-feature-settings: "kern" 1, "liga" 1;
  font-optical-sizing: auto;
}

.detail-body .detail-meta {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 24px;
  padding-bottom: 0;
  line-height: 1.8;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  align-items: center;
}

.detail-source {
  font-weight: 600;
  color: var(--accent);
}

.detail-body h1 a.detail-original {
  color: inherit;
  text-decoration: none;
}

.detail-body h1 a.detail-original:active {
  text-decoration: underline;
}

/* Article content - clean readable typography */
.article-content {
  font-family: ui-serif, Charter, "Lora", Georgia, serif;
  font-size: 20px;
  line-height: 1.6;
  color: #333;
  word-wrap: break-word;
  -webkit-user-select: text;
  user-select: text;
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1;
  font-optical-sizing: auto;
}

.article-content p {
  margin-bottom: 1.2em;
}

.article-content img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  margin: 1.2em 0;
  display: block;
}

.article-content a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.article-content h2,
.article-content h3,
.article-content h4 {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin-top: 1.8em;
  margin-bottom: 0.6em;
  line-height: 1.3;
  color: var(--text);
}

.article-content h2 { font-size: 22px; }
.article-content h3 { font-size: 19px; }
.article-content h4 { font-size: 17px; }

.article-content blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 16px;
  margin: 1.4em 0;
  color: var(--text-secondary);
  font-style: italic;
}

.article-content figure {
  margin: 1.5em 0;
}

.article-content figcaption {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
  margin-top: 8px;
}

.article-content pre {
  overflow-x: auto;
  background: var(--hover);
  padding: 14px;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.5;
  margin: 1.2em 0;
  font-family: "SF Mono", Menlo, Consolas, monospace;
}

.article-content code {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--hover);
  padding: 2px 5px;
  border-radius: 3px;
}

.article-content pre code {
  background: none;
  padding: 0;
}

.article-content ul,
.article-content ol {
  margin-bottom: 1.2em;
  padding-left: 1.5em;
}

.article-content li {
  margin-bottom: 0.4em;
}

.article-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.2em 0;
  font-size: 15px;
}

.article-content th,
.article-content td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}

.article-content th {
  background: var(--hover);
  font-weight: 600;
}

.article-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2em 0;
}

/* Summary box */
.summary-box {
  background: #f0f7ff;
  border-left: 3px solid var(--accent);
  padding: 14px 18px;
  margin-bottom: 20px;
  border-radius: 0 6px 6px 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.6;
  color: #333;
}

.summary-box.loading {
  color: var(--text-secondary);
  font-style: italic;
}

.summary-box.error {
  background: #fff0f0;
  border-left-color: #dc2626;
  color: #dc2626;
}

.summary-sources {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  font-size: 13px;
  color: #666;
}

.summary-sources ul {
  margin: 4px 0 0;
  padding-left: 18px;
}

.summary-sources li {
  margin-bottom: 3px;
  word-break: break-all;
}

.summary-source-label {
  font-weight: 500;
}

.summary-source-url {
  color: var(--accent);
}

.summary-discuss-link {
  display: block;
  margin-top: 12px;
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
}

/* Link summary inline buttons */
.link-summary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0;
  margin-left: 4px;
  vertical-align: middle;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s;
  -webkit-user-select: none;
  user-select: none;
}

.link-summary-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.link-summary-btn.has-summary {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(37, 99, 235, 0.06);
}

.link-summary-btn.loading {
  opacity: 0.6;
  cursor: wait;
  padding: 0;
  animation: ls-spin 1s linear infinite;
}

@keyframes ls-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Link summary popup */
.link-summary-popup {
  position: fixed;
  z-index: 400;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
  padding: 14px 16px;
  max-height: 60vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.link-summary-popup:not(.mobile) {
  width: 340px;
}

.link-summary-popup.mobile {
  left: 16px;
  right: 16px;
  bottom: 24px;
  width: auto;
  max-height: 50vh;
}

.link-summary-popup-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 2px 4px;
  line-height: 1;
}

.link-summary-popup-close:hover {
  color: var(--text);
}

.link-summary-popup-content {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  padding-right: 20px;
  -webkit-user-select: text;
  user-select: text;
}

/* Loading */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
}

.load-more {
  text-align: center;
  padding: 16px;
}

.load-more button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 24px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}

/* Column elements hidden on mobile */
.entry-source,
.entry-age {
  display: none;
}

/* Tablet/desktop: Feedly-style columnar layout */
@media (min-width: 768px) {
  .entry-text {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .entry-source {
    display: block;
    flex-shrink: 0;
    width: 160px;
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .entry-title {
    flex: 1;
    display: block;
    -webkit-line-clamp: unset;
    font-size: 15px;
  }

  .entry-age {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    flex-shrink: 0;
    width: 80px;
    text-align: right;
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
  }

  .entry-meta {
    display: none;
  }

  .entry-content {
    padding: 8px 20px;
  }
}

/* Mobile only (phones/Android — not iPad) */
@media (max-width: 767px) {
  .article-content {
    font-size: 18px;
  }
}

/* Utility */
.hidden { display: none; }
