/* ============================================================
   CircuitLab — 零基础交互式电路学习平台
   设计方向：电子工坊美学 · 温暖 · 动手感 · 创客氛围
   ============================================================ */

/* ===== 设计令牌 ===== */
:root {
    /* 主色：琥珀暖光（像LED发光） */
    --amber: oklch(72% 0.16 65);
    --amber-light: oklch(85% 0.1 65);
    --amber-dark: oklch(52% 0.14 65);
    --amber-deep: oklch(38% 0.1 65);

    /* 辅助色：电路板青绿 */
    --teal: oklch(60% 0.1 185);
    --teal-light: oklch(80% 0.07 185);
    --teal-dark: oklch(42% 0.09 185);

    /* 语义色 */
    --success: oklch(58% 0.14 145);
    --success-light: oklch(88% 0.08 145);
    --warning: oklch(68% 0.16 55);
    --warning-light: oklch(88% 0.1 55);
    --danger: oklch(55% 0.2 25);
    --danger-light: oklch(88% 0.08 25);
    --info: oklch(58% 0.12 240);

    /* 暖色调中性色 */
    --neutral-0: oklch(99% 0.005 70);
    --neutral-50: oklch(97% 0.008 70);
    --neutral-100: oklch(94% 0.01 70);
    --neutral-200: oklch(89% 0.012 70);
    --neutral-300: oklch(82% 0.012 70);
    --neutral-400: oklch(68% 0.012 70);
    --neutral-500: oklch(55% 0.012 70);
    --neutral-600: oklch(42% 0.012 70);
    --neutral-700: oklch(32% 0.01 70);
    --neutral-800: oklch(22% 0.008 70);
    --neutral-900: oklch(15% 0.006 70);

    /* 表面色 */
    --bg: oklch(97% 0.008 70);
    --surface: oklch(99% 0.005 70);
    --surface-raised: oklch(100% 0 0);
    --surface-overlay: oklch(99% 0.006 70);

    /* 面包板专用色 */
    --bb-bg: oklch(88% 0.025 145);
    --bb-bg-dark: oklch(78% 0.03 145);
    --bb-hole: oklch(55% 0.01 70);
    --bb-hole-hover: oklch(45% 0.015 70);
    --bb-rail-pos: oklch(55% 0.16 25);
    --bb-rail-neg: oklch(50% 0.12 250);
    --bb-center: oklch(82% 0.025 145);

    /* 文字色 */
    --text-primary: var(--neutral-900);
    --text-secondary: var(--neutral-600);
    --text-tertiary: var(--neutral-400);
    --text-inverse: var(--neutral-0);

    /* 边框 */
    --border: oklch(90% 0.01 70);
    --border-strong: oklch(80% 0.012 70);

    /* 阴影 */
    --shadow-sm: 0 1px 2px oklch(0% 0 0 / 0.06);
    --shadow-md: 0 2px 8px oklch(0% 0 0 / 0.08), 0 1px 2px oklch(0% 0 0 / 0.04);
    --shadow-lg: 0 8px 24px oklch(0% 0 0 / 0.1), 0 2px 6px oklch(0% 0 0 / 0.06);
    --shadow-glow: 0 0 0 3px oklch(72% 0.16 65 / 0.2);

    /* 圆角 */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* 字体 */
    --font-display: 'Space Grotesk', system-ui, sans-serif;
    --font-body: 'Plus Jakarta Sans', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'Courier New', monospace;

    /* 过渡 */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

    /* 间距 */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;

    /* 面板宽度 */
    --panel-left-w: 260px;
    --panel-right-w: 420px;
    --topbar-h: 56px;
    --footer-h: 52px;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    overflow: hidden;
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

input, textarea, select {
    font-family: inherit;
    font-size: inherit;
}

svg { display: block; }

/* ===== 顶部导航栏 ===== */
.topbar {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-lg);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    position: relative;
    z-index: 100;
    gap: var(--space-lg);
}

.topbar-left, .topbar-right {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.topbar-center {
    display: flex;
    align-items: center;
    flex: 1;
    justify-content: center;
    max-width: 400px;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.logo-text {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 18px;
    letter-spacing: -0.02em;
    color: var(--amber-deep);
}

.board-switcher {
    display: flex;
    gap: 2px;
    padding: 3px;
    background: var(--neutral-100);
    border-radius: var(--radius-md);
}

.board-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s var(--ease-out);
}

.board-btn:hover {
    color: var(--text-primary);
    background: oklch(0% 0 0 / 0.04);
}

.board-btn.active {
    background: var(--surface-raised);
    color: var(--amber-dark);
    box-shadow: var(--shadow-sm);
    font-weight: 600;
}

/* 进度条 */
.progress-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    width: 100%;
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: var(--neutral-200);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--amber), var(--teal));
    border-radius: 3px;
    transition: width 0.5s var(--ease-out);
}

.progress-text {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    font-weight: 500;
}

/* 顶部按钮 */
.icon-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    background: var(--surface);
    transition: all 0.15s var(--ease-out);
}

.icon-btn:hover {
    color: var(--text-primary);
    border-color: var(--border-strong);
    box-shadow: var(--shadow-sm);
}

.icon-btn:active {
    transform: translateY(1px);
}

.save-btn.saved {
    color: var(--success);
    border-color: var(--success-light);
}

.save-status {
    font-size: 11px;
    color: var(--text-tertiary);
}

/* ===== 主工作区布局 ===== */
.workspace {
    display: flex;
    height: calc(100vh - var(--topbar-h));
    overflow: hidden;
}

.panel {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    overflow: hidden;
}

.panel-left {
    width: var(--panel-left-w);
    border-right: 1px solid var(--border);
    flex-shrink: 0;
}

.panel-center {
    flex: 1;
    min-width: 0;
}

.panel-right {
    width: var(--panel-right-w);
    border-left: 1px solid var(--border);
    flex-shrink: 0;
}

.panel-header {
    padding: var(--space-md);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.panel-title {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.panel-hint {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 2px;
    display: block;
}

/* ===== 左侧：元件库 ===== */
.panel-search {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    margin: 0 var(--space-md) var(--space-sm);
    background: var(--neutral-50);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
}

.panel-search input {
    flex: 1;
    border: none;
    background: none;
    outline: none;
    font-size: 13px;
    color: var(--text-primary);
}

.panel-search input::placeholder {
    color: var(--text-tertiary);
}

.component-categories {
    flex: 1;
    overflow-y: auto;
    padding: 0 var(--space-md) var(--space-md);
}

.component-categories::-webkit-scrollbar { width: 6px; }
.component-categories::-webkit-scrollbar-track { background: transparent; }
.component-categories::-webkit-scrollbar-thumb { background: var(--neutral-300); border-radius: 3px; }

.component-category {
    margin-bottom: var(--space-md);
}

.category-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    margin-bottom: 8px;
    padding-left: 2px;
}

.component-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.component-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px 6px;
    background: var(--neutral-50);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s var(--ease-out);
    text-align: center;
}

.component-item:hover {
    background: var(--amber-light);
    border-color: var(--amber);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.component-item.selected {
    background: var(--amber);
    border-color: var(--amber-dark);
    color: white;
    box-shadow: var(--shadow-glow);
}

.component-item.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.component-item svg {
    width: 32px;
    height: 32px;
}

.component-item .comp-name {
    font-size: 11px;
    font-weight: 500;
    line-height: 1.2;
}

/* ===== 中间：面包板 ===== */
.breadboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px var(--space-md);
}

.tool-tabs {
    display: flex;
    gap: 2px;
    padding: 3px;
    background: var(--neutral-100);
    border-radius: var(--radius-sm);
}

.tool-tab {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.15s var(--ease-out);
}

.tool-tab:hover { color: var(--text-primary); }
.tool-tab.active {
    background: var(--surface-raised);
    color: var(--amber-dark);
    box-shadow: var(--shadow-sm);
    font-weight: 600;
}

/* 撤销按钮 */
.undo-btn {
    margin-left: 6px;
    border-left: 1px solid var(--border);
    border-radius: 0;
    padding-left: 14px;
}
.undo-btn:hover:not(:disabled) {
    color: var(--teal-dark);
}
.undo-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.breadboard-info {
    display: flex;
    gap: 6px;
}

.info-chip {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--neutral-100);
    padding: 3px 8px;
    border-radius: 10px;
}

.breadboard-container {
    flex: 1;
    overflow: auto;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: var(--space-sm) var(--space-md);
    background: var(--neutral-50);
    position: relative;
}

.breadboard-container::-webkit-scrollbar { width: 8px; height: 8px; }
.breadboard-container::-webkit-scrollbar-thumb { background: var(--neutral-300); border-radius: 4px; }

/* SVG 面包板样式 */
.bb-svg {
    background: var(--bb-bg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md), inset 0 1px 3px oklch(0% 0 0 / 0.1);
    margin: auto;
    flex-shrink: 0;
}

.bb-hole {
    fill: var(--bb-hole);
    transition: fill 0.1s;
    cursor: pointer;
}

.bb-hole:hover {
    fill: var(--amber);
}

.bb-hole.connected {
    fill: var(--neutral-700);
}

.bb-hole.power-pos { fill: var(--bb-rail-pos); }
.bb-hole.power-neg { fill: var(--bb-rail-neg); }

.bb-rail-label {
    font-family: var(--font-mono);
    font-size: 8px;
    font-weight: 800;
    fill: var(--neutral-600);
    pointer-events: none;
}

.pin-label-power {
    font-size: 8px;
    font-weight: 800;
}

.arduino-panel-title {
    font-family: var(--font-mono);
    font-size: 7px;
    font-weight: 800;
    fill: var(--teal-dark);
    pointer-events: none;
}

.led-polarity-label {
    font-size: 9px;
    font-weight: 800;
}

.bb-row-label {
    font-family: var(--font-mono);
    font-size: 8px;
    fill: var(--neutral-400);
    pointer-events: none;
}

/* 面包板上的元件 */
.bb-component {
    cursor: pointer;
    transition: filter 0.2s;
}

.bb-component:hover {
    filter: drop-shadow(0 2px 4px oklch(0% 0 0 / 0.2));
}

.bb-component.selected {
    filter: drop-shadow(0 0 6px var(--amber));
}

.bb-component.led-on .led-body {
    filter: drop-shadow(0 0 8px currentColor);
}

/* 导线 */
.bb-wire {
    pointer-events: stroke;
    cursor: pointer;
    transition: stroke-width 0.15s;
}

.bb-wire:hover {
    stroke-width: 4;
}

.bb-wire.selected {
    stroke-width: 5;
    filter: drop-shadow(0 0 4px var(--amber));
}

/* 接线预览线 */
.wire-preview {
    stroke: var(--amber);
    stroke-width: 2.5;
    stroke-dasharray: 4 3;
    fill: none;
    pointer-events: none;
    opacity: 0.6;
}

/* 引脚标记 */
.pin-label {
    font-family: var(--font-mono);
    font-size: 7px;
    fill: var(--neutral-700);
    pointer-events: none;
    font-weight: 600;
}

/* 电机运行状态 */
.motor-fwd .motor-wheel { animation: motorSpin 0.42s linear infinite; transform-origin: center; }
.motor-rev .motor-wheel { animation: motorSpinReverse 0.42s linear infinite; transform-origin: center; }
@keyframes motorSpin { to { transform: rotate(360deg); } }
@keyframes motorSpinReverse { to { transform: rotate(-360deg); } }

/* 小车试车场 */
.car-stage-wrap {
    flex: 0 0 auto;
    padding: var(--space-md);
    border-top: 1px solid var(--border);
    background: oklch(96% 0.018 155);
}

.car-stage-header {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: var(--space-md);
    margin-bottom: var(--space-sm);
}

.car-stage-eyebrow {
    display: block;
    color: var(--teal-dark);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

.car-stage-header h3 {
    margin: 2px 0 0;
    font-size: 15px;
    color: var(--text-primary);
}

.car-stage-metrics {
    display: flex;
    gap: var(--space-md);
    color: var(--text-secondary);
    font-size: 12px;
}

.car-stage-metrics strong { color: var(--teal-dark); }

.car-stage-content {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 118px;
    gap: var(--space-md);
    align-items: center;
}

.car-arena {
    width: 100%;
    display: block;
    border-radius: var(--radius-sm);
    border: 2px solid oklch(55% 0.08 155);
    overflow: hidden;
}

.arena-floor { fill: oklch(90% 0.035 155); }
.arena-grid { fill: oklch(95% 0.025 155); stroke: oklch(60% 0.07 155); stroke-width: 2; }
.arena-track { fill: none; stroke: oklch(73% 0.15 70); stroke-width: 10; stroke-linecap: round; opacity: 0.42; }
.arena-wall-labels text { fill: oklch(43% 0.05 155); font-family: var(--font-mono); font-size: 7px; }
.car-distance-line { stroke: oklch(60% 0.14 70); stroke-width: 1.5; stroke-dasharray: 4 3; }
.car-body { fill: oklch(50% 0.11 225); stroke: oklch(34% 0.09 225); stroke-width: 1.5; }
.car-deck { fill: oklch(78% 0.12 70); stroke: oklch(54% 0.13 70); stroke-width: 1; }
.car-wheel { fill: oklch(26% 0.01 70); }
.car-sensor { fill: oklch(70% 0.13 35); stroke: oklch(45% 0.12 35); stroke-width: 1; }
.car-sensor-core { fill: oklch(30% 0.02 35); }
.car-direction { fill: none; stroke: oklch(27% 0.04 225); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.car-controller { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.controller-label { color: var(--text-secondary); font-size: 11px; font-weight: 700; }
.controller-hint { color: var(--text-tertiary); font-size: 10px; text-align: center; }
.joystick-pad {
    width: 100px;
    height: 100px;
    position: relative;
    border-radius: 50%;
    border: 2px solid oklch(62% 0.1 185);
    background: oklch(90% 0.04 185);
    touch-action: none;
    outline: none;
}
.joystick-pad:focus-visible { box-shadow: var(--shadow-glow); }
.joystick-axis { position: absolute; background: oklch(57% 0.07 185 / 0.5); }
.axis-x { width: 72px; height: 1px; left: 12px; top: 49px; }
.axis-y { width: 1px; height: 72px; left: 49px; top: 12px; }
.joystick-knob {
    position: absolute;
    width: 34px;
    height: 34px;
    left: 31px;
    top: 31px;
    border-radius: 50%;
    background: var(--teal-dark);
    border: 3px solid oklch(91% 0.04 185);
    box-shadow: 0 2px 4px oklch(35% 0.08 185 / 0.25);
    transition: transform 0.1s var(--ease-out);
}
.joystick-dir { position: absolute; color: oklch(43% 0.08 185); font-size: 9px; pointer-events: none; }
.joystick-dir-up { top: 3px; left: 45px; }
.joystick-dir-down { bottom: 3px; left: 45px; }
.joystick-dir-left { left: 4px; top: 43px; }
.joystick-dir-right { right: 4px; top: 43px; }

/* 面包板底部 */
.breadboard-footer {
    height: var(--footer-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-md);
    border-top: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}

.simulation-controls {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.sim-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 7px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    transition: all 0.15s var(--ease-out);
}

.run-btn {
    background: var(--success);
    color: white;
}

.run-btn:hover {
    background: oklch(52% 0.14 145);
    box-shadow: var(--shadow-md);
}

.run-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.stop-btn {
    background: var(--danger);
    color: white;
}

.stop-btn:hover {
    background: oklch(50% 0.2 25);
}

.stop-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.temp-slider-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: var(--space-sm);
    padding-left: var(--space-md);
    border-left: 1px solid var(--border);
}

.temp-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.temp-slider {
    width: 120px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--neutral-200);
    border-radius: 2px;
    outline: none;
}

.temp-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--amber);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

.temp-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--amber);
    cursor: pointer;
    border: none;
}

.temp-value {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 600;
    color: var(--amber-dark);
    min-width: 42px;
}

.simulation-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--neutral-400);
}

.status-dot.idle { background: var(--neutral-400); }
.status-dot.running { background: var(--success); animation: pulse 1.5s ease-in-out infinite; }
.status-dot.error { background: var(--danger); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ===== 右侧面板 ===== */
.right-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.right-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 8px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    transition: all 0.15s var(--ease-out);
}

.right-tab:hover { color: var(--text-primary); }

.right-tab.active {
    color: var(--amber-dark);
    border-bottom-color: var(--amber);
    font-weight: 600;
}

.tab-content {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
}

.tab-content.active {
    display: flex;
}

/* ===== 教程面板 ===== */
.tutorial-header {
    padding: var(--space-md);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.tutorial-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.tutorial-badge {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--amber-dark);
    background: var(--amber-light);
    padding: 2px 8px;
    border-radius: 10px;
}

.tutorial-header h3 {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.tutorial-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.tutorial-steps {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md);
}

.tutorial-steps::-webkit-scrollbar { width: 6px; }
.tutorial-steps::-webkit-scrollbar-thumb { background: var(--neutral-300); border-radius: 3px; }

.tutorial-step {
    display: none;
}

.tutorial-step.active {
    display: block;
    animation: fadeInUp 0.4s var(--ease-out);
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--amber);
    color: white;
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 700;
    margin-bottom: var(--space-sm);
}

.step-title {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 600;
    margin-bottom: var(--space-sm);
    letter-spacing: -0.01em;
}

.step-instruction {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-primary);
    margin-bottom: var(--space-md);
}

.step-instruction strong {
    color: var(--amber-dark);
    font-weight: 600;
}

.step-instruction code {
    font-family: var(--font-mono);
    font-size: 12px;
    background: var(--neutral-100);
    padding: 1px 5px;
    border-radius: 3px;
    color: var(--teal-dark);
}

.step-visual {
    background: var(--neutral-50);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-bottom: var(--space-md);
    text-align: center;
}

.step-visual svg {
    max-width: 100%;
    height: auto;
}

.step-tip {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    background: var(--warning-light);
    border-left: 3px solid var(--warning);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 12px;
    line-height: 1.5;
    color: var(--neutral-800);
    margin-bottom: var(--space-sm);
}

.step-tip svg { flex-shrink: 0; margin-top: 1px; }

.step-check {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    transition: all 0.3s var(--ease-out);
}

.step-check.pending {
    background: var(--neutral-100);
    color: var(--text-secondary);
}

.step-check.success {
    background: var(--success-light);
    color: var(--success);
}

.step-check.error {
    background: var(--danger-light);
    color: var(--danger);
}

.step-check .check-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.step-action-btn {
    width: 100%;
    padding: 10px;
    border-radius: var(--radius-sm);
    background: var(--amber);
    color: white;
    font-size: 13px;
    font-weight: 600;
    margin-top: var(--space-sm);
    transition: all 0.15s var(--ease-out);
}

.step-action-btn:hover {
    background: var(--amber-dark);
    box-shadow: var(--shadow-md);
}

.step-action-btn.secondary {
    background: var(--neutral-100);
    color: var(--text-secondary);
}

.step-action-btn.secondary:hover {
    background: var(--neutral-200);
}

/* 教程导航 */
.tutorial-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    transition: all 0.15s var(--ease-out);
}

.prev-btn {
    background: var(--neutral-100);
    color: var(--text-secondary);
}

.prev-btn:hover:not(:disabled) {
    background: var(--neutral-200);
    color: var(--text-primary);
}

.next-btn {
    background: var(--amber);
    color: white;
}

.next-btn:hover:not(:disabled) {
    background: var(--amber-dark);
    box-shadow: var(--shadow-md);
}

.nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.step-dots {
    display: flex;
    gap: 4px;
}

.step-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--neutral-300);
    transition: all 0.2s var(--ease-out);
}

.step-dot.completed { background: var(--success); }
.step-dot.current {
    background: var(--amber);
    width: 18px;
    border-radius: 3px;
}

/* ===== 代码编辑器 ===== */
.code-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.code-filename {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.code-actions {
    display: flex;
    gap: 4px;
}

.code-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    background: var(--surface);
    transition: all 0.15s var(--ease-out);
}

.code-btn:hover {
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.code-btn.upload-btn {
    background: var(--teal);
    color: white;
    border-color: var(--teal-dark);
}

.code-btn.upload-btn:hover {
    background: var(--teal-dark);
}

.code-editor-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
}

.line-numbers {
    padding: 12px 8px 12px 12px;
    text-align: right;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-tertiary);
    background: var(--neutral-50);
    border-right: 1px solid var(--border);
    user-select: none;
    overflow: hidden;
    white-space: pre;
    flex-shrink: 0;
}

.code-highlight {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 12px 16px;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    pointer-events: none;
    overflow: auto;
    margin: 0;
}

.code-input {
    position: absolute;
    top: 0;
    left: 0;
    width: calc(100% - 0px);
    height: 100%;
    padding: 12px 16px;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    background: transparent;
    color: transparent;
    caret-color: var(--amber-dark);
    border: none;
    outline: none;
    resize: none;
    overflow: auto;
}

.code-input::selection {
    background: oklch(72% 0.16 65 / 0.25);
}

/* 语法高亮 */
.code-highlight .tok-keyword { color: oklch(50% 0.18 300); font-weight: 500; }
.code-highlight .tok-type { color: oklch(45% 0.14 250); font-weight: 500; }
.code-highlight .tok-string { color: oklch(45% 0.13 145); }
.code-highlight .tok-number { color: oklch(50% 0.16 55); }
.code-highlight .tok-comment { color: var(--text-tertiary); font-style: italic; }
.code-highlight .tok-function { color: oklch(45% 0.16 30); }
.code-highlight .tok-variable { color: var(--neutral-800); }
.code-highlight .tok-constant { color: oklch(45% 0.16 250); font-weight: 500; }
.code-highlight .tok-operator { color: var(--neutral-600); }
.code-highlight .tok-punct { color: var(--neutral-500); }

/* 代码提示区 */
.code-hints-area {
    padding: 8px 12px;
    border-top: 1px solid var(--border);
    max-height: 120px;
    overflow-y: auto;
    flex-shrink: 0;
}

.code-hint-item {
    display: flex;
    gap: 8px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    line-height: 1.4;
    margin-bottom: 4px;
    animation: fadeInUp 0.2s var(--ease-out);
}

.code-hint-item.warning {
    background: var(--warning-light);
    color: var(--neutral-800);
}

.code-hint-item.error {
    background: var(--danger-light);
    color: var(--danger);
}

.code-hint-item.info {
    background: oklch(88% 0.06 240);
    color: var(--info);
}

.code-hint-item.success {
    background: var(--success-light);
    color: var(--success);
}

.code-hint-item .hint-icon-sm {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    margin-top: 1px;
}

.code-hints-empty {
    font-size: 11px;
    color: var(--text-tertiary);
    text-align: center;
    padding: 8px;
}

/* ===== 串口监视器 ===== */
.console-toolbar {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.console-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    flex: 1;
}

.baud-rate {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-tertiary);
}

.baud-rate select {
    padding: 2px 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 11px;
    font-family: var(--font-mono);
}

.console-btn {
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    background: var(--surface);
}

.console-btn:hover {
    background: var(--neutral-100);
}

.console-output {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.6;
    background: oklch(20% 0.01 70);
    color: oklch(85% 0.02 145);
}

.console-output::-webkit-scrollbar { width: 6px; }
.console-output::-webkit-scrollbar-thumb { background: oklch(40% 0.01 70); border-radius: 3px; }

.console-line {
    white-space: pre-wrap;
    word-break: break-all;
    animation: fadeIn 0.1s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.console-line .timestamp { color: oklch(60% 0.02 145); }
.console-line .data { color: oklch(80% 0.05 65); }
.console-line .error { color: oklch(70% 0.15 25); }
.console-line .info { color: oklch(70% 0.1 200); }

.console-empty {
    color: oklch(50% 0.02 145);
    text-align: center;
    padding: var(--space-lg);
    font-style: italic;
}

/* ===== 智能提示弹窗 ===== */
.hint-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: oklch(0% 0 0 / 0.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.hint-popup.active { display: flex; }

.hint-popup-content {
    background: var(--surface-raised);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 440px;
    width: 90%;
    padding: var(--space-lg);
    animation: scaleIn 0.3s var(--ease-out);
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.hint-popup-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: var(--space-md);
}

.hint-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.hint-icon.warning { background: var(--warning-light); color: var(--warning); }
.hint-icon.error { background: var(--danger-light); color: var(--danger); }
.hint-icon.info { background: oklch(88% 0.06 240); color: var(--info); }
.hint-icon.success { background: var(--success-light); color: var(--success); }

.hint-title {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 600;
}

.hint-popup-body {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-primary);
    margin-bottom: var(--space-lg);
}

.hint-popup-body strong { color: var(--amber-dark); }
.hint-popup-body code {
    font-family: var(--font-mono);
    font-size: 12px;
    background: var(--neutral-100);
    padding: 1px 5px;
    border-radius: 3px;
}

.hint-popup-body .hint-detail {
    background: var(--neutral-50);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-top: 10px;
    font-size: 12px;
}

.hint-popup-close {
    width: 100%;
    padding: 10px;
    border-radius: var(--radius-sm);
    background: var(--amber);
    color: white;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.15s var(--ease-out);
}

.hint-popup-close:hover {
    background: var(--amber-dark);
}

/* ===== Toast 通知 ===== */
.toast-container {
    position: fixed;
    top: calc(var(--topbar-h) + 12px);
    right: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 999;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    background: var(--surface-raised);
    box-shadow: var(--shadow-lg);
    max-width: 360px;
    font-size: 12px;
    line-height: 1.4;
    animation: slideInRight 0.3s var(--ease-out);
    pointer-events: auto;
    border-left: 3px solid;
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

.toast.fade-out {
    animation: slideOutRight 0.3s var(--ease-out) forwards;
}

@keyframes slideOutRight {
    to { opacity: 0; transform: translateX(20px); }
}

.toast.warning { border-left-color: var(--warning); }
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }
.toast.info { border-left-color: var(--info); }

.toast-icon {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    margin-top: 1px;
}

.toast.warning .toast-icon { color: var(--warning); }
.toast.error .toast-icon { color: var(--danger); }
.toast.success .toast-icon { color: var(--success); }
.toast.info .toast-icon { color: var(--info); }

.toast-body { flex: 1; }
.toast-title { font-weight: 600; margin-bottom: 2px; }
.toast-message { color: var(--text-secondary); }

/* ===== 元件详情浮窗 ===== */
.component-detail {
    position: fixed;
    z-index: 500;
    display: none;
    pointer-events: none;
}

.component-detail.active {
    display: block;
}

.detail-content {
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: var(--space-md);
    max-width: 240px;
    pointer-events: auto;
}

.detail-title {
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    padding: 3px 0;
    border-bottom: 1px solid var(--border);
}

.detail-row:last-child { border-bottom: none; }

.detail-label { color: var(--text-tertiary); }
.detail-value { color: var(--text-primary); font-weight: 500; }

/* ===== 响应式 ===== */
@media (max-width: 1200px) {
    :root {
        --panel-left-w: 220px;
        --panel-right-w: 360px;
    }
}

@media (max-width: 900px) {
    .panel-left { display: none; }
    :root { --panel-right-w: 320px; }
    .car-stage-header { align-items: start; }
    .car-stage-content { grid-template-columns: 1fr; }
    .car-controller { flex-direction: row; justify-content: center; }
}

/* ===== 工具类 ===== */
.hidden { display: none !important; }

/* ============================================================
   课程体系（课程列表 + 课程卡片）
   ============================================================ */

#courseListView {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
}

.course-overview {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 10px 14px;
    background: var(--amber-light);
    border: 1px solid oklch(80% 0.09 65 / 0.5);
    border-radius: 10px;
    margin-bottom: 12px;
}

.overview-num {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
    color: var(--amber-dark);
}

.overview-bar {
    flex: 1;
    height: 6px;
    background: oklch(90% 0.04 65);
    border-radius: 3px;
    overflow: hidden;
    display: block;
}

.overview-fill {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--amber), var(--amber-dark));
    border-radius: 3px;
    transition: width 0.4s ease;
}

.payment-banner {
    display: grid;
    gap: 10px;
    padding: 12px;
    margin: 0 0 12px;
    background: var(--amber-light);
    border: 1px solid oklch(80% 0.09 65 / 0.65);
    border-radius: 8px;
}

.payment-banner[hidden] {
    display: none;
}

.payment-banner-copy {
    display: grid;
    gap: 3px;
}

.payment-banner-copy strong {
    color: var(--text-primary);
    font-size: 13px;
}

.payment-banner-copy span {
    color: var(--text-secondary);
    font-size: 11px;
    line-height: 1.4;
}

.payment-banner-actions {
    display: flex;
    gap: 8px;
}

.payment-button,
.payment-check-button {
    flex: 1;
    border: 0;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 12px;
    cursor: pointer;
}

.payment-button {
    color: white;
    background: var(--amber-dark);
}

.payment-check-button {
    color: var(--text-primary);
    background: var(--surface-raised);
    border: 1px solid var(--border);
}

.payment-button:disabled,
.payment-check-button:disabled {
    cursor: wait;
    opacity: 0.6;
}

.free-lab-entry {
    width: 100%;
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) 16px;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    margin: 0 0 12px;
    color: var(--text-primary);
    background: oklch(96% 0.035 190);
    border: 1px solid oklch(76% 0.1 190 / 0.7);
    border-radius: 8px;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.16s var(--ease-out), background 0.16s var(--ease-out), transform 0.16s var(--ease-out);
}

.free-lab-entry:hover {
    background: oklch(93% 0.055 190);
    border-color: var(--teal);
    transform: translateY(-1px);
}

.free-lab-entry.locked {
    color: var(--text-secondary);
    background: var(--neutral-100);
    border-color: var(--border);
}

.free-lab-entry.locked .free-lab-entry-icon {
    color: var(--text-secondary);
    background: var(--neutral-200);
}

.free-lab-entry-icon {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 7px;
    color: var(--teal-dark);
    background: oklch(86% 0.09 190);
    font-size: 25px;
    font-weight: 700;
    line-height: 1;
}

.free-lab-entry-copy {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.free-lab-entry-copy strong {
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 700;
}

.free-lab-entry-copy small {
    overflow: hidden;
    color: var(--text-secondary);
    font-size: 11px;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.free-lab-entry-arrow {
    color: var(--teal-dark);
    font-size: 24px;
    line-height: 1;
}

#freeLabView {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
    padding: 12px;
    overflow-y: auto;
}

.free-lab-header {
    padding: 4px 0 12px;
    border-bottom: 1px solid var(--border);
}

.free-lab-header h3 {
    margin: 7px 0 5px;
    font-family: var(--font-display);
    font-size: 17px;
    line-height: 1.2;
}

.free-lab-header p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.55;
}

.free-lab-status {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
    padding: 12px 0;
}

.free-lab-state {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    padding: 7px 8px;
    color: var(--text-secondary);
    background: var(--neutral-100);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
}

.free-lab-dot {
    width: 7px;
    height: 7px;
    flex: 0 0 7px;
    border-radius: 50%;
    background: var(--neutral-400);
}

.free-lab-state.is-ready {
    color: var(--teal-dark);
    background: oklch(96% 0.03 190);
    border-color: oklch(76% 0.1 190 / 0.55);
}

.free-lab-state.is-ready .free-lab-dot { background: var(--teal); }

.free-lab-state.is-active {
    color: var(--success);
    background: var(--success-light);
    border-color: oklch(75% 0.1 145 / 0.55);
}

.free-lab-state.is-active .free-lab-dot {
    background: var(--success);
    animation: pulse 1.2s ease-in-out infinite;
}

.ai-code-assistant {
    margin: 2px 0 12px;
    padding: 12px;
    background: oklch(96% 0.028 265);
    border: 1px solid oklch(80% 0.075 265);
    border-radius: 8px;
}

.ai-code-assistant-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 9px;
}

.ai-code-kicker {
    display: block;
    color: var(--info);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0;
}

.ai-code-assistant h4 {
    margin-top: 2px;
    font-family: var(--font-display);
    font-size: 13px;
    line-height: 1.25;
}

.ai-code-status {
    flex: 0 0 auto;
    padding: 3px 6px;
    color: var(--text-secondary);
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 10px;
    font-weight: 700;
}

.ai-code-status.is-ready { color: var(--success); }
.ai-code-status.is-error { color: var(--danger); }

.ai-code-prompt {
    display: block;
    width: 100%;
    min-height: 66px;
    padding: 8px 9px;
    color: var(--text-primary);
    background: var(--surface-raised);
    border: 1px solid oklch(76% 0.05 265);
    border-radius: 6px;
    outline: none;
    resize: vertical;
    font-size: 12px;
    line-height: 1.45;
}

.ai-code-prompt:focus {
    border-color: var(--info);
    box-shadow: 0 0 0 3px oklch(58% 0.12 240 / 0.12);
}

.ai-code-prompt::placeholder { color: var(--text-tertiary); }

.ai-code-examples {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin: 8px 0;
}

.ai-code-example {
    padding: 4px 7px;
    color: var(--info);
    background: var(--surface-raised);
    border: 1px solid oklch(78% 0.06 265);
    border-radius: 5px;
    font-size: 10px;
    font-weight: 700;
}

.ai-code-example:hover { border-color: var(--info); background: oklch(93% 0.04 265); }

.ai-mode-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    margin-bottom: 8px;
    padding: 3px;
    background: oklch(91% 0.025 265);
    border: 1px solid oklch(82% 0.05 265);
    border-radius: 6px;
}

.ai-mode-btn {
    min-height: 29px;
    padding: 5px 7px;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 800;
}

.ai-mode-btn.is-active {
    color: var(--info);
    background: var(--surface-raised);
    border-color: oklch(78% 0.06 265);
}

.ai-code-generate {
    display: flex;
    width: 100%;
    min-height: 34px;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--text-inverse);
    background: var(--info);
    border: 1px solid oklch(48% 0.12 240);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 800;
    transition: background 0.15s var(--ease-out), transform 0.15s var(--ease-out);
}

.ai-code-generate:hover:not(:disabled) { background: oklch(50% 0.12 240); }
.ai-code-generate:active:not(:disabled) { transform: translateY(1px); }
.ai-code-generate:disabled { opacity: 0.7; cursor: wait; }
.ai-code-generate-mark { font-size: 15px; line-height: 1; }

.ai-code-result {
    min-height: 36px;
    margin-top: 8px;
    color: var(--text-secondary);
    font-size: 11px;
    line-height: 1.45;
}

.ai-code-result.is-error { color: var(--danger); }

.ai-guide-panel {
    margin-top: 9px;
    padding: 10px;
    background: oklch(96% 0.03 155);
    border: 1px solid oklch(78% 0.075 155);
    border-left: 3px solid var(--teal);
    border-radius: 6px;
}

.ai-guide-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.ai-guide-kicker {
    color: var(--teal-dark);
    font-size: 10px;
    font-weight: 800;
}

.ai-guide-progress {
    color: var(--teal-dark);
    font-size: 11px;
    font-weight: 800;
}

.ai-guide-panel h5 {
    margin: 6px 0 3px;
    color: var(--text-primary);
    font-family: var(--font-display);
    font-size: 13px;
}

.ai-guide-panel p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 11px;
    line-height: 1.5;
}

.ai-guide-steps {
    display: grid;
    gap: 6px;
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
    counter-reset: guide-step;
}

.ai-guide-step {
    position: relative;
    padding: 7px 8px 7px 31px;
    color: var(--text-secondary);
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 11px;
    line-height: 1.4;
}

.ai-guide-step::before {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 16px;
    height: 16px;
    display: grid;
    place-items: center;
    color: var(--text-secondary);
    border: 1px solid var(--neutral-400);
    border-radius: 50%;
    content: counter(guide-step);
    counter-increment: guide-step;
    font-size: 9px;
    font-weight: 800;
}

.ai-guide-step.is-current { color: var(--teal-dark); border-color: var(--teal); }
.ai-guide-step.is-current::before { color: var(--surface-raised); background: var(--teal); border-color: var(--teal); }
.ai-guide-step.is-done { color: var(--success); background: var(--success-light); border-color: oklch(75% 0.1 145 / 0.55); }
.ai-guide-step.is-done::before { color: var(--surface-raised); background: var(--success); border-color: var(--success); content: '✓'; }
.ai-guide-step strong, .ai-guide-step small { display: block; }
.ai-guide-step small { margin-top: 2px; color: var(--text-tertiary); font-size: 10px; }

.free-lab-feedback {
    min-height: 58px;
    padding: 10px;
    color: var(--text-secondary);
    background: var(--neutral-100);
    border-left: 3px solid var(--amber);
    font-size: 12px;
    line-height: 1.5;
}

.free-lab-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 12px;
}

.free-lab-action {
    min-height: 34px;
    padding: 7px 9px;
    color: var(--text-primary);
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
}

.free-lab-action:hover { border-color: var(--amber); }
.free-lab-action.primary { color: var(--text-inverse); background: var(--teal); border-color: var(--teal); }
.free-lab-action.danger { grid-column: 1 / -1; color: var(--danger); }

.course-units {
    overflow-y: auto;
    padding-right: 2px;
    flex: 1;
}

.course-unit { margin-bottom: 18px; }

.course-unit-header {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 8px;
    padding: 8px 10px;
    border-left: 3px solid var(--amber);
    background: var(--neutral-100);
    border-radius: 0 8px 8px 0;
}

.course-unit-name {
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
}

.course-unit-tagline {
    font-size: 11px;
    color: var(--text-tertiary);
}

.course-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.course-card {
    display: flex;
    gap: 10px;
    padding: 10px 12px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}

.course-card:hover:not(.locked) {
    border-color: var(--amber);
    box-shadow: 0 3px 12px oklch(72% 0.16 65 / 0.18);
    transform: translateY(-1px);
}

.course-card.locked {
    opacity: 0.55;
    cursor: not-allowed;
    background: var(--neutral-100);
}

.course-card.done {
    border-color: oklch(75% 0.1 145 / 0.6);
    background: var(--success-light);
}

.course-card-icon {
    font-size: 22px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--amber-light);
    border-radius: 10px;
    flex-shrink: 0;
}

.course-card.locked .course-card-icon {
    background: var(--neutral-200);
}

.course-card-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.course-card-title {
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
}

.course-card-sub {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.course-card-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.course-difficulty {
    font-size: 10px;
    letter-spacing: 1px;
    color: var(--amber-dark);
}

.course-status {
    font-size: 10px;
    padding: 1px 7px;
    border-radius: 8px;
    font-weight: 600;
}

.course-status.done-badge {
    background: var(--success-light);
    color: var(--success);
    border: 1px solid oklch(75% 0.1 145 / 0.5);
}

.course-status.doing-badge {
    background: var(--warning-light);
    color: var(--warning);
    border: 1px solid oklch(80% 0.1 55 / 0.5);
}

.course-card-progress {
    height: 4px;
    background: var(--neutral-200);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 3px;
}

.course-progress-fill {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--teal), var(--teal-dark));
    border-radius: 2px;
    transition: width 0.3s ease;
}

.course-card.done .course-progress-fill {
    background: linear-gradient(90deg, var(--success), var(--success));
}

.course-card-steps {
    font-size: 10px;
    color: var(--text-tertiary);
}

/* ===== 返回课程列表按钮 ===== */
.back-to-courses {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    align-self: flex-start;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--neutral-100);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 5px 10px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.back-to-courses:hover {
    color: var(--amber-dark);
    border-color: var(--amber);
    background: var(--amber-light);
}

#courseStepView {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
}

/* ===== 步骤操作按钮（我已了解，继续） ===== */
.step-action-btn {
    align-self: flex-start;
    margin-top: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-inverse);
    background: var(--teal);
    border: none;
    border-radius: 8px;
    padding: 6px 14px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.step-action-btn:hover { background: var(--teal-dark); }

/* ===== 按钮按下状态 ===== */
.bb-component.button-pressed .btn-cap {
    fill: #7f8c8d;
    stroke: #566573;
}

.bb-component.button-pressed {
    filter: drop-shadow(0 0 4px oklch(58% 0.12 240 / 0.6));
}

.bb-component[data-component-type='button'] {
    cursor: pointer;
}

/* ===== 蜂鸣器鸣响动画 ===== */
.bb-component.buzzer-on {
    animation: buzzer-pulse 0.35s ease-in-out infinite;
}

@keyframes buzzer-pulse {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 0 2px oklch(68% 0.16 55 / 0.4)); }
    50% { transform: scale(1.08); filter: drop-shadow(0 0 8px oklch(68% 0.16 55 / 0.9)); }
}

/* ===== 光线滑块 ===== */
.light-wrapper .temp-label { color: var(--warning); }

.light-slider::-webkit-slider-thumb {
    background: var(--warning);
}

.light-slider::-moz-range-thumb {
    background: var(--warning);
}

