/* Shared item & tile world editor. */
#world-editor {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: #05070a;
}

.we-root {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: min(76vh, 920px);
  min-height: 420px;
  background: #0b0d12;
  color: #e9e2cf;
  font: 13px/1.4 "Courier New", monospace;
  border: 1px solid #4b4438;
  box-sizing: border-box;
}

#world-editor .we-root {
  height: 100%;
  min-height: 0;
  border: 0;
}

.we-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid #343946;
  background: #12141a;
}

.we-title {
  color: #e6b84c;
  letter-spacing: 2px;
  margin-right: 8px;
}

.we-head label {
  display: flex;
  gap: 4px;
  align-items: center;
  color: #a99f8a;
}

.we-head select,
.we-head input,
.we-pane input,
.we-pane select {
  background: #0d1015;
  border: 1px solid #4b4438;
  color: #e9e2cf;
  font: inherit;
  padding: 4px 6px;
  min-width: 0;
}

.we-head button,
.we-tools button {
  background: #242936;
  border: 1px solid #4b4438;
  color: #e9e2cf;
  font: inherit;
  padding: 5px 9px;
  cursor: pointer;
}

.we-head button:hover,
.we-tools button:hover,
.we-tabs button:hover {
  border-color: #e6b84c;
  color: #e6b84c;
}

.we-head button.primary {
  background: #3a2d16;
  color: #ffe2a0;
  border-color: #8b6c2c;
}

.we-head button:disabled {
  opacity: .45;
  cursor: default;
}

.we-body {
  display: flex;
  gap: 8px;
  flex: 1;
  min-height: 0;
  padding: 8px;
  box-sizing: border-box;
}

.we-mapwrap {
  position: relative;
  flex: 1;
  overflow: auto;
  background: #080a0e;
  border: 1px solid #343946;
  min-width: 0;
}

#we-canvas {
  display: block;
  cursor: crosshair;
  image-rendering: pixelated;
  touch-action: none;
}

#we-overlay {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  image-rendering: pixelated;
}

.we-pane {
  width: min(380px, 42vw);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}

.we-tabs {
  display: flex;
  gap: 4px;
}

.we-tabs button {
  flex: 1;
  background: #1a1f29;
  border: 1px solid #4b4438;
  color: #e9e2cf;
  font: inherit;
  padding: 6px;
  cursor: pointer;
}

.we-tabs button.on {
  border-color: #e6b84c;
  color: #e6b84c;
}

.we-kindrow {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.we-kindrow label {
  display: flex;
  gap: 4px;
  align-items: center;
  color: #a99f8a;
}

.we-kindrow input {
  width: 64px;
}

.we-grid {
  flex: 1;
  min-height: 120px;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, 28px);
  gap: 2px;
  align-content: start;
  padding: 4px;
  background: #0b0d12;
  border: 1px solid #2b303b;
}

.we-cell {
  width: 28px;
  height: 28px;
  border: 1px solid #343946;
  background-color: #11151c;
  background-repeat: no-repeat;
  image-rendering: pixelated;
  cursor: pointer;
  padding: 0;
  color: #e9e2cf;
  font: bold 9px/1 "Courier New", monospace;
  display: flex;
  align-items: center;
  justify-content: center;
}

.we-cell:hover,
.we-cell.on {
  border-color: #e6b84c;
  box-shadow: 0 0 0 1px #e6b84c inset;
}

.we-artbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px;
  border: 1px solid #2b303b;
  background: #0d1015;
}

.we-artpreview {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border: 1px solid #343946;
  background: #11151c;
  image-rendering: pixelated;
}

.we-artinfo {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
  color: #a99f8a;
  font-size: 11px;
}

.we-artinfo span:first-child {
  color: #e9e2cf;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.we-artbar button {
  background: #242936;
  border: 1px solid #4b4438;
  color: #e9e2cf;
  font: inherit;
  padding: 5px 9px;
  cursor: pointer;
}

.we-artbar button:hover {
  border-color: #e6b84c;
  color: #e6b84c;
}

.we-artbar button:disabled {
  opacity: .45;
  cursor: default;
}

.we-artmodal {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(0, 0, 0, .72);
  box-sizing: border-box;
}

.we-artdialog {
  display: flex;
  flex-direction: column;
  width: min(760px, 100%);
  max-height: 100%;
  background: #0b0d12;
  border: 1px solid #4b4438;
  box-sizing: border-box;
}

.we-arthead,
.we-artmodes,
.we-artsheets,
.we-artactions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.we-arthead {
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid #343946;
  background: #12141a;
  color: #e6b84c;
}

.we-arthead button,
.we-artmodes button,
.we-artsheets button,
.we-artactions button,
.we-artside > button {
  background: #242936;
  border: 1px solid #4b4438;
  color: #e9e2cf;
  font: inherit;
  padding: 5px 9px;
  cursor: pointer;
}

.we-artmodes button.on,
.we-artsheets button.on {
  border-color: #e6b84c;
  color: #e6b84c;
}

.we-artactions button.primary {
  background: #3a2d16;
  color: #ffe2a0;
  border-color: #8b6c2c;
}

.we-artmodes {
  padding: 6px 10px 0;
}

.we-artbody {
  display: flex;
  gap: 8px;
  padding: 8px;
  min-height: 0;
  overflow: auto;
}

.we-artgridwrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
  min-height: 260px;
}

.we-artsheets {
  margin-bottom: 2px;
}

#we-art-grid {
  max-height: 420px;
}

.we-artside {
  width: 220px;
  flex: 0 0 220px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

#we-art-canvas {
  width: 160px;
  height: 160px;
  align-self: center;
  border: 1px solid #343946;
  background: #11151c;
  image-rendering: pixelated;
}

.we-artparts {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 230px;
  overflow: auto;
}

.we-partrow {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border: 1px solid #2b303b;
  background: #0d1015;
  color: #a99f8a;
  font-size: 11px;
  cursor: pointer;
}

.we-partrow.on {
  border-color: #e6b84c;
}

.we-partthumb {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border: 1px solid #343946;
  background: #11151c;
  background-repeat: no-repeat;
  image-rendering: pixelated;
}

.we-partrow label {
  display: flex;
  align-items: center;
  gap: 2px;
}

.we-partrow input {
  width: 44px;
}

.we-partrow button {
  margin-left: auto;
  background: #242936;
  border: 1px solid #4b4438;
  color: #e9e2cf;
  cursor: pointer;
}

.we-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.we-tools button.on {
  border-color: #e0554b;
  color: #ff9c92;
}

.we-status {
  color: #a99f8a;
  font-size: 11px;
  min-height: 30px;
}

.we-status.ok { color: #67c96b; }
.we-status.bad { color: #e0554b; }
.we-empty { color: #a99f8a; padding: 8px; grid-column: 1 / -1; }

@media (max-width: 760px) {
  .we-body { flex-direction: column; }
  .we-pane { width: 100%; max-height: 46%; }
  .we-mapwrap { min-height: 240px; }
  .we-root { height: 72vh; }
  .we-artbody { flex-direction: column; }
  .we-artside { width: 100%; flex: 0 0 auto; }
  #we-art-grid { max-height: 200px; }
}
