/* --- CSS Reset & Base --- */
:root {
    --font-serif: 'Playfair Display', serif;
    --font-sans: 'Inter', sans-serif;
    --color-text: #1a1a1a;
    --color-text-muted: #555;
    --color-border: #e0e0e0;
    --color-bg: #ffffff;
    --color-bg-alt: #f7f7f7;
    --sentiment-bearish: #C62828; /* Strong Red */
    --sentiment-pessimistic: #EF5350; /* Red */
    --sentiment-neutral: #616161; /* Gray */
    --sentiment-optimistic: #66BB6A; /* Green */
    --sentiment-bullish: #2E7D32; /* Strong Green */
    --sentiment-strong-bearish: #B71C1C; /* Darkest Red */
    --sentiment-strong-bullish: #1B5E20; /* Darkest Green */
}
body {
    font-family: var(--font-sans);
    background-color: var(--color-bg);
    color: var(--color-text);
    margin: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
a {
    color: var(--color-text);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}
img {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 8px; /* Slightly rounded images */
}
/* COMPACT: Reduced container width and padding */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 16px;
}

/* --- Header --- */
/* COMPACT: Reduced header padding */
.main-header {
    border-bottom: 2px solid var(--color-text);
    padding: 12px 0;
}
.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; /* Allow wrapping on small screens */
}
/* COMPACT: Reduced logo font size */
.logo {
    font-family: var(--font-serif);
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -1px;
    flex-shrink: 0; /* Prevent logo from shrinking */
    margin-right: 16px; /* Space between logo and date */
}
.logo span {
    font-family: var(--font-sans);
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--sentiment-neutral);
    vertical-align: top;
    letter-spacing: 0;
}
.header-date {
    font-family: var(--font-sans);
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    white-space: nowrap; /* Prevent date wrapping */
    text-align: right; /* Align date to the right */
     margin-left: auto; /* Push date to the right */
}
/* Empty div for search, ensures proper spacing */
.header-search {
    width: 0; /* Or actual width if search is implemented */
}



























/* ===============================
   SUBHEADER / NAV (Final — Two-Line Trending Layout)
   =============================== */
.main-nav {
  border-bottom: 1px solid var(--color-border);
}

/* Top-level nav list */
.nav-list {
  display: flex;
  flex-wrap: nowrap;
  justify-content: space-between;
  align-items: center;
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
}

/* Flex groups */
.nav-left-group,
.nav-right-group {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-right-group {
  margin-left: auto;
  flex: 1 1 0;
  min-width: 0;
}

/* Base list items / links */
.nav-list li { position: relative; padding: 0; }

.nav-list li a {
  display: block;
  padding: 10px 12px;
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.nav-list li a:hover {
  color: var(--color-text);
  text-decoration: none;
}

/* ===============================
   Dropdown
   =============================== */
.nav-dropdown-toggle { cursor: pointer; }
.nav-dropdown-toggle:hover { color: var(--color-text); }

.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  border-top: none;
  box-shadow: 0 4px 8px rgba(0,0,0,0.05);
  padding: 8px 16px;
  margin: 0;
  list-style: none;
  min-width: 220px;
  z-index: 1000;
}
.nav-dropdown-menu li { margin: 0; padding: 0; }
.nav-dropdown-menu li a {
  padding: 8px 0;
  font-size: 0.85rem;
  text-transform: none;
  font-weight: 500;
}
.nav-dropdown:hover .nav-dropdown-menu { display: block; }

/* ===============================
   Sentiment Section
   =============================== */
.nav-sentiment {
  display: flex;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-muted);
  padding: 10px 0;
  white-space: nowrap;
  text-transform: uppercase;
}

.nav-sentiment span { margin-left: 6px; }

.nav-sentiment-strip-container {
  width: 50px;
  height: 6px;
  background-color: var(--color-border);
  border-radius: 3px;
  position: relative;
  margin-left: 8px;
  display: inline-block;
  vertical-align: middle;
}
.nav-sentiment-marker {
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  border: 1px solid var(--color-bg);
  background-color: var(--sentiment-neutral);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 3px rgba(0,0,0,0.1);
}

/* ===============================
   Trending Keywords (Single-Line Layout)
   =============================== */
.nav-keywords {
  display: flex;
  flex-direction: row;        /* <-- Puts label and list side-by-side */
  align-items: center;       /* <-- Vertically centers the label with the list */
  gap: 8px;                  /* <-- Adds space between "Trending:" and the first keyword */
  text-transform: none;
  color: var(--color-text-muted);
  font-size: 0.80rem;
  font-weight: 500;
  letter-spacing: 0;
  flex: 1 1 0;
  min-width: 0;
  position: relative;
  overflow: visible;
}

/* "Trending:" label */
.nav-keywords-label {
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-bottom: 2px;           /* slight separation from keywords row */
}

/* Keyword list (can wrap naturally now) */
.nav-keywords-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  padding: 0;
  margin: 0;
  list-style: none;
  column-gap: 6px;
  row-gap: 2px;
}

.nav-keywords-list li {
  flex: 0 0 auto;
  white-space: nowrap;
}

.nav-keywords-list a {
  font-weight: 600;
  color: var(--color-text);
  text-transform: capitalize;
  font-size: 0.80rem;
}

.nav-keywords-list li:not(:last-child) a::after {
  content: "·";
  margin: 0 4px;
  color: var(--color-text-muted);
  font-weight: 500;
}

.nav-keywords-list a:hover {
  text-decoration: underline;
}

/* ===============================
   Responsive adjustments
   =============================== */
@media (max-width: 1200px) {
  .nav-keywords-label { font-size: 0.7rem; }
}

@media (max-width: 768px) {
  .nav-list { flex-wrap: wrap; }
  .nav-right-group { width: 100%; }

  .nav-keywords {
    width: 100%;
    align-items: flex-start;
  }

  .nav-keywords-list {
    flex-wrap: wrap;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .nav-keywords-list::-webkit-scrollbar { display: none; }
}































/* --- Hero Grid (Featured) --- */
.hero-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px; /* COMPACT: Reduced gap */
    padding: 20px 0; /* COMPACT: Reduced padding */
    border-bottom: 2px solid var(--color-text);
}

/* --- CAROUSEL STYLES --- */
.hero-main {
    grid-column: 1 / 2;
    position: relative; /* Needed for Swiper pagination */
    overflow: hidden; /* Hide overflowing slides */
     aspect-ratio: 16 / 9; /* Ensure consistent height */
     background-color: var(--color-bg-alt); /* Placeholder bg */
}
 .swiper-container {
    width: 100%;
    height: 100%; 
}
.swiper-slide {
    /* Center content */
    display: flex;
    justify-content: center;
    align-items: flex-end; /* Align text to bottom */
    position: relative; /* For absolute positioning of text */
}
.swiper-slide .story-image-container {
     position: absolute;
     top: 0;
     left: 0;
     width: 100%;
     height: 100%;
     z-index: 1;
}
 .swiper-slide .story-image {
     width: 100%;
     height: 100%;
     object-fit: cover;
 }
 .swiper-slide .story-content-overlay {
    position: relative; /* Sit on top of image */
    z-index: 2;
    width: 100%;
    padding: 16px; /* COMPACT: Reduced padding */
    background: linear-gradient(to top, rgba(0,0,0,1), rgba(0,0,0,0.5)); /* Stronger Gradient overlay */
    color: #fff; /* White text on overlay */
    box-sizing: border-box; /* Include padding in width */
 }
 .swiper-slide .story-content-overlay a {
     color: #fff; /* White links */
 }
.swiper-slide .story-meta {
    font-size: 0.8rem; /* COMPACT */
    font-weight: 700;
    color: rgba(255,255,255,0.8); /* Lighter muted color */
    margin-bottom: 6px; /* COMPACT */
}
.swiper-slide .story-title {
    font-family: var(--font-serif);
    font-size: 2.0rem; /* COMPACT */
    line-height: 1.15;
    margin: 0 0 8px 0; /* COMPACT */
}
.swiper-slide .story-summary {
    font-size: 0.95rem; /* COMPACT */
    line-height: 1.5;
    color: rgba(255,255,255,0.9);
    margin: 0 0 10px 0; /* COMPACT: Space before sentiment */
    /* Limit summary lines */
    display: -webkit-box;
    -webkit-line-clamp: 2; /* Show max 2 lines */
    -webkit-box-orient: vertical;  
    overflow: hidden;
}
 /* Sentiment Strip inside Carousel */
 .swiper-slide .sentiment-display {
     padding-top: 8px; /* COMPACT */
     margin-top: 0; /* Reset margin */
 }
.swiper-slide .sentiment-header {
    margin-bottom: 6px; /* COMPACT */
}
.swiper-slide .sentiment-label, .swiper-slide .sentiment-score {
    font-size: 0.75rem; /* COMPACT */
    color: #fff !important; /* Override default color for overlay */
}
 .swiper-slide .sentiment-strip {
     background-color: rgba(255,255,255, 0.3); /* Lighter strip bg */
     height: 4px; /* Thinner strip */
	 margin-bottom:25px;
 }
 .swiper-slide .sentiment-marker {
     width: 10px; /* Smaller marker */
     height: 10px;
     border-width: 1px; /* Thinner border */
     box-shadow: 0 0 3px rgba(0,0,0,0.2);
 }
/* Swiper Pagination */
 .swiper-pagination {
     position: absolute;
     bottom: 10px !important; /* Position dots inside */
     left: 50% !important;
     transform: translateX(-50%);
     width: auto !important; /* Allow dots to determine width */
 }
 .swiper-pagination-bullet {
     background-color: rgba(255, 255, 255, 0.5);
     opacity: 1;
 }
 .swiper-pagination-bullet-active {
     background-color: #fff;
 }

/* Featured Secondary (Now "Trending") */
.featured-secondary {
    grid-column: 2 / 3;
    display: flex;
    flex-direction: column;
    gap: 12px; /* COMPACT */
    border-left: 1px solid var(--color-border);
    padding-left: 20px; /* COMPACT: Reduced padding */
}
.trending-header {
    font-family: var(--font-serif);
    font-size: 1.4rem; /* COMPACT: Reduced font size */
    font-weight: 800;
    margin: 0 0 12px 0; /* COMPACT: Reduced margin */
    padding-bottom: 12px;
    border-bottom: 1px solid var(--color-border);
}
.secondary-story {
     display: flex; /* Change to flex for better control */
     flex-direction: column; /* Stack vertically */
     gap: 8px; /* COMPACT */
     padding-bottom: 12px; /* COMPACT: Reduced padding */
}
.secondary-story-top { /* Container for image and text */
    display: grid;
    grid-template-columns: 80px 1fr; 
    gap: 12px;
}
.featured-secondary .secondary-story:not(:last-child) {
    border-bottom: 1px solid var(--color-border);
}
.secondary-story .story-image-container {
    width: 80px; /* Fixed image size */
    height: 80px;
    aspect-ratio: 1 / 1;
    background-color: var(--color-bg-alt);
     flex-shrink: 0; /* Prevent image shrinking */
     border-radius: 4px; /* Slightly rounder */
     overflow: hidden;
}
.secondary-story .story-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.secondary-story .story-meta {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--color-text-muted);
    margin-bottom: 4px;
}
.secondary-story .story-title {
    font-family: var(--font-serif);
    font-size: 1.1rem; /* COMPACT: Reduced font size */
    line-height: 1.3;
    margin: 0;
    font-weight: 700;
    /* Limit title lines */
     display: -webkit-box;
    -webkit-line-clamp: 3; /* Show max 3 lines */
    -webkit-box-orient: vertical;  
    overflow: hidden;
}
/* Sentiment in Trending Now */
.secondary-story .sentiment-display {
    padding-top: 8px; /* COMPACT */
    margin-top: 0;
}

/* --- Market Drivers (Trending Keywords) --- */
.trending-topics-header {
    font-family: var(--font-serif);
    font-size: 1.75rem; /* COMPACT: Reduced font size */
    font-weight: 800;
    margin: 20px 0; /* COMPACT: Reduced margin */
    padding-bottom: 12px;
    border-bottom: 1px solid var(--color-border);
}
.topics-grid {
    display: grid;
     /* ADJUSTED GRID: 6 items */
    grid-template-columns: repeat(3, 1fr); 
    gap: 20px; /* COMPACT: Reduced gap */
    padding-bottom: 20px; /* COMPACT: Reduced padding */
    border-bottom: 2px solid var(--color-text);
}
.topic-item {
    display: flex;
    flex-direction: column;
    background-color: var(--color-bg-alt); /* Subtle background */
    padding: 16px; /* Padding inside */
    border-radius: 8px; /* Rounded corners */
    border: 1px solid var(--color-border);
}
.topic-keyword {
    font-family: var(--font-sans);
    font-size: 0.85rem; /* COMPACT: Reduced font size */
    font-weight: 700;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 8px 0;
}
.topic-blurb {
    font-family: var(--font-serif);
    font-size: 1.1rem; /* COMPACT: Reduced font size */
    line-height: 1.4;
    margin: 0 0 12px 0;
    /* Limit blurb lines */
     display: -webkit-box;
    -webkit-line-clamp: 4; /* Show max 4 lines */
    -webkit-box-orient: vertical;  
    overflow: hidden;
    flex-grow: 1; /* Allow blurb to take space */
}
.topic-link {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--color-text);
    /* margin-top: auto; Pushed by sentiment now */
}
.topic-item .sentiment-display {
    padding-top: 8px; /* COMPACT */
    margin-top: 8px; /* Space between blurb/link and sentiment */
}
.db-error-message {
    grid-column: 1 / -1; /* Span grid if inside */
    color: var(--sentiment-bearish);
    font-family: var(--font-serif);
    font-size: 1.1rem; /* COMPACT: Reduced font size */
    text-align: center;
    padding: 20px 0; /* Add some padding */
}


/* --- Main News Feed & Topic Article List --- */
.main-feed-header,
.latest-articles-section .section-header { /* Style Topic page header like index */
    font-family: var(--font-serif);
    font-size: 1.75rem; /* COMPACT: Reduced font size */
    font-weight: 800;
    margin: 20px 0; /* COMPACT: Reduced margin */
    padding-bottom: 12px;
    border-bottom: 1px solid var(--color-border);
}
.main-feed,
.article-list-grid { /* Style Topic page article grid like index */
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px 20px; /* COMPACT: Reduced gap */
}
.story-item {
    display: flex;
    flex-direction: column;
     background-color: var(--color-bg); /* Ensure background */
     border: 1px solid var(--color-border); /* Add border */
     border-radius: 8px; /* Rounded corners */
     /* Padding is handled differently for image/no-image */
     /* padding: 16px; */ 
     box-shadow: 0 2px 4px rgba(0,0,0,0.03); /* Subtle shadow */
     position: relative; /* For potential absolute elements if needed */
     overflow: hidden; /* Clip image corners */
	 margin-bottom: 50px;
}
.story-item .story-image-container {
    aspect-ratio: 16 / 9;
    background-color: var(--color-bg-alt);
    margin: 0 0 12px 0; /* Only margin below */
    overflow: hidden; /* Ensure image stays rounded */
    border-radius: 8px 8px 0 0; /* Only round top corners if image exists */
    border-bottom: 1px solid var(--color-border);
    position: relative; /* For placeholder */
}
/* STYLING FOR NO IMAGE */
.story-item.no-image {
    padding: 16px; /* Add padding back to the card itself */
}
.story-item.no-image .story-image-container {
    display: none; /* Hide the container entirely */
}
.story-item.no-image .story-content {
     padding: 0; /* Remove extra padding */
}
.story-item.no-image .sentiment-display {
     padding: 12px 0 0 0; /* Adjust padding */
}
/* END NO IMAGE STYLING */

.story-item .image-placeholder {
    /* Placeholder div inside container */
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    background-color: var(--color-bg-alt);
    border-radius: 8px 8px 0 0;
}
.story-item .story-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.story-item .story-content {
    padding: 16px; /* Padding for content area */
    display: flex; 
    flex-direction: column; 
    flex-grow: 1; 
}
.story-item.no-image .story-content {
     padding: 0; /* Remove padding when no image */
}

.story-item .story-meta {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--color-text-muted);
    margin-bottom: 8px;
}
.story-item .story-title {
    font-family: var(--font-serif);
    font-size: 1.3rem; /* COMPACT: Reduced font size */
    line-height: 1.2;
    margin: 0 0 12px 0;
    flex-grow: 1; /* Allow title to push summary/sentiment down */
}
/* STYLING FIX: Revert no-image title to normal */
.story-item.no-image .story-title {
    font-size: 3.3rem; /* Back to normal size */
    line-height: 1.2;
    text-align: left; /* Back to normal alignment */
    margin-bottom: 12px;
}
.story-item .story-summary {
    font-size: 0.95rem; /* COMPACT: Reduced font size */
    line-height: 1.6;
    color: var(--color-text-muted);
    margin-bottom: 12px; /* COMPACT: Reduced margin */
     /* Limit summary lines */
     display: -webkit-box;
    -webkit-line-clamp: 3; /* Show max 3 lines */
    -webkit-box-orient: vertical;  
    overflow: hidden;
}
/* STYLING FIX: Re-enable summary for no-image cards */
.story-item.no-image .story-summary {
    display: -webkit-box; /* Re-enable summary */
}
.story-item .sentiment-display {
    padding: 0 16px 16px; /* Padding for sentiment area */
    margin-top: auto; 
}
.story-item.no-image .sentiment-display {
    padding: 12px 0 0 0; /* Adjust padding for no-image */
}


/* --- More Headlines (No Image) Section --- */
.more-headlines-header {
    font-family: var(--font-serif);
    font-size: 1.75rem; /* COMPACT: Reduced font size */
    font-weight: 800;
    margin: 32px 0 20px 0; /* COMPACT: Reduced margin */
    padding-bottom: 12px;
    border-bottom: 1px solid var(--color-border);
}
.headlines-list {
    display: flex;
    flex-direction: column;
    gap: 12px; /* COMPACT: Reduced gap */
}
.headline-item {
    padding-bottom: 12px; /* COMPACT: Reduced padding */
    border-bottom: 1px solid var(--color-border);
    display: flex; /* Use flex for alignment */
    flex-direction: column;
}
.headline-item .story-content {
     flex-grow: 1; /* Allow content to grow */
}
.headline-item .story-meta {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--color-text-muted);
    margin-bottom: 8px;
}
.headline-item .story-title {
    font-family: var(--font-serif);
    font-size: 1.3rem; /* COMPACT: Reduced font size */
    line-height: 1.2;
    margin: 0 0 12px 0;
}
.headline-item .story-summary {
    font-size: 0.95rem; /* COMPACT: Reduced font size */
    line-height: 1.6;
    color: var(--color-text-muted);
    margin-bottom: 12px; /* COMPACT: Reduced margin */
     /* Limit summary lines */
     display: -webkit-box;
    -webkit-line-clamp: 2; /* Show max 2 lines */
    -webkit-box-orient: vertical;  
    overflow: hidden;
}


/* --- Sentiment Strip --- */
.sentiment-display {
    margin-top: auto; /* Pushes strip to the bottom of the card */
    padding-top: 12px; /* COMPACT: Reduced padding */
}
.sentiment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.sentiment-label {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
}
.sentiment-score {
    font-size: 0.9rem;
    font-weight: 700;
}
.sentiment-strip {
    position: relative;
    width: 100%;
    height: 6px;
    background-color: var(--color-border);
    border-radius: 3px;
    overflow: hidden; /* Ensure marker stays within bounds */
}
.sentiment-marker {
    position: absolute;
    top: 50%;
    width: 12px;
    height: 12px;
    border: 2px solid var(--color-bg);
    background-color: var(--sentiment-neutral); /* Default */
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 5px rgba(0,0,0,0.2);
}

/* --- Footer --- */
.main-footer {
    margin-top: 32px; /* COMPACT: Reduced margin */
    padding: 24px 0;
    background-color: var(--color-text);
    color: var(--color-bg-alt);
}
.main-footer .container {
    text-align: center;
    font-size: 0.9rem;
}

/* --- POST.PHP SPECIFIC STYLES --- */
.post-content {
    max-width: 850px; /* Limit article width for readability */
    margin: 24px auto; /* Center article */
    color: var(--color-text); /* Use default text color */
}
.post-header {
    border-bottom: 2px solid var(--color-text);
    margin-bottom: 24px;
    padding-bottom: 16px;
}
.post-header .story-title {
    font-size: 2.75rem; /* Larger title for post page */
    margin-bottom: 12px;
    font-family: var(--font-serif); /* Ensure serif font */
    line-height: 1.1;
}
.post-header .story-meta {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    margin-bottom: 16px;
}
.post-header .story-meta a.external-link {
    font-weight: 600;
    color: var(--color-text);
    text-decoration: underline;
    text-decoration-color: var(--color-border);
}
.post-header .post-sentiment {
     padding-top: 0; /* Remove top padding */
     margin-top: 16px;
}

.featured-media {
    margin-bottom: 24px;
    background-color: var(--color-bg-alt); /* Placeholder bg */
    border-radius: 8px; /* Match image rounding */
    overflow: hidden; /* Clip contents */
}
.featured-media img.story-image { /* Ensure post image uses rounding */
    width: 100%;
    height: auto;
    border-radius: 0; /* Remove double rounding if parent has it */
}
/* Responsive YouTube Embed */
.youtube-embed {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
    height: 0;
    overflow: hidden;
    /* border-radius: 8px; Match image rounding - already on parent */
}
.youtube-embed iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.post-description {
    font-size: 1.1rem; /* Slightly larger body text */
    line-height: 1.7;
    margin-bottom: 24px;
}
.post-description p { /* Add space between paragraphs if using <p> tags */
    margin-bottom: 1em;
}

/* Action Bar */
.action-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 24px 0;
  padding-bottom: 24px;
  /* Removed border-bottom, now only separates visually from notes */
}
.action-button, 
.action-bar a.action-button { /* Style links like buttons */
  display: inline-flex; /* Use inline-flex for alignment */
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border: 1px solid var(--color-border);
  border-radius: 20px; /* Pill shape */
  background-color: transparent;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none !important; /* Remove underline from links */
}
.action-button:hover,
.action-bar a.action-button:hover {
  background-color: var(--color-bg-alt);
  border-color: var(--color-text-muted);
  color: var(--color-text);
  text-decoration: none !important; /* Keep underline off on hover */
}
.action-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: transparent !important; /* Ensure disabled bg doesn't conflict */
}

/* Bookmark Section - Moved below Action Bar */
.bookmark-section {
    position: relative; /* Context for notes */
    margin-top: 24px; /* Space above notes section */
    padding-top: 24px; /* Space inside notes section */
    border-top: 1px solid var(--color-border); /* Separator line */
    /* Remove flex-grow and min-width */
}
.bookmark-container {
    display: flex; /* Align button and potential notes icon */
    align-items: flex-start; /* Align to top */
    flex-direction: column; /* Stack button and notes area */
}
.bookmark-btn, .remove-bookmark-btn {
   /* Inherit from .action-button but make round */
   border-radius: 50%; 
   width: 36px; /* Explicit size for round button */
   height: 36px;
   padding: 0; /* Remove padding */
   position: relative; /* For icon positioning */
   flex-shrink: 0;
   background-color: transparent !important; /* Ensure transparent bg */
   border-width: 2px; /* Thicker border for icon */
   /* Remove margin-bottom, handled by parent spacing */
}
/* Simple Plus/Minus Icon using pseudo-elements */
.bookmark-btn::before, .bookmark-btn::after,
.remove-bookmark-btn::before {
    content: "";
    position: absolute;
    background-color: var(--color-text-muted);
    transition: background-color 0.2s ease;
    top: 50%; 
    left: 50%; 
    transform: translate(-50%, -50%);
}
.bookmark-btn:hover, .remove-bookmark-btn:hover {
    border-color: var(--color-text); /* Darker border on hover */
}
.bookmark-btn:hover::before, .bookmark-btn:hover::after,
.remove-bookmark-btn:hover::before {
    background-color: var(--color-text);
}
/* Plus Icon */
.bookmark-btn::before { width: 12px; height: 2px; }
.bookmark-btn::after { width: 2px; height: 12px; }
/* Minus Icon */
.remove-bookmark-btn::before { width: 12px; height: 2px; }

.bookmark-notes-area {
    display: none; /* Hidden by default */
    width: 100%; /* Take full width below button */
    clear: both; /* Ensure it drops below floated elements if any */
    margin-top: 16px; /* Space between button and notes area */
}
/* Show notes area when bookmarked */
.bookmark-container.active .bookmark-notes-area {
    display: block; 
}
/* Hide the simple add button when notes are active */
.bookmark-container.active .bookmark-btn {
    display: none; 
}
/* Show the remove button only when active */
.bookmark-container .remove-bookmark-btn {
    display: none;
}
.bookmark-container.active .remove-bookmark-btn {
    display: inline-flex; /* Show remove button */
    margin-bottom: 16px; /* Space below remove button */
}

/* STYLING FIX: Header for notes */
.notes-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.notes-header label {
    font-size: 0.9rem; /* Slightly larger label */
    color: var(--color-text); /* Darker label */
    font-weight: 700;
    margin-bottom: 0; /* Remove bottom margin from label itself */
}
.action-button-inline { /* For Get Pulse button next to label */
    padding: 4px 10px; /* Adjust padding */
    font-size: 0.8rem; /* Adjust font size */
    margin-left: 8px;
    vertical-align: middle;
    /* Inherit action-button styles but keep inline */
    display: inline-flex;
    border-radius: 16px;
}

.bookmark-notes-area textarea {
    width: 100%;
    min-height: 80px; /* Slightly taller default */
    padding: 10px 14px; /* More padding */
    border: 1px solid var(--color-border);
    border-radius: 8px; /* Match other elements */
    font-family: var(--font-sans);
    font-size: 1rem; /* Slightly larger text */
    line-height: 1.6;
    resize: vertical; /* Allow vertical resize */
    box-sizing: border-box; /* Include padding/border in width */
    background-color: var(--color-bg-alt); /* Subtle background */
}
.bookmark-notes-area textarea:focus {
    outline: none;
    border-color: var(--color-text-muted);
    box-shadow: 0 0 0 2px rgba(0,0,0,0.05); /* Subtle focus ring */
}


/* Pulse AI Section */
.pulse-analysis-section {
    margin: 24px 0;
    padding: 20px;
    background-color: var(--color-bg-alt);
    border-radius: 8px;
    border: 1px solid var(--color-border);
}
.section-header { /* Shared header style */
    font-family: var(--font-serif);
    font-size: 1.6rem;
    font-weight: 800;
    margin-top: 0;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--color-border);
}
.pulse-content {
    white-space: pre-line; 
    line-height: 1.6; 
    font-size: 1rem; 
    color: var(--color-text);
}
.pulse-disclaimer {
    margin-top: 16px; 
    font-size: 0.85rem; 
    color: var(--color-text-muted);
    font-style: italic;
}

/* Chat Section */
.chat-section {
     margin: 24px 0;
}
.chat-iframe {
    width: 100%; 
    height: 500px; /* Adjust height as needed */
    border: 1px solid var(--color-border);
    border-radius: 8px;
}

/* Related Info (Sectors/Assets) */
.related-info-section {
     margin: 24px 0;
}
.related-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}
.related-column strong {
    display: block;
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 8px;
    text-transform: uppercase;
    color: var(--color-text-muted);
}
.related-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.related-list li {
    margin-bottom: 6px;
}
.related-list li a {
    font-size: 0.95rem;
    line-height: 1.4;
    color: var(--color-text);
}
.related-list li a:hover {
    text-decoration: underline;
    color: var(--sentiment-bullish); /* Optional hover color */
}

/* Related Posts Section */
.related-posts-section {
     margin: 24px 0;
}
.related-posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); /* Responsive grid */
    gap: 16px;
}
.related-post-card {
    display: flex; /* Use flex for vertical stacking */
    flex-direction: column;
    background-color: var(--color-bg); /* Use base bg */
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--color-border);
    transition: box-shadow 0.2s ease;
    height: 100%; /* Make cards equal height */
}
.related-post-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    text-decoration: none;
}
.related-thumbnail {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    background-color: var(--color-bg-alt); /* Placeholder color */
    border-bottom: 1px solid var(--color-border);
    display: block; /* Ensure it takes space */
}
/* STYLING FIX: Style for cards without images */
.related-post-card.no-image .related-thumbnail {
    display: none; /* Hide image area if no image */
}
.related-post-card.no-image .related-content {
    /* Add more padding when no image */
    padding-top: 16px; 
}
.related-content {
    padding: 12px;
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* Allow content to fill space */
}
.related-title {
    font-family: var(--font-serif);
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.3;
    margin: 0 0 6px 0;
    color: var(--color-text);
    /* Limit title lines */
     display: -webkit-box;
    -webkit-line-clamp: 3; 
    -webkit-box-orient: vertical;  
    overflow: hidden;
    flex-grow: 1; /* Push meta to bottom */
}
.related-meta {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 8px; /* Space above meta */
}

/* Snap Card Specific Styles (Keep these separate) */
#snapCanvasHost { position:fixed; left:-99999px; top:-99999px; z-index:-1; }
#snapCard { 
    width:800px; height:1000px; position:relative; overflow:hidden;
    border:1px solid rgba(255,255,255,.15);
    box-shadow:0 10px 40px rgba(0,0,0,.6); background:#0b0b0b;
    font-family:'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}
#snapBg { 
    position:absolute; inset:0; 
    width:100%; height:100%;
    object-fit:cover; /* Default, will be overridden by JS bake */
    object-position:center center;
    display:block;
}
.snap-gradient {
    position:absolute; left:0; right:0; bottom:0; height:100%;
    background:linear-gradient(180deg, rgba(0,0,0,0) 28%, rgba(0,0,0,.7) 63%, rgba(0,0,0,.92) 100%);
    pointer-events:none; background-repeat:no-repeat;
}
.snap-brand {
    position:absolute; top:24px; left:24px;
    background:rgba(0,0,0,.45); padding:8px 12px; border-radius:999px;
    border:1px solid rgba(255,255,255,.18); color:#f3f3f3; font-weight:600; font-size:16px;
}
.snap-content { position:absolute; left:28px; right:28px; bottom:24px; color:#f3f3f3; }
.stroked-title{
    font-size:60px; line-height:1.1; font-weight:800; margin:0 0 10px 0; word-break:break-word; color:#fff;
    text-shadow: 0 0 0 #000, 0 2px 0 #000, 0 -2px 0 #000, 2px 0 0 #000, -2px 0 0 #000, 2px 2px 0 #000, -2px 2px 0 #000, 2px -2px 0 #000, -2px -2px 0 #000, 0 0 8px rgba(0,0,0,.35);
}
#snapDesc {
    font-size:18px; line-height:1.45; color:#d7d7d7; margin:0 0 14px 0;
    display:-webkit-box; -webkit-line-clamp:3; -webkit-box-orient:vertical; overflow:hidden;
}
#snapMeta { display:flex; gap:12px; flex-wrap:wrap; align-items:center; font-size:18px; color:#dddddd; margin-bottom:10px; }
#snapHash { font-size:14px; color:#c9c9c9; opacity:.9; margin:6px 0 0 0; }
#snapSentiment { margin-top:10px; }
.snap-sentiment-header { display:flex; align-items:center; gap:10px; margin-bottom:6px; }
.snap-sentiment-title { font-weight:700; font-size:18px; color:#e8f6ff; }
.snap-sentiment-info { font-size:14px; color:#cfd8e3; }
.snap-sentiment-strip { position: relative; width: 100%; height: 6px; background: linear-gradient(to right, #ff3b30 0%, #ff9500 25%, #ffd60a 50%, #34c759 75%, #0a7f2e 100%); border-radius: 3px; }
.snap-sentiment-marker { position: absolute; top: 50%; width: 14px; height: 14px; background: #0b0b0b; border: 2px solid #e6edf7; border-radius: 50%; transform: translate(-50%, -50%); }
.snap-sentiment-labels { display:flex; justify-content:space-between; font-size:12px; color:#c9c9c9; margin-top:4px; }
#snapPulse { display:none; margin-top:6px; padding:12px 14px; background:rgba(0,0,0,.5); border:1px solid rgba(255,255,255,.15); border-radius:12px; }
.snap-pulse-header { font-weight:700; font-size:18px; margin-bottom:6px; color:#cfe3ff; }
.snap-pulse-content { font-size:16px; line-height:1.45; color:#eaeaea; white-space:pre-line; overflow:hidden; display:block; }

/* --- TOPIC PAGE SPECIFIC --- */
.topic-page .topic-header-main {
    padding: 24px 0 16px;
    border-bottom: 2px solid var(--color-text);
    margin-bottom: 24px;
}
.topic-page .topic-header-main h1 {
    font-family: var(--font-serif);
    font-size: 2.5rem;
    margin: 0 0 8px 0;
    line-height: 1.1;
}
.topic-page .topic-last-updated {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    margin: 0 0 16px 0; /* Add margin below date */
}
/* NEW: Overall topic sentiment styles */
.topic-overall-sentiment {
    margin-top: 16px; /* Space above sentiment */
    padding-top: 16px; /* Space inside */
    border-top: 1px solid var(--color-border); /* Separator */
    max-width: 400px; /* Limit width */
}
.topic-overall-sentiment .sentiment-header {
    margin-bottom: 8px;
}
.topic-overall-sentiment .sentiment-label {
    font-size: 0.85rem;
    font-weight: 700;
}
.topic-overall-sentiment .sentiment-score {
    font-size: 0.95rem;
    font-weight: 700;
}
.topic-overall-sentiment .sentiment-strip {
    height: 8px; /* Slightly thicker */
}
.topic-overall-sentiment .sentiment-marker {
     width: 14px; height: 14px; /* Slightly larger */
}


.topic-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.topic-stat-box {
    background-color: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 16px;
}
.topic-stat-box h4 {
    margin: 0 0 8px 0;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--color-text-muted);
    text-transform: uppercase;
}
.topic-stat-box .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.1;
}
.topic-stat-box .stat-note {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-top: 6px;
}
.sentiment-mix {
    display: flex;
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
    background-color: var(--color-border); /* Fallback */
    margin-bottom: 6px;
}
.sentiment-mix .mix-bar { height: 100%; }
.sentiment-mix .positive { background-color: var(--sentiment-optimistic); }
.sentiment-mix .neutral { background-color: var(--sentiment-neutral); }
.sentiment-mix .negative { background-color: var(--sentiment-pessimistic); }

.sentiment-mix-legend { text-align: center; display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.sentiment-mix-legend span { display: inline-flex; align-items: center; font-size: 0.75rem; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; display: inline-block; }
.legend-dot.positive { background-color: var(--sentiment-optimistic); }
.legend-dot.neutral { background-color: var(--sentiment-neutral); }
.legend-dot.negative { background-color: var(--sentiment-pessimistic); }

.topic-details-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 2 columns for charts */
    gap: 24px;
    margin-bottom: 24px;
}
.chart-container, .co-topics-container {
    background-color: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 16px;
}
.co-topics-container {
    grid-column: span 2; /* Make co-topics span both columns */
}
.section-header-small {
    font-family: var(--font-serif);
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--color-border);
}
.chart-wrapper {
    position: relative;
    height: 280px; /* Fixed height for charts */
}
.co-topics-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.topic-chip {
    display: inline-block;
    padding: 6px 12px;
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    transition: all 0.2s ease;
}
.topic-chip:hover {
    background-color: var(--color-text-muted);
    color: var(--color-bg);
    text-decoration: none;
    border-color: var(--color-text-muted);
}
.topic-chip span {
    font-size: 0.75rem;
    opacity: 0.7;
}

.latest-articles-section .section-header {
    font-size: 1.75rem; /* Match index page */
    margin-bottom: 20px;
}
.article-list-grid {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Use same 2-col layout as index */
    gap: 24px 20px;
}
/* Style story items within topic page like index */
.article-list-grid .story-item {
     /* Inherits base .story-item styles */
     /* Ensure background, border, padding, shadow */
     background-color: var(--color-bg); 
     border: 1px solid var(--color-border); 
     border-radius: 8px; 
     /* Padding moved to content/sentiment */
     box-shadow: 0 2px 4px rgba(0,0,0,0.03); 
     overflow: hidden; /* Needed for image bleed */
}
/* Styles specific to no-image articles in topic list */
.article-list-grid .story-item.no-image {
    padding: 16px; /* Add padding back to the card itself */
}
.article-list-grid .story-item.no-image .story-image-container {
    display: none; /* Hide the container entirely */
}
.article-list-grid .story-item.no-image .story-content {
     padding: 0; /* Remove extra padding */
}
.article-list-grid .story-item.no-image .sentiment-display {
     padding: 12px 0 0 0; /* Adjust padding */
}
/* STYLING FIX: Revert no-image title to normal */
.article-list-grid .story-item.no-image .story-title {
    font-size: 3.3rem; /* Back to normal size */
    line-height: 1.2;
    text-align: left; /* Back to normal alignment */
    margin-bottom: 12px;
}
/* STYLING FIX: Re-enable summary for no-image cards */
.article-list-grid .story-item.no-image .story-summary {
     display: -webkit-box; /* Re-enable summary */
     /* Other styles inherited from .story-item .story-summary */
}


.load-more { text-align: center; margin: 24px 0 40px; }
.no-articles-message {
    text-align: center;
    color: var(--color-text-muted);
    font-size: 1.1rem;
    padding: 32px 0;
    grid-column: 1 / -1; /* Span grid */
}
.load-more .stat-note { /* Style for no-more message */
     color: var(--color-text-muted);
     font-size: 0.9rem;
}
.load-error, .load-error-message { /* Style for load more errors */
     color: var(--sentiment-bearish);
     font-size: 0.9rem;
     text-align: center;
}
/* NEW: Sentiment Language Breakdown */
.sentiment-breakdown {
    background-color: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 24px;
}
.sentiment-breakdown-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px; /* Increased gap */
}
.sentiment-breakdown-col {
    padding-right: 20px; /* Space between columns */
    border-right: 1px solid var(--color-border); /* Separator */
}
.sentiment-breakdown-col:last-child {
     border-right: none; /* No border on last column */
     padding-right: 0;
}
.sentiment-breakdown-col h4 {
    margin: 0 0 12px 0; /* More space below header */
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--color-text-muted);
    padding-bottom: 6px; /* Underscore */
    border-bottom: 2px solid var(--color-border); /* Thicker underscore */
}
.sentiment-breakdown-col ul {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 1rem; /* Slightly larger */
}
.sentiment-breakdown-col li {
    margin-bottom: 8px; /* More space between words */
    color: var(--color-text);
    padding-left: 0; /* Remove padding */
    position: relative;
    display: flex; /* Use flex for alignment */
    justify-content: space-between; /* Space word and count */
    align-items: center;
}
.sentiment-breakdown-col li::before { 
    content: none; /* Remove default bullet */
}
.sentiment-breakdown-col .word-count {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-muted);
    background-color: var(--color-border); /* Subtle background for count */
    padding: 2px 6px;
    border-radius: 10px; /* Pill shape */
    margin-left: 8px; /* Space from word */
}
/* Color coding for titles */
.sentiment-breakdown-col.bullish h4 { color: var(--sentiment-bullish); border-bottom-color: var(--sentiment-bullish); }
.sentiment-breakdown-col.pessimistic h4 { color: var(--sentiment-pessimistic); border-bottom-color: var(--sentiment-pessimistic); }
.sentiment-breakdown-col.bearish h4 { color: var(--sentiment-bearish); border-bottom-color: var(--sentiment-bearish); }


/* --- Responsive --- */
/* MOBILE FRIENDLY: Changed breakpoint to 1024px */
@media (max-width: 1024px) {
    .hero-grid { grid-template-columns: 1fr; }
    .featured-secondary { grid-template-columns: 1fr 1fr; border-left: none; padding-left: 0; margin-top: 20px; }
    .topics-grid { grid-template-columns: 1fr 1fr; }
    .main-feed { grid-template-columns: 1fr 1fr; }
    .article-list-grid { grid-template-columns: 1fr 1fr; } /* Keep 2 cols on tablet */
    .topic-details-grid { grid-template-columns: 1fr; } /* Stack charts/co-topics */
    .co-topics-container { grid-column: auto; } /* Reset span */

    /* Mobile Nav */
    .nav-list { flex-wrap: wrap; justify-content: center; }
    .nav-left-group, .nav-right-group { flex-basis: 100%; justify-content: center; gap: 12px; padding: 5px 0; }
     .nav-right-group { border-top: 1px solid var(--color-border); flex-wrap: wrap; }
    .nav-dropdown-menu { position: relative; width: 100%; box-shadow: none; border: none; text-align: center; padding: 0; margin-top: 5px; }
    .nav-dropdown-menu li a { padding: 8px 0; background-color: var(--color-bg-alt); border-bottom: 1px solid var(--color-border); }
    .nav-keywords { white-space: normal; text-align: center; }
     .nav-sentiment, .nav-keywords { flex-basis: 100%; justify-content: center; }
    .sentiment-breakdown-grid { grid-template-columns: 1fr; } /* Stack breakdown cols */
     .sentiment-breakdown-col { border-right: none; padding-right: 0; padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--color-border); }
     .sentiment-breakdown-col:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
}

/* MOBILE FRIENDLY: Changed breakpoint to 768px */
@media (max-width: 768px) {
     .header-content { flex-direction: column; gap: 8px; }
     .logo { width: 100%; text-align: center; margin-right: 0;}
     .header-date { width: 100%; text-align: center; margin-left: 0; }
    .featured-secondary { grid-template-columns: 1fr; }
     .topics-grid { grid-template-columns: 1fr; }
    .main-feed { grid-template-columns: 1fr; }
    .article-list-grid { grid-template-columns: 1fr; } /* Stack articles */
    .swiper-slide .story-title { font-size: 1.8rem; }
     .swiper-slide .story-summary { display: none; }
     .swiper-pagination { bottom: 5px !important; }
    .post-header .story-title { font-size: 2.2rem; } /* Smaller post title */
    .story-item .story-title,
    .headline-item .story-title { font-size: 1.25rem; }
    /* Larger title for no-image cards on mobile */
    .article-list-grid .story-item.no-image .story-title { font-size: 1.3rem; } /* Keep consistent on mobile */
    
    .nav-left-group, .nav-right-group { gap: 8px; }
     .nav-sentiment, .nav-keywords { font-size: 0.8rem; padding: 8px 6px; }
     .nav-list li a { font-size: 0.8rem; padding: 8px 10px; }
     .related-columns { grid-template-columns: 1fr; } /* Stack related columns */
     .related-posts-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); } /* Smaller related cards */

     .action-bar { justify-content: center; } /* Center buttons */
     .post-description { font-size: 1rem; } /* Slightly smaller body on mobile */
     /* Bookmark section already takes full width due to parent stacking */
     .bookmark-section { margin-top: 16px; padding-top: 16px; } /* Reduce space on mobile */
}












/* --- CHAT STYLES --- */
/* Center the chat content and give it a max-width */
.chat-main-content {
    max-width: 1850px; /* Match post content width for readability */
    margin: 0 auto;
}

/* Your HTML uses .chatsection */
.chatsection {
     margin: 24px 0;
}

/* The main chat message window */
#chat-container {
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background-color: var(--color-bg-alt);
    height: 500px;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

/* Base message styles */
.user-message,
.ai-message {
    padding: 10px 14px;
    border-radius: 18px;
    line-height: 1.5;
    max-width: 80%;
    word-wrap: break-word; /* Ensure long text breaks */
}

.user-message {
    background-color: var(--color-text);
    color: var(--color-bg);
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}

.ai-message {
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}

/* Styles for AI messages with HTML content */
.ai-message p { margin: 0 0 10px 0; }
.ai-message p:last-child { margin-bottom: 0; }
.ai-message ul, .ai-message ol { padding-left: 20px; margin: 10px 0; }
.ai-message li { margin-bottom: 5px; }

/* Typing indicator */
.ai-message.typing {
    padding: 12px 14px; /* Give it space */
}
.ai-message.typing .dots { 
    display: flex; 
    gap: 4px; 
    align-items: center;
}
.ai-message.typing .dots span {
    width: 8px; 
    height: 8px; 
    background-color: var(--color-text-muted);
    border-radius: 50%;
    animation: typing-bounce 1.2s infinite ease-in-out;
}
.ai-message.typing .dots span:nth-child(2) { animation-delay: 0.2s; }
.ai-message.typing .dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
}

/* Save button container */
.save-button-container {
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px dashed var(--color-border);
}
.save-button-container .save-button {
    /* Uses .action-button-inline styles */
    font-size: 0.75rem;
}

/* Suggested Prompts */
#suggested-prompts {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}
.suggested-prompt {
    padding: 8px 14px;
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}
.suggested-prompt:hover {
    background-color: var(--color-bg-alt);
    border-color: var(--color-text-muted);
    color: var(--color-text);
}

/* Chat Input Form */
#chat-form {
    display: flex;
    gap: 10px;
    align-items: flex-end; /* Align button to bottom of textarea */
}

#user-input {
    flex-grow: 1;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 12px 16px;
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.4;
    resize: none; /* JS handles resize */
    min-height: 48px; /* Match button height */
    box-sizing: border-box; /* Include padding in height */
    background-color: var(--color-bg);
}
#user-input:focus {
    outline: none;
    border-color: var(--color-text-muted);
    box-shadow: 0 0 0 2px rgba(0,0,0,0.05);
}

#chat-form .action-button {
    border-radius: 8px; /* Match textarea */
    height: 48px;
    flex-shrink: 0;
    /* Make it more prominent */
    background-color: var(--color-text);
    color: var(--color-bg);
    border-color: var(--color-text);
}
#chat-form .action-button:hover {
    background-color: #333; /* Darker hover */
    border-color: #333;
}

/* New/Clear buttons */
.chat-controls {
    margin-top: 12px;
    display: flex;
    gap: 10px;
}
.chat-controls .danger {
    color: var(--sentiment-pessimistic);
    /* border-color: var(--sentiment-pessimistic); */ /* Keep it subtle */
}
 .chat-controls .danger:hover {
    background-color: var(--sentiment-pessimistic);
    color: var(--color-bg);
    border-color: var(--sentiment-pessimistic);
}

/* Disclaimer Box */
.chat-disclaimer-box {
    margin: 24px 0;
    padding: 16px;
    background-color: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: 8px;
}
.chat-disclaimer-box p {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin: 0 0 10px 0;
}
.chat-disclaimer-box p:last-child { margin-bottom: 0; }

/* Timeline / Saved Chats */
.chat-timeline-section {
    margin-top: 32px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border);
}
/* .section-header is already styled */

.chat-timeline-section-inner {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.chat-item {
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 16px;
}
.chat-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.chat-item-date {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--color-text-muted);
    text-transform: uppercase;
}
.chat-item-controls { display: flex; gap: 8px; }
.chat-item-controls .copy-button,
.chat-item-controls .delete-chat-button {
    /* Use action-button-inline styles */
    padding: 4px 10px;
    font-size: 0.8rem;
}
 .chat-item-controls .delete-chat-button {
     color: var(--sentiment-pessimistic);
     border-color: transparent; /* Make it more subtle */
 }
 .chat-item-controls .delete-chat-button:hover {
     background-color: var(--sentiment-pessimistic);
     color: var(--color-bg);
     border-color: var(--sentiment-pessimistic);
 }

.chat-content {
    /* Styles for the saved chat preview */
    background-color: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 12px 16px;
    max-height: 200px; /* Limit height */
    overflow-y: auto;
    color: var(--color-text);
}
.chat-content p { margin: 0 0 10px 0; font-size: 0.9rem; }
.chat-content p:last-child { margin-bottom: 0; }

/* Ensure .feed-placeholder-wrapper (for non-members) looks right */
.feed-placeholder-wrapper {
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background-color: var(--color-bg-alt);
    margin-top: 16px;
}

/* --- SAVED CHAT TIMELINE STYLES --- */
.chat-timeline-section {
    margin-top: 32px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border);
}
/* .section-header is already styled */

.chat-timeline-section-inner {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.chat-item {
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 16px;
}
.chat-item-header {
    display: flex;
    flex-wrap: wrap; /* Allow wrapping on small screens */
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    gap: 10px; /* Space between date and buttons */
}
.chat-item-date {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--color-text-muted);
    text-transform: uppercase;
}
.chat-item-controls { 
    display: flex; 
    gap: 8px; 
    flex-shrink: 0; /* Prevent buttons from wrapping */
}
.chat-item-controls .copy-button,
.chat-item-controls .delete-chat-button {
    /* Uses action-button-inline styles */
    padding: 4px 10px;
    font-size: 0.8rem;
}
 .chat-item-controls .delete-chat-button {
     /* Uses .danger class from index.php */
     color: var(--sentiment-pessimistic);
     border-color: transparent; 
 }
 .chat-item-controls .delete-chat-button:hover {
     background-color: var(--sentiment-pessimistic);
     color: var(--color-bg);
     border-color: var(--sentiment-pessimistic);
 }

.chat-content {
    background-color: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 12px 16px;
    max-height: 200px;
    overflow-y: auto;
    color: var(--color-text);
    /* Ensure content from AI message renders correctly */
    line-height: 1.6;
}
.chat-content p { margin: 0 0 10px 0; }
.chat-content p:last-child { margin-bottom: 0; }
.chat-content ul, .chat-content ol { padding-left: 20px; margin: 10px 0; }
.chat-content li { margin-bottom: 5px; }
.chat-content .save-button-container { display: none; } /* Hide nested save buttons */

/* This is the "No saved chats found" message */
.stat-note {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    text-align: center;
    padding: 20px 0;
}



















/* --- BOOKMARKS PAGE (Compact Refresh) --- */

/* Search bar on top of bookmarks page */
.bookmark-search-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
    font-family: var(--font-sans);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-sizing: border-box; /* Important */
    margin-bottom: 24px;
}
.bookmark-search-input:focus {
    outline: none;
    border-color: var(--color-text-muted);
    box-shadow: 0 0 0 2px rgba(0,0,0,0.05);
}

/* Hides the entire notes section */
.bookmark-container {
    display: none;
}

/* The wrapper is now just a simple spacer */
.bookmark-wrapper {
    display: block;
    width: 100%; 
    margin-bottom: 24px; /* Space between bookmarks */
}
	
/* The article card itself now gets the border and shadow */
.topic-item {
    width: -webkit-fill-available; /* Take full width */
    margin: 0;
    
    /* Remove the old left border */
    border-left: none;
    
    /* Add the border, radius, and shadow from the old wrapper */
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.03);
    overflow: hidden; /* Keep images clipped */
}

/* * NEW: Panoramic 2.5:1 aspect ratio for the image preview.
* This overrides the 16:9 ratio from the base .story-item class.
*/
.topic-item .story-image-container {
    aspect-ratio: 2.5 / 1; /* Wide preview crop */
    border-radius: 0;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 0; 
}

/* Ensure object-fit is cover (it is, but good to be sure) */
.topic-item .story-image {
    object-fit: cover;
}

/* Ensure content padding is correct */
.topic-item .story-content {
    padding-top: 16px; 
}

/* Remove extra padding from the action bar */
.topic-item .action-bar {
    padding-top: 0;
    padding-bottom: 16px;
	margin: 0px;
}

/* NEW: Style for the "Remove" button in the action bar */
.action-button-inline.remove {
    color: var(--sentiment-pessimistic);
    border-color: transparent;
}
.action-button-inline.remove:hover {
    color: var(--color-bg);
    background-color: var(--sentiment-pessimistic);
    border-color: var(--sentiment-pessimistic);
}
























/* --- MY FEED PAGE --- */

/* Main container for feed customization */
.feed-tools {
    border-radius: 8px;
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    padding: 20px;
    margin-bottom: 24px;
}

/* Re-style the search and topic inputs */
.feed-tools .search-input,
.feed-tools .topic-input {
    width: 100%;
    padding: 10px 14px;
    font-size: 1rem;
    font-family: var(--font-sans);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-sizing: border-box;
    margin-bottom: 10px;
}
.feed-tools .search-input:focus,
.feed-tools .topic-input:focus {
    outline: none;
    border-color: var(--color-text-muted);
    box-shadow: 0 0 0 2px rgba(0,0,0,0.05);
}

/* Container for scrolling sources */
.checkbox-group {
    text-align: left;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
    background-color: var(--color-bg-alt);
}
.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 0.95rem;
    color: var(--color-text);
    cursor: pointer;
}
.checkbox-group label:hover {
    color: var(--color-text);
}
.checkbox-group input[type="checkbox"] {
    accent-color: var(--color-text);
    transform: scale(1.1);
}

/* Container for topic tags */
#topicsContainer {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 10px;
}

/* Use the existing .topic-chip style for tags */
.topic-tag {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px 6px 14px;
    background-color: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    font-size: 0.85rem;
    color: var(--color-text);
    transition: all 0.2s ease;
}
.topic-tag .remove-topic {
    margin-left: 8px;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--color-text-muted);
}
.topic-tag:hover {
    border-color: var(--color-text-muted);
}
.topic-tag .remove-topic:hover {
    color: var(--sentiment-pessimistic);
}

/* Use existing .stat-note for "no more articles" */
.no-more-articles {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    text-align: center;
    padding: 20px 0;
}

















/* --- MARKET MOOD PAGE (Redesign) --- */

/* New Grid Layout */
.mood-grid {
    display: grid;
    /* Define columns - adjust as needed for screen sizes */
    grid-template-columns: repeat(3, 1fr); 
    gap: 20px; /* Gap between cards */
    margin-top: 24px;
}

/* Make cards span columns if needed */
.mood-card-span-1 { grid-column: span 1; }
.mood-card-span-2 { grid-column: span 2; }
.mood-card-span-3 { grid-column: span 3; }

/* General Card Styling (inherits from .card in marketmood styles) */
.mood-card {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.03);
    overflow: hidden;
    display: flex; /* Use flex for vertical stacking */
    flex-direction: column;
    height: 100%; /* Make cards fill grid row height */
}
.mood-card-header { /* Replaces .hd */
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: var(--font-serif);
    font-size: 1.2rem;
    font-weight: 700;
}
.mood-card-header .muted { /* Replaces .hd .muted */
    font-family: var(--font-sans);
    font-size: 0.8rem;
    color: var(--color-text-muted);
    font-weight: 500;
    text-transform: uppercase;
}
.mood-card-body { /* Replaces .bd */
    padding: 16px;
    flex-grow: 1; /* Allow body to fill card height */
    display: flex; /* Enable flex for content alignment if needed */
    flex-direction: column;
}

/* Overall Sentiment Card */
.overall-sentiment-score {
    font-size: 2.5rem; /* Larger score */
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 4px;
    text-align: center;
}
.overall-sentiment-label {
    font-size: 1rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 16px;
}
/* Use standard .sentiment-display styles for the strip */

/* Trending Topics in Overall Card */
.mood-trending-topics {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px dashed var(--color-border);
}
.mood-trending-topics .muted { /* Small label above chips */
     display: block;
     font-size: 0.8rem;
     font-weight: 600;
     color: var(--color-text-muted);
     margin-bottom: 8px;
     text-transform: uppercase;
}
.mood-trending-topics .chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
/* Use standard .chip style */

/* Sentiment Distribution Card */
.distribution-bar-container {
    display: flex;
    height: 20px; /* Taller bar */
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
    background-color: var(--color-bg-alt); /* Background for empty space */
}
.distribution-bar-segment {
    height: 100%;
    transition: width 0.3s ease; /* Animate width changes */
}
.distribution-legend {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); /* Responsive legend */
    gap: 4px 12px; /* Row and column gap */
    margin-top: 12px;
    font-size: 0.8rem;
}
.distribution-legend-item {
    display: flex;
    align-items: center;
}
.distribution-legend-color {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    margin-right: 6px;
    flex-shrink: 0;
}
.distribution-legend-label {
    color: var(--color-text-muted);
    margin-right: auto; /* Push percentage to the right */
}
.distribution-legend-percent {
    font-weight: 600;
    color: var(--color-text);
}

/* Sentiment Trend Card */
/* Uses .spark and .axis-note from previous styles - ensure they exist */
.mood-card-body .spark {
    width: 100%;
    height: 200px; /* Adjust height if needed */
    display: block;
}

/* Sector Sentiment Card */
.sector-list {
    list-style: none;
    padding: 0;
    margin: 0;
    flex-grow: 1; /* Allow list to fill space */
}
.sector-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px dashed var(--color-border);
}
.sector-item:last-child {
    border-bottom: none;
}
.sector-name {
    font-weight: 600;
    color: var(--color-text);
    font-size: 0.95rem;
    flex-grow: 1; /* Allow name to take space */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sector-sentiment-score {
    font-weight: 700;
    font-size: 0.95rem;
    flex-shrink: 0; /* Prevent score from shrinking */
}
.sector-sentiment-strip-container { /* Small strip next to score */
    width: 40px; 
    height: 6px;
    background-color: var(--color-border);
    border-radius: 3px;
    position: relative;
    margin-left: 8px; 
    display: inline-block; 
    vertical-align: middle; 
}
.sector-sentiment-marker {
    position: absolute; top: 50%; width: 8px; height: 8px;
    border: 1px solid var(--color-bg); background-color: var(--sentiment-neutral); 
    border-radius: 50%; transform: translate(-50%, -50%);
}

/* Top Bullish/Bearish Sources Card */
/* Uses .clean list styles from previous CSS */
.mood-card-body ul.clean li {
    font-size: 0.95rem; /* Slightly larger text */
}
.mood-card-body ul.clean li span:first-child { /* Source name */
    font-weight: 600;
}

/* Keyword Polarization / Volume Cards */
/* Use .chip styles for polarization */
.polarization-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
/* Use .kv-list styles for volume */

/* Responsive Adjustments */
@media (max-width: 1200px) {
    .mood-grid {
        grid-template-columns: repeat(2, 1fr); /* 2 columns */
    }
    /* Adjust spans if needed */
    .mood-card-span-3 { grid-column: span 2; } 
}
@media (max-width: 768px) {
    .mood-grid {
        grid-template-columns: 1fr; /* 1 column */
    }
    /* All cards span 1 */
    .mood-card-span-1, .mood-card-span-2, .mood-card-span-3 { 
        grid-column: span 1; 
    }
    .mood-card-header { font-size: 1.1rem; }
}