/* ===== 钙钛矿结构绘制（perovskite）· 独立样式 v1 · 红色主题 ===== */
/* 布局参考 pdf2md：左「结构参数」/ 右「三维视图」两栏工作台；色系与平台 template/style.css 和谐 */

:root {
    --red: #c81623;
    --red-dark: #a9121d;
    --red-light: #fdecec;
    --red-border: #f3c2c7;
    --line: #ececef;
}

/* [hidden] 会被下方 display:flex 的规则覆盖，这里强制生效 */
[hidden] { display: none !important; }

.pvk { padding-bottom: 28px; min-width: 0; }
.pvk .workbench { max-width: 100%; }

/* ---------- 页面标题 ---------- */
.page-head {
    margin: 4px 0 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 6px;
}
.page-title {
    margin: 0;
    font-size: 26px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: .5px;
}
.page-desc {
    margin: 0;
    font-size: 13px;
    color: var(--text-2);
    line-height: 1.6;
}

/* ---------- 特性条 ---------- */
.feature-strip {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin: 0 0 16px;
}
.fs-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 13px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 12.5px;
    color: var(--text-2);
    white-space: nowrap;
}
.fs-item svg { color: var(--red); flex-shrink: 0; }

/* ---------- 工作台两栏（结构参数 / 三维视图） ---------- */
.workbench {
    display: grid;
    grid-template-columns: minmax(0, 340px) minmax(0, 1fr);
    gap: 14px;
    align-items: stretch;
    height: clamp(620px, 82vh, 900px);
}

/* ---------- 面板通用 ---------- */
.panel {
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 6px rgba(20, 30, 50, .04);
}
.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid #f2f2f4;
    flex-shrink: 0;
    flex-wrap: wrap;
}
.panel-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}
.formula-badge {
    background: var(--red);
    color: #ffffff;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .4px;
    padding: 3px 12px;
    border-radius: 999px;
    font-family: "Times New Roman", Georgia, serif;
}

/* ---------- 左：结构参数 ---------- */
.cfg-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.cfg-block {
    display: flex;
    flex-direction: column;
    gap: 9px;
}
.cfg-title {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text);
}
.cfg-title::before {
    content: "";
    width: 3px;
    height: 12px;
    border-radius: 2px;
    background: var(--red);
    align-self: center;
    flex-shrink: 0;
}
.cfg-sub {
    font-size: 11.5px;
    font-weight: 400;
    color: var(--text-3);
}

/* 位点元素 */
.site-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.site-label {
    width: 76px;
    flex-shrink: 0;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-2);
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}
.site-label em {
    font-style: normal;
    font-size: 10.5px;
    font-weight: 400;
    color: var(--text-3);
}
.site-r {
    width: 62px;
    flex-shrink: 0;
    text-align: right;
    font-size: 11.5px;
    color: var(--text-3);
    font-variant-numeric: tabular-nums;
}
.opt-select {
    flex: 1;
    min-width: 0;
    border: 1px solid #e2e2e6;
    border-radius: 7px;
    background: #ffffff;
    padding: 7px 10px;
    font-size: 12.5px;
    font-family: inherit;
    color: var(--text);
    outline: none;
    transition: border-color .2s;
    cursor: pointer;
}
.opt-select:focus { border-color: var(--red); }

/* 分段按钮 */
.seg {
    display: flex;
    gap: 3px;
    background: #f3f3f5;
    border-radius: 9px;
    padding: 3px;
}
.seg-btn {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-2);
    font-size: 12px;
    padding: 6px 4px;
    border-radius: 7px;
    cursor: pointer;
    transition: all .16s ease;
    font-family: inherit;
    white-space: nowrap;
}
.seg-btn:hover { color: var(--red); }
.seg-btn.active {
    background: #ffffff;
    color: var(--red);
    font-weight: 600;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .08);
}
.seg-sm .seg-btn { font-size: 11.5px; padding: 5px 8px; }

/* 显示选项 */
.check-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 10px;
}
.opt-check {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12.5px;
    color: var(--text-2);
    cursor: pointer;
    line-height: 1.5;
}
.opt-check input {
    width: 14px;
    height: 14px;
    accent-color: var(--red);
    cursor: pointer;
    flex-shrink: 0;
}
/* 位点样式行：标签 + 取色 + 滑杆 + 数值 */
.style-row {
    display: flex;
    align-items: center;
    gap: 7px;
}
.style-row + .style-row { margin-top: 2px; }
.style-tag {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    border-radius: 6px;
    background: #f3f3f5;
    color: var(--text-2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11.5px;
    font-weight: 700;
}
.style-name {
    width: 62px;
    flex-shrink: 0;
    font-size: 11.5px;
    color: var(--text-3);
}
.style-sub { padding-left: 29px; }
.opt-color {
    width: 34px;
    height: 24px;
    flex-shrink: 0;
    padding: 0;
    border: 1px solid #e2e2e6;
    border-radius: 6px;
    background: #ffffff;
    cursor: pointer;
}
.opt-color::-webkit-color-swatch-wrapper { padding: 2px; }
.opt-color::-webkit-color-swatch { border: none; border-radius: 4px; }
.opt-color::-moz-color-swatch { border: none; border-radius: 4px; }
.style-range {
    flex: 1;
    min-width: 0;
    accent-color: var(--red);
    cursor: pointer;
}
.style-val {
    width: 30px;
    text-align: right;
    font-size: 12px;
    color: var(--text-3);
    font-variant-numeric: tabular-nums;
}

/* ---------- 右：三维视图 ---------- */
.view-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.btn-icon {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border: 1px solid #e2e2e6;
    background: #ffffff;
    color: var(--text-2);
    font-size: 15px;
    line-height: 1;
    border-radius: 7px;
    cursor: pointer;
    transition: all .16s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
}
.btn-icon:hover {
    border-color: var(--red);
    color: var(--red);
    background: var(--red-light);
}
.btn-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid #e2e2e6;
    background: #ffffff;
    color: var(--text-2);
    font-size: 12.5px;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all .16s ease;
    font-family: inherit;
    white-space: nowrap;
}
.btn-action:hover {
    border-color: var(--red);
    color: var(--red);
    background: var(--red-light);
}
.btn-action.primary {
    background: var(--red);
    border-color: var(--red);
    color: #ffffff;
    font-weight: 600;
}
.btn-action.primary:hover {
    background: var(--red-dark);
    border-color: var(--red-dark);
    color: #ffffff;
}

.view-body {
    flex: 1;
    min-height: 0;
    position: relative;
    background:
        radial-gradient(circle at 50% 38%, #ffffff 0%, #f6f7f9 68%, #eef0f3 100%);
    overflow: hidden;
    cursor: grab;
    touch-action: none;
}
.view-body.dragging { cursor: grabbing; }
.view-body canvas {
    display: block;
    width: 100%;
    height: 100%;
}
.view-hint {
    position: absolute;
    left: 12px;
    bottom: 10px;
    font-size: 11.5px;
    color: #9aa0a8;
    pointer-events: none;
    user-select: none;
}

/* ---------- 三维视图：右上角绕轴旋转盘 ---------- */
.rot-pad {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 7px 8px 6px;
    background: rgba(255, 255, 255, .9);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(20, 30, 50, .08);
    user-select: none;
}
.rot-pad-title {
    font-size: 10.5px;
    font-weight: 600;
    color: var(--text-3);
    text-align: center;
    letter-spacing: 2px;
    margin-bottom: 1px;
}
.rot-row {
    display: flex;
    align-items: center;
    gap: 4px;
}
.rot-axis {
    width: 13px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-2);
    text-align: center;
}
.rot-btn {
    width: 24px;
    height: 24px;
    padding: 0;
    border: 1px solid #e2e2e6;
    background: #ffffff;
    color: var(--text-2);
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all .16s ease;
}
.rot-btn:hover {
    border-color: var(--red);
    color: var(--red);
    background: var(--red-light);
}
.rot-btn:active { transform: scale(.9); }
.rot-btn svg { width: 13px; height: 13px; }

.view-foot {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    border-top: 1px solid #f2f2f4;
    background: #fcfcfd;
    flex-wrap: wrap;
}
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    min-width: 0;
}
.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-2);
    white-space: nowrap;
}
.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: inset -2px -2px 3px rgba(0, 0, 0, .28), inset 2px 2px 3px rgba(255, 255, 255, .55);
}

/* ---------- 响应式 ---------- */
@media (max-width: 1080px) {
    .workbench {
        grid-template-columns: minmax(0, 1fr);
        height: auto;
    }
    .panel-cfg .cfg-body { max-height: 520px; }
    .panel-view .view-body { min-height: 460px; }
}
