﻿@media (prefers-color-scheme: dark) {
  /* Base Dark Theme */
  html, body {
    background: linear-gradient(to right, #0f2027, #203a43, #2c5364);
    min-height: 100vh;
    margin: 0;
    padding: 0;
  }
  body {
    font-family: 'Segoe UI', sans-serif;
    margin: 0;
    padding: 0;
    background: black;
    min-height: 100vh;
    text-align: center;
    color: #ddd;
    overscroll-behavior-y: contain;
    transition: background 0.3s, color 0.3s;
  }

  /* Hero Title */
  .hero-title {
    margin-top: 20px;
    font-size: 32px;
    font-weight: 800;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
  }

  /* Controls Container */
  #controls {
    background-color: #222222dd;
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(255, 255, 255, 0.1);
    padding: 15px 10px;
    margin: 20px auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    width: 100%;
    max-width: 900px;
    transition: background-color 0.3s, color 0.3s;
  }

  /* Controls Inputs */
  #controls select,
  #controls button,
  #controls input[type="range"] {
    padding: 8px 12px;
    font-size: 14px;
    border-radius: 6px;
    border: 1px solid #444;
    background: #333;
    color: #ddd;
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
  }

  /* Button Hover */
  #controls button:hover {
    background-color: #1e90ff;
    color: white;
    transform: scale(1.03);
  }

  /* Array Container */
  #array-container {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    height: 420px;
    margin: 20px auto;
    background: #121212;
    border-radius: 12px;
    width: 95%;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.1);
    transition: background 0.3s, box-shadow 0.3s;
  }

  /* Bar Wrapper */
  .bar-wrapper {
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    margin: 0 1px;
    position: relative;
  }

  /* Bars */
  .bar {
    width: 8px;
    border-radius: 4px 4px 0 0;
    transition: height 0.3s ease, background-color 0.3s;
    box-shadow: 0 0 8px rgba(30, 144, 255, 0.9);
  }

  /* Circles */
  .circle {
    width: 26px;
    height: 26px;
    background-color: white;
    border: 2px solid #888;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 6px;
    box-shadow: 0 2px 5px rgba(255, 255, 255, 0.1);
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
    color: black;
  }

  /* Info Bar */
  .info-bar {
    display: flex;
    justify-content: center;
    gap: 40px;
    font-weight: bold;
    font-size: 16px;
    margin-bottom: 10px;
  }

  /* Footer */
  footer {
    margin: 10px auto 8px auto;
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(15, 23, 42, 0.06);
    border-radius: 20px;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
  }

  footer a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
  }

  .footer-version {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    background: rgba(15, 23, 42, 0.05);
    color: #475569;
    border-radius: 999px;
    border: 1px solid rgba(15, 23, 42, 0.06);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
  }

  /* Footer Button */
  #footer-btn {
    padding: 5px 12px;
    background-color: rgba(37, 99, 235, 0.12);
    color: #102b43;
    border: 1px solid rgba(37, 99, 235, 0.14);
    border-radius: 999px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    transition: background-color 0.25s ease, transform 0.2s ease;
  }

  #footer-btn:hover {
    background-color: rgba(37, 99, 235, 0.2);
    transform: translateY(-1px);
  }

  body.night-mode footer {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.14);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.25);
  }

  body.night-mode .footer-version {
    background: rgba(255, 255, 255, 0.08);
    color: #f8fafc;
    border-color: rgba(255, 255, 255, 0.18);
  }

  body.night-mode #footer-btn {
    background-color: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.2);
  }

  body.night-mode #footer-btn:hover {
    background-color: rgba(255, 255, 255, 0.22);
  }

  /* Slider */
  .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #555;
    transition: .4s;
    border-radius: 34px;
  }

  .slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: #ddd;
    transition: .4s;
    border-radius: 50%;
  }

  input:checked + .slider {
    background-color: #1e90ff;
  }

  input:checked + .slider:before {
    transform: translateX(26px);
  }

  /* Loader */
  .lottie-loader {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 10px 0;
  }
} /* <-- This closes the @media block! */

body.night-mode,
body.night-mode html {
  background: linear-gradient(to right, #0f2027, #203a43, #2c5364);
  color: #ddd;
}

body.night-mode #controls {
  background-color: #222222dd;
}

body.night-mode #controls select,
body.night-mode #controls button,
body.night-mode #controls input[type="range"] {
  background: #333;
  color: #ddd;
  border-color: #444;
}

body.night-mode #array-container {
  background: #121212;
}

body.night-mode .hero-title {
  color: #ffffff;
  -webkit-text-fill-color: #ffffff;
}

body.night-mode .circle {
  background-color: white;
  color: black;
}

body.night-mode #algorithm-description {
  background: #23272f;
  color: #ffd700;
  border-color: #1e90ff;
}

html, body {
  background: linear-gradient(180deg, #eff4ff 0%, #f8fafc 100%);
  min-height: 100vh;
  margin: 0;
  padding: 0;
  color: #111827;
  font-family: 'Segoe UI', sans-serif;
  text-align: center;
  overscroll-behavior-y: contain;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
}

* {
  box-sizing: border-box;
}

.page-shell {
  width: min(100%, 1280px);
  padding: 0 16px 32px;
  margin: 0 auto;
}

.hero-section {
  max-width: 720px;
  margin: 0 auto 18px;
  padding: 0 4px;
}

.hero-subtitle {
  margin: 12px auto 0;
  font-size: 1rem;
  color: #475569;
  line-height: 1.7;
  max-width: 720px;
}

.hero-title {
  margin-top: 24px;
  font-size: clamp(2rem, 7vw, 3.2rem);
  font-weight: 900;
  letter-spacing: 0.18em;
  color: #000000;
  -webkit-text-fill-color: #000000;
  -webkit-background-clip: unset;
  text-transform: uppercase;
  text-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
  position: relative;
  z-index: 2;
}

#controls {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(59, 130, 246, 0.16);
  border-radius: 24px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.08);
  padding: 18px 16px;
  margin: 20px auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  width: 100%;
  max-width: 980px;
  backdrop-filter: blur(14px);
}

#controls > * {
  flex: 1 1 160px;
  min-width: 140px;
}

#controls select,
#controls button,
#controls input[type="range"] {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: white;
  color: #111827;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
  transition: background-color 0.25s ease, color 0.25s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

#controls button {
  background: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
  color: #ffffff;
  border: none;
  min-width: 110px;
  font-weight: 700;
}

#controls button:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 28px rgba(37, 99, 235, 0.22);
}

#controls label {
  color: #475569;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: space-between;
  width: 100%;
}

#controls input[type="range"] {
  accent-color: #2563eb;
  width: 100%;
}

#array-container {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: clamp(280px, 34vh, 430px);
  margin: 20px auto;
  background: linear-gradient(180deg, #f8fbff 0%, #e2eaf8 100%);
  border-radius: 24px;
  width: 100%;
  max-width: 980px;
  overflow: hidden;
  padding: 10px 6px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.12);
}

.bar {
  width: 10px;
  border-radius: 6px 6px 0 0;
  transition: height 0.3s ease, background-color 0.3s;
  box-shadow: 0 0 18px rgba(37, 99, 235, 0.18);
}

.circle {
  width: 30px;
  height: 30px;
  background-color: white;
  border: 2px solid rgba(15, 23, 42, 0.12);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
  transition: background-color 0.3s, color 0.3s, border-color 0.3s;
  color: #111827;
}

#algorithm-description {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 16px;
  color: #1e293b;
  border: 1px solid rgba(37, 99, 235, 0.2);
  padding: 18px 24px;
  margin: 20px auto 16px auto;
  max-width: 860px;
  font-size: 17px;
  font-weight: 600;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.08);
  text-align: center;
  letter-spacing: 0.01em;
  transition: background 0.3s, color 0.3s, border-color 0.3s;
}

#code-examples {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: 20px;
  padding: 24px;
  margin: 24px auto;
  width: 100%;
  max-width: 980px;
  text-align: left;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.08);
}

#code-examples h2 {
  margin-bottom: 10px;
  color: #0f172a;
  font-size: clamp(1.6rem, 3vw, 2rem);
}

#code-examples p {
  margin-bottom: 18px;
  color: #475569;
  max-width: 760px;
}

.code-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
  justify-content: center;
}

.code-tabs .tab {
  flex: 0 1 auto;
  min-width: 110px;
  border: 1px solid rgba(37, 99, 235, 0.25);
  background: rgba(255, 255, 255, 0.9);
  color: #1e293b;
  padding: 12px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
  font-weight: 700;
}

.code-tabs .tab:hover {
  transform: translateY(-1px);
}

.code-tabs .tab.active {
  background: #2563eb;
  color: white;
  border-color: #2563eb;
}

.code-block pre {
  background: #0f172a;
  color: #f8fafc;
  padding: 20px;
  border-radius: 18px;
  overflow-x: auto;
  border: 1px solid rgba(148, 163, 184, 0.18);
  font-size: 13px;
  line-height: 1.6;
  box-shadow: inset 0 0 30px rgba(15, 23, 42, 0.12);
}

.code-block code {
  font-family: 'Courier New', Courier, monospace;
  white-space: pre;
}

@media (min-width: 900px) {
  #controls > * {
    flex: 1 1 180px;
  }

  #controls {
    justify-content: space-between;
  }

  .hero-section {
    padding: 0;
  }

  #array-container {
    height: clamp(360px, 40vh, 520px);
    padding: 18px 10px;
  }

  .bar {
    width: min(22px, 2vw);
  }

  .circle {
    width: 36px;
    height: 36px;
    font-size: 13px;
    margin-bottom: 10px;
  }

  .code-tabs {
    justify-content: flex-start;
  }
}

@media (max-width: 860px) {
  #controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(140px, 1fr));
    gap: 14px;
  }

  #controls > * {
    min-width: 0;
    width: 100%;
  }

  #controls select {
    grid-column: 1;
  }

  #controls button:nth-of-type(1) {
    grid-column: 2;
  }

  #controls button:nth-of-type(2) {
    grid-column: 1;
  }

  #controls button:nth-of-type(3) {
    grid-column: 2;
  }

  #controls button:nth-of-type(4) {
    grid-column: 1;
  }

  #controls button:nth-of-type(5) {
    grid-column: 2;
  }

  #controls label:nth-of-type(1) {
    grid-column: 1;
  }

  #controls label:nth-of-type(2) {
    grid-column: 2;
  }
}

