/* Tutorial section styles — extends the main site beach theme */

.tutorial-shell {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 32px;
  padding: 32px 20px 60px;
  background: var(--sand-100);
  min-height: calc(100vh - 200px);
}

/* ---- Sidebar ---- */
.tut-sidebar {
  position: relative;
}
.tut-sidebar__inner {
  position: sticky;
  top: 90px;
  background: var(--paper);
  border: 1px solid #fff;
  border-radius: var(--radius-md);
  padding: 20px 16px;
  box-shadow: var(--shadow-card);
  max-height: calc(100vh - 110px);
  overflow-y: auto;
}
.tut-sidebar__title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--coral-deep);
  margin-bottom: 14px;
  font-family: var(--font-display);
  font-weight: 700;
}
.tut-sidebar__chapter {
  margin-bottom: 6px;
}
.tut-sidebar__chapter-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 800;
  font-size: 14px;
  color: var(--coco-deep);
  font-family: var(--font-display);
  transition: .15s;
  user-select: none;
}
.tut-sidebar__chapter-head:hover {
  background: rgba(58,167,179,.08);
}
.tut-sidebar__chapter-head::before {
  content: "";
  display: inline-block;
  width: 0; height: 0;
  border-style: solid;
  border-width: 5px 0 5px 7px;
  border-color: transparent transparent transparent var(--ink-soft);
  transition: transform .15s;
  flex-shrink: 0;
}
.tut-sidebar__chapter.is-open > .tut-sidebar__chapter-head::before {
  transform: rotate(90deg);
}
.tut-sidebar__links {
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 4px 0 8px 18px;
}
.tut-sidebar__chapter.is-open > .tut-sidebar__links {
  display: flex;
}
.tut-sidebar__links a {
  display: block;
  padding: 6px 12px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--ink-soft);
  border-left: 3px solid transparent;
  transition: .15s;
  text-decoration: none;
}
.tut-sidebar__links a:hover {
  background: rgba(58,167,179,.1);
  color: var(--sea-deep);
}
.tut-sidebar__links a.is-active {
  background: linear-gradient(90deg, #fff3e2, transparent);
  color: var(--coral-deep);
  border-left-color: var(--coral);
  font-weight: 700;
}
.tut-sidebar__back {
  display: block;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px dashed #e9d4a6;
  font-weight: 700;
  font-size: 14px;
  color: var(--sea-deep);
  text-decoration: none;
}
.tut-sidebar__back:hover { color: var(--coral-deep); }

/* ---- Content area ---- */
.tut-content {
  min-width: 0;
}
.tut-article {
  background: var(--paper);
  border: 1px solid #fff;
  border-radius: var(--radius-md);
  padding: 36px 40px;
  box-shadow: var(--shadow-card);
}
.tut-article h1 {
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--ink);
  line-height: 1.2;
}
.tut-article .tut-subtitle {
  font-size: 17px;
  color: var(--ink-soft);
  margin-bottom: 28px;
  line-height: 1.5;
}
.tut-article h2 {
  font-size: 24px;
  font-weight: 800;
  margin: 36px 0 14px;
  padding-bottom: 8px;
  border-bottom: 2px dashed #f0d9ad;
  color: var(--ink);
}
.tut-article h3 {
  font-size: 20px;
  font-weight: 700;
  margin: 28px 0 10px;
  color: var(--sea-deep);
}
.tut-article p {
  font-size: 16px;
  line-height: 1.7;
  margin-bottom: 16px;
  color: var(--ink);
}
.tut-article ul, .tut-article ol {
  margin: 8px 0 16px;
  padding-left: 24px;
}
.tut-article li {
  font-size: 15.5px;
  line-height: 1.6;
  margin-bottom: 8px;
  color: var(--ink);
}
.tut-article strong { color: var(--coral-deep); }
.tut-article em { color: var(--sea-deep); font-style: normal; font-weight: 700; }
.tut-article a { color: var(--sea-deep); font-weight: 700; text-decoration: underline; }
.tut-article a:hover { color: var(--coral-deep); }

/* inline code */
.tut-article code {
  background: #fdeccb;
  color: var(--coco-deep);
  padding: 2px 7px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 600;
}

/* code blocks */
.tut-code {
  background: #1e1e2e;
  border-radius: var(--radius-sm);
  padding: 18px 20px;
  overflow-x: auto;
  margin: 12px 0 20px;
  box-shadow: 0 14px 30px -16px rgba(0,0,0,.5), var(--inset-top);
  border: 1px solid #3a4753;
  position: relative;
}
.tut-code code {
  display: block;
  white-space: pre;
  background: none;
  color: #cdd6f4;
  font-size: 13.5px;
  line-height: 1.75;
  padding: 0;
  border-radius: 0;
  font-weight: 400;
}
.tut-code .code-label {
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 11px;
  font-weight: 700;
  color: #6c7086;
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* syntax colors (simple) */
.tut-code .kw { color: #cba6f7; }
.tut-code .fn { color: #89b4fa; }
.tut-code .str { color: #a6e3a1; }
.tut-code .cmt { color: #6c7086; font-style: italic; }
.tut-code .num { color: #fab387; }
.tut-code .op { color: #89dceb; }
.tut-code .var { color: #f5c2e7; }

/* callout boxes */
.tut-callout {
  margin: 20px 0;
  padding: 16px 20px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  line-height: 1.6;
}
.tut-callout--info {
  background: #eaf6f7;
  border-left: 4px solid var(--sea-deep);
}
.tut-callout--warn {
  background: #fff8e6;
  border-left: 4px solid #d6a94c;
}
.tut-callout--danger {
  background: #fff0ee;
  border-left: 4px solid var(--coral);
}
.tut-callout strong { display: block; margin-bottom: 4px; }

/* comparison table / side by side */
.tut-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 16px 0 24px;
}
.tut-compare > div {
  background: #f8f4ee;
  border: 1px solid #f0d9ad;
  border-radius: var(--radius-sm);
  padding: 16px;
}
.tut-compare > div h4 {
  font-size: 15px;
  margin-bottom: 10px;
  color: var(--sea-deep);
}

/* symbol table */
.tut-symbol-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 16px 0 24px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: 0 6px 16px -10px rgba(95,60,29,.4);
  border: 1px solid #f0d9ad;
}
.tut-symbol-table th {
  background: linear-gradient(180deg, #fff6e6, #f8e3bf);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  color: var(--coco-deep);
  text-align: left;
  padding: 12px 14px;
  border-bottom: 2px solid var(--sand-line);
}
.tut-symbol-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #f1e3c6;
  font-size: 14.5px;
  vertical-align: top;
}
.tut-symbol-table tbody tr:nth-child(odd) { background: rgba(248,227,191,.3); }
.tut-symbol-table tbody tr:last-child td { border-bottom: none; }

/* Formula display */
.tut-formula {
  margin: 20px 0;
  padding: 20px;
  background: #fff8ec;
  border: 1px solid #f0d9ad;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  text-align: center;
}

/* Interactive sections */
.tut-interactive {
  margin: 24px 0;
  padding: 24px;
  background: linear-gradient(180deg, #fff, #fffaf0);
  border: 2px solid var(--sea-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
}
.tut-interactive h4 {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--sea-deep);
  margin-bottom: 16px;
}

/* Sliders */
.tut-slider-group {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.tut-slider-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tut-slider-item label {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
}
.tut-slider-item input[type="range"] {
  width: 100%;
  accent-color: var(--sea);
}
.tut-slider-item .slider-val {
  font-size: 12px;
  font-weight: 800;
  color: var(--sea-deep);
  font-family: var(--font-display);
}

/* Metric cards */
.tut-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 16px 0;
}
.tut-metric {
  background: linear-gradient(180deg, #fff, #f8f4ee);
  border: 1px solid #f0d9ad;
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
}
.tut-metric__value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  color: var(--sea-deep);
}
.tut-metric__label {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
  margin-top: 2px;
}

/* Toggle buttons */
.tut-toggle-group {
  display: inline-flex;
  background: linear-gradient(180deg, #f3dcaf, #e7c98f);
  border-radius: 999px;
  padding: 3px;
  box-shadow: inset 0 2px 4px rgba(95,60,29,.35), 0 1px 0 rgba(255,255,255,.6);
  margin-bottom: 16px;
}
.tut-toggle-btn {
  border: none;
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 14px;
  color: var(--coco-deep);
  background: transparent;
  padding: 8px 16px;
  border-radius: 999px;
  line-height: 1;
  transition: .16s;
}
.tut-toggle-btn.is-active {
  background: linear-gradient(180deg, #fff, #fff3da);
  color: var(--coral-deep);
  box-shadow: var(--inset-top), 0 3px 7px -3px rgba(95,60,29,.5);
}

/* Model selector */
.tut-select {
  padding: 8px 14px;
  border: 1px solid var(--sand-line);
  border-radius: 10px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

/* Chart container */
.tut-chart-wrap {
  margin: 20px 0;
  padding: 16px;
  background: #fff;
  border: 1px solid #f0d9ad;
  border-radius: var(--radius-sm);
}
.tut-chart-wrap canvas {
  width: 100% !important;
  max-height: 320px;
}

/* Cache bar visualization */
.cache-bar {
  display: flex;
  height: 40px;
  border-radius: 8px;
  overflow: hidden;
  margin: 12px 0;
  box-shadow: inset 0 2px 4px rgba(0,0,0,.1);
}
.cache-bar__hit {
  background: linear-gradient(180deg, #6ee7a8, #34d399);
  transition: width .3s;
}
.cache-bar__miss {
  background: linear-gradient(180deg, #fde047, #facc15);
  transition: width .3s;
}
.cache-bar__discard {
  background: linear-gradient(180deg, #d4d4d8, #a1a1aa);
  transition: width .3s;
}
.cache-bar-legend {
  display: flex;
  gap: 16px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
  margin-top: 6px;
}
.cache-bar-legend span::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  margin-right: 5px;
  vertical-align: middle;
}
.cache-bar-legend .legend-hit::before { background: #34d399; }
.cache-bar-legend .legend-miss::before { background: #facc15; }
.cache-bar-legend .legend-discard::before { background: #a1a1aa; }

/* Navigation footer */
.tut-nav-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 2px dashed #f0d9ad;
}
.tut-nav-footer a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  color: var(--sea-deep);
  background: linear-gradient(180deg, #fff, #fff8ec);
  border: 1px solid #bfe7e6;
  box-shadow: var(--shadow-soft);
  text-decoration: none;
  transition: .15s;
}
.tut-nav-footer a:hover {
  color: var(--coral-deep);
  border-color: var(--coral);
  transform: translateY(-2px);
}

/* Bilingual content toggle */
[data-lang-content="en"], [data-lang-content="zh"] {
  display: none;
}
[data-lang-content="en"].is-visible,
[data-lang-content="zh"].is-visible {
  display: block;
}

/* Tutorial index page cards */
.tut-chapter-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  margin: 24px 0;
}
.tut-chapter-card {
  background: var(--paper);
  border: 1px solid #fff;
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-card);
  transition: transform .2s, box-shadow .2s;
}
.tut-chapter-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 22px 44px -16px rgba(95,60,29,.4);
}
.tut-chapter-card h3 {
  font-size: 20px;
  margin-bottom: 8px;
}
.tut-chapter-card p {
  font-size: 14.5px;
  color: var(--ink-soft);
  margin-bottom: 12px;
}
.tut-chapter-card ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.tut-chapter-card li {
  padding: 6px 0;
  border-top: 1px dashed #e9d4a6;
}
.tut-chapter-card li:first-child { border-top: none; }
.tut-chapter-card li a {
  font-size: 14px;
  font-weight: 700;
  color: var(--sea-deep);
  text-decoration: none;
}
.tut-chapter-card li a:hover { color: var(--coral-deep); }
.tut-chapter-card .badge-stub {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e7c98f;
  color: var(--coco-deep);
  margin-left: 6px;
}

/* KaTeX overrides */
.katex-display {
  margin: 16px 0 !important;
  overflow-x: auto;
  overflow-y: hidden;
}

/* ---- Tip / try-it-out box (HF-course style) ---- */
.tut-callout--tip {
  background: linear-gradient(180deg, #eefaf3, #e2f6ea);
  border-left: 4px solid var(--palm);
}
.tut-callout--tip strong { color: var(--palm-deep); }
.tut-callout--key {
  background: linear-gradient(180deg, #fff6e6, #ffeecd);
  border-left: 4px solid var(--sun);
}
.tut-callout--key strong { color: var(--coco-deep); }

/* ---- Output blocks (code → output → explanation) ---- */
.tut-code--output {
  background: #14141f;
  border-color: #2b3540;
  box-shadow: 0 10px 22px -16px rgba(0,0,0,.5);
}
.tut-code--output code { color: #b9c2d0; }
.tut-code--output .code-label { color: #8b93a7; }
.tut-code--error { border-color: #7a3b34; }
.tut-code--error code { color: #f5a49a; }
.tut-io-label {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: #f3e6cd;
  border-radius: 999px;
  padding: 3px 12px;
  margin: 14px 0 -4px;
}

/* ---- Token sequence chips (prefix-match visual) ---- */
.tok-seq {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin: 10px 0;
  padding: 12px 14px;
  background: #fffaf0;
  border: 1px dashed #e9d4a6;
  border-radius: var(--radius-sm);
}
.tok {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  padding: 5px 10px;
  border-radius: 8px;
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 800;
  border: 1px solid rgba(0,0,0,.08);
}
.tok--hit    { background: #cdf3e0; color: #1f7d52; }
.tok--new    { background: #fdeeb8; color: #8a6414; }
.tok--drop   { background: #e7e5e4; color: #78716c; text-decoration: line-through; }
.tok--broken { background: #ffdcd4; color: #b8452c; }
.tok-arrow { color: var(--ink-soft); font-weight: 800; padding: 0 2px; }
.tok-turn-label {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--ink-soft);
  font-family: var(--font-display);
  min-width: 62px;
}
.tok-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-soft);
  margin: 4px 0 18px;
}
.tok-legend span::before {
  content: "";
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 3px;
  margin-right: 5px;
  vertical-align: middle;
}
.tok-legend .lg-hit::before    { background: #6ee7a8; }
.tok-legend .lg-new::before    { background: #facc15; }
.tok-legend .lg-drop::before   { background: #a1a1aa; }
.tok-legend .lg-broken::before { background: #ff7a5c; }

/* ---- Numbered step list ---- */
.tut-article ol.tut-steps { counter-reset: step; list-style: none; padding-left: 0; }
.tut-article ol.tut-steps > li {
  counter-increment: step;
  position: relative;
  padding: 2px 0 2px 42px;
  margin-bottom: 12px;
}
.tut-article ol.tut-steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0; top: 0;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--sea-light), var(--sea));
  color: #fff;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 14px;
  box-shadow: var(--inset-top), 0 3px 7px -3px rgba(19,103,114,.6);
}

/* ---- Worked example box ---- */
.tut-worked {
  margin: 18px 0 24px;
  padding: 18px 20px;
  background: #fffdf8;
  border: 1px solid #f0d9ad;
  border-left: 4px solid var(--sea);
  border-radius: var(--radius-sm);
}
.tut-worked h4 {
  font-size: 16px;
  color: var(--sea-deep);
  margin-bottom: 10px;
}
.tut-worked table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.tut-worked td { padding: 6px 4px; border-bottom: 1px dashed #f1e3c6; }
.tut-worked td:last-child { text-align: right; font-weight: 800; color: var(--coco-deep); white-space: nowrap; }
.tut-worked tr:last-child td { border-bottom: none; border-top: 2px solid #e9d4a6; color: var(--coral-deep); }

/* ---- Inline bilingual spans (inside buttons, labels, table cells) ---- */
span[data-lang-content].is-visible,
label[data-lang-content].is-visible,
td[data-lang-content].is-visible,
th[data-lang-content].is-visible { display: inline; }
div.tut-metric__label[data-lang-content].is-visible { display: block; }
div.cache-bar-legend[data-lang-content].is-visible { display: flex; }

/* Responsive */
@media (max-width: 980px) {
  .tutorial-shell {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .tut-sidebar__inner {
    position: static;
    max-height: none;
  }
  .tut-compare {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 640px) {
  .tutorial-shell {
    padding: 16px 12px 40px;
  }
  .tut-article {
    padding: 22px 18px;
  }
  .tut-article h1 { font-size: 26px; }
  .tut-slider-group {
    grid-template-columns: 1fr;
  }
  .tut-metrics {
    grid-template-columns: 1fr;
  }
  .tut-nav-footer {
    flex-direction: column;
    gap: 12px;
  }
}
