/* ============================================================
   技能加点页：顶栏 + 技能树（左）+ 技能详情（右）
   技能树与详情面板的结构由 js/skill/skill-tree.js、skill-detail.js 生成
   ============================================================ */

.app {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* ---------- 顶栏 ---------- */

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

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: linear-gradient(135deg, #45b3ff, var(--accent));
    color: #fff;
}

.brand-mark .ico {
    width: 15px;
    height: 15px;
}

.brand-tag {
    padding: 1px 5px;
    border-radius: 5px;
    background: #eaf2fd;
    color: var(--accent);
    font-size: 10px;
    letter-spacing: .5px;
}

.stats {
    display: flex;
    gap: 6px;
}

.actions {
    display: flex;
    gap: 2px;
}

/* ---------- 工作区 ---------- */

.workspace {
    flex: 1;
    min-height: 0;
    display: flex;
    gap: 14px;
    padding: 14px;
}

.pane-tree {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pane-tree .pills {
    align-self: flex-start;
}

.tab-badge {
    padding: 0 5px;
    border-radius: 6px;
    background: rgba(122, 134, 153, .14);
    font-size: 11px;
    font-style: normal;
    font-variant-numeric: tabular-nums;
}

.pill.on .tab-badge {
    background: rgba(30, 159, 255, .14);
}

.tree {
    flex: 1;
    min-height: 0;
}

.tab-panel {
    display: none;
}

.tab-panel.on {
    display: block;
}

/* ---------- 技能树 ---------- */

/* 层级配色：层级越深颜色越暖；节点与层级标记共用 */
[data-tire="2"] {
    --tier: #8494a8;
}

[data-tire="3"] {
    --tier: #16b777;
}

[data-tire="4"] {
    --tier: #1e9fff;
}

[data-tire="5"] {
    --tier: #ffa726;
}

[data-tire="6"] {
    --tier: #f4511e;
}

/* 基础技能：页签内两个分支的根节点 */
.root-row {
    position: relative;
    display: flex;
    justify-content: center;
    padding-bottom: 18px;
}

.root-row::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 2px;
    height: 18px;
    background: var(--line-2);
}

.branches {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

/* 连接根节点与两个分支卡片的横向导线（两端落在卡片中点） */
.branches::before {
    content: "";
    position: absolute;
    top: 0;
    left: 25%;
    right: 25%;
    height: 2px;
    background: var(--line-2);
}

.branch {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
}

/* 卡片内横向导线：由卡片中点向左接到层级导线 */
.branch::before {
    content: "";
    position: absolute;
    top: 1px;
    left: 21px;
    right: 50%;
    height: 2px;
    background: var(--line-2);
}

/* 竖向导线：接到首层层级标记 */
.branch::after {
    content: "";
    position: absolute;
    top: 1px;
    left: 21px;
    width: 2px;
    height: 27px;
    background: var(--line-2);
}

.tier-row {
    position: relative;
    display: grid;
    grid-template-columns: 22px 1fr;
    column-gap: 6px;
    align-items: start;
}

/* 层级标记到技能节点的短横线 */
.tier-row::before {
    content: "";
    position: absolute;
    top: 12px;
    left: 20px;
    width: 9px;
    height: 2px;
    background: var(--line-2);
}

/* 连向下一层级的竖向导线（末层不画） */
.tier-row::after {
    content: "";
    position: absolute;
    top: 23px;
    bottom: -13px;
    left: 9px;
    width: 2px;
    background: var(--line-2);
}

.tier-row:last-child::after {
    display: none;
}

.tier-mark {
    z-index: 1;
    display: grid;
    place-items: center;
    width: 20px;
    height: 20px;
    margin-top: 3px;
    border-radius: 7px;
    background: var(--tier);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
}

/* 该层全部未解锁时淡化层级标记与导线 */
.tier-row.locked .tier-mark {
    background: #ccd5e1;
}

.tier-row.locked::before,
.tier-row.locked::after {
    background: #e9edf3;
}

.nodes {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* ---------- 技能节点 ---------- */

.node {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border: 1px solid var(--line-2);
    border-radius: 8px;
    background: #fff;
    font-size: 12px;
    line-height: 1.35;
    transition: border-color .15s, box-shadow .15s, background .15s;
}

.node:hover {
    border-color: var(--tier);
}

.node.on {
    border-color: var(--tier);
    background: #f6fbff;
    box-shadow: 0 0 0 3px rgba(30, 159, 255, .14);
}

.node.on .node-name {
    font-weight: 600;
}

.node .lv {
    color: var(--muted);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.node.has .lv {
    color: var(--accent);
    font-weight: 600;
}

.node.maxed .lv {
    color: var(--ok);
}

.node.locked {
    color: var(--faint);
    border-style: dashed;
    background: #fbfcfe;
}

.node.locked .lv {
    display: none;
}

.node .lock {
    display: none;
    color: var(--faint);
}

.node .lock .ico {
    width: 13px;
    height: 13px;
}

.node.locked .lock {
    display: inline-flex;
}

/* 基础技能节点：整个页签的入口 */
.node.-root {
    --tier: var(--ok);
    padding: 6px 12px;
    border-color: #b7e6d3;
    background: #f3fbf7;
    font-size: 12.5px;
}

.node.-root.on {
    background: #eaf9f2;
}

/* ---------- 技能详情 ---------- */

.pane-detail {
    flex: 0 0 300px;
    display: flex;
    flex-direction: column;
}

/* 窄屏抽屉把手，宽屏隐藏 */
.sheet-bar {
    display: none;
}

.detail-card.-root {
    --tier: var(--ok);
}

.tier-badge {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 7px;
    background: var(--tier);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
}

.pips {
    display: flex;
    gap: 4px;
}

.pip {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: #e8ecf3;
}

.pip.on {
    background: var(--tier);
}

.detail-lock {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 7px 9px;
    border-radius: 8px;
    background: #fff6e8;
    color: #a06412;
    font-size: 12px;
}

.detail-lock .ico {
    width: 13px;
    height: 13px;
}

.detail-lock .bar {
    flex: 1;
    height: 5px;
    border-radius: 3px;
    background: rgba(160, 100, 18, .18);
}

.detail-lock .bar b {
    display: block;
    height: 100%;
    border-radius: 3px;
    background: #e8a33d;
}

/* ---------- 链接异常 ---------- */

.fatal {
    flex: 1;
    display: grid;
    place-items: center;
}

.fatal-card {
    padding: 24px 28px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel);
    box-shadow: var(--shadow);
    text-align: center;
}

.fatal-card .ico {
    width: 30px;
    height: 30px;
    color: var(--danger);
}

.fatal-card h2 {
    margin: 10px 0 4px;
    font-size: 15px;
}

.fatal-card p {
    margin: 0;
    color: var(--muted);
    font-size: 12.5px;
}

.fatal-card .fatal-note {
    margin-top: 8px;
    color: var(--faint);
    font-size: 12px;
}

/* ---------- 窄屏：分支改单列，详情改为底部抽屉 ---------- */

@media (max-width: 900px) {
    .branches {
        grid-template-columns: 1fr;
    }

    /* 单列时不再画分支导线，层级串联由卡片内的层级导线表达 */
    .root-row::after,
    .branches::before,
    .branch::before,
    .branch::after {
        display: none;
    }

    .pane-detail {
        position: fixed;
        inset: auto 0 0 0;
        z-index: 40;
        max-height: 62vh;
        border-radius: 14px 14px 0 0;
        background: var(--panel);
        box-shadow: 0 -12px 30px -18px rgba(29, 37, 49, .55);
        transform: translateY(105%);
        transition: transform .22s ease;
    }

    .pane-detail.open {
        transform: none;
    }

    .sheet-bar {
        display: flex;
        align-items: center;
        justify-content: center;
        height: 24px;
        border: 0;
        background: transparent;
    }

    .sheet-bar span {
        width: 38px;
        height: 4px;
        border-radius: 2px;
        background: var(--line-2);
    }

    .detail-empty {
        display: none;
    }

    .detail-card {
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .tree {
        padding-bottom: 30px;
    }
}

@media (max-width: 760px) {
    .brand-name,
    .stat-label,
    .chip,
    .actions .tbtn span {
        display: none;
    }

    .actions .tbtn {
        padding: 0 8px;
    }

    .chip {
        max-width: 90px;
    }

    .workspace {
        padding: 10px;
        gap: 10px;
    }
}
