/**
 * Reset some basic elements
 */
body, h1, h2, h3, h4, h5, h6,
p, blockquote, pre, hr,
dl, dd, ol, ul, figure {
  margin: 0;
  padding: 0; }

/**
 * Basic styling
 */
html {
  overflow-x: hidden;
  max-width: 100vw; }

body {
  overflow-x: hidden;
  max-width: 100vw; }

/* Prevent ad elements from causing horizontal overflow */
.reportline, .ezoicwhat, [class*="ezoic"] {
  max-width: 100vw !important;
  overflow: hidden !important; }

html body {
  font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 18px;
  line-height: 1.7;
  font-weight: 400;
  color: #1a1a2e;
  background-color: #fdfdfd;
  -webkit-text-size-adjust: 100%; }
@media screen and (max-width: 600px) {
  html body {
    font-size: 17px;
    line-height: 1.65; }

  /* Tighter headings on mobile */
  #content h1 {
    font-size: 1.7em;
    line-height: 1.25; }
  #content h2 {
    font-size: 1.35em; }
  #content h3, #content h4 {
    font-size: 1.1em; }

  /* Reduce list indent on small screens */
  ul, ol {
    margin-left: 20px; }

  /* Horizontal scroll for wide tables */
  #content table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch; }

  /* Soften FAQ/Exercise negative margins on mobile */
  #content h2#faq ~ h3,
  #content h2#FAQ ~ h3,
  #content h2#faq ~ h4,
  #content h2#FAQ ~ h4,
  #content h3[id*="exercise"],
  #content h3[id*="Exercise"],
  #content h4[id*="exercise"],
  #content h4[id*="Exercise"] {
    margin-left: -6px;
    margin-right: -6px; }

  /* Larger touch targets for WebR buttons */
  .webr-run-btn {
    padding: 8px 18px !important;
    font-size: 14px !important; }
  .webr-reset-btn {
    padding: 6px 14px !important;
    font-size: 13px !important; }

  /* Hide keyboard hints on touch devices */
  .webr-kbd-hint {
    display: none !important; }

  /* Allow horizontal scroll inside code editors so long R lines stay reachable.
     Desktop still suppresses scroll to avoid wheel-event capture; touch scrolling
     on mobile doesn't conflict with page scroll, so we re-enable overflow-x. */
  .webr-editor {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch; }
  .webr-editor .CodeMirror-scroll {
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch; }
}

/**
 * Set `margin-bottom` to maintain vertical rhythm
 */
h1, h2, h3, h4, h5, h6,
p, blockquote, pre,
ul, ol, dl, figure,
.highlight {
  margin-bottom: 15px; }

/**
 * Images
 */
img {
  max-width: 100%;
  vertical-align: middle; }

/**
 * Figures
 */
figure > img {
  display: block; }

figcaption {
  font-size: 0.8em; }

/**
 * Lists
 */
ul, ol {
  margin-left: 30px; }

li > ul,
li > ol {
  margin-bottom: 0; }

/**
 * Headings
 */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  color: #111; }

/**
 * Links
 */
a {
  color: #2a7ae2;
  text-decoration: none; }
  a:visited {
    color: #1756a9; }
  a:hover {
    color: #111;
    text-decoration: underline; }

/**
 * Blockquotes
 */
blockquote {
  color: #1e3a5f;
  background: #eff6ff;
  border-left: 4px solid #3b82f6;
  padding: 1em 1.25em;
  margin: 1.5em 0;
  border-radius: 0 8px 8px 0;
  font-size: 1em;
  letter-spacing: 0;
  font-style: normal;
  line-height: 1.65; }
  blockquote > :last-child {
    margin-bottom: 0; }
  blockquote code {
    background: #dbeafe; }

/**
 * Code formatting
 */
pre,
code {
  font-family: 'IBM Plex Mono', 'JetBrains Mono', Inconsolata, monospace;
  font-size: 0.875em;
  border: 1px solid #e8e8e8;
  border-radius: 3px;
  background-color: #eef; }

code {
  padding: 2px 6px; }

pre {
  padding: 8px 12px;
  overflow-x: auto; }
  pre > code {
    border: 0;
    padding-right: 0;
    padding-left: 0; }

/**
 * Wrapper
 */
.wrapper {
  max-width: -webkit-calc(800px - (30px * 2));
  max-width: calc(800px - (30px * 2));
  margin-right: auto;
  margin-left: auto;
  padding-right: 30px;
  padding-left: 30px; }
  @media screen and (max-width: 800px) {
    .wrapper {
      max-width: -webkit-calc(800px - (30px));
      max-width: calc(800px - (30px));
      padding-right: 15px;
      padding-left: 15px; } }

/**
 * Clearfix
 */
.wrapper:after, .footer-col-wrapper:after {
  content: "";
  display: table;
  clear: both; }

/**
 * Icons
 */
.icon > svg {
  display: inline-block;
  width: 16px;
  height: 16px;
  vertical-align: middle; }
  .icon > svg path {
    fill: #828282; }

/**
 * Site header
 */
.masthead {
  padding-top: 4px; }

.site-header {
  border-top: none;
  border-bottom: none;
  min-height: auto;
  position: relative; }

.site-title {
  font-size: 20px;
  font-weight: 700;
  line-height: normal;
  letter-spacing: normal;
  margin-bottom: 0; }
  .site-title a {
    color: #3560b8; }
  .site-title a:visited {
    color: #3560b8; }

.site-nav {
  float: right;
  line-height: 56px; }
  .site-nav .menu-icon {
    display: none; }
  .site-nav .page-link {
    color: #111;
    line-height: 1.5; }
    .site-nav .page-link:not(:first-child) {
      margin-left: 20px; }
  @media screen and (max-width: 600px) {
    .site-nav {
      position: absolute;
      top: 9px;
      right: 30px;
      background-color: #fdfdfd;
      border: 1px solid #e8e8e8;
      border-radius: 5px;
      text-align: right; }
      .site-nav .menu-icon {
        display: block;
        float: right;
        width: 36px;
        height: 26px;
        line-height: 0;
        padding-top: 10px;
        text-align: center; }
        .site-nav .menu-icon > svg {
          width: 18px;
          height: 15px; }
          .site-nav .menu-icon > svg path {
            fill: #424242; }
      .site-nav .trigger {
        clear: both;
        display: none; }
      .site-nav:hover .trigger {
        display: block;
        padding-bottom: 5px; }
      .site-nav .page-link {
        display: block;
        padding: 5px 10px; } }

/**
 * Site footer
 */
.site-footer {
  border-top: 1px solid #e8e8e8;
  padding: 30px 0; }

.footer-heading {
  font-size: 18px;
  margin-bottom: 15px; }

.contact-list,
.social-media-list {
  list-style: none;
  margin-left: 0; }

.footer-col-wrapper {
  font-size: 15px;
  color: #828282;
  margin-left: -15px; }

.footer-col {
  float: left;
  margin-bottom: 15px;
  padding-left: 15px; }

.footer-col-1 {
  width: -webkit-calc(35% - (30px / 2));
  width: calc(35% - (30px / 2)); }

.footer-col-2 {
  width: -webkit-calc(20% - (30px / 2));
  width: calc(20% - (30px / 2)); }

.footer-col-3 {
  width: -webkit-calc(45% - (30px / 2));
  width: calc(45% - (30px / 2)); }

@media screen and (max-width: 800px) {
  .footer-col-1,
  .footer-col-2 {
    width: -webkit-calc(50% - (30px / 2));
    width: calc(50% - (30px / 2)); }

  .footer-col-3 {
    width: -webkit-calc(100% - (30px / 2));
    width: calc(100% - (30px / 2)); } }
@media screen and (max-width: 600px) {
  .footer-col {
    float: none;
    width: -webkit-calc(100% - (30px / 2));
    width: calc(100% - (30px / 2)); } }
/**
 * Page content
 */
.page-content {
  padding: 30px 0; }

.page-heading {
  font-size: 20px; }

.post-list {
  margin-left: 0;
  list-style: none; }
  .post-list > li {
    margin-bottom: 30px; }

.post-meta {
  font-size: 14px;
  color: #828282; }

.post-link {
  display: block;
  font-size: 24px; }

/**
 * Posts
 */
.post-header {
  margin-bottom: 30px; }

.post-title {
  font-size: 42px;
  letter-spacing: -1px;
  line-height: 1; }
  @media screen and (max-width: 800px) {
    .post-title {
      font-size: 36px; } }

.post-content {
  margin-bottom: 30px; }
  .post-content h2 {
    font-size: 32px; }
    @media screen and (max-width: 800px) {
      .post-content h2 {
        font-size: 28px; } }
  .post-content h3 {
    font-size: 26px; }
    @media screen and (max-width: 800px) {
      .post-content h3 {
        font-size: 22px; } }
  .post-content h4 {
    font-size: 20px; }
    @media screen and (max-width: 800px) {
      .post-content h4 {
        font-size: 18px; } }

/**
 * Syntax highlighting styles
 */
.highlight {
  background: #fff; }
  .highlight .c {
    color: #998;
    font-style: italic; }
  .highlight .err {
    color: #a61717;
    background-color: #e3d2d2; }
  .highlight .k {
    font-weight: bold; }
  .highlight .o {
    font-weight: bold; }
  .highlight .cm {
    color: #998;
    font-style: italic; }
  .highlight .cp {
    color: #999;
    font-weight: bold; }
  .highlight .c1 {
    color: #998;
    font-style: italic; }
  .highlight .cs {
    color: #999;
    font-weight: bold;
    font-style: italic; }
  .highlight .gd {
    color: #000;
    background-color: #fdd; }
  .highlight .gd .x {
    color: #000;
    background-color: #faa; }
  .highlight .ge {
    font-style: italic; }
  .highlight .gr {
    color: #a00; }
  .highlight .gh {
    color: #999; }
  .highlight .gi {
    color: #000;
    background-color: #dfd; }
  .highlight .gi .x {
    color: #000;
    background-color: #afa; }
  .highlight .go {
    color: #888; }
  .highlight .gp {
    color: #555; }
  .highlight .gs {
    font-weight: bold; }
  .highlight .gu {
    color: #aaa; }
  .highlight .gt {
    color: #a00; }
  .highlight .kc {
    font-weight: bold; }
  .highlight .kd {
    font-weight: bold; }
  .highlight .kp {
    font-weight: bold; }
  .highlight .kr {
    font-weight: bold; }
  .highlight .kt {
    color: #458;
    font-weight: bold; }
  .highlight .m {
    color: #099; }
  .highlight .s {
    color: #d14; }
  .highlight .na {
    color: #008080; }
  .highlight .nb {
    color: #0086B3; }
  .highlight .nc {
    color: #458;
    font-weight: bold; }
  .highlight .no {
    color: #008080; }
  .highlight .ni {
    color: #800080; }
  .highlight .ne {
    color: #900;
    font-weight: bold; }
  .highlight .nf {
    color: #900;
    font-weight: bold; }
  .highlight .nn {
    color: #555; }
  .highlight .nt {
    color: #000080; }
  .highlight .nv {
    color: #008080; }
  .highlight .ow {
    font-weight: bold; }
  .highlight .w {
    color: #bbb; }
  .highlight .mf {
    color: #099; }
  .highlight .mh {
    color: #099; }
  .highlight .mi {
    color: #099; }
  .highlight .mo {
    color: #099; }
  .highlight .sb {
    color: #d14; }
  .highlight .sc {
    color: #d14; }
  .highlight .sd {
    color: #d14; }
  .highlight .s2 {
    color: #d14; }
  .highlight .se {
    color: #d14; }
  .highlight .sh {
    color: #d14; }
  .highlight .si {
    color: #d14; }
  .highlight .sx {
    color: #d14; }
  .highlight .sr {
    color: #009926; }
  .highlight .s1 {
    color: #d14; }
  .highlight .ss {
    color: #990073; }
  .highlight .bp {
    color: #999; }
  .highlight .vc {
    color: #008080; }
  .highlight .vg {
    color: #008080; }
  .highlight .vi {
    color: #008080; }
  .highlight .il {
    color: #099; }

/**
 * Collapsible solution blocks (<details>/<summary>)
 */
details {
  margin: 1.5em 0 2em 0;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 0;
  background: #fff;
  overflow: hidden;
  transition: border-color 0.2s ease; }

details:hover {
  border-color: #3566c0; }

details summary {
  cursor: pointer;
  padding: 11px 16px;
  background: #f7f8fa;
  font-weight: 400;
  font-size: 0.93em;
  color: #3566c0;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.2s ease;
  border-bottom: 1px solid transparent; }

details summary:hover {
  background: #eef2fb; }

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

details summary::before {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 5px 0 5px 8px;
  border-color: transparent transparent transparent #3566c0;
  transition: transform 0.25s ease;
  margin-right: 2px;
  flex-shrink: 0; }

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

details[open] summary {
  border-bottom: 1px solid #e0e0e0;
  background: #eef2fb; }

details[open] {
  border-color: #3566c0; }

details[open] > *:not(summary) {
  animation: detailsSlide 0.25s ease-out; }

@keyframes detailsSlide {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); } }

details > *:not(summary) {
  padding: 0 16px; }

details > p:first-of-type {
  margin-top: 14px; }

details > *:not(summary):last-child {
  padding-bottom: 16px; }

details .webr-container {
  margin: 12px 0; }

/**
 * Breadcrumb navigation (Quarto-style)
 */
.breadcrumb-nav {
  font-size: 13.5px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: #6c757d;
  margin-bottom: 2px;
  padding: 0; }

.breadcrumb-nav + .webr-loading-banner { margin-top: 4px; }
.breadcrumb-nav + h1,
.breadcrumb-nav + .webr-loading-banner + h1,
.webr-loading-banner.hidden + h1 { margin-top: 2px; }

.breadcrumb-nav a {
  color: #6c757d;
  text-decoration: none;
  transition: color 0.15s; }

.breadcrumb-nav a:hover {
  color: #3b82f6;
  text-decoration: underline; }

.bc-sep, .breadcrumb-sep {
  margin: 0 5px;
  color: #adb5bd; }

.bc-current, .breadcrumb-current {
  color: #495057;
  font-weight: 500; }

/**
 * Featured snippet subtitle
 */
/* p.lead defined in content typography section below */

/**
 * Quarto-style collapsible sidebar
 */
/* Sidebar scrollbar — thin, visible, sleek */
#nav,
#sidebar-nav {
  scrollbar-width: thin;
  scrollbar-color: #d0d7de transparent; }

#nav::-webkit-scrollbar,
#sidebar-nav::-webkit-scrollbar { width: 3px; }

#nav::-webkit-scrollbar-track,
#sidebar-nav::-webkit-scrollbar-track { background: transparent; }

#nav::-webkit-scrollbar-thumb,
#sidebar-nav::-webkit-scrollbar-thumb { background: #d0d7de; border-radius: 3px; }

#nav::-webkit-scrollbar-thumb:hover,
#sidebar-nav::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

html.dark #nav,
html.dark #sidebar-nav { scrollbar-color: #475569 transparent; }
html.dark #nav::-webkit-scrollbar-thumb,
html.dark #sidebar-nav::-webkit-scrollbar-thumb { background: #475569; }
html.dark #nav::-webkit-scrollbar-thumb:hover,
html.dark #sidebar-nav::-webkit-scrollbar-thumb:hover { background: #64748b; }

#sidebar-nav {
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 8px 0; }

.sidebar-menu { margin: 0; padding: 0; }

.sidebar-section { margin-bottom: 1px; }

.sidebar-section-header {
  padding: 7px 12px;
  font-size: 15px;
  font-weight: 700;
  color: #212529;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s; }

.sidebar-section-header:hover {
  background: #f1f3f5;
  color: #000; }

.sidebar-chevron {
  display: inline-block;
  font-size: 10px;
  margin-right: 4px;
  transition: transform 0.2s ease;
  color: #757575; }

.sidebar-section.expanded .sidebar-chevron {
  transform: rotate(90deg);
  color: #6b7280; }

.sidebar-section-items {
  display: none;
  padding-left: 0;
  margin: 2px 0 6px 0; }

.sidebar-section.expanded .sidebar-section-items {
  display: block; }

.sidebar-section-items li { line-height: 1.5; }

.sidebar-section-items li a {
  display: block;
  padding: 4px 10px 4px 32px;
  font-size: 14px;
  color: #495057;
  text-decoration: none;
  border-left: 2px solid transparent;
  border-radius: 0 4px 4px 0;
  transition: all 0.15s; }

.sidebar-section-items li a:hover {
  color: #3b82f6;
  background: #f8f9fa;
  border-left-color: #d0d7de; }

.sidebar-section-items li a.active {
  color: #3b82f6;
  font-weight: 600;
  border-left-color: #3b82f6;
  background: #eff6ff; }

.sidebar-divider {
  margin: 12px 0 2px 0;
  padding: 0 12px 4px 24px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #9ca3af;
  border-bottom: 1px solid #f0f2f5;
  cursor: default;
  list-style: none; }

.sidebar-divider:first-child { margin-top: 4px; }

.sidebar-subsection-toggle { cursor: pointer; }
.sidebar-subsection-toggle:hover { color: #6b7280; }

.subsec-chevron {
  font-size: 8px;
  opacity: 0.5;
  margin-right: 2px;
  display: inline-block;
  vertical-align: middle; }

/* Progress completion dots */
.progress-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid #d1d5db;
  margin-right: 7px;
  vertical-align: middle;
  flex-shrink: 0;
  position: relative;
  transition: background 0.2s, border-color 0.2s; }

.progress-dot.visited {
  background: #22c55e;
  border-color: #22c55e; }

.progress-dot.visited::after {
  content: '';
  position: absolute;
  left: 2px;
  top: 0px;
  width: 3px;
  height: 6px;
  border: 1.5px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg); }

html.dark .sidebar-divider { color: #94a3b8; border-bottom-color: #1e293b; }
html.dark .progress-dot { border-color: #4b5563; }
html.dark .progress-dot.visited { background: #16a34a; border-color: #16a34a; }

.sidebar-subscribe {
  margin-top: 16px;
  padding: 12px;
  font-size: 14px;
  border-top: 1px solid #e9ecef;
  color: #6c757d; }

.sidebar-subscribe a { color: #3b82f6; }

/**
 * Right-side "On this page" TOC
 */
#toc-sidebar { position: relative; }

/* Hide TOC sidebar when empty (e.g., homepage) */
#toc:empty ~ .toc-title,
#toc:empty { display: none; }
#toc-wrapper:has(#toc:empty) { display: none; }

#toc-wrapper {
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding-left: 14px;
  border-left: 1px solid #e9ecef;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent; }

#toc-wrapper:hover {
  scrollbar-color: #d0d7de transparent; }

#toc-wrapper::-webkit-scrollbar { width: 3px; }
#toc-wrapper::-webkit-scrollbar-track { background: transparent; }
#toc-wrapper::-webkit-scrollbar-thumb { background: transparent; border-radius: 3px; }
#toc-wrapper:hover::-webkit-scrollbar-thumb { background: #d0d7de; }

.toc-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #6c757d;
  margin-bottom: 10px;
  padding-bottom: 0; }

#toc { margin: 0; padding: 0; }

#toc li {
  line-height: 1.45;
  margin-bottom: 1px; }

#toc li a {
  font-size: 13.5px;
  color: #6c757d;
  text-decoration: none;
  display: block;
  padding: 3px 0;
  border-left: 2px solid transparent;
  padding-left: 8px;
  margin-left: -15px;
  transition: all 0.15s; }

#toc li a:hover {
  color: #3b82f6; }

#toc li a.toc-active {
  color: #3b82f6;
  font-weight: 600;
  border-left-color: #3b82f6; }

/**
 * Content typography — IBM Plex Sans (body) + IBM Plex Serif (headings)
 */

/* Smooth scroll removed — handled by JS click handler in template.html
   to avoid compositor overhead during manual scrolling */

/* Paragraph rhythm */
#content p {
  line-height: 1.75;
  margin-bottom: 1.15em;
  color: #1a1a2e; }

/* Serif headings — IBM Plex Serif for authority */
#content h1,
#content h2,
#content h3,
#content h4 {
  font-family: 'IBM Plex Serif', Georgia, 'Times New Roman', serif; }

/* H1: bold, commanding */
#content h1 {
  font-weight: 700;
  font-size: 2.1em;
  line-height: 1.2;
  margin-bottom: 0.4em;
  letter-spacing: -0.01em; }

/* H2: section headers with divider */
#content h2 {
  font-weight: 600;
  font-size: 1.65em;
  line-height: 1.25;
  margin-top: 2.5em;
  margin-bottom: 0.6em;
  padding-top: 0.8em;
  border-top: 1px solid #e5e7eb; }

#content h2:first-of-type {
  border-top: none;
  margin-top: 1.5em; }

/* H3/H4: subheadings */
#content h3,
#content h4 {
  font-weight: 600;
  font-size: 1.2em;
  margin-top: 1.8em;
  margin-bottom: 0.5em;
  color: #1a1a2e; }

/* Lead paragraph */
p.lead {
  font-size: 1.1em;
  line-height: 1.7;
  color: #374151;
  font-weight: 400;
  border-left: 3px solid #3b82f6;
  padding-left: 1em;
  margin: -4px 0 1.5em 0; }

/* Lists */
#content li {
  line-height: 1.7;
  margin-bottom: 0.3em; }

/* Images: rounded + shadow */
#content img.img-responsive {
  border-radius: 8px;
  box-shadow: 0 2px 16px rgba(0,0,0,0.08);
  margin: 1.5em auto;
  display: block;
  max-width: 100%;
  height: auto; }

/* Diagram images: cap height so tall diagrams (flowchart TD, mindmap)
   don't dominate the viewport. Wide diagrams are unaffected — only height
   is constrained, width scales proportionally via auto. */
#content img[src*="/screenshots/"] {
  max-height: 500px;
  width: auto;
  max-width: 100%; }

/* Figure captions (italic paragraph after an image) */
#content p > em:only-child {
  display: block;
  text-align: center;
  font-size: 0.875em;
  color: #6b7280;
  margin-top: -0.5em;
  margin-bottom: 2em;
  line-height: 1.5; }

/* Tables: polished headers */
#content table {
  margin: 1.5em 0; }

#content th {
  background: #f1f5f9;
  padding: 11px 16px;
  font-weight: 600;
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #475569;
  border-bottom: 2px solid #cbd5e1; }

#content td {
  padding: 10px 16px; }

/* Strong text */
#content strong {
  font-weight: 600;
  color: #111; }

/* Further Reading section */
#auto-further-reading {
  margin-top: 2.5em;
  padding-top: 1.5em;
  border-top: 1px solid #e5e7eb; }

#auto-further-reading h2 {
  border-top: none;
  margin-top: 0;
  padding-top: 0; }

/**
 * Summary table — highlighted so readers can find it instantly
 */
#content h2 + table:last-of-type,
#content table.summary-table {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden; }

/**
 * FAQ section — visual distinction
 */
#content h2#faq ~ h4,
#content h2#FAQ ~ h4 {
  background: #f9fafb;
  padding: 10px 14px;
  margin-left: -14px;
  margin-right: -14px;
  border-radius: 6px;
  border-left: 3px solid #6366f1; }

/**
 * Exercise card styling
 */
#content h3[id*="exercise"],
#content h3[id*="Exercise"],
#content h4[id*="exercise"],
#content h4[id*="Exercise"] {
  background: #fffbeb;
  padding: 8px 14px;
  margin-left: -14px;
  margin-right: -14px;
  border-radius: 6px;
  border-left: 3px solid #f59e0b;
  color: #92400e; }

/**
 * Callout boxes: [TIP], [WARNING], [NOTE], [KEY INSIGHT]
 */
.callout {
  margin: 1.6em 0;
  padding: 12px 18px 14px 18px;
  border-left: 4px solid;
  border-radius: 0 8px 8px 0;
  background: #fff; }

.callout-label {
  font-size: 0.72em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px; }

.callout-body {
  line-height: 1.6;
  color: #1a1a2e; }

.callout-body > *:last-child { margin-bottom: 0; }

.callout-tip {
  border-left-color: #22c55e;
  background: #f0fdf4; }
.callout-tip .callout-label { color: #15803d; }

.callout-warning {
  border-left-color: #f59e0b;
  background: #fffbeb; }
.callout-warning .callout-label { color: #b45309; }

.callout-note {
  border-left-color: #3b82f6;
  background: #eff6ff; }
.callout-note .callout-label { color: #1e40af; }

.callout-insight {
  border-left-color: #8b5cf6;
  background: #f5f3ff; }
.callout-insight .callout-label { color: #6d28d9; }

/**
 * Dark mode
 */
html.dark {
  color-scheme: dark; }

html.dark body {
  background-color: #0f172a;
  color: #cbd5e1; }

html.dark #content p,
html.dark #content li {
  color: #cbd5e1; }

html.dark #content h1,
html.dark #content h2,
html.dark #content h3,
html.dark #content h4,
html.dark h1, html.dark h2, html.dark h3, html.dark h4, html.dark h5, html.dark h6 {
  color: #e2e8f0; }

html.dark #content strong {
  color: #f1f5f9; }

html.dark a { color: #60a5fa; }
html.dark a:visited { color: #818cf8; }
html.dark a:hover { color: #93c5fd; }

html.dark p.lead {
  color: #94a3b8;
  border-left-color: #3b82f6; }

html.dark hr { border-color: #334155; }

/* Dark: blockquotes */
html.dark blockquote {
  background: #1e293b;
  border-left-color: #3b82f6;
  color: #94a3b8; }
html.dark blockquote p { color: #94a3b8; }
html.dark blockquote code { background: #334155; }

/* Dark: callouts */
html.dark .callout { background: #1e293b; }
html.dark .callout-body { color: #cbd5e1; }
html.dark .callout-tip { background: #0a2818; }
html.dark .callout-tip .callout-label { color: #4ade80; }
html.dark .callout-warning { background: #241b0e; }
html.dark .callout-warning .callout-label { color: #fbbf24; }
html.dark .callout-note { background: #0c1a33; }
html.dark .callout-note .callout-label { color: #60a5fa; }
html.dark .callout-insight { background: #1e1338; }
html.dark .callout-insight .callout-label { color: #a78bfa; }

/* Dark: inline code */
html.dark code {
  background-color: #1e293b;
  border-color: #334155;
  color: #e2e8f0; }

/* Dark: tables */
html.dark #content table {
  border-color: #334155; }
html.dark #content th {
  background: #1e293b;
  color: #94a3b8;
  border-bottom-color: #475569; }
html.dark #content td {
  color: #cbd5e1;
  border-bottom-color: #334155; }
html.dark .table-striped > tbody > tr:nth-child(odd) > td,
html.dark .table-striped > tbody > tr:nth-child(odd) > th {
  background-color: rgba(30, 41, 59, 0.5) !important; }
html.dark .table-striped > tbody > tr:nth-child(even) > td,
html.dark .table-striped > tbody > tr:nth-child(even) > th {
  background-color: transparent !important; }
html.dark .table > tbody > tr > td,
html.dark .table > tbody > tr > th,
html.dark .table > thead > tr > th {
  border-color: #334155 !important; }

/* Dark: images */
html.dark #content img.img-responsive {
  box-shadow: 0 2px 16px rgba(0,0,0,0.3);
  border-radius: 8px; }

/* Dark: details/summary (exercises) */
html.dark details {
  background: #1e293b;
  border-color: #334155; }
html.dark details summary {
  background: #1e293b;
  color: #60a5fa; }
html.dark details summary:hover { background: #334155; }
html.dark details[open] summary {
  background: #334155;
  border-bottom-color: #475569; }
html.dark details[open] { border-color: #3b82f6; }

/* Dark: WebR containers */
html.dark .webr-container {
  border-color: #334155; }
html.dark .webr-container:hover {
  border-color: #4f46e5; }
html.dark .webr-code-block {
  background: #1e293b; }

/* Dark: sidebar */
html.dark .sidebar-section-header { color: #94a3b8; }
html.dark .sidebar-section-header:hover { background: #1e293b; color: #e2e8f0; }
html.dark .sidebar-section-items li a { color: #94a3b8; }
html.dark .sidebar-section-items li a:hover { color: #60a5fa; background: #1e293b; }
html.dark .sidebar-section-items li a.active { color: #60a5fa; background: #1e293b; }

/* Dark: TOC */
html.dark #toc-wrapper { border-left-color: #334155; }
html.dark .toc-title { color: #64748b; }
html.dark #toc li a { color: #64748b; }
html.dark #toc li a:hover { color: #60a5fa; }
html.dark #toc li a.toc-active { color: #60a5fa; border-left-color: #3b82f6; }

/* Dark: header */
html.dark .masthead { border-bottom-color: #334155; }
html.dark .site-title a { color: #e2e8f0; }
html.dark .site-header small { color: #64748b; }
html.dark #dark-mode-toggle { color: #e2e8f0; border-color: #475569; }
html.dark #my-google-search { background: #1e293b; color: #e2e8f0; border-color: #475569; }

/* Dark: footer */
html.dark .footer { color: #64748b; }
html.dark .footer hr { border-color: #334155; }

/* Dark: FAQ and exercise cards */
html.dark #content h2#faq ~ h4,
html.dark #content h2#FAQ ~ h4 {
  background: #1e293b;
  border-left-color: #818cf8; }

html.dark #content h3[id*="exercise"],
html.dark #content h3[id*="Exercise"],
html.dark #content h4[id*="exercise"],
html.dark #content h4[id*="Exercise"] {
  background: #1e293b;
  border-left-color: #f59e0b;
  color: #fbbf24; }

/* Dark: summary table */
html.dark #content h2 + table:last-of-type,
html.dark #content table.summary-table {
  background: #1e293b;
  border-color: #334155; }

/* Dark: figure captions */
html.dark #content p > em:only-child { color: #64748b; }

/* Dark: lead paragraph */
html.dark .breadcrumb-nav,
html.dark .breadcrumb-nav a { color: #64748b; }

/* Dark: loading banner */
html.dark .webr-loading-banner {
  background: #1e293b;
  color: #94a3b8;
  border-color: #334155; }
html.dark .webr-loading-banner.ready {
  background: #1e293b;
  color: #4ade80;
  border-color: #334155; }

/**
 * Homepage styles
 */

/* Hero */
.home-hero {
  text-align: center;
  padding: 2.5em 0 1.5em; }

.home-hero h1 {
  font-family: 'IBM Plex Serif', Georgia, serif;
  font-weight: 700;
  font-size: 2.2em;
  color: #111;
  margin-bottom: 0.3em;
  letter-spacing: -0.01em; }

.home-subtitle {
  font-size: 1.1em;
  color: #6b7280;
  margin-bottom: 1.5em;
  line-height: 1.6; }

.home-cta {
  display: inline-block;
  background: #3b82f6;
  color: #fff;
  padding: 10px 28px;
  border-radius: 6px;
  font-weight: 500;
  font-size: 1em;
  text-decoration: none;
  transition: background 0.2s; }

.home-cta:hover { background: #2563eb; color: #fff; text-decoration: none; }
.home-cta:visited { color: #fff; }

/* Section titles */
.home-section { margin: 2.5em 0 1.5em; }

.home-section-title {
  font-family: 'IBM Plex Serif', Georgia, serif;
  font-weight: 600;
  font-size: 1.3em;
  color: #374151;
  margin-bottom: 1.2em;
  padding-bottom: 0.5em;
  border-bottom: 1px solid #e5e7eb; }

/* Bar chart */
.home-bar {
  display: flex;
  align-items: center;
  margin-bottom: 1.2em;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease; }

.home-bar:hover { transform: translateX(4px); text-decoration: none; color: inherit; }

.home-bar-fill {
  display: block;
  height: 38px !important;
  border-radius: 6px;
  min-width: 40px;
  flex-shrink: 0;
  transition: width 0.6s ease; }

.home-bar-label {
  margin-left: 16px;
  min-width: 0; }

.home-bar-name {
  font-weight: 600;
  font-size: 0.95em;
  color: #1a1a2e;
  display: block;
  line-height: 1.3; }

.home-bar-topics {
  font-size: 0.8em;
  color: #9ca3af;
  margin-top: 2px;
  line-height: 1.3; }

/* Bar colors — lavender to indigo spectrum */
.home-bar:nth-child(1) .home-bar-fill { background: linear-gradient(135deg, #6366f1, #4f46e5); }
.home-bar:nth-child(2) .home-bar-fill { background: linear-gradient(135deg, #818cf8, #6366f1); }
.home-bar:nth-child(3) .home-bar-fill { background: linear-gradient(135deg, #7c3aed, #6d28d9); }
.home-bar:nth-child(4) .home-bar-fill { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.home-bar:nth-child(5) .home-bar-fill { background: linear-gradient(135deg, #a78bfa, #8b5cf6); }
.home-bar:nth-child(6) .home-bar-fill { background: linear-gradient(135deg, #a5b4fc, #818cf8); }
.home-bar:nth-child(7) .home-bar-fill { background: linear-gradient(135deg, #c4b5fd, #a78bfa); }
.home-bar:nth-child(8) .home-bar-fill { background: linear-gradient(135deg, #ddd6fe, #c4b5fd); }

/* Two-panel layout */
.home-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5em;
  margin: 2.5em 0 2em; }

@media (max-width: 768px) {
  .home-panels { grid-template-columns: 1fr; } }

.home-panel {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 1.5em; }

.home-panel h3 {
  font-family: 'IBM Plex Serif', Georgia, serif;
  font-weight: 600;
  font-size: 1.1em;
  margin-bottom: 1em;
  color: #1a1a2e; }

/* Console */
.home-console {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1em 1.2em;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.85em;
  line-height: 1.65;
  overflow-x: auto;
  white-space: pre;
  color: #1a1a2e; }

.home-console-note {
  font-size: 0.82em;
  color: #6b7280;
  margin-top: 0.75em; }

/* Featured list */
.home-featured-item {
  display: block;
  padding: 0.75em 0;
  border-bottom: 1px solid #f3f4f6;
  text-decoration: none;
  color: inherit;
  transition: padding-left 0.15s ease; }

.home-featured-item:hover { padding-left: 6px; text-decoration: none; color: inherit; }
.home-featured-item:last-child { border-bottom: none; }

.home-featured-item strong {
  display: block;
  font-weight: 600;
  color: #1a1a2e;
  font-size: 0.95em; }

.home-featured-item span {
  font-size: 0.85em;
  color: #6b7280;
  line-height: 1.4; }

/* Homepage dark mode */
html.dark .home-hero h1 { color: #e2e8f0; }
html.dark .home-subtitle { color: #94a3b8; }
html.dark .home-cta { background: #3b82f6; }
html.dark .home-cta:hover { background: #2563eb; }
html.dark .home-section-title { color: #94a3b8; border-bottom-color: #334155; }
html.dark .home-bar-name { color: #e2e8f0; }
html.dark .home-bar-topics { color: #64748b; }
html.dark .home-panel { border-color: #334155; background: #1e293b; }
html.dark .home-panel h3 { color: #e2e8f0; }
html.dark .home-console { background: #0f172a; border-color: #334155; color: #cbd5e1; }
html.dark .home-console-note { color: #64748b; }
html.dark .home-featured-item { border-bottom-color: #334155; }
html.dark .home-featured-item strong { color: #e2e8f0; }
html.dark .home-featured-item span { color: #64748b; }

/* Try It practice blocks — visually distinct from tutorial code */
.tryit-block {
  position: relative;
  margin: 28px 0 24px 0;
  padding: 20px 20px 12px 20px;
  background: #fff8e1;
  border-left: 4px solid #f57c00;
  border-radius: 4px;
}
.tryit-block::before {
  content: "TRY IT";
  display: inline-block;
  position: absolute;
  top: -11px;
  left: 14px;
  padding: 3px 11px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #fff;
  background: #f57c00;
  border-radius: 10px;
  text-transform: uppercase;
}
.tryit-block > p:first-of-type {
  margin: 4px 0 10px 0;
  font-weight: 500;
  color: #5d4037;
}
.tryit-block .webr-container {
  margin: 8px 0;
}
.tryit-block details {
  margin: 10px 0 0 0;
  padding: 8px 12px;
  background: #fff3cd;
  border-radius: 3px;
}
.tryit-block details summary {
  color: #795548;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}
html.dark .tryit-block { background: #3e2723; border-left-color: #ffb74d; }
html.dark .tryit-block::before { background: #ffb74d; color: #1a0f0a; }
html.dark .tryit-block > p:first-of-type { color: #ffe0b2; }
html.dark .tryit-block details { background: #4e342e; }
html.dark .tryit-block details summary { color: #ffcc80; }

/* --- Prev/Next post navigation --- */
.prev-next-nav {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 16px;
  margin: 4.125em 0 1.5em 0;
  padding-top: 1.32em;
  border-top: 1px solid #e5e7eb;
}
.prev-next-nav .pn-link {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 14px 18px;
  background: #fafbfc;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  text-decoration: none;
  color: #1a1a2e;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.prev-next-nav .pn-link:hover {
  background: #f0f4ff;
  border-color: #3566c0;
  text-decoration: none;
  transform: translateY(-1px);
}
.prev-next-nav .pn-next {
  text-align: right;
  align-items: flex-end;
}
.prev-next-nav .pn-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.prev-next-nav .pn-title {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: #3566c0;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.prev-next-nav .pn-placeholder {
  flex: 1 1 0;
  visibility: hidden;
}
@media (max-width: 600px) {
  .prev-next-nav { flex-direction: column; gap: 10px; }
  .prev-next-nav .pn-next { text-align: left; align-items: flex-start; }
  .prev-next-nav .pn-placeholder { display: none; }
}
html.dark .prev-next-nav { border-top-color: #334155; }
html.dark .prev-next-nav .pn-link {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}
html.dark .prev-next-nav .pn-link:hover {
  background: #283548;
  border-color: #60a5fa;
}
html.dark .prev-next-nav .pn-label { color: #94a3b8; }
html.dark .prev-next-nav .pn-title { color: #60a5fa; }

/* --- Related Tutorials grid ---
   No section-level margin/padding/border: the inner <h2 class="rt-heading">
   is styled by #content h2 (id specificity wins), which already provides
   the correct top rhythm. Adding section decoration too produced DOUBLE
   spacing and two stacked horizontal rules above "Related Tutorials". */
.related-tutorials {
  margin: 0 0 1em 0;
}
.related-tutorials .rt-heading {
  margin-bottom: 16px;
}
.related-tutorials .rt-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.related-tutorials .rt-card {
  display: flex;
  flex-direction: column;
  padding: 14px 16px;
  background: #fafbfc;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  text-decoration: none;
  color: #1a1a2e;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
  min-height: 90px;
}
.related-tutorials .rt-card:hover {
  background: #f0f4ff;
  border-color: #3566c0;
  text-decoration: none;
  transform: translateY(-1px);
}
.related-tutorials .rt-title {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: #3566c0;
  line-height: 1.35;
  margin-bottom: 8px;
}
.related-tutorials .rt-meta {
  display: block;
  margin-top: auto;
  font-size: 12px;
  color: #6b7280;
  font-weight: 500;
}
@media (max-width: 520px) {
  .related-tutorials .rt-grid { grid-template-columns: 1fr; }
}
html.dark .related-tutorials { border-top-color: #334155; }
html.dark .related-tutorials .rt-heading { color: #e2e8f0; }
html.dark .related-tutorials .rt-card {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}
html.dark .related-tutorials .rt-card:hover {
  background: #283548;
  border-color: #60a5fa;
}
html.dark .related-tutorials .rt-title { color: #60a5fa; }
html.dark .related-tutorials .rt-meta { color: #94a3b8; }
