/* The save editor's own styles (edit.html), on top of style.css. */

/* One column: the summary, then the cards (the map's two-column layout is for its world view). */
body.editor main,
body.editor.loaded main {
  display: block;
  padding: 0 16px 96px;
}
.editor .intro {
  max-width: 900px;
}

/* The full map: MirkMap's own two-column world view, above the save bar. */
body.editor.loaded.map-mode main {
  display: grid;
  grid-template-columns: minmax(360px, 540px) minmax(0, 1fr);
  gap: 20px;
  padding: 14px 16px 96px;
  align-items: start;
}
@media (max-width: 980px) {
  body.editor.loaded.map-mode main {
    grid-template-columns: 1fr;
  }
}
.view-switch {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
}
.view-switch button {
  padding: 4px 10px;
  border: 0;
  background: none;
  color: var(--text);
  cursor: pointer;
}
.view-switch button + button {
  border-left: 1px solid var(--line);
}
.view-switch button:hover {
  color: var(--gold);
}
.view-switch button[aria-pressed="true"] {
  background: var(--gold2);
  color: #1b1516;
  font-weight: 600;
}
.view-switch button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: -2px;
}
.map-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 16px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.map-bar .edit-note {
  margin: 0;
}
/* The Move tool: the map's empty ground takes a click; marks keep their own cursor. */
body.map-move svg.map:not(.on-mark, .panning) {
  cursor: crosshair;
}
body.map-move .map-bar label {
  color: var(--gold);
}
.edit-summary {
  margin: 16px 0;
}
.edit-summary h2 {
  font-size: 18px;
}
.edit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
  align-items: start;
}
.edit-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
  min-width: 0;
}
.edit-card h3 {
  margin: 0 0 8px;
  font-size: 15px;
  color: var(--gold);
}
.edit-card h4 {
  margin: 14px 0 6px;
  font-size: 13px;
  color: var(--gold2);
}
.edit-card.edit-preview,
.edit-card.edit-map,
.edit-card.edit-items {
  grid-column: span 2;
}
@media (max-width: 720px) {
  .edit-card.edit-preview,
  .edit-card.edit-map,
  .edit-card.edit-items {
    grid-column: auto;
  }
}
/* The min and max a number input takes, beside it. */
.range-hint {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.range-hint:empty {
  display: none;
}
/* An on/off setting, such as Stunned: the box and its words. */
.edit-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 6px 0;
  cursor: pointer;
}
.edit-check input {
  accent-color: var(--gold2);
}
/* One of a few states (a hit point's Healthy, Lost or Burned), the current one lit. */
.segmented {
  display: inline-flex;
  margin: 4px 0 6px;
}
.segmented button {
  padding: 3px 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.segmented button + button {
  border-left: 0;
}
.segmented button:first-child {
  border-radius: 4px 0 0 4px;
}
.segmented button:last-child {
  border-radius: 0 4px 4px 0;
}
.segmented button:hover {
  background: var(--panel);
}
.segmented button[aria-pressed="true"] {
  background: var(--gold2);
  color: #120e0f;
}
.segmented button:focus-visible {
  position: relative;
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}
/* A vital bar to drag: an invisible slider laid over the bar, its thumb a handle on the fill. */
.vital-edit {
  position: relative;
}
.vital-slider {
  position: absolute;
  inset: -7px 0;
  width: 100%;
  height: calc(100% + 14px);
  margin: 0;
  background: transparent;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}
.vital-slider::-webkit-slider-runnable-track {
  height: 100%;
  background: transparent;
}
.vital-slider::-moz-range-track {
  height: 100%;
  background: transparent;
}
.vital-slider::-webkit-slider-thumb {
  width: 12px;
  height: 12px;
  margin-top: 1px;
  border: 2px solid #120e0f;
  border-radius: 50%;
  background: var(--gold);
  -webkit-appearance: none;
  appearance: none;
}
.vital-slider::-moz-range-thumb {
  width: 9px;
  height: 9px;
  border: 2px solid #120e0f;
  border-radius: 50%;
  background: var(--gold);
}
.vital-slider:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 4px;
}
.edit-field {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  margin: 6px 0;
}
.edit-field > span:first-child {
  flex: 0 0 128px;
  color: var(--text);
}
.edit-field input[type="range"] {
  flex: 1 1 140px;
  accent-color: var(--gold2);
}
.edit-field output {
  min-width: 9em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
/* Sliders keep their value beside them; on narrow cards the label goes above. */
.edit-field:has(input[type="range"]) > span:first-child {
  flex-basis: 100%;
}
.edit-field:has(input[type="range"]) output {
  min-width: 8em;
}
.edit-card input[type="number"],
.edit-card input[type="text"],
.edit-card input[type="time"] {
  padding: 3px 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
}
.edit-card .num {
  width: 6em;
}
.edit-card .item-name {
  flex: 1 1 200px;
  min-width: 0;
}
.coin-fields .edit-field > span:first-child {
  flex-basis: 60px;
}
.coin-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 0 16px;
}
.small {
  font-size: 12px;
}
.button.small {
  padding: 1px 6px;
  font-size: 12px;
}
.edit-note {
  margin: 10px 0 0;
  color: var(--gold);
}
.edit-note.error {
  color: #ff8a80;
}

.zone-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 52px));
  gap: 3px;
  margin-bottom: 8px;
}
.zone-button {
  padding: 3px 0;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--bg);
  cursor: pointer;
}
.zone-button:disabled {
  opacity: .35;
  cursor: not-allowed;
}
.zone-button.you {
  border-color: var(--gold2);
}
.zone-button.current {
  background: #3a2e30;
  color: var(--gold);
}
.map-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  margin-bottom: 8px;
}
.tool {
  white-space: nowrap;
}
.tool.disabled {
  opacity: .5;
}
.map-frame {
  max-width: 480px;
}
.edit-map {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  image-rendering: pixelated;
  border: 1px solid var(--line);
  border-radius: 3px;
  cursor: pointer;
}
.edit-map.tool-move,
.edit-map.tool-spawn {
  cursor: crosshair;
}
.map-caption {
  min-height: 1.4em;
  margin: 4px 0;
}
.selected-being {
  margin-top: 10px;
  padding: 8px;
  border: 1px solid var(--gold2);
  border-radius: 4px;
}
.selected-being h4 {
  margin-top: 0;
}
.being-list,
.backup-list {
  padding-left: 22px;
  margin: 6px 0;
}
.being-list li,
.backup-list li {
  margin: 4px 0;
}
.being-list li.selected > .link {
  color: var(--gold);
  font-weight: 600;
}
.carried {
  margin-top: 14px;
}
.carried summary {
  cursor: pointer;
  color: var(--gold2);
  font-size: 13px;
  font-weight: 600;
}
.carried ul {
  margin: 4px 0;
  padding-left: 18px;
}
.carried-list {
  max-height: 480px;
  overflow: hidden auto;
}
.carried li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 6px;
  margin: 3px 0;
}
.carried li > ul {
  flex-basis: 100%;
}
.carried-name {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--text);
}
.carried-controls {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  min-width: 0;
}
.carried-controls .button {
  flex: none;
  white-space: nowrap;
}
.carried .num {
  width: 4em;
}
.carried .move-to {
  flex: 0 1 15em;
  min-width: 7em;
  padding: 1px 4px;
  font-size: 12px;
}
/* Repair all, Refuel all and Dry all, above the list they change. */
.upkeep {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 4px;
}
.carried .item-condition {
  font-size: 12px;
}
.carried details.item-condition {
  margin: 2px 0 4px;
}
.carried details.item-condition summary {
  width: fit-content;
  color: var(--gold2);
  cursor: pointer;
}
.carried details.item-condition[open] {
  padding: 4px 8px;
  border-left: 2px solid var(--line);
}
.carried details.item-condition .edit-field > span:first-child {
  flex-basis: 96px;
}
.item-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Hit points as buttons (health.ts healthGridPicker): bigger cells to aim at, the picked one ringed in gold. */
.hp-picker {
  --hp-cell: 26px;
}
.hp-picker .hp-grid {
  gap: 6px;
}
.hp-pick {
  display: block;
  width: var(--hp-cell);
  height: var(--hp-cell);
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.hp-pick:hover .hp-cell {
  filter: brightness(1.2);
}
.hp-pick[aria-pressed="true"],
.hp-pick:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.hp-picked {
  margin: 8px 0;
  padding: 8px;
  border: 1px solid var(--gold2);
  border-radius: 4px;
}
.hp-picked h4 {
  margin-top: 0;
}
.edit-card select {
  padding: 2px 4px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
}

.savebar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 10px 16px;
  background: var(--glass-solid);
  border-top: 1px solid var(--gold2);
  z-index: 10;
}
.savebar summary {
  cursor: pointer;
  color: var(--gold);
}
.savebar ol {
  max-height: 30vh;
  overflow: auto;
  margin: 6px 0 0;
}
.savebar-actions {
  display: flex;
  gap: 8px;
}
/* Saving or restoring: nothing on the page can change the drafts until the files are written. */
body.busy main,
body.busy .savebar,
body.busy .map-bar,
body.busy .top {
  pointer-events: none;
  opacity: .6;
}

.disclosure {
  max-width: 620px;
  padding: 18px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--gold2);
  border-radius: 6px;
}
.disclosure::backdrop {
  background: rgba(0, 0, 0, .6);
}
.disclosure h2 {
  margin-bottom: 10px;
}
.disclosure li {
  margin: 6px 0;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 16px 0 0;
}
