.md-tool { display: grid; gap: 1rem; }
.md-toolbar { display: grid; gap: 1rem; padding: 1.15rem 1rem; border: 4px solid #1a120c; background: var(--surface); box-shadow: 5px 5px 0 #000; }
@media (min-width: 700px) { .md-toolbar { grid-template-columns: 1.4fr auto auto; align-items: end; } }
.md-toolbar__actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.md-sizes { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.md-size { font-family: var(--font-pixel); font-size: 0.8rem; font-weight: 600; padding: 0.45rem 0.55rem; border: 2px solid #1a120c; background: #243028; color: #fff; cursor: pointer; }
.md-size.is-active { background: linear-gradient(180deg, #5ecf6a, #2d7a38); color: #06140c; }
.md-hint { margin: 0; color: var(--muted); font-size: 0.9rem; }
.md-workspace { display: grid; gap: 1rem; }
@media (min-width: 900px) { .md-workspace { grid-template-columns: 1.2fr 1fr; align-items: start; } }
.md-panel { padding: 1rem; border: 4px solid #1a120c; background: var(--surface); box-shadow: 5px 5px 0 #000; }
.md-chest { border: 3px solid #1a120c; background: #2a1e14; }
.md-chest__bar { padding: 0.55rem 0.75rem; font-family: var(--font-pixel); font-size: 0.85rem; font-weight: 600; color: #f0e6c8; background: #3a2a1c; border-bottom: 3px solid #1a120c; line-height: 1.4; }
.md-chest__grid { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 3px; padding: 0.5rem; background: #1a120c; }
.md-slot-wrap {
  position: relative;
  min-width: 0;
}
.md-slot {
  width: 100%;
  aspect-ratio: 1;
  border: 2px solid #0d0a07;
  background: #8b6b3d;
  cursor: pointer;
  padding: 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 0;
}
.md-slot.is-filled { background: #6e5430; }
.md-slot__remove {
  position: absolute;
  top: 1px;
  right: 1px;
  z-index: 2;
  width: 1.15rem;
  height: 1.15rem;
  padding: 0;
  border: 1px solid #1a120c;
  background: #c43c3c;
  color: #fff;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.md-slot__remove:hover {
  background: #e04a4a;
}
.md-slot__icon,
.md-icon {
  width: 58%;
  height: 58%;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border: none;
  background: transparent;
}
.md-icon--missing {
  width: 58%;
  height: 58%;
  background:
    linear-gradient(45deg, #f800f8 25%, #000 25%, #000 50%, #f800f8 50%, #f800f8 75%, #000 75%);
  background-size: 8px 8px;
  border: 1px solid #111;
}
.md-slot__label {
  font-size: 0.55rem;
  color: #1a120c;
  overflow: hidden;
  max-width: 100%;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.md-brush { margin: 0.35rem 0; min-height: 1.2em; color: var(--accent-bright); font-size: 0.85rem; }
.md-palette {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8.2rem, 1fr));
  gap: 0.4rem;
  max-height: min(70vh, 36rem);
  overflow: auto;
  align-content: start;
}
.md-palette__status {
  grid-column: 1 / -1;
  margin: 0 0 0.15rem;
  color: var(--muted);
  font-size: 0.8rem;
}
.md-palette__item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem;
  border: 2px solid #1a120c;
  background: #243028;
  color: #fff;
  cursor: pointer;
  font-size: 0.75rem;
  text-align: left;
  min-height: 2.4rem;
}
.md-palette__item.is-selected { outline: 2px solid var(--accent-bright); }
.md-palette__icon {
  width: 1.45rem;
  height: 1.45rem;
  flex-shrink: 0;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #1a120c;
}
.md-palette__icon.md-icon--missing {
  width: 1.45rem;
  height: 1.45rem;
}
.md-palette__text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.md-picker { border: none; padding: 0; background: transparent; max-width: 32rem; width: calc(100% - 2rem); }
.md-picker::backdrop { background: rgba(0, 0, 0, .65); }
.md-picker__inner {
  border: 4px solid #1a120c;
  background: var(--surface);
  box-shadow: 6px 6px 0 #000;
  padding: 0.85rem;
  display: grid;
  gap: 0.65rem;
}
.md-picker__head { display: flex; justify-content: space-between; align-items: center; }
.md-picker__head h3 { margin: 0; font-family: var(--font-pixel); font-size: 0.95rem; font-weight: 700; line-height: 1.4; }
.md-picker__close {
  border: 2px solid #1a120c;
  background: #3a2a1c;
  color: #fff;
  width: 2rem;
  height: 2rem;
  cursor: pointer;
  font-size: 1.2rem;
}
.md-picker__list {
  max-height: min(60vh, 24rem);
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
  gap: 0.35rem;
  align-content: start;
}
.md-back { margin: 1.5rem 0 0; }
.md-yaml__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.md-yaml__note {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}
.md-yaml__editor {
  min-height: 16rem;
  resize: vertical;
}
@media (max-width: 520px) { .md-slot__label { display: none; } }
