:root {
  --dark-navy: #0a1628;
  --navy: #1a2332;
  --light-navy: #1e3a5f;
  --cyan: #00d9ff;
  --purple: #6366f1;
  --white: #ffffff;
  --green: #28a745;
  --red: #dc3545;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", sans-serif;
  background-color: var(--dark-navy);
  color: var(--white);
}

/* ===== Header ===== */
header {
  background: var(--dark-navy);
  color: var(--cyan);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 30px;
  border-bottom: 2px solid var(--cyan);
}

.header-left {
  width: 100px;
}

.title {
  flex-grow: 1;
  text-align: center;
  font-size: 2em;
  font-weight: 600;
  color: var(--cyan);
}

.header-right {
  width: 100px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.ptu-logo {
  height: 80px;
  width: auto;
  transition: transform 0.3s ease;
}

.ptu-logo:hover {
  transform: scale(1.05);
}

/* ===== Navigation ===== */
nav {
  background: var(--navy);
  padding: 0;
  text-align: center;
  border-bottom: 1px solid var(--light-navy);
}

nav a {
  color: white;
  padding: 15px 25px;
  text-decoration: none;
  display: inline-block;
  transition: all 0.3s;
  border-bottom: 3px solid transparent;
}

nav a:hover {
  background: var(--light-navy);
  border-bottom-color: var(--cyan);
}

nav a.active {
  background: var(--purple);
  border-bottom-color: var(--cyan);
}

/* ===== Sections ===== */
section {
  display: none;
  max-width: 1400px;
  margin: 20px auto;
  padding: 30px;
  background-color: var(--navy);
  border-radius: 10px;
  margin-bottom: 20px;
  border: 1px solid var(--light-navy);
}

section.active {
  display: block;
}

section h2 {
  color: var(--cyan);
  border-bottom: 2px solid var(--cyan);
  padding-bottom: 10px;
  margin-bottom: 20px;
}

section h3 {
  color: var(--cyan);
  margin-top: 20px;
}

section p,
section li {
  line-height: 1.8;
  color: #e0e0e0;
}

/* ===== Controls Grid ===== */
.controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  max-width: 900px;
  margin: auto;
}

@media (max-width: 800px) {
  .controls {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 500px) {
  .controls {
    grid-template-columns: 1fr;
  }
  .ptu-logo {
    height: 60px;
  }
  .title {
    font-size: 1.5em;
  }
}

.control-box {
  background: var(--navy);
  border: 2px solid var(--cyan);
  border-radius: 8px;
  padding: 20px 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.control-box label {
  font-weight: bold;
  color: var(--cyan);
  margin-bottom: 10px;
}

.control-box input[type="range"] {
  width: 100%;
  max-width: 200px;
  accent-color: var(--cyan);
  cursor: pointer;
}

.control-box select {
  width: 100%;
  max-width: 200px;
  padding: 8px 10px;
  border: 1px solid var(--cyan);
  border-radius: 6px;
  text-align: center;
  background: var(--dark-navy);
  color: var(--white);
}

.value-display {
  margin-top: 8px;
  font-weight: bold;
  color: var(--cyan);
  font-size: 14px;
}

.unit-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  margin-top: 6px;
}

.unit-row select {
  padding: 4px 8px;
  border: 1px solid var(--cyan);
  border-radius: 6px;
  background: var(--dark-navy);
  color: var(--white);
  font-size: 13px;
}

#simulateBtn {
  margin-top: 15px;
  padding: 12px 25px;
  background: var(--purple);
  color: white;
  font-weight: bold;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s;
}

#simulateBtn:hover {
  background: var(--cyan);
  color: var(--dark-navy);
}

/* ===== Channel ===== */
.channel {
  background: var(--navy);
  border: 2px solid var(--cyan);
  padding: 15px;
  border-radius: 10px;
  margin-top: 25px;
}

.channel-header button {
  padding: 8px 16px;
  border: 2px solid var(--cyan);
  background: var(--dark-navy);
  color: var(--white);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s;
  margin: 0 5px;
}

.channel-header button:hover {
  background: var(--light-navy);
}

.channel-header button.active {
  background: var(--purple);
  color: white;
  border-color: var(--cyan);
}

.plot-wrapper {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 15px;
  align-items: start;
  width: 100%;
  overflow: hidden;
  margin-top: 10px;
}

.plot-container {
  min-width: 0;
  width: 100%;
  overflow: hidden;
}

.quantization-levels-box {
  width: 200px;
  flex-shrink: 0;
  background: var(--dark-navy);
  border: 2px solid var(--cyan);
  border-radius: 8px;
  padding: 15px;
  max-height: 420px;
  overflow-y: auto;
  display: none;
}

.quantization-levels-box.visible {
  display: block;
}

/* ===== Quiz ===== */
.quiz-container {
  max-width: 900px;
  margin: 0 auto;
}

.question-card {
  background: var(--navy);
  border: 2px solid var(--cyan);
  border-radius: 10px;
  padding: 25px;
  margin-bottom: 25px;
}

.question-number {
  color: var(--cyan);
  font-weight: bold;
  font-size: 1.1em;
  margin-bottom: 15px;
}

.question-text {
  font-size: 1.05em;
  color: #e0e0e0;
  margin-bottom: 20px;
  line-height: 1.6;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.option {
  display: flex;
  align-items: center;
  padding: 15px;
  border: 2px solid var(--light-navy);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  background: var(--dark-navy);
  color: var(--white);
}

.option:hover {
  border-color: var(--cyan);
  background: var(--light-navy);
}

.option input[type="radio"] {
  margin-right: 12px;
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--cyan);
}

.option label {
  cursor: pointer;
  flex: 1;
  font-size: 1em;
  color: var(--white);
}

.option.correct {
  border-color: var(--green);
  background: #d4edda;
}

.option.incorrect {
  border-color: var(--red);
  background: #f8d7da;
}

.feedback {
  margin-top: 15px;
  padding: 15px;
  border-radius: 8px;
  display: none;
  line-height: 1.6;
}

.feedback.show {
  display: block;
}

.feedback.correct {
  background: #d4edda;
  border: 2px solid var(--green);
  color: #155724;
}

.feedback.incorrect {
  background: #f8d7da;
  border: 2px solid var(--red);
  color: #721c24;
}

.feedback strong {
  display: block;
  margin-bottom: 8px;
}

.submit-quiz {
  text-align: center;
  margin: 30px 0;
}

.submit-quiz button {
  padding: 15px 40px;
  background: var(--purple);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1.1em;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.3s;
}

.submit-quiz button:hover {
  background: var(--cyan);
  color: var(--dark-navy);
}

.submit-quiz button:disabled {
  background: #555;
  cursor: not-allowed;
}

.quiz-result {
  background: var(--navy);
  border: 3px solid var(--cyan);
  border-radius: 10px;
  padding: 30px;
  margin: 30px auto;
  max-width: 600px;
  text-align: center;
  display: none;
}

.quiz-result.show {
  display: block;
}

.quiz-result h3 {
  color: var(--cyan);
  font-size: 1.8em;
  margin-bottom: 20px;
}

.score-display {
  font-size: 3em;
  font-weight: bold;
  color: var(--cyan);
  margin: 20px 0;
}

.result-message {
  font-size: 1.2em;
  margin: 20px 0;
  color: #e0e0e0;
}

.retry-button {
  margin-top: 20px;
  padding: 12px 30px;
  background: var(--purple);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1em;
  font-weight: bold;
  cursor: pointer;
}

.retry-button:hover {
  background: var(--cyan);
  color: var(--dark-navy);
}

/* ===== Floating Help Bulb ===== */
#helpBtn {
  position: fixed;
  bottom: 25px;
  right: 25px;
  width: 60px;
  height: 60px;
  background: var(--purple);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  cursor: pointer;
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.5);
  transition: all 0.3s ease;
  z-index: 999;
}

#helpBtn:hover {
  background: var(--cyan);
  color: var(--dark-navy);
  box-shadow: 0 0 25px var(--cyan);
  transform: scale(1.1);
}

#helpPopup {
  position: fixed;
  bottom: 100px;
  right: 25px;
  width: 320px;
  background: var(--navy);
  border: 2px solid var(--cyan);
  border-radius: 10px;
  padding: 15px;
  display: none;
  z-index: 1000;
  box-shadow: 0 0 20px rgba(0, 217, 255, 0.3);
}

.help-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  color: var(--cyan);
  font-weight: bold;
}

#closeHelp {
  background: none;
  border: none;
  color: var(--white);
  font-size: 16px;
  cursor: pointer;
}

.help-section {
  margin-bottom: 12px;
  font-size: 14px;
  color: #e0e0e0;
}

.preset-btn {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 6px;
  background: var(--purple);
  border: none;
  border-radius: 6px;
  color: white;
  cursor: pointer;
  transition: 0.3s;
}

.preset-btn:hover {
  background: var(--cyan);
  color: var(--dark-navy);
}

/* ===== Procedure Cards ===== */
.proc-card {
  display: grid;
  grid-template-columns: 1fr 480px;
  gap: 24px;
  align-items: center;
  background: var(--dark-navy);
  border: 2px solid var(--cyan);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
}

@media (max-width: 820px) {
  .proc-card {
    grid-template-columns: 1fr;
  }
}

.proc-step-text {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.proc-step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--purple);
  color: white;
  font-weight: bold;
  font-size: 1em;
  flex-shrink: 0;
}

.proc-step-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.proc-step-title {
  color: var(--cyan);
  font-size: 1.1em;
  font-weight: 600;
}

.proc-step-desc {
  color: #e0e0e0;
  line-height: 1.7;
  font-size: 0.97em;
  padding-left: 48px;
}

.proc-step-desc ul {
  margin: 8px 0 0 0;
  padding-left: 18px;
}

.proc-step-desc li {
  margin-bottom: 4px;
}

.proc-video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--navy);
  border: 2px dashed var(--cyan);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
}

.proc-video-wrap video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}

.proc-video-wrap-full video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}

.proc-video-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--cyan);
  opacity: 0.7;
  pointer-events: none;
}

.proc-video-placeholder svg {
  width: 40px;
  height: 40px;
}

.proc-video-placeholder span {
  font-size: 0.82em;
  text-align: center;
}

.proc-video-label {
  position: absolute;
  bottom: 6px;
  right: 8px;
  font-size: 0.72em;
  color: var(--cyan);
  opacity: 0.5;
  pointer-events: none;
}

.proc-video-wrap video[src] { display: block; }
.proc-video-wrap video[src] ~ .proc-video-placeholder { display: none; }
.proc-video-wrap video[src] ~ .proc-video-label { display: none; }
.proc-video-wrap-full video[src] { display: block; }
.proc-video-wrap-full video[src] ~ .proc-video-placeholder { display: none; }

.proc-card-full {
  background: var(--dark-navy);
  border: 2px solid var(--cyan);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
  width: 100%;
  box-sizing: border-box;
  display: block;
}

.proc-card-full .proc-step-header {
  margin-bottom: 14px;
}

.proc-card-full .proc-step-desc {
  padding-left: 0;
  margin-bottom: 18px;
}

.proc-video-wrap-full {
  position: relative;
  width: 100%;
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
  aspect-ratio: 16/9;
  background: var(--navy);
  border: 2px dashed var(--cyan);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
}

.proc-video-wrap-full video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
  display: none;
}

/* ===== Footer ===== */
footer {
  background: var(--dark-navy);
  color: var(--cyan);
  text-align: center;
  padding: 15px;
  border-top: 2px solid var(--cyan);
}