:root {
  --bg: #0a0e1a;
  --bg-card: #131929;
  --bg-card-hover: #1a2237;
  --text: #e8eaed;
  --text-dim: #95a3b8;
  --text-faint: #5c6b85;
  --accent: #f5a623;
  --accent-soft: rgba(245, 166, 35, 0.15);
  --blue: #4a90e2;
  --red: #e74c3c;
  --green: #2ecc71;
  --border: #1f2940;
  --max-width: 1100px;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 120ms ease;
}

a:hover {
  border-bottom-color: var(--accent);
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1rem;
}

/* HEADER */
header {
  padding: 0.85rem 0 0.85rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #0d1322 0%, var(--bg) 100%);
}

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  flex: 1 1 auto;
  min-width: 200px;
}

header h1 {
  font-size: clamp(1.1rem, 2.8vw, 1.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

header h1 a {
  color: inherit;
  border: none;
}

header .tagline {
  color: var(--text-dim);
  font-size: 0.9rem;
  max-width: 50ch;
  margin-top: 0.3rem;
}

/* HEADER ACTIONS (nav + tip button) */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* TOP NAV */
.top-nav {
  display: flex;
  gap: 0.25rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
}

/* MINI TIP BUTTON in header */
.bmc-mini {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.75rem;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 8px;
  transition: all 120ms ease;
}

.bmc-mini:hover {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.bmc-mini svg {
  flex-shrink: 0;
}

.nav-link {
  color: var(--text-dim);
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 6px;
  border: none;
  transition: all 120ms ease;
}

.nav-link:hover {
  color: var(--text);
  border: none;
}

.nav-link.active {
  background: var(--accent);
  color: var(--bg);
}

.nav-link.active:hover {
  color: var(--bg);
}

/* ABOUT PAGE */
.about-page {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  margin-top: 2rem;
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}

.about-page h2 {
  font-size: 1.6rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.about-page h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-top: 1.75rem;
  margin-bottom: 0.6rem;
  color: var(--text);
}

.about-page p,
.about-page ul {
  color: var(--text-dim);
  margin-bottom: 0.85rem;
}

.about-page ul {
  padding-left: 1.25rem;
}

.about-page li {
  margin-bottom: 0.5rem;
}

.about-page strong {
  color: var(--text);
}

main {
  padding: 1.25rem 0 3rem;
}

/* STATS — promoted, more visual punch */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  transition: background 120ms ease;
}

.stat-card.highlight {
  border-color: var(--accent);
  background: linear-gradient(180deg, var(--bg-card) 0%, rgba(245, 166, 35, 0.08) 100%);
}

.stat-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 0.35rem;
}

.stat-value {
  font-size: clamp(1.6rem, 4.5vw, 2.2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.stat-sub {
  font-size: 0.78rem;
  color: var(--text-faint);
  margin-top: 0.3rem;
}

.stat-value.down {
  color: var(--red);
}

.stat-value.up {
  color: var(--green);
}

/* CHART SECTIONS */
.chart-section,
.vessel-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.chart-header {
  margin-bottom: 1rem;
}

.chart-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.chart-sub {
  font-size: 0.85rem;
  color: var(--text-dim);
}

.chart-wrap {
  position: relative;
  height: 460px;
  width: 100%;
}

.chart-wrap.small {
  height: 280px;
}

/* Watermark sits in chart's bottom-left corner so screenshots include it.
   The exported PNG also bakes its own watermarks in the title bar/footer. */
.chart-watermark {
  position: absolute;
  bottom: 6px;
  left: 8px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-faint);
  letter-spacing: 0.04em;
  pointer-events: none;
  user-select: none;
  z-index: 1;
}

/* CHART TOOLBAR */
.chart-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.85rem;
}

.range-buttons {
  display: inline-flex;
  flex-wrap: wrap;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}

.range-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 0.4rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 120ms ease;
  font-family: inherit;
  white-space: nowrap;
}

.range-btn:hover {
  color: var(--text);
}

.range-btn.active {
  background: var(--accent);
  color: var(--bg);
}

/* CUSTOM DATE RANGE */
.custom-range {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 0.85rem;
  padding: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
}

.custom-range label {
  display: inline-flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.custom-range input[type="date"] {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.85rem;
  min-width: 130px;
  color-scheme: dark;
}

.custom-range input[type="date"]:focus {
  outline: none;
  border-color: var(--accent);
}

/* Compact icon button for download */
.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 0.4rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all 120ms ease;
  font-family: inherit;
}

.icon-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.icon-btn svg {
  flex-shrink: 0;
}

/* EVENT LIST — informative rows, replacing duplicate chip set */
.event-list {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.event-empty {
  color: var(--text-faint);
  font-size: 0.85rem;
  padding: 0.5rem 0;
}

.event-row {
  display: grid;
  grid-template-columns: 26px 90px 1fr auto;
  gap: 0.6rem;
  align-items: center;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--text-dim);
  transition: all 120ms ease;
  font-family: inherit;
  text-align: left;
  width: 100%;
}

.event-row:hover {
  background: rgba(245, 166, 35, 0.05);
  border-color: rgba(245, 166, 35, 0.3);
  color: var(--text);
}

.event-row.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
}

.event-row .ev-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  font-size: 0.74rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* Minor events: outlined ring, matches chart marker style */
.event-row:not(.major) .ev-num {
  background: transparent;
  border: 1.5px solid var(--accent);
  color: var(--accent);
  width: 20px;
  height: 20px;
  font-size: 0.68rem;
}

.event-row .ev-date {
  color: var(--accent);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  font-size: 0.8rem;
  white-space: nowrap;
}

.event-row .ev-label {
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.3;
}

.event-row .ev-source {
  color: var(--text-faint);
  font-size: 0.78rem;
  white-space: nowrap;
  border: none;
  padding: 0.2rem 0.4rem;
}

.event-row .ev-source:hover {
  color: var(--accent);
  border: none;
}

/* DATA TABLE */
.data-table-section {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}

.data-table-section summary {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
  padding: 0.4rem 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  list-style: none;
  user-select: none;
}

.data-table-section summary::-webkit-details-marker {
  display: none;
}

.data-table-section summary:hover {
  color: var(--text);
}

.data-table-section summary .caret {
  font-size: 1rem;
  transition: transform 200ms ease;
}

.data-table-section[open] summary .caret {
  transform: rotate(180deg);
}

.table-wrap {
  margin-top: 0.6rem;
  max-height: 380px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.data-table thead {
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 1;
}

.data-table th {
  text-align: left;
  font-weight: 600;
  color: var(--text-dim);
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.data-table th.th-num,
.data-table td.td-num {
  text-align: right;
}

.data-table tbody tr {
  border-bottom: 1px solid rgba(31, 41, 64, 0.5);
}

.data-table tbody tr:last-child {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: rgba(245, 166, 35, 0.04);
}

.data-table td {
  padding: 0.45rem 0.75rem;
  color: var(--text);
}

.data-table td.td-date {
  color: var(--text-dim);
  white-space: nowrap;
}

.data-table td.td-num.down {
  color: var(--red);
}

.data-table td.td-num.up {
  color: var(--green);
}

.table-footer {
  font-size: 0.75rem;
  color: var(--text-faint);
  margin-top: 0.5rem;
  text-align: right;
}

/* SHARE PAGE (/today) */
.share-page {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-top: 1.5rem;
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
}

.share-page h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.share-intro {
  color: var(--text-dim);
  font-size: 0.92rem;
  margin-bottom: 1.5rem;
}

.share-page h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.share-image-section,
.share-text-section,
.share-instructions-section {
  margin-bottom: 1.75rem;
}

.share-tip {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
}

.share-image-wrap {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.share-image-wrap img {
  width: 100%;
  height: auto;
  display: block;
}

.share-image-loader {
  color: var(--text-dim);
  font-size: 0.9rem;
  padding: 2rem;
}

#tweetText {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.85rem 1rem;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.5;
  resize: vertical;
  min-height: 140px;
}

#tweetText:focus {
  outline: none;
  border-color: var(--accent);
}

.share-buttons {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.share-buttons .icon-btn,
.share-buttons .bmc-cta {
  flex: 0 0 auto;
}

.share-instructions {
  padding-left: 1.25rem;
  color: var(--text-dim);
  font-size: 0.92rem;
}

.share-instructions li {
  margin-bottom: 0.4rem;
}

.share-instructions strong {
  color: var(--text);
}

.share-customize {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  margin-top: 1rem;
}

.share-customize summary {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
  padding: 0.4rem 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  list-style: none;
}

.share-customize summary::-webkit-details-marker {
  display: none;
}

.share-customize summary:hover {
  color: var(--text);
}

.share-customize summary .caret {
  font-size: 1rem;
  transition: transform 200ms ease;
}

.share-customize[open] summary .caret {
  transform: rotate(180deg);
}

.share-range-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.share-range-buttons .range-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 0.45rem 0.85rem;
}

.share-range-buttons .range-btn.active {
  background: var(--accent);
  border-color: var(--accent);
}

/* SUPPORT CALLOUT */
.support-callout {
  background: linear-gradient(135deg, rgba(245, 166, 35, 0.08) 0%, rgba(245, 166, 35, 0.03) 100%);
  border: 1px solid rgba(245, 166, 35, 0.35);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.support-text {
  flex: 1 1 320px;
  min-width: 0;
}

.support-text h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--text);
}

.support-text p {
  font-size: 0.88rem;
  color: var(--text-dim);
  margin: 0;
  max-width: 56ch;
}

.bmc-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--accent);
  color: var(--bg);
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0.7rem 1.15rem;
  border-radius: 10px;
  border: none;
  white-space: nowrap;
  transition: transform 120ms ease, box-shadow 120ms ease;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3), 0 4px 12px rgba(245, 166, 35, 0.25);
}

.bmc-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3), 0 6px 16px rgba(245, 166, 35, 0.35);
  border-bottom: none;
}

.bmc-cta svg {
  flex-shrink: 0;
}

/* FOOTER */
footer {
  padding: 1.25rem 0 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-faint);
  text-align: center;
}

/* MOBILE */
@media (max-width: 600px) {
  .container {
    padding: 0 0.85rem;
  }
  header {
    padding: 0.6rem 0;
  }
  header h1 {
    font-size: 1rem;
  }
  .top-nav {
    margin-top: 0;
  }
  .bmc-mini span {
    display: none;
  }
  .bmc-mini {
    padding: 0.4rem 0.55rem;
  }
  .support-callout {
    padding: 1.15rem;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
  }
  .bmc-cta {
    width: 100%;
    justify-content: center;
  }
  main {
    padding: 0.85rem 0 2rem;
  }
  .stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.85rem;
  }
  .stat-card {
    padding: 0.7rem 0.8rem;
  }
  .stat-value {
    font-size: 1.45rem;
  }
  .stat-label {
    font-size: 0.62rem;
  }
  .stat-sub {
    font-size: 0.7rem;
  }
  .chart-section,
  .vessel-section {
    padding: 0.85rem;
  }
  .chart-wrap {
    height: 380px;
  }
  .chart-wrap.small {
    height: 240px;
  }
  /* Tighter range buttons on mobile */
  .range-btn {
    padding: 0.35rem 0.6rem;
    font-size: 0.78rem;
  }
  .custom-range {
    padding: 0.6rem;
  }
  .custom-range input[type="date"] {
    min-width: 110px;
    font-size: 0.8rem;
  }
  .data-table th,
  .data-table td {
    padding: 0.4rem 0.5rem;
    font-size: 0.76rem;
  }
  /* Stack event row contents differently on small screens */
  .event-row {
    grid-template-columns: 26px 1fr auto;
    grid-template-areas:
      "num date source"
      "num label label";
    row-gap: 0.15rem;
    column-gap: 0.5rem;
    padding: 0.5rem 0.6rem;
  }
  .event-row .ev-num { grid-area: num; align-self: start; margin-top: 2px; }
  .event-row .ev-date { grid-area: date; }
  .event-row .ev-label { grid-area: label; font-size: 0.85rem; }
  .event-row .ev-source { grid-area: source; }
}
