:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-2: #243044;
  --border: #2d3a4f;
  --text: #e8edf5;
  --muted: #8b9cb3;
  --primary: #4f8cff;
  --primary-hover: #3d7aef;
  --danger: #ff6b6b;
  --success: #3dd68c;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --header-height: 88px;
  --mobile-nav-height: 68px;
  --sidebar-width: 380px;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: radial-gradient(circle at top, #1a2740 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
}

button,
input {
  font: inherit;
}

button {
  touch-action: manipulation;
}

a {
  color: var(--primary);
}

.app {
  max-width: 1600px;
  margin: 0 auto;
  padding: 16px 16px calc(var(--mobile-nav-height) + 16px + env(safe-area-inset-bottom));
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-shrink: 0;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  min-width: 0;
}

.brand-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), #7c5cff);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.brand h1,
.sidebar-header h2,
.content-header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.brand-tagline,
.subtitle,
.hint,
.sidebar-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.brand-tagline {
  display: none;
}

.header-actions,
.dialog-actions,
.sidebar-header,
.content-header {
  display: flex;
  gap: 12px;
  align-items: center;
}

.offline-badge {
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 107, 107, 0.15);
  color: #ffb4b4;
  border: 1px solid rgba(255, 107, 107, 0.35);
}

.layout {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 0;
}

.panel {
  display: none;
}

.panel.active {
  display: flex;
}

.sidebar,
.content {
  background: rgba(26, 35, 50, 0.85);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  min-height: 0;
}

.sidebar {
  padding: 16px;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.sidebar-header {
  justify-content: space-between;
  flex-shrink: 0;
}

.content {
  padding: 16px;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.content-header {
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
}

.content-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.back-btn {
  flex-shrink: 0;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  transition: 0.15s ease;
  white-space: nowrap;
}

.btn-sm {
  padding: 8px 12px;
  font-size: 0.9rem;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

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

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: #2f3f58;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  color: var(--text);
  background: var(--surface-2);
}

.btn-danger {
  background: rgba(255, 107, 107, 0.15);
  color: var(--danger);
  border: 1px solid rgba(255, 107, 107, 0.35);
}

.feeds-list,
.articles-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  flex: 1;
  min-height: 0;
  overscroll-behavior: contain;
}

.feed-item,
.article-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  background: rgba(15, 20, 25, 0.35);
  cursor: pointer;
  transition: 0.15s ease;
}

.feed-item:hover,
.article-item:hover {
  border-color: var(--primary);
}

.feed-item.active {
  border-color: var(--primary);
  background: rgba(79, 140, 255, 0.12);
}

.feed-item-header,
.article-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.feed-title,
.article-title {
  margin: 0;
  font-size: 1rem;
  line-height: 1.35;
}

.feed-title-wrap {
  min-width: 0;
}

.feed-meta,
.article-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feed-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 0.85rem;
}

.icon-btn:hover {
  color: var(--text);
  background: var(--surface-2);
}

.icon-btn.danger:hover {
  color: var(--danger);
  background: rgba(255, 107, 107, 0.12);
}

.article-title a {
  color: inherit;
  text-decoration: none;
}

.article-title a:hover {
  color: var(--primary);
}

.article-summary {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  background: rgba(79, 140, 255, 0.15);
  color: var(--primary);
}

.badge.unread {
  background: rgba(61, 214, 140, 0.15);
  color: var(--success);
}

.badge.disabled {
  background: rgba(139, 156, 179, 0.15);
  color: var(--muted);
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 48px 16px;
}

.dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0;
  width: min(520px, 92vw);
  max-height: 90dvh;
  box-shadow: var(--shadow);
}

.dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.dialog form {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dialog h3 {
  margin: 0 0 4px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
}

input[type="text"],
input[type="url"],
input[type="password"] {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  width: 100%;
}

.toggle {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.preview-box,
.install-hint {
  padding: 12px;
  border-radius: 8px;
  background: rgba(79, 140, 255, 0.08);
  border: 1px solid rgba(79, 140, 255, 0.25);
  font-size: 0.9rem;
}

.hidden {
  display: none !important;
}

.mobile-only {
  display: flex;
}

.desktop-only {
  display: none;
}

.mobile-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  background: rgba(15, 20, 25, 0.92);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(16px);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  justify-content: space-around;
  align-items: stretch;
  gap: 4px;
}

.mobile-nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 4px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 0.7rem;
  cursor: pointer;
}

.mobile-nav-btn.active {
  color: var(--primary);
  background: rgba(79, 140, 255, 0.12);
}

.mobile-nav-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.mobile-nav-fab {
  flex: 0 0 auto;
  width: 52px;
  margin-top: -18px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), #7c5cff);
  color: white;
  box-shadow: var(--shadow);
}

.mobile-nav-fab .mobile-nav-icon {
  font-size: 1.6rem;
  font-weight: 700;
}

.toast {
  position: fixed;
  bottom: calc(var(--mobile-nav-height) + 16px + env(safe-area-inset-bottom));
  left: 16px;
  right: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 100;
  text-align: center;
}

.toast.error {
  border-color: rgba(255, 107, 107, 0.5);
  color: #ffd0d0;
}

.toast.success {
  border-color: rgba(61, 214, 140, 0.5);
  color: #c9ffe4;
}

.offline-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
}

.offline-card {
  text-align: center;
  max-width: 420px;
  padding: 32px;
  background: rgba(26, 35, 50, 0.85);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.offline-card h1 {
  margin: 16px 0 8px;
}

.offline-card p {
  color: var(--muted);
  margin-bottom: 20px;
}

@media (min-width: 768px) {
  .app {
    padding: 24px;
    padding-bottom: 24px;
  }

  .brand-tagline {
    display: block;
  }

  .toast {
    left: auto;
    right: 24px;
    bottom: 24px;
    max-width: 420px;
    text-align: left;
  }

  .mobile-only {
    display: none !important;
  }

  .desktop-only {
    display: inline-flex;
  }

  .layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    gap: 20px;
    min-height: calc(100dvh - var(--header-height) - 48px);
  }

  .panel {
    display: flex;
  }

  .sidebar,
  .content {
    max-height: calc(100dvh - var(--header-height) - 48px);
  }

  .feed-actions .icon-btn {
    min-width: 34px;
  }
}

@media (min-width: 1200px) {
  :root {
    --sidebar-width: 420px;
  }

  .sidebar {
    padding: 20px;
  }

  .content {
    padding: 20px;
  }

  .article-item {
    padding: 18px;
  }

  .feed-item {
    padding: 16px;
  }

  .icon-btn .action-label {
    display: inline;
  }
}

@media (max-width: 767px) {
  .header-actions .btn-ghost {
    padding: 10px 12px;
  }

  .brand h1 {
    font-size: 1.1rem;
  }

  .content-header {
    flex-direction: column;
    align-items: stretch;
  }

  .content-header .toggle {
    justify-content: flex-end;
  }
}
