/* Global reset and colour variables used across the whole page. */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink: #111111;
  --navy: #0a1628;
  --blue: #1e3a6e;
  --line: #cccccc;
  --muted: #333333;
  --up: #007733;
  --down: #cc1111;
  --paper: #ffffff;
  --soft: #f8fbff;
}

html { scroll-behavior: smooth; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'Lato', sans-serif;
  font-size: 16px;
  line-height: 1.7;
}

a { color: inherit; }

/* Top scrolling ticker design. JavaScript fills the ticker text. */
.ticker {
  background: var(--paper);
  color: var(--ink);
  padding: .5rem 0;
  overflow: hidden;
  border-bottom: 2px solid var(--ink);
}

.ticker-inner {
  display: inline-flex;
  gap: 2rem;
  animation: scroll 55s linear infinite;
  white-space: nowrap;
  font-family: 'Roboto Mono', monospace;
  font-size: .75rem;
  font-weight: 500;
  min-width: 200%;
}

.t-up  { color: var(--up); }
.t-dn  { color: var(--down); }
.t-neu { color: var(--blue); }
@keyframes scroll { from{transform:translateX(0)} to{transform:translateX(-50%)} }

/* Masthead, site title, date, and draggable navigation buttons. */
.masthead {
  background: var(--paper);
  border-bottom: 4px solid var(--navy);
  padding: 2rem 1.5rem 1.2rem;
  text-align: center;
}

.mast-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
  font-family: 'Roboto Mono', monospace;
  font-size: .65rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1rem;
}

.edition {
  background: var(--blue);
  color: #ffffff;
  padding: .25rem .8rem;
  font-size: .62rem;
  letter-spacing: .14em;
  font-weight: 700;
}

.mast-title {
  font-family: 'Merriweather', serif;
  font-size: clamp(2.4rem, 6vw, 4.8rem);
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
  margin-bottom: .4rem;
}

.mast-title span { color: var(--blue); font-style: italic; }

.mast-sub {
  font-family: 'Lato', sans-serif;
  font-size: .82rem;
  color: var(--muted);
  letter-spacing: .2em;
  text-transform: uppercase;
  margin-bottom: .6rem;
}

.mast-date {
  font-family: 'Roboto Mono', monospace;
  font-size: .72rem;
  color: var(--blue);
  font-weight: 700;
  letter-spacing: .1em;
  margin-bottom: 1rem;
}

.nav-bar {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: .4rem;
  border-top: 1px solid var(--line);
  padding-top: .9rem;
}

.nav-bar a {
  font-family: 'Lato', sans-serif;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--blue);
  text-decoration: none;
  padding: .35rem .85rem;
  border: 1.5px solid var(--blue);
  border-radius: 3px;
  transition: all .18s;
}

.nav-bar a:hover { background: var(--blue); color: #ffffff; }
.nav-bar a {
  cursor: grab;
  transition: background .18s, color .18s, opacity .18s, transform .18s;
}
.nav-bar a.dragging {
  opacity: .45;
  transform: scale(.98);
}

/* Reusable page section layout and newspaper-style section headers. */
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 1.5rem; }
.section { margin: 2.5rem 0; }

.section:has(> .status-line:last-child) {
  margin-bottom: .65rem;
}

.section-hdr {
  display: flex;
  align-items: center;
  gap: .8rem;
  border-top: 3px solid var(--navy);
  border-bottom: 1px solid var(--line);
  padding: .6rem 0;
  margin-bottom: 1.4rem;
}

.sec-tag {
  background: var(--navy);
  color: #ffffff;
  font-family: 'Lato', sans-serif;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  padding: .28rem .8rem;
}

.sec-title {
  font-family: 'Merriweather', serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--navy);
}

/* News article grid used by World, UAE/Middle East, and India sections. */
.news-grid {
  display: grid;
  grid-template-columns: 1.8fr 1fr 1fr;
  gap: 1.8rem;
}

.col-divider-left { border-left: 1px solid var(--line); padding-left: 1.8rem; }
.story { padding-bottom: 1.2rem; margin-bottom: 1.2rem; border-bottom: 1px solid #dddddd; }
.story:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.story-flag,
.story-meta {
  font-family: 'Roboto Mono', monospace;
  font-size: .64rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--blue);
  font-weight: 500;
  margin-bottom: .35rem;
}

.story-hl {
  font-family: 'Merriweather', serif;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--navy);
  margin-bottom: .45rem;
}

.story-hl a { text-decoration: none; border-bottom: 1px solid transparent; }
.story-hl a:hover { border-bottom-color: var(--navy); }
.lead .story-hl { font-size: 1.3rem; }
.story-body { font-family: 'Lato', sans-serif; font-size: .88rem; line-height: 1.8; color: #222222; }
.lead .story-body { font-size: .92rem; }

/* Status banners shown above news sections. */
.banner {
  background: var(--paper);
  color: var(--ink);
  padding: .85rem 1.4rem;
  margin: 1.5rem 0;
  display: flex;
  align-items: center;
  gap: 1rem;
  border-radius: 2px;
  border: 2px solid var(--blue);
}

.banner-label {
  background: var(--blue);
  color: #ffffff;
  font-family: 'Lato', sans-serif;
  font-size: .62rem;
  font-weight: 900;
  letter-spacing: .16em;
  text-transform: uppercase;
  padding: .22rem .65rem;
  flex-shrink: 0;
  border-radius: 2px;
}

.banner-text { font-family: 'Lato', sans-serif; font-size: .88rem; color: var(--ink); line-height: 1.5; }

/* Watchlist tile grid used by markets, stocks, and crypto. */
.idx-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  border: 1.5px solid var(--navy);
  border-radius: 3px;
  overflow: hidden;
  margin: 1.2rem 0;
}

.idx-cell { background: var(--paper); padding: 1rem .8rem; text-align: center; border-right: 1px solid var(--line); min-height: 112px; }
.idx-cell:last-child { border-right: none; }

.idx-name {
  font-family: 'Roboto Mono', monospace;
  font-size: .58rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: .3rem;
}

.idx-val { font-family: 'Merriweather', serif; font-size: 1.25rem; font-weight: 700; color: var(--navy); line-height: 1.1; }
.idx-chg { font-family: 'Roboto Mono', monospace; font-size: .65rem; margin-top: .25rem; font-weight: 500; }
.idx-up { color: var(--up); }
.idx-dn { color: var(--down); }

/* General card grid and data cards used by investing, currency, and commodities. */
.data-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.2rem;
  margin: 1rem 0;
}

.data-card { background: var(--paper); border: 1.5px solid var(--navy); border-radius: 3px; padding: 1.1rem 1.2rem; }
.data-card-wide { grid-column: 1 / -1; }

.dc-title {
  font-family: 'Lato', sans-serif;
  font-size: .68rem;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--navy);
  border-bottom: 1.5px solid var(--navy);
  padding-bottom: .55rem;
  margin-bottom: .75rem;
}

.dc-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .4rem 0; border-bottom: 1px solid #eeeeee; font-size: .86rem; }
.dc-row:last-child { border-bottom: none; }
.dc-name { color: var(--muted); font-size: .84rem; font-family: 'Lato', sans-serif; }
.dc-val { font-family: 'Roboto Mono', monospace; font-size: .84rem; font-weight: 500; color: var(--navy); text-align: right; }
/* Currency/rates watchlist layout, editable amount field, and swap arrows. */
.rate-list { display: grid; gap: .15rem; }
.rate-row {
  align-items: center;
  border-bottom: 1px solid #eeeeee;
  display: grid;
  gap: .6rem;
  grid-template-columns: minmax(0, 1.4fr) minmax(7rem, auto) auto;
  padding: .38rem 0;
}
.rate-row:last-child { border-bottom: none; }
.rate-main { min-width: 0; }
.rate-label {
  color: var(--navy);
  font-family: 'Roboto Mono', monospace;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  margin-bottom: .25rem;
  text-transform: uppercase;
}
.rate-form {
  align-items: baseline;
  color: var(--navy);
  display: flex;
  gap: .35rem;
}
.rate-field {
  display: block;
}
.rate-field span { display: none; }
.rate-base-code {
  color: var(--navy);
  font-family: 'Roboto Mono', monospace;
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .08em;
}
.rate-input {
  background: transparent;
  border: 0;
  border-bottom: 1px solid transparent;
  color: var(--navy);
  font-family: 'Roboto Mono', monospace;
  font-size: .74rem;
  font-weight: 700;
  min-width: 0;
  text-align: left;
  padding: 0;
  width: 4.8rem;
}
.rate-input:focus {
  border-bottom-color: var(--navy);
  outline: none;
}
.rate-side {
  align-content: center;
  display: grid;
  justify-items: end;
  min-width: 7rem;
}
.rate-value {
  color: var(--navy);
  font-family: 'Roboto Mono', monospace;
  font-size: .84rem;
  font-weight: 700;
  line-height: 1.2;
}
.rate-meta {
  color: var(--muted);
  font-family: 'Roboto Mono', monospace;
  font-size: .56rem;
  font-weight: 700;
  letter-spacing: .08em;
  margin-top: .25rem;
  text-transform: uppercase;
}
.rate-swap {
  align-self: center;
  align-items: center;
  border: 0;
  background: transparent;
  color: var(--navy);
  cursor: pointer;
  display: inline-flex;
  flex-direction: column;
  font-family: 'Roboto Mono', monospace;
  font-size: .95rem;
  font-weight: 700;
  gap: 0;
  height: 2.15rem;
  justify-content: center;
  line-height: .68;
  padding: .2rem .42rem;
  width: 2.15rem;
}
.rate-swap:hover {
  color: var(--accent);
}
.rate-row.dragging { background: #f8fbff; }
/* Add/picker controls for stocks, markets, crypto, and rates. */
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  border-bottom: 1.5px solid var(--navy);
  padding-bottom: .55rem;
  margin-bottom: .75rem;
}
.card-head .dc-title { border-bottom: none; padding-bottom: 0; margin-bottom: 0; }
.mini-btn {
  border: 1.5px solid var(--navy);
  background: var(--paper);
  color: var(--navy);
  border-radius: 3px;
  cursor: pointer;
  font-family: 'Roboto Mono', monospace;
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .08em;
  padding: .35rem .6rem;
  text-transform: uppercase;
}
.mini-btn:hover { background: var(--navy); color: #ffffff; }
.stock-picker {
  border: 1px solid var(--line);
  margin-bottom: .85rem;
  padding: .75rem;
}
.stock-picker[hidden] { display: none; }
.stock-search {
  border: 1.5px solid var(--navy);
  border-radius: 3px;
  color: var(--navy);
  font-family: 'Lato', sans-serif;
  font-size: .92rem;
  margin-bottom: .65rem;
  padding: .55rem .65rem;
  width: 100%;
}
.stock-results {
  display: grid;
  gap: .45rem;
  margin-bottom: .75rem;
}
/* Search result rows and drag handles for rearranging pinned watchlists. */
.stock-result {
  align-items: center;
  border-bottom: 1px solid #eeeeee;
  display: flex;
  gap: .75rem;
  justify-content: space-between;
  padding: .45rem 0;
  transition: background .16s, transform .16s, opacity .16s;
}
.stock-result.dragging {
  background: #f8fbff;
  opacity: .65;
}
.drag-handle {
  color: var(--navy);
  cursor: grab;
  font-family: 'Roboto Mono', monospace;
  font-size: .9rem;
  font-weight: 700;
  line-height: 1;
  padding: .2rem .1rem;
  user-select: none;
}
.drag-handle:active { cursor: grabbing; }
.stock-result-left {
  align-items: center;
  display: flex;
  gap: .7rem;
}
.stock-result-name {
  color: var(--muted);
  font-family: 'Lato', sans-serif;
  font-size: .88rem;
}
.stock-result-meta {
  color: var(--navy);
  font-family: 'Roboto Mono', monospace;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .08em;
}
.stock-picker-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.empty-note { color: var(--muted); font-size: .84rem; padding: .3rem 0; }

/* Green/red badges for price, point, and percentage movement. */
.badge { font-family: 'Roboto Mono', monospace; font-size: .64rem; font-weight: 500; padding: .1rem .38rem; border-radius: 2px; margin-left: .35rem; white-space: nowrap; }
.b-up  { background: #e6f4ec; color: var(--up); }
.b-dn  { background: #fdecea; color: var(--down); }
.b-neu { background: #eef0f4; color: var(--blue); }

/* Card layout used by Science and Fashion article sections. */
.sci-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 1.2rem; margin: 1rem 0; }
.sci-card { background: var(--paper); border: 1.5px solid var(--navy); border-top: 4px solid var(--blue); border-radius: 3px; padding: 1rem 1.1rem; min-height: 180px; }
.sci-tag { font-family: 'Lato', sans-serif; font-size: .64rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--blue); margin-bottom: .4rem; }
.sci-hl { font-family: 'Merriweather', serif; font-size: .95rem; font-weight: 700; line-height: 1.35; color: var(--navy); margin-bottom: .45rem; }
.sci-hl a { text-decoration: none; }
.sci-hl a:hover { text-decoration: underline; }
.sci-body { font-family: 'Lato', sans-serif; font-size: .84rem; line-height: 1.75; color: #222222; }

/* Floating Ask AI button and summary panel. */
.ai-summary-toggle {
  align-items: center;
  background: var(--paper);
  border: 2px solid var(--navy);
  border-radius: 8px;
  bottom: 1.1rem;
  box-shadow: 0 8px 22px rgba(10, 22, 40, .14);
  color: var(--navy);
  cursor: pointer;
  display: inline-flex;
  font-family: 'Roboto Mono', monospace;
  font-size: .72rem;
  font-weight: 700;
  gap: .45rem;
  left: 1.1rem;
  letter-spacing: .08em;
  padding: .7rem .9rem;
  position: fixed;
  text-transform: uppercase;
  z-index: 20;
}

.ai-summary-toggle::before {
  background: transparent;
  border: 2px solid var(--navy);
  border-radius: 50%;
  content: '';
  height: .48rem;
  width: .48rem;
}

.ai-summary-toggle.active {
  background: var(--paper);
  color: var(--navy);
}

.ai-summary-toggle.active::before {
  background: var(--up);
  border-color: var(--up);
}
.ai-summary-target.ai-summary-ready { cursor: pointer; }
.ai-summary-target.ai-summary-ready .story-hl a,
.ai-summary-target.ai-summary-ready .sci-hl a { border-bottom-color: var(--blue); }

.ai-panel {
  background: var(--paper);
  border: 2px solid var(--navy);
  border-radius: 4px;
  bottom: 5rem;
  box-shadow: 0 14px 38px rgba(10, 22, 40, .18);
  left: 1.1rem;
  max-height: min(520px, calc(100vh - 7rem));
  max-width: min(430px, calc(100vw - 2.2rem));
  overflow: auto;
  padding: 1rem;
  position: fixed;
  width: 430px;
  z-index: 21;
}

.ai-panel[hidden] { display: none; }

.ai-panel-head {
  align-items: flex-start;
  border-bottom: 1.5px solid var(--navy);
  display: flex;
  gap: .8rem;
  justify-content: space-between;
  margin-bottom: .8rem;
  padding-right: 1.6rem;
  padding-bottom: .65rem;
}

.ai-panel-kicker {
  color: var(--blue);
  font-family: 'Roboto Mono', monospace;
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.ai-panel-title {
  color: var(--navy);
  font-family: 'Merriweather', serif;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
  margin-top: .25rem;
}

.ai-panel-close {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--navy);
  cursor: pointer;
  font-family: 'Roboto Mono', monospace;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
  display: block;
  float: right;
  margin: -.35rem -.35rem .25rem .65rem;
  padding: .35rem;
  position: sticky;
  top: 0;
  z-index: 22;
}

.ai-summary-block { margin-top: .8rem; }
.ai-summary-label {
  color: var(--navy);
  font-family: 'Roboto Mono', monospace;
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .12em;
  margin-bottom: .25rem;
  text-transform: uppercase;
}

.ai-summary-text,
.ai-summary-list {
  color: #222222;
  font-size: .88rem;
  line-height: 1.7;
}

.ai-summary-list { margin-left: 1rem; }

.ai-panel-source {
  border-top: 1px solid var(--line);
  display: inline-block;
  font-family: 'Roboto Mono', monospace;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  margin-top: .9rem;
  padding-top: .7rem;
  text-transform: uppercase;
}

.ai-panel-status {
  color: var(--muted);
  font-family: 'Roboto Mono', monospace;
  font-size: .72rem;
  line-height: 1.6;
}

/* Small timestamp/source/status text below cards. */
.status-line {
  font-family: 'Roboto Mono', monospace;
  font-size: .68rem;
  color: var(--muted);
  margin-top: .5rem;
}

.section > .status-line:last-child {
  background: var(--paper);
  display: inline-block;
  margin-bottom: -.25rem;
  margin-top: 1.2rem;
  padding-right: .65rem;
  position: relative;
  z-index: 1;
}

.divider { border: none; border-top: 1px solid var(--line); margin: 2rem 0; }

footer {
  background: var(--paper);
  color: var(--muted);
  border-top: 2px solid var(--ink);
  text-align: center;
  padding: 1.5rem;
  font-family: 'Roboto Mono', monospace;
  font-size: .65rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-top: 3rem;
}

/* Tablet layout adjustments. */
@media (max-width: 780px) {
  .news-grid { grid-template-columns: 1fr; }
  .col-divider-left { border-left: none; padding-left: 0; border-top: 1px solid var(--line); padding-top: 1.2rem; }
  .idx-strip { grid-template-columns: repeat(3, 1fr); }
}

/* Phone layout adjustments. */
@media (max-width: 520px) {
  .idx-strip { grid-template-columns: repeat(2, 1fr); }
  .mast-top { justify-content: center; text-align: center; }
  .banner { flex-direction: column; align-items: flex-start; }
  .dc-row { align-items: flex-start; flex-direction: column; gap: .25rem; }
  .dc-val { text-align: left; }
  .mast-sub { letter-spacing: .08em; }
  .ai-summary-toggle { bottom: 1.05rem; left: 1rem; }
  .ai-panel { bottom: 4.85rem; left: 1rem; max-width: calc(100vw - 2rem); }
  .rate-row {
    align-items: center;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: .35rem .65rem;
    padding: .7rem 0;
  }
  .rate-main { grid-column: 1; }
  .rate-form {
    align-items: baseline;
    gap: .35rem;
  }
  .rate-side {
    grid-column: 1;
    justify-items: start;
    min-width: 0;
  }
  .rate-value { font-size: .98rem; }
  .rate-meta {
    font-size: .5rem;
    max-width: 100%;
    overflow-wrap: anywhere;
  }
  .rate-swap {
    grid-column: 2;
    grid-row: 1 / span 2;
    justify-self: end;
  }
  .rate-input { width: 3.4rem; }
  .rate-field { flex: 0 0 auto; }
}
