/* ============================================================
   NewsHub v2 — Blue theme, Market bar, Rich cards
   ============================================================ */

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

:root {
  --blue:       #0057b8;
  --blue-lt:    #1a73e8;
  --blue-dk:    #003f8a;
  --blue-bg:    #e8f0fe;
  --red:        #d9000d;
  --green:      #0a7c3e;
  --green-lt:   #16a34a;
  --orange:     #c2410c;
  --gray-50:    #f7f9fc;
  --gray-100:   #eef1f6;
  --gray-200:   #dde3ed;
  --gray-300:   #bfc8d9;
  --gray-500:   #6b7a99;
  --gray-700:   #374151;
  --gray-900:   #111827;
  --text:       #111827;
  --text-muted: #4b5563;
  --text-light: #9ca3af;
  --border:     #e2e8f0;
  --white:      #fff;
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.07);
  --shadow:     0 2px 10px rgba(0,0,0,0.09);
  --shadow-md:  0 4px 20px rgba(0,0,0,0.13);
  --radius-sm:  4px;
  --radius:     8px;
  --radius-lg:  12px;
  --font:       'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --max-w:      1280px;
}

html { font-size: 15px; scroll-behavior: smooth; }
body { font-family: var(--font); background: var(--gray-50); color: var(--text); line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font-family: var(--font); cursor: pointer; }

/* ── Market Bar ──────────────────────────────────────────── */
.market-bar {
  background: var(--gray-900);
  height: 34px;
  overflow: hidden;
  display: flex;
  align-items: center;
}
.market-inner {
  display: flex;
  align-items: center;
  gap: 0;
  white-space: nowrap;
  animation: market-scroll 60s linear infinite;
  padding-left: 20px;
}
.market-inner:hover { animation-play-state: paused; }
@keyframes market-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}
.market-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  font-size: 12px;
}
.m-sym   { color: #fff; font-weight: 700; letter-spacing: 0.03em; }
.m-price { color: #d1d5db; font-variant-numeric: tabular-nums; }
.m-chg.up   { color: #4ade80; }
.m-chg.down { color: #f87171; }
.m-divider  { color: #374151; padding: 0 4px; }
.m-spacer   { display: inline-block; width: 60px; }
.market-loading { color: #6b7280; font-size: 12px; padding: 0 16px; }

/* ── Utility Bar ─────────────────────────────────────────── */
.utility-bar { background: #1e2a3a; color: #9ca3af; font-size: 11.5px; }
.utility-inner { max-width: var(--max-w); margin: 0 auto; padding: 5px 20px; display: flex; justify-content: space-between; align-items: center; }
.utility-left, .utility-right { display: flex; align-items: center; gap: 8px; }
.u-sep { color: #374151; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: #374151; display: inline-block; transition: background 0.3s; }
.status-dot.live { background: #4ade80; box-shadow: 0 0 5px #4ade80; }
.status-dot.loading { background: #fbbf24; }
.u-refresh-btn { background: none; border: 1px solid #374151; color: #9ca3af; font-size: 11px; padding: 2px 8px; border-radius: 3px; transition: all 0.15s; }
.u-refresh-btn:hover { border-color: #9ca3af; color: #fff; }
.u-auto-label { display: flex; align-items: center; gap: 4px; cursor: pointer; font-size: 11px; }

/* ── Header ──────────────────────────────────────────────── */
.main-header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: var(--shadow-sm);
}
.header-inner { max-width: var(--max-w); margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 20px; }

.logo { font-size: 26px; font-weight: 800; color: var(--blue); letter-spacing: -0.5px; flex-shrink: 0; }
.logo span { color: var(--gray-900); }

.header-search { flex: 1; max-width: 560px; }
.search-wrap {
  display: flex; align-items: center;
  border: 2px solid var(--gray-200); border-radius: 24px;
  padding: 7px 16px; gap: 8px; background: var(--gray-50);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-wrap:focus-within { border-color: var(--blue); background: var(--white); box-shadow: 0 0 0 3px rgba(0,87,184,0.12); }
.search-icon { flex-shrink: 0; }
#search-input { border: none; outline: none; background: transparent; font-size: 14px; color: var(--text); width: 100%; }
#search-input::placeholder { color: #bbb; }

.header-right { position: relative; flex-shrink: 0; }
.api-key-toggle { background: var(--blue-bg); border: 1px solid var(--blue); color: var(--blue); font-size: 12px; font-weight: 600; padding: 6px 14px; border-radius: 20px; transition: all 0.15s; }
.api-key-toggle:hover { background: var(--blue); color: var(--white); }

.api-key-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px);
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-md); padding: 18px; width: 360px; z-index: 300; font-size: 13px;
  color: var(--text-muted); line-height: 1.6;
}
.api-key-dropdown h4 { font-size: 13px; font-weight: 700; color: var(--gray-900); margin-bottom: 4px; }
.api-key-dropdown .optional { font-weight: 400; color: var(--text-light); font-size: 11px; }
.api-key-dropdown a { color: var(--blue); }
.api-key-row { display: flex; gap: 6px; margin-top: 8px; }
#newsapi-key, #finnhub-key { flex: 1; border: 1px solid var(--gray-300); border-radius: var(--radius-sm); padding: 7px 10px; font-size: 13px; outline: none; font-family: var(--font); }
#newsapi-key:focus, #finnhub-key:focus { border-color: var(--blue); }
#save-key-btn, #save-finnhub-btn { background: var(--blue); color: var(--white); border: none; border-radius: var(--radius-sm); padding: 7px 14px; font-size: 13px; font-weight: 600; transition: background 0.15s; }
#save-key-btn:hover, #save-finnhub-btn:hover { background: var(--blue-lt); }
.settings-divider { height: 1px; background: var(--border); margin: 14px 0; }
.skip-btn { background: none; border: none; color: var(--text-light); font-size: 12px; padding: 6px 0 0; display: block; cursor: pointer; }
.skip-btn:hover { color: var(--text-muted); text-decoration: underline; }
.hidden { display: none !important; }

/* ── Category Nav ────────────────────────────────────────── */
.cat-nav { background: var(--white); border-bottom: 1px solid var(--border); position: sticky; top: 57px; z-index: 190; }
.cat-nav-inner { max-width: var(--max-w); margin: 0 auto; padding: 0 20px; display: flex; align-items: center; overflow-x: auto; scrollbar-width: none; }
.cat-nav-inner::-webkit-scrollbar { display: none; }

.cn-btn { background: none; border: none; border-bottom: 3px solid transparent; color: var(--text-muted); font-size: 13.5px; font-weight: 500; padding: 12px 14px; white-space: nowrap; transition: all 0.15s; }
.cn-btn:hover { color: var(--blue); }
.cn-btn.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 700; }

.cn-divider { width: 1px; height: 20px; background: var(--gray-200); margin: 0 10px; flex-shrink: 0; }

.src-pill { background: none; border: 1px solid var(--gray-200); border-radius: 20px; color: var(--text-muted); font-size: 12px; font-weight: 500; padding: 4px 12px; margin: 0 3px; white-space: nowrap; transition: all 0.15s; flex-shrink: 0; }
.src-pill:hover { border-color: var(--blue); color: var(--blue); }
.src-pill.active { background: var(--blue); border-color: var(--blue); color: var(--white); }

/* ── News Ticker ─────────────────────────────────────────── */
.news-ticker-strip { background: var(--blue-dk); display: flex; align-items: center; height: 30px; overflow: hidden; }
.ticker-label { background: var(--red); color: var(--white); font-size: 10px; font-weight: 800; letter-spacing: 0.1em; padding: 0 12px; height: 100%; display: flex; align-items: center; flex-shrink: 0; }
.ticker-track { flex: 1; overflow: hidden; height: 100%; display: flex; align-items: center; }
.ticker-inner { color: #bfdbfe; font-size: 12px; white-space: nowrap; animation: ticker-scroll 100s linear infinite; padding-left: 20px; }
@keyframes ticker-scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* ── Page layout ─────────────────────────────────────────── */
.page-main { max-width: var(--max-w); margin: 0 auto; padding: 20px; }
.page-inner { display: grid; grid-template-columns: 1fr 300px; gap: 24px; }

/* ── Hero ────────────────────────────────────────────────── */
.hero-section { margin-bottom: 22px; border-radius: var(--radius-lg); overflow: hidden; background: var(--white); box-shadow: var(--shadow); }
.hero-card { display: grid; grid-template-columns: 1fr 1fr; cursor: pointer; min-height: 300px; transition: box-shadow 0.2s; }
.hero-card:hover { box-shadow: var(--shadow-md); }
.hero-img-wrap { background-size: cover; background-position: center; background-color: var(--gray-100); min-height: 280px; }
.hero-no-img { display: flex; align-items: center; justify-content: center; font-size: 72px; min-height: 280px; }
.hero-content { padding: 28px; display: flex; flex-direction: column; gap: 12px; }
.hero-badges { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cat-tag { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; padding: 3px 8px; border-radius: 3px; color: var(--white); }
.src-tag { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.hero-title { font-size: 22px; font-weight: 800; line-height: 1.25; color: var(--gray-900); letter-spacing: -0.3px; }
.hero-desc { font-size: 14px; color: var(--text-muted); line-height: 1.65; flex: 1; }
.hero-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: auto; }
.hero-time { font-size: 12px; color: var(--text-light); }
.hero-read-btn { background: var(--blue); color: var(--white); font-size: 13px; font-weight: 600; padding: 9px 20px; border-radius: 20px; border: none; cursor: pointer; text-decoration: none; transition: background 0.15s; display: inline-block; }
.hero-read-btn:hover { background: var(--blue-lt); }

/* Skeleton */
.hero-skeleton { display: grid; grid-template-columns: 1fr 1fr; min-height: 280px; background: var(--white); border-radius: var(--radius-lg); overflow: hidden; }
.sk-img { background: var(--gray-100); animation: shimmer 1.5s ease-in-out infinite; }
.sk-lines { padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.sk-line { height: 14px; background: var(--gray-100); border-radius: 4px; animation: shimmer 1.5s ease-in-out infinite; width: 85%; }
.sk-line.wide { height: 26px; width: 100%; }
.sk-line.short { width: 50%; }
@keyframes shimmer { 0%,100% { opacity: 1; } 50% { opacity: 0.45; } }

/* ── Sort bar ────────────────────────────────────────────── */
.sort-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 2px solid var(--gray-200); }
.sort-left { display: flex; align-items: baseline; gap: 8px; }
.sort-heading { font-size: 17px; font-weight: 700; }
.sort-count { font-size: 12px; color: var(--text-light); }
.sort-right { display: flex; align-items: center; gap: 6px; }
.sort-label { font-size: 12px; color: var(--text-muted); }
.sort-opt { background: none; border: 1px solid var(--gray-200); border-radius: 20px; font-size: 12px; font-weight: 500; padding: 3px 12px; color: var(--text-muted); transition: all 0.15s; }
.sort-opt.active { background: var(--gray-900); border-color: var(--gray-900); color: var(--white); }

/* ── News Grid ───────────────────────────────────────────── */
.news-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

.news-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; cursor: pointer; transition: box-shadow 0.18s, transform 0.18s; display: flex; flex-direction: column; }
.news-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.card-img-wrap { width: 100%; padding-top: 56.25%; position: relative; background: var(--gray-100); overflow: hidden; }
.card-img { position: absolute; inset: 0; background-size: cover; background-position: center; transition: transform 0.3s; }
.news-card:hover .card-img { transform: scale(1.04); }
.card-img-emoji { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 38px; }

.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 7px; flex: 1; }
.card-top-row { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.card-cat { font-size: 10.5px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; padding: 2px 7px; border-radius: 3px; color: var(--white); }
.card-time { font-size: 11px; color: var(--text-light); white-space: nowrap; }
.card-title { font-size: 13.5px; font-weight: 700; line-height: 1.38; color: var(--gray-900); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-desc { font-size: 12px; color: var(--text-muted); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 8px; border-top: 1px solid var(--gray-100); }
.card-source { font-size: 11.5px; font-weight: 600; color: var(--text-muted); display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.card-src-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.card-score { color: var(--orange); font-size: 11px; font-weight: 600; }
.card-read-link { font-size: 11.5px; font-weight: 600; color: var(--blue); }
.card-read-link:hover { text-decoration: underline; }

/* ── Load more ───────────────────────────────────────────── */
.load-more-wrap { display: flex; justify-content: center; padding: 24px 0; }
.load-more-btn { background: var(--white); border: 2px solid var(--blue); color: var(--blue); font-size: 14px; font-weight: 700; padding: 10px 36px; border-radius: 24px; transition: all 0.15s; }
.load-more-btn:hover { background: var(--blue); color: var(--white); }

/* ── No results ──────────────────────────────────────────── */
.no-results { text-align: center; color: var(--text-muted); font-size: 14px; padding: 48px 24px; grid-column: 1 / -1; }
.no-results strong { display: block; font-size: 18px; margin-bottom: 6px; color: var(--gray-700); }

/* ── Sidebar ─────────────────────────────────────────────── */
.side-col { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 110px; max-height: calc(100vh - 130px); overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--gray-200) transparent; }
.side-col::-webkit-scrollbar { width: 4px; }
.side-col::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 2px; }

.widget { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.widget-hd { font-size: 13px; font-weight: 700; padding: 11px 14px 9px; border-bottom: 2px solid var(--blue); }

/* Market widget */
.market-widget {}
.market-sidebar { display: flex; flex-direction: column; }
.mw-section-label { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-light); padding: 8px 14px 4px; background: var(--gray-50); border-bottom: 1px solid var(--border); }
.mw-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 14px; border-bottom: 1px solid var(--gray-100); }
.mw-row:last-child { border-bottom: none; }
.mw-left { display: flex; flex-direction: column; gap: 1px; }
.mw-sym { font-size: 12.5px; font-weight: 700; color: var(--gray-900); }
.mw-label { font-size: 10.5px; color: var(--text-light); }
.mw-right { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.mw-price { font-size: 12.5px; font-weight: 600; color: var(--gray-900); font-variant-numeric: tabular-nums; }
.mw-chg { font-size: 11px; font-weight: 600; }
.mw-chg.up { color: var(--green); }
.mw-chg.down { color: var(--red); }
.market-loading-sm { padding: 12px 14px; font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.market-loading-sm a { color: var(--blue); }

/* Trending */
.trending-item { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-bottom: 1px solid var(--gray-100); cursor: pointer; transition: background 0.12s; }
.trending-item:hover { background: var(--gray-50); }
.trending-item:last-child { border-bottom: none; }
.t-rank { font-size: 12px; font-weight: 700; color: var(--text-light); width: 18px; flex-shrink: 0; }
.t-word { font-size: 13px; font-weight: 600; color: var(--gray-900); flex: 1; }
.t-count { font-size: 11px; color: var(--blue); font-weight: 600; background: var(--blue-bg); padding: 1px 6px; border-radius: 10px; }

/* Sidebar items */
.s-item { padding: 10px 14px; border-bottom: 1px solid var(--gray-100); cursor: pointer; transition: background 0.12s; }
.s-item:hover { background: var(--gray-50); }
.s-item:last-child { border-bottom: none; }
.s-src { font-size: 10.5px; font-weight: 700; color: var(--blue); margin-bottom: 3px; text-transform: uppercase; letter-spacing: 0.04em; }
.s-title { font-size: 12.5px; font-weight: 600; color: var(--gray-900); line-height: 1.4; margin-bottom: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.s-title a { color: inherit; }
.s-title a:hover { color: var(--blue); }
.s-meta { font-size: 11px; color: var(--text-light); }
.s-meta a { color: var(--orange); }

/* Twitter widget */
.tw-widget .tw-body { padding: 12px 14px; font-size: 12.5px; color: var(--text-muted); line-height: 1.65; display: flex; flex-direction: column; gap: 8px; }
.tw-body code { background: var(--gray-100); padding: 1px 5px; border-radius: 3px; font-size: 11px; }
.tw-alt { background: var(--blue-bg); border-left: 3px solid var(--blue); padding: 8px 10px; border-radius: 0 4px 4px 0; font-size: 12px; }
.tw-alt a { color: var(--blue); font-weight: 600; }

/* ── Modal ───────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal.hidden { display: none; }
.modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.55); backdrop-filter: blur(3px); }
.modal-box { position: relative; background: var(--white); border-radius: var(--radius-lg); box-shadow: 0 20px 60px rgba(0,0,0,0.22); max-width: 660px; width: 100%; max-height: 88vh; overflow-y: auto; }
.modal-bar { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--white); z-index: 1; }
.modal-badges { display: flex; gap: 8px; align-items: center; }
.m-cat { font-size: 11px; font-weight: 700; letter-spacing: 0.05em; padding: 3px 9px; border-radius: 3px; color: var(--white); }
.m-src { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.modal-close { background: var(--gray-100); border: none; border-radius: 50%; width: 30px; height: 30px; font-size: 13px; color: var(--gray-700); display: flex; align-items: center; justify-content: center; transition: all 0.15s; }
.modal-close:hover { background: var(--gray-200); }

.modal-img-wrap { width: 100%; max-height: 320px; overflow: hidden; }
.modal-img-wrap img { width: 100%; height: 320px; object-fit: cover; display: block; }

.modal-body { padding: 24px; }
.modal-body h2 { font-size: 20px; font-weight: 800; line-height: 1.3; margin-bottom: 10px; color: var(--gray-900); letter-spacing: -0.3px; }
.modal-meta { display: flex; gap: 12px; font-size: 12px; color: var(--text-light); margin-bottom: 14px; }
#modal-desc { font-size: 14px; line-height: 1.72; color: var(--text-muted); margin-bottom: 22px; }
.modal-cta { display: inline-block; background: var(--blue); color: var(--white); font-size: 14px; font-weight: 700; padding: 11px 24px; border-radius: 24px; transition: background 0.15s; }
.modal-cta:hover { background: var(--blue-lt); }

/* ── Footer ──────────────────────────────────────────────── */
.site-footer { background: var(--gray-900); margin-top: 40px; padding: 18px 20px; }
.footer-inner { max-width: var(--max-w); margin: 0 auto; display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: #6b7280; flex-wrap: wrap; }
.footer-logo { color: #60a5fa; font-weight: 800; font-size: 15px; }
.footer-inner a { color: #9ca3af; transition: color 0.15s; }
.footer-inner a:hover { color: var(--white); }
.f-sep { color: #374151; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1060px) {
  .page-inner { grid-template-columns: 1fr; }
  .side-col { position: static; max-height: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
}
@media (max-width: 800px) {
  .news-grid { grid-template-columns: repeat(2, 1fr); }
  .hero-card { grid-template-columns: 1fr; }
  .hero-img-wrap { min-height: 200px; }
  .header-inner { flex-wrap: wrap; }
  .header-search { order: 3; flex: 0 0 100%; }
}
@media (max-width: 540px) {
  .news-grid { grid-template-columns: 1fr; }
  .utility-right { display: none; }
  .page-main { padding: 12px; }
  .side-col { grid-template-columns: 1fr; }
  .market-bar { display: none; }
}

/* ── Scrollbar & Selection ───────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-500); }
::selection { background: rgba(0,87,184,0.15); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
