/* ─── Variables (with fallbacks) ───────────── */

:root {
  --bg: #f5f5f5;
  --card: #fff;
  --text: #1a1a1a;
  --muted: #666;
  --border: #e0e0e0;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --error: #dc2626;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f5f5;
  background: var(--bg);
  color: #1a1a1a;
  color: var(--text);
  line-height: 1.5;
}

header {
  background: #fff;
  background: var(--card);
  border-bottom: 1px solid #e0e0e0;
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

header h1 { font-size: 1.25rem; font-weight: 700; }

.header-actions { display: flex; gap: 0.5rem; }

.container { max-width: 720px; margin: 0 auto; padding: 1rem; }

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

.feed-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-bottom: 1rem;
  min-height: 1.5rem;
}

.feed-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.5rem 0.2rem 0.35rem;
  background: #fff;
  background: var(--card);
  border: 1px solid #e0e0e0;
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 0.8rem;
  animation: fadeIn 0.25s ease;
}

.feed-pill.error { border-color: #dc2626; border-color: var(--error); background: #fef2f2; cursor: pointer; }
.feed-pill.error:hover { background: #fde8e8; }

.feed-favicon {
  width: 16px;
  height: 16px;
  border-radius: 2px;
  flex-shrink: 0;
}

.remove-feed {
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  opacity: 0.4;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
}
.remove-feed:hover { opacity: 1; }

/* ─── Items ────────────────────────────────── */

.item {
  background: #fff;
  background: var(--card);
  border: 1px solid #e0e0e0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 0.625rem;
  animation: fadeIn 0.25s ease;
}

.item-meta {
  font-size: 0.75rem;
  color: #666;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.item-title {
  display: block;
  font-size: 1.05rem;
  font-weight: 600;
  color: #1a1a1a;
  color: var(--text);
  text-decoration: none;
  margin-bottom: 0.375rem;
}
.item-title:hover { color: #2563eb; color: var(--accent); }

.item-summary { font-size: 0.875rem; color: #444; }

.preview-text { line-height: 1.5; }

.expand-btn {
  display: block;
  color: #2563eb;
  color: var(--accent);
  cursor: pointer;
  border: none;
  background: none;
  font-size: 0.8rem;
  padding: 0.25rem 0;
  margin-top: 0.25rem;
}
.expand-btn:hover { color: #1d4ed8; color: var(--accent-hover); }

.full-content {
  display: none;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid #e0e0e0;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  line-height: 1.65;
  overflow-x: auto;
}
.full-content.visible { display: block; animation: fadeIn 0.2s ease; }
.full-content img { max-width: 100%; height: auto; border-radius: 4px; }
.full-content a { color: #2563eb; color: var(--accent); text-decoration: underline; }
.full-content blockquote {
  margin: 0.5rem 0;
  padding: 0.25rem 0.75rem;
  border-left: 3px solid #e0e0e0;
  border-left: 3px solid var(--border);
  color: #666;
  color: var(--muted);
}
.full-content pre, .full-content code {
  background: #f0f0f0;
  border-radius: 3px;
  font-size: 0.85em;
}
.full-content pre { padding: 0.5rem; overflow-x: auto; }
.full-content code { padding: 0.1rem 0.3rem; }
.full-content pre code { padding: 0; background: none; }

/* ─── Buttons ──────────────────────────────── */

.btn {
  background: #2563eb;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.4rem 0.9rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
}
.btn:hover { background: #1d4ed8; background: var(--accent-hover); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:disabled:hover { background: #2563eb; background: var(--accent); }
.btn-secondary { background: #6b7280; }
.btn-secondary:hover { background: #4b5563; }

/* ─── Dialog Overlay ───────────────────────── */

.dialog-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.35);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.dialog-overlay.visible { display: flex; }

.dialog {
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  max-width: 460px;
  width: calc(100vw - 2rem);
}
.dialog h2 { margin-bottom: 1rem; font-size: 1.1rem; }
.dialog input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 2px solid #e0e0e0;
  border: 2px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  margin-bottom: 1rem;
  transition: border-color 0.15s;
}
.dialog input:focus { outline: none; border-color: #2563eb; border-color: var(--accent); }
.dialog menu {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  padding: 0;
}

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

.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: #fff;
  padding: 0.5rem 1.25rem;
  border-radius: 8px;
  font-size: 0.85rem;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
  z-index: 200;
}
.toast.visible { opacity: 1; }

/* ─── States ───────────────────────────────── */

.empty-hint { color: #666; color: var(--muted); font-size: 0.85rem; }

.loading { text-align: center; padding: 2rem; color: #666; color: var(--muted); }

.empty {
  text-align: center;
  padding: 3rem 1rem;
  color: #666;
  color: var(--muted);
}
.empty p { margin-bottom: 0.5rem; }

/* ─── Keyframes ────────────────────────────── */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Nav Buttons ──────────────────────────── */

.nav-btn {
  position: fixed;
  right: 0.5rem;
  z-index: 50;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid #ddd;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: #fff;
  background: var(--card);
  color: #666;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.6;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  line-height: 1;
}
.nav-btn:hover, .nav-btn:active { opacity: 0.95; }
.nav-prev { bottom: 4.5rem; }
.nav-next { bottom: 1.25rem; }

/* ─── Responsive ───────────────────────────── */

@media (max-width: 1000px) {
  .container { max-width: 480px; }
  body { font-size: 1.75rem; }
  header h1 { font-size: 1.75rem; }
  .item { padding: 1.6rem 1.6rem; margin-bottom: 1rem; }
  .item-title { font-size: 2.25rem; }
  .item-meta { font-size: 1.1rem; }
  .item-summary { font-size: 1.75rem; }
  .preview-text { line-height: 1.7; }
  .full-content { font-size: 1.75rem; line-height: 1.7; }
  .feed-pill { font-size: 1.3rem; padding: 0.5rem 1rem 0.5rem 0.7rem; }
  .remove-feed { font-size: 2rem; }
  .expand-btn { font-size: 1.4rem; padding: 0.55rem 0; }
  .nav-btn { width: 4.5rem; height: 4.5rem; font-size: 1.8rem; opacity: 0.75; }
  .nav-prev { bottom: 6.5rem; }
  .nav-next { bottom: 1.75rem; }
  .toast { font-size: 1.2rem; padding: 0.8rem 1.8rem; }
}

@media (max-width: 600px) {
  header { padding: 0.6rem 1rem; }
  body { font-size: 1rem; }
  header h1 { font-size: 1.1rem; }
  .container { padding: 0.75rem; }
  .item { padding: 0.75rem 1rem; }
  .item-title { font-size: 1.1rem; }
  .item-summary { font-size: 0.95rem; }
  .full-content { font-size: 0.95rem; }
  .nav-btn { width: 2.25rem; height: 2.25rem; font-size: 0.9rem; }
  .nav-prev { bottom: 4rem; }
  .nav-next { bottom: 1rem; }
}
