@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700&family=Inter:wght@300;400;500;600;700&display=swap');

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

html, body {
  font-family: 'Inter', system-ui, sans-serif;
  background: #0d0d1a;
  color: #e8e8f0;
  min-height: 100vh;
  width: 100%;
  overflow-x: hidden;
}

/* ── Header ── */
header {
  background: linear-gradient(135deg, hsl(235, 100%, 50%) 0%, hsl(235, 100%, 50%),hsl(235, 100%, 50%));
  border-bottom: 1px solid hwb(0 100% 0%);
  padding: 12px 20px 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 24px rgba(30, 30, 120, 0.3);
}

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

.logo {
  font-family: 'Playfair Display', serif;
  font-size: 26px;
  font-weight: 700;
  background: linear-gradient(90deg, #7986cb, #3949ab);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.5px;
}

.status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #5c6bc0;
}

#last-updated { font-size: 11px; color: #3d4f9f; }

#refresh-btn {
  background: transparent;
  border: 1px solid #3949ab;
  color: #7986cb;
  padding: 5px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s;
}
#refresh-btn:hover {
  background: rgba(121,134,203,0.1);
  border-color: #7986cb;
  color: #c5cae9;
}

/* ── Profile Button ── */
.profile-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3949ab, #1a237e);
  border: 2px solid #3949ab;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
  position: relative;
}
.profile-btn:hover {
  border-color: #7986cb;
  box-shadow: 0 0 0 3px rgba(121,134,203,0.2);
}

/* ── Profile Dropdown ── */
.profile-wrap {
  position: relative;
}

.profile-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background: #12122e;
  border: 1px solid #1e1e5e;
  border-radius: 14px;
  min-width: 220px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  overflow: hidden;
  z-index: 999;
}
.profile-dropdown.open { display: block; }

.profile-header {
  padding: 16px 18px;
  border-bottom: 1px solid #1e1e5e;
  background: linear-gradient(135deg, #0a0a2e, #1a1a4e);
}
.profile-name {
  font-size: 13px;
  font-weight: 600;
  color: #c5cae9;
  margin-bottom: 2px;
}
.profile-email {
  font-size: 11px;
  color: #5c6bc0;
  word-break: break-all;
}

.profile-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  font-size: 13px;
  color: #9fa8da;
  cursor: pointer;
  transition: background 0.2s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.profile-item:hover { background: rgba(121,134,203,0.1); color: #c5cae9; }
.profile-item.danger { color: #ef9a9a; }
.profile-item.danger:hover { background: rgba(239,154,154,0.1); color: #f44336; }

#sort-select {
  padding: 5px 10px;
  border-radius: 20px;
  border: 1px solid #3949ab;
  background: rgba(255,255,255,0.05);
  color: #7986cb;
  font-size: 11px;
  cursor: pointer;
}
#sort-select option { background: #0a0a2e; }

/* ── Search bar ── */
.search-wrap { margin-bottom: 10px; }

.search-bar {
  width: 100%;
  padding: 10px 16px;
  background: #ffffff;
  border: none;
  border-radius: 10px;
  color: #0a0a2e;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  transition: box-shadow 0.2s;
  box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}
.search-bar:focus {
  outline: none;
  box-shadow: 0 0 0 2px #3949ab, 0 2px 12px rgba(0,0,0,0.2);
}
.search-bar::placeholder { color: #9fa8da; }

/* ── Stock Tabs ── */
.stock-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 0;
  overflow-x: auto;
  scrollbar-width: none;
  align-items: center;
  -webkit-overflow-scrolling: touch;
}
.stock-tabs::-webkit-scrollbar { display: none; }

.tab {
  background: rgba(255,255,255,0.04);
  border: 1px solid #1e1e5e;
  color: #5c6bc0;
  padding: 6px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.2s;
  flex-shrink: 0;
  user-select: none;
}
.tab:hover {
  border-color: #3949ab;
  color: #9fa8da;
  background: rgba(121,134,203,0.08);
}
.tab.active {
  background: linear-gradient(90deg, #1a237e, #3949ab);
  color: #fff;
  border-color: transparent;
  font-weight: 600;
  box-shadow: 0 2px 12px rgba(57,73,171,0.4);
}

/* ── Tab wrap with long press remove ── */
.tab-wrap {
  position: relative;
  flex-shrink: 0;
}

.tab-context-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #12122e;
  border: 1px solid #1e1e5e;
  border-radius: 10px;
  padding: 6px;
  z-index: 999;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  white-space: nowrap;
}
.tab-context-menu.open { display: block; }

.tab-context-item {
  display: block;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 500;
  color: #ef9a9a;
  cursor: pointer;
  border-radius: 6px;
  border: none;
  background: none;
  width: 100%;
  text-align: center;
  transition: background 0.2s;
}
.tab-context-item:hover { background: rgba(239,154,154,0.1); }

/* ── Sentiment Filters ── */
.sentiment-filters {
  display: flex;
  gap: 6px;
  padding: 10px 0;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.sentiment-filters::-webkit-scrollbar { display: none; }

.sentiment-btn {
  border: 1px solid #1e1e5e;
  padding: 5px 16px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  background: transparent;
  white-space: nowrap;
  flex-shrink: 0;
}
.sentiment-btn.all { color: #5c6bc0; }
.sentiment-btn.bullish { color: #69f0ae; }
.sentiment-btn.bearish { color: #ef9a9a; }
.sentiment-btn.neutral { color: #5c6bc0; }
.sentiment-btn.active { background: rgba(255,255,255,0.06); border-color: #3949ab; color: #fff; }
.sentiment-btn.bullish.active { border-color: #69f0ae; color: #69f0ae; }
.sentiment-btn.bearish.active { border-color: #ef9a9a; color: #ef9a9a; }

/* ── News Grid ── */
.news-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
  padding: 20px;
  width: 100%;
  background: #0d0d1a;
}

/* ── News Card ── */
.news-card {
  background: #ffffff;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  border-radius: 16px;
  width: 100%;
  box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}
.news-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 28px rgba(30,35,120,0.25);
}
.news-card.bullish { border-top: 3px solid #00c853; }
.news-card.bearish { border-top: 3px solid #f44336; }
.news-card.neutral { border-top: 3px solid #3949ab; }

.card-body { padding: 18px 20px; }

.card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  gap: 8px;
}

.stock-badge {
  background: linear-gradient(90deg, #1a237e, #3949ab);
  color: #fff;
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.time-label { font-size: 10px; color: #aaa; white-space: nowrap; }

.card-headline {
  font-family: 'Playfair Display', serif;
  font-size: 17px;
  font-weight: 600;
  color: #0a0a2e;
  line-height: 1.5;
  margin-bottom: 10px;
  cursor: pointer;
  transition: color 0.2s;
}
.card-headline:hover { color: #3949ab; }

.card-story {
  font-size: 13px;
  color: #666;
  line-height: 1.8;
  margin-bottom: 12px;
  min-height: 70px;
}

.sentiment-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 20px;
  margin-bottom: 10px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.sentiment-tag.bullish { background: #e8f5e9; color: #2e7d32; }
.sentiment-tag.bearish { background: #ffebee; color: #c62828; }
.sentiment-tag.neutral { background: #e8eaf6; color: #3949ab; }

.card-source {
  font-size: 10px;
  color: #bbb;
  border-top: 1px solid #f0f0f0;
  padding-top: 8px;
  margin-top: 2px;
}

.bookmark-btn {
  background: none;
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 10px;
  color: #aaa;
  transition: all 0.2s;
}
.bookmark-btn:hover { border-color: #3949ab; color: #3949ab; }
.bookmark-btn.bookmarked { border-color: #3949ab; color: #3949ab; background: #e8eaf6; }

.loading {
  grid-column: 1 / -1;
  text-align: center;
  color: #3d4f9f;
  padding: 80px 20px;
  font-size: 14px;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #12122e;
  border: 1px solid #3949ab;
  color: #c5cae9;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  z-index: 9999;
  transition: transform 0.3s ease;
  white-space: nowrap;
  box-shadow: 0 8px 32px rgba(30,35,120,0.4);
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ── Auth Page ── */
.auth-box {
  background: #12122e;
  border-radius: 20px;
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  border: 1px solid #1e1e5e;
  margin: 16px;
}
.auth-logo {
  font-family: 'Playfair Display', serif;
  font-size: 28px;
  text-align: center;
  margin-bottom: 4px;
  font-weight: 700;
  background: linear-gradient(90deg, #7986cb, #3949ab);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.auth-sub { text-align: center; color: #3d4f9f; margin-bottom: 28px; font-size: 13px; }
.auth-tabs {
  display: flex;
  margin-bottom: 24px;
  border: 1px solid #1e1e5e;
  border-radius: 10px;
  overflow: hidden;
}
.auth-tab {
  flex: 1; padding: 10px; border: none;
  background: transparent; color: #5c6bc0;
  cursor: pointer; font-size: 13px; font-weight: 500; transition: all 0.2s;
}
.auth-tab.active { background: linear-gradient(90deg, #1a237e, #3949ab); color: #fff; }
.auth-input {
  width: 100%; padding: 12px 14px; margin-bottom: 10px;
  border-radius: 10px; border: 1px solid #1e1e5e;
  background: rgba(255,255,255,0.04); color: #e8e8f0;
  font-size: 13px; box-sizing: border-box;
  font-family: 'Inter', sans-serif; transition: border-color 0.2s;
}
.auth-input:focus { outline: none; border-color: #3949ab; }
.auth-input::placeholder { color: #3d4f9f; }
.auth-btn {
  width: 100%; padding: 13px; border: none; border-radius: 10px;
  background: linear-gradient(90deg, #1a237e, #3949ab);
  color: #fff; font-size: 15px; font-weight: 600;
  cursor: pointer; margin-top: 6px; transition: all 0.2s;
  font-family: 'Inter', sans-serif;
  box-shadow: 0 4px 16px rgba(57,73,171,0.4);
}
.auth-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 24px rgba(57,73,171,0.5); }
.auth-error { color: #ef9a9a; font-size: 12px; margin: 4px 0; min-height: 16px; }

/* ── Mobile ── */
@media (max-width: 600px) {
  header { padding: 10px 14px 0; }
  .header-inner { flex-wrap: wrap; gap: 8px; }
  .news-grid { grid-template-columns: 1fr; padding: 12px; gap: 12px; }
  .logo { font-size: 22px; }
  .status-bar { gap: 6px; }
  #refresh-btn { padding: 4px 12px; font-size: 11px; }
  .card-headline { font-size: 16px; }
  .auth-box { padding: 28px 20px; }
}