/* ===== CSS Reset & Base Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }
  
  :root {
    --color-susceptible: #2c3e50;
    --color-exposed: #27ae60;
    --color-infectious: #e67e22;
    --color-recovered: #3498db;
    --color-primary: #B8956A;
    --color-secondary: #A0826D;
    --color-background: #FAF6F1;
    --color-card: #ffffff;
    --color-border: #E8DDD0;
    --color-text: #4A4A4A;
    --color-text-light: #8B7D6B;
    --color-link: #B8956A;
    --shadow-sm: 0 2px 4px rgba(184, 149, 106, 0.08);
    --shadow-md: 0 4px 6px rgba(184, 149, 106, 0.12);
    --shadow-lg: 0 10px 25px rgba(184, 149, 106, 0.15);
    --radius: 9px;
    --transition: all 0.3s ease;
  }
  
  body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--color-text);
    background: linear-gradient(135deg, #FAF6F1 0%, #F0E8DC 100%);
    min-height: 100vh;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
  }

  /* ===== Global Link Styles ===== */
  a {
    color: var(--color-link);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
    border-bottom: 1px solid transparent;
  }

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

  a:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: 2px;
  }

  a:active {
    color: var(--color-primary);
  }
  
  .container {
    max-width: 1050px;
    margin: 0 auto;
    padding: 0 1.5rem;
  }
  
  /* ===== Header ===== */
  .site-header {
    background: linear-gradient(135deg, #C9A882 0%, #B8956A 100%);
    color: white;
    padding: 2.25rem 0;
    box-shadow: var(--shadow-lg);
    margin-bottom: 2.25rem;
    position: sticky;
    top: 0;
    z-index: 100;
  }
  
  .site-title {
    font-size: 1.875rem;
    font-weight: 700;
    margin-bottom: 0.375rem;
    text-align: center;
    letter-spacing: -0.5px;
  }
  
  .site-subtitle {
    font-size: 0.825rem;
    font-weight: 300;
    text-align: center;
    opacity: 0.95;
  }

  /* Mobile header improvements */
  @media (max-width: 768px) {
    .site-header {
      position: relative;
      margin-bottom: 1.5rem;
    }
  }
  
  /* ===== Main Content ===== */
  .main-content {
    padding-bottom: 3rem;
  }
  
  /* ===== Info Section ===== */
  .info-section {
    margin-bottom: 1.5rem;
  }
  
  .info-card {
    background: var(--color-card);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
  }
  
  .description-text {
    margin-bottom: 0;
  }
  
  .description {
    font-size: 0.825rem;
    line-height: 1.8;
    color: var(--color-text);
    text-align: left;
    margin: 0;
  }
  
  /* ===== Variable Badges ===== */
  .varS {
    color: var(--color-susceptible);
    font-weight: 600;
  }

  .varE {
    color: var(--color-exposed);
    font-weight: 600;
  }

  .varI {
    color: var(--color-infectious);
    font-weight: 600;
  }

  .varR {
    color: var(--color-recovered);
    font-weight: 600;
  }
  
  .varS.badge {
    /* color: var(--color-susceptible); */
    background: rgba(44, 62, 80, 0.1);
    padding: 0.1875rem 0.5625rem;
    border-radius: 15px;
    display: inline-block;
    margin: 0 0.15rem;
    font-size: 0.825rem;
  }
  
  .varE.badge {
    /* color: var(--color-exposed); */
    background: rgba(39, 174, 96, 0.1);
    padding: 0.1875rem 0.5625rem;
    border-radius: 15px;
    display: inline-block;
    margin: 0 0.15rem;
    font-size: 0.825rem;
  }
  
  .varI.badge {
    /* color: var(--color-infectious); */
    background: rgba(230, 126, 34, 0.1);
    padding: 0.1875rem 0.5625rem;
    border-radius: 15px;
    display: inline-block;
    margin: 0 0.15rem;
    font-size: 0.825rem;
  }
  
  .varR.badge {
    /* color: var(--color-recovered); */
    background: rgba(52, 152, 219, 0.1);
    padding: 0.1875rem 0.5625rem;
    border-radius: 15px;
    display: inline-block;
    margin: 0 0.15rem;
    font-size: 0.825rem;
  }
  
  /* ===== Plot Paths ===== */
  path.varS { stroke: var(--color-susceptible); stroke-width: 3; fill: none; }
  path.varE { stroke: var(--color-exposed); stroke-width: 3; fill: none; }
  path.varI { stroke: var(--color-infectious); stroke-width: 3; fill: none; }
  path.varR { stroke: var(--color-recovered); stroke-width: 3; fill: none; }
  
  /* ===== Cards ===== */
  .card {
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    margin-bottom: 1.5rem;
    transition: var(--transition);
  }
  
  .card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
  }
  
  .card-header {
    background: linear-gradient(135deg, #C9A882 0%, #B8956A 100%);
    color: white;
    padding: 1.125rem 1.5rem;
    border-bottom: 3px solid rgba(255, 255, 255, 0.1);
  }
  
  .card-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
  }
  
  .card-subtitle {
    font-size: 0.675rem;
    opacity: 0.9;
    margin-top: 0.375rem;
    font-weight: 300;
  }
  
  .card-body {
    padding: 1.5rem;
  }
  
  /* ===== Expandable Header ===== */
  .expandable-header {
    cursor: pointer;
    user-select: none;
    transition: var(--transition);
  }
  
  .expandable-header:hover {
    background: linear-gradient(135deg, #D4B594 0%, #C9A882 100%);
  }
  
  .header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  
  .expand-icon {
    font-size: 0.9rem;
    transition: transform 0.3s ease;
  }
  
  .equations-body {
    overflow-x: auto;
    transition: all 0.3s ease;
  }
  
  #model-eqns {
    font-size: 0.7125rem;
  }
  
  /* ===== Plot Section ===== */
  #plot-section {
    margin-bottom: 1.5rem;
  }
  
  #plot-container {
    padding: 3rem 2rem;
    background: #FAF6F1;
    border-radius: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  #plot svg {
    width: 100%;
    height: 450px;
    display: block;
    background: white;
    border-radius: 6px;
    /* box-shadow: var(--shadow-sm); */
    margin-bottom: 2rem;
    min-width: 300px; /* Ensure minimum width for mobile */
  }

  #plot {
    font-size: 0.725rem;
  }

  /* Mobile plot improvements */
  @media (max-width: 768px) {
    #plot-container {
      padding: 1.5rem 1rem;
      margin: 0 -0.5rem; /* Extend to edges on mobile */
      border-radius: 0;
    }

    #plot svg {
      min-width: 280px;
      border-radius: 4px;
    }

    /* Improve plot text readability on mobile */
    #plot text {
      font-size: 0.7rem !important;
    }

    #plot .axis text {
      font-size: 0.65rem !important;
    }
  }

  @media (max-width: 480px) {
    #plot-container {
      padding: 1rem 0.5rem;
    }

    #plot svg {
      min-width: 250px;
    }

    #plot text {
      font-size: 0.65rem !important;
    }

    #plot .axis text {
      font-size: 0.6rem !important;
    }
  }
  
  .axis {
    stroke: var(--color-text);
    stroke-linecap: round;
    stroke-width: 1.5;
  }
  
  /* ===== Parameters Card ===== */
  .param-group {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    /* border-bottom: 2px solid var(--color-border); */
  }
  
  .param-group:last-child {
    /* border-bottom: none; */
    margin-bottom: 0;
    padding-bottom: 0;
  }
  
  .param-group h3 {
    font-size: 0.825rem;
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: 0.9375rem;
    padding-bottom: 0.375rem;
    border-bottom: 2px solid var(--color-border);
  }
  
  /* ===== Parameters Grid ===== */
  .params-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1.125rem 1.5rem;
  }
  
  /* @media (max-width: 500px) {
    .params-grid {
      grid-template-columns: 1fr;
    }
  } */
  
  /* ===== Plot Controls ===== */
  .plot-control {
    display: block;
  }
  
  .plot-control label {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: 0.5625rem;
    font-size: 0.7125rem;
  }
  
  .plot-control input[type=range] {
    width: 100%;
    height: 6px;
    border-radius: 3.75px;
    background: linear-gradient(to right, #C9A882, #B8956A);
    outline: none;
    opacity: 0.8;
    transition: opacity 0.2s;
    -webkit-appearance: none;
    appearance: none;
    margin-bottom: 0.375rem;
  }
  
  .plot-control input[type=range]:hover {
    opacity: 1;
  }
  
  .plot-control input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    box-shadow: 0 1.5px 4.5px rgba(184, 149, 106, 0.3);
    border: 2.25px solid #B8956A;
  }
  
  .plot-control input[type=range]::-moz-range-thumb {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    box-shadow: 0 1.5px 4.5px rgba(184, 149, 106, 0.3);
    border: 2.25px solid #B8956A;
  }
  
  .plot-control .show_value {
    display: inline-block;
    font-weight: 600;
    color: var(--color-primary);
    background: var(--color-background);
    padding: 0.3rem 0.75rem;
    border-radius: 15px;
    font-size: 0.675rem;
    min-width: 45px;
    text-align: center;
  }
  
  /* ===== Info Button ===== */
  .info-btn {
    background: linear-gradient(135deg, #C9A882 0%, #B8956A 100%);
    color: white;
    border: none;
    border-radius: 50%;
    width: 15px;
    height: 15px;
    font-size: 0.5625rem;
    cursor: help;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    position: relative;
    flex-shrink: 0;
    font-weight: 600;
  }
  
  .info-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 1.5px 6px rgba(184, 149, 106, 0.4);
  }
  
  .info-btn::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 7.5px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-primary);
    color: white;
    padding: 0.5625rem 0.75rem;
    border-radius: 6px;
    font-size: 0.6375rem;
    font-weight: 400;
    white-space: normal;
    width: 210px;
    max-width: 90vw;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    line-height: 1.4;
    text-align: left;
  }
  
  .info-btn::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 1.5px);
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--color-primary);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1000;
  }
  
  .info-btn:hover::after,
  .info-btn:hover::before {
    opacity: 1;
  }
  
  /* ===== Reset Button ===== */
  .reset-btn {
    background: linear-gradient(135deg, #C9A882 0%, #B8956A 100%);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 0.675rem 1.5rem;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
  }
  
  .reset-btn:hover {
    background: linear-gradient(135deg, #D4B594 0%, #C9A882 100%);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
  }
  
  .reset-btn:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
  }
  
  /* ===== Footer ===== */
  #footer {
    background: var(--color-card);
    padding: 1.5rem 0;
    text-align: center;
    box-shadow: 0 -3px 4.5px rgba(184, 149, 106, 0.08);
    margin-top: 3rem;
  }
  
  #footer p {
    color: var(--color-text-light);
    font-size: 0.7125rem;
  }
  
  /* ===== Mobile-First Responsive Design ===== */
  
  /* Base mobile styles (320px+) */
  @media (max-width: 767px) {
    .container {
      padding: 0 1rem;
    }

    .site-header {
      padding: 1.25rem 0;
      margin-bottom: 1.5rem;
    }

    .site-title {
      font-size: 1.5rem;
      line-height: 1.2;
      margin-bottom: 0.5rem;
    }

    .site-subtitle {
      font-size: 0.8rem;
      line-height: 1.3;
    }

    .description {
      font-size: 0.8rem;
      line-height: 1.6;
      padding: 1rem;
    }

    .card {
      margin-bottom: 1rem;
    }

    .card-header {
      padding: 1rem;
    }

    .card-header h2 {
      font-size: 1rem;
      line-height: 1.3;
    }

    .card-subtitle {
      font-size: 0.7rem;
      margin-top: 0.25rem;
    }

    .card-body {
      padding: 1rem;
    }

    #plot-container {
      padding: 1.5rem 1rem;
    }

    #plot svg {
      height: 280px;
    }

    .param-group {
      margin-bottom: 1rem;
      padding-bottom: 1rem;
    }

    .param-group h3 {
      font-size: 0.8rem;
      margin-bottom: 0.75rem;
    }

    .params-grid {
      grid-template-columns: 1fr 1fr;
      gap: 1rem;
    }

    .plot-control label {
      font-size: 0.75rem;
      margin-bottom: 0.5rem;
    }

    .plot-control input[type=range] {
      margin-bottom: 0.5rem;
    }

    .show_value {
      font-size: 0.7rem;
      padding: 0.25rem 0.5rem;
      min-width: 40px;
    }

    .info-btn {
      width: 14px;
      height: 14px;
      font-size: 0.5rem;
    }

    .info-btn::after {
      width: 180px;
      font-size: 0.65rem;
      padding: 0.5rem 0.75rem;
      bottom: calc(100% + 8px);
    }

    .reset-btn {
      padding: 0.6rem 1.25rem;
      font-size: 0.8rem;
    }

    /* Improve touch targets */
    .plot-control input[type=range] {
      height: 8px;
      -webkit-tap-highlight-color: transparent;
    }

    .plot-control input[type=range]::-webkit-slider-thumb {
      width: 18px;
      height: 18px;
      border: 2px solid #B8956A;
    }

    .plot-control input[type=range]::-moz-range-thumb {
      width: 18px;
      height: 18px;
      border: 2px solid #B8956A;
    }

    /* Better spacing for mobile */
    .main-content {
      padding-bottom: 2rem;
    }

    #footer {
      padding: 1.25rem 0;
      margin-top: 2rem;
    }

    #footer p {
      font-size: 0.7rem;
    }

    /* Improve equations section for mobile */
    .equations-body {
      font-size: 0.75rem;
    }

    #model-eqns {
      font-size: 0.7rem;
    }

    /* Better badge spacing on mobile */
    .varS.badge, .varE.badge, .varI.badge, .varR.badge {
      font-size: 0.7rem;
      padding: 0.15rem 0.4rem;
      margin: 0 0.1rem;
    }
  }

  /* Small mobile devices (480px and below) */
  @media (max-width: 480px) {
    .container {
      padding: 0 0.75rem;
    }

    .site-title {
      font-size: 1.25rem;
    }

    .site-subtitle {
      font-size: 0.75rem;
    }

    .description {
      font-size: 0.75rem;
      padding: 0.875rem;
    }

    .card-header {
      padding: 0.875rem;
    }

    .card-header h2 {
      font-size: 0.9rem;
    }

    .card-body {
      padding: 0.875rem;
    }

    #plot-container {
      padding: 1.25rem 0.75rem;
    }

    #plot svg {
      height: 250px;
    }

    .param-group h3 {
      font-size: 0.75rem;
    }

    .params-grid {
      grid-template-columns: 1fr;
    }

    .plot-control label {
      font-size: 0.7rem;
    }

    .show_value {
      font-size: 0.65rem;
      padding: 0.2rem 0.4rem;
      min-width: 35px;
    }

    .info-btn::after {
      width: 160px;
      font-size: 0.6rem;
      padding: 0.4rem 0.6rem;
    }

    .reset-btn {
      padding: 0.5rem 1rem;
      font-size: 0.75rem;
    }

    /* Smaller badges for small mobile devices */
    .varS.badge, .varE.badge, .varI.badge, .varR.badge {
      font-size: 0.6rem;
      padding: 0.1rem 0.3rem;
      margin: 0 0.05rem;
    }
  }

  /* Very small devices (360px and below) */
  @media (max-width: 360px) {
    .container {
      padding: 0 0.5rem;
    }

    .site-title {
      font-size: 1.1rem;
    }

    .site-subtitle {
      font-size: 0.7rem;
    }

    .description {
      font-size: 0.7rem;
      padding: 0.75rem;
    }

    .card-header {
      padding: 0.75rem;
    }

    .card-header h2 {
      font-size: 0.85rem;
    }

    .card-body {
      padding: 0.75rem;
    }

    #plot-container {
      padding: 1rem 0.5rem;
    }

    #plot svg {
      height: 220px;
    }

    .info-btn::after {
      width: 140px;
      font-size: 0.55rem;
    }
  }

  /* Landscape orientation on mobile */
  @media (max-width: 768px) and (orientation: landscape) {
    #plot svg {
      height: 200px;
    }

    .site-header {
      padding: 1rem 0;
      margin-bottom: 1rem;
    }

    .site-title {
      font-size: 1.2rem;
    }

    .site-subtitle {
      font-size: 0.7rem;
    }
  }

  /* ===== Animations ===== */
  @keyframes fadeIn {
    from {
      opacity: 0;
      transform: translateY(15px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  
  .card {
    animation: fadeIn 0.5s ease-out;
  }
  
  /* ===== Print Styles ===== */
  @media print {
    body {
      background: white;
    }
  
    .site-header {
      background: var(--color-primary);
      color: white;
    }
  
    .card {
      box-shadow: none;
      border: 1px solid var(--color-border);
      page-break-inside: avoid;
    }
  }