* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; overflow: hidden; }
body { font: 14px/1.4 system-ui, sans-serif; color: #eef3fa; background: linear-gradient(#568dcc 0%, #a4c8e9 53%, #dbe8ef 100%); }
body[data-theme="glacier"] { background: linear-gradient(#192e58 0%, #6c91b4 52%, #dbedef 100%); }
body[data-theme="harbor"] { background: linear-gradient(#243750 0%, #738b96 54%, #edc092 100%); }
canvas { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; }
header, .dock, .camera { position: fixed; z-index: 1; }
.camera { right: max(8px, env(safe-area-inset-right)); top: 45%; display: flex; flex-direction: column; gap: 4px; touch-action: manipulation; }
.camera button { width: 44px; height: 44px; padding: 0; }
@media (max-height: 480px) { .camera { flex-direction: row; } }
header, .controls, footer p:not(:empty) { background: #101a2be8; border: 1px solid #ffffff22; border-radius: 10px; }
header { top: 8px; left: 8px; padding: 8px 12px; width: min(410px, calc(100% - 16px)); }
h1 { font-size: 17px; letter-spacing: .02em; }
h1 small { font-weight: 400; font-size: 11px; opacity: .7; margin-left: 6px; }
.heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.heading-actions { display: flex; gap: 4px; }
.heading button { padding: 3px 8px; font-size: 12px; }
header label { display: flex; align-items: center; gap: 8px; margin: 5px 0; }
header select { min-width: 0; }
#goal, #criteria { font-size: 12px; color: #d6e3f3; }
#criteria:not(:empty) { margin-top: 4px; color: #ffdd8b; }
select, button { font: inherit; color: inherit; background: #223252; border: 1px solid #ffffff2e; border-radius: 8px; padding: 7px 12px; cursor: pointer; }
button:hover { background: #2d4270; }
button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid #ffd35c; outline-offset: -2px; }
button:disabled { opacity: .5; cursor: default; }
button[aria-pressed="true"] { background: #f0ad2e; color: #17130a; font-weight: 600; }
.dock { left: 8px; right: 8px; bottom: max(8px, env(safe-area-inset-bottom)); display: grid; grid-template-columns: minmax(0, 1fr); justify-items: start; gap: 5px; pointer-events: none; }
.controls, .tools, .actions, .drive, .piston-controls { display: flex; align-items: center; gap: 5px; }
.controls { max-width: 100%; padding: 5px; pointer-events: auto; }
.tools { min-width: 0; overflow-x: auto; }
.tools button, .actions button, [data-control] { white-space: nowrap; min-height: 38px; }
.actions { padding-inline-start: 6px; border-inline-start: 1px solid #ffffff33; }
.material { display: flex; align-items: center; gap: 4px; font-size: 12px; }
.material select { padding-inline: 5px; }
.primary { background: #207b4b; font-weight: 700; }
.primary:hover { background: #258958; }
[data-control] { user-select: none; touch-action: none; }
.piston-controls button:active { background: #f0ad2e; color: #17130a; }
footer { display: flex; flex-wrap: wrap; gap: 4px; font-size: 12px; }
footer p:not(:empty) { padding: 4px 9px; }
#message[data-kind="bad"] { background: #7c2230ee; }
#message[data-kind="good"] { background: #1d6b43ee; font-weight: 700; }
body[data-mode="build"] .when-sim, body[data-mode="sim"] .when-build, body[data-drive="auto"] .drive, [hidden] { display: none; }
@media (max-width: 740px) {
  .controls { flex-wrap: wrap; }
  .tools, .drive, .piston-controls { flex: 1 1 100%; }
  .tools { flex-wrap: wrap; overflow: visible; }
  .tools button { flex: 1 0 30%; padding-inline: 7px; }
  .actions { border: 0; padding: 0; margin-left: auto; }
  [data-control] { flex: 1; }
}
@media (max-height: 450px) and (orientation: landscape) {
  #message[data-kind=""] { display: none; }
}
dialog { margin: auto; width: min(520px, calc(100% - 20px)); max-height: calc(100% - 20px); overflow: auto; color: inherit; background: #101a2bf7; border: 1px solid #ffffff33; border-radius: 14px; padding: 18px; }
dialog::backdrop { background: #0008; }
dialog > * { margin-bottom: 10px; }
.option-group { display: flex; flex-wrap: wrap; gap: 6px; }
#guide-step { color: #ffdd8b; font-size: 12px; }
#guide-copy { margin-top: 5px; }
input, textarea { font: inherit; color: inherit; background: #0a1220; border: 1px solid #ffffff44; border-radius: 8px; padding: 7px 10px; }
textarea { width: 100%; resize: vertical; }
#save-list { list-style: none; padding: 0; display: grid; gap: 6px; }
#save-list li { display: flex; gap: 8px; align-items: center; } #save-list span { flex: 1; overflow-wrap: anywhere; }
