
/* ===================================================
   Reset / Base
   =================================================== */

*{ box-sizing: border-box; }

html{
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body{
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  margin: 0;
  padding: 16px 16px 28px;
  line-height: 1.5;
  color: #111;
  background: #fff;
  overflow-x: hidden;
}

/* ===================================================
   Header / Intro width
   =================================================== */

header,
.page-summary{
  width: min(100%, 38em);
  margin-left: auto;
  margin-right: auto;
}

header{
  padding: 8px 0 6px;
}

h1{
  text-align: center;
  margin: 8px 0 10px;
  font-size: clamp(20px, 3vw, 30px);
  line-height: 1.35;
}

/* ===================================================
   Header meta
   =================================================== */

.header-meta{
  width: 100%;
  margin: 6px 0 0;
  text-align: right;
}

.author{
  font-size: 14px;
  margin: 0;
  line-height: 1.5;
}

.author a{
  color: inherit;
  text-decoration: none;
}

.author a:hover{
  text-decoration: underline;
}

.author-sep{
  margin: 0 0.3em;
}

.update-date{
  font-size: 14px;
  color: #666;
  margin: 2px 0 0 0;
  line-height: 1.4;
}

/* ===================================================
   Summary text
   =================================================== */

.page-summary{
  margin-top: 0;
  margin-bottom: 20px;
  line-height: 1.7;
}

.page-summary h2,
.page-summary p{
  width: 100%;
  margin: 0 0 1em 0;
}

.page-summary a{
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 0.12em;
}

/* ===================================================
   Controls card
   =================================================== */

.controls-card{
  max-width: 900px;
  margin: 0 auto 14px;
  padding: 10px 14px 8px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
}

.controls-title{
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 8px;
  text-align: center;
}

.filter-group{
  margin-bottom: 10px;
}

.filter-group:last-of-type{
  margin-bottom: 4px;
}

.filter-actions{
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 6px;
}

.controls-card select{
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #fff;
  font-weight: 600;
  font-size: 0.95rem;
}

#pref-selected,
#disease-selected{
  margin-top: 0;
  padding-top: 0;
}

.link-button{
  background: none;
  border: none;
  color: #6b7280;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  line-height: 36px;
}

.link-button:hover{
  text-decoration: underline;
}

.filter-tags{
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-tag{
  background: #eef2ff;
  color: #1e3a8a;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.filter-tag:hover{
  background: #e0e7ff;
}

/* ===================================================
   Hidden dropdown
   =================================================== */

.dropdown{
  position: relative;
  display: inline-block;
  width: min(360px, 92vw);
  text-align: left;
}

.dropdown-btn{
  border: 1px solid #ccc;
  padding: 10px 10px;
  background: #fff;
  cursor: pointer;
  width: 100%;
  border-radius: 8px;
}

.dropdown-content{
  display: none;
  position: absolute;
  inset: calc(100% + 6px) 0 auto 0;
  background: #fff;
  border: 1px solid #ccc;
  max-height: 260px;
  overflow-y: auto;
  z-index: 1000;
  border-radius: 10px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.12);
}

.dropdown.open .dropdown-content{ display: block; }

.option{
  padding: 10px 10px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
  user-select: none;
}

.option:last-child{ border-bottom: none; }

.option.selected{ background: #def; }

/* ===================================================
   Chart grid
   =================================================== */

#chart-container{
  max-width: 1200px;
  margin: 16px auto 0;
  display: grid;
  gap: 26px;
  grid-template-columns: 1fr;
}

@media (min-width: 900px){
  #chart-container{
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1400px){
  #chart-container{
    max-width: 1500px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* ===================================================
   Chart card
   =================================================== */

.chart{
  background: #fff;
  border: none;
  border-radius: 12px;
  padding: 12px 12px 10px;
  overflow: hidden;
  container-type: inline-size;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.chart h2{
  margin: 6px 0 8px;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.25;
}

/* ===================================================
   Inner layout
   =================================================== */

.chart-wrapper{
  display: flex;
  gap: 4px;
  align-items: flex-start;
  min-width: 0;
  flex-wrap: nowrap;
}

.left-charts{
  flex: 1 1 auto;
  min-width: 0;
  overflow: visible;
}

.chart-legend{
  flex: 0 0 auto;
  width: fit-content;
  max-width: 110px;
  padding-left: 2px;
}

.chart-svg{
  margin-bottom: 12px;
}

/* ===================================================
   Legend
   =================================================== */

.legend{
  text-align: left;
  font-size: 13px;
}

.legend-item{
  display: block;
  margin: 5px 0;
  font-weight: 700;
  cursor: pointer;
  white-space: normal;
  overflow-wrap: anywhere;
}

@media (max-width: 600px){
  .legend{
    font-size: 12px;
  }
}

/* ===================================================
   SVG
   =================================================== */

.svg-content{
  display: block;
  max-width: 100%;
}

.chart svg{
  max-width: 100%;
  display: block;
}

.axis path,
.axis line{
  fill: none;
  stroke: #000;
}

.chart-svg .axis text{
  font-size: 12px;
}

.line{
  fill: none;
  stroke-width: 2px;
}

/* ===================================================
   Tooltip
   =================================================== */

.tooltip{
  position: absolute;
  text-align: center;
  padding: 6px 8px;
  background: rgba(220,220,220,0.95);
  border-radius: 6px;
  pointer-events: none;
  opacity: 0;
  font-size: 0.9rem;
}

/* ===================================================
   Slider
   =================================================== */

.slider-wrapper{
  display: block;
  background: #fafafa;
  padding: 4px 8px 6px;
  margin-top: 8px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

.slider-wrapper svg{
  display: block;
  width: 100%;
  min-width: 0;
}

.slider-wrapper .axis text{
  font-size: 12px;
  fill: #555;
}

.slider-track-bg{
  fill: #f3f4f6;
  stroke: #e5e7eb;
  stroke-width: 1;
  rx: 5;
  ry: 5;
}

.context-dim{
  fill: rgba(17, 24, 39, 0.08);
  pointer-events: none;
}

.brush .overlay{
  cursor: crosshair;
}

.brush .selection{
  fill: rgba(37, 99, 235, 0.14);
  stroke: #2563eb;
  stroke-width: 1.2px;
  shape-rendering: crispEdges;
  cursor: grab;
}

.brush .selection:active{
  cursor: grabbing;
}

.brush .handle{
  fill: #fff;
  stroke: #2563eb;
  stroke-width: 1.2px;
  rx: 6;
  ry: 6;
  cursor: ew-resize;
}

.brush-handle-grip line{
  stroke: #2563eb;
  stroke-width: 1.3px;
  stroke-linecap: round;
  pointer-events: none;
}

/* ===================================================
   Highlight
   =================================================== */

.highlight-line{ stroke-width: 4px !important; }
.highlight-circle{ r: 6 !important; }

.inactive-line,
.inactive-circle{ opacity: 0.15; }

/* ===================================================
   Select arrow
   =================================================== */

.select-wrap{
  position: relative;
  display: inline-block;
  height: 36px;
}

.select-wrap::after{
  content: "▾";
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: #6b7280;
  pointer-events: none;
}

.select-wrap select{
  appearance: none;
  padding-right: 28px;
}

#pref-selected{
  margin-bottom: 10px;
}

.controls-card select{
  height: 36px;
}

/* ===================================================
   Mobile adjustments
   =================================================== */

@media (max-width: 640px){
  body{
    padding: 14px 14px 24px;
  }

  h1{
    font-size: clamp(20px, 6vw, 28px);
    margin: 6px 0 8px;
  }

  .author,
  .update-date{
    font-size: 13px;
  }

  .filter-actions{
    flex-wrap: wrap;
    gap: 8px;
  }

  .chart-wrapper{
    flex-wrap: nowrap;
    align-items: flex-start;
    gap: 4px;
  }

.chart-legend{
  flex: 0 0 auto;
  width: fit-content;
  max-width: 56px;
  min-width: 0;
  padding-left: 2px;
}

  .legend{
    font-size: 11px;
    line-height: 1.25;
  }

  .legend-item{
    margin: 4px 0;
  }

  .slider-wrapper .axis text{
    font-size: 13px;
  }
}

.usage-note{
  font-size: 0.85rem;
  color: #555;
  line-height: 1.6;
  margin-top: 6px;
  padding: 6px 8px;
  background: #f8f9fa;
  border-radius: 6px;
}
