:root {
	--bg: #0b1017;
	--panel: #121923;
	--panel-2: #182231;
	--line: #293647;
	--ink: #e2edf3;
	--dim: #7f91a1;
	--cyan: #7fd2d8;
	--cyan-dark: #173c42;
	--gold: #f1cf73;
	--danger: #ef7c73;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; }
body { background: var(--bg); color: var(--ink); font: 13px/1.45 "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif; }
button, select, textarea, input { font: inherit; }
button, select {
	color: var(--ink); background: #1a2533; border: 1px solid var(--line);
	border-radius: 6px; padding: 6px 10px;
}
button { cursor: pointer; }
button:hover { border-color: #4f687f; background: #223142; }
button.on { color: #071416; background: var(--cyan); border-color: var(--cyan); }
button.primary { min-width: 106px; color: #061517; background: var(--cyan); border-color: var(--cyan); font-weight: 700; }
button.quiet { color: #abc0cf; background: transparent; border-style: dashed; }
.wide { width: 100%; }

#boot { position: fixed; inset: 0; display: grid; place-items: center; text-align: center; background: radial-gradient(circle at 50% 40%, #162431, var(--bg) 56%); }
#boot h1 { margin: 5px 0 8px; font-size: 28px; font-weight: 650; }
#boot p:last-child { margin: 0; color: var(--dim); }
.eyebrow { margin: 0; color: var(--cyan); font: 600 10px/1.2 ui-monospace, SFMono-Regular, monospace; letter-spacing: .16em; }

#app { height: 100%; display: grid; grid-template-rows: 58px 1fr; }
.topbar { display: flex; align-items: center; gap: 28px; padding: 0 18px; border-bottom: 1px solid var(--line); background: #0e151e; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.brand .mark { width: 25px; height: 25px; border: 2px solid var(--cyan); border-radius: 50%; box-shadow: inset 0 -7px 0 #426f86; }
.brand b, .brand small { display: block; }
.brand b { font-size: 14px; }.brand small { color: var(--dim); font-size: 10px; }
nav { display: flex; align-self: stretch; }
nav a { display: grid; place-items: center; padding: 0 14px; color: var(--dim); text-decoration: none; border-bottom: 2px solid transparent; }
nav a.on { color: var(--ink); border-bottom-color: var(--cyan); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.status { color: var(--dim); font-size: 11px; }

main { min-height: 0; display: grid; grid-template-columns: 260px minmax(460px, 1fr) 268px; }
.panel { min-height: 0; overflow-y: auto; padding: 14px; background: var(--panel); }
.left-panel { border-right: 1px solid var(--line); }
.right-panel { border-left: 1px solid var(--line); }
.panel section { margin-bottom: 20px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.section-head h2 { margin: 0; color: #b9cad5; font-size: 11px; letter-spacing: .08em; }
.section-head span { color: var(--dim); font-size: 10px; }

.recipes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.recipes button { padding: 7px 3px; font-size: 11px; }
.dna { display: grid; gap: 5px; margin-bottom: 7px; }
.gene { position: relative; display: grid; grid-template-columns: 7px 18px 24px 1fr auto auto; align-items: center; gap: 6px; min-height: 36px; padding: 4px 5px 4px 0; border: 1px solid var(--line); border-radius: 7px; background: var(--panel-2); cursor: pointer; }
.gene .color { align-self: stretch; border-radius: 6px 0 0 6px; }
.gene .grip { color: #5f7385; cursor: grab; font-size: 12px; }
.gene .num { color: var(--dim); font: 10px ui-monospace, monospace; text-align: right; }
.gene b { font-size: 11px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gene button { width: 23px; height: 23px; padding: 0; border-color: transparent; background: transparent; color: var(--dim); font-size: 10px; }
.gene button:hover { color: var(--ink); border-color: var(--line); }
.gene.dragging { opacity: .4; }
.gene.active { border-color: var(--gold); box-shadow: 0 0 0 1px #f1cf7333; }
.gene.active::after { content: "NOW"; position: absolute; right: 5px; top: -7px; padding: 0 4px; color: #261f0c; background: var(--gold); border-radius: 3px; font: 700 8px/14px ui-monospace, monospace; }

.field { display: flex; align-items: center; gap: 8px; margin: 7px 0; }
.field > span:first-child { width: 38px; color: var(--dim); font-size: 11px; }
.field select, .field input { flex: 1; min-width: 0; }
.field output { width: 44px; text-align: right; color: #b9cad5; font: 11px ui-monospace, monospace; }
.segmented { display: flex; }
.segmented button { border-radius: 0; border-right-width: 0; }
.segmented button:first-child { border-radius: 6px 0 0 6px; }
.segmented button:last-child { border-radius: 0 6px 6px 0; border-right-width: 1px; }

.stage-panel { position: relative; min-width: 0; min-height: 0; display: grid; grid-template-rows: 50px 1fr 64px; background: #080d13; }
.stage-toolbar, .transport { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-bottom: 1px solid var(--line); background: #101720; }
.stage-toolbar .segmented button { min-width: 70px; font-size: 11px; }
.legend { margin-left: auto; display: flex; align-items: center; gap: 6px; color: var(--dim); font-size: 10px; }
.cell-dot { width: 7px; height: 7px; background: #d8f3ff; border-radius: 1px; }
.viewport { position: relative; min-height: 0; overflow: hidden; background: radial-gradient(circle at 50% 48%, #142433, #071018 65%); }
#view { display: block; width: 100%; height: 100%; }
.pose-banner { position: absolute; z-index: 3; top: 60px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 9px; padding: 6px 8px 6px 11px; border: 1px solid #685929; border-radius: 8px; background: #211d12e8; box-shadow: 0 8px 24px #0008; color: #d9c989; font-size: 10px; }
.pose-banner b { color: var(--gold); }
.pose-banner button { padding: 3px 7px; font-size: 9px; }
.corner-label { position: absolute; left: 14px; bottom: 12px; display: flex; gap: 12px; color: #78909f; font: 10px ui-monospace, monospace; pointer-events: none; }
.corner-label b { color: #b7dce1; font-weight: 500; }
.transport { justify-content: center; border-top: 1px solid var(--line); border-bottom: 0; }
.transport label { color: var(--dim); font-size: 11px; }
.transport select { margin-left: 4px; padding: 4px 7px; }
.timeline { width: min(240px, 25%); height: 4px; overflow: hidden; border-radius: 9px; background: #283442; }
.timeline i { display: block; width: 100%; height: 100%; background: var(--cyan); transform-origin: left; }

.specimen-card { padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: linear-gradient(150deg, #1b2d3b, #111a24); }
.specimen-card h2 { margin: 6px 0 12px; font-size: 21px; font-weight: 650; }
.active-action { display: flex; justify-content: space-between; align-items: center; padding-top: 9px; border-top: 1px solid #334352; }
.active-action span { color: var(--dim); font-size: 10px; }.active-action b { color: var(--gold); font-size: 12px; }
.belly-preview { position: relative; width: 78px; height: 78px; margin: 10px auto; overflow: hidden; border: 2px solid #a4d7dc; border-radius: 50%; background: #09121a; box-shadow: inset 0 0 18px #000a; }
.belly-preview > div { position: absolute; inset: auto 0 0; height: 0%; background: #347cc4; transition: height .15s; }
.belly-list { min-height: 24px; display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 7px; }
.belly-list span { padding: 2px 6px; border-radius: 10px; background: #202c39; font-size: 10px; }
.belly-list .empty { color: var(--dim); background: transparent; }
.metrics { margin: 0; display: grid; gap: 1px; }
.metrics div { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid #222f3d; }
.metrics dt { color: var(--dim); }.metrics dd { margin: 0; font: 11px ui-monospace, monospace; color: #c8dce5; }
.note-box label { display: block; margin-bottom: 6px; color: #b9cad5; font-size: 11px; font-weight: 600; }
.note-box textarea { width: 100%; resize: vertical; color: var(--ink); background: #0d141d; border: 1px solid var(--line); border-radius: 7px; padding: 8px; }
.note-box p { margin: 5px 0 0; color: var(--dim); font-size: 10px; }

#toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); padding: 8px 14px; color: #081416; background: var(--cyan); border-radius: 7px; box-shadow: 0 8px 30px #0008; font-weight: 650; }

.editor-dialog { width: min(680px, calc(100vw - 36px)); max-height: min(720px, calc(100vh - 36px)); overflow: auto; color: var(--ink); background: #121a24; border: 1px solid #3b4b5d; border-radius: 12px; padding: 22px; box-shadow: 0 26px 90px #000c; }
.editor-dialog::backdrop { background: #02060ad9; backdrop-filter: blur(4px); }
.editor-dialog h2 { margin: 6px 0; font-size: 20px; }
.dialog-close { position: absolute; top: 12px; right: 12px; width: 29px; height: 29px; padding: 0; border-radius: 50%; }
.dialog-help { margin: 0 0 16px; color: var(--dim); font-size: 11px; }
.gene-palette { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.gene-choice { display: grid; grid-template-columns: 8px 1fr; align-items: center; gap: 8px; min-height: 42px; text-align: left; }
.gene-choice i { align-self: stretch; margin: -1px 0 -1px -1px; border-radius: 5px 0 0 5px; }
.gene-choice small { display: block; color: var(--dim); font: 9px ui-monospace, monospace; }
.capacity { height: 8px; overflow: hidden; margin: 12px 0; border-radius: 8px; background: #273442; }
.capacity i { display: block; width: 0; height: 100%; background: var(--cyan); transition: width .12s; }
.material-palette { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.mat-choice { display: grid; grid-template-columns: 11px 1fr auto auto auto; align-items: center; gap: 7px; padding: 6px 7px; border: 1px solid var(--line); border-radius: 7px; background: #17212d; }
.mat-choice i { width: 11px; height: 25px; border-radius: 3px; }
.mat-choice b { font-size: 11px; }
.mat-choice em { min-width: 18px; color: var(--cyan); font: normal 11px ui-monospace, monospace; text-align: center; }
.mat-choice button { width: 25px; height: 25px; padding: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 7px; margin-top: 16px; }
.dialog-actions form { margin: 0; }

@media (max-width: 1000px) {
	main { grid-template-columns: 220px 1fr; }
	.right-panel { display: none; }
}

@media (max-width: 720px) {
	.gene-palette, .material-palette { grid-template-columns: 1fr; }
}
