/* RSS Reader - Drudge/Craigslist aesthetic. Intentionally plain. */

/* Base */
:root {
  --touch-min: 44px;
  --content-max: 680px;
  --padding-mobile: 12px;
  --padding-desktop: 16px;
  --font-size-article: 18px;
  --line-height-article: 1.6;
}

/* Minimal: light */
[data-style="minimal"][data-color-scheme="light"] {
  --bg: #fff;
  --bg-elevated: #fff;
  --text: #000;
  --text-muted: #333;
  --accent: #000;
  --accent-visited: #333;
  --border: #000;
}

/* Minimal: dark */
[data-style="minimal"][data-color-scheme="dark"] {
  --bg: #1a1a1a;
  --bg-elevated: #222;
  --text: #ddd;
  --text-muted: #999;
  --accent: #ddd;
  --accent-visited: #999;
  --border: #444;
}

/* Craigslist: light */
[data-style="craigslist"][data-color-scheme="light"] {
  --bg: #f5f5f5;
  --bg-elevated: #fff;
  --text: #000;
  --text-muted: #333;
  --accent: #0000ee;
  --accent-visited: #551a8b;
  --border: #ccc;
}

/* Craigslist: dark */
[data-style="craigslist"][data-color-scheme="dark"] {
  --bg: #1a1a1a;
  --bg-elevated: #222;
  --text: #ddd;
  --text-muted: #999;
  --accent: #6eb3ff;
  --accent-visited: #b89aff;
  --border: #444;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: "Times New Roman", Times, serif;
  font-size: 14px;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: 12px;
  overflow-x: hidden;
}

body[data-font-family="arial"] {
  font-family: Arial, Helvetica, sans-serif;
}

body[data-font-family="times"] {
  font-family: "Times New Roman", Times, serif;
}

body[data-font-family="courier"] {
  font-family: "Courier New", Courier, monospace;
}

#app {
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 100vw;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: var(--touch-min);
  padding: 6px var(--padding-mobile);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

body[data-nav-position="bottom"] .app-header {
  order: 1;
  top: auto;
  bottom: 0;
  border-bottom: none;
  border-top: 1px solid var(--border);
}

body[data-nav-position="bottom"] #main {
  order: 0;
}

body[data-nav-position="bottom"] .toast {
  bottom: auto;
  top: calc(24px + env(safe-area-inset-top, 0px));
}

.app-header-main {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.app-header-main[hidden] {
  display: none;
}

.app-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 0;
  text-decoration: none;
  color: var(--text);
}

.app-title-wrap:hover,
.app-title-wrap:focus-visible {
  color: var(--accent);
}

.app-title-wrap:visited {
  color: var(--text);
}

.app-title {
  margin: 0;
  font-size: 1rem;
  font-weight: bold;
  color: inherit;
  line-height: 1.2;
}

.app-title-sub {
  margin: 0;
  font-size: 0.75rem;
  font-weight: normal;
  color: var(--text-muted);
  line-height: 1.2;
}

.app-header-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.header-nav-link {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
}

.header-nav-link:hover,
.header-nav-link:focus-visible {
  color: var(--text);
}

.header-nav-link.nav-active {
  color: var(--text);
  font-weight: bold;
}

.icon-btn {
  width: var(--touch-min);
  height: var(--touch-min);
  min-width: var(--touch-min);
  min-height: var(--touch-min);
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.icon-btn:hover,
.icon-btn:focus-visible {
  background: var(--border);
}

.icon-btn[hidden] {
  display: none;
}

.app-header .icon-btn {
  flex-shrink: 0;
}

#btn-back::before {
  content: "‹";
  font-size: 1.25rem;
}

#btn-refresh::before {
  content: "↻";
  font-size: 1.25rem;
}

/* Main */
.main {
  flex: 1;
  position: relative;
  overflow: hidden;
  max-width: 100%;
}

.view {
  display: none;
  flex-direction: column;
  min-height: 100%;
  padding: 0 0 12px;
}

.view-active {
  display: flex;
}

.pull-indicator {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%) translateY(-100%);
  z-index: 20;
  padding: 8px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.pull-indicator.pulling {
  transform: translateX(-50%) translateY(0);
}

/* Article list */
.article-list,
.feed-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.article-item {
  position: relative;
  min-height: var(--touch-min);
  padding: 10px var(--padding-mobile);
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  cursor: pointer;
  overflow: hidden;
  touch-action: pan-y;
}

.article-item:active {
  background: var(--border);
}

.article-item.unread .article-item-title {
  font-weight: bold;
}

.article-item-title {
  margin: 0 0 2px;
  font-size: 0.95rem;
  font-weight: normal;
  line-height: 1.3;
  color: var(--accent);
  text-decoration: underline;
}

.article-item-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.article-item-swipe-hint {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  pointer-events: none;
  transition: transform 0.2s;
}

.article-item-swipe-hint.left {
  left: 0;
  background: var(--border);
  color: var(--text);
  transform: translateX(-100%);
}

.article-item-swipe-hint.right {
  right: 0;
  background: var(--border);
  color: var(--text);
  transform: translateX(100%);
}

.article-item.swipe-left .article-item-swipe-hint.left {
  transform: translateX(0);
}

.article-item.swipe-right .article-item-swipe-hint.right {
  transform: translateX(0);
}

#view-feeds {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.feeds-add-sticky {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.feeds-toolbar {
  padding: 8px var(--padding-mobile);
}

.feeds-toolbar .btn-primary {
  width: 100%;
}

/* Feed list */
.feed-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--touch-min);
  padding: 10px var(--padding-mobile);
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  gap: 8px;
  overflow: hidden;
  touch-action: pan-y;
}

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

.feed-item-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: bold;
  color: var(--text);
}

.feed-item-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.feed-item.muted .feed-item-title {
  opacity: 0.6;
}

.feed-item-new-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-left: 6px;
  vertical-align: middle;
}

/* Empty state */
.empty-state {
  padding: 24px var(--padding-mobile);
  text-align: center;
}

.empty-title {
  font-size: 1rem;
  font-weight: bold;
  margin: 0 0 6px;
  color: var(--text);
}

.empty-philosophy {
  font-size: 1rem;
  font-weight: bold;
  margin: 0 0 10px;
  color: var(--text);
}

.empty-text {
  color: var(--text-muted);
  margin: 0 0 16px;
  font-size: 0.9rem;
}

.empty-import-link-wrap {
  margin: 12px 0 0;
  font-size: 0.8rem;
}

.empty-import-link {
  color: var(--text-muted);
  text-decoration: underline;
}

.empty-import-link:hover,
.empty-import-link:focus-visible {
  color: var(--text);
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch-min);
  padding: 8px 16px;
  border: 1px solid var(--border);
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  background: var(--bg-elevated);
  font-family: inherit;
}

.btn-primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-danger {
  background: transparent;
  color: #c00;
  border-color: #c00;
}

.btn-danger:hover {
  background: rgba(204,0,0,0.1);
}

/* Add feed form */
.add-feed-form {
  padding: var(--padding-mobile);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.add-feed-form label {
  display: block;
  font-weight: bold;
  margin-bottom: 6px;
  color: var(--text);
  font-size: 0.9rem;
}

.add-feed-form input[type="url"] {
  width: 100%;
  min-height: 36px;
  padding: 8px 10px;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  margin-bottom: 6px;
  font-family: inherit;
}

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

.hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0 0 10px;
}

.hint a {
  color: var(--accent);
  text-decoration: underline;
}

.import-status-wrap #import-status {
  white-space: pre-wrap;
}

.import-failed-list {
  margin: 6px 0 0;
  padding-left: 20px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.form-actions button {
  min-height: 36px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  font-size: 0.9rem;
  cursor: pointer;
  background: var(--bg-elevated);
  color: var(--text);
  font-family: inherit;
}

.form-actions .btn-primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.add-feed-pending-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.add-feed-pending-card {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.add-feed-pending-label {
  margin: 0 0 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  word-break: break-all;
}

.add-feed-pending-status {
  margin: 0 0 8px;
}

.add-feed-pending-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.youtube-choice-btn {
  width: 100%;
  text-align: left;
}

.youtube-playlists-container {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.youtube-playlists-container .youtube-choices-title {
  margin-bottom: 8px;
}

.youtube-playlists-container .youtube-choice-btn {
  margin-bottom: 6px;
}

/* Settings */
.settings-list {
  padding: var(--padding-mobile);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 36px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.setting-row span {
  color: var(--text);
  font-size: 0.9rem;
}

.setting-row select {
  min-height: 36px;
  padding: 4px 8px;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.setting-toggle input[type="checkbox"] {
  width: 44px;
  height: 24px;
  accent-color: var(--accent);
  cursor: pointer;
  font-family: inherit;
}

.setting-proxy-urls {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.setting-proxy-urls label {
  font-size: 0.9rem;
  color: var(--text);
}

.setting-proxy-urls textarea {
  width: 100%;
  padding: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  resize: vertical;
  min-height: 60px;
}

.setting-actions {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setting-actions .btn-secondary,
.setting-actions .btn-danger {
  width: 100%;
}

/* About view */
.about-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--padding-mobile);
  padding-bottom: 24px;
}

.about-title {
  margin: 0 0 10px;
  font-size: 1rem;
  font-weight: bold;
  color: var(--text);
}

.about-philosophy {
  margin: 0 0 12px;
  font-size: 1rem;
  font-weight: bold;
  line-height: 1.4;
  color: var(--text);
}

.about-text {
  margin: 0 0 10px;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.about-text a {
  color: var(--accent);
  text-decoration: underline;
}

.about-text a:visited {
  color: var(--accent-visited);
}

.about-text:last-of-type {
  margin-bottom: 24px;
}

.install-app-card {
  padding: 16px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  margin-bottom: 24px;
}

.install-app-title {
  margin: 0 0 8px;
  font-size: 0.95rem;
  font-weight: bold;
  color: var(--text);
}

.install-app-text {
  margin: 0 0 12px;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.install-prompt-inner {
  margin-bottom: 12px;
}

.install-prompt-inner[hidden] {
  margin-bottom: 0;
}

.install-app-manual {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text-muted);
}

/* Article reader */
.view-article {
  padding: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.article-content {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--padding-mobile);
  padding-bottom: 60px;
}

.article-content .article-body {
  font-size: var(--font-size-article);
  line-height: var(--line-height-article);
  color: var(--text);
}

.article-content .article-body img {
  max-width: 100%;
  height: auto;
}

.article-content .article-body a {
  color: var(--accent);
  text-decoration: underline;
}

.article-content .article-body a:visited {
  color: var(--accent-visited);
}

.article-body .no-preview {
  color: var(--text-muted);
  font-style: italic;
  padding: 1em;
  border: 1px dashed var(--border);
  border-radius: 4px;
}

.article-content h1 {
  font-size: 1.25rem;
  line-height: 1.3;
  margin: 0 0 8px;
  color: var(--text);
}

.article-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.article-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.article-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.load-more-wrap {
  padding: 16px;
  text-align: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.load-more-wrap[hidden] {
  display: none !important;
}

.load-more-wrap .btn-secondary {
  min-width: 120px;
}

.feed-action-dialog {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 0 env(safe-area-inset-bottom, 0);
}

.feed-action-dialog[hidden] {
  display: none;
}

.feed-action-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.feed-action-dialog-content {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: var(--bg-elevated);
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.feed-action-dialog-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: bold;
  color: var(--text);
}

.feed-action-dialog-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.feed-action-dialog-actions .btn-secondary,
.feed-action-dialog-actions .btn-danger {
  width: 100%;
}

.add-feed-dialog {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: env(safe-area-inset-top, 0) 0 0 0;
}

.add-feed-dialog[hidden] {
  display: none;
}

.add-feed-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.add-feed-dialog-content {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--bg-elevated);
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.add-feed-dialog-tabs {
  display: flex;
  gap: 4px;
  margin: -4px 0 4px;
}

.add-feed-tab {
  flex: 1;
  min-height: var(--touch-min);
  padding: 10px 12px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}

.add-feed-tab:hover,
.add-feed-tab:focus-visible {
  color: var(--text);
}

.add-feed-tab-active {
  color: var(--text);
  background: var(--bg);
  border-color: var(--border);
}

.add-feed-label-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.add-feed-tab-panel label {
  font-weight: 500;
}

.add-feed-inline-link {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.add-feed-inline-link:hover {
  color: var(--accent);
}

.add-feed-dialog-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.add-feed-podcasts-results {
  max-height: 240px;
  overflow-y: auto;
  margin-top: 8px;
}

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

.add-feed-podcast-item img {
  width: 60px;
  height: 60px;
  border-radius: 4px;
  flex-shrink: 0;
}

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

.add-feed-podcast-item-info strong {
  display: block;
  font-size: 0.9rem;
}

.add-feed-podcast-item-info span {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.header-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

.header-loading[hidden] {
  display: none;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.toast {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 10px 20px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.9rem;
  border-radius: 8px;
  z-index: 25;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Tablet+ */
@media (min-width: 768px) {
  body {
    padding-bottom: 0;
  }

  .app-header {
    padding-left: var(--padding-desktop);
    padding-right: var(--padding-desktop);
  }

  .article-item,
  .feed-item {
    padding-left: var(--padding-desktop);
    padding-right: var(--padding-desktop);
  }

  .article-content {
    padding: var(--padding-desktop);
    padding-bottom: 32px;
  }

}

body[data-article-font="16"] .article-content .article-body {
  font-size: 16px;
}

body[data-article-font="20"] .article-content .article-body {
  font-size: 20px;
}
