/*
 * Space Python workspace: one layout for challenges, examples and the free editor.
 * Layout from the exercise prototype, colours and type from the site
 * (same palette as code-editor.css). Every class is prefixed ws- so the page
 * can sit next to Bootstrap or the old editor styles without clashes.
 */

:root {
    /* Site palette (spacepython.com) */
    --sp-dark: #04060c;
    --sp-deep: #070b13;
    --sp-panel: #0c121c;
    --sp-panel-2: #121a27;
    --sp-panel-3: #18222f;
    --sp-pre: #080d15;
    --sp-line: #1b2534;
    --sp-line-2: #2a3849;

    --sp-light: #e8eef7;
    --sp-body: #c2cddc;
    --sp-muted: #94a5bb;
    --sp-dim: #5f7288;

    --sp-primary: #ff7043;
    --sp-primary-hover: #ff8a63;
    --sp-on-primary: #1a0800;
    --sp-secondary: #4b9fe1;
    --sp-info: #66b1ec;
    --sp-success: #4ade80;
    --sp-on-success: #052611;
    --sp-warning: #ffd343;
    --sp-danger: #ff6b6b;
    --sp-on-danger: #2a0507;

    --sp-primary-rgb: 255, 112, 67;
    --sp-secondary-rgb: 75, 159, 225;
    --sp-success-rgb: 74, 222, 128;
    --sp-warning-rgb: 255, 211, 67;
    --sp-danger-rgb: 255, 107, 107;

    --ws-primary-bg: rgba(var(--sp-primary-rgb), .12);
    --ws-secondary-bg: rgba(var(--sp-secondary-rgb), .12);
    --ws-success-bg: rgba(var(--sp-success-rgb), .12);
    --ws-warning-bg: rgba(var(--sp-warning-rgb), .12);
    --ws-danger-bg: rgba(var(--sp-danger-rgb), .12);

    --ws-font-display: 'Space Grotesk', system-ui, sans-serif;
    --ws-font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --ws-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

    /* Resizable sizes (the resizers write these) */
    --ws-left: 440px;
    --ws-bottom: 280px;

    --ws-top: 56px;
    --ws-mnav: 56px;
    --ws-r: 10px;
    --ws-line-h: 21px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body.ws-body {
    margin: 0;
    background: var(--sp-dark);
    color: var(--sp-light);
    font: 14px/1.55 var(--ws-font);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    touch-action: manipulation;   /* no double-tap zoom on phones */
}

.ws-body [hidden] { display: none !important; }

.ws-body button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.ws-body code, .ws-body pre, .ws-mono { font-family: var(--ws-mono); }
.ws-body a { color: var(--sp-secondary); }
.ws-body a:hover { color: var(--sp-info); }
.ws-body ::selection { background: rgba(var(--sp-secondary-rgb), .35); }
.ws-body ::-webkit-scrollbar { width: 10px; height: 10px; }
.ws-body ::-webkit-scrollbar-thumb { background: var(--sp-line-2); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
.ws-body ::-webkit-scrollbar-track { background: transparent; }
.ws-body :focus-visible { outline: 2px solid var(--sp-secondary); outline-offset: 2px; }

.ws-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;
}

.ws-spacer { flex: 1; }

/* ---------- Top bar ---------- */

.ws-top {
    height: var(--ws-top);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 16px;
    background: var(--sp-panel);
    border-bottom: 1px solid var(--sp-line);
    position: relative;
    z-index: 30;
}

.ws-brand { display: flex; align-items: center; flex-shrink: 0; }
.ws-brand img { display: block; height: 26px; width: auto; }
.ws-brand .ws-brand-icon { display: none; height: 28px; width: 28px; }

.ws-crumbs { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--sp-dim); font-size: 13px; }
.ws-crumbs a { color: var(--sp-muted); text-decoration: none; white-space: nowrap; }
.ws-crumbs a:hover { color: var(--sp-light); }
.ws-crumbs .ws-sep { opacity: .6; }
.ws-crumbs b { color: var(--sp-light); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

.ws-status {
    display: inline-flex; align-items: center; gap: 7px;
    font: 500 12px var(--ws-mono); color: var(--sp-muted);
    padding: 6px 10px; border-radius: 8px;
    background: var(--sp-panel-2); border: 1px solid var(--sp-line);
    white-space: nowrap;
}
.ws-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--sp-warning); }
.ws-status[data-state="loading"]::before { animation: ws-pulse 1s ease-in-out infinite; }
.ws-status[data-state="ready"]::before { background: var(--sp-success); }
.ws-status[data-state="running"]::before { background: var(--sp-secondary); animation: ws-pulse .6s ease-in-out infinite; }
.ws-status[data-state="error"]::before { background: var(--sp-danger); }
@keyframes ws-pulse { 50% { opacity: .3; } }

/* ---------- Buttons and chips ---------- */

.ws-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    height: 34px; padding: 0 14px; border-radius: 8px;
    font-family: var(--ws-font); font-weight: 600; font-size: 13px; white-space: nowrap;
    border: 1px solid var(--sp-line-2) !important; background: var(--sp-panel-2) !important;
    color: var(--sp-light) !important; text-decoration: none;
    transition: background-color .15s, border-color .15s, filter .15s;
}
.ws-btn:hover { background: var(--sp-panel-3) !important; border-color: var(--sp-dim) !important; }
.ws-btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.ws-btn.ws-primary { background: var(--sp-primary) !important; border-color: var(--sp-primary) !important; color: var(--sp-on-primary) !important; }
.ws-btn.ws-primary:hover { background: var(--sp-primary-hover) !important; border-color: var(--sp-primary-hover) !important; }
.ws-btn.ws-success { background: var(--sp-success) !important; border-color: var(--sp-success) !important; color: var(--sp-on-success) !important; }
.ws-btn.ws-ghost { border-color: transparent !important; background: transparent !important; color: var(--sp-muted) !important; }
.ws-btn.ws-ghost:hover { background: var(--sp-panel-2) !important; color: var(--sp-light) !important; }
.ws-btn.ws-sm { height: 28px; padding: 0 10px; font-size: 12px; gap: 6px; }
.ws-btn.ws-icon { width: 34px; padding: 0; }
.ws-btn.ws-sm.ws-icon { width: 28px; }
.ws-btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.ws-btn.is-busy { pointer-events: none; }
.ws-btn.is-busy svg { animation: ws-spin .8s linear infinite; }

.ws-kbd { font: 500 10.5px var(--ws-mono); padding: 1px 5px; border-radius: 4px; background: rgba(0, 0, 0, .25); opacity: .8; }

.ws-chip {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 11.5px; font-weight: 600; line-height: 1.5;
    padding: 2px 8px; border-radius: 999px; white-space: nowrap;
    background: var(--sp-panel-3); color: var(--sp-muted);
}
.ws-chip svg { width: 11px; height: 11px; }
.ws-chip.ws-ok { background: var(--ws-success-bg); color: var(--sp-success); }
.ws-chip.ws-err { background: var(--ws-danger-bg); color: var(--sp-danger); }
.ws-chip.ws-warn { background: var(--ws-warning-bg); color: var(--sp-warning); }
.ws-chip.ws-acc { background: var(--ws-primary-bg); color: var(--sp-primary); }
.ws-chip.ws-info { background: var(--ws-secondary-bg); color: var(--sp-info); }

/* Drop-down menus (Save, site menu) */
.ws-menu-wrap { position: relative; }
.ws-menu {
    position: absolute; top: calc(100% + 6px); right: 0; min-width: 220px;
    background: var(--sp-panel-2); border: 1px solid var(--sp-line-2); border-radius: 10px;
    padding: 6px; box-shadow: 0 18px 50px rgba(0, 0, 0, .55);
    display: none; z-index: 60;
}
.ws-menu.is-open { display: block; animation: ws-fade .15s; }
.ws-menu-item {
    display: flex !important; align-items: center; gap: 9px; width: 100%;
    padding: 8px 10px; border-radius: 7px; text-align: left;
    color: var(--sp-body) !important; font-size: 13px; text-decoration: none;
}
.ws-menu-item:hover { background: var(--sp-panel-3); color: var(--sp-light) !important; }
.ws-menu-item svg { width: 15px; height: 15px; color: var(--sp-muted); flex-shrink: 0; }
.ws-menu-item:disabled { opacity: .5; cursor: not-allowed; }
.ws-menu-item small { margin-left: auto; color: var(--sp-dim); font: 11px var(--ws-mono); }
.ws-menu-sep { height: 1px; background: var(--sp-line-2); margin: 5px 4px; }
.ws-menu-title { padding: 6px 10px 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--sp-dim); }

.ws-avatar {
    width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
    display: grid; place-items: center; font-weight: 700; font-size: 12px;
    background: var(--sp-panel-3); color: var(--sp-light); text-decoration: none;
}

/* Progress line under the top bar */
.ws-progress { position: fixed; top: var(--ws-top); left: 0; height: 2px; width: 0; background: var(--sp-primary); transition: width .4s; z-index: 31; }

/* ---------- Layout ---------- */

.ws-main { display: grid; grid-template-columns: var(--ws-left) 6px minmax(0, 1fr); height: calc(100% - var(--ws-top)); }
.ws-main.ws-no-left { grid-template-columns: minmax(0, 1fr); }
.ws-main.ws-no-left > .ws-pane, .ws-main.ws-no-left > .ws-vres { display: none; }

.ws-pane { background: var(--sp-panel); display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.ws-vres, .ws-hres { background: var(--sp-dark); position: relative; touch-action: none; }
.ws-vres { cursor: col-resize; }
.ws-hres { cursor: row-resize; }
.ws-vres::after, .ws-hres::after { content: ""; position: absolute; border-radius: 2px; transition: background-color .15s; }
.ws-vres::after { inset: 0 2px; }
.ws-hres::after { inset: 2px 0; }
.ws-vres:hover::after, .ws-vres.is-drag::after, .ws-hres:hover::after, .ws-hres.is-drag::after { background: var(--sp-primary); }

.ws-right { display: grid; grid-template-rows: minmax(0, 1fr) 6px var(--ws-bottom); min-width: 0; min-height: 0; }
.ws-edcol { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

/* ---------- Tabs ---------- */

.ws-tabs { display: flex; gap: 2px; padding: 6px 8px 0; border-bottom: 1px solid var(--sp-line); overflow-x: auto; scrollbar-width: none; flex-shrink: 0; }
.ws-tabs::-webkit-scrollbar { display: none; }
.ws-tab {
    display: flex; align-items: center; gap: 7px;
    padding: 9px 11px 10px; margin-bottom: -1px;
    font-size: 13px; font-weight: 500; color: var(--sp-dim) !important;
    border-bottom: 2px solid transparent !important; white-space: nowrap;
    transition: color .15s, border-color .15s;
}
.ws-tab:hover { color: var(--sp-muted) !important; }
.ws-tab.is-on { color: var(--sp-light) !important; border-bottom-color: var(--sp-primary) !important; }
.ws-tab svg { width: 15px; height: 15px; opacity: .85; }
.ws-tab .ws-count { font-size: 11px; padding: 0 6px; border-radius: 999px; background: var(--sp-panel-3); color: var(--sp-muted); }

.ws-panel { flex: 1; overflow: auto; padding: 20px 22px 40px; display: none; }
.ws-panel.is-on { display: block; }

/* ---------- Task text ---------- */

.ws-h1 { font: 700 22px/1.25 var(--ws-font-display); letter-spacing: -.01em; margin: 0 0 10px; }
.ws-h3 { font: 600 15px/1.3 var(--ws-font-display); margin: 22px 0 8px; }
.ws-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }

.ws-prose { color: var(--sp-body); }
.ws-prose p { margin: 0 0 10px; }
.ws-prose ul, .ws-prose ol { padding-left: 20px; margin: 0 0 10px; }
.ws-prose li { margin: 4px 0; }
.ws-prose li::marker { color: var(--sp-dim); }
.ws-prose h2, .ws-prose h3, .ws-prose h4 { font-family: var(--ws-font-display); color: var(--sp-light); margin: 18px 0 8px; line-height: 1.3; }
.ws-prose h2 { font-size: 17px; }
.ws-prose h3 { font-size: 15px; }
.ws-prose h4 { font-size: 14px; }
.ws-prose strong, .ws-prose b { color: var(--sp-light); }
.ws-prose :not(pre) > code { font-size: 12.5px; background: var(--sp-panel-3); color: #ffd7c9; padding: 1px 6px; border-radius: 5px; }
.ws-prose pre { background: var(--sp-pre); border: 1px solid var(--sp-line); border-radius: var(--ws-r); padding: 12px 14px; font-size: 12.5px; line-height: 1.65; overflow-x: auto; color: var(--sp-body); }
.ws-prose img { max-width: 100%; height: auto; border-radius: 8px; }
.ws-prose blockquote { margin: 12px 0; padding: 10px 14px; border-left: 3px solid var(--sp-secondary); background: var(--ws-secondary-bg); border-radius: 0 8px 8px 0; }
.ws-prose table { border-collapse: collapse; width: 100%; font-size: 13px; margin: 10px 0; }
.ws-prose th, .ws-prose td { border: 1px solid var(--sp-line); padding: 6px 9px; text-align: left; }

.ws-notice {
    display: flex; gap: 10px; padding: 11px 13px; margin: 14px 0;
    border-radius: var(--ws-r); font-size: 13px; color: var(--sp-body);
    background: var(--ws-secondary-bg); border: 1px solid rgba(var(--sp-secondary-rgb), .25);
}
.ws-notice svg { flex-shrink: 0; color: var(--sp-secondary); margin-top: 1px; width: 16px; height: 16px; }
.ws-notice b { color: var(--sp-light); }
.ws-notice.ws-warn { background: var(--ws-warning-bg); border-color: rgba(var(--sp-warning-rgb), .3); }
.ws-notice.ws-warn svg { color: var(--sp-warning); }
.ws-notice.ws-ok { background: var(--ws-success-bg); border-color: rgba(var(--sp-success-rgb), .3); }
.ws-notice.ws-ok svg { color: var(--sp-success); }

/* ---------- Stages timeline ---------- */

.ws-stages { display: flex; flex-direction: column; margin: 18px 0 4px; }
.ws-stage { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; position: relative; }
.ws-stage:not(:last-child)::before { content: ""; position: absolute; left: 13.5px; top: 30px; bottom: -2px; width: 1px; background: var(--sp-line-2); }
.ws-stage.is-done:not(:last-child)::before { background: var(--sp-success); }
.ws-dot {
    width: 28px; height: 28px; border-radius: 50%; z-index: 1;
    display: grid; place-items: center; font-size: 12px; font-weight: 700;
    background: var(--sp-panel-3); color: var(--sp-dim); border: 1px solid var(--sp-line-2);
}
.ws-dot svg { width: 13px; height: 13px; }
.ws-stage.is-current .ws-dot { background: var(--ws-primary-bg); color: var(--sp-primary); border-color: var(--sp-primary); box-shadow: 0 0 0 4px rgba(var(--sp-primary-rgb), .08); }
.ws-stage.is-done .ws-dot { background: var(--sp-success); color: var(--sp-on-success); border-color: var(--sp-success); }

.ws-scard { border: 1px solid var(--sp-line); background: var(--sp-panel-2); border-radius: var(--ws-r); margin-bottom: 14px; overflow: hidden; transition: border-color .15s; }
.ws-stage.is-current .ws-scard { border-color: rgba(var(--sp-primary-rgb), .45); }
.ws-stage.is-locked .ws-scard { opacity: .6; }
.ws-shead { display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 14px; text-align: left; }
.ws-shead .ws-t { font-weight: 600; font-size: 13.5px; flex: 1; min-width: 0; }
.ws-caret { color: var(--sp-dim); transition: transform .2s; display: grid; }
.ws-caret svg { width: 14px; height: 14px; }
.ws-scard.is-open .ws-caret { transform: rotate(180deg); }
.ws-sbody { display: none; padding: 12px 14px 14px; border-top: 1px solid var(--sp-line); }
.ws-scard.is-open .ws-sbody { display: block; }
.ws-sbody .ws-prose { font-size: 13.5px; margin-bottom: 8px; }

.ws-req { display: flex; gap: 9px; align-items: flex-start; margin: 6px 0; color: var(--sp-body); font-size: 13.5px; }
.ws-req .ws-ck { width: 16px; height: 16px; border-radius: 4px; border: 1.5px solid var(--sp-line-2); flex-shrink: 0; margin-top: 2px; display: grid; place-items: center; }
.ws-req.is-met { color: var(--sp-light); }
.ws-req.is-met .ws-ck { background: var(--sp-success); border-color: var(--sp-success); }
.ws-req.is-met .ws-ck::after { content: ""; width: 8px; height: 4px; border: 2px solid var(--sp-on-success); border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }
.ws-req.is-fail .ws-ck { border-color: var(--sp-danger); }

/* ---------- Hints ---------- */

.ws-hint { border: 1px solid var(--sp-line); background: var(--sp-panel-2); border-radius: var(--ws-r); margin-bottom: 10px; overflow: hidden; }
.ws-hint-h { display: flex; align-items: center; gap: 10px; padding: 12px 14px; }
.ws-hint-h .ws-n { width: 24px; height: 24px; border-radius: 7px; background: var(--ws-warning-bg); color: var(--sp-warning); display: grid; place-items: center; font-weight: 700; font-size: 12px; flex-shrink: 0; }
.ws-hint-h .ws-t { flex: 1; font-weight: 600; font-size: 13.5px; min-width: 0; }
.ws-hint-h .ws-sub { display: block; font-weight: 400; font-size: 12px; color: var(--sp-dim); }
.ws-hint.is-locked .ws-hint-h .ws-t { color: var(--sp-dim); }
.ws-hint.is-locked .ws-n { background: var(--sp-panel-3); color: var(--sp-dim); }
.ws-hint-b { display: none; padding: 0 14px 14px 48px; color: var(--sp-body); }
.ws-hint.is-open .ws-hint-b { display: block; animation: ws-fade .25s; }
.ws-hint-b .ws-codeblock { margin-top: 8px; }

/* ---------- Solution gate and code blocks ---------- */

.ws-gate { text-align: center; padding: 36px 20px; border: 1px dashed var(--sp-line-2); border-radius: 14px; background: var(--sp-panel-2); }
.ws-gate .ws-ico { width: 52px; height: 52px; border-radius: 14px; margin: 0 auto 14px; display: grid; place-items: center; background: var(--ws-warning-bg); color: var(--sp-warning); }
.ws-gate .ws-ico svg { width: 24px; height: 24px; }
.ws-gate h4 { font: 600 16px var(--ws-font-display); margin: 0 0 6px; }
.ws-gate p { color: var(--sp-muted); font-size: 13px; max-width: 320px; margin: 0 auto 16px; }
.ws-meter { height: 6px; max-width: 220px; margin: 0 auto 18px; border-radius: 3px; background: var(--sp-panel-3); overflow: hidden; }
.ws-meter span { display: block; height: 100%; background: var(--sp-warning); border-radius: 3px; }

.ws-codeblock { background: var(--sp-pre); border: 1px solid var(--sp-line); border-radius: var(--ws-r); overflow: hidden; margin: 10px 0; }
.ws-codeblock .ws-bar { display: flex; align-items: center; gap: 6px; padding: 6px 8px 6px 14px; border-bottom: 1px solid var(--sp-line); font: 12px var(--ws-mono); color: var(--sp-dim); }
.ws-codeblock pre { margin: 0; padding: 14px; font-size: 12.5px; line-height: 1.65; overflow-x: auto; color: var(--sp-light); background: transparent; border: 0; border-radius: 0; }

/* ---------- Audio lesson (Example mode) ---------- */

.ws-audio { display: flex; align-items: center; gap: 12px; padding: 12px; margin-bottom: 18px; border: 1px solid var(--sp-line); border-radius: 12px; background: var(--sp-panel-2); }
.ws-audio .play-btn { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; background: var(--sp-primary); color: var(--sp-on-primary); }
.ws-audio .play-btn svg { fill: currentColor; }
.ws-audio .audio-info { flex: 1; min-width: 0; }
.ws-audio .audio-title { font: 600 13.5px var(--ws-font-display); margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-audio .audio-subtitle { font-size: 12px; color: var(--sp-dim); }
.ws-audio .progress-bar { flex: 1.3; min-width: 0; }
.ws-audio .progress-track { height: 5px; border-radius: 3px; background: var(--sp-panel-3); cursor: pointer; position: relative; }
.ws-audio .progress-fill { height: 100%; width: 0; border-radius: 3px; background: var(--sp-primary); }
.ws-audio .audio-time { font: 11px var(--ws-mono); color: var(--sp-dim); margin-top: 5px; text-align: right; }

/* ---------- Editor ---------- */

.ws-edhead { display: flex; align-items: center; gap: 4px; height: 42px; padding: 0 8px 0 0; border-bottom: 1px solid var(--sp-line); background: var(--sp-panel); flex-shrink: 0; }
.ws-ftab { display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 14px; font: 500 12.5px var(--ws-mono); color: var(--sp-light); border-bottom: 2px solid var(--sp-primary); background: var(--sp-panel-2); white-space: nowrap; }
.ws-ftab svg { width: 13px; height: 13px; }
.ws-ftab .ws-mod { width: 7px; height: 7px; border-radius: 50%; background: var(--sp-warning); display: none; }
.ws-ftab.is-dirty .ws-mod { display: block; }

.ws-editor { flex: 1; display: flex; min-height: 0; background: var(--sp-dark); position: relative; }
.ws-gutter {
    width: 52px; flex-shrink: 0; overflow: hidden; padding: 14px 0;
    text-align: right; color: #33445a; font: 13px/var(--ws-line-h) var(--ws-mono);
    user-select: none; border-right: 1px solid var(--sp-line); background: var(--sp-deep);
}
.ws-gutter div { padding-right: 14px; }
.ws-gutter div.is-cur { color: var(--sp-muted); }
.ws-codewrap { flex: 1; position: relative; min-width: 0; overflow: hidden; }
.ws-codewrap pre, .ws-codewrap textarea {
    position: absolute; inset: 0; margin: 0; padding: 14px 18px;
    font: 13px/var(--ws-line-h) var(--ws-mono); white-space: pre; tab-size: 4;
    letter-spacing: 0; border: 0; overflow: auto;
}
.ws-codewrap pre { pointer-events: none; color: var(--sp-light); overflow: hidden; background: transparent; }
.ws-codewrap textarea { background: transparent; color: transparent; caret-color: #fff; resize: none; outline: none; z-index: 2; }
.ws-codewrap textarea::placeholder { color: var(--sp-dim); }
.ws-codewrap textarea:disabled { cursor: progress; }
.ws-curline { position: absolute; left: 0; right: 0; height: var(--ws-line-h); top: 14px; background: rgba(var(--sp-secondary-rgb), .05); pointer-events: none; }

/* Audio-lesson line highlights sit between the current-line band and the code */
.ws-codewrap .line-highlights { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 1; }
.ws-codewrap .line-highlights__inner { position: absolute; left: 0; right: 0; top: 0; }

/* Prism tokens in the site palette */
.ws-codewrap .token.comment, .ws-codeblock .token.comment, .ws-prose .token.comment { color: #5f7288; font-style: italic; }
.ws-body .token.keyword, .ws-body .token.boolean { color: #ff8a63; }
.ws-body .token.string, .ws-body .token.triple-quoted-string, .ws-body .token.string-interpolation .token.string { color: #a5e075; }
.ws-body .token.number { color: #ffd343; }
.ws-body .token.function { color: #66b1ec; }
.ws-body .token.class-name { color: #ffd343; }
.ws-body .token.builtin { color: #5fd4c4; }
.ws-body .token.decorator, .ws-body .token.annotation { color: #ffd343; }
.ws-body .token.operator { color: #c2cddc; }
.ws-body .token.punctuation { color: #94a5bb; }
.ws-body .token.interpolation { color: #e8eef7; }

.ws-statusbar { height: 26px; display: flex; align-items: center; gap: 16px; padding: 0 12px; font: 11.5px var(--ws-mono); color: var(--sp-dim); background: var(--sp-panel); border-top: 1px solid var(--sp-line); flex-shrink: 0; white-space: nowrap; overflow: hidden; }
.ws-statusbar .is-ok { color: var(--sp-success); }
.ws-statusbar .is-warn { color: var(--sp-warning); }

/* ---------- Bottom panel ---------- */

.ws-bottom { background: var(--sp-panel); display: flex; flex-direction: column; min-height: 0; }
.ws-bhead { display: flex; align-items: center; border-bottom: 1px solid var(--sp-line); padding-right: 8px; flex-shrink: 0; }
.ws-bhead .ws-tabs { border: 0; padding-top: 0; flex: 1; }
.ws-summary { display: flex; gap: 6px; align-items: center; }
.ws-bbody { flex: 1; overflow: auto; display: none; }
.ws-bbody.is-on { display: block; }

.ws-tgroup { padding: 4px 10px 8px; }
.ws-tgroup-h { display: flex; align-items: center; gap: 8px; padding: 10px 6px 6px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--sp-dim); }
.ws-tgroup-h .ws-line { flex: 1; height: 1px; background: var(--sp-line); }
.ws-tgroup-h .ws-ck-s { width: 14px; height: 14px; }
.ws-tgroup-h.is-met { color: var(--sp-success); }

.ws-test { border-radius: 8px; }
.ws-test-h { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border-radius: 8px; text-align: left; }
.ws-test-h:hover, .ws-test.is-open .ws-test-h { background: var(--sp-panel-2); }
.ws-st { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; border: 1.5px solid var(--sp-line-2); }
.ws-st svg { width: 11px; height: 11px; }
.ws-st.is-pass { background: var(--sp-success); border-color: var(--sp-success); color: var(--sp-on-success); }
.ws-st.is-fail { background: var(--sp-danger); border-color: var(--sp-danger); color: var(--sp-on-danger); }
.ws-st.is-run { border-color: var(--sp-secondary); border-top-color: transparent; animation: ws-spin .7s linear infinite; }
@keyframes ws-spin { to { transform: rotate(360deg); } }
.ws-test-h .ws-nm { flex: 1; min-width: 0; font: 500 12.5px var(--ws-mono); color: var(--sp-light); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-test-h .ws-tm { font: 11.5px var(--ws-mono); color: var(--sp-dim); }
.ws-test-h .ws-caret { margin-left: 2px; }
.ws-test.is-open .ws-test-h .ws-caret { transform: rotate(180deg); }
.ws-test-b { display: none; padding: 4px 8px 12px 36px; }
.ws-test.is-open .ws-test-b { display: block; }
.ws-test-msg { font-size: 12.5px; color: var(--sp-warning); margin: 2px 0 8px; }

.ws-io { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 5px 10px; font-size: 12px; margin: 0; }
.ws-io dt { color: var(--sp-dim); padding-top: 5px; }
.ws-io dd { margin: 0; font: 12px/1.55 var(--ws-mono); background: var(--sp-pre); border: 1px solid var(--sp-line); border-radius: 6px; padding: 5px 9px; white-space: pre-wrap; word-break: break-word; color: var(--sp-body); }
.ws-io dd.is-bad { color: var(--sp-danger); border-color: rgba(var(--sp-danger-rgb), .3); }
.ws-io dd.is-good { color: var(--sp-success); }
.ws-io dd.is-empty { color: var(--sp-dim); font-style: italic; }

.ws-note { display: flex; gap: 9px; align-items: center; margin: 2px 6px 6px; padding: 8px 10px; border-radius: 8px; background: var(--sp-panel-2); color: var(--sp-muted); font-size: 12px; }
.ws-note svg { width: 15px; height: 15px; flex-shrink: 0; }

/* Console */
.ws-console { padding: 12px 16px 18px; font: 12.5px/1.7 var(--ws-mono); color: var(--sp-body); white-space: pre-wrap; word-break: break-word; }
.ws-console .terminal-output { color: var(--sp-light); }
.ws-console .terminal-error { color: var(--sp-danger); font-weight: 600; }
.ws-console .terminal-success { color: var(--sp-success); }
.ws-console .terminal-loading { color: var(--sp-warning); }
.ws-console .terminal-muted { color: var(--sp-dim); }
.ws-console .terminal-prompt { color: var(--sp-primary); }
.ws-console .input-container { display: flex; gap: 8px; margin: 4px 0; white-space: normal; }
.ws-console .input-field {
    flex: 1; min-width: 0; height: 32px; padding: 0 10px; border-radius: 7px;
    background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .1);
    color: var(--sp-light); font: 13px var(--ws-mono); outline: none;
}
.ws-console .input-field:focus { border-color: var(--sp-secondary); box-shadow: 0 0 0 3px rgba(var(--sp-secondary-rgb), .15); }
.ws-console .input-submit { height: 32px; padding: 0 14px; border-radius: 7px; background: var(--sp-primary); color: var(--sp-on-primary); font: 600 12.5px var(--ws-font); }
.ws-console .compatibility-warning { white-space: normal; font-family: var(--ws-font); margin-bottom: 10px; padding: 10px 12px; border-radius: 8px; background: var(--ws-warning-bg); border: 1px solid rgba(var(--sp-warning-rgb), .3); color: var(--sp-body); }
.ws-console .compatibility-warning-title { color: var(--sp-warning); font-weight: 600; margin-bottom: 4px; }
.ws-console img { max-width: 100%; border-radius: 8px; background: #fff; }

/* Arguments */
.ws-args { padding: 12px 14px; }
.ws-args label { display: block; font-size: 12px; color: var(--sp-muted); margin-bottom: 6px; }
.ws-field, .ws-args textarea {
    width: 100%; background: var(--sp-pre); border: 1px solid var(--sp-line); border-radius: 8px;
    color: var(--sp-light); font: 12.5px/1.6 var(--ws-mono); padding: 9px 10px; outline: none;
}
.ws-args textarea { height: 70px; resize: vertical; }
.ws-field:focus, .ws-args textarea:focus { border-color: var(--sp-secondary); }
.ws-help { font-size: 12px; color: var(--sp-dim); margin-top: 6px; }

.ws-empty { display: grid; place-items: center; text-align: center; color: var(--sp-dim); padding: 30px 20px; font-size: 13px; gap: 6px; }

/* ---------- Toast and modal ---------- */

.ws-toast {
    position: fixed; bottom: 22px; left: 50%; z-index: 100;
    transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
    display: flex; gap: 8px; align-items: center; max-width: calc(100% - 32px);
    background: var(--sp-panel-3); border: 1px solid var(--sp-line-2); border-radius: 10px;
    padding: 10px 16px; font-size: 13px; box-shadow: 0 16px 40px rgba(0, 0, 0, .5);
    transition: opacity .25s, transform .25s;
}
.ws-toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.ws-toast svg { width: 16px; height: 16px; flex-shrink: 0; }
.ws-toast b { color: var(--sp-light); }

.ws-modal-bg { position: fixed; inset: 0; z-index: 90; padding: 16px; background: rgba(2, 4, 10, .72); backdrop-filter: blur(4px); display: none; place-items: center; }
.ws-modal-bg.is-on { display: grid; animation: ws-fade .2s; }
.ws-modal { background: var(--sp-panel-2); border: 1px solid var(--sp-line-2); border-radius: 16px; padding: 26px; width: 100%; max-width: 440px; text-align: center; box-shadow: 0 30px 80px rgba(0, 0, 0, .6); max-height: calc(100vh - 32px); overflow: auto; }
.ws-modal.ws-wide { max-width: 760px; text-align: left; }
.ws-modal .ws-big { width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 14px; display: grid; place-items: center; background: var(--ws-success-bg); color: var(--sp-success); }
.ws-modal .ws-big svg { width: 30px; height: 30px; }
.ws-modal.is-fail .ws-big { background: var(--ws-danger-bg); color: var(--sp-danger); }
.ws-modal h2 { font: 700 20px var(--ws-font-display); margin: 0 0 6px; }
.ws-modal p { color: var(--sp-body); font-size: 13.5px; margin: 0 0 16px; }
.ws-modal .ws-prose { text-align: left; margin-bottom: 16px; font-size: 13.5px; }
.ws-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 18px; }
.ws-stats div { background: var(--sp-panel); border: 1px solid var(--sp-line); border-radius: 10px; padding: 10px 6px; }
.ws-stats b { display: block; font: 600 16px var(--ws-mono); }
.ws-stats small { color: var(--sp-dim); font-size: 11px; }
.ws-modal .ws-acts { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.ws-modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.ws-modal-head h2 { flex: 1; margin: 0; font-size: 17px; }
.ws-modal img { max-width: 100%; border-radius: 10px; background: #fff; display: block; margin: 0 auto 14px; }

@keyframes ws-fade { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ---------- Mobile ---------- */

.ws-mnav { display: none; }

@media (max-width: 900px) {
    body.ws-body { overflow: hidden; }
    .ws-top { padding: 0 10px; gap: 8px; }
    .ws-brand .ws-brand-logo { display: none; }
    .ws-brand .ws-brand-icon { display: block; }
    .ws-crumbs .ws-hide-m, .ws-top .ws-hide-m, .ws-kbd { display: none; }
    .ws-top .ws-btn .ws-lbl { display: none; }
    .ws-top .ws-btn { padding: 0 10px; }
    .ws-status { padding: 6px 8px; }
    .ws-status .ws-lbl { display: none; }

    .ws-main, .ws-main.ws-no-left { display: block; height: calc(100% - var(--ws-top) - var(--ws-mnav)); }
    .ws-vres, .ws-hres { display: none; }
    .ws-main > .ws-pane, .ws-main > .ws-right { display: none; height: 100%; }
    .ws-main[data-m="task"] > .ws-pane { display: flex; }
    .ws-main[data-m="code"] > .ws-right, .ws-main[data-m="out"] > .ws-right { display: flex; flex-direction: column; }
    .ws-main[data-m="code"] .ws-bottom { display: none; }
    .ws-main[data-m="out"] .ws-edcol { display: none; }
    .ws-main[data-m="out"] .ws-bottom { flex: 1; }
    .ws-edcol { flex: 1; }

    .ws-mnav {
        display: flex; position: fixed; left: 0; right: 0; bottom: 0; height: var(--ws-mnav); z-index: 40;
        background: var(--sp-panel); border-top: 1px solid var(--sp-line);
        padding-bottom: env(safe-area-inset-bottom);
    }
    .ws-mnav button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; color: var(--sp-dim); }
    .ws-mnav button svg { width: 18px; height: 18px; }
    .ws-mnav button.is-on { color: var(--sp-primary); }
    .ws-mnav[hidden] { display: none; }

    .ws-panel { padding: 16px 16px 30px; }
    .ws-gutter { width: 40px; }
    .ws-gutter div { padding-right: 9px; }
    .ws-codewrap pre, .ws-codewrap textarea { padding: 14px 12px; font-size: 16px; }   /* 16px stops iOS zooming in on focus */
    .ws-curline { display: none; }
    .ws-io { grid-template-columns: 1fr; }
    .ws-io dt { padding-top: 2px; }
    .ws-test-b { padding-left: 8px; }
    .ws-statusbar .ws-hide-m { display: none; }
    .ws-audio { flex-wrap: wrap; }
    .ws-audio .progress-bar { flex-basis: 100%; }
}

/* With no left pane the mobile layout has two views: code and output */
@media (max-width: 900px) {
    .ws-main.ws-no-left[data-m="task"] > .ws-right { display: flex; flex-direction: column; }
    .ws-main.ws-no-left[data-m="task"] .ws-bottom { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .ws-body *, .ws-body *::before, .ws-body *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- Audio lesson segments and line highlights (audio-lesson.js) ---------- */

.ws-body .segments { margin-top: 18px; display: flex; flex-direction: column; gap: 6px; }
.ws-body .segment { display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 10px; padding: 9px 10px; border-radius: 8px; border: 1px solid transparent; cursor: pointer; transition: background-color .15s, border-color .15s; }
.ws-body .segment:hover { background: var(--sp-panel-2); }
.ws-body .segment.played .segment__text { color: var(--sp-muted); }
.ws-body .segment.active { background: var(--ws-primary-bg); border-color: rgba(var(--sp-primary-rgb), .35); }
.ws-body .segment__time { font: 12px var(--ws-mono); color: var(--sp-dim); display: flex; flex-direction: column; gap: 3px; }
.ws-body .segment.active .segment__time { color: var(--sp-primary); }
.ws-body .lines-badge { font-size: 10.5px; color: var(--sp-muted); }
.ws-body .segment__text { color: var(--sp-body); font-size: 13.5px; }

.ws-body .line-hl { position: absolute; left: 0; right: 0; background: rgba(var(--sp-primary-rgb), .08); border-left: 2px solid rgba(var(--sp-primary-rgb), .5); }
.ws-body .line-hl--strong { background: rgba(var(--sp-primary-rgb), .16); border-left-color: var(--sp-primary); }
.ws-body .line-hl--part { right: auto; border-left: 0; border-radius: 3px; background: rgba(var(--sp-warning-rgb), .18); box-shadow: 0 0 0 1px rgba(var(--sp-warning-rgb), .35); }

/* ---------- Footer links in the left pane (prev / next, mark as done) ---------- */

.ws-pane-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--sp-line); }
.ws-pane-foot .ws-spacer { min-width: 8px; }

/* ==================================================================
 * Page pieces added with the real pages
 * ================================================================== */

/* Run turns into Stop while a program waits for input() */
.ws-btn.ws-stop { background: var(--ws-danger-bg) !important; border-color: rgba(var(--sp-danger-rgb), .5) !important; color: var(--sp-danger) !important; }
.ws-btn.ws-stop svg { display: none; }
.ws-btn.is-busy::after { content: ""; width: 12px; height: 12px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: ws-spin .7s linear infinite; }
.ws-btn.is-busy svg { display: none; }

/* Difficulty chips */
.ws-chip.ws-diff-1 { background: var(--ws-success-bg); color: var(--sp-success); }
.ws-chip.ws-diff-2 { background: var(--ws-warning-bg); color: var(--sp-warning); }
.ws-chip.ws-diff-3 { background: var(--ws-danger-bg); color: var(--sp-danger); }

/* Crumbs: the chip shouldn't squeeze the title */
.ws-crumbs .ws-chip { flex-shrink: 0; }

/* Stages */
.ws-stage-chip { display: inline-flex; }
.ws-locked-text { display: flex; gap: 8px; align-items: center; margin: 0 0 10px; color: var(--sp-muted); font-size: 13px; }
.ws-locked-text svg { width: 14px; height: 14px; flex-shrink: 0; }
.ws-objectives { margin-top: 6px; }
.ws-req-t { min-width: 0; }
.ws-req-t > p { margin: 0; }
.ws-req-t code { font-size: 12.5px; background: var(--sp-panel-3); color: #ffd7c9; padding: 1px 6px; border-radius: 5px; }
.ws-notice-acts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* Tests panel */
.ws-tgroup-t { min-width: 0; text-transform: none; letter-spacing: 0; font-size: 12.5px; font-weight: 600; }
.ws-tgroup-t p { display: inline; margin: 0; }
.ws-tgroup-t code { font: 12px var(--ws-mono); }
.ws-tgroup-h .ws-ck-s { display: grid; place-items: center; flex-shrink: 0; }
.ws-tgroup-h .ws-ck-s svg { width: 13px; height: 13px; }
.ws-tgroup-h.is-fail { color: var(--sp-danger); }
.ws-test-h:disabled { cursor: default; opacity: 1; }
.ws-test-h:disabled:hover { background: transparent; }
.ws-test.is-queued .ws-st { border-style: dashed; }
.ws-io dd.ws-io-code { color: var(--sp-light); }
.ws-test-b .ws-help { margin: 4px 0 0; }

/* Console extras */
.ws-console .terminal-stderr { color: var(--sp-warning); }
.ws-console .terminal-input { color: var(--sp-info); }
.ws-console .ws-out-img { display: block; max-width: min(100%, 520px); margin: 8px 0; cursor: zoom-in; }
.ws-console .ws-btn { margin-top: 10px; white-space: normal; }

/* Hints and solution */
.ws-hints { margin-top: 16px; }
.ws-hint .ws-lock { color: var(--sp-dim); display: grid; }
.ws-hint .ws-lock svg { width: 15px; height: 15px; }
.ws-hint-h .ws-btn { flex-shrink: 0; }
.ws-gate .ws-ico.ws-open { background: var(--ws-success-bg); color: var(--sp-success); }
.ws-gate .ws-acts { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.ws-meter-label { margin-top: -8px !important; font-size: 12px !important; }
.ws-empty svg { width: 22px; height: 22px; }

/* Lesson pane */
.ws-lesson { margin-top: 2px; }
.ws-prose .uc-title { font: 700 22px/1.25 var(--ws-font-display); color: var(--sp-light); margin: 0 0 10px; }
.ws-prose .uc-description { white-space: normal; color: var(--sp-body); }
.ws-prose .uc-status { font-size: 12.5px; color: var(--sp-muted); }
.ws-terms { margin-top: 20px; }
.ws-ccard { border: 1px solid var(--sp-line); background: var(--sp-panel-2); border-radius: var(--ws-r); padding: 14px 16px; margin: 14px 0; }
.ws-ccard .ws-h3 { margin-top: 0; }
.ws-ccard .ws-h3 a { color: var(--sp-light); text-decoration: none; }
.ws-ccard .ws-h3 a:hover { color: var(--sp-primary); }
.ws-ccard .ws-meta { margin-bottom: 10px; }
.ws-ccard-text { color: var(--sp-body); font-size: 13.5px; margin: 0 0 12px; }
.ws-example-content { margin-bottom: 8px; }

/* Dialogs with forms (save, share) */
.ws-modal.ws-form-modal { text-align: left; max-width: 480px; }
.ws-modal .ws-explain { text-align: left; background: var(--sp-panel); border: 1px solid var(--sp-line); border-radius: 10px; padding: 12px 14px; }
.ws-modal .ws-explain h3 { margin-top: 0; font-size: 14px; }
.ws-modal .ws-help { margin: -8px 0 16px; }
.ws-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--sp-muted); margin: 0 0 6px; }
.ws-field + .ws-label, textarea.ws-field + .ws-label { margin-top: 14px; }
.ws-form-modal .ws-field { font-family: var(--ws-font); font-size: 14px; }
.ws-form-modal textarea.ws-field { resize: vertical; min-height: 70px; }
.ws-check { display: flex; gap: 10px; align-items: center; margin: 16px 0 6px; font-size: 13.5px; color: var(--sp-body); cursor: pointer; }
.ws-check input { width: 17px; height: 17px; accent-color: var(--sp-primary); margin: 0; }
.ws-form-modal .ws-help { margin: 0 0 14px 27px; }
.ws-form-error { margin: 0 0 14px; padding: 9px 12px; border-radius: 8px; background: var(--ws-danger-bg); color: var(--sp-danger); font-size: 13px; }
.ws-form-modal .ws-acts { justify-content: flex-end; }
.ws-form-modal #ucDone { text-align: center; }
.ws-form-modal #ucDone .ws-acts { justify-content: center; margin-top: 16px; }
.ws-linkrow { display: flex; gap: 8px; text-align: left; }
.ws-linkrow .ws-field { flex: 1; min-width: 0; font-family: var(--ws-mono); font-size: 12.5px; }
#ucShare { text-align: left; margin-top: 4px; }

/* Older partials in the menus (Path module): hamburger-item / dropup-item */
.ws-path-slot { display: block; }
.ws-menu .hamburger-item, .ws-menu .dropup-item {
    display: flex; align-items: center; gap: 9px; width: 100%;
    padding: 8px 10px; border-radius: 7px; text-align: left; border: 0; background: none;
    color: var(--sp-body); font: 13px var(--ws-font); text-decoration: none; cursor: pointer;
}
.ws-menu .hamburger-item:hover, .ws-menu .dropup-item:hover { background: var(--sp-panel-3); color: var(--sp-light); }
.ws-menu .hamburger-item:disabled, .ws-menu .dropup-item:disabled { opacity: .5; cursor: not-allowed; }
.ws-menu .hamburger-divider { height: 1px; background: var(--sp-line-2); margin: 5px 4px; }
.ws-menu .hamburger-menu-title { padding: 6px 10px 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--sp-dim); }
.ws-menu form { margin: 0; }

/* Long menus scroll on short screens */
.ws-menu { max-height: calc(100vh - var(--ws-top) - 20px); overflow-y: auto; }
.ws-avatar svg { width: 17px; height: 17px; }

@media (max-width: 900px) {
    .ws-toast { bottom: calc(var(--ws-mnav) + 12px + env(safe-area-inset-bottom)); }
    .ws-menu { position: fixed; top: calc(var(--ws-top) + 4px); right: 8px; left: auto; max-width: calc(100vw - 16px); }
    .ws-modal { padding: 20px 18px; }
    .ws-form-modal .ws-help { margin-left: 0; }
}
