.container {
    max-width: 1400px;
}

.main {
    grid-template-columns: minmax(0, 1fr) 340px;
    align-items: start;
}

/* ---- 工具栏 ---- */
.pt-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

.pt-toolbar #ptSearch {
    width: 240px;
    height: 34px;
}

.pt-toolbar #ptCat {
    height: 34px;
    width: 150px;
}

/* ---- 图例 ---- */
.pt-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 15px;
    border-bottom: 1px solid #f3f4f6;
}

.pt-legend button {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1px solid #e5e7eb;
    background: #fff;
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 12px;
    color: #4b5563;
    cursor: pointer;
    transition: all 0.2s;
}

.pt-legend button.active {
    border-color: #667eea;
    color: #4338ca;
    background: #eef2ff;
}

.pt-legend i {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

/* ---- 周期表网格 ---- */
.ptable-wrap {
    padding: 14px 15px;
    overflow-x: auto;
}

.ptable {
    display: grid;
    grid-template-columns: repeat(18, minmax(46px, 1fr));
    gap: 2px;
    min-width: 850px;
}

.pt-cell {
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: 3px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 68px;
    position: relative;
    cursor: pointer;
    user-select: none;
    transition: transform 0.12s, outline 0.12s, box-shadow 0.12s;
}

.pt-cell .num {
    position: absolute;
    top: 2px;
    left: 4px;
    font-size: 10px;
    color: rgba(0,0,0,0.5);
}

.pt-cell .sym {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.1;
}

.pt-cell .cn {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.15;
}

.pt-cell .mass {
    font-size: 8.5px;
    color: rgba(0,0,0,0.55);
    line-height: 1.1;
    margin-top: 3px;
}

.pt-cell:hover {
    z-index: 3;
    transform: scale(1.12);
    outline: 2px dashed rgba(102,126,234,0.6);
}

.pt-cell.selected {
    z-index: 4;
    transform: scale(1.16);
    outline: 2px solid #667eea;
    box-shadow: 0 2px 10px rgba(102,126,234,0.4);
}

.pt-cell.dim {
    opacity: 0.18;
}

.pt-cell.hl {
    outline: 2px solid #16a34a;
}

/* 镧系 / 锕系标记位 */
.pt-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed #c7cbd1;
    border-radius: 3px;
    color: #9ca3af;
    font-size: 11px;
    letter-spacing: 0.3px;
    min-height: 30px;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}

.pt-marker:hover {
    color: #667eea;
    border-color: #667eea;
}

/* ---- 元素分类配色 ---- */
.pt-alkali      { background: #ff9e9e; }
.pt-alkaline    { background: #ffe9a3; }
.pt-transition  { background: #9ecbff; }
.pt-postmetal   { background: #a3e0a8; }
.pt-metalloid   { background: #8ae0d0; }
.pt-nonmetal    { background: #cfc4f2; }
.pt-halogen     { background: #a0f0e0; }
.pt-noble       { background: #bfe3ff; }
.pt-lanthanide  { background: #ffc9d4; }
.pt-actinide    { background: #ffadc2; }
.pt-unknown     { background: #e2e2e2; }

.pt-legend i.pt-alkali,
.pt-legend i.pt-alkaline,
.pt-legend i.pt-transition,
.pt-legend i.pt-postmetal,
.pt-legend i.pt-metalloid,
.pt-legend i.pt-nonmetal,
.pt-legend i.pt-halogen,
.pt-legend i.pt-noble,
.pt-legend i.pt-lanthanide,
.pt-legend i.pt-actinide,
.pt-legend i.pt-unknown {
    border: 1px solid rgba(0,0,0,0.12);
}

/* ---- 右侧元素详情 ---- */
.detail-panel {
    display: flex;
    flex-direction: column;
    min-height: 650px;
}

.pt-body {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.pt-detail-head {
    text-align: center;
    padding: 20px 15px 14px;
    border-bottom: 1px solid #f3f4f6;
}

.pt-detail-head .catsym {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 66px;
    height: 66px;
    margin: 0 auto 8px;
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,0.12);
    font-size: 34px;
    font-weight: 700;
    color: #333;
}

.pt-detail-head .zh {
    font-size: 20px;
    font-weight: 600;
    color: #333;
}

.pt-detail-head .en {
    font-size: 12px;
    color: #9ca3af;
    margin-top: 2px;
}

.pt-detail-head .cat-pill {
    display: inline-block;
    margin-top: 8px;
    padding: 2px 12px;
    border-radius: 999px;
    font-size: 12px;
    color: #4b5563;
    border: 1px solid rgba(0,0,0,0.12);
}

.pt-props {
    padding: 8px 15px 15px;
}

.pt-props .row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f3f4f6;
    font-size: 13px;
}

.pt-props .row .k {
    color: #6b7280;
}

.pt-props .row .v {
    color: #374151;
    text-align: right;
    font-variant-numeric: tabular-nums;
    padding-left: 12px;
}

/* ---- 小屏适配 ---- */
@media (max-width: 900px) {
    .main {
        grid-template-columns: 1fr;
    }
    .detail-panel {
        min-height: 0;
    }
}

@media (max-width: 600px) {
    .pt-toolbar #ptSearch {
        flex: 1;
        width: auto;
        min-width: 160px;
    }
}