/* ==========================================================================
   파이썬 학습 워크북 — 디자인 토큰과 컴포넌트
   색은 파이썬 IDLE 편집기의 실제 구문 색을 기준으로 삼았다.
   ========================================================================== */

:root {
  /* 지면 */
  --paper: #f2f5f8;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --ink: #191d24;
  --ink-soft: #5a6675;
  --ink-faint: #8a95a3;
  --line: #dce3ea;
  --line-strong: #c3cdd8;

  /* 강조 (강의 슬라이드와 IDLE 키워드의 주황 계열) */
  --accent: #c2410c;
  --accent-hover: #9a3412;
  --accent-wash: #fdf0e7;
  --accent-line: #f0c9b1;

  /* 의미색 */
  --ok: #157a4a;
  --ok-wash: #e6f4ec;
  --ok-line: #a8d8bf;
  --bad: #b7362b;
  --bad-wash: #fdecea;
  --bad-line: #f0bdb7;
  --warn: #9a6206;
  --warn-wash: #fdf4e3;
  --warn-line: #ecd6a8;

  /* 코드 (IDLE 배색) */
  --code-bg: #fbfcfd;
  --code-ink: #1c2027;
  --code-keyword: #d2691e;
  --code-string: #0a7f2e;
  --code-comment: #b3261e;
  --code-builtin: #7b2d8b;
  --code-number: #1a5fb4;
  --code-def: #1447c4;
  --code-gutter: #a7b2c0;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(20, 30, 45, 0.06);
  --shadow: 0 6px 20px rgba(20, 30, 45, 0.1);

  /* 제목은 동글동글한 Jua, 본문은 읽기 편한 Gothic A1,
     요약과 힌트처럼 손으로 적어 둔 느낌이 어울리는 곳에는 Gaegu 를 쓴다. */
  --font-display: "Jua", "Gothic A1", "Malgun Gothic", sans-serif;
  --font-body: "Gothic A1", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  --font-hand: "Gaegu", "Gothic A1", cursive;
  --font-mono: "Nanum Gothic Coding", "D2Coding", "Consolas", "Menlo", monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #12151a;
    --surface: #1a1e25;
    --surface-2: #21262e;
    --ink: #e7ebf1;
    --ink-soft: #9aa6b5;
    --ink-faint: #6f7c8c;
    --line: #2b323b;
    --line-strong: #3c4552;

    --accent: #fb923c;
    --accent-hover: #fdba74;
    --accent-wash: #2a1b11;
    --accent-line: #54321d;

    --ok: #4ade80;
    --ok-wash: #14261c;
    --ok-line: #2c4a36;
    --bad: #f87171;
    --bad-wash: #2a1717;
    --bad-line: #4d2a2a;
    --warn: #fbbf24;
    --warn-wash: #2a2213;
    --warn-line: #4d3f1f;

    --code-bg: #161a20;
    --code-ink: #dfe5ec;
    --code-keyword: #ffab5e;
    --code-string: #6fd47f;
    --code-comment: #ff8d85;
    --code-builtin: #d79be0;
    --code-number: #7fb6f5;
    --code-def: #8ab4ff;
    --code-gutter: #4a5563;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  }
}

:root[data-theme="dark"] {
  --paper: #12151a;
  --surface: #1a1e25;
  --surface-2: #21262e;
  --ink: #e7ebf1;
  --ink-soft: #9aa6b5;
  --ink-faint: #6f7c8c;
  --line: #2b323b;
  --line-strong: #3c4552;

  --accent: #fb923c;
  --accent-hover: #fdba74;
  --accent-wash: #2a1b11;
  --accent-line: #54321d;

  --ok: #4ade80;
  --ok-wash: #14261c;
  --ok-line: #2c4a36;
  --bad: #f87171;
  --bad-wash: #2a1717;
  --bad-line: #4d2a2a;
  --warn: #fbbf24;
  --warn-wash: #2a2213;
  --warn-line: #4d3f1f;

  --code-bg: #161a20;
  --code-ink: #dfe5ec;
  --code-keyword: #ffab5e;
  --code-string: #6fd47f;
  --code-comment: #ff8d85;
  --code-builtin: #d79be0;
  --code-number: #7fb6f5;
  --code-def: #8ab4ff;
  --code-gutter: #4a5563;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.72;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { text-wrap: balance; margin: 0; }
p { margin: 0; }
a { color: var(--accent); }

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ---------- 상단 바 ---------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 22px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: baseline; gap: 10px; margin-right: auto; }

.brand-mark {
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: -0.5px;
}

.brand-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 400;
  letter-spacing: 0;
}

.brand-sub {
  font-size: 12px;
  color: var(--ink-faint);
  letter-spacing: 0.02em;
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  background: var(--surface);
  transition: border-color .15s, color .15s;
}
.icon-btn:hover { border-color: var(--line-strong); color: var(--ink); }

.engine-badge {
  font-size: 11.5px;
  font-family: var(--font-mono);
  color: var(--ink-faint);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}
.engine-badge[data-state="ready"] { color: var(--ok); border-color: var(--ok-line); background: var(--ok-wash); }
.engine-badge[data-state="loading"] { color: var(--warn); border-color: var(--warn-line); background: var(--warn-wash); }

/* ---------- 레이아웃 ---------------------------------------------------- */

.shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  gap: 26px;
  max-width: 1320px;
  margin: 0 auto;
  padding: 22px;
  align-items: start;
}

.rail {
  position: sticky;
  top: 78px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.rail-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.rail-heading {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink-faint);
  font-weight: 600;
  margin-bottom: 9px;
  padding: 0 4px;
}

.week-list { display: flex; flex-direction: column; gap: 2px; }

.week-item {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 8px 8px;
  border-radius: var(--radius-sm);
  text-align: left;
  width: 100%;
  color: var(--ink-soft);
  transition: background .14s, color .14s;
}
.week-item:hover { background: var(--surface-2); color: var(--ink); }
.week-item[aria-current="true"] { background: var(--accent-wash); color: var(--accent); }

.week-no {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  border: 1px solid currentColor;
  border-radius: 5px;
  padding: 1px 0;
  text-align: center;
  opacity: .85;
}

.week-name {
  font-size: 13.5px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.week-item[aria-current="true"] .week-name { font-weight: 600; }

.week-score {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}
.week-score[data-done="true"] { color: var(--ok); font-weight: 700; }

/* 전체 진행률 */
.progress-total { padding: 4px; }
.progress-figure {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.progress-figure b { font-size: 26px; font-weight: 700; letter-spacing: -1px; }
.progress-figure span { font-size: 12px; color: var(--ink-faint); }

.bar {
  height: 5px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}
.bar > i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width .35s ease;
}

.reset-link {
  margin-top: 10px;
  font-size: 12px;
  color: var(--ink-faint);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.reset-link:hover { color: var(--bad); }

/* ---------- 본문 ------------------------------------------------------- */

.main { min-width: 0; display: flex; flex-direction: column; gap: 18px; }

.week-head {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
}
.week-eyebrow {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
}
.week-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 400;
  letter-spacing: 0;
  margin: 4px 0 6px;
  line-height: 1.3;
}
.week-subtitle { font-size: 13.5px; color: var(--ink-soft); }

.tabs {
  display: flex;
  gap: 4px;
  margin-top: 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: -20px;
  padding-bottom: 0;
}
.tab {
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-soft);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .14s, border-color .14s;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-faint);
  margin-left: 5px;
  font-variant-numeric: tabular-nums;
}

/* ---------- 개념 카드 --------------------------------------------------- */

.concept {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.concept + .concept { margin-top: 14px; }

.concept-head {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 14px 18px;
  text-align: left;
}
.concept-head:hover { background: var(--surface-2); }

.concept-title {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 400;
  letter-spacing: 0;
  flex: 1;
  min-width: 0;
}

.chev {
  color: var(--ink-faint);
  transition: transform .2s ease;
  flex-shrink: 0;
}
.concept[data-open="true"] .chev { transform: rotate(90deg); }

.concept-summary {
  font-family: var(--font-hand);
  font-weight: 700;
  font-size: 15px;
  line-height: 1.4;
  color: var(--ink-soft);
  padding: 0 18px 13px;
  margin-top: -6px;
}

.concept-body {
  display: none;
  padding: 4px 18px 20px;
  border-top: 1px solid var(--line);
  flex-direction: column;
  gap: 14px;
}
.concept[data-open="true"] .concept-body { display: flex; padding-top: 16px; }

.prose { max-width: 68ch; }
.prose strong { font-weight: 600; }

.bullets { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 5px; max-width: 68ch; }
.bullets li::marker { color: var(--accent); }

code.inline {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--code-keyword);
  white-space: nowrap;
}

/* 팁 / 주의 */
.callout {
  border-left: 3px solid;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 11px 14px;
  font-size: 14px;
  max-width: 72ch;
}
.callout .callout-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  margin-bottom: 3px;
}
.callout.tip { background: var(--ok-wash); border-color: var(--ok); }
.callout.tip .callout-label { color: var(--ok); }
.callout.warn { background: var(--warn-wash); border-color: var(--warn); }
.callout.warn .callout-label { color: var(--warn); }

/* 표 */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
thead th {
  background: var(--surface-2);
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.03em;
  color: var(--ink-soft);
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
tbody tr:last-child td { border-bottom: none; }
tbody td:first-child { font-family: var(--font-mono); color: var(--code-keyword); white-space: nowrap; }

/* ---------- 코드 표시 --------------------------------------------------- */

.codeblock {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--code-bg);
}

.codeblock-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px 5px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  color: var(--ink-faint);
  font-family: var(--font-mono);
}
.codeblock-bar .spacer { flex: 1; }

.mini-btn {
  font-size: 11.5px;
  font-family: var(--font-body);
  padding: 3px 9px;
  border-radius: 5px;
  border: 1px solid var(--line-strong);
  color: var(--ink-soft);
  background: var(--surface);
  transition: color .14s, border-color .14s;
  white-space: nowrap;
}
.mini-btn:hover { color: var(--accent); border-color: var(--accent); }

pre {
  margin: 0;
  padding: 12px 14px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.62;
  color: var(--code-ink);
  tab-size: 4;
}

.tok-kw { color: var(--code-keyword); font-weight: 600; }
.tok-str { color: var(--code-string); }
.tok-com { color: var(--code-comment); font-style: italic; }
.tok-bi { color: var(--code-builtin); }
.tok-num { color: var(--code-number); }
.tok-def { color: var(--code-def); font-weight: 600; }

/* 실행 결과 */
.result {
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.result-label {
  font-size: 10.5px;
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 6px 14px 0;
}
.result pre { padding: 4px 14px 12px; font-size: 12.5px; color: var(--ink-soft); }
.result.is-error pre { color: var(--bad); }

/* 고정 출력 예시 */
.sample-out {
  font-family: var(--font-mono);
  font-size: 12.5px;
  white-space: pre-wrap;
  background: var(--surface-2);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  color: var(--ink-soft);
  overflow-x: auto;
  tab-size: 8;
}

/* ---------- 문제 -------------------------------------------------------- */

.prob-list { display: flex; flex-direction: column; gap: 12px; }

.prob {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.prob[data-solved="true"] { border-color: var(--ok-line); }

.prob-head {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 13px 16px;
  text-align: left;
}
.prob-head:hover { background: var(--surface-2); }

.prob-status {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  display: grid; place-items: center;
  flex-shrink: 0;
  color: transparent;
  font-size: 12px;
}
.prob[data-solved="true"] .prob-status {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
}
:root[data-theme="dark"] .prob[data-solved="true"] .prob-status { color: #10281c; }

.prob-name {
  flex: 1; min-width: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 16.5px;
  letter-spacing: 0;
}

.prob-meta { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.level {
  font-size: 10.5px;
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink-faint);
}
.level[data-lv="1"] { color: var(--ok); border-color: var(--ok-line); background: var(--ok-wash); }
.level[data-lv="2"] { color: var(--warn); border-color: var(--warn-line); background: var(--warn-wash); }
.level[data-lv="3"] { color: var(--bad); border-color: var(--bad-line); background: var(--bad-wash); }

.kind {
  font-size: 10.5px;
  color: var(--ink-faint);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
}

.prob-body {
  display: none;
  border-top: 1px solid var(--line);
  padding: 16px;
  gap: 18px;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
}
.prob[data-open="true"] .prob-body { display: grid; }

.panel { display: flex; flex-direction: column; gap: 11px; min-width: 0; }

.panel-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* 편집기 */
.editor-wrap {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--code-bg);
  display: flex;
  flex-direction: column;
}
.editor-wrap:focus-within { border-color: var(--accent); }

.editor {
  width: 100%;
  min-height: 172px;
  resize: vertical;
  border: none;
  outline: none;
  padding: 11px 13px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.62;
  background: transparent;
  color: var(--code-ink);
  tab-size: 4;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
}
.editor::placeholder { color: var(--ink-faint); }

.stdin-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 8px 11px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.stdin-row label {
  font-size: 11px;
  color: var(--ink-faint);
  font-weight: 600;
  white-space: nowrap;
  padding-top: 5px;
}
.stdin {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 4px 8px;
  resize: vertical;
  min-height: 30px;
  line-height: 1.5;
}
.stdin:focus { outline: none; border-color: var(--accent); }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: background .14s, border-color .14s, color .14s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
:root[data-theme="dark"] .btn-primary { color: #241206; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn-primary { color: #241206; }
}
.btn-primary:disabled { opacity: .55; cursor: not-allowed; }

.btn-ghost { border-color: var(--line-strong); color: var(--ink-soft); background: var(--surface); }
.btn-ghost:hover { color: var(--accent); border-color: var(--accent); }

.kbd-hint { font-size: 11.5px; color: var(--ink-faint); margin-left: auto; font-family: var(--font-mono); }

/* 채점 결과 */
.verdict {
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14px;
  border: 1px solid;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.verdict.pass { background: var(--ok-wash); border-color: var(--ok-line); color: var(--ok); }
.verdict.fail { background: var(--bad-wash); border-color: var(--bad-line); color: var(--bad); }
.verdict.info { background: var(--surface-2); border-color: var(--line); color: var(--ink-soft); }
.verdict-title { font-weight: 700; display: flex; align-items: center; gap: 7px; }
.verdict-note { color: var(--ink-soft); font-size: 13px; }

.diff-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.diff-col { min-width: 0; }
.diff-col .panel-label { margin-bottom: 4px; }
.diff-box {
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: pre-wrap;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 8px 10px;
  color: var(--ink);
  overflow-x: auto;
  max-height: 190px;
  overflow-y: auto;
  tab-size: 8;
}
.diff-box mark {
  background: var(--bad-wash);
  color: var(--bad);
  border-radius: 2px;
  padding: 0 1px;
  outline: 1px solid var(--bad-line);
}

/* 힌트 */
.hints { display: flex; flex-direction: column; gap: 7px; }

.hint {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
}
.hint-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  text-align: left;
  font-size: 13.5px;
  color: var(--ink-soft);
}
.hint-btn:hover { background: var(--surface-2); color: var(--ink); }
.hint-no {
  font-family: var(--font-hand);
  font-size: 14px;
  font-weight: 700;
  color: var(--warn);
  background: var(--warn-wash);
  border: 1px solid var(--warn-line);
  border-radius: 4px;
  padding: 0 6px;
  flex-shrink: 0;
}
.hint-text {
  display: none;
  padding: 0 12px 11px 40px;
  font-size: 13.5px;
  color: var(--ink);
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.hint[data-open="true"] .hint-text { display: block; }
.hint-lock { margin-left: auto; font-size: 11px; color: var(--ink-faint); }

/* 해설 */
.explain {
  border: 1px solid var(--accent-line);
  background: var(--accent-wash);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}
.explain .panel-label { color: var(--accent); }
.explain .callout { background: var(--surface); }

/* 예측 문제 입력 */
.predict-input {
  width: 100%;
  min-height: 88px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--code-bg);
  color: var(--code-ink);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.62;
  padding: 10px 12px;
  resize: vertical;
}
.predict-input:focus { outline: none; border-color: var(--accent); }

/* 객관식 */
.choices { display: flex; flex-direction: column; gap: 8px; }
.choice {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  text-align: left;
  width: 100%;
  background: var(--surface);
  transition: border-color .14s, background .14s;
}
.choice:hover { border-color: var(--accent); }
.choice[data-picked="true"] { border-color: var(--accent); background: var(--accent-wash); }
.choice[data-verdict="ok"] { border-color: var(--ok); background: var(--ok-wash); }
.choice[data-verdict="no"] { border-color: var(--bad); background: var(--bad-wash); }
.choice-mark {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
  width: 18px;
}
.choice pre { padding: 0; background: none; font-size: 12.5px; }
.choice .codeblock { border: none; background: none; }

/* 접근성 보조 */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.empty {
  color: var(--ink-faint);
  font-size: 14px;
  padding: 22px;
  text-align: center;
}

/* ---------- 반응형 ------------------------------------------------------ */

@media (max-width: 1020px) {
  .shell { grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 16px; }
  .rail { position: static; min-width: 0; }
  .week-list { flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 4px; min-width: 0; }
  .week-item { grid-template-columns: auto auto; min-width: max-content; }
  .week-name { display: none; }
  .rail-card.progress-card { display: flex; align-items: center; gap: 16px; }
  .progress-total { flex: 1; padding: 0; min-width: 0; }
  .prob-body { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 620px) {
  .topbar { padding: 9px 14px; gap: 12px; }
  .brand-sub { display: none; }
  .week-title { font-size: 22px; }
  .diff-grid { grid-template-columns: 1fr; }
  .prob-head { padding: 11px 12px; }
  .prob-body { padding: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

@media print {
  .rail, .topbar-actions, .actions, .tabs { display: none; }
  .concept-body, .prob-body { display: block !important; }
}

/* ==========================================================================
   Thonny 를 닮은 실습 패널
   수업에서 쓰는 편집기와 비슷한 배치로 만들어 익숙하게 연습할 수 있도록 한다.
   편집기 · Shell · Variables 세 부분으로 나뉜다.
   ========================================================================== */

.thonny {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* 상단 도구 모음 */
.th-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}

.th-run {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 600;
  background: var(--ok);
  color: #fff;
  border: 1px solid transparent;
  transition: filter .14s;
}
.th-run:hover { filter: brightness(1.08); }
.th-run:disabled { opacity: .5; cursor: not-allowed; }
:root[data-theme="dark"] .th-run { color: #08210f; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .th-run { color: #08210f; }
}

.th-btn {
  padding: 4px 11px;
  border-radius: 5px;
  font-size: 13px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-soft);
  transition: color .14s, border-color .14s;
}
.th-btn:hover { color: var(--accent); border-color: var(--accent); }

.th-spacer { flex: 1; }

.th-kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-faint);
  white-space: nowrap;
}

/* 파일 탭 */
.th-tabs {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  padding: 4px 8px 0;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}

.th-tab {
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 3px 12px;
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 5px 5px 0 0;
  background: var(--code-bg);
  color: var(--ink-soft);
  margin-bottom: -1px;
}
.th-tab[data-dirty="true"]::after { content: " *"; color: var(--accent); }

/* 편집기: 줄 번호 + 입력 영역 */
.th-editor {
  display: flex;
  background: var(--code-bg);
  min-height: 0;
  position: relative;
}

.th-gutter {
  flex: 0 0 auto;
  padding: 10px 8px 10px 10px;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.62;
  color: var(--code-gutter);
  background: var(--surface-2);
  border-right: 1px solid var(--line);
  user-select: none;
  overflow: hidden;
  white-space: pre;
  min-width: 34px;
  font-variant-numeric: tabular-nums;
}

.th-code {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  resize: vertical;
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.62;
  background: transparent;
  color: var(--code-ink);
  tab-size: 4;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
  min-height: 150px;
}
.th-code::placeholder { color: var(--ink-faint); }
.th-editor:focus-within { box-shadow: inset 0 0 0 1px var(--accent); }

/* 입력값 칸 */
.th-stdin {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 7px 10px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.th-stdin > label {
  font-size: 11px;
  color: var(--ink-faint);
  font-weight: 600;
  white-space: nowrap;
  padding-top: 5px;
}
.th-stdin textarea {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 4px 8px;
  resize: vertical;
  min-height: 28px;
  line-height: 1.5;
}
.th-stdin textarea:focus { outline: none; border-color: var(--accent); }
.th-stdin textarea[readonly] { background: var(--surface-2); color: var(--ink-soft); }

/* 아래쪽 패널 제목 (Shell / Variables) */
.th-pane-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  padding: 4px 10px;
  background: var(--surface-2);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
}
.th-pane-title .th-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-faint);
  font-weight: 400;
}

/* Shell 출력 */
.th-shell {
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  padding: 8px 10px;
  white-space: pre-wrap;
  overflow-x: auto;
  max-height: 260px;
  overflow-y: auto;
  background: var(--surface);
  color: var(--ink);
  tab-size: 8;
  margin: 0;
}
.th-shell .th-run-line { color: var(--ink-faint); }
.th-shell .th-err { color: var(--bad); }
.th-shell .th-empty { color: var(--ink-faint); font-style: italic; }

/* Variables 패널 */
.th-vars { background: var(--surface); }
.th-vars table { font-size: 12px; }
.th-vars thead th {
  background: var(--surface);
  font-size: 11px;
  padding: 4px 10px;
  color: var(--ink-faint);
}
.th-vars tbody td {
  padding: 3px 10px;
  font-family: var(--font-mono);
  border-bottom: 1px solid var(--line);
}
.th-vars tbody td:first-child { color: var(--code-def); font-weight: 600; }
.th-vars tbody td:nth-child(2) { color: var(--ink); }
.th-vars tbody td:last-child { color: var(--ink-faint); font-size: 11px; }
.th-vars-empty {
  padding: 7px 10px;
  font-size: 12px;
  color: var(--ink-faint);
}

/* 오류 도움말 (Thonny 의 Assistant 를 흉내) */
.th-assist {
  border-top: 1px solid var(--line);
  background: var(--warn-wash);
  padding: 8px 10px;
  font-size: 12.5px;
  color: var(--ink);
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.th-assist b { color: var(--warn); flex-shrink: 0; }
