/* Components. Layout mirrors the sibling course sites (studyMLBasic):
   left nav · middle content · right dark "실행 결과" terminal. Tokens only. */

/* ================================================================ Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  border-radius: 8px;
  padding: 6px 12px;
  min-height: 34px;
  cursor: pointer;
  font-weight: var(--weight-medium);
  font-size: var(--text-sm);
  white-space: nowrap;
  text-decoration: none;
  transition: background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast);
}

.btn:hover {
  border-color: var(--color-accent);
}

.btn.small {
  padding: 3px 9px;
  min-height: 28px;
  font-size: var(--text-xs);
  border-radius: 7px;
}

.btn.ghost {
  background: transparent;
}

.btn.primary {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-accent-contrast);
}

.btn.primary:hover {
  filter: brightness(1.07);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
}

.icon-btn:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.icon-btn[aria-pressed="true"] {
  background: var(--color-accent-soft);
  color: var(--color-accent);
}

/* ================================================================ Layout */
.layout {
  display: grid;
  grid-template-columns: var(--nav-w) 5px minmax(360px, 1fr) 5px var(--out-w);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.layout.nav-collapsed {
  grid-template-columns: 0 0 minmax(360px, 1fr) 5px var(--out-w);
}

.layout.nav-collapsed .nav {
  visibility: hidden;
}

.pane {
  min-width: 0;
  min-height: 0;
  background: var(--color-pane);
}

.gutter {
  cursor: col-resize;
  background: var(--color-border);
  opacity: 0.6;
  touch-action: none;
}

.gutter:hover,
.gutter.drag {
  background: var(--color-accent);
  opacity: 1;
}

/* ================================================================ Left nav */
.nav {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--color-border);
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 10px 10px 14px;
}

.brand-logo {
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--gradient-brand);
  box-shadow: 0 2px 8px rgb(231 111 0 / 0.35);
  font-size: 21px;
  text-decoration: none;
}

.brand-text {
  flex: 1;
  min-width: 0;
}

.brand-title {
  display: block;
  font-weight: var(--weight-heavy);
  font-size: 16.5px;
  letter-spacing: -0.01em;
  color: var(--color-text);
  text-decoration: none;
}

.brand-sub {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.role-switch,
.view-switch {
  display: flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--color-border);
  border-radius: 9px;
  background: var(--color-surface-2);
}

.role-switch {
  margin: 2px 12px 10px;
}

.role-switch a,
.view-switch a {
  flex: 1;
  padding: 5px 8px;
  border-radius: 7px;
  color: var(--color-text-muted);
  font-weight: var(--weight-bold);
  font-size: 13px;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
}

.view-switch a {
  flex: none;
  padding: 3px 10px;
  font-size: var(--text-xs);
}

.role-switch a[aria-current="page"],
.view-switch a[aria-current="page"] {
  background: var(--color-pane);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}

.role-switch a[data-role="student"][aria-current="page"] {
  color: var(--color-accent);
}

.role-switch a[data-role="teacher"][aria-current="page"] {
  color: var(--color-accent2);
}

.progress-wrap {
  padding: 0 14px 8px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: var(--weight-medium);
}

.progress {
  height: 6px;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface-2);
}

.progress-fill {
  height: 100%;
  width: 0;
  background: var(--gradient-progress);
  transition: width 0.3s;
}

.nav-search {
  margin: 4px 12px 8px;
  padding: 7px 10px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface-2);
  outline: none;
}

.nav-search:focus {
  border-color: var(--color-accent);
}

.nav-tree {
  flex: 1;
  overflow-y: auto;
  padding: 2px 8px 16px;
}

.nav-home {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--color-text);
  font-weight: var(--weight-bold);
  font-size: 14px;
  text-decoration: none;
}

.nav-home:hover {
  background: var(--color-surface-2);
}

.nav-home[aria-current="page"] {
  background: var(--color-accent-soft);
  color: var(--color-accent);
}

.nav-part {
  margin: 14px 10px 4px;
  font-size: 11.5px;
  font-weight: var(--weight-heavy);
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.nav-ch {
  margin-top: 2px;
}

.nav-ch-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 8px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--color-text);
  font-weight: var(--weight-bold);
  font-size: 14px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.nav-ch-head:hover {
  background: var(--color-surface-2);
}

.nav-ch-head .no {
  min-width: 38px;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--color-accent-soft);
  color: var(--color-accent);
  font: 700 11.5px var(--font-mono);
  text-align: center;
}

.nav-ch-head .t {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-ch-head .pending,
.nav-ch-head .caret {
  font-size: 11px;
  font-weight: var(--weight-regular);
  color: var(--color-text-muted);
}

.nav-ch-head .done {
  color: var(--color-success);
  font-size: 12px;
}

.nav-ch.is-current > .nav-ch-head {
  color: var(--color-accent);
}

.nav-ch.is-disabled > .nav-ch-head {
  cursor: default;
  color: var(--color-text-muted);
}

.nav-ch.is-disabled > .nav-ch-head:hover {
  background: none;
}

.nav-ch.is-disabled .no {
  background: var(--color-surface-2);
  color: var(--color-text-muted);
}

.nav-secs {
  margin: 0 0 6px 20px;
  padding: 2px 0 2px 14px;
  border-left: 1px dashed var(--color-border);
  list-style: none;
}

.nav-sec {
  display: flex;
  gap: 6px;
  width: 100%;
  padding: 5px 8px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--color-text);
  font-size: var(--text-sm);
  line-height: 1.45;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.nav-sec:hover {
  background: var(--color-surface-2);
}

.nav-sec[aria-current="true"] {
  background: var(--color-accent-soft);
  color: var(--color-accent);
  font-weight: var(--weight-bold);
}

.nav-sec .chk {
  flex: none;
  width: 18px;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: 11.5px;
  margin-top: 1px;
}

.nav-empty {
  padding: 10px;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.nav-foot {
  border-top: 1px solid var(--color-border);
  padding: 8px 10px;
}

.env-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface-2);
  font-size: 12.5px;
  font-weight: var(--weight-medium);
}

.env-badge .dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--color-warning);
}

.env-badge.ok .dot {
  background: var(--color-success);
  box-shadow: 0 0 0 3px var(--color-success-soft);
}

/* ================================================================ Center */
.center {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--color-bg);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  min-height: var(--topbar-h);
  padding: 7px 12px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-pane);
}

.topbar .nav-open {
  display: none;
}

.layout.nav-collapsed .topbar .nav-open {
  display: inline-grid;
}

.crumb {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.crumb b {
  color: var(--color-text);
}

.content {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
  outline: none;
}

/* ================================================================ Document */
.doc {
  max-width: var(--doc-w);
  margin: 0 auto;
  padding: 28px 34px 80px;
}

.doc h1 {
  margin: 6px 0 10px;
  font-size: var(--text-2xl);
  letter-spacing: -0.02em;
}

.doc h2 {
  margin: 36px 0 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--color-border);
  font-size: var(--text-xl);
}

.doc h2 .section-num {
  margin-right: 8px;
  color: var(--color-accent);
  font-family: var(--font-mono);
  font-size: 0.85em;
}

.doc h2 .section-num::after {
  content: ".";
}

.doc h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 28px 0 8px;
  font-size: 18.5px;
}

.doc h3::before {
  content: "";
  flex: none;
  width: 5px;
  height: 18px;
  border-radius: 3px;
  background: var(--color-accent);
}

.doc h4 {
  margin: 18px 0 8px;
  font-size: var(--text-md);
}

.doc p {
  margin: 8px 0;
}

.doc ul,
.doc ol {
  margin: 8px 0;
  padding-left: 24px;
}

.doc li {
  margin: 3px 0;
}

.doc li::marker {
  color: var(--color-accent);
}

.doc :not(pre) > code {
  padding: 0 5px;
  border: 1px solid var(--color-border);
  border-radius: 5px;
  background: var(--color-surface-2);
  color: var(--color-code-def);
  font-size: 0.88em;
}

.doc pre {
  padding: 12px 16px;
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-code-bg);
  color: var(--color-code-fg);
  font-size: var(--text-sm);
  line-height: 1.6;
}

.doc table {
  width: 100%;
  margin: 12px 0;
  overflow: hidden;
  border-collapse: collapse;
  border-radius: 8px;
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
  font-size: 14px;
}

.doc th,
.doc td {
  padding: 7px 10px;
  border: 1px solid var(--color-border);
  text-align: left;
  vertical-align: top;
}

.doc th {
  background: var(--color-surface-2);
  font-weight: var(--weight-bold);
}

.chapter-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 12px;
  border-radius: 20px;
  background: var(--color-accent-soft);
  color: var(--color-accent);
  font-weight: var(--weight-bold);
  font-size: 13px;
}

.lead {
  font-size: var(--text-lg);
  color: var(--color-text-muted);
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 4px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border: 1px solid var(--color-border);
  border-radius: 20px;
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: 12.5px;
  font-weight: var(--weight-medium);
  white-space: nowrap;
}

.chip.ok {
  border-color: transparent;
  background: var(--color-success-soft);
  color: var(--color-success);
}

.chip.accent {
  border-color: transparent;
  background: var(--color-accent-soft);
  color: var(--color-accent);
}

.chip.warn {
  border-color: transparent;
  background: var(--color-warning-soft);
  color: var(--color-warning);
}

.goals {
  margin: 16px 0;
  padding: 12px 18px;
  border: 1px solid var(--color-border);
  border-left: 5px solid var(--color-accent2);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.goals b {
  color: var(--color-accent2);
}

.goals ul {
  margin: 6px 0 0;
}

.flow {
  display: flex;
  margin: 10px 0;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: 8px;
}

.flow div {
  flex: 1;
  padding: 5px 8px;
  border-right: 1px solid var(--color-border);
  background: var(--color-surface-2);
  font-size: 12.5px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.flow div:last-child {
  border-right: 0;
}

.flow b {
  color: var(--color-accent2);
}

/* Callouts */
.callout {
  margin: 16px 0;
  padding: 12px 16px;
  border: 1px solid var(--color-border);
  border-left: 5px solid var(--color-accent2);
  border-radius: var(--radius-md);
  background: var(--color-accent2-soft);
}

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

.callout p:first-of-type {
  margin-top: 0;
}

.callout__title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  color: var(--color-accent2);
  font-weight: var(--weight-heavy);
}

.callout--ok {
  border-left-color: var(--color-success);
  background: var(--color-success-soft);
}

.callout--ok .callout__title {
  color: var(--color-success);
}

.callout--danger {
  border-left-color: var(--color-danger);
  background: var(--color-danger-soft);
}

.callout--danger .callout__title {
  color: var(--color-danger);
}

.callout--more {
  border-left-color: var(--color-more);
  background: var(--color-more-soft);
}

.callout--more .callout__title {
  color: var(--color-more);
}

/* Figures */
.figure {
  margin: 18px 0;
  padding: 16px;
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.figure svg {
  display: block;
  width: 100%;
  height: auto;
  font-family: var(--font-sans);
}

.figure figcaption {
  margin-top: 8px;
  color: var(--color-text-muted);
  font-size: 12.5px;
  text-align: center;
}

/* Practice (Challenge) cards */
.practice {
  margin: 16px 0;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.practice-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-accent-soft);
}

.practice-head b {
  flex: 1;
  min-width: 180px;
  font-size: var(--text-md);
}

.level {
  color: var(--color-accent);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: 1px;
}

.practice-body {
  padding: 10px 16px 14px;
}

.practice-body > p:first-child {
  margin-top: 0;
}

/* Code runner = MLBasic-style code block with ▶ 실행 */
.code-block {
  margin: 12px 0 0;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-code-bg);
}

.code-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 10px 6px 14px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}

.code-head .t {
  flex: 1;
  min-width: 140px;
  font-weight: var(--weight-bold);
  font-size: var(--text-sm);
}

.code-head .tag {
  margin-right: 6px;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--color-accent2-soft);
  color: var(--color-accent2);
  font: 600 11px var(--font-mono);
  vertical-align: 1px;
}

.code-block textarea {
  display: block;
  width: 100%;
  padding: 12px 16px;
  border: 0;
  resize: vertical;
  background: transparent;
  color: var(--color-code-fg);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.6;
  tab-size: 2;
  white-space: pre;
  overflow-x: auto;
}

.code-block textarea:focus-visible {
  box-shadow: inset var(--focus-ring);
  border-radius: 0;
}

.code-inline-out {
  border-top: 1px solid var(--term-line);
  background: var(--term-bg);
  color: var(--term-fg);
  padding: 10px 14px;
  font: 13px/1.55 var(--font-mono);
  white-space: pre-wrap;
  word-break: break-all;
}

.code-inline-out:empty {
  display: none;
}

/* Section end + prev/next */
.section-end {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 36px;
  padding: 18px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.done-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 36px;
  cursor: pointer;
  font-weight: var(--weight-medium);
}

.done-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--color-success);
}

.week-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.week-nav a,
.week-nav span {
  display: block;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-surface);
  color: var(--color-text);
  font-weight: var(--weight-bold);
  font-size: 14px;
  text-decoration: none;
}

.week-nav a:hover {
  border-color: var(--color-accent);
}

.week-nav small {
  display: block;
  color: var(--color-text-muted);
  font-weight: var(--weight-regular);
  font-size: var(--text-xs);
}

.week-nav .next {
  grid-column: 2;
  text-align: right;
}

.week-nav span {
  color: var(--color-text-muted);
  font-weight: var(--weight-regular);
}

/* ================================================================ Home */
.hero {
  position: relative;
  overflow: hidden;
  margin-bottom: 20px;
  padding: 30px 32px;
  border-radius: 16px;
  background: var(--gradient-hero);
  color: var(--hero-fg);
}

.hero h1 {
  margin: 0 0 6px;
  font-size: var(--text-3xl);
}

.hero p {
  margin: 4px 0;
  opacity: 0.95;
}

.hero .hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.hero .btn {
  border-color: transparent;
  background: rgb(255 255 255 / 0.95);
  color: #1d2433;
}

.hero .btn.outline {
  border-color: rgb(255 255 255 / 0.7);
  background: transparent;
  color: var(--hero-fg);
}

.hero .deco {
  position: absolute;
  right: 26px;
  bottom: -16px;
  font-size: 120px;
  opacity: 0.25;
  pointer-events: none;
}

.part-title {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
}

.part-title small {
  color: var(--color-text-muted);
  font-size: 13.5px;
  font-weight: var(--weight-regular);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  gap: 12px;
  margin: 14px 0;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
  color: inherit;
  text-decoration: none;
  transition: transform var(--dur-fast), border-color var(--dur-fast);
}

a.card:hover {
  transform: translateY(-2px);
  border-color: var(--color-accent);
}

.card .ci {
  font-size: 24px;
}

.card .cn {
  color: var(--color-accent);
  font: 700 12px var(--font-mono);
}

.card .ct {
  font-weight: var(--weight-heavy);
  font-size: 16px;
}

.card .cs {
  color: var(--color-text-muted);
  font-size: 13px;
}

.card .cp {
  height: 4px;
  margin-top: 6px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--color-surface-2);
}

.card .cp i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--color-success);
}

.card.disabled {
  opacity: 0.55;
}

/* Course series pathway (same component as the sibling course sites) */
.pathway {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}

.pathway .card {
  position: relative;
}

.pathway .card:not(:last-child)::after {
  content: "→";
  position: absolute;
  top: 50%;
  right: -12px;
  transform: translate(50%, -50%);
  color: var(--color-text-muted);
  font-weight: var(--weight-bold);
}

.pathway .card.is-here {
  border: 2px solid var(--color-accent);
  background: var(--color-accent-soft);
}

.pathway .card .cn {
  color: var(--color-text-muted);
}

.pathway .card.is-here .cn {
  color: var(--color-accent);
}

/* 여섯 과정 학습 경로 (… → RAG → AI 에이전트 → 온톨로지): 가운데 칸 폭에 맞춰 줄바꿈, 순서는 ①~⑥ 번호로 */
.pathway.path-5 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.pathway.path-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 700px) { .pathway.path-6 { grid-template-columns: 1fr 1fr; } }
.pathway.path-5 .card:not(:last-child)::after, .pathway.path-6 .card:not(:last-child)::after { content: none; }

.steps {
  counter-reset: step;
  list-style: none;
  padding: 0 !important;
}

.steps li {
  counter-increment: step;
  position: relative;
  margin: 10px 0;
  padding-left: 38px;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--color-accent);
  color: var(--color-accent-contrast);
  font-weight: var(--weight-heavy);
  font-size: 13px;
}

/* ================================================================ Right: terminal */
.output {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--color-border);
  background: var(--term-bg);
}

.console-panel {
  --c-font: 13.5px;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  background: var(--term-bg);
  color: var(--term-fg);
}

.console-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--term-line);
  background: var(--term-head);
}

.console-dots {
  display: flex;
  gap: 6px;
}

.console-dots i {
  display: block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--term-dot-1);
}

.console-dots i:nth-child(2) {
  background: var(--term-dot-2);
}

.console-dots i:nth-child(3) {
  background: var(--term-dot-3);
}

.console-title {
  overflow: hidden;
  color: var(--term-title);
  font-weight: var(--weight-bold);
  font-size: var(--text-sm);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.console-title .muted {
  color: var(--term-muted);
  font-weight: var(--weight-regular);
}

.run-state {
  padding: 2px 9px;
  border-radius: 20px;
  background: var(--term-line);
  color: var(--term-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  white-space: nowrap;
}

.run-state.running {
  background: var(--term-ok-bg);
  color: var(--term-ok);
}

.run-state.error {
  background: var(--term-err-bg);
  color: var(--term-err);
}

.run-state.done {
  background: var(--term-done-bg);
  color: var(--term-sys);
}

.console-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--term-line);
  background: var(--term-tools);
  color: var(--term-muted);
  font-size: var(--text-xs);
}

.console-tools .btn {
  border-color: var(--term-border);
  background: transparent;
  color: var(--term-fg);
}

.console-tools .btn:hover {
  border-color: var(--term-sys);
}

.console {
  flex: 1;
  overflow: auto;
  padding: 12px 14px;
  font: var(--c-font) / 1.55 var(--font-mono);
  white-space: pre-wrap;
  word-break: break-all;
}

.console .o {
  color: var(--term-fg);
}

.console .e {
  color: var(--term-err);
}

.console .w {
  color: var(--term-warn);
}

.console .s {
  color: var(--term-sys);
}

.console .m {
  color: var(--term-muted);
}

.console .ok {
  color: var(--term-ok);
}

.run-sep {
  display: block;
  margin: 10px 0 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--term-border);
  color: var(--term-muted);
  font-family: var(--font-sans);
  font-size: var(--text-xs);
}

.run-sep:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.console table,
.code-inline-out table {
  margin: 6px 0 10px;
  border-collapse: collapse;
  color: var(--term-fg);
  font-size: 12px;
  white-space: nowrap;
}

.console th,
.console td,
.code-inline-out th,
.code-inline-out td {
  padding: 3px 8px;
  border: 1px solid var(--term-line);
  text-align: right;
}

.console th,
.code-inline-out th {
  background: var(--term-head);
  color: var(--term-sys);
}

.console-welcome {
  padding: 40px 16px;
  color: var(--term-muted);
  font-family: var(--font-sans);
  text-align: center;
  white-space: normal;
}

.console-welcome .cw-icon {
  margin-bottom: 8px;
  color: var(--term-ok);
  font: 700 34px var(--font-mono);
}

.console-welcome b {
  color: var(--term-title);
}

.console-welcome kbd {
  border-color: var(--term-border);
  background: var(--term-head);
  color: var(--term-title);
}

.console-status {
  display: flex;
  gap: 8px;
  padding: 4px 12px;
  border-top: 1px solid var(--term-line);
  background: var(--term-head);
  color: var(--term-muted);
  font-size: var(--text-xs);
}

/* Live widget output pinned inside the terminal: page-themed card, like a plot */
.rich-widget {
  display: block;
  margin: 0 0 12px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--color-surface);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: var(--leading-body);
  white-space: normal;
  word-break: keep-all;
  box-shadow: 0 2px 10px rgb(0 0 0 / 0.35);
}

.rich-widget__head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
}

.rich-widget__head::before {
  content: "LIVE";
  padding: 0 6px;
  border-radius: 4px;
  background: var(--color-success);
  color: var(--color-pane);
  font-size: 10px;
  letter-spacing: 0.05em;
}

.rich-widget__body {
  padding: 10px 12px;
}

.rich-widget.is-flash {
  box-shadow: 0 0 0 2px var(--term-sys);
}

/* ================================================================ Widgets (demo) */
.widget {
  margin: 18px 0;
  padding: 14px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.widget__title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  font-size: var(--text-md);
  font-weight: var(--weight-heavy);
}

.doc .widget__title::before,
.widget__title::before {
  content: "▶ 체험";
  width: auto;
  height: auto;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--color-accent);
  color: var(--color-accent-contrast);
  font-size: 11.5px;
  font-weight: var(--weight-bold);
}

.widget__controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  gap: var(--space-3) var(--space-4);
  margin-bottom: var(--space-3);
}

.field {
  display: grid;
  gap: var(--space-1);
  font-size: var(--text-sm);
}

.field__label {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  font-weight: var(--weight-medium);
}

.field__label output {
  padding: 0 8px;
  border-radius: 6px;
  background: var(--color-surface-2);
  color: var(--color-text);
  font-family: var(--font-mono);
  font-size: 13px;
}

.field select,
.field input[type="text"],
.field input[type="password"],
.field textarea {
  width: 100%;
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface-2);
}

.field textarea {
  min-height: 140px;
  resize: vertical;
  line-height: 1.6;
}

.field input[type="range"] {
  width: 100%;
  min-height: 28px;
  accent-color: var(--color-accent);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.widget details {
  margin-top: 10px;
}

.widget summary {
  cursor: pointer;
  color: var(--color-accent2);
  font-weight: var(--weight-bold);
  font-size: var(--text-sm);
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 6px;
  margin: 10px 0;
}

.stat {
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--color-surface-2);
}

.stat__label {
  display: block;
  color: var(--color-text-muted);
  font-size: 11.5px;
}

.stat__value {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: var(--weight-bold);
}

.widget__status {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 24px;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.widget__error {
  padding: 10px 14px;
  border-left: 4px solid var(--color-danger);
  border-radius: var(--radius-sm);
  background: var(--color-danger-soft);
  font-size: var(--text-sm);
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.bar-progress {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--color-surface-2);
}

.bar-progress__fill {
  height: 100%;
  width: 0;
  background: var(--color-accent);
  transition: width var(--dur-med);
}

/* Chunk view (w04) */
.chunk-view {
  max-height: 380px;
  overflow-y: auto;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg);
  font-size: var(--text-sm);
  line-height: 2;
  white-space: pre-wrap;
}

.chunk-view .seg {
  padding: 0.1em 0;
  border-radius: 3px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.chunk-view .c0 { background: var(--chunk-1); }
.chunk-view .c1 { background: var(--chunk-2); }
.chunk-view .c2 { background: var(--chunk-3); }
.chunk-view .c3 { background: var(--chunk-4); }
.chunk-view .c4 { background: var(--chunk-5); }
.chunk-view .c5 { background: var(--chunk-6); }
.chunk-view .ov { background: var(--chunk-overlap); }

.chunk-view .fact {
  text-decoration: underline wavy var(--color-danger);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 4px;
}

.chunk-view .boundary {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  margin: 0 1px;
  background: var(--color-text);
  vertical-align: -0.15em;
}

.chunk-list {
  display: grid;
  gap: 6px;
  max-height: 320px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.chunk-list li {
  margin: 0;
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-left-width: 6px;
  border-radius: 6px;
  background: var(--color-surface);
  font-size: 13px;
}

.chunk-list li.has-fact {
  border-color: var(--color-success);
}

.chunk-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 2px;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: 11.5px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 8px 0 6px;
  color: var(--color-text-muted);
  font-size: 11.5px;
}

.legend i {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 3px;
  border-radius: 3px;
  vertical-align: -1px;
}

.w04-out h4 {
  margin: 12px 0 6px;
  font-size: var(--text-sm);
}

.w04-out .callout {
  margin: 0 0 8px;
  padding: 8px 12px;
  font-size: 13px;
}

.badge-ok {
  padding: 0 6px;
  border-radius: 999px;
  background: var(--color-success-soft);
  color: var(--color-success);
}

/* ================================================================ Responsive */
@media (max-width: 1100px) {
  .layout {
    --nav-w: 250px;
    --out-w: 360px;
  }
}

/* Phones & small tablets: single column. Nav collapses behind ☰, the
   terminal is hidden and results render inline under their source. */
@media (max-width: 860px) {
  .layout,
  .layout.nav-collapsed {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    height: auto;
    overflow: visible;
  }
  .layout .gutter,
  .layout .output {
    display: none;
  }
  .nav {
    display: none;
    max-height: 70vh;
    border-right: 0;
    border-bottom: 1px solid var(--color-border);
  }
  .layout.nav-open .nav {
    display: flex;
    visibility: visible;
  }
  .topbar {
    position: sticky;
    top: 0;
    z-index: 5;
  }
  .topbar .nav-open {
    display: inline-grid;
  }
  .center {
    overflow: visible;
  }
  .content {
    overflow: visible;
  }
  .doc {
    padding: 20px 16px 60px;
  }
  /* wide tables and code scroll inside their own box instead of widening the page */
  .doc table,
  .widget table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
  }
  .doc pre,
  .doc figure,
  .doc .widget,
  .doc .practice,
  .doc .code-block {
    max-width: 100%;
    min-width: 0;
  }
  .doc pre {
    overflow-x: auto;
  }
  /* grid/flex children default to min-width:auto and refuse to shrink */
  .doc :where(div, section, article, details, li, figure, form, label) {
    min-width: 0;
  }
  .hero {
    padding: 22px 20px;
  }
  .hero .deco {
    display: none;
  }
  .flow {
    flex-wrap: wrap;
  }
  .pathway {
    grid-template-columns: 1fr;
  }
  .pathway .card:not(:last-child)::after {
    content: "↓";
    top: auto;
    right: 50%;
    bottom: -12px;
    transform: translate(50%, 50%);
  }
}

/* 일곱 과정 학습 경로 (⑦ 연결 과정 MLOps 추가) */
.pathway.path-7 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .pathway.path-7 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 700px) { .pathway.path-7 { grid-template-columns: 1fr 1fr; } }
.pathway.path-7 .card:not(:last-child)::after { content: none; }
