/* ===== Design Tokens ===== */
:root {
  --bg-primary: #07070d;
  --bg-secondary: #0d0d16;
  --bg-card: #111119;
  --bg-card-hover: #16161f;
  --bg-glass: rgba(17, 17, 25, 0.85);
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);

  --text-primary: #e8e8ef;
  --text-secondary: #8a8a9a;
  --text-muted: #5a5a6d;

  --accent-cyan: #00e5ff;
  --accent-cyan-dim: rgba(0, 229, 255, 0.15);
  --accent-blue: #3d7aed;
  --accent-purple: #8b5cf6;
  --accent-green: #10b981;
  --accent-orange: #f59e0b;
  --accent-red: #ef4444;
  --accent-pink: #ec4899;

  --cat-ai: #00e5ff;
  --cat-crypto: #f59e0b;
  --cat-stocks: #10b981;
  --cat-politics: #8b5cf6;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', monospace;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ===== Reset & Base ===== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  min-height: 100dvh;
  padding-top: var(--safe-top);
  padding-bottom: calc(var(--safe-bottom) + 20px);
}

/* ===== Header ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(180deg, var(--bg-primary) 0%, rgba(7, 7, 13, 0.95) 100%);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  max-width: 720px;
  margin: 0 auto;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-icon {
  font-size: 22px;
  color: var(--accent-cyan);
  filter: drop-shadow(0 0 8px rgba(0, 229, 255, 0.4));
  animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {

  0%,
  100% {
    filter: drop-shadow(0 0 6px rgba(0, 229, 255, 0.3));
  }

  50% {
    filter: drop-shadow(0 0 12px rgba(0, 229, 255, 0.6));
  }
}

.logo-text {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.logo-accent {
  color: var(--accent-cyan);
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.update-time {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
}

.refresh-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 50%;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.25s ease;
}

.refresh-btn:hover {
  background: var(--accent-cyan-dim);
  color: var(--accent-cyan);
  transform: rotate(90deg);
}

/* ===== Tabs ===== */
.tabs {
  position: sticky;
  top: 56px;
  z-index: 90;
  display: flex;
  gap: 6px;
  padding: 12px 16px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  background: linear-gradient(180deg, rgba(7, 7, 13, 0.98) 0%, rgba(7, 7, 13, 0.9) 100%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  max-width: 752px;
  margin: 0 auto;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 100px;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
  flex-shrink: 0;
}

.tab:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.tab.active {
  background: var(--accent-cyan);
  border-color: var(--accent-cyan);
  color: #07070d;
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.tab-icon {
  font-size: 14px;
}

/* ===== Stats Bar ===== */
.stats-bar {
  display: flex;
  gap: 2px;
  padding: 12px 16px;
  max-width: 720px;
  margin: 0 auto;
}

.stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: all 0.3s ease;
}

.stat:first-child {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.stat:last-child {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-cyan);
}

.stat-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 2px;
}

/* ===== Feed ===== */
.feed {
  max-width: 720px;
  margin: 0 auto;
  padding: 8px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ===== News Card ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  cursor: pointer;
  transition: all 0.35s cubic-bezier(0.23, 1, 0.32, 1);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  opacity: 0.8;
  transition: width 0.3s ease;
}

.card[data-cat="AI"]::before {
  background: var(--cat-ai);
}

.card[data-cat="X"]::before {
  background: #ffffff;
}

.card[data-cat="Crypto"]::before {
  background: var(--cat-crypto);
}

.card[data-cat="Stocks"]::before {
  background: var(--cat-stocks);
}

.card[data-cat="Politics"]::before {
  background: var(--cat-politics);
}

.card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  transform: translateY(-1px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.card:hover::before {
  width: 4px;
}

.card:active {
  transform: scale(0.99);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.card-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 3px 8px;
  border-radius: 100px;
  line-height: 1;
}

.card-badge[data-cat="AI"] {
  background: rgba(0, 229, 255, 0.12);
  color: var(--cat-ai);
}

.card-badge[data-cat="X"] {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.card-badge[data-cat="Crypto"] {
  background: rgba(245, 158, 11, 0.12);
  color: var(--cat-crypto);
}

.card-badge[data-cat="Stocks"] {
  background: rgba(16, 185, 129, 0.12);
  color: var(--cat-stocks);
}

.card-badge[data-cat="Politics"] {
  background: rgba(139, 92, 246, 0.12);
  color: var(--cat-politics);
}

.card-source {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.card-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.45;
  color: var(--text-primary);
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  line-clamp: 3;
  overflow: hidden;
}

.card-desc {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-clamp: 2;
  overflow: hidden;
}

.card-priority {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 6px rgba(0, 229, 255, 0.5);
}

.card-priority.low {
  background: var(--text-muted);
  box-shadow: none;
}

/* ===== Loading ===== */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 0;
  gap: 16px;
  color: var(--text-muted);
  font-size: 13px;
}

.loading-spinner {
  width: 28px;
  height: 28px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.35s ease;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  width: 100%;
  max-width: 720px;
  max-height: 85dvh;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 24px 20px calc(var(--safe-bottom) + 24px);
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.23, 1, 0.32, 1);
  position: relative;
}

.modal-overlay.open .modal {
  transform: translateY(0);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.modal-category {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 4px 10px;
  border-radius: 100px;
  margin-bottom: 12px;
}

.modal-title {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.35;
  margin-bottom: 12px;
  letter-spacing: -0.3px;
}

.modal-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.modal-body {
  font-size: 15px;
  line-height: 1.75;
  color: var(--text-secondary);
  margin-bottom: 24px;
  white-space: pre-wrap;
}

.modal-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: var(--accent-cyan);
  color: #07070d;
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}

.modal-link:hover {
  box-shadow: 0 4px 20px rgba(0, 229, 255, 0.35);
  transform: translateY(-1px);
}

/* ===== Empty state ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.3;
}

/* ===== Responsive ===== */
@media (min-width: 768px) {
  .card-title {
    font-size: 16px;
  }

  .modal {
    border-radius: var(--radius-xl);
    margin-bottom: 20px;
  }

  .modal-overlay {
    align-items: center;
  }
}

/* ===== Animations ===== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card {
  animation: fadeInUp 0.4s ease both;
}

.card:nth-child(1) {
  animation-delay: 0.02s;
}

.card:nth-child(2) {
  animation-delay: 0.04s;
}

.card:nth-child(3) {
  animation-delay: 0.06s;
}

.card:nth-child(4) {
  animation-delay: 0.08s;
}

.card:nth-child(5) {
  animation-delay: 0.10s;
}

.card:nth-child(6) {
  animation-delay: 0.12s;
}

.card:nth-child(7) {
  animation-delay: 0.14s;
}

.card:nth-child(8) {
  animation-delay: 0.16s;
}

.card:nth-child(9) {
  animation-delay: 0.18s;
}

.card:nth-child(10) {
  animation-delay: 0.20s;
}