html, body { overflow: hidden; height: 100%; }

#edApp {
  position: fixed; inset: 0; width: 100%; height: 100%; padding: 0; margin: 0;
  display: flex; flex-direction: column;
}
#edApp header {
  display: flex; align-items: center; gap: 16px; padding: 12px 18px; flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,0.11); background: #1c1d20;
}
#edApp header h1 { font-size: 20px; margin: 0; }

.editor-layout { flex: 1; min-height: 0; display: flex; }
#edStage {
  position: relative;
  flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: #17181b;
}
#edOverlay {
  position: absolute; top: 16px; right: 16px; display: none;
  padding: 8px 14px; border-radius: 8px; font-size: 14px; font-weight: 600;
  background: rgba(10,15,22,0.85); color: #6fd3a6; border: 1px solid rgba(255,255,255,0.11);
}
#edOverlay.show { display: block; }
#edit {
  background: #46b35a; border-radius: 8px; cursor: crosshair; display: block;
  box-shadow: 0 14px 50px rgba(0,0,0,0.5);
  touch-action: none;            /* paint with a finger instead of scrolling */
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  /* width/height set by fitEditor() */
}

#tools {
  width: 320px; flex-shrink: 0; height: 100%; overflow-y: auto;
  display: flex; flex-direction: column;
  border-left: 1px solid rgba(255,255,255,0.11); background: #1c1d20;
}
/* Tabs stay pinned while the pane scrolls; the status line pins to the bottom. */
#tools .tabs { position: sticky; top: 0; z-index: 2; margin: 12px 12px 0; box-shadow: 0 6px 12px #1c1d20; }
.tab-pane { display: flex; flex-direction: column; flex: 1; }
.tab-pane[hidden] { display: none; }
.sec { display: flex; flex-direction: column; gap: 10px; padding: 14px 14px 16px; border-bottom: 1px solid rgba(255,255,255,0.07); }
.sec:last-child { border-bottom: none; }
.sec-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px; color: #6b7078; }
.hint { font-size: 11.5px; color: #6b7078; line-height: 1.45; }
.btn-row { display: flex; gap: 8px; }
.btn-row > * { flex: 1; min-width: 0; }
#tools button { padding: 0 10px; font-size: 13px; height: 36px; }
#tools input:not([type="checkbox"]):not([type="radio"]), #tools select { height: 36px; font-size: 13px; padding: 0 10px; }
#tools .field { gap: 5px; }
#tools .field > span { font-size: 11.5px; }

/* Selected brush: big tile + name + what it does (tooltips don't exist on touch). */
.brush-card { display: flex; gap: 12px; align-items: flex-start; padding: 10px; background: #232428; border: 1px solid rgba(255,255,255,0.08); border-radius: 10px; }
.brush-icon canvas { width: 40px; height: 40px; border-radius: 6px; display: block; image-rendering: pixelated; border: 1px solid rgba(255,255,255,0.15); }
.brush-text { min-width: 0; }
.brush-name { font-size: 14px; font-weight: 600; }
.brush-help { font-size: 12px; color: #8a8f98; line-height: 1.4; margin-top: 2px; }

.row-label { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; color: #c9ccd1; }
.segmented.mini { padding: 3px; gap: 2px; border-radius: 8px; }
.segmented.mini label { padding: 4px 9px; font-size: 12px; }

/* Palette: grouped icon grid. */
#palette { display: flex; flex-direction: column; gap: 10px; }
.pal-group { display: flex; flex-direction: column; gap: 5px; }
.pal-name { font-size: 11px; color: #6b7078; }
.pal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(32px, 1fr)); gap: 4px; }
.swatch-btn {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center; padding: 2px;
  border-radius: 7px; background: #232428; cursor: pointer; border: 2px solid transparent;
}
#tools .swatch-btn { height: auto; padding: 2px; }
.swatch-btn:hover { background: #2e2f33; border-color: rgba(255,255,255,0.18); }
.swatch-btn.sel { border-color: #6fd3a6; background: #2a3a33; }
.swatch-btn:focus-visible { outline: 2px solid #6fd3a6; outline-offset: 1px; }
.swatch-btn .sw { width: 100%; height: 100%; border-radius: 4px; image-rendering: pixelated; }
.swatch-btn.glyph { font-size: 15px; color: #c9ccd1; }

.par-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #c9ccd1; }
.par-row > span { margin-right: auto; }
.stepper { display: flex; align-items: center; background: #232428; border: 1px solid rgba(255,255,255,0.10); border-radius: 8px; }
#tools .stepper button { width: 32px; height: 34px; padding: 0; border: none; background: none; font-size: 16px; }
#tools .stepper button:hover { color: #6fd3a6; }
#tools .stepper input { width: 34px; height: 34px; padding: 0; text-align: center; border: none; background: none; box-shadow: none; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* Local saves list */
.save-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.save-list:empty::before { content: 'Nothing saved yet.'; font-size: 12px; color: #5b5f66; padding: 4px 2px; }
.save-item { display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px 10px; border-radius: 8px; background: #232428; border: 1px solid transparent; }
.save-item.current { border-color: rgba(111,211,166,0.45); }
.save-item .meta { flex: 1; min-width: 0; }
.save-item .nm { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.save-item .sub { font-size: 11px; color: #6b7078; }
#tools .save-item button { height: 28px; padding: 0 9px; font-size: 12px; flex-shrink: 0; }
#tools .save-item button.del { width: 28px; padding: 0; color: #8a8f98; }
#tools .save-item button.del.armed { width: auto; padding: 0 9px; background: #4a2320; color: #ffb4a8; border-color: rgba(232,80,58,0.5); }

.switch-row { font-size: 13px; gap: 10px; }
.share-out { display: flex; gap: 6px; }
.share-out[hidden] { display: none; }
#tools .share-out input { color: #6fd3a6; font-size: 12px; }
#tools .share-out .icon-btn { width: 36px; height: 36px; }
.share-stale { font-size: 12px; line-height: 1.4; color: #e8a33a; }
.share-stale[hidden] { display: none; }
.unit { font-size: 11px; color: #6b7078; }
.route-key { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: #8a8f98; }
.route-key[hidden] { display: none; }
.route-key i { display: inline-block; width: 16px; height: 3px; border-radius: 2px; margin-right: 7px; vertical-align: middle; }
.k-typ { background: #fff04a; } .k-best { background: #39d0ff; }
.course-row select { flex: 1; min-width: 0; }

.tool-status {
  position: sticky; bottom: 0; margin-top: auto; padding: 10px 14px; min-height: 38px;
  font-size: 12.5px; color: #6fd3a6; background: #18191c; border-top: 1px solid rgba(255,255,255,0.08);
  overflow-wrap: anywhere;
}
.tool-status:empty { visibility: hidden; }

#holeNav { display: flex; align-items: center; gap: 8px; }
#holeNav button { padding: 5px 10px; }
#holeLabel { font-size: 14px; color: #8a8f98; min-width: 90px; text-align: center; }

/* ===== Narrow screens: stack the tool panel under the canvas ===== */
@media (max-width: 760px) {
  .editor-layout { flex-direction: column; }
  #edStage { padding: 10px; min-height: 46vh; }
  #tools {
    width: 100%; height: auto; max-height: 44vh; flex-shrink: 0;
    border-left: none; border-top: 1px solid rgba(255,255,255,0.11);
  }
  .pal-grid { grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); }
  #edApp header { flex-wrap: wrap; gap: 8px 12px; padding: 10px 12px; }
  #edApp header h1 { font-size: 17px; }
}
