:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #242836;
  --border: #2e3345;
  --text: #e8eaef;
  --text-muted: #9aa3b5;
  --accent: #5b8def;
  --accent-hover: #7aa3f5;
  --success: #3ecf8e;
  --warning: #f0b429;
  --danger: #e85d5d;
  --fav: #f5c542;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,.35);
  --sidebar-w: 280px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app {
  display: flex;
  height: 100%;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 20;
  transition: transform .25s ease;
}

.sidebar-header {
  padding: 1.25rem 1.25rem 0.75rem;
  position: relative;
}

.sidebar-header h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.nav-cats {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0.75rem;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.9rem;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: background .15s;
}

.nav-item:hover { background: var(--surface2); }
.nav-item.active {
  background: rgba(91, 141, 239, 0.18);
  color: var(--accent);
  font-weight: 600;
}

.badge {
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  min-width: 1.4rem;
  text-align: center;
}

.nav-item.active .badge {
  background: rgba(91, 141, 239, 0.3);
  color: var(--accent);
}

.nav-divider {
  height: 1px;
  background: var(--border);
  margin: 0.5rem 0.5rem;
}

.sidebar-footer {
  padding: 0.75rem 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

/* Main */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.topbar-title {
  font-size: 1.05rem;
  font-weight: 600;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem 2rem;
}

/* Cards */
.list {
  display: grid;
  gap: 0.75rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  cursor: pointer;
  transition: border-color .15s, transform .1s;
}

.card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.card.unread {
  border-left: 3px solid var(--accent);
}

.card-header {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.card-title {
  font-weight: 600;
  font-size: 0.98rem;
  flex: 1;
  line-height: 1.35;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.85rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.45rem;
}

.card-preview {
  font-size: 0.88rem;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tag {
  display: inline-block;
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 0.72rem;
  padding: 0.12rem 0.45rem;
  border-radius: 6px;
}

.status-new { color: var(--accent); }
.status-read { color: var(--text-muted); }
.status-done { color: var(--success); }

.fav-star {
  color: var(--fav);
  font-size: 1rem;
  line-height: 1;
}

/* Detail */
.detail-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  position: sticky;
  top: 0;
  background: var(--bg);
  padding: 0.5rem 0;
  z-index: 5;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-left: auto;
}

.detail-body {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 820px;
}

.detail-body h2 {
  font-size: 1.35rem;
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.detail-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.detail-content {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.95rem;
  line-height: 1.65;
}

.detail-content h1, .detail-content h2, .detail-content h3 {
  margin: 1.2em 0 0.5em;
}

/* Buttons & controls */
.btn, .btn-icon {
  font-family: inherit;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

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

.btn.secondary {
  background: transparent;
}

.btn.danger {
  border-color: rgba(232, 93, 93, 0.4);
  color: var(--danger);
}

.btn.danger:hover {
  background: rgba(232, 93, 93, 0.15);
}

.btn.full { width: 100%; }

.btn-icon {
  padding: 0.4rem 0.55rem;
  font-size: 1.1rem;
  line-height: 1;
}

.select {
  font-family: inherit;
  font-size: 0.85rem;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
}

.hidden { display: none !important; }

.empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty .hint {
  margin-top: 0.75rem;
  font-size: 0.85rem;
}

.empty code {
  background: var(--surface2);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.8rem;
}

.mobile-only { display: none; }

/* Responsive */
@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-only { display: inline-flex; }
  .content { padding: 0.85rem 0.9rem 1.5rem; }
  .detail-body { padding: 1.1rem; }
  .detail-actions { margin-left: 0; width: 100%; }
  .detail-toolbar { flex-direction: column; align-items: stretch; }
}

@media (max-width: 480px) {
  .card { padding: 0.85rem; }
  .topbar { padding: 0.7rem 0.85rem; }
}

/* ===== Login screen ===== */
.login-screen {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(91,141,239,.15), transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(62,207,142,.08), transparent 45%),
    var(--bg);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2.25rem 1.75rem;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow);
}

.login-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), #3ecf8e);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.35rem;
  color: #fff;
  letter-spacing: -0.03em;
}

.login-card h1 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.login-sub {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.75rem;
  line-height: 1.4;
}

.yandex-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.75rem 1rem;
  background: #fc3f1d;
  border: none;
  color: #fff !important;
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: 10px;
  text-decoration: none;
  transition: background .15s, transform .1s;
}

.yandex-btn:hover {
  background: #e03516;
  transform: translateY(-1px);
}

.login-hint {
  margin-top: 1rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* User block in sidebar */
.user-block {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem 1.1rem;
  border-bottom: 1px solid var(--border);
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface2);
  object-fit: cover;
  flex-shrink: 0;
}

.user-info { min-width: 0; }
.user-name {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-email {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#btnEnablePush.subscribed {
  border-color: rgba(62, 207, 142, 0.45);
  color: var(--success);
}
