:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-card: #0f3460;
  --accent: #e94560;
  --text-primary: #ffffff;
  --text-secondary: #b0b0b0;
  --text-muted: #707070;
  --border: #2a2a4a;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --text-primary: #1a1a2e;
    --text-secondary: #555555;
    --text-muted: #999999;
    --border: #dddddd;
  }
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 8px) calc(var(--safe-right) + 12px) 8px calc(var(--safe-left) + 12px);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.header-title {
  font-size: 1.2rem;
  font-weight: 700;
}

.header-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.header-btn:active {
  background: rgba(255,255,255,0.1);
}

.header-btn.spinning svg {
  animation: spin 0.8s linear infinite;
}

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

/* Sidebar */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  max-width: 80vw;
  background: var(--bg-secondary);
  z-index: 300;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  padding: calc(var(--safe-top) + 16px) 16px calc(var(--safe-bottom) + 16px);
  overflow-y: auto;
}

.sidebar.active {
  transform: translateX(0);
}

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

.sidebar-header h2 {
  font-size: 1.3rem;
  color: var(--accent);
}

.category-list {
  list-style: none;
}

.category-list li {
  padding: 12px 16px;
  border-radius: 8px;
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
  color: var(--text-secondary);
  transition: background 0.2s;
}

.category-list li:active,
.category-list li.active {
  background: var(--bg-card);
  color: var(--text-primary);
}

/* Main */
.main {
  padding: 0 calc(var(--safe-right) + 12px) calc(var(--safe-bottom) + 70px) calc(var(--safe-left) + 12px);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.view-title {
  padding: 16px 0 8px;
  font-size: 1.1rem;
}

/* Search */
.search-bar {
  position: relative;
  margin: 12px 0;
}

.search-bar input {
  width: 100%;
  padding: 10px 40px 10px 14px;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 1rem;
  min-height: 44px;
  outline: none;
  transition: border-color 0.2s;
}

.search-bar input:focus {
  border-color: var(--accent);
}

.search-clear {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  display: none;
  align-items: center;
  justify-content: center;
}

.search-bar input:not(:placeholder-shown) ~ .search-clear {
  display: flex;
}

/* Pull to refresh */
.pull-indicator {
  text-align: center;
  padding: 8px;
  color: var(--text-muted);
  font-size: 0.85rem;
  height: 0;
  overflow: hidden;
  transition: height 0.3s;
}

.pull-indicator.visible {
  height: 36px;
}

/* Article list */
.article-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 16px;
}

/* Article card */
.article-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  transition: transform 0.15s;
  border: 1px solid var(--border);
}

.article-card:active {
  transform: scale(0.98);
}

.article-source {
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.article-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 6px;
}

.article-snippet {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 8px;
}

.article-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.article-meta-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.article-category {
  background: rgba(233,69,96,0.2);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
}

.bookmark-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.bookmark-btn.saved {
  color: var(--accent);
}

/* Bottom Nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 4px 0 calc(var(--safe-bottom) + 4px);
  z-index: 100;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px 0;
  min-height: 44px;
  font-size: 0.65rem;
  transition: color 0.2s;
}

.nav-item.active {
  color: var(--accent);
}

/* Settings */
.settings-list {
  padding: 8px 0;
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  min-height: 44px;
}

.settings-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  min-height: 44px;
}

.settings-btn:active {
  background: var(--accent);
}

/* Toggle switch */
.toggle {
  position: relative;
  width: 52px;
  height: 30px;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 30px;
  cursor: pointer;
  transition: background 0.3s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 24px;
  height: 24px;
  background: white;
  border-radius: 50%;
  transition: transform 0.3s;
}

.toggle input:checked + .toggle-slider {
  background: var(--accent);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(22px);
}

/* Placeholder */
.placeholder {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-muted);
}

.placeholder-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}
