:root {
  --accent-color: #2f855a; /* spring green */
  --accent-color-dark: #276749;
  --callout-bg-color: #d1fae5;
  --callout-border-color: var(--accent-color);
  --challenge-bg-color: #fffbeb;
  --challenge-border-color: #ecc94b;
  --button-bg-color: var(--accent-color);
  --button-hover-bg-color: var(--accent-color-dark);
  --cancel-color: #e53e3e;
  --cancel-hover-color: #c53030;
  --heading-font: "Georgia", "Times New Roman", serif;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
    Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  line-height: 1.6;
  color: #111;
  background-color: #fff;
  max-width: 100%;
  margin: 0 auto;
  padding: 0;
}

a {
  color: var(--accent-color);
}

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--heading-font);
  font-weight: 400;
}

.layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

header,
main,
footer {
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

header {
  border-bottom: 1px solid #ccc;
  margin-bottom: 0; /* Changed from 20px to 0 */
  padding-bottom: 10px;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  width: 100%;
}

.header-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-weight: bold;
}

.header-title-content {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.header-title-text {
  white-space: nowrap;
}

#header-spinner-root {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  margin-right: 12px;
  min-width: 20px;
  min-height: 20px;
}

#header-spinner-root:empty {
  margin-right: 0;
  min-width: 0;
  min-height: 0;
}

.header-search-button {
  background: none;
  border: none;
  padding: 4px;
  border-radius: 9999px;
  color: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
}

.header-search-button svg {
  width: 16px;
  height: 16px;
  display: block;
}

.header-search-button:hover:not(:disabled),
.header-search-button:focus-visible {
  background-color: rgba(0, 0, 0, 0.08);
  outline: none;
}

.header-search-button:focus-visible {
  box-shadow: 0 0 0 2px rgba(47, 133, 90, 0.4);
}

.header-search-button:disabled {
  opacity: 0.5;
  cursor: default;
}

.header-links {
  display: flex;
  gap: 10px;
}

.text-logo {
  font-family: monospace;
  font-size: 1.5rem;
  font-weight: bold;
  letter-spacing: 0.1em;
  color: #111;
}

/* Small spinner shown next to the logo while examples load */
.header-spinner {
  width: 20px;
  height: 20px;
  margin-right: 8px;
  border: 3px solid #111;
  border-top-color: var(--accent-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

a.text-logo {
  text-decoration: none;
}

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

h1 {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

h2 {
  font-size: 2rem;
  margin: 0 0 1rem;
}

/* Dropdown Navigation */
.dropdown-nav {
  position: relative;
  display: inline-block;
  /* No bottom margin so the navigation aligns with the logo */
}

.dropdown-content {
  display: none;
  position: absolute;
  background-color: #fff;
  min-width: 160px;
  box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.1);
  z-index: 200;
  border-radius: 4px;
}

.dropdown-wide {
  min-width: 250px;
}

/* Extra wide dropdown for long example titles */
.dropdown-extra-wide {
  min-width: 320px;
}

.dropdown-content a {
  color: #111;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
}

.dropdown-content a:hover {
  background-color: #e0e0e0;
}

.dropdown-nav:hover .dropdown-content {
  display: block;
}

.dropdown-nav:hover .dropdown-button {
  background-color: var(--button-hover-bg-color);
  color: #fff;
}

/* Base styles for dropdown buttons */
.dropdown-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  height: 38px;
  padding: 0 12px;
  font-family: inherit;
  font-size: 1rem;
  text-align: center;
  border-radius: 4px;
  color: #fff;
  vertical-align: middle;
  border: 1px solid var(--accent-color-dark);
  background-color: var(--button-bg-color);
  cursor: pointer;
}

/* Reset button styles to ensure consistent appearance */
button.dropdown-button {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  margin: 0;
  outline: none;
}

/* Style for anchor tags with dropdown-button class */
a.dropdown-button {
  text-decoration: none;
  color: #fff;
}

main {
  flex: 1;
}

footer {
  margin-top: 40px;
  border-top: 1px solid #ccc;
  padding-top: 10px;
  font-size: 0.9em;
  color: #666;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

footer .footer-left {
  text-align: left;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  h1 {
    font-size: 1.8rem;
  }

  h2 {
    font-size: 1.5rem;
  }
}

/* Mobile responsiveness for example cards */
@media (max-width: 480px) {
  .example-card {
    min-width: 130px; /* Slightly smaller on very small screens */
    padding: 12px;
  }

  .example-card h4 {
    font-size: 1rem;
  }

  .example-card p {
    font-size: 0.8rem;
  }
}

/* Mobile responsiveness for footer */
@media (max-width: 480px) {
  footer {
    flex-direction: column;
    text-align: center;
  }

  footer .footer-left {
    margin-bottom: 10px;
  }
}

/* Chapter Navigation Styles */
.chapter-nav {
  display: flex;
  justify-content: space-between;
  margin: 20px 0;
  padding: 10px 0;
}

.chapter-nav-top {
  border-bottom: 1px solid #ccc;
  margin-bottom: 30px;
}

.chapter-nav-bottom {
  margin-top: 30px;
}

body.editor-expanded .chapter-nav-bottom {
  display: none;
}

.chapter-nav-button {
  background-color: var(--button-bg-color);
  color: #fff;
  padding: 6px 10px;
  border: 1px solid var(--accent-color-dark);
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  font-size: 0.85rem;
  transition:
    background-color 0.2s,
    box-shadow 0.2s;
}

.chapter-nav-button:hover {
  background-color: var(--button-hover-bg-color);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.chapter-nav-button.disabled {
  background-color: #f5f5f5;
  color: #aaa;
  cursor: not-allowed;
  pointer-events: none;
  box-shadow: none;
  border: 1px solid #ccc;
}

.prev-chapter {
  text-align: left;
}

.next-chapter {
  text-align: right;
}

/* Example navigation reuses chapter styles */
.example-nav {
  margin-top: 30px;
}

/* Mobile responsiveness for chapter navigation */
@media (max-width: 768px) {
  .chapter-nav {
    flex-direction: column;
    gap: 10px;
  }

  .chapter-nav-button {
    width: 100%;
    text-align: center;
  }
}

/* Adjust navigation for very small screens */
@media (max-width: 480px) {
  .chapter-nav {
    margin: 15px 0;
    padding: 8px 0;
  }

  .chapter-nav-button {
    padding: 5px 8px;
    font-size: 0.8rem;
  }
}

/* Visual indicator for horizontal scrolling */
.example-selector-container {
  position: relative; /* Container for positioning the fixed indicator */
}

.example-selector-container::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: 20px;
  background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.8));
  pointer-events: none;
  z-index: 2; /* Higher z-index to ensure it's above the scrolling content */
}

/* Card Component */
.card {
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 20px;
  margin: 20px 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  transition: box-shadow 0.3s ease;
}

.card:hover {
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.card-title {
  font-size: 1.5rem;
  margin-top: 0;
  margin-bottom: 10px;
}

.card-description {
  margin-bottom: 15px;
}

.example-level {
  margin-bottom: 15px;
}

.difficulty-chip {
  display: inline-block;
  border-radius: 16px;
  padding: 2px 8px;
  font-size: 0.8rem;
  color: #fff;
}

.difficulty-beginner {
  background-color: var(--accent-color);
}

.difficulty-intermediate {
  background-color: #ed8936;
}

.difficulty-advanced {
  background-color: var(--cancel-color);
}

.difficulty-local {
  background-color: #718096;
}

.card-link {
  display: inline-block;
  color: var(--accent-color);
  text-decoration: none;
  font-weight: 500;
}

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

.delete-link {
  color: var(--cancel-color);
  margin-left: 10px;
}

.delete-link:hover {
  color: var(--cancel-hover-color);
  text-decoration: underline;
}

/* ExampleCard styles */
.example-meta {
  list-style: none;
  padding-left: 0;
  margin-bottom: 15px;
}

.example-meta li {
  margin-bottom: 3px;
}

.example-card-actions {
  display: flex;
  align-items: center;
}

.actions-right {
  margin-left: auto;
  display: flex;
  align-items: center;
}

.fork-link {
  margin-left: 10px;
  padding: 4px 8px;
  border: 1px solid var(--accent-color-dark);
  border-radius: 4px;
}

.view-link {
  margin-left: 10px;
  padding: 4px 8px;
  border: 1px solid var(--accent-color-dark);
  border-radius: 4px;
}

/* Ensure consistent button heights in example cards */
.example-card-actions .run-button {
  padding: 4px 8px;
  line-height: 1.6;
}

/* Mini example card */
.example-mini-card {
  padding: 10px;
  margin: 10px 0;
}

.example-mini-card .card-title {
  font-size: 1.2rem;
  margin-bottom: 5px;
}

.example-mini-card .card-description {
  font-size: 0.9rem;
  margin-bottom: 5px;
}

.example-detail-card code {
  background-color: #f5f5f5;
  padding: 2px 4px;
  border-radius: 3px;
  font-size: 1em;
}

.callout {
  margin-top: 20px;
  padding: 15px;
  background-color: var(--callout-bg-color);
  border-left: 4px solid var(--callout-border-color);
}

blockquote {
  margin: 1em 0;
  padding: 0.5em 1em;
  background-color: #f5f5f5;
  border-left: 4px solid #ccc;
}

/* Message displayed when JavaScript is disabled */
.noscript-warning {
  margin: 10px 0;
  padding: 10px;
  background-color: #ffebeb;
  border-left: 4px solid var(--cancel-color);
}

/* Introductory section on the home page */
.intro {
  margin-bottom: 15px;
  background-color: #fff;
}

.toggle-info-link {
  margin-top: 10px;
  display: inline-block;
}

.toggle-chapters {
  margin: 10px 0;
}


.no-top-margin {
  margin-top: 0;
}

.no-bottom-margin {
  margin-bottom: 0;
}

/* Challenge Box */
.challenge-box {
  background-color: var(--challenge-bg-color);
  border-left-color: var(--challenge-border-color);
}

/* Glossary Styles */
.glossary-section {
  margin-bottom: 40px;
}

.section-title {
  font-size: 1.5rem;
  color: #111;
  margin-top: 30px;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--accent-color);
  cursor: pointer;
}

.glossary-terms {
  margin-top: 20px;
}

/* Grid layout for example cards on the examples page */
.example-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.glossary-term {
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 1px solid #ccc;
}

.glossary-term h4 {
  font-size: 1.3rem;
  margin-bottom: 10px;
  color: #111;
}

.term-description {
  margin-bottom: 15px;
}

.term-examples {
  margin-top: 10px;
  font-style: italic;
  color: #111;
  padding-left: 15px;
  border-left: 3px solid var(--accent-color);
}

/* Search Styles */
.search-container {
  margin: 20px 0;
  position: sticky;
  top: 0;
  background-color: #fff;
  padding: 10px 0;
  z-index: 100;
  border-bottom: 1px solid #ccc;
}

.search-input {
  width: 100%;
  padding: 10px;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-sizing: border-box;
  margin-bottom: 1rem;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(0, 150, 136, 0.2);
}

/* Highlight matches */
.highlight {
  background-color: #ffeb3b;
  padding: 2px 0;
}

/* Tag Cloud */
.tag-cloud {
  margin-bottom: 1rem;
}

.tag-cloud .tag,
.example-tags .tag {
  display: inline-block;
  background-color: #f5f5f5;
  border: 1px solid #ccc;
  border-radius: 16px;
  padding: 2px 8px;
  margin: 2px;
  font-size: 0.8rem;
  text-decoration: none;
}

.tag-cloud .tag {
  cursor: pointer;
}

.tag-cloud .tag.selected {
  background-color: var(--accent-color);
  border-color: var(--accent-color);
  color: #fff;
}

.tag-cloud .tag.hidden {
  display: none;
}

/* Accordion Styles */
details {
  margin-bottom: 20px;
}

details summary {
  list-style: none;
  transition: margin 0.3s ease;
}

details summary::-webkit-details-marker {
  display: none;
}

details summary::before {
  content: "▶";
  display: inline-block;
  margin-right: 10px;
  transition: transform 0.3s ease;
}

details[open] summary::before {
  transform: rotate(90deg);
}

details[open] summary {
  margin-bottom: 10px;
}

/* SimPy Playground Styles */
.simpy-playground {
  margin-top: 20px;
}

.simpy-playground .section {
  margin-bottom: 30px;
  padding: 20px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background-color: #fff;
}

.simpy-playground h2 {
  margin-top: 0;
  margin-bottom: 15px;
  color: #111;
  font-size: 1.5rem;
}

.sim-params-form {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 15px;
}

.param-group {
  margin-bottom: 15px;
}

.param-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
}

.param-group input {
  width: 100%;
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1rem;
}

#sim-code-editor {
  width: 100%;
  font-family: monospace;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background-color: #fff;
  font-size: 0.9rem;
  line-height: 1.4;
  resize: vertical;
}

.simulation-controls {
  display: flex;
  gap: 10px;
  margin-top: 15px;
}

.run-button,
.cancel-button {
  padding: 8px 16px;
  border-radius: 4px;
  font-size: 1rem;
  cursor: pointer;
  border: none;
}

.mt-10 {
  margin-top: 10px;
}

.loading-indicator {
  margin-left: 10px;
  font-style: italic;
}

.clickable {
  cursor: pointer;
}

.run-button {
  background-color: var(--button-bg-color);
  color: #fff;
  border: 1px solid var(--accent-color-dark);
}

a.run-button {
  text-decoration: none;
  color: #fff;
  display: inline-block;
}

.run-button:hover {
  background-color: var(--button-hover-bg-color);
}

.run-button:disabled {
  background-color: #a0d5c2;
  cursor: not-allowed;
}

.cancel-button {
  background-color: var(--cancel-color);
  color: #fff;
  border: 1px solid var(--cancel-hover-color);
}

.cancel-button:hover {
  background-color: var(--cancel-hover-color);
}

.cancel-button:disabled {
  background-color: #f8d7da;
  cursor: not-allowed;
}

.counter-button {
  background-color: var(--button-bg-color);
  color: #fff;
  border: 1px solid var(--accent-color-dark);
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  margin-right: 6px;
}

.counter-button:hover {
  background-color: var(--button-hover-bg-color);
}
/* Progress bar styling */

.progress-container {
  margin: 15px 0;
  display: block;
  width: 100%;
}

.progress-container.compact {
  margin: 8px 0;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
  font-weight: 500;
}

.progress-container.compact .progress-label {
  font-size: 0.9em;
  margin-bottom: 3px;
}

.progress-range {
  width: 100%;
  height: 12px;
  background-color: #e0e0e0;
  border: 1px solid #ccc;
  border-radius: 6px;
  overflow: hidden;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  background-image: linear-gradient(to right, #4dd0e1, var(--accent-color));
  background-size: var(--progress) 100%;
  background-repeat: no-repeat;
}

.progress-range::-webkit-slider-runnable-track {
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
}

.progress-range::-moz-range-track {
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
}

.progress-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-color);
  border: 2px solid #fff;
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
  position: relative;
  top: 50%;
  transform: translateY(-50%);
}

.progress-range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-color);
  border: 2px solid #fff;
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}

.log-output {
  margin-top: 15px;
  max-height: 200px;
  overflow-y: auto;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background-color: #fff;
  font-family: monospace;
  font-size: 0.9rem;
  color: #111;
}

/* Ensure log-output in expanded mode can show at least 3 messages */
.simpy-playground.expanded .log-output {
  color: #111;
  min-height: 120px;
  max-height: none;
  margin-bottom: 15px;
}

.log-entry {
  background-color: #fff;
  border-left: 4px solid transparent;
  margin-bottom: 5px;
  padding: 5px;
  border-radius: 3px;
}

.log-entry.info {
  border-left-color: var(--accent-color-dark);
  color: var(--accent-color-dark);
}

.log-entry.probe {
  border-left-color: #33691e;
  color: #33691e;
}

.log-entry.success {
  border-left-color: #1b5e20;
  color: #1b5e20;
}

.log-entry.error {
  border-left-color: #b71c1c;
  color: #b71c1c;
}

.results-panel {
  margin-top: 20px;
  padding: 15px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background-color: #fff;
}

.results-panel h3 {
  margin-top: 0;
  margin-bottom: 10px;
  color: #111;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
}

.results-table th,
.results-table td {
  padding: 8px;
  text-align: left;
  border-bottom: 1px solid #ccc;
}

.results-table th {
  font-weight: 600;
  background-color: #f5f5f5;
}

.results-table tr:last-child td {
  border-bottom: none;
}

.intro-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid #ccc;
  margin-top: 1rem;
}

.intro-table th,
.intro-table td {
  padding: 12px;
  text-align: left;
  border: 1px solid #ccc;
}

.intro-table th {
  background-color: #f5f5f5;
  font-weight: 600;
}

/* Pretty printed JSON inside results tables */
.json-pretty {
  white-space: pre-wrap;
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  background-color: #fff;
  padding: 4px;
  border-radius: 3px;
  margin: 0;
}

.chart-stats-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

.chart-stats-table th,
.chart-stats-table td {
  padding: 4px 8px;
  text-align: left;
  border-bottom: 1px solid #ccc;
}

.chart-stats-table th {
  background-color: #f5f5f5;
  font-weight: 600;
}

.chart-stats-table tr:last-child td {
  border-bottom: none;
}

/* Tabs for the output section */
.output-tabs {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.output-tabs button {
  padding: 6px 12px;
  font-size: 0.9rem;
  border: 1px solid var(--accent-color-dark);
  background-color: #f0f0f0;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.output-tabs button:hover {
  background-color: #e0e0e0;
}

.output-tabs button.active {
  background-color: var(--button-bg-color);
  color: #fff;
}

/* Run history selector */
.run-history-select {
  display: flex;
  align-items: center;
  gap: 6px;
}

.run-history-select select {
  padding: 4px 8px;
  font-size: 0.9rem;
}

/* Comparison selector in chart modal */
.comparison-select {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 1rem;
}

.comparison-select select {
  padding: 4px 8px;
  font-size: 0.9rem;
}

/* Chip-style section titles */
.section-chip {
  display: inline-block;
  padding: 4px 12px;
  margin-bottom: 15px;
  border-radius: 16px;
  background-color: #f0f0f0;
  color: #111;
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.5px;
}

.autosave-chip {
  background-color: #e0f7fa;
  color: #0277bd;
}

/* Playground textarea styling */
.playground-textarea {
  width: 100%;
  font-family: monospace;
  padding: 0;
  border: 1px solid #ccc;
  border-radius: 4px;
  background-color: #fff;
  font-size: 0.9rem;
  line-height: 1.4;
  resize: vertical;
  box-sizing: border-box;
}

/* Example selector styling */
.example-selector-container {
  position: relative; /* Container for positioning the fixed indicator */
  margin-bottom: 20px;
}

.example-selector {
  display: flex;
  /* Prevent wrapping on small screens */
  overflow-x: auto; /* Enable horizontal scrolling */
  gap: 15px;
  padding: 10px 5px; /* Spacing improves scrolling appearance */
  scrollbar-width: thin; /* For Firefox */
}

.example-card {
  flex: 0 0 auto;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 15px;
  background-color: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  min-width: 150px;
  max-width: 200px; /* Prevent cards from becoming too wide */
}

.example-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.example-card.selected {
  border-color: var(--accent-color);
  background-color: #e6f2ff;
}

.example-card h4 {
  margin: 0 0 5px 0;
  font-size: 1.1rem;
  color: #111;
}

.example-card p {
  margin: 0;
  font-size: 0.9rem;
  color: #666;
}

/* Toggle expand button */
/* Code section header styling */
.code-section-header {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  gap: 10px;
}

.code-section-header .section-chip {
  margin-bottom: 0;
}

.code-section-header .section-info {
  font-size: 14px;
  color: #666;
  flex: 1;
}

.fork-button {
  margin-left: 10px;
  padding: 6px 12px;
  background-color: var(--button-bg-color);
  border: 1px solid var(--accent-color-dark);
  border-radius: 4px;
  font-size: 0.9rem;
  color: #fff;
  cursor: pointer;
  transition: background-color 0.2s;
  align-self: center;
}

.cheatsheet-button {
  margin-left: 10px;
  padding: 6px 12px;
  background-color: var(--button-bg-color);
  border: 1px solid var(--accent-color-dark);
  border-radius: 4px;
  font-size: 0.9rem;
  color: #fff;
  cursor: pointer;
  transition: background-color 0.2s;
  align-self: center;
}

.cheatsheet-button:hover {
  background-color: var(--button-hover-bg-color);
}

.cheatsheet-button:focus {
  outline: 2px solid var(--accent-color);
}

.fork-button:hover {
  background-color: var(--button-hover-bg-color);
}

.fork-button:focus {
  outline: 2px solid var(--accent-color);
}

/* Parameters panel header in expanded mode */
.simpy-playground.expanded .section .code-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0;
}

/* Expanded editor layout */
.simpy-playground.expanded {
  position: fixed;
  top: 60px;
  left: 0;
  width: 100vw;
  height: calc(100vh - 60px); /* Fill remaining viewport height */
  z-index: 9999;
  background-color: #fff;
  display: grid;
  grid-template-columns: var(--editor-column, 65fr) 5px var(
      --sidebar-column,
      35fr
    );
  grid-template-rows: 1fr;
  grid-gap: 12px;
  padding: 16px;
  box-sizing: border-box;
  overflow: hidden;
  margin: 0;
}

.simpy-playground.expanded .grid-resizer {
  width: 8px;
  height: 100%;
  cursor: col-resize;
  position: relative;
  background-color: transparent;
}

.simpy-playground.expanded .grid-resizer::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 4px;
  height: 40px;
  background-color: #ddd;
  border-radius: 2px;
}

.simpy-playground.expanded .row-resizer {
  height: 8px;
  width: 100%;
  cursor: row-resize;
  position: relative;
  background-color: transparent;
}

.simpy-playground.expanded .row-resizer::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 4px;
  background-color: #ddd;
  border-radius: 2px;
}

.simpy-playground.expanded.resizing,
.simpy-playground.expanded.resizing .grid-resizer {
  cursor: col-resize;
}

.simpy-playground.expanded.row-resizing,
.simpy-playground.expanded.row-resizing .row-resizer {
  cursor: row-resize;
}

/* Hide header and footer when editor is expanded */
body.editor-expanded footer {
  display: none !important;
}

body.editor-expanded header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  max-width: none;
  margin: 0;
  z-index: 10000;
}

/* Override main display for expanded editor */
body.editor-expanded .layout > main {
  padding: 0;
  margin: 0;
}

/* Shared layout classes for both modes */
.playground-content {
  display: flex;
  flex-direction: column;
}

.playground-content.sidebar {
  display: grid;
  grid-template-rows: minmax(300px, 1fr) minmax(400px, 2fr);
  grid-gap: 16px;
  overflow: hidden;
  box-sizing: border-box;
  height: 100%;
  /* Avoid setting min-height to prevent overflow */
}

/* Code section styling */

.simpy-playground.expanded .section.code-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
  box-sizing: border-box;
  height: 100%;
  max-height: 100%; /* Constrain element height */
  padding: 0;
  background-color: transparent;
  border: none;
  border-radius: 0;
  min-height: 0;
}

/* Editor styling */
.simpy-playground.expanded .playground-textarea {
  overflow: auto;
  padding: 0;
  margin: 0;
  box-sizing: border-box;
  border: 1px solid #ccc;
  border-radius: 4px;
  background-color: #fff;
  width: 100%;
  height: 100% !important; /* Override inline styles */
  min-height: 0 !important;
  max-height: none !important;
  display: flex !important;
  flex-direction: column !important;
}

/* Target the CodeMirror editor directly in expanded mode */
.simpy-playground.expanded .playground-textarea .cm-editor {
  height: 100% !important;
  flex: 1 1 auto !important;
  min-height: 0 !important;
}

/* Section styling in both modes */
.section {
  margin-bottom: 20px;
  padding: 15px;
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 5px;
  box-sizing: border-box;
}

.simpy-playground.expanded .section {
  margin-bottom: 0;
  padding: 0;
  background-color: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Sidebar section styling */
.playground-content.sidebar .section {
  overflow: auto;
  height: 100%;
  max-height: 100%; /* Constrain max height */
  display: flex;
  flex-direction: column;
  flex: 1;
  padding-bottom: 16px;
}

.simpy-playground.expanded .playground-content.sidebar .section {
  flex: none;
  padding-bottom: 0;
}

/* Ensure proper height distribution in sidebar */
.simpy-playground.expanded .playground-content.sidebar {
  display: grid;
  grid-template-rows: minmax(180px, 1fr) 5px minmax(260px, 2fr);
  gap: 12px;
}

.simpy-playground.expanded .playground-content.sidebar .section:first-child {
  min-height: 180px;
  transition: all 0.3s ease;
  margin-bottom: 0;
}

.simpy-playground.expanded .playground-content.sidebar .section:last-child {
  min-height: 260px;
  transition: all 0.3s ease;
  padding-bottom: 0;
  margin-bottom: 0;
}

/* Log output styling */
.log-output {
  max-height: 150px;
  overflow-y: auto;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 10px;
  background-color: #fff;
  margin-bottom: 15px;
  flex-shrink: 0;
  color: #111;
}

#simulation-logs {
  height: 100%;
  max-height: none;
  flex: 1;
}

/* Specific log output styling for expanded mode */
.simpy-playground.expanded
  .playground-content.sidebar
  .log-output:not(#simulation-logs) {
  color: #111;
  max-height: 70px !important;
  overflow-y: auto;
  line-height: 1.2;
  padding: 5px;
}

/* Charts container styling */
.charts-container {
  margin-top: 20px;
  width: 100%;
  box-sizing: border-box;
  display: grid;
  grid-gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  overflow-y: auto;
  flex: 1;
  min-height: 300px;
}

.chart-row {
  width: 100%;
  box-sizing: border-box;
}

.time-series-chart {
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  width: 100%;
  box-sizing: border-box;
}

.histogram-chart {
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  width: 100%;
  box-sizing: border-box;
}

.chart-title {
  font-size: 16px;
  margin-top: 0;
  margin-bottom: 10px;
  color: #111;
}

.probe-chart {
  width: 100%;
  display: block;
  padding: 10px;
  border: 1px solid #ccc;
  box-sizing: border-box;
  background-color: #fff;
  cursor: pointer;
}

/* Ensure SVG takes full width */
.time-series-chart svg {
  width: 100%;
  max-width: 100%;
  display: block;
}

/* Inline SVG charts in example detail pages */
.chart-row svg {
  width: 100%;
  height: auto;
  display: block;
}

/* Final frame SVGs on example detail pages */
.final-frame {
  width: 100%;
}
.final-frame img {
  width: 100%;
  height: auto;
  display: block;
}
.final-frame svg {
  width: 100%;
  height: auto;
  display: block;
}

/* Expanded chart styles */
.expanded-chart {
  width: 100%;
  height: 100%;
}

/* Ensure charts in expanded mode display properly */
.simpy-playground.expanded .charts-container {
  overflow-y: auto;
  max-height: 100%;
  margin: 0;
  padding-bottom: 0;
  grid-gap: 12px;
}

/* Data point hover styles */
.chart-data-point {
  cursor: pointer;
  transition: r 0.2s ease;
}

/* Tooltip styles */
.tooltip rect {
  opacity: 0.9;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.tooltip text {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Charts container styling in expanded mode */
.simpy-playground.expanded .playground-content.sidebar .charts-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  width: 100%;
}

/* Charts container heading styling */
.simpy-playground.expanded .playground-content.sidebar .charts-container > h3 {
  width: 100%;
  margin-top: 0;
  margin-bottom: 10px;
  font-size: 16px;
}

/* Chart styling in sidebar */
.simpy-playground.expanded .playground-content.sidebar .chart-row {
  margin-bottom: 10px;
  flex: 1 1 calc(50% - 5px);
  min-width: 300px;
  display: flex;
  box-sizing: border-box;
}

/* When only a single chart is displayed use the full width */
.simpy-playground.expanded
  .playground-content.sidebar
  .charts-container.single-chart
  .chart-row {
  flex: 1 1 100%;
}

.simpy-playground.expanded
  .playground-content.sidebar
  .charts-container.single-chart::after {
  content: none;
}

/* Ensure all charts are properly aligned */
.simpy-playground.expanded
  .playground-content.sidebar
  .charts-container::after {
  content: "";
  flex: 1 1 calc(50% - 5px);
  min-width: 300px;
}

/* Results panel styling */
.results-panel {
  overflow-y: auto;
  flex: 1;
}

/* In expanded mode the results panel should only be as tall as needed */
.simpy-playground.expanded .results-panel {
  flex: 0 0 auto;
}

/* Overlay styles used by modals */
.chart-modal-overlay,
.example-search-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  z-index: 11000; /* Always above editor and header */
}

/* Chart modal styles */
.chart-modal-overlay {
  align-items: center;
}

.chart-modal {
  background-color: #fff;
  padding: 1.5rem;
  padding-top: 3rem;
  border-radius: 5px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
}

.cheatsheet-modal {
  background-color: #fff;
  padding: 1.5rem;
  padding-top: 3rem;
  border-radius: 5px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
  position: relative;
  width: 80vw;
  max-height: 80vh;
  overflow-y: auto;
}

.cheatsheet-content ul {
  padding-left: 1.2rem;
}

.cheatsheet-tables {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.cheatsheet-tables .intro-table {
  flex: 1 1 45%;
}

.close-modal {
  position: absolute;
  top: 10px;
  right: 10px;
  background-color: var(--button-bg-color);
  border: 1px solid var(--accent-color-dark);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #fff;
  cursor: pointer;
  z-index: 10001;
}

.download-chart-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

.download-chart-button,
.download-chart-image-button {
  background-color: var(--button-bg-color);
  border: 1px solid var(--accent-color-dark);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 0.8rem;
  color: #fff;
  cursor: pointer;
}
a.download-chart-button,
a.download-chart-image-button {
  text-decoration: none;
  color: #fff;
  display: inline-block;
}

/* Responsive video embed container */
.video-embed-container {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
  height: 0;
  overflow: hidden;
  max-width: 100%;
  margin: 1.5rem 0;
}

.video-embed-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* Grid output for Game of Life */
.grid-output {
  display: grid;
  gap: 1px;
  background-color: #ccc;
  width: 100%;
  margin-top: 15px;
}

.grid-cell {
  background-color: #fff;
  aspect-ratio: 1;
}

.grid-cell.alive {
  background-color: #000;
}

/* Example search overlay */
.example-search-overlay {
  align-items: flex-start;
  padding-top: 80px;
}

@media (min-height: 600px) {
  .example-search-overlay {
    align-items: center;
    padding-top: 0;
  }
}

.example-search-modal {
  background-color: #fff;
  padding: 1.5rem;
  border-radius: 5px;
  width: 900px;
  max-height: 80vh;
  overflow: auto;
}

.example-search-modal .card {
  padding: 10px;
  margin: 10px 0;
}

.example-search-modal .search-results {
  margin-top: 10px;
  max-height: 60vh;
  overflow-y: auto;
}

.example-search-modal .search-result.selected .card {
  border-color: var(--accent-color);
  background-color: #e0f2f1;
}

/* Annotation list on example pages */
.annotations {
  margin-top: 10px;
  padding: 10px;
  background-color: #f8f9fa;
  border-left: 4px solid var(--accent-color);
}
.annotations ul {
  margin: 0;
  padding-left: 20px;
}
.annotations li {
  margin-bottom: 4px;
}

/* Generic loading overlay used for network operations */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 11000;
  color: #fff;
  font-size: 1.2rem;
}

.loading-overlay .spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #fff;
  border-top-color: var(--accent-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 10px;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Fork modal styles */
.fork-modal {
  background-color: #fff;
  padding: 1.5rem;
  padding-top: 3rem;
  border-radius: 5px;
  width: 400px;
  max-width: 90vw;
  position: relative;
}

.fork-modal h3 {
  margin: 0 0 1rem;
}

.fork-modal-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 10px;
}

/* Delete confirmation modal */
.confirm-modal {
  background-color: #fff;
  padding: 1.5rem;
  border-radius: 5px;
  width: 300px;
  max-width: 90vw;
  position: relative;
  text-align: center;
}

.confirm-modal p {
  margin: 0 0 1rem;
}

.confirm-modal-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 10px;
}

/* Inline annotations for example code */
.annotated-code pre {
  margin: 0;
  padding: 0;
  line-height: 1.3;
  font-size: 1em;
}
.annotated-code pre.inline-annotation {
  padding: 8px 10px;
}

.inline-annotation {
  margin: 0;
  padding: 8px 10px;
  background-color: #f8f9fa;
  border-left: 4px solid var(--accent-color);
}

/* Larger code fonts on example detail pages */
.example-detail-page pre,
.example-detail-page .annotated-code pre {
  font-size: 1.1em;
}
.playground-float-button {
  position: fixed;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  z-index: 1000;
}
.playground-float-button .run-button {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  line-height: 0.4;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
}

@media (max-width: 768px) {
  .playground-float-button {
    right: 0;
  }
  .playground-float-button .run-button {
    padding: 6px 12px;
    font-size: 0.9rem;
  }
}

@media (max-width: 480px) {
  .playground-float-button .run-button {
    padding: 4px 10px;
    font-size: 0.8rem;
  }
}

/* FAQ styles */
.faq-list {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.faq-item dt {
  margin-top: 0;
  margin-bottom: 10px;
  font-weight: normal;
}

.faq-item dd {
  margin: 0;
}

/* Featured example card */
.featured-example-card .charts-container.two-column {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.featured-example-card .charts-container {
  min-height: 0;
  margin-bottom: 10px;
}

.featured-example-card .charts-container.two-column .chart-row {
  flex: 1 1 calc(50% - 10px);
}
.featured-example-card .chart-row {
  display: flex;
  flex-direction: column;
}

/* Ensure images fit within the grid without overflowing */
.featured-example-card .chart-row img {
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 150px;
  object-fit: contain;
  display: block;
  cursor: pointer;
}


.featured-example-card .learn-more {
  text-align: center;
  margin-top: 10px;
}

/* Charts on example detail pages should scale on small screens */
.example-detail-page .chart-row img {
  width: 100%;
  max-width: 100%;
  height: auto;
  display: block;
}
/* Keep probe charts full width on example detail pages */
.example-detail-page .charts-container {
  display: block;
}

/* Quiz styles */
.quiz {
  margin-top: 20px;
}

.quiz-question {
  margin-bottom: 15px;
  padding: 15px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background-color: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.quiz-option {
  display: block;
  margin-bottom: 4px;
}

.quiz-feedback {
  color: var(--cancel-hover-color);
  margin-top: 4px;
}

.quiz-score {
  font-weight: bold;
  margin-top: 10px;
  margin-bottom: 10px;
}

/* Breadcrumb navigation */
.breadcrumb {
  font-size: 0.9rem;
  margin: 10px 0;
}
.breadcrumb .separator {
  margin: 0 4px;
}
