/* ============ Design tokens ============ */
:root {
  --bg: #f5f6fb;
  --bg-grad: radial-gradient(1200px 500px at 20% -10%, #e9e8ff 0%, rgba(245,246,251,0) 60%), radial-gradient(900px 400px at 100% 0%, #dff4ff 0%, rgba(245,246,251,0) 55%);
  --panel: #ffffff;
  --panel-2: #fafbff;
  --text: #151a2d;
  --sub: #4b5470;
  --muted: #7d86a0;
  --line: #e6e9f3;
  --brand: #5b4bff;
  --brand-2: #8a5cff;
  --brand-ink: #ffffff;
  --brand-soft: #efedff;
  --ok: #10b981;
  --ok-soft: #e4f9f1;
  --warn: #d97706;
  --warn-soft: #fff5e3;
  --code-bg: #eef0f8;
  --cmd-bg: #0f1320;
  --cmd-text: #e8ecfa;
  --r: 18px;
  --shadow-sm: 0 1px 2px rgba(23,28,60,.05);
  --shadow: 0 1px 2px rgba(23,28,60,.04), 0 10px 30px rgba(23,28,60,.07);
  --shadow-brand: 0 8px 22px rgba(91,75,255,.32);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0e17;
    --bg-grad: radial-gradient(1000px 500px at 15% -10%, #1d1b4a 0%, rgba(11,14,23,0) 60%), radial-gradient(800px 400px at 100% 0%, #0f2c3c 0%, rgba(11,14,23,0) 55%);
    --panel: #131828; --panel-2: #171c2e; --text: #eef1fb; --sub: #b9c0d8; --muted: #8790ab; --line: #232a40;
    --brand: #8f84ff; --brand-2: #b08cff; --brand-ink: #0b0e17; --brand-soft: #211f4b;
    --ok: #34d399; --ok-soft: #0f3228; --warn: #f2bd62; --warn-soft: #352a10;
    --code-bg: #1d2336; --cmd-bg: #080b13; --cmd-text: #e8ecfa;
    --shadow-sm: none; --shadow: 0 10px 30px rgba(0,0,0,.35); --shadow-brand: 0 8px 22px rgba(143,132,255,.25);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg) var(--bg-grad) no-repeat; color: var(--text);
  font: 16px/1.85 "Inter", "Hiragino Sans", "Yu Gothic UI", "Meiryo UI", "Noto Sans JP", system-ui, sans-serif;
  display: flex; flex-direction: column; -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }
kbd { background: rgba(255,255,255,.12); color: #e6e9f7; border-radius: 6px; padding: 1px 8px; font: 12px ui-monospace, "Cascadia Code", Consolas, monospace; border: 1px solid rgba(255,255,255,.14); }
code { background: var(--code-bg); padding: .12em .5em; border-radius: 7px; font: .88em ui-monospace, "Cascadia Code", Consolas, monospace; color: var(--text); }
::selection { background: var(--brand-soft); }
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }

/* ============ Top bar ============ */
.topbar {
  height: 62px; flex: none; display: flex; align-items: center; gap: 20px; padding: 0 24px;
  background: color-mix(in srgb, var(--panel) 78%, transparent); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line); position: relative; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 19px; letter-spacing: .01em; }
.logo {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); box-shadow: var(--shadow-brand);
  font: 800 14px ui-monospace, "Cascadia Code", Consolas, monospace;
}
.overall { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--sub); font-size: 13px; font-weight: 700; padding: 7px 14px; border-radius: 99px; background: var(--panel); border: 1px solid var(--line); }
.bar { width: 150px; height: 8px; background: var(--code-bg); border-radius: 99px; overflow: hidden; }
.bar > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--brand), var(--ok)); border-radius: 99px; transition: width .6s cubic-bezier(.2,.8,.2,1); }
.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); padding: 7px 14px; border-radius: 99px; font-size: 13px; font-weight: 600; transition: all .15s; }
.ghost:hover { color: var(--text); border-color: var(--muted); background: var(--panel); }

/* ============ Layout ============ */
.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 276px minmax(380px, 1fr) minmax(420px, 44%); transition: grid-template-columns .28s cubic-bezier(.2,.8,.2,1); }
.layout.collapsed { grid-template-columns: 0 minmax(380px, 1fr) minmax(420px, 44%); }
.layout.collapsed .sidebar { padding-left: 0; padding-right: 0; overflow: hidden; visibility: hidden; }
.sidebar { min-width: 0; }
.icon-btn { flex: none; width: 38px; height: 38px; margin-left: -6px; display: grid; place-items: center; border-radius: 11px; border: 1px solid transparent; background: transparent; color: var(--sub); transition: all .15s; }
.icon-btn:hover { background: var(--panel); border-color: var(--line); color: var(--text); }
.icon-btn:focus-visible, .btn:focus-visible, .course-item:focus-visible, .stepper .dot:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ============ Sidebar ============ */
.sidebar { overflow-y: auto; padding: 20px 14px 28px 20px; }
.level-head { display: flex; align-items: center; gap: 8px; margin: 22px 6px 8px; }
.level-head:first-child { margin-top: 2px; }
.level-head .lv { flex: none; white-space: nowrap; font-size: 11px; font-weight: 800; letter-spacing: .08em; padding: 3px 11px; border-radius: 99px; color: #fff; background: linear-gradient(135deg, #10b981, #059669); }
.level-head.intermediate .lv { background: linear-gradient(135deg, #f59e0b, #d97706); }
.level-head.advanced .lv { background: linear-gradient(135deg, #f43f5e, #dc2626); }
.level-head .ld { font-size: 12px; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.level-head .lc { flex: none; margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 700; }

.course-item {
  position: relative; display: flex; gap: 13px; align-items: center; width: 100%; text-align: left;
  background: transparent; border: 1px solid transparent; border-radius: 14px; padding: 10px 12px; margin-bottom: 4px; color: inherit;
  transition: background .15s, transform .15s, box-shadow .15s;
}
.course-item:hover { background: var(--panel); box-shadow: var(--shadow-sm); }
.course-item.active { background: var(--panel); border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); box-shadow: var(--shadow); }
.course-item.active::before { content: ""; position: absolute; left: -1px; top: 14px; bottom: 14px; width: 4px; border-radius: 0 4px 4px 0; background: linear-gradient(var(--brand), var(--brand-2)); }
.num {
  --p: 0%; flex: none; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 800; color: var(--sub);
  background: radial-gradient(closest-side, var(--panel) 76%, transparent 78%), conic-gradient(var(--brand) var(--p), var(--code-bg) 0);
}
.course-item.complete .num { background: var(--ok); color: #fff; font-size: 15px; }
.course-item .t { font-weight: 700; font-size: 14px; line-height: 1.5; }
.course-item .m { color: var(--muted); font-size: 12px; margin-top: 1px; line-height: 1.5; }

/* ============ Lesson ============ */
.lesson { min-height: 0; display: flex; flex-direction: column; position: relative; }
.lesson-scroll { flex: 1; overflow-y: auto; padding: 14px clamp(20px, 3.5vw, 48px) 110px; }
.lesson-inner { max-width: 680px; margin: 0 auto; animation: rise .4s cubic-bezier(.2,.8,.2,1); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.course-title { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; font-weight: 600; margin-top: 10px; }
.course-title strong { color: var(--brand); background: var(--brand-soft); padding: 2px 10px; border-radius: 99px; font-size: 12px; }

.stepper { display: flex; align-items: center; margin: 18px 0 30px; }
.stepper .dot { flex: none; width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--line); background: var(--panel); color: var(--muted); font: 800 13px inherit; display: grid; place-items: center; padding: 0; transition: all .2s; }
.stepper .dot:not(:disabled):hover { transform: translateY(-1px); border-color: var(--brand); }
.stepper .dot:disabled { cursor: default; }
.stepper .dot.done { background: var(--ok); border-color: var(--ok); color: #fff; }
.stepper .dot.cur { border-color: var(--brand); color: var(--brand); box-shadow: 0 0 0 5px var(--brand-soft); }
.stepper .dot.done.cur { color: #fff; }
.stepper .line { flex: 1; height: 3px; border-radius: 3px; background: var(--line); min-width: 6px; }
.stepper .line.done { background: var(--ok); }

.step-label { display: inline-block; color: var(--brand); font-size: 12px; font-weight: 800; letter-spacing: .1em; }
.lesson h1 { font-size: 31px; line-height: 1.4; margin: 6px 0 16px; letter-spacing: -.01em; font-weight: 800; }
.lesson p { margin: 0 0 16px; color: var(--sub); }
.lesson strong { color: var(--text); }
.lesson ul { color: var(--sub); padding-left: 1.3em; margin: 0 0 16px; }

.cmd {
  position: relative; margin: 8px 0 20px; background: var(--cmd-bg); color: var(--cmd-text); border-radius: 14px;
  padding: 16px 116px 16px 20px; font: 14px/1.75 ui-monospace, "Cascadia Code", Consolas, monospace; white-space: pre-wrap; word-break: break-all;
  box-shadow: var(--shadow); border: 1px solid rgba(255,255,255,.06);
}
.cmd::before { content: "$ "; color: #8f84ff; font-weight: 700; }
.cmd button { position: absolute; top: 11px; right: 11px; background: rgba(255,255,255,.1); color: #e6e9f7; border: 1px solid rgba(255,255,255,.12); border-radius: 9px; padding: 5px 13px; font-size: 12px; font-weight: 700; transition: all .15s; }
.cmd button:hover { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---- 解説ボックス ---- */
.anatomy { margin: 22px 0 8px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); overflow: hidden; box-shadow: var(--shadow); }
.an-title { display: flex; align-items: center; gap: 8px; padding: 11px 18px; font-size: 12px; font-weight: 800; letter-spacing: .1em; color: var(--brand); background: linear-gradient(90deg, var(--brand-soft), transparent); }
.an-title::before { content: "📖"; letter-spacing: 0; }
.an-cmd { margin: 6px 18px 4px; padding: 12px 16px; background: var(--cmd-bg); color: var(--cmd-text); border-radius: 12px; font: 14px/1.65 ui-monospace, "Cascadia Code", Consolas, monospace; white-space: pre-wrap; word-break: break-all; }
.parts { padding: 4px 18px 8px; }
.part { display: flex; gap: 16px; padding: 11px 0; border-top: 1px dashed var(--line); }
.part:first-child { border-top: 0; }
.part .tok { flex: none; align-self: flex-start; max-width: 42%; white-space: pre-wrap; word-break: break-all; background: var(--brand-soft); color: var(--brand); font-weight: 800; padding: 3px 10px; border-radius: 8px; }
.part .desc { color: var(--sub); font-size: 15px; line-height: 1.75; min-width: 0; }
.an-res-label { margin: 6px 18px 0; font-size: 12px; font-weight: 800; letter-spacing: .06em; color: var(--muted); }
.res { margin: 6px 18px 16px; padding: 12px 16px; background: var(--cmd-bg); color: #8ff0b8; border-radius: 12px; font: 13px/1.65 ui-monospace, "Cascadia Code", Consolas, monospace; white-space: pre-wrap; }
.an-use { margin: 0; padding: 13px 18px; border-top: 1px solid var(--line); font-size: 14px; color: var(--sub); background: var(--panel-2); }
.an-use::before { content: "💡 "; }

/* ---- ミッション ---- */
.mission {
  position: sticky; top: 6px; z-index: 4; margin: 4px 0 18px; padding: 12px 16px; border-radius: var(--r); display: flex; gap: 14px; align-items: center;
  background: linear-gradient(var(--panel), var(--panel)) padding-box, linear-gradient(135deg, var(--brand), var(--brand-2)) border-box;
  border: 2px solid transparent; box-shadow: var(--shadow-brand);
}
.mission .chk { flex: none; width: 36px; height: 36px; border-radius: 50%; background: var(--brand-soft); display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 17px; transition: all .3s; }
.mission .mbody { flex: 1; min-width: 0; }
.mission .lab { font-size: 11px; font-weight: 800; letter-spacing: .1em; color: var(--brand); line-height: 1.5; }
.mission .txt { font-weight: 800; font-size: 17px; color: var(--text); line-height: 1.5; }
.mission .wait { flex: none; max-width: 30%; font-size: 12px; color: var(--muted); text-align: right; line-height: 1.5; }
.mission.done { background: linear-gradient(var(--ok-soft), var(--ok-soft)) padding-box, linear-gradient(135deg, var(--ok), #34d399) border-box; box-shadow: 0 8px 22px rgba(16,185,129,.22); }
.mission.done .chk { background: var(--ok); border-color: var(--ok); animation: pop .4s cubic-bezier(.2,1.6,.4,1); }
.mission.done .lab { color: var(--ok); }
@keyframes pop { from { transform: scale(.4); } to { transform: scale(1); } }

.note { margin-top: 16px; padding: 14px 18px; border-radius: 14px; font-size: 15px; color: var(--text); }
.note.hint { background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent); }
.note.hint code { cursor: pointer; border: 1px dashed var(--warn); transition: background .15s; }
.note.hint code:hover { background: var(--panel); }
.note.good { background: var(--ok-soft); border: 1px solid color-mix(in srgb, var(--ok) 45%, transparent); }
.note b { display: block; font-size: 12px; letter-spacing: .08em; margin-bottom: 2px; }
.note.hint b { color: var(--warn); } .note.good b { color: var(--ok); }

.finish { text-align: center; padding: 36px 0; }
.finish .big { font-size: 68px; line-height: 1.2; animation: pop .6s cubic-bezier(.2,1.6,.4,1); }

/* ---- フッター（浮かぶバー） ---- */
.lesson-foot { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px clamp(20px, 3.5vw, 48px) 20px; background: linear-gradient(to top, var(--bg) 55%, transparent); pointer-events: none; }
.foot-inner { pointer-events: auto; max-width: 680px; margin: 0 auto; display: flex; gap: 8px; align-items: center; flex-wrap: nowrap; padding: 6px; background: color-mix(in srgb, var(--panel) 88%, transparent); backdrop-filter: blur(14px); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.btn { flex: none; white-space: nowrap; border: 0; border-radius: 10px; padding: 7px 18px; font-size: 14px; line-height: 1.6; color: var(--brand-ink); font-weight: 800; background: linear-gradient(135deg, var(--brand), var(--brand-2)); box-shadow: var(--shadow-brand); transition: transform .15s, filter .15s, box-shadow .15s; }
.btn:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.06); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: .35; cursor: not-allowed; box-shadow: none; }
.btn.sub { background: var(--code-bg); color: var(--text); box-shadow: none; }
.btn.sub:hover:not(:disabled) { background: var(--line); }
.btn.icon { width: 36px; height: 36px; padding: 0; display: grid; place-items: center; font-size: 16px; line-height: 1; border-radius: 50%; }
.spacer { flex: 1; }

/* ============ Terminal ============ */
.terminal-pane { padding: 18px 22px 22px 6px; min-height: 0; display: flex; }
.term-card { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; border-radius: 20px; overflow: hidden; background: #0b0e17; box-shadow: 0 24px 60px rgba(14,18,48,.35), 0 0 0 1px rgba(255,255,255,.06); }
.term-head { display: flex; align-items: center; gap: 12px; padding: 13px 16px; background: linear-gradient(#1a2033, #151a2b); color: #aab2cd; font-size: 13px; font-weight: 700; }
.dots i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 7px; }
.dots i:nth-child(1) { background: #ff5f57; } .dots i:nth-child(2) { background: #febc2e; } .dots i:nth-child(3) { background: #28c840; }
.term-title { margin-left: 6px; }
.status { margin-left: auto; font-weight: 600; font-size: 12px; padding: 3px 11px; border-radius: 99px; background: rgba(255,255,255,.07); }
.status.ok { color: #6ee7a8; }
.status.ok::before { content: "● "; }
.term-tip { padding: 8px 16px; font-size: 12px; color: #8a93ae; background: #0f1322; border-bottom: 1px solid #1c2236; }
#terminal { flex: 1; min-height: 0; padding: 12px 6px 12px 16px; }
.boot { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; background: radial-gradient(500px 300px at 50% 40%, #1b1a46, #0b0e17); color: #d3d9ee; text-align: center; padding: 30px; z-index: 2; }
.boot-main { font-size: 18px; font-weight: 800; }
.boot-sub { font-size: 13px; color: #8089a6; line-height: 1.9; }
.boot.hidden { display: none; }
.spinner { width: 42px; height: 42px; border: 3px solid rgba(255,255,255,.1); border-top-color: #8f84ff; border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ ツールチップ（ブラウザ標準の title の代わり） ============ */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip); position: absolute; left: 50%; top: calc(100% + 8px); transform: translate(-50%, -4px);
  white-space: nowrap; background: #1b2136; color: #fff; font: 700 12px/1 inherit; padding: 8px 11px; border-radius: 9px;
  box-shadow: 0 8px 20px rgba(10,14,30,.3); opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; z-index: 30;
}
[data-tip]:hover::after, [data-tip]:focus-visible::after { opacity: 1; transform: translate(-50%, 0); transition-delay: .25s; }
[data-tip-pos="top"]::after { top: auto; bottom: calc(100% + 8px); transform: translate(-50%, 4px); }
[data-tip-pos="top"]:hover::after { transform: translate(-50%, 0); }
[data-tip-pos="bottom-start"]::after { left: 0; transform: translateY(-4px); }
[data-tip-pos="bottom-start"]:hover::after, [data-tip-pos="bottom-start"]:focus-visible::after { transform: translateY(0); }
[data-tip-pos="top-start"]::after { top: auto; bottom: calc(100% + 8px); left: 0; transform: translateY(4px); }
[data-tip-pos="top-start"]:hover::after, [data-tip-pos="top-start"]:focus-visible::after { transform: translateY(0); }

/* ============ モーダル（ブラウザ標準の confirm の代わり） ============ */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(12,16,34,.45); backdrop-filter: blur(6px); opacity: 0; transition: opacity .2s; }
.modal-card {
  position: relative; width: min(420px, 100%); padding: 30px 28px 24px; text-align: center; border-radius: 24px;
  background: var(--panel); border: 1px solid var(--line); box-shadow: 0 30px 80px rgba(10,14,40,.4);
  opacity: 0; transform: translateY(14px) scale(.96); transition: opacity .2s, transform .28s cubic-bezier(.2,1.3,.4,1);
}
.modal.show .modal-backdrop { opacity: 1; }
.modal.show .modal-card { opacity: 1; transform: none; }
.modal-icon { width: 60px; height: 60px; margin: 0 auto 14px; display: grid; place-items: center; font-size: 28px; border-radius: 20px; background: var(--warn-soft); }
.modal-card h2 { margin: 0 0 8px; font-size: 20px; line-height: 1.5; letter-spacing: -.01em; }
.modal-card p { margin: 0 0 24px; color: var(--sub); font-size: 15px; line-height: 1.8; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; padding: 11px 16px; font-size: 15px; }
.btn.danger { background: linear-gradient(135deg, #f43f5e, #dc2626); box-shadow: 0 8px 22px rgba(220,38,38,.3); color: #fff; }

[data-tip-pos="bottom-end"]::after { left: auto; right: 0; transform: translateY(-4px); }
[data-tip-pos="bottom-end"]:hover::after, [data-tip-pos="bottom-end"]:focus-visible::after { transform: translateY(0); }

/* ============ はじめてガイド ============ */
.modal-card { max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px); overflow-y: auto; }
.welcome-card { width: min(640px, 100%); padding: 0; text-align: left; display: flex; flex-direction: column; overflow: hidden; }
.welcome-close { position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; border: 0; background: var(--code-bg); color: var(--sub); transition: all .15s; }
.welcome-close:hover { background: var(--line); color: var(--text); }
.welcome-body { flex: 1 1 auto; min-height: min(380px, calc(100vh - 230px)); overflow-y: auto; padding: 34px 34px 8px; }
.slide { animation: slideIn .35s cubic-bezier(.2,.8,.2,1); }
@keyframes slideIn { from { opacity: 0; transform: translateX(calc(var(--dir, 1) * 24px)); } to { opacity: 1; transform: none; } }
.w-emoji { width: 58px; height: 58px; display: grid; place-items: center; font-size: 30px; border-radius: 18px; background: linear-gradient(135deg, var(--brand-soft), transparent); border: 1px solid var(--line); margin-bottom: 14px; }
.welcome-card h2 { margin: 0 0 12px; font-size: 25px; line-height: 1.4; letter-spacing: -.01em; }
.welcome-card p { text-align: left; margin: 0 0 14px; }
.welcome-card .lead { font-size: 16px; color: var(--sub); }
.welcome-card .why { margin: 16px 0 0; padding: 12px 16px; border-radius: 12px; background: var(--brand-soft); color: var(--text); font-size: 15px; }

.feat { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.feat > div { padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel-2); }
.feat b { display: block; font-size: 15px; margin-bottom: 2px; }
.feat span { font-size: 13.5px; color: var(--sub); line-height: 1.7; display: block; }

.gloss > div { display: flex; gap: 14px; align-items: flex-start; padding: 12px 0; border-top: 1px dashed var(--line); }
.gloss > div:first-child { border-top: 0; }
.gk { flex: none; min-width: 92px; text-align: center; padding: 4px 10px; border-radius: 9px; background: var(--brand-soft); color: var(--brand); font-weight: 800; font-size: 14px; }
.gv { font-size: 15px; color: var(--sub); line-height: 1.8; }

.tour { display: grid; grid-template-columns: 0.8fr 1.3fr 1.1fr; gap: 8px; margin: 22px 0 18px; }
.tcol { position: relative; padding: 16px 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel-2); text-align: center; }
.tcol i { position: absolute; top: -11px; left: 12px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font: 800 12px inherit; font-style: normal; color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand-2)); }
.tcol b { display: block; font-size: 14px; }
.tcol span { display: block; font-size: 12px; color: var(--muted); line-height: 1.6; margin-top: 2px; }
.tcol.t3 { background: #0f1320; border-color: #0f1320; }
.tcol.t3 b { color: #fff; } .tcol.t3 span { color: #98a1bd; }
.flow { margin: 0 0 6px; padding-left: 1.4em; color: var(--sub); }
.flow li { margin-bottom: 8px; font-size: 15px; }
.flow b { color: var(--text); }

.mockterm { padding: 16px 18px; border-radius: 14px; background: var(--cmd-bg); color: #dfe4f5; font: 15px/1.9 ui-monospace, "Cascadia Code", Consolas, monospace; margin-bottom: 14px; }
.mockterm .rs, .legend .rs { color: #8ff0b8; }
.pr { color: #8f84ff; font-weight: 700; }
.cm { color: #ffd479; font-weight: 700; }
.cur { display: inline-block; width: 9px; height: 18px; vertical-align: middle; background: #8f84ff; animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.legend > div { display: flex; gap: 14px; align-items: baseline; padding: 6px 0; font-size: 14.5px; color: var(--sub); }
.legend > div > span:first-child { flex: none; min-width: 52px; font: 700 14px ui-monospace, Consolas, monospace; background: var(--cmd-bg); padding: 1px 9px; border-radius: 7px; text-align: center; }
.keys { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.k { background: var(--code-bg); color: var(--text); border: 1px solid var(--line); box-shadow: 0 1px 0 var(--line); padding: 1px 8px; }
.lesson kbd, .welcome-card kbd { background: var(--code-bg); color: var(--text); border: 1px solid var(--line); }

.welcome-nav { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 34px 20px; border-top: 1px solid var(--line); background: var(--panel); }
.welcome-nav .btn { padding: 10px 24px; font-size: 15px; }
.wdots { display: flex; gap: 8px; }
.wdots i { width: 8px; height: 8px; border-radius: 99px; background: var(--line); transition: all .25s; }
.wdots i.on { width: 24px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }
.ghost.help { color: var(--brand); border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); background: var(--brand-soft); }
.ghost.help:hover { background: var(--panel); }
@media (max-width: 640px) {
  .welcome-body { padding: 24px 20px 8px; }
  .welcome-nav { padding: 14px 20px 16px; }
  .feat { grid-template-columns: 1fr; }
  .tour { grid-template-columns: 1fr; }
  .gloss > div { flex-direction: column; gap: 6px; }
  .welcome-body { min-height: 0; }
}

/* ============ 読み物ステップ用の部品 ============ */
.level-head.intro .lv { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.readtag { margin-left: 10px; padding: 2px 10px; border-radius: 99px; background: var(--brand-soft); color: var(--brand); letter-spacing: 0; font-size: 12px; }
.cmp { display: grid; gap: 10px; margin: 6px 0 18px; }
.cmp.two { grid-template-columns: 1fr 1fr; }
.cmp.three { grid-template-columns: repeat(3, 1fr); }
.cmp > div { padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: var(--shadow-sm); }
.cmp > div.hl { border-color: color-mix(in srgb, var(--brand) 55%, var(--line)); background: linear-gradient(135deg, var(--brand-soft), var(--panel)); }
.cmp b { display: block; font-size: 15px; margin-bottom: 2px; color: var(--text); }
.cmp span { display: block; font-size: 14px; line-height: 1.7; color: var(--sub); }
.tree { margin: 8px 0 18px; padding: 16px 20px; border-radius: 14px; background: var(--cmd-bg); color: #cfd6ee; font: 13.5px/1.9 ui-monospace, "Cascadia Code", Consolas, monospace; white-space: pre; overflow-x: auto; border: 1px solid rgba(255,255,255,.06); }
.warnbox { padding: 12px 16px; border-radius: 12px; background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent); color: var(--text) !important; font-size: 15px; }
@media (max-width: 640px) { .cmp.two, .cmp.three { grid-template-columns: 1fr; } }

/* ターミナルのスクロールバーを暗い配色に */
.xterm .xterm-viewport { scrollbar-width: thin; scrollbar-color: #2b3250 transparent; background-color: transparent !important; }

/* ============ Toast ============ */
.toast { position: fixed; top: 76px; left: 50%; transform: translate(-50%, -24px) scale(.96); opacity: 0; pointer-events: none; background: linear-gradient(135deg, #10b981, #059669); color: #fff; font-weight: 800; padding: 11px 24px; border-radius: 99px; box-shadow: 0 12px 30px rgba(5,150,105,.4); transition: all .35s cubic-bezier(.2,1.4,.4,1); z-index: 10; }
.toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }

/* ============ Responsive ============ */
@media (max-width: 1180px) {
  .layout { grid-template-columns: 240px 1fr; grid-template-rows: minmax(0, 1fr) 360px; }
  .layout.collapsed { grid-template-columns: 0 1fr; }
  .terminal-pane { grid-column: 1 / -1; padding: 0 20px 20px; }
}
@media (max-width: 760px) {
  .topbar { padding: 0 14px; gap: 10px; }
  .layout { display: flex; flex-direction: column; overflow-y: auto; }
  .sidebar { display: flex; flex: none; overflow-x: auto; padding: 10px 12px; gap: 6px; }
  .level-head { display: none; }
  .layout.collapsed { display: flex; }
  .layout.collapsed .sidebar { display: none; }
  .course-item { min-width: 220px; margin: 0; background: var(--panel); border-color: var(--line); }
  .lesson { flex: none; }
  .lesson-scroll { overflow: visible; padding-bottom: 100px; }
  .lesson-foot { position: sticky; bottom: 0; }
  .terminal-pane { height: 440px; flex: none; padding: 0 12px 14px; }
  .bar { display: none; }
  .lesson h1 { font-size: 26px; }
}
