/* ===== 机器人实验室 · 工程图纸暗色风格 ===== */
:root {
    --lab-bg: #0b1220;
    --lab-panel: rgba(15, 23, 42, 0.88);
    --lab-panel-border: rgba(96, 165, 250, 0.22);
    --lab-text: #e2e8f0;
    --lab-text-dim: #94a3b8;
    --lab-accent: #3b82f6;
    --lab-accent-soft: #60a5fa;
    --lab-ok: #34d399;
    --lab-warn: #fbbf24;
    --lab-radius: 10px;
    --lab-mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    background: var(--lab-bg);
    color: var(--lab-text);
    font-family: "Inter", "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
}

html.hero-mode,
html.hero-mode body {
    background: transparent;
}

html.hero-mode .lab-toolbar,
html.hero-mode .lab-panel,
html.hero-mode .lab-status,
html.hero-mode .lab-loading {
    display: none !important;
}

#canvas-wrap {
    position: fixed;
    inset: 0;
}
#canvas-wrap canvas { display: block; }

html.hero-mode #canvas-wrap,
html.hero-mode #canvas-wrap canvas {
    background: transparent;
    pointer-events: none;
}

/* ===== 顶部工具栏 ===== */
.lab-toolbar {
    position: fixed;
    top: 14px;
    left: 14px;
    right: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    background: var(--lab-panel);
    border: 1px solid var(--lab-panel-border);
    border-radius: var(--lab-radius);
    backdrop-filter: blur(10px);
    z-index: 20;
}

.lab-toolbar__left { display: flex; align-items: center; gap: 12px; min-width: 0; }

.lab-toolbar__window { display: flex; gap: 5px; }
.lab-toolbar__window span {
    width: 9px; height: 9px; border-radius: 50%;
    background: rgba(96, 165, 250, 0.35);
}
.lab-toolbar__window span:nth-child(1) { background: #f87171aa; }
.lab-toolbar__window span:nth-child(2) { background: #fbbf24aa; }
.lab-toolbar__window span:nth-child(3) { background: #34d399aa; }

.lab-toolbar__meta { display: flex; flex-direction: column; min-width: 0; }
.lab-toolbar__label {
    font-family: var(--lab-mono);
    font-size: 10px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--lab-accent-soft);
}
.lab-toolbar__title { font-size: 15px; font-weight: 600; white-space: nowrap; }

.lab-toolbar__right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.lab-model-tag {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 12px;
    font-size: 13px;
    color: var(--lab-accent-soft);
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.35);
    border-radius: 8px;
    white-space: nowrap;
}
.lab-model-tag i { font-size: 12px; }

/* ===== 按钮 ===== */
.lab-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    font-size: 13px;
    color: var(--lab-text);
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}
.lab-btn:hover {
    border-color: var(--lab-accent);
    color: #fff;
    background: rgba(59, 130, 246, 0.18);
}
.lab-btn.active {
    border-color: var(--lab-accent);
    background: rgba(59, 130, 246, 0.28);
    color: #fff;
}
.lab-btn i { font-size: 12px; color: var(--lab-accent-soft); }

.lab-btn--action:hover i { color: var(--lab-warn); }

.lab-btn-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

/* ===== 面板 ===== */
.lab-panel {
    position: fixed;
    width: 240px;
    max-height: calc(100vh - 150px);
    overflow-y: auto;
    padding: 14px;
    background: var(--lab-panel);
    border: 1px solid var(--lab-panel-border);
    border-radius: var(--lab-radius);
    backdrop-filter: blur(10px);
    z-index: 15;
}
.lab-panel--controls { top: 76px; left: 14px; }
.lab-panel--joints {
    top: 76px;
    right: 14px;
    width: 260px;
}

.lab-panel__heading {
    margin: 0 0 10px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--lab-accent-soft);
    text-transform: uppercase;
}
.lab-panel__heading small {
    display: block;
    margin-top: 2px;
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
    color: var(--lab-text-dim);
}
.lab-panel__section + .lab-panel__section { margin-top: 16px; padding-top: 14px; border-top: 1px dashed rgba(148, 163, 184, 0.2); }

/* ===== 表单控件 ===== */
.lab-field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--lab-text-dim); }
.lab-field > span { display: flex; justify-content: space-between; align-items: center; }
.lab-field output {
    font-family: var(--lab-mono);
    color: var(--lab-accent-soft);
    font-size: 11px;
}

.lab-field--select select {
    padding: 7px 10px;
    font-size: 13px;
    color: var(--lab-text);
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 8px;
    outline: none;
    cursor: pointer;
}
.lab-field--select select:focus { border-color: var(--lab-accent); }
.lab-field--select span { justify-content: flex-start; gap: 6px; }

.lab-field--slider { margin-top: 12px; }
.lab-field--slider input[type="range"] {
    width: 100%;
    height: 4px;
    appearance: none;
    -webkit-appearance: none;
    background: rgba(148, 163, 184, 0.3);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}
.lab-field--slider input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--lab-accent);
    border: 2px solid #0f172a;
}
.lab-field--slider input[type="range"]::-moz-range-thumb {
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--lab-accent);
    border: 2px solid #0f172a;
}

/* ===== 关节滑块列表 ===== */
.joint-list { display: flex; flex-direction: column; gap: 4px; }
.joint-group__title {
    margin: 10px 0 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--lab-text-dim);
    letter-spacing: 0.06em;
}
.joint-group__title:first-child { margin-top: 0; }

.joint-row {
    display: grid;
    grid-template-columns: 1fr 62px;
    gap: 8px;
    align-items: center;
    padding: 3px 0;
}
.joint-row label {
    font-size: 11.5px;
    color: var(--lab-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.joint-row .joint-value {
    font-family: var(--lab-mono);
    font-size: 10.5px;
    color: var(--lab-accent-soft);
    text-align: right;
}
.joint-row input[type="range"] {
    grid-column: 1 / -1;
    width: 100%;
    height: 3px;
    appearance: none;
    -webkit-appearance: none;
    background: rgba(148, 163, 184, 0.25);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}
.joint-row input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    width: 11px; height: 11px;
    border-radius: 50%;
    background: var(--lab-accent-soft);
    border: 2px solid #0f172a;
}
.joint-row input[type="range"]::-moz-range-thumb {
    width: 11px; height: 11px;
    border-radius: 50%;
    background: var(--lab-accent-soft);
    border: 2px solid #0f172a;
}

/* ===== 底部状态栏 ===== */
.lab-status {
    position: fixed;
    left: 14px;
    right: 14px;
    bottom: 12px;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 8px 14px;
    font-family: var(--lab-mono);
    font-size: 11.5px;
    color: var(--lab-text-dim);
    background: var(--lab-panel);
    border: 1px solid var(--lab-panel-border);
    border-radius: var(--lab-radius);
    backdrop-filter: blur(10px);
    z-index: 15;
}
.lab-status span { white-space: nowrap; }
.lab-status #status-height { color: var(--lab-ok); }
.lab-status #status-hint { margin-left: auto; }
.lab-status__credit { color: rgba(148, 163, 184, 0.6); font-size: 10.5px; }

/* ===== 加载遮罩 ===== */
.lab-loading {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at 50% 40%, #101c33 0%, #0b1220 70%);
    z-index: 50;
    transition: opacity 0.5s ease;
}
.lab-loading.done { opacity: 0; pointer-events: none; }

.lab-loading__card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    width: min(340px, 84vw);
    padding: 34px 30px;
    text-align: center;
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid var(--lab-panel-border);
    border-radius: 14px;
}
.lab-loading__card h2 { margin: 0; font-size: 20px; letter-spacing: 0.04em; }
.lab-loading__card p { margin: 0; font-size: 12.5px; color: var(--lab-text-dim); min-height: 18px; }

.lab-loading__ring {
    width: 44px; height: 44px;
    border: 3px solid rgba(96, 165, 250, 0.2);
    border-top-color: var(--lab-accent);
    border-radius: 50%;
    animation: lab-spin 1s linear infinite;
}
@keyframes lab-spin { to { transform: rotate(360deg); } }

.lab-loading__bar {
    width: 100%;
    height: 4px;
    background: rgba(148, 163, 184, 0.18);
    border-radius: 2px;
    overflow: hidden;
}
.lab-loading__bar > div {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--lab-accent), var(--lab-accent-soft));
    transition: width 0.25s ease;
}

.lab-loading__error {
    padding: 10px 12px;
    font-size: 12px;
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.35);
    border-radius: 8px;
    word-break: break-all;
}

/* ===== 模式切换器(RL 行走 / 伺服姿态) ===== */
.lab-switch {
    display: inline-flex;
    padding: 3px;
    gap: 3px;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 10px;
}
.lab-switch .lab-btn {
    padding: 5px 11px;
    font-size: 12px;
    border-radius: 7px;
    background: transparent;
    border-color: transparent;
    color: var(--lab-text-dim);
}
.lab-switch .lab-btn:hover { background: rgba(59, 130, 246, 0.14); }
.lab-switch .lab-btn.active {
    border-color: rgba(59, 130, 246, 0.45);
    background: rgba(59, 130, 246, 0.26);
}

/* ===== 行走指令面板 ===== */
.walk-cmd {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.walk-cmd > span {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px;
    font-size: 11px;
    color: var(--lab-text-dim);
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 8px;
}
.walk-cmd i {
    font-style: normal;
    font-size: 15px;
    font-weight: 600;
    color: var(--lab-text);
    font-variant-numeric: tabular-nums;
}.walk-hint {
    margin: 10px 0 0;
    font-size: 11px;
    line-height: 1.6;
    color: var(--lab-text-dim);
}

/* ===== 移动端适配 ===== */
@media (max-width: 720px) {
    .lab-toolbar {
        top: 8px;
        left: 8px;
        right: 8px;
        min-height: 48px;
        flex-wrap: nowrap;
        gap: 6px;
        padding: 6px 8px;
    }

    .lab-toolbar__window,
    .lab-toolbar__label,
    .lab-model-tag {
        display: none;
    }

    .lab-toolbar__left { flex: 0 0 auto; }
    .lab-toolbar__title { font-size: 12px; }

    .lab-toolbar__right {
        flex: 1;
        width: auto;
        min-width: 0;
        gap: 4px;
        justify-content: flex-end;
    }

    .lab-switch { min-width: 0; padding: 2px; }
    .lab-switch .lab-btn {
        min-height: 36px;
        padding: 6px 8px;
        font-size: 11px;
    }

    #btn-joints,
    #btn-camera {
        width: 36px;
        height: 36px;
        min-height: 36px;
        padding: 0;
        justify-content: center;
    }

    #btn-joints span,
    #btn-camera span {
        display: none;
    }

    .lab-panel {
        left: 8px;
        right: 8px;
        width: auto;
        padding: 12px;
        border-radius: 12px;
    }

    .lab-panel--controls {
        top: auto;
        bottom: 54px;
        max-height: min(40vh, 320px);
    }

    .lab-panel--joints {
        top: 64px;
        bottom: 54px;
        width: auto;
        max-height: none;
    }

    .lab-btn { min-height: 40px; }
    .lab-btn-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .lab-panel__section + .lab-panel__section { margin-top: 10px; padding-top: 10px; }
    .walk-hint { display: none; }

    .lab-status {
        left: 8px;
        right: 8px;
        bottom: 8px;
        min-height: 38px;
        justify-content: space-between;
        gap: 8px;
        padding: 6px 10px;
        font-size: 10px;
    }

    .lab-status #status-sim,
    .lab-status #status-fps,
    .lab-status #status-hint,
    .lab-status__credit {
        display: none;
    }

    .lab-loading__card {
        width: min(340px, calc(100vw - 32px));
        padding: 26px 20px;
    }
}

@media (max-width: 400px) {
    .lab-toolbar__title { display: none; }
    .lab-toolbar__left { display: none; }
    .lab-toolbar__right { justify-content: space-between; }
    .walk-cmd { gap: 4px; }
    .walk-cmd > span { padding: 7px 5px; }
}
