/*!
 * iPhone 17 精密零件 3D 拆解 /tools/iphone17
 *
 * 设计系统
 *   · 8px 间距基准（4 / 8 / 12 / 16 / 20 / 24），统一圆角 14 / 10 / 8 三级
 *   · 面板三级层次：--ip-panel（容器） → --ip-panel2（内嵌块） → --ip-line（分隔线）
 *   · 单一强调色（蓝 #4f9cff）+ 分类语义色（--cc 由 JS 注入），选中态为「淡背景 + 边框 + 左强调条」
 *   · 深浅双主题全量变量化，切换主题无需改任何规则
 *
 * 断点
 *   ≥1201  桌面三栏：清单 300 / 舞台 1fr / 详情 348，等高且各自内部滚动，舞台高度跟随视口
 *   901~1200 平板两栏：清单 264 / 舞台 1fr，详情整行置底
 *   ≤900   手机单栏：舞台优先，清单与详情改为底部抽屉 + 遮罩 + 安全区适配
 *   ≤420   超小屏：压缩间距、按钮纵向铺满
 */
.ip-page {
    --ip-bg: #0d1117;
    --ip-panel: #161b22;
    --ip-panel2: #1c2128;
    --ip-line: #2d333b;
    --ip-line2: #3a424c;
    --ip-fg: #e6edf3;
    --ip-muted: #9198a1;
    --ip-faint: #6e7681;
    --ip-accent: #4f9cff;
    --ip-acc2: #a371f7;
    --ip-radius: 14px;
    --ip-shadow: 0 8px 26px rgba(0, 0, 0, .34);
    --ip-shadow-sm: 0 4px 14px rgba(0, 0, 0, .28);
    --ip-glass: color-mix(in srgb, var(--ip-panel) 76%, transparent);
    background: var(--ip-bg);
    color: var(--ip-fg);
    min-height: 100vh;
    -webkit-text-size-adjust: 100%;
}
[data-theme="light"] .ip-page {
    --ip-bg: #f4f6f9;
    --ip-panel: #ffffff;
    --ip-panel2: #f1f4f8;
    --ip-line: #e2e7ee;
    --ip-line2: #c9d2dc;
    --ip-fg: #1c222b;
    --ip-muted: #5b6673;
    --ip-faint: #7b8695;
    --ip-accent: #136ce9;
    --ip-acc2: #7a4dff;
    --ip-shadow: 0 8px 26px rgba(31, 36, 44, .10);
    --ip-shadow-sm: 0 3px 12px rgba(31, 36, 44, .08);
}
.ip-page *, .ip-page *::before, .ip-page *::after { box-sizing: border-box; }
.ip-page [hidden] { display: none !important; }

.ip-wrap { max-width: 1560px; margin: 0 auto; padding: 18px 20px 32px; }

/* ---------- 头部 ---------- */
.ip-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.ip-head__icon {
    width: 50px; height: 50px; flex: 0 0 50px; border-radius: 15px;
    background: linear-gradient(145deg, var(--ip-acc2), var(--ip-accent));
    color: #fff; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 8px 20px color-mix(in srgb, var(--ip-accent) 34%, transparent);
}
.ip-head__icon svg { width: 28px; height: 28px; }
.ip-head__txt { flex: 1 1 300px; min-width: 0; }
.ip-head__title { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: .2px; line-height: 1.3; }
.ip-head__sub { margin: 5px 0 0; font-size: 13px; color: var(--ip-muted); line-height: 1.65; }
.ip-head__acts { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }

/* ---------- 通用控件 ---------- */
.ip-btn {
    appearance: none; border: 1px solid var(--ip-line2); background: var(--ip-panel2);
    color: var(--ip-fg); border-radius: 10px; padding: 0 14px; min-height: 36px;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    font-size: 12.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
    transition: background .16s, border-color .16s, color .16s, transform .12s;
}
.ip-btn:hover { border-color: var(--ip-accent); color: var(--ip-accent); background: color-mix(in srgb, var(--ip-accent) 10%, var(--ip-panel2)); }
.ip-btn:active { transform: translateY(1px); }
.ip-btn.is-on { background: var(--ip-accent); border-color: var(--ip-accent); color: #fff; }
.ip-btn.is-on:hover { color: #fff; filter: brightness(1.06); }
.ip-btn:focus-visible, .ip-chip:focus-visible, .ip-item:focus-visible, .ip-inp:focus-visible, .ip-range:focus-visible {
    outline: 2px solid var(--ip-accent); outline-offset: 2px;
}
.ip-inp {
    background: var(--ip-panel2); color: var(--ip-fg); border: 1px solid var(--ip-line);
    border-radius: 10px; padding: 0 11px; min-height: 38px; font-size: 13px; width: 100%;
    transition: border-color .16s, box-shadow .16s;
}
.ip-inp:focus { outline: none; border-color: var(--ip-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ip-accent) 22%, transparent); }
.ip-inp::placeholder { color: var(--ip-faint); }

/* ---------- 主体三栏（桌面等高 + 内部滚动） ---------- */
.ip-main {
    display: grid; gap: 14px; grid-template-columns: 300px minmax(0, 1fr) 348px;
    align-items: stretch; height: clamp(540px, calc(100vh - 244px), 900px);
}
@supports (height: 100dvh) {
    .ip-main { height: clamp(540px, calc(100dvh - 244px), 900px); }
}
.ip-panel {
    background: var(--ip-panel); border: 1px solid var(--ip-line);
    border-radius: var(--ip-radius); display: flex; flex-direction: column;
    min-height: 0; overflow: hidden;
}
.ip-ptitle {
    display: flex; align-items: center; gap: 8px; flex: 0 0 auto;
    padding: 0 13px; min-height: 46px; border-bottom: 1px solid var(--ip-line);
    font-size: 13px; font-weight: 800; letter-spacing: .2px;
}
.ip-ptitle > span:first-child { flex: 1 1 auto; }
.ip-ptitle .ip-mini { font-weight: 600; color: var(--ip-muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.ip-pbody { padding: 12px; overflow: auto; flex: 1 1 auto; min-height: 0; overscroll-behavior: contain; }
.ip-pbody::-webkit-scrollbar { width: 9px; height: 9px; }
.ip-pbody::-webkit-scrollbar-thumb { background: var(--ip-line2); border-radius: 99px; border: 2px solid var(--ip-panel); }
.ip-pbody::-webkit-scrollbar-track { background: transparent; }

/* ---------- 分类 chips ---------- */
.ip-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ip-chip {
    appearance: none; border: 1px solid var(--ip-line); background: var(--ip-panel2);
    color: var(--ip-muted); border-radius: 9px; padding: 5px 9px; min-height: 28px;
    display: inline-flex; align-items: center; gap: 2px;
    font-size: 12px; font-weight: 700; cursor: pointer; transition: .14s;
}
.ip-chip:hover { color: var(--ip-fg); border-color: var(--cc, var(--ip-line2)); }
.ip-chip b { font-size: 11px; opacity: .7; font-variant-numeric: tabular-nums; }
.ip-chip.is-on {
    color: var(--ip-fg);
    border-color: color-mix(in srgb, var(--cc, var(--ip-accent)) 62%, transparent);
    background: color-mix(in srgb, var(--cc, var(--ip-accent)) 20%, var(--ip-panel2));
}

/* ---------- 零件清单 ---------- */
.ip-lgrp {
    position: sticky; top: 0; z-index: 2; background: var(--ip-panel);
    margin: 12px 0 6px; padding: 6px 0 6px 8px; font-size: 11.5px; font-weight: 800;
    color: var(--cc, var(--ip-muted)); border-left: 3px solid var(--cc, var(--ip-line2));
}
.ip-lgrp:first-child { margin-top: 0; }
.ip-item {
    display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
    appearance: none; border: 1px solid transparent; background: transparent; color: var(--ip-fg);
    border-radius: 10px; padding: 8px 9px; min-height: 38px; font-size: 13px;
    cursor: pointer; transition: background .14s, border-color .14s;
}
.ip-item:hover { background: var(--ip-panel2); border-color: var(--ip-line); }
.ip-item.is-sel {
    background: color-mix(in srgb, var(--ip-accent) 16%, var(--ip-panel2));
    border-color: color-mix(in srgb, var(--ip-accent) 52%, transparent);
    box-shadow: inset 3px 0 0 var(--ip-accent);
}
.ip-item i { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 10px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .25) inset; }
.ip-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ip-empty { color: var(--ip-muted); font-size: 12.5px; padding: 18px 6px; text-align: center; line-height: 1.7; }

/* ---------- 舞台 ---------- */
.ip-stage { display: flex; flex-direction: column; min-height: 0; }
.ip-canvas-wrap {
    position: relative; flex: 1 1 auto; min-height: 320px; margin: 12px 12px 0;
    border-radius: 12px; overflow: hidden; border: 1px solid var(--ip-line);
    /* 精密展台：中心冷光聚光 + 极淡工程网格 + 四周沉底，让模型有"摆放"的实感 */
    background:
        radial-gradient(circle at 50% 34%, rgba(120, 170, 255, .10) 0%, rgba(120, 170, 255, 0) 58%),
        repeating-linear-gradient(0deg, rgba(255, 255, 255, .032) 0 1px, rgba(255, 255, 255, 0) 1px 44px),
        repeating-linear-gradient(90deg, rgba(255, 255, 255, .032) 0 1px, rgba(255, 255, 255, 0) 1px 44px),
        radial-gradient(circle at 50% 38%, #1b2432 0%, #0d1117 62%, #080b10 100%);
}
[data-theme="light"] .ip-canvas-wrap {
    background:
        radial-gradient(circle at 50% 34%, rgba(19, 108, 233, .07) 0%, rgba(19, 108, 233, 0) 58%),
        repeating-linear-gradient(0deg, rgba(20, 40, 80, .030) 0 1px, rgba(20, 40, 80, 0) 1px 44px),
        repeating-linear-gradient(90deg, rgba(20, 40, 80, .030) 0 1px, rgba(20, 40, 80, 0) 1px 44px),
        radial-gradient(circle at 50% 38%, #ffffff 0%, #eef2f7 60%, #dfe6ef 100%);
}
/* 绝对定位：画布不参与父容器高度计算，避免「JS 设高→容器变高→画布更高」的尺寸反馈 */
.ip-canvas-wrap canvas { position: absolute; left: 0; top: 0; display: block; touch-action: none; cursor: grab; }
.ip-canvas-wrap canvas:active { cursor: grabbing; }

/* 视图工具浮在画布右上角：把画布面积全部留给模型 */
.ip-tools {
    position: absolute; right: 10px; top: 10px; z-index: 3; display: flex; gap: 6px;
    padding: 6px; border-radius: 12px; border: 1px solid color-mix(in srgb, var(--ip-line2) 60%, transparent);
    background: var(--ip-glass); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    box-shadow: var(--ip-shadow-sm);
}
.ip-tools .ip-btn { min-height: 32px; padding: 0 11px; font-size: 12px; }
.ip-hint {
    position: absolute; left: 10px; bottom: 10px; z-index: 2; max-width: calc(100% - 20px);
    font-size: 11.5px; line-height: 1.5; color: var(--ip-muted);
    background: var(--ip-glass); border: 1px solid color-mix(in srgb, var(--ip-line) 60%, transparent);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    border-radius: 8px; padding: 4px 9px; pointer-events: none;
}
.ip-sheetbar { display: none; }

/* ---------- 底部控制 ---------- */
.ip-ctrl { padding: 12px; display: grid; gap: 10px; flex: 0 0 auto; }
.ip-ctrl__row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ip-ctrl__row label { font-size: 12px; color: var(--ip-muted); font-weight: 700; flex: 0 0 auto; }
.ip-range { flex: 1 1 180px; min-width: 140px; height: 22px; accent-color: var(--ip-accent); cursor: pointer; }
.ip-expval {
    font-size: 12px; font-weight: 800; color: var(--ip-accent); min-width: 44px;
    text-align: right; font-variant-numeric: tabular-nums;
}
.ip-steprow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ip-stepbox {
    background: var(--ip-panel2); border: 1px solid var(--ip-line); border-radius: 12px; padding: 10px 12px;
}
.ip-stepbox__top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.ip-stepbox h4 { margin: 0; font-size: 13.5px; font-weight: 800; line-height: 1.4; }
.ip-stepno { font-size: 11.5px; font-weight: 800; color: var(--ip-accent); font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.ip-stepbar { height: 4px; border-radius: 99px; background: var(--ip-line); overflow: hidden; margin: 8px 0 9px; }
.ip-stepbar i {
    display: block; height: 100%; width: 0; border-radius: 99px;
    background: linear-gradient(90deg, var(--ip-acc2), var(--ip-accent)); transition: width .32s ease;
}
.ip-stepbox p { margin: 0; font-size: 12.5px; color: var(--ip-muted); line-height: 1.7; }

/* ---------- 详情面板 ---------- */
.ip-dempty {
    color: var(--ip-muted); font-size: 12.5px; text-align: center; padding: 30px 8px; line-height: 1.85;
    min-height: 220px; display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.ip-dhead { display: flex; gap: 11px; align-items: flex-start; }
.ip-dhead i { width: 26px; height: 26px; border-radius: 7px; flex: 0 0 26px; margin-top: 2px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .22) inset; }
.ip-dhead h3 { margin: 0; font-size: 15.5px; font-weight: 800; line-height: 1.4; }
.ip-dhead p { margin: 3px 0 0; font-size: 11.5px; color: var(--ip-faint); word-break: break-word; }
.ip-dcat {
    display: inline-block; margin: 10px 0 2px; font-size: 11.5px; font-weight: 700;
    padding: 3px 10px; border-radius: 20px; border: 1px solid var(--ip-line2); color: var(--ip-muted);
    background: var(--ip-panel2);
}
.ip-dl { margin: 12px 0 0; display: grid; grid-template-columns: 68px minmax(0, 1fr); gap: 10px 12px; align-items: baseline; }
.ip-dl dt { font-size: 11.5px; font-weight: 800; color: var(--ip-muted); line-height: 1.6; }
.ip-dl dd { margin: 0; font-size: 13px; line-height: 1.75; word-break: break-word; }
.ip-dbtn { margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.ip-dbtn .ip-btn { flex: 1 1 auto; }

/* ---------- 提示条 / 说明 / 遮罩 ---------- */
.ip-toast {
    position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
    background: rgba(20, 26, 34, .96); color: #fff; border: 1px solid var(--ip-line2);
    padding: 11px 18px; border-radius: 11px; font-size: 13px; z-index: 99999;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .42); animation: ip-rise .2s ease;
}
@keyframes ip-rise { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
.ip-mask { display: none; }
.ip-note {
    margin-top: 14px; background: var(--ip-panel); border: 1px solid var(--ip-line);
    border-radius: var(--ip-radius); padding: 13px 15px; font-size: 12.5px;
    color: var(--ip-muted); line-height: 1.85;
}
.ip-note b { color: var(--ip-fg); }
.ip-close { display: none; }
body.ip-list-open .ip-close, body.ip-info-open .ip-close { display: inline-flex; }

/* ================= 平板（901~1200）：两栏，详情整行置底 ================= */
@media (max-width: 1200px) {
    .ip-wrap { padding: 16px 16px 30px; }
    .ip-main { grid-template-columns: 264px minmax(0, 1fr); height: auto; }
    .ip-info { grid-column: 1 / -1; }
    .ip-info .ip-pbody { max-height: 40vh; }
    /* 两栏下高度不再跟随视口，给清单与画布各自一个上限，避免被长清单撑成超长页 */
    .ip-side .ip-pbody { max-height: min(64vh, 620px); }
    .ip-canvas-wrap { min-height: min(58vh, 520px); }
    .ip-dl { grid-template-columns: 84px minmax(0, 1fr); }
    .ip-dbtn .ip-btn { flex: 0 1 auto; }
}

/* ================= 手机（≤900）：单栏 + 底部抽屉 ================= */
@media (max-width: 900px) {
    .ip-wrap { padding: 12px 12px 30px; }
    .ip-head { gap: 11px; margin-bottom: 13px; }
    .ip-head__icon { width: 42px; height: 42px; flex: 0 0 42px; border-radius: 13px; }
    .ip-head__icon svg { width: 23px; height: 23px; }
    .ip-head__title { font-size: 19px; }
    .ip-head__sub { font-size: 12px; margin-top: 4px; }
    .ip-head__acts { width: 100%; margin-left: 0; }
    .ip-head__acts .ip-btn { flex: 1 1 0; min-height: 42px; }

    .ip-main { grid-template-columns: minmax(0, 1fr); gap: 12px; height: auto; }
    .ip-canvas-wrap { margin: 10px 10px 0; min-height: clamp(300px, 52vh, 470px); }

    /* 工具条移到画布底部居中，避开模型主体；提示语移到左上 */
    .ip-tools {
        right: 10px; left: 10px; top: auto; bottom: 10px; justify-content: center;
        flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
        scrollbar-width: none; padding: 5px;
    }
    .ip-tools::-webkit-scrollbar { display: none; }
    .ip-tools .ip-btn { min-height: 36px; flex: 0 0 auto; }
    .ip-hint { left: 10px; right: 10px; bottom: auto; top: 10px; max-width: none; }

    /* 展开清单 / 详情的入口放在画布下方，不与浮层争空间 */
    .ip-sheetbar { display: flex; gap: 8px; padding: 10px 12px 0; }
    .ip-sheetbar .ip-btn { flex: 1 1 0; min-height: 44px; }

    .ip-ctrl { padding: 10px 12px 12px; gap: 9px; }
    .ip-ctrl__row label { width: 100%; }
    .ip-range { flex: 1 1 100%; height: 28px; }
    .ip-steprow .ip-btn { flex: 1 1 0; min-height: 44px; }

    /* 左右面板改为底部抽屉 */
    .ip-side, .ip-info {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
        max-height: 76dvh; border-radius: 18px 18px 0 0; border-bottom: 0;
        transform: translateY(102%);
        transition: transform .28s cubic-bezier(.22, .61, .36, 1);
        box-shadow: 0 -14px 40px rgba(0, 0, 0, .48);
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
    body.ip-list-open .ip-side { transform: translateY(0); }
    body.ip-info-open .ip-info { transform: translateY(0); }
    .ip-side .ip-pbody, .ip-info .ip-pbody { max-height: none; flex: 1 1 auto; }
    .ip-ptitle { min-height: 52px; }
    .ip-item { min-height: 44px; padding: 10px 10px; }
    .ip-chip { min-height: 34px; padding: 6px 11px; }
    .ip-dl { grid-template-columns: minmax(0, 1fr); gap: 4px 0; }
    .ip-dl dt { margin-top: 8px; }
    .ip-dl dd { padding-bottom: 8px; border-bottom: 1px dashed var(--ip-line); }
    .ip-dl dd:last-child { border-bottom: 0; }
    .ip-dbtn .ip-btn { flex: 1 1 0; min-height: 44px; }

    /* 抽屉遮罩：点空白处收起，并锁定背景滚动 */
    .ip-mask {
        display: block; position: fixed; inset: 0; z-index: 65;
        background: rgba(6, 9, 14, .58); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
        animation: ip-fade .2s ease;
    }
    body.ip-list-open, body.ip-info-open { overflow: hidden; }

    .ip-page select, .ip-page input, .ip-page textarea { font-size: 16px; }
}
@keyframes ip-fade { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 420px) {
    .ip-head__title { font-size: 18px; }
    .ip-canvas-wrap { min-height: clamp(268px, 46vh, 400px); margin: 8px 8px 0; }
    .ip-tools .ip-btn { padding: 0 9px; font-size: 11.5px; }
    .ip-hint { font-size: 11px; padding: 3px 8px; }
    .ip-note { font-size: 12px; padding: 11px 12px; }
}

@media (prefers-reduced-motion: reduce) {
    .ip-page * { transition: none !important; animation: none !important; }
}
