/* Visual preset editor */
button:focus-visible, a:focus-visible, input:focus-visible, summary:focus-visible { outline: 3px solid rgba(241,178,74,.5); outline-offset: 2px; }
.editor-heading { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; }
.editor-heading .eyebrow { margin:0 0 5px; }
.icon-close { width:40px; height:40px; padding:0; font-size:25px; line-height:1; }
.name-field { margin-top:16px; }
.builder { margin-top:22px; }
.builder h3 { margin:20px 0 8px; font:600 1rem 'Space Grotesk',sans-serif; }
.builder .hint { margin:0 0 14px; line-height:1.45; }
#build-json-import { margin:12px 0 18px; padding:10px 12px; border:1px solid var(--line); border-radius:5px; background:#202e28; }
#build-json-import summary { cursor:pointer; color:var(--accent); font-weight:700; }
#build-json-import textarea { display:block; width:100%; box-sizing:border-box; margin:10px 0; padding:10px; border:1px solid var(--line); border-radius:4px; background:#101816; color:var(--ink); font:12px/1.5 ui-monospace,Consolas,monospace; resize:vertical; }
#import-build-json { min-height:40px; }
.icon-picker { display:grid; grid-template-columns:repeat(auto-fill,minmax(98px,1fr)); gap:8px; }
.building-choice { display:grid; justify-items:center; align-content:center; gap:7px; min-height:84px; padding:8px 5px; background:#202e28; color:var(--ink); border-color:var(--line); font-size:12px; text-align:center; }
.building-choice:hover { border-color:var(--accent); background:#293b33; }
.building-choice img, .build-step img { width:28px; height:28px; object-fit:contain; }
.building-choice img[hidden], .build-step img[hidden], .unit-name img[hidden] { display:none; }
.sequence-title { display:flex; justify-content:space-between; align-items:center; gap:10px; }
.sequence-title span { color:var(--muted); font:500 12px 'DM Sans',sans-serif; }
.build-sequence { display:grid; gap:7px; margin:10px 0 0; padding:0; list-style:none; counter-reset:steps; }
.build-step { display:grid; grid-template-columns:26px 30px 32px minmax(80px,1fr) 76px 38px 38px 38px; align-items:center; gap:8px; padding:8px; border:1px solid var(--line); border-radius:5px; background:#202e28; counter-increment:steps; }
.build-step::before { content:counter(steps); color:var(--muted); font:700 12px monospace; text-align:center; }
.step-drag-handle { width:30px; min-height:38px; padding:0; cursor:grab; font-size:23px; user-select:none; }
.step-drag-handle:active { cursor:grabbing; }
.build-step.dragging { opacity:.45; }
.build-step.drop-before { box-shadow:0 -3px 0 var(--accent); }
.build-step.drop-after { box-shadow:0 3px 0 var(--accent); }
.build-step strong { min-width:0; font-size:13px; }
.level-field { display:grid; gap:3px; margin:0; font-size:11px; }
.level-field input { padding:8px 5px; text-align:center; }
.step-action { width:38px; min-height:38px; padding:0; }
.step-action:disabled { opacity:.35; cursor:default; }
.remove-step { border-color:var(--danger); background:transparent; color:var(--danger); font-size:23px; }
.remove-step:hover { background:var(--danger); color:#1a1d17; }
.unit-targets { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
.unit-target-row { display:grid; grid-template-columns:minmax(0,1fr) 110px; align-items:center; gap:10px; min-width:0; margin:0; padding:9px 10px; border:1px solid var(--line); border-radius:5px; background:#202e28; }
.unit-name { display:flex; align-items:center; gap:9px; min-width:0; color:var(--ink); font-size:13px; }
.unit-name img { width:24px; height:24px; flex:0 0 24px; object-fit:contain; }
.unit-target-row input { padding:10px 8px; text-align:right; font-variant-numeric:tabular-nums; }
.json-preview { margin-top:18px; border-top:1px solid var(--line); padding-top:12px; color:var(--muted); font-size:13px; }
.json-preview summary { cursor:pointer; }
.json-preview pre { max-height:180px; overflow:auto; padding:10px; border:1px solid var(--line); border-radius:4px; background:#101816; color:var(--ink); font:12px/1.5 ui-monospace,Consolas,monospace; }
#editor { max-height:min(92dvh,900px); overflow:auto; overscroll-behavior:contain; }
#preset-form { padding:6px; }
#preset-form .actions { position:sticky; bottom:-1px; margin:16px -6px -6px; padding:12px 6px 6px; background:var(--panel); }
.actions button { min-height:44px; }
@media (max-width:700px) {
  .shell { width:calc(100% - 24px); padding:20px 0 calc(30px + env(safe-area-inset-bottom)); }
  header { flex-direction:row; align-items:center; gap:10px; padding-bottom:16px; }
  header > a { padding:9px 10px; font-size:12px; white-space:nowrap; }
  .grid { gap:12px; }
  .panel { padding:15px; }
  .panel-head { gap:8px; }
  .panel-head button { min-height:42px; }
  .preset-row { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:8px; }
  .preset-row strong { grid-column:1; }
  .preset-row span { grid-column:1; }
  .preset-row button { min-height:42px; }
  dialog { width:100%; max-width:none; max-height:100dvh; height:100dvh; margin:0; border-radius:0; padding:16px max(16px, env(safe-area-inset-left)) calc(12px + env(safe-area-inset-bottom)); }
  dialog::backdrop { background:var(--bg); }
  #preset-form { padding:0; }
  #preset-form .actions { bottom:calc(-12px - env(safe-area-inset-bottom)); margin:14px 0 calc(-12px - env(safe-area-inset-bottom)); padding:10px 0 calc(12px + env(safe-area-inset-bottom)); }
  .actions { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
  .icon-picker { grid-template-columns:repeat(4,minmax(0,1fr)); gap:6px; }
  .building-choice { min-height:76px; padding:7px 3px; font-size:10px; }
  .building-choice img { width:26px; height:26px; }
  .build-step { grid-template-columns:20px 30px minmax(0,1fr) 58px 34px 34px 34px; gap:4px; padding:6px 4px; }
  .build-step img { display:none; }
  .build-step .step-action { width:34px; }
  .build-step strong { font-size:11px; }
  .level-field { font-size:10px; }
  .unit-targets { grid-template-columns:1fr; gap:6px; }
  .unit-target-row { grid-template-columns:minmax(0,1fr) minmax(90px,120px); min-height:52px; }
}
@media (max-width:360px) {
  .icon-picker { grid-template-columns:repeat(3,minmax(0,1fr)); }
  .build-step { grid-template-columns:18px 26px minmax(0,1fr) 48px 30px 30px 30px; gap:3px; }
  .build-step .step-action, .step-drag-handle { width:26px; }
  .step-action { width:34px; min-height:36px; }
}
