/* 星辰生物实验室 · 遗传沙盒（配色沿用 style.css 的变量） */
.sandbox .top-controls { gap: 8px; }
.sandbox .seed-box input { width: 92px; }
.file-button { position: relative; overflow: hidden; cursor: pointer; display: inline-block; }
.file-button input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.share-box { max-width: 1680px; margin: 10px auto 0; padding: 10px 14px; background: var(--card); border: 1px solid var(--line2); border-radius: var(--radius); font-size: 13px; color: var(--muted); }
.share-box { margin-left: 20px; margin-right: 20px; }
.share-row { display: flex; gap: 6px; margin-top: 6px; }
.share-row input { flex: 1; min-width: 0; background: var(--bg2); border: 1px solid var(--line2); border-radius: 8px; padding: 4px 8px; font: 12px var(--mono); }
.share-row button { background: var(--card2); border: 1px solid var(--line2); border-radius: 8px; padding: 4px 12px; font-size: 13px; }

.sb-layout { display: grid; grid-template-columns: 270px minmax(0, 1fr) 360px; gap: 18px; padding: 18px 20px 40px; max-width: 1680px; margin: 0 auto; }
.sb-left, .sb-right { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.sb-main { min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.sb-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; min-width: 0; }
.sb-h { margin: 0 0 8px; font-size: 13px; letter-spacing: 2px; color: var(--faint); font-weight: 650; }
.sb-head h1 { font-size: 26px; }
.sb-card button, .examples button, .cross-actions button, .tool-group button, .editor button, .pop-actions button { background: var(--card2); border: 1px solid var(--line2); border-radius: 8px; padding: 4px 12px; font-size: 13px; }
.sb-card button:hover { border-color: var(--accent); }
.sb-card button.primary, .cross-actions button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 650; }
.editor button.primary, .pop-actions button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 650; }
.sb-card button:disabled { opacity: .45; cursor: not-allowed; }
.sb-card button.danger { color: var(--bad); }

/* 示例 */
.examples { display: grid; gap: 8px; }
.example { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--bg2); }
.example.current { border-color: var(--accent); }
.example h3 { margin: 0; font-size: 14.5px; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.example p { margin: 2px 0 6px; color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.example .opts { display: flex; flex-wrap: wrap; gap: 4px 10px; margin: 4px 0 6px; font-size: 12.5px; color: var(--muted); }
.example .opts label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.example input[type=checkbox] { accent-color: var(--accent); }
.save-row { display: flex; gap: 6px; }
.save-row input { flex: 1; min-width: 0; font-family: var(--font); }
.saved-list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; }
.saved-list li { display: flex; align-items: center; gap: 6px; font-size: 13px; border-bottom: 1px dashed var(--line); padding: 3px 0; }
.saved-list li span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-list small { color: var(--faint); }
.saved-list button { padding: 1px 8px; font-size: 12px; }

/* 选项卡 */
.sb-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.sb-tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 14px; color: var(--muted); font-weight: 650; }
.sb-tabs button[aria-selected=true] { color: var(--text); border-bottom-color: var(--accent); }
.tab-body { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.guide { border: 1px solid var(--line2); background: linear-gradient(160deg, #142540, #0f1828); border-radius: 12px; padding: 10px 14px; font-size: 14px; line-height: 1.7; }
.guide b { color: var(--accent); }

/* 杂交栏 */
.slots { display: flex; align-items: stretch; gap: 10px; }
.slot { flex: 1; min-width: 0; border: 1px dashed var(--line2); border-radius: 10px; padding: 6px 10px; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.slot.filled { border-style: solid; border-color: var(--line2); background: var(--bg2); }
.slot .role { color: var(--faint); font-size: 12px; white-space: nowrap; }
.slot .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot .who small { color: var(--muted); }
.slot button { padding: 0 8px; font-size: 12px; }
.times { align-self: center; color: var(--faint); font-size: 20px; }
.cross-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.num-field { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.num-field input, .editor input[type=number], .pop-grid input[type=number], .freq-table input { width: 80px; background: var(--bg2); border: 1px solid var(--line2); border-radius: 6px; padding: 2px 6px; font: 13px var(--mono); }
#cross-msg { min-height: 1em; margin: 6px 0 0; }
#cross-msg.warn { color: var(--amber); }

/* 谱系树 */
.ped-tools { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.ped-tools .sb-h { margin: 0; }
.tool-group button { min-width: 32px; }
.ped-wrap { position: relative; height: clamp(360px, 58vh, 640px); border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: radial-gradient(900px 420px at 50% 0%, #12301f, #060c0f 72%); touch-action: none; cursor: grab; }
.ped-wrap.dragging { cursor: grabbing; }
#ped { display: block; width: 100%; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend b { color: var(--text); font-weight: 600; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 1px solid #ffffff40; flex: none; vertical-align: -1px; }
.sw.line { height: 3px; border: 0; border-radius: 2px; width: 18px; }
.sw.dash { background-image: none !important; }

/* 起始个体 */
.founders { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; }
.founder { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; font-size: 13px; background: var(--bg2); }
.founder .who { flex: 1; min-width: 0; }
.founder .who b { display: block; font-weight: 600; }
.founder .who small { color: var(--muted); font-family: var(--mono); font-size: 12px; word-break: break-all; }
.founder button { padding: 1px 8px; font-size: 12px; }
.add-founder { margin-top: 10px; }
.add-founder summary { cursor: pointer; color: var(--accent); font-size: 14px; }
.ff-grid { display: grid; grid-template-columns: auto 1fr 1fr; gap: 6px 10px; align-items: center; font-size: 13px; margin: 10px 0; }
.ff-grid .hd { color: var(--faint); font-size: 12px; }
.ff-grid select { width: 100%; min-width: 0; }
.ff-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; }
.ff-row input.text-input { width: 160px; font-family: var(--font); }

/* 个体详情 */
.ind-head { display: flex; align-items: center; gap: 10px; }
.ind-head h3 { margin: 0; font-size: 17px; }
.ind-head small { color: var(--muted); display: block; font-size: 12.5px; }
.ind-pheno { margin: 8px 0; padding: 6px 10px; border-left: 3px solid var(--accent); background: #8be08f12; border-radius: 0 8px 8px 0; font-size: 14px; }
.kv { width: 100%; font-size: 13px; margin: 6px 0; }
.kv td, .kv th { text-align: left; font-family: var(--font); white-space: normal; padding: 4px 6px; }
.kv th { position: static; }
.kv td:first-child { text-align: left; color: var(--muted); }
.kv .geno { font-family: var(--mono); color: var(--text); }
.kv sup { font-size: 70%; }
.chrom-svg { display: block; width: 100%; height: auto; margin: 6px 0; }
.chrom-svg text { font: 11px var(--mono); fill: var(--text); }
.chrom-svg .lab { fill: var(--faint); font-family: var(--font); }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.linkish { background: none !important; border: 0 !important; padding: 0 !important; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; font-size: 13px !important; }

/* 统计 */
.stat-table { max-height: 320px; }
.stat-table td.name { text-align: left; font-family: var(--font); white-space: normal; min-width: 110px; }
.stat-table td:first-child { color: var(--text); }
.chi { margin-top: 8px; font-size: 13.5px; line-height: 1.6; padding: 8px 10px; border-radius: 8px; background: var(--bg2); border: 1px solid var(--line); }
.chi .formula { font-family: var(--mono); color: var(--accent); }
.chi.reject { border-color: #ff8a7a66; }
.ratio-row { display: flex; gap: 6px; margin-top: 8px; align-items: center; font-size: 13px; flex-wrap: wrap; }
.ratio-row input { flex: 1; min-width: 120px; }
.toggle-line { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; }
.toggle-line input { accent-color: var(--accent); }
.rec-list { margin: 8px 0 0; padding: 0; list-style: none; font-size: 13px; }
.rec-list li { padding: 4px 0; border-bottom: 1px dashed var(--line); }
.rec-list b { font-family: var(--mono); color: var(--accent); }
.species-note { font-size: 13.5px; line-height: 1.75; color: var(--muted); }
.species-note p { margin: 0 0 6px; }
.karyo { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.karyo span { font: 11.5px var(--mono); border: 1px solid var(--line2); border-radius: 6px; padding: 0 6px; color: var(--faint); }
.karyo span.has { color: var(--text); border-color: var(--accent); }

/* 物种编辑器 */
.editor { display: flex; flex-direction: column; gap: 14px; }
.ed-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px 14px; }
.ed-field { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--muted); min-width: 0; }
.ed-field input, .ed-field select, .ed-field textarea { width: 100%; min-width: 0; }
.ed-field input:not([type=color]):not([type=checkbox]) { background: var(--bg2); border: 1px solid var(--line2); border-radius: 8px; padding: 4px 8px; }
.ed-field.wide { grid-column: 1 / -1; }
.gene-card { border: 1px solid var(--line2); border-radius: 12px; padding: 10px 12px; background: var(--bg2); }
.gene-card + .gene-card { margin-top: 10px; }
.gene-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.gene-head h3 { margin: 0; font-size: 15px; }
.al-table { width: 100%; font-size: 13px; margin: 6px 0; border-collapse: collapse; }
.al-table th, .al-table td { text-align: left; padding: 3px 4px; font-family: var(--font); white-space: nowrap; border-bottom: 1px solid var(--line); }
.al-table th { position: static; background: none; color: var(--faint); font-weight: 600; font-size: 12px; }
.al-table td:first-child { text-align: left; color: var(--text); }
.al-table input:not([type=color]) { width: 100%; min-width: 50px; background: var(--card); border: 1px solid var(--line2); border-radius: 6px; padding: 2px 6px; }
.al-table input.sym { width: 70px; font-family: var(--mono); }
.al-table input.rank { width: 52px; }
.al-table input[type=color] { width: 34px; height: 24px; padding: 0; border: 1px solid var(--line2); border-radius: 6px; background: none; }
.al-scroll { overflow-x: auto; }
.hint { color: var(--faint); font-size: 12.5px; line-height: 1.5; margin: 4px 0; }
.rule { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; margin: 6px 0; font-size: 13px; background: var(--bg2); }
.rule select, .rule input:not([type=color]) { max-width: 160px; min-width: 0; background: var(--card); border: 1px solid var(--line2); border-radius: 6px; padding: 2px 6px; }
.rule input[type=color] { width: 34px; height: 24px; padding: 0; border: 1px solid var(--line2); border-radius: 6px; background: none; }
.ed-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; position: sticky; bottom: 0; background: var(--card); padding: 10px 14px; border: 1px solid var(--line2); border-radius: var(--radius); z-index: 3; }
.ed-errors { color: var(--amber); font-size: 13px; }
.dist-table td { text-align: left; font-family: var(--font); }

/* 种群 */
.pop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px 14px; font-size: 13px; color: var(--muted); }
.pop-grid label { display: flex; flex-direction: column; gap: 3px; }
.pop-grid input[type=number] { width: 100%; }
.pop-src { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13.5px; margin: 6px 0 10px; }
.pop-src label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.pop-src input { accent-color: var(--accent); }
.freq-table { width: 100%; font-size: 13px; }
.freq-table td, .freq-table th { text-align: left; font-family: var(--font); white-space: normal; }
.freq-table th { position: static; }
.freq-table td:first-child { color: var(--text); text-align: left; }
.freq-table input { width: 72px; }
.pop-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.pop-actions .prog { font: 13px var(--mono); color: var(--muted); }
.chart-title { margin: 10px 0 2px; font-size: 13px; color: var(--muted); font-weight: 600; }
.chart-wrap { position: relative; }
.chart { display: block; width: 100%; height: 220px; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; touch-action: pan-y; }
.chart-tip { position: absolute; top: 8px; pointer-events: none; background: #0b1220f0; border: 1px solid var(--line2); border-radius: 8px; padding: 6px 9px; font-size: 12px; line-height: 1.55; min-width: 120px; z-index: 2; }
.chart-tip b { font-family: var(--mono); }
.pop-summary { font-size: 13.5px; line-height: 1.7; margin-top: 10px; }
.pop-summary p { margin: 4px 0; }

.sb-toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 20px); background: var(--accent); color: var(--accent-ink); padding: 8px 18px; border-radius: 999px; font-weight: 600; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; max-width: calc(100vw - 32px); text-align: center; z-index: 60; }
.sb-toast.show { opacity: 1; transform: translate(-50%, 0); }
.sb-toast.warn { background: var(--amber); }

@media (max-width: 1260px) {
  .sb-layout { grid-template-columns: 250px minmax(0, 1fr); }
  .sb-right { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-items: start; }
}
@media (max-width: 860px) {
  .sandbox .topbar { position: static; }
  .ed-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .ed-grid .ed-field:has(textarea), .ed-grid > .table-wrap { grid-column: 1 / -1; }
  .pop-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sb-layout { grid-template-columns: minmax(0, 1fr); padding: 12px 16px 32px; gap: 14px; }
  .sb-left { order: 2; }
  .sb-main { order: 1; }
  .sb-right { order: 1; display: flex; }
  .share-box { margin: 8px 16px 0; }
  .sb-head h1 { font-size: 21px; }
  .sb-tabs button { padding: 8px 10px; flex: 1; }
  .slots { flex-direction: column; }
  .times { align-self: center; line-height: 1; }
  .ped-wrap { height: clamp(320px, 100vw, 60vh); }
  .ff-grid { grid-template-columns: auto 1fr 1fr; }
  .rule select, .rule input:not([type=color]) { max-width: 130px; }
}
@media (prefers-reduced-motion: reduce) { .sb-toast { transition: none; } }
