/* Scry — Source Reader */

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

:root {
  --bg: #f5f5f5;
  --card-bg: #fff;
  --border: #e0e0e0;
  --text: #111;
  --text-secondary: #666;
  --text-muted: #999;
  --text-faint: #bbb;
  --accent: #007aff;
  --save-bg: #111;
  --save-text: #fff;
  --mark-read-bg: #2d8a4e;
  --mark-read-text: #fff;
  --relevance-bg: #f0f6ff;
  --relevance-text: #007aff;
  --note-bg: #fffbe6;
  --danger: #d33;
}

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", system-ui, sans-serif;
  color: var(--text);
  line-height: 1.4;
  padding-bottom: 60px; /* space for bottom nav */
  min-height: 100vh;
}

[x-cloak] { display: none !important; }

/* Page layout */
.page {
  max-width: 640px;
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 12px 8px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 50;
}

.page-header h1 {
  font-size: 20px;
  font-weight: 700;
}

.header-count {
  font-size: 13px;
  color: var(--text-muted);
}

/* Toggle group */
.toggle-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
}
.toggle-group {
  display: inline-flex;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.toggle-btn {
  font-size: 11px;
  padding: 4px 10px;
  background: var(--card-bg);
  color: var(--text-muted);
  border: none;
  cursor: pointer;
  border-right: 1px solid var(--border);
  font-weight: 500;
  letter-spacing: 0.2px;
  font-family: inherit;
}

.toggle-btn:last-child { border-right: none; }
.toggle-btn.active { background: var(--text); color: #fff; }
.toggle-btn:hover:not(.active) { background: #f0f0f0; }

.toggle-btn.active { background: #888; color: #fff; }

/* Feed filter dropdown */
.feed-filter {
  font-size: 11px;
  padding: 4px 8px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: var(--card-bg);
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  max-width: 140px;
}

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

/* Sort filter dropdown (mobile) */
.sort-filter {
  font-size: 11px;
  padding: 4px 8px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: var(--card-bg);
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
}

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

/* Mobile/desktop visibility */
.mobile-only { display: none; }

@media (max-width: 767px) {
  .desktop-only { display: none !important; }
  .mobile-only { display: initial; }
}

/* Search */
.sticky-header {
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 50;
}

.sticky-header .page-header {
  position: static;
}

.search-bar {
  padding: 4px 12px 8px;
}

.search-input {
  width: 100%;
  font-size: 13px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  font-family: inherit;
  color: var(--text);
}

.search-input::placeholder { color: var(--text-faint); }
.search-input:focus { outline: none; border-color: var(--accent); }

/* Cards */
.card-list {
  padding: 0 4px;
}

.card {
  background: var(--card-bg);
  margin: 8px;
  border-radius: 10px;
  padding: 14px;
  border: 1px solid #e8e8e8;
  transition: box-shadow 0.15s;
}

.card.focused {
  box-shadow: 0 0 0 2px var(--accent);
}

.card.discarded-card {
  opacity: 0.55;
}

.card.discarded-card:hover {
  opacity: 0.8;
}

/* Flag button */
.card { position: relative; }

.flag-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-faint);
  padding: 2px;
  line-height: 1;
  border-radius: 4px;
  transition: color 0.15s;
}

.flag-btn:hover { color: var(--text-muted); }
.flag-btn.flagged { color: #d97706; }
.flag-btn.flagged:hover { color: #b45309; }

.card.read-card {
  opacity: 0.55;
}

.card.read-card:hover {
  opacity: 0.8;
}

/* Meta row */
.meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.dot {
  width: 3px;
  height: 3px;
  background: #ccc;
  border-radius: 50%;
  flex-shrink: 0;
}

.spacer { flex: 1; }

.type-badge {
  background: #f0f0f0;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  color: var(--text-secondary);
  text-transform: lowercase;
}

/* Vault mini chips (read view) */
.meta-vault-wrapper {
  position: relative;
  display: flex;
  gap: 4px;
}

.vault-mini {
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 3px;
  background: #f0f0f0;
  color: #777;
  cursor: pointer;
  user-select: none;
}

.vault-mini.on {
  background: #e8e8e8;
  color: #444;
}

.vault-dropdown {
  position: absolute;
  top: 22px;
  right: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.vault-dropdown .vault-chip {
  font-size: 10px;
  padding: 2px 8px;
  white-space: nowrap;
}

/* Card content */
.card h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 4px;
}

.person {
  font-size: 12px;
  color: #555;
  margin-bottom: 4px;
}

.summary {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 6px;
}

.summary-clamp p {
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.summary-more {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 0;
  font-family: inherit;
}

.summary-more:hover {
  color: var(--accent);
}

.relevance {
  font-size: 11px;
  color: var(--relevance-text);
  background: var(--relevance-bg);
  padding: 4px 8px;
  border-radius: 6px;
  margin-bottom: 10px;
  display: inline-block;
}

.user-note {
  font-size: 12px;
  color: #444;
  background: var(--note-bg);
  padding: 6px 8px;
  border-radius: 6px;
  margin-bottom: 10px;
  font-style: italic;
}

.read-badge {
  font-size: 11px;
  color: var(--mark-read-bg);
  margin-bottom: 6px;
}

.notes-preview {
  font-size: 12px;
  color: #555;
  background: #f8f8f8;
  padding: 8px;
  border-radius: 6px;
  margin-bottom: 10px;
  line-height: 1.4;
  border-left: 3px solid #ddd;
  white-space: pre-wrap;
}

.wikilink { color: var(--accent); }

/* Vault chips (triage — full size) */
.vaults {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.vault-chip {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  color: #888;
  cursor: pointer;
  background: transparent;
  font-family: inherit;
  transition: all 0.1s;
}

.vault-chip.on {
  border-color: var(--text);
  color: var(--text);
  background: #f5f5f5;
}

.vault-chip:hover {
  border-color: var(--text-secondary);
}

/* Inputs */
.input {
  width: 100%;
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  color: var(--text);
  background: var(--card-bg);
}

.input:focus { outline: none; border-color: var(--accent); }
.input::placeholder { color: var(--text-faint); }

.note-input {
  width: 100%;
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  resize: vertical;
  font-family: inherit;
  color: var(--text);
  margin-bottom: 8px;
  min-height: 36px;
}

.note-input:focus { outline: none; border-color: var(--accent); }
.note-input::placeholder { color: var(--text-faint); }

.save-form label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.note-title-input {
  width: 100%;
  font-size: 12px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: monospace;
  color: var(--text);
  margin-bottom: 8px;
  background: #fafafa;
}

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

/* Buttons */
.actions {
  display: flex;
  gap: 8px;
}

.btn {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  flex: 1;
  text-align: center;
  font-family: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.1s;
}

.btn:hover { opacity: 0.85; }

.btn-discard { background: #f0f0f0; color: var(--text-secondary); }
.btn-save-triage { background: var(--save-bg); color: var(--save-text); }
.btn-open { background: #f0f0f0; color: var(--accent); }
.btn-save { background: var(--save-bg); color: var(--save-text); }
.btn-mark-read { background: var(--mark-read-bg); color: var(--mark-read-text); }
.btn-primary { background: var(--save-bg); color: var(--save-text); }
.btn-secondary { background: #f0f0f0; color: var(--text); }
.btn-muted { background: #f0f0f0; color: var(--text-muted); }
.btn-danger { background: #f0f0f0; color: var(--danger); }
.btn-small { padding: 6px 12px; font-size: 12px; flex: none; }
.btn-block { width: 100%; }

/* Form rows */
.form-row {
  margin-bottom: 8px;
}

.feed-card h3 a {
  color: inherit;
  text-decoration: none;
}
.feed-card h3 a:hover {
  text-decoration: underline;
}

/* Feed card extras */
.feed-url {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
  word-break: break-all;
}

.feed-status {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 500;
}

.feed-status.active { background: #e6f4ea; color: #1a7f37; }
.feed-status.paused { background: #fff3e0; color: #b86e00; }

/* Bottom nav */
.bottombar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: #fafafa;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
  position: relative;
  padding: 4px 12px;
}

.nav-item.active { color: var(--text); }
.nav-icon { font-size: 18px; }
.nav-label { font-size: 10px; }

.nav-badge {
  position: absolute;
  top: 0;
  right: 4px;
  background: var(--danger);
  color: #fff;
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 8px;
  font-weight: 600;
}

.add-btn .nav-icon {
  font-size: 24px;
  font-weight: 300;
  line-height: 1;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.modal {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 20px;
  width: 100%;
  max-width: 400px;
}

.modal h3 {
  font-size: 17px;
  margin-bottom: 12px;
}

.modal .input {
  margin-bottom: 12px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* Flash messages */
.flash {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin-top: 8px;
  background: #f0f0f0;
  color: var(--text-secondary);
}

.flash.success { background: #e6f4ea; color: #1a7f37; }
.flash.error { background: #fde8e8; color: #c62828; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

/* Undo link */
.undo-link {
  display: block;
  padding: 4px 12px;
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
}
.undo-link:hover { color: var(--accent); }

/* Keyboard hint */
.keyboard-hint {
  text-align: center;
  padding: 8px;
  font-size: 10px;
  color: var(--text-faint);
}

/* Add feed card */
.add-feed-card {
  margin: 8px 12px;
}

/* Responsive */
@media (min-width: 768px) {
  .page {
    max-width: 680px;
  }

  .card {
    margin: 8px 12px;
  }
}

/* Login */
.login-container {
  max-width: 320px;
  margin: 120px auto 0;
  padding: 0 20px;
}

.login-container h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 24px;
  text-align: center;
}

.login-container .input {
  margin-bottom: 12px;
}

.login-container .btn {
  margin-top: 4px;
}

.login-container .flash {
  margin-bottom: 16px;
}

/* htmx loading indicator */
.htmx-request .btn {
  opacity: 0.5;
  pointer-events: none;
}

/* New feed highlight */
@keyframes feed-highlight {
  0% { background: #e0edff; }
  100% { background: var(--card-bg); }
}

.feed-new {
  animation: feed-highlight 30s ease-out;
}

/* Poll button spinner */
.btn-poll .poll-loading { display: none; }
.btn-poll.htmx-request .poll-label { display: none; }
.btn-poll.htmx-request .poll-loading { display: inline; }

/* Add Feed button spinner */
.btn-add-feed .add-feed-loading { display: none; }
.htmx-request .btn-add-feed .add-feed-label { display: none; }
.htmx-request .btn-add-feed .add-feed-loading { display: inline; }

/* Import OPML button spinner */
.btn-import-opml .import-opml-loading { display: none; }
.htmx-request .btn-import-opml .import-opml-label { display: none; }
.htmx-request .btn-import-opml .import-opml-loading { display: inline; }
.htmx-request .btn-add-feed::before,
.htmx-request .btn-import-opml::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 1.5px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 4px;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.btn-poll.htmx-request::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 1.5px solid var(--text-muted);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 4px;
  vertical-align: middle;
}

/* Toast */
.toast-container {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: #e6f4ea;
  color: #1a7f37;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: auto;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Account page */
.account-section {
  margin: 8px 12px;
}

.account-section h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
}

.api-key-row {
  padding: 10px 14px;
}

.api-key-info {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.api-key-prefix {
  font-size: 12px;
  color: var(--text-muted);
  background: #f0f0f0;
  padding: 1px 6px;
  border-radius: 4px;
}
