@font-face {
  font-family: "Apple Garamond";
  src: url("./apple_garamond/AppleGaramond.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Apple Garamond";
  src: url("./apple_garamond/AppleGaramond-Light.ttf") format("truetype");
  font-style: normal;
  font-weight: 300;
  font-display: swap;
}

@font-face {
  font-family: "Apple Garamond";
  src: url("./apple_garamond/AppleGaramond-Bold.ttf") format("truetype");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: "Apple Garamond";
  src: url("./apple_garamond/AppleGaramond-Italic.ttf") format("truetype");
  font-style: italic;
  font-weight: 400;
  font-display: swap;
}

:root {
  --font-body: "Avenir Next", "Segoe UI", sans-serif;
  --font-display: "Apple Garamond", "Iowan Old Style", "Times New Roman", serif;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --ink: #1f2328;
  --muted: #606a76;
  --single: #116466;
  --multi: #b33f40;
  --overlay-single: #1f8f91;
  --overlay-multi: #d26b2f;
  --mixed: #627462;
  --overlay-mixed: #789067;
  --axis: #cfd5dd;
  --grid: #e8ecf1;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background:
    radial-gradient(circle at 20% 10%, #ffffff, transparent 40%),
    radial-gradient(circle at 90% 20%, #eceff3, transparent 35%),
    var(--bg);
  color: var(--ink);
  line-height: 1.4;
}

.wrap {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0.5rem 1rem 1rem;
}

.page-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.35rem;
}

.page-header-share {
  justify-self: end;
  align-self: end;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 0.24rem;
  padding-bottom: 0.12rem;
}

.page-header-share-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.page-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 1rem;
  align-items: start;
}

.main-column {
  min-width: 0;
}

.stats-column {
  min-width: 0;
}

.stats-card {
  position: sticky;
  top: 1rem;
}

h1 {
  margin: 0;
  font-size: clamp(2.52rem, 5.5125vw, 3.78rem);
  text-align: center;
  letter-spacing: -0.02em;
  font-family: var(--font-display);
  font-weight: 300;
}

.subtitle {
  margin: 0 0 1.5rem;
  color: var(--muted);
}

.card {
  background: var(--surface);
  border: 1px solid #d8dde4;
  border-radius: 14px;
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.06);
}

.card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
}

.card-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.85rem;
  margin-bottom: 0.75rem;
}

.card-header-row h2 {
  margin: 0;
}

.chart {
  width: 100%;
  height: 300px;
  display: block;
  border-radius: 10px;
  background: #fff;
  border: 1px solid #dfe4eb;
}

.legend {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.95rem;
  color: var(--muted);
  margin-top: 0.5rem;
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
  margin-right: 0.35rem;
  transform: translateY(1px);
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

.stats-vertical {
  grid-template-columns: 1fr;
}

.stat-tile {
  border: 1px solid #dde2ea;
  border-radius: 10px;
  background: #fff;
  padding: 0.7rem 0.75rem;
  min-height: 92px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.stat-value {
  font-size: clamp(1.35rem, 2.8vw, 1.95rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: #1f2328;
  font-family: var(--font-display);
}

.stat-value-group {
  display: grid;
  grid-template-columns: repeat(var(--timeline-count, 1), minmax(0, 1fr));
  gap: 0.45rem;
  align-items: end;
}

.stat-value-timeline {
  min-width: 0;
}

.stat-value.is-placeholder {
  color: #98a1ad;
}

.stat-label {
  margin-top: 0.35rem;
  font-size: 0.82rem;
  color: #697382;
}

.stat-note {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.75rem;
}

.picker {
  position: relative;
  max-width: 540px;
}

.timelines-region {
  position: relative;
  margin-bottom: 0.55rem;
}

.timelines-share-button {
  border: 1px solid #c9d1dc;
  border-radius: 999px;
  background: #ffffff;
  color: #445161;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.34rem 0.78rem;
  cursor: pointer;
  white-space: nowrap;
}

.timelines-share-button:hover,
.timelines-share-button:focus-visible {
  background: #f4f7fa;
  border-color: #b7c1cf;
  color: #324050;
  outline: none;
}

.timelines-clear-button {
  color: #5a6676;
}

.timelines-share-icon {
  width: 0.9rem;
  height: 0.9rem;
  display: block;
}

.timelines-share-status {
  min-height: 0.95rem;
  font-size: 0.8rem;
  line-height: 1;
  color: #5f6b7b;
}

.timelines-share-status.is-error {
  color: #b33f40;
}

.timelines-list {
  display: grid;
  gap: 0.42rem;
}

.timeline-card {
  position: relative;
  border: 1px solid #d5dce7;
  border-radius: 11px;
  background: #fff;
  padding: 0.34rem 0.54rem;
  padding-left: 0.68rem;
}

.timeline-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  border-radius: 11px 0 0 11px;
  background: var(--timeline-color, #007aff);
}

.timeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.timeline-title {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  min-width: 0;
  flex: 1 1 auto;
}

.timeline-name-text {
  font-size: 0.94rem;
  font-weight: 600;
  color: #1f2328;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.timeline-expand-toggle {
  border: 0;
  background: transparent;
  color: #5e6978;
  border-radius: 6px;
  width: 1.45rem;
  min-width: 1.45rem;
  height: 1.45rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.timeline-expand-toggle.is-expanded .picker-option-chevron {
  transform: rotate(90deg);
}

.timeline-expand-toggle:hover,
.timeline-expand-toggle:focus-visible {
  background: #edf1f6;
  outline: none;
}

.timeline-name-input {
  width: 100%;
  min-width: 0;
  border: 1px solid #d2d9e4;
  border-radius: 8px;
  background: #fff;
  color: #1f2328;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.28rem 0.52rem;
}

.timeline-name-input:focus {
  outline: 2px solid #a5c5ee;
  outline-offset: 1px;
}

.timeline-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.timeline-header-actions .ownership-option-toggle {
  white-space: nowrap;
}

.timeline-card.is-collapsed {
  cursor: pointer;
}

.timeline-card.is-collapsed:focus-visible {
  outline: 2px solid #a5c5ee;
  outline-offset: 2px;
}

.timeline-card.is-collapsed .timeline-name-text {
  max-width: none;
}

.model-picker-overlay {
  position: absolute;
  left: 0;
  width: 100%;
  z-index: 45;
}

.model-picker-overlay[hidden] {
  display: none;
}

.model-picker-overlay-panel {
  width: min(600px, calc(100% - 0.5rem));
  max-width: calc(100vw - 1.25rem);
  margin: 0 auto;
  border: 1px solid #d4dbe5;
  border-radius: 12px;
  background: #ffffff;
  padding: 0.7rem 0.2rem 0.9rem 0.9rem;
  box-shadow: 0 14px 26px rgba(15, 23, 42, 0.2);
}

.model-picker-overlay-topbar {
  display: flex;
  align-items: flex-start;
  gap: 0.22rem;
}

.model-picker-overlay-panel .picker {
  max-width: none;
  flex: 1 1 auto;
  min-width: 0;
}

.model-picker-overlay-close {
  align-self: flex-start;
  margin-top: -4px;
  width: 1.6rem;
  height: 1.6rem;
  border: 0;
  background: transparent;
  color: #5a6676;
  border-radius: 999px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
}

.model-picker-overlay-close span {
  position: relative;
  top: -2px;
}

.model-picker-overlay-close:hover,
.model-picker-overlay-close:focus-visible {
  background: #e3e9f1;
  color: #2d3745;
  outline: none;
}

.picker-label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.picker-input {
  width: 100%;
  border: 1px solid #cdd4de;
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  padding: 0.6rem 0.7rem;
}

.picker-input:focus {
  outline: 2px solid rgba(28, 130, 132, 0.25);
  outline-offset: 1px;
}

.picker-options {
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0.3rem;
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  max-height: 240px;
  overflow: auto;
  border: 1px solid #cdd4de;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.12);
}

.picker-option-btn {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 0.5rem 0.55rem;
  border-radius: 7px;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.picker-option-btn-expandable {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
}

.picker-option-chevron {
  flex: 0 0 auto;
  color: #5e6978;
  transform: rotate(0deg);
  transform-origin: 50% 50%;
  transition: transform 160ms ease;
}

.picker-option-btn.is-expanded .picker-option-chevron {
  transform: rotate(90deg);
}

.picker-option-label {
  min-width: 0;
}

.picker-option-btn:hover,
.picker-option-btn:focus-visible {
  background: #e9edf3;
  outline: none;
}

.picker-config-list {
  list-style: none;
  margin: 0.2rem 0 0.35rem;
  padding: 0 0 0 1rem;
}

.picker-option-btn-config {
  font-size: 0.92rem;
  color: #2f3742;
  border-left: 2px solid #d4dbe4;
  border-radius: 0 7px 7px 0;
}

.model-selection {
  margin: 0.8rem 0 0;
  color: var(--muted);
}

.model-selection:empty {
  display: none;
}

.model-history {
  list-style: none;
  margin: 0.34rem 0 0 1.65rem;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.model-history-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  max-width: 100%;
  min-height: 1.56rem;
  border: 0;
  border-radius: 999px;
  background: var(--timeline-color, #007aff);
  color: #ffffff;
  padding: 0.26rem 0.35rem 0.26rem 0.6rem;
}

.model-history-content {
  min-width: 0;
}

.model-history-title {
  font-size: 0.86rem;
  font-weight: 600;
  color: inherit;
  white-space: nowrap;
}

.model-history-remove {
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.9);
  font: inherit;
  border-radius: 999px;
  padding: 0;
  width: 1rem;
  height: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-size: 0.82rem;
  cursor: pointer;
  flex: 0 0 auto;
}

.model-history-remove:hover,
.model-history-remove:focus-visible {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.model-history-remove:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.9);
  outline-offset: 1px;
}

.model-history-remove-glyph {
  position: relative;
  left: 0.2px;
  top: 1px;
}

.model-history-add-item {
  display: inline-flex;
}

.model-history-add {
  width: auto;
  min-width: 0;
  height: 1.56rem;
  border: 1px solid #c4ccd7;
  background: #ffffff;
  color: #6e7887;
  padding: 0 0.6rem;
  justify-content: flex-start;
  gap: 0.42rem;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
}

.model-history-add:hover,
.model-history-add:focus-visible {
  background: #f4f7fa;
  border-color: #b5bfcc;
  color: #5f6978;
}

.model-history-add:focus-visible {
  outline: 2px solid rgba(122, 132, 146, 0.35);
  outline-offset: 2px;
}

.model-history-add-glyph {
  position: relative;
  top: -1px;
}

.model-history-add-text {
  position: relative;
  top: -0.35px;
  white-space: nowrap;
}

.ownership-option-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.84rem;
  font-weight: 600;
  color: #353f4c;
}

.ownership-option-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--timeline-color, #1f8f91);
}

.ownership-option-row {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: flex-start;
  min-height: 1.6rem;
}

@media (max-width: 720px) {
  .page-header {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 0.55rem;
  }

  .page-header-spacer {
    display: none;
  }

  .page-header-share {
    justify-self: center;
    align-items: center;
    padding-bottom: 0;
  }

  .card-header-row {
    flex-wrap: wrap;
    gap: 0.55rem;
  }
}

/*
  Reusable tooltip primitive for inline help across the UI.
  Behavior:
  - Bubble opens on hover and keyboard focus.
  - `.tooltip` can wrap either a compact circular "i" trigger or an entire interactive chip.
  - Content bubble is shared, with optional modifier classes for context-specific sizing.
*/
.tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
  --tooltip-shift-x: 0px;
  --tooltip-arrow-left: 50%;
}

.tooltip-trigger {
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 999px;
  border: 1px solid #c2cad4;
  background: #fff;
  color: #526071;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: 1.0rem;
  line-height: 1;
  padding: 0;
  cursor: help;
}

.tooltip-trigger:hover,
.tooltip-trigger:focus-visible {
  background: #edf2f7;
  border-color: #aeb8c5;
  color: #2f3946;
  outline: none;
}

.tooltip-content {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.35rem);
  transform: translateX(calc(-50% + var(--tooltip-shift-x))) translateY(4px);
  min-width: 250px;
  max-width: min(360px, 85vw);
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  border: 1px solid #ccd4df;
  background: #f9fbfd;
  color: #2f3946;
  font-size: 0.8rem;
  font-weight: 400;
  line-height: 1.35;
  box-shadow: 0 10px 18px rgba(13, 18, 26, 0.32);
  opacity: 0;
  visibility: hidden;
  pointer-events: auto;
  transition: opacity 120ms ease, transform 120ms ease;
  z-index: 20;
}

.tooltip-content::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 0.4rem;
}

.tooltip-content::after {
  content: "";
  position: absolute;
  left: var(--tooltip-arrow-left);
  top: 100%;
  transform: translateX(-50%);
  border-width: 6px 6px 0;
  border-style: solid;
  border-color: #f9fbfd transparent transparent;
}

.tooltip:hover .tooltip-content,
.tooltip:focus-within .tooltip-content {
  opacity: 1;
  visibility: visible;
  transform: translateX(calc(-50% + var(--tooltip-shift-x))) translateY(0);
}

.tooltip-content code {
  background: #eef3f8;
  border: 1px solid #d5dde8;
  border-radius: 4px;
  padding: 0.1em 0.35em;
  color: inherit;
}

.tooltip-content-history {
  left: 0;
  transform: translateX(var(--tooltip-shift-x)) translateY(4px);
  min-width: 320px;
  max-width: min(720px, 92vw);
  overflow-wrap: anywhere;
}

.tooltip:hover .tooltip-content-history,
.tooltip:focus-within .tooltip-content-history {
  transform: translateX(var(--tooltip-shift-x)) translateY(0);
}

.chart-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1.6rem;
  margin-bottom: 0.75rem;
  align-items: center;
  justify-content: center;
}

.chart-dropdown {
  position: relative;
  flex: 0 0 auto;
  width: fit-content;
}

.chart-dropdown-toggle {
  width: auto;
  border: 0;
  background: transparent;
  color: #1f2328;
  border-radius: 0;
  padding: 0;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.25rem;
  text-align: left;
  line-height: 1.15;
}

.chart-dropdown-toggle:hover,
.chart-dropdown-toggle:focus-visible {
  outline: none;
  color: #0f141b;
}

.chart-dropdown-toggle[aria-expanded="true"] {
  color: #0f141b;
}

.chart-dropdown-value {
  display: block;
}

.chart-dropdown-chevron {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-dropdown-menu {
  position: absolute;
  top: calc(100% + 0.26rem);
  left: 0;
  min-width: 240px;
  width: max-content;
  max-width: min(420px, 92vw);
  border: 1px solid #cdd4de;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 9px 18px rgba(15, 23, 42, 0.14);
  padding: 0.26rem;
  z-index: 35;
}

.chart-dropdown-menu[hidden] {
  display: none;
}

.chart-dropdown-option {
  width: 100%;
  border: 0;
  background: transparent;
  color: #2f3742;
  border-radius: 8px;
  padding: 0.48rem 0.52rem;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.chart-dropdown-option:hover,
.chart-dropdown-option:focus-visible {
  background: #edf1f6;
  outline: none;
}

.chart-dropdown-option.is-active {
  background: #e5eef8;
  color: #1f2834;
}

.metric-mix-option {
  font-weight: 600;
}

.chart-dropdown-option-title {
  display: block;
  font-weight: 600;
}

.chart-dropdown-option-subtitle {
  display: block;
  margin-top: 0.16rem;
  color: #5d6877;
  font-size: 0.83rem;
}

.status {
  color: var(--muted);
}

.error {
  color: #9f2022;
  font-weight: 600;
}

@media (min-width: 961px) {
  .wrap {
    height: 100svh;
    min-height: 100svh;
    display: flex;
    flex-direction: column;
  }

  .page-layout {
    flex: 1 1 auto;
    min-height: 0;
    grid-template-rows: minmax(0, 1fr);
    align-items: stretch;
  }

  .main-column {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 0;
    align-self: stretch;
  }

  .stats-column {
    min-height: 0;
    align-self: stretch;
    overflow: visible;
  }

  .stats-card {
    position: static;
    top: auto;
    margin-bottom: 0;
    height: 100%;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 1rem;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .stats-card::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
  }

  .main-column > .chart-card {
    display: flex;
    flex-direction: column;
    min-height: 0;
    margin-bottom: 0;
  }

  .main-column > .chart-card .chart {
    flex: 1 1 auto;
    min-height: clamp(120px, 22svh, 300px);
    height: 100%;
  }
}

@media (max-width: 960px) {
  .page-layout {
    grid-template-columns: 1fr;
  }

  .stats-card {
    position: static;
  }

  .stats-vertical {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }

}
