/* ── Reset & Base ─────────────────────────────────────────────── */

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

:root {
  --blue: #2ea3f2;
  --blue-dark: #1a8cd8;
  --navy: #0f1b2d;
  --navy-light: #162340;
  --white: #ffffff;
  --gray-50: #f8f9fa;
  --gray-100: #f1f3f5;
  --gray-200: #e9ecef;
  --gray-300: #dee2e6;
  --gray-400: #ced4da;
  --gray-500: #adb5bd;
  --gray-600: #868e96;
  --gray-700: #495057;
  --gray-800: #343a40;
  --gray-900: #212529;
  --red: #e74c3c;
  --green: #27ae60;
  --purple: #8e44ad;
  --orange: #e67e22;
  --teal: #16a085;
  --yellow: #f39c12;
  --panel-width: 520px;
  --header-height: 64px;
  --filter-height: 52px;
}

body {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Header ──────────────────────────────────────────────────── */

.header {
  background: var(--navy);
  color: var(--white);
  height: var(--header-height);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.logo-mark {
  width: 38px;
  height: 38px;
  object-fit: contain;
  border-radius: 4px;
}

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.logo-name {
  font-weight: 600;
  font-size: 16px;
}

.logo-sub {
  font-size: 12px;
  opacity: 0.7;
  font-weight: 300;
}

.header-meta {
  font-size: 13px;
  opacity: 0.6;
}

/* ── Page Nav ────────────────────────────────────────────────── */

.page-nav {
  display: flex;
  gap: 4px;
}

.page-nav-tab {
  background: none;
  border: none;
  padding: 6px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
}

.page-nav-tab:hover {
  color: rgba(255,255,255,0.8);
  background: rgba(255,255,255,0.08);
}

.page-nav-tab.active {
  color: var(--white);
  background: rgba(255,255,255,0.12);
}

/* ── Sector Filter Bar ───────────────────────────────────────── */

.filter-bar {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: var(--header-height);
  z-index: 90;
  height: var(--filter-height);
}

.filter-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.filter-inner::-webkit-scrollbar {
  display: none;
}

.filter-tab {
  background: none;
  border: none;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  border-radius: 20px;
  white-space: nowrap;
  transition: all 0.2s;
}

.filter-tab:hover {
  background: var(--gray-100);
  color: var(--gray-800);
}

.filter-tab.active {
  background: var(--blue);
  color: var(--white);
}

/* ── Date Filter Bar ─────────────────────────────────────────── */

.date-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

.date-filters {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.date-tab {
  background: none;
  border: 1px solid var(--gray-300);
  padding: 6px 14px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  border-radius: 6px;
  white-space: nowrap;
  transition: all 0.2s;
}

.date-tab:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.date-tab.active {
  background: var(--navy);
  border-color: var(--navy);
  color: var(--white);
}

.btn-refresh {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--white);
  border: 1px solid var(--gray-300);
  padding: 6px 14px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-700);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-refresh:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.btn-refresh.refreshing .refresh-icon {
  animation: spin 0.6s linear infinite;
}

.refresh-icon {
  flex-shrink: 0;
}

/* ── Trending ────────────────────────────────────────────────── */

.trending {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding: 10px 16px;
  background: var(--white);
  border-radius: 8px;
  border: 1px solid var(--gray-200);
  flex-wrap: wrap;
}

.trending-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

.trending-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.trending-chip {
  font-size: 12px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 12px;
  background: var(--gray-100);
  color: var(--gray-700);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.trending-chip:hover {
  background: var(--blue);
  color: #fff;
}

.trending-chip.active {
  background: var(--blue);
  color: #fff;
}

.trending-chip.active .chip-count {
  color: rgba(255,255,255,0.7);
}

.trending-chip .chip-count {
  color: var(--gray-500);
  font-size: 11px;
  margin-left: 3px;
}

/* ── Article count ───────────────────────────────────────────── */

.article-count {
  font-size: 13px;
  color: var(--gray-500);
  margin-bottom: 16px;
}

/* ── Main Content ────────────────────────────────────────────── */

.main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

/* ── Page Intros ─────────────────────────────────────────────── */

.page-intro {
  margin-bottom: 24px;
}

.page-intro h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 4px;
}

.page-intro p {
  font-size: 14px;
  color: var(--gray-600);
}

/* ── Loading & Empty States ──────────────────────────────────── */

.loading, .empty-state {
  text-align: center;
  padding: 80px 24px;
  color: var(--gray-500);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

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

.hidden {
  display: none !important;
}

/* ── News Grid ───────────────────────────────────────────────── */

.news-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

/* ── News Card ───────────────────────────────────────────────── */

.news-card {
  background: var(--white);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s;
}

.news-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.06);
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card-top-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sector-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  color: var(--white);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.card-time {
  font-size: 12px;
  color: var(--gray-500);
}

.btn-bookmark {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--gray-400);
  transition: color 0.2s;
  font-size: 18px;
  line-height: 1;
}

.btn-bookmark:hover {
  color: var(--blue);
}

.btn-bookmark.bookmarked {
  color: var(--blue);
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 8px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-source {
  font-size: 12px;
  color: var(--gray-500);
  margin-bottom: 8px;
}

.card-desc {
  font-size: 13px;
  color: var(--gray-600);
  line-height: 1.5;
  flex: 1;
  margin-bottom: 16px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-actions {
  display: flex;
  gap: 8px;
}

.btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn-read {
  background: var(--gray-100);
  color: var(--gray-700);
  text-decoration: none;
  text-align: center;
}

.btn-read:hover {
  background: var(--gray-200);
}

.btn-generate {
  background: var(--blue);
  color: var(--white);
  flex: 1;
}

.btn-generate:hover {
  background: var(--blue-dark);
}

/* ── Post Panel ──────────────────────────────────────────────── */

.panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 200;
  transition: opacity 0.3s;
}

.post-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--panel-width);
  height: 100vh;
  background: var(--white);
  z-index: 210;
  box-shadow: -4px 0 20px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s ease;
}

.post-panel.open {
  transform: translateX(0);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--gray-200);
}

.panel-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.panel-close {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: var(--gray-500);
  line-height: 1;
  padding: 0 4px;
}

.panel-close:hover {
  color: var(--gray-800);
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ── Style & Tone Pills ─────────────────────────────────────── */

.panel-selectors {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--gray-100);
}

.pill-group {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.pill {
  background: var(--gray-100);
  border: 1px solid transparent;
  padding: 5px 12px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  border-radius: 16px;
  transition: all 0.2s;
  white-space: nowrap;
}

.pill:hover {
  background: var(--gray-200);
  color: var(--gray-800);
}

.pill.active {
  background: var(--navy);
  color: var(--white);
  border-color: var(--navy);
}

.panel-generating {
  text-align: center;
  padding: 60px 0;
  color: var(--gray-500);
}

.panel-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-500);
  margin-bottom: 6px;
  display: block;
}

.panel-article-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-800);
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--gray-100);
}

.panel-textarea {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.6;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  padding: 14px;
  resize: vertical;
  color: var(--gray-800);
  transition: border-color 0.2s;
}

.panel-textarea:focus {
  outline: none;
  border-color: var(--blue);
}

.panel-char-count {
  font-size: 12px;
  color: var(--gray-500);
  text-align: right;
  margin-top: 4px;
  margin-bottom: 16px;
}

.panel-actions {
  display: flex;
  gap: 10px;
}

.btn-copy {
  background: var(--blue);
  color: var(--white);
  flex: 1;
}

.btn-copy:hover {
  background: var(--blue-dark);
}

.btn-regen {
  background: var(--gray-100);
  color: var(--gray-700);
}

.btn-regen:hover {
  background: var(--gray-200);
}

.panel-tip {
  margin-top: 20px;
  font-size: 12px;
  color: var(--gray-500);
  background: var(--gray-50);
  padding: 12px;
  border-radius: 8px;
  line-height: 1.5;
}

.panel-error {
  text-align: center;
  padding: 40px 0;
  color: var(--red);
}

.panel-error .btn {
  margin-top: 16px;
}

/* ── Ideas Section ───────────────────────────────────────────── */

.ideas-intro {
  margin-bottom: 24px;
}

.ideas-intro h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 6px;
}

.ideas-intro p {
  font-size: 14px;
  color: var(--gray-600);
}

.ideas-categories {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.ideas-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.idea-card {
  background: var(--white);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s;
  border-left: 4px solid var(--gray-200);
}

.idea-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.06);
}

.idea-card[data-category="hot-take"]  { border-left-color: var(--red); }
.idea-card[data-category="question"]  { border-left-color: var(--blue); }
.idea-card[data-category="market"]    { border-left-color: var(--purple); }
.idea-card[data-category="career"]    { border-left-color: var(--green); }
.idea-card[data-category="personal"]  { border-left-color: var(--orange); }

.idea-category {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 10px;
}

.idea-card[data-category="hot-take"] .idea-category  { color: var(--red); }
.idea-card[data-category="question"] .idea-category  { color: var(--blue); }
.idea-card[data-category="market"] .idea-category    { color: var(--purple); }
.idea-card[data-category="career"] .idea-category    { color: var(--green); }
.idea-card[data-category="personal"] .idea-category  { color: var(--orange); }

.idea-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 8px;
  line-height: 1.4;
}

.idea-desc {
  font-size: 13px;
  color: var(--gray-600);
  line-height: 1.5;
  flex: 1;
  margin-bottom: 16px;
}

.idea-template {
  font-size: 12px;
  color: var(--gray-500);
  background: var(--gray-50);
  padding: 10px 12px;
  border-radius: 6px;
  line-height: 1.5;
  margin-bottom: 14px;
  font-style: italic;
}

.idea-actions {
  display: flex;
  gap: 8px;
}

.btn-use {
  background: var(--blue);
  color: var(--white);
  flex: 1;
}

.btn-use:hover {
  background: var(--blue-dark);
}

/* ── History ─────────────────────────────────────────────────── */

.history-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.history-card {
  background: var(--white);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

.history-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.history-date {
  font-size: 12px;
  color: var(--gray-500);
}

.history-style {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--gray-100);
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.history-article {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 8px;
}

.history-post {
  font-size: 13px;
  color: var(--gray-600);
  line-height: 1.6;
  white-space: pre-wrap;
  background: var(--gray-50);
  padding: 14px;
  border-radius: 8px;
  margin-bottom: 12px;
  max-height: 200px;
  overflow-y: auto;
}

.history-actions {
  display: flex;
  gap: 8px;
}

.btn-clear-history {
  background: var(--gray-100);
  color: var(--red);
  font-size: 12px;
  padding: 6px 14px;
}

.btn-clear-history:hover {
  background: var(--red);
  color: var(--white);
}

/* ── Toast ────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gray-900);
  color: var(--white);
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  z-index: 300;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 1.5s forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* ── Responsive ──────────────────────────────────────────────── */

@media (max-width: 768px) {
  .news-grid,
  .ideas-grid {
    grid-template-columns: 1fr;
  }

  .post-panel {
    width: 100%;
  }

  .header-meta {
    display: none;
  }

  .filter-inner {
    padding: 0 12px;
  }

  .main {
    padding: 16px;
  }

  .page-nav {
    gap: 2px;
  }

  .page-nav-tab {
    font-size: 11px;
    padding: 5px 8px;
  }

  .pill {
    font-size: 11px;
    padding: 4px 10px;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .ideas-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
