/* XRD 物相鉴定（/xrd）；.xrd-chart 和 .cif-powder-* 也被 CIF 查询页的模拟 XRD 使用，.xrd-card-* 是 PDF-4+ 卡片页 */
[hidden] { display: none !important; }

/* 通用 */
.xrd-step-title { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.xrd-step-title h2 { margin: 0; font-size: 17px; }
.xrd-step { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--c-primary); color: #fff; font-size: 13px; font-weight: 700; }
.xrd-error { color: #b91c1c; }
.xrd-msg { margin: 8px 0 0; font-size: 13.5px; color: var(--c-muted); min-height: 1em; }
.xrd-spacer { flex: 1; }
.xrd-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 8px 0 6px; }
.xrd-tog { display: inline-flex; align-items: center; gap: 5px; margin: 0; padding: 3px 9px; border: 1px solid var(--c-line); border-radius: 999px; font-size: 13px; font-weight: 500; color: var(--c-text-2); cursor: pointer; background: var(--c-surface); }
.xrd-tog:has(input:checked) { border-color: #bfdbfe; background: var(--c-primary-soft); color: var(--c-primary); }
.xrd-tog input { margin: 0; }
.xrd-canvas { display: block; width: 100%; border: 1px solid var(--c-line); border-radius: 8px; background: #fff; cursor: crosshair; touch-action: pan-y; }
.xrd-canvas:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }

/* ① 数据 */
.xrd-drop { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 22px 16px;
    border: 2px dashed #bfdbfe; border-radius: var(--r-md); background: #f8fbff; color: var(--c-muted); text-align: center; cursor: pointer; margin: 0; }
.xrd-drop:hover, .xrd-drop.over { border-color: var(--c-primary); background: var(--c-primary-soft); }
.xrd-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.xrd-drop > i { font-size: 26px; color: var(--c-primary); }
.xrd-drop-main { font-size: 15px; font-weight: 600; color: var(--c-ink); overflow-wrap: anywhere; }
.xrd-file-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-top: 12px; }
.xrd-file-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; font-size: 14px; color: var(--c-muted); min-width: 0; }
.xrd-file-meta strong { color: var(--c-ink); overflow-wrap: anywhere; }
.xrd-export { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.xrd-export label { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 14px; font-weight: 500; }
.xrd-export select { min-height: 32px; padding: 3px 8px; border: 1px solid #cbd5e1; border-radius: 6px; font: inherit; font-size: 14px; background: #fff; }
.xrd-preview { margin-top: 6px; }

/* ② 设置 */
.xrd-login p { color: var(--c-muted); margin-bottom: 12px; }
.xrd-form { display: grid; gap: 18px; }
.xrd-form .xrd-step-title { margin-bottom: 0; }
.xrd-form fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.xrd-form legend { font-weight: 650; margin-bottom: 8px; }
.xrd-form legend .field-hint { font-weight: 400; margin-left: 6px; }
.xrd-form select, .xrd-form input[type=number] { display: block; width: 100%; min-height: 40px; padding: 6px 8px; margin-top: .4rem; color: #172033; background: #fff; border: 1px solid #cbd5e1; border-radius: 6px; font: inherit; }
.xrd-settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 14px; }
.xrd-settings label { margin-bottom: 0; }
.xrd-check { display: flex; align-items: center; gap: 8px; margin: -4px 0 0; font-weight: 500; font-size: 14px; color: var(--c-text-2); }
.xrd-element-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 10px; }
.xrd-element-summary { font-size: 14px; color: #1e40af; font-weight: 600; }
.xrd-seg { display: inline-flex; padding: 3px; gap: 3px; border-radius: var(--r-sm); background: var(--c-line-soft); }
.xrd-seg label { position: relative; margin: 0; cursor: pointer; }
.xrd-seg input { position: absolute; opacity: 0; pointer-events: none; }
.xrd-seg span { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 4px; font-size: 13.5px; color: var(--c-muted); }
.xrd-seg input:checked + span { background: var(--c-surface); color: var(--c-ink); font-weight: 600; box-shadow: var(--sh-1); }
.xrd-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.xrd-dot.allowed { background: #60a5fa; }
.xrd-dot.required { background: #10b981; }
.xrd-periodic-scroll, .xrd-table-scroll { overflow-x: auto; }
.xrd-periodic { display: grid; grid-template-columns: repeat(18, minmax(34px, 1fr)); grid-template-rows: repeat(7, auto) 10px repeat(2, auto);
    gap: 3px; min-width: 660px; max-width: 980px; margin: 0 auto; }
.xrd-pt { position: relative; display: flex; align-items: center; justify-content: center; aspect-ratio: 1 / .86; min-height: 34px; padding: 9px 0 1px;
    border: 1px solid rgba(15, 23, 42, .10); border-radius: 5px; background: #f8fafc; color: #1e293b; cursor: pointer;
    font-size: 14px; font-weight: 650; line-height: 1; transition: transform .08s ease, box-shadow .08s ease; }
.xrd-pt small { position: absolute; top: 2px; left: 4px; font-size: 9px; font-weight: 500; color: rgba(30, 41, 59, .55); }
.xrd-pt:hover { transform: translateY(-1px); box-shadow: 0 2px 6px rgba(15, 23, 42, .15); border-color: var(--c-primary); }
.xrd-pt:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 1px; }
/* 族的底色（浅） */
.xrd-pt.alkali { background: #fee2e2; } .xrd-pt.alkaline { background: #ffedd5; } .xrd-pt.transition { background: #fef9c3; }
.xrd-pt.post { background: #dcfce7; } .xrd-pt.metalloid { background: #ccfbf1; } .xrd-pt.nonmetal { background: #e0f2fe; }
.xrd-pt.halogen { background: #e0e7ff; } .xrd-pt.noble { background: #f3e8ff; } .xrd-pt.lanthanide { background: #fce7f3; } .xrd-pt.actinide { background: #f5e1e9; }
/* 选中状态盖过底色 */
.xrd-pt[data-state=allowed] { background: #2563eb; border-color: #1d4ed8; color: #fff; box-shadow: 0 0 0 2px #bfdbfe; }
.xrd-pt[data-state=required] { background: #059669; border-color: #047857; color: #fff; box-shadow: 0 0 0 2px #a7f3d0; }
.xrd-pt[data-state] small { color: rgba(255, 255, 255, .8); }
.xrd-pt[data-state=''] small { color: rgba(30, 41, 59, .55); }
.xrd-pt-marker { display: flex; align-items: center; justify-content: center; border: 1px dashed #cbd5e1; border-radius: 5px; font-size: 10px; color: #64748b; }
.xrd-pt-marker.lanthanide { background: #fdf2f8; } .xrd-pt-marker.actinide { background: #faf0f4; }
.xrd-pt-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; margin-top: 10px; font-size: 12px; color: var(--c-muted); }
.xrd-pt-key { display: inline-flex; align-items: center; gap: 5px; }
.xrd-pt-key i { width: 12px; height: 12px; min-height: 0; padding: 0; aspect-ratio: auto; border-radius: 3px; cursor: default; }
.xrd-card-export { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: -6px 0 18px; font-size: 14px; color: var(--c-text-2); }
.xrd-elements > .field-hint { margin-top: 8px; }
.xrd-sources { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.xrd-sources legend { width: 100%; }
.xrd-pill { position: relative; margin: 0; cursor: pointer; }
.xrd-pill input { position: absolute; opacity: 0; pointer-events: none; }
.xrd-pill span { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border: 1px solid var(--c-line); border-radius: 999px; font-size: 13.5px; color: var(--c-muted); background: var(--c-surface); }
.xrd-pill span::before { content: ''; width: 12px; height: 12px; border: 1.5px solid #94a3b8; border-radius: 3px; }
.xrd-pill input:checked + span { border-color: var(--c-primary); background: var(--c-primary-soft); color: var(--c-primary); font-weight: 600; }
.xrd-pill input:checked + span::before { border-color: var(--c-primary); background: var(--c-primary) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2 5 8.5l4.5-5' fill='none' stroke='white' stroke-width='1.8'/%3E%3C/svg%3E") center / 10px no-repeat; }
.xrd-pill input:focus-visible + span { outline: 2px solid var(--c-primary); outline-offset: 1px; }
.xrd-submit { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem 1.15rem; }

/* ③ 结果 */
.xrd-result { margin-top: 20px; }
.xrd-result-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.xrd-result-grid > .card { margin-bottom: 0; }
.xrd-compare-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.xrd-compare-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.xrd-compare-name { font-size: 17px; font-weight: 700; color: var(--c-ink); overflow-wrap: anywhere; }
.xrd-swatch { display: inline-block; flex-shrink: 0; width: 14px; height: 14px; border-radius: 4px; background: var(--c, transparent); }
.xrd-compare-nav { display: flex; align-items: center; gap: 6px; }
.xrd-pos { min-width: 5.5em; text-align: center; font-size: 13px; color: var(--c-muted); font-variant-numeric: tabular-nums; }
.xrd-stats { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 2px; }
.xrd-stat { display: inline-flex; align-items: baseline; gap: 6px; padding: 4px 10px; border-radius: var(--r-sm); background: var(--c-bg); border: 1px solid var(--c-line-soft); }
.xrd-stat small { font-size: 12px; color: var(--c-faint); }
.xrd-stat b { font-size: 15px; color: var(--c-ink); font-variant-numeric: tabular-nums; }
.xrd-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 8px 0 2px; font-size: 13px; color: var(--c-muted); }
.xrd-legend span::before { content: ''; display: inline-block; width: 16px; margin-right: 6px; vertical-align: middle; }
.xrd-key-line::before { height: 2px; background: var(--c); }
.xrd-key-stick::before { width: 3px !important; height: 12px; background: var(--c); }
.xrd-key-dash::before { width: 0 !important; height: 12px; border-left: 2px dashed var(--c); }
.xrd-howto { margin: 4px 0 0; }
.xrd-howto .ok, .xrd-legend .ok { color: #16a34a; }
.xrd-howto .miss { color: #dc2626; }
.xrd-warnings { margin: 12px 0 0; padding: 8px 12px 8px 28px; background: #fffbeb; border: 1px solid #fde68a; border-radius: 6px; color: #78350f; font-size: 13.5px; }
.xrd-warnings li.xrd-meta { list-style: none; margin-left: -16px; color: #475569; }
.xrd-bottom-actions { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 10px; margin-top: 14px; }
.xrd-peak-table { flex: 1; min-width: 260px; }
.xrd-peak-table summary { cursor: pointer; font-weight: 600; color: var(--c-text-2); }
.xrd-result table { width: 100%; border-collapse: collapse; margin-top: .5rem; font-size: 13.5px; }
.xrd-result :is(th, td) { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid #e2e8f0; vertical-align: top; }
.xrd-result th { color: #475569; font-weight: 650; white-space: nowrap; }

/* 右侧 */
.xrd-side { position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow: auto; padding: 16px; }
.xrd-side-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 0 0 8px; font-size: 15px; }
.xrd-side-title .field-hint { margin: 0; font-weight: 400; }
#xrd-phases { margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--c-line); }
.xrd-phase { padding: 8px 10px; margin-bottom: 6px; border: 1px solid var(--c-line); border-left: 4px solid var(--c); border-radius: var(--r-sm); cursor: pointer; }
.xrd-phase.on { background: #faf5ff; box-shadow: 0 0 0 1px var(--c) inset; }
.xrd-phase-head { display: flex; align-items: center; gap: 8px; }
.xrd-phase-head strong { flex: 1; min-width: 0; font-size: 14px; overflow-wrap: anywhere; }
.xrd-phase-head .xrd-swatch { background: var(--c); }
.xrd-phase-tools { display: inline-flex; gap: 2px; }
.xrd-phase-tools .btn-icon { width: 26px; height: 26px; color: var(--c-faint); }
.xrd-phase-facts { margin-top: 4px; font-size: 13px; color: var(--c-text-2); }
.xrd-filter { width: 100%; min-height: 34px; padding: 4px 10px; margin-bottom: 8px; border: 1px solid var(--c-line); border-radius: var(--r-sm); font: inherit; font-size: 13.5px; }
.xrd-cand-list { display: grid; gap: 6px; outline: none; }
.xrd-cand-list:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; border-radius: 6px; }
.xrd-cand { padding: 8px 10px; border: 1px solid var(--c-line); border-radius: var(--r-sm); cursor: pointer; background: var(--c-surface); }
.xrd-cand:hover { border-color: #93c5fd; }
.xrd-cand.on { border-color: #ea580c; box-shadow: 0 0 0 1px #ea580c inset; background: #fff7ed; }
.xrd-cand-head { display: flex; align-items: baseline; gap: 8px; }
.xrd-cand-head strong { font-size: 14px; color: var(--c-ink); overflow-wrap: anywhere; }
.xrd-rank { flex-shrink: 0; min-width: 20px; padding: 0 5px; border-radius: 4px; background: var(--c-line-soft); color: var(--c-muted); font-size: 12px; text-align: center; font-variant-numeric: tabular-nums; }
.xrd-cand.on .xrd-rank { background: #ea580c; color: #fff; }
.xrd-ref { margin-top: 2px; font-size: 12.5px; color: var(--c-muted); }
.xrd-ref-sub { color: var(--c-text-2); }
.xrd-ref-code a { color: var(--c-primary); }
.xrd-bars { display: grid; gap: 3px; margin-top: 6px; }
.xrd-bar { display: grid; grid-template-columns: 3.6em 1fr 3.6em; align-items: center; gap: 6px; font-size: 12px; color: var(--c-faint); }
.xrd-bar i { height: 6px; border-radius: 3px; background: var(--c-line-soft); overflow: hidden; }
.xrd-bar b { display: block; height: 100%; background: #60a5fa; border-radius: 3px; }
.xrd-cand.on .xrd-bar b { background: #ea580c; }
.xrd-bar em { font-style: normal; text-align: right; color: var(--c-text-2); font-variant-numeric: tabular-nums; }
.xrd-cand-stats { margin-top: 6px; font-size: 12.5px; color: var(--c-text-2); }
.xrd-cand-actions { display: grid; gap: 6px; margin-top: 8px; }
.xrd-cand-actions .btn { justify-self: start; }
.xrd-alts summary { cursor: pointer; font-size: 12.5px; color: var(--c-muted); }
.xrd-alt { padding: 4px 0 4px 10px; border-left: 2px solid var(--c-line); margin-top: 4px; font-size: 12.5px; }

@media (max-width: 1100px) {
    .xrd-result-grid { grid-template-columns: 1fr; }
    .xrd-side { position: static; max-height: none; }
    .xrd-cand-list { max-height: 60vh; overflow: auto; }
}

/* CIF 查询页的模拟 XRD 使用的旧绘图组件 */
.xrd-chart { display: block; width: 100%; height: clamp(230px, 40vw, 395px); border: 1px solid #e2e8f0; border-radius: 8px; margin-top: .75rem; }
.cif-powder-controls { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem 1.15rem; }
.cif-powder-controls label { display: flex; align-items: center; gap: .4rem; }
.cif-powder-controls select { display: block; width: auto; min-height: 40px; padding: 6px 8px; margin: 0; color: #172033; background: #fff; border: 1px solid #cbd5e1; border-radius: 6px; font: inherit; }
.cif-powder h2 { font-size: 1.15rem; margin-bottom: .5rem; }

/* PDF-4+ 卡片页 */
.xrd-card-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); gap: .75rem 1rem; margin-bottom: 1rem; }
.xrd-card-facts dt { color: #475569; font-size: .9rem; }
.xrd-card-facts dd { margin: .2rem 0 0; overflow-wrap: anywhere; }
.xrd-card-peaks { max-height: 34rem; overflow: auto; }
.xrd-card-peaks thead { position: sticky; top: 0; background: #fff; }
.card.xrd-result h2 { font-size: 1.1rem; margin: 20px 0 10px; }
.card.xrd-result h2:first-child { margin-top: 0; }
