/* ---------------------------------------------------------------------------
   Application layout: the three panes, the editor, and the bank browser.
   ------------------------------------------------------------------------ */

.desktop {
  display: grid;
  grid-template-columns: 118px minmax(360px, 1fr) 330px;
  align-items: start;
  gap: 12px;
  padding: 12px;
  min-height: calc(100vh - 42px);
}

@media (max-width: 1180px) {
  .desktop {
    grid-template-columns: 118px minmax(0, 1fr);
  }

  .desktop > .window--bank {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .desktop {
    grid-template-columns: minmax(0, 1fr);
    padding: 8px;
  }

  .desktop > .window--tools {
    grid-column: 1 / -1;
  }
}

/* ----------------------------------------------------------- tool palette */

.toolbox {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  border: var(--line);
  background: var(--ink);
}

.toolbox__button {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  padding: 0;
  background: var(--paper);
  border: 0;
  cursor: pointer;
}

.toolbox__button canvas {
  width: 24px;
  height: 24px;
}

.toolbox__button[aria-pressed='true'] {
  background: var(--ink);
}

.toolbox__button[aria-pressed='true'] canvas {
  filter: invert(1);
}

.swatches {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  border: var(--line);
  background: var(--ink);
}

.swatches__button {
  padding: 0;
  aspect-ratio: 1;
  border: 0;
  background: var(--paper);
  cursor: pointer;
}

.swatches__button canvas {
  width: 100%;
  height: 100%;
}

.swatches__button[aria-pressed='true'] {
  outline: 2px solid var(--ink);
  outline-offset: -2px;
}

.palette__label {
  font-size: var(--size-small);
  font-weight: 700;
  margin: 8px 0 3px;
}

.palette__options {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: var(--size-small);
}

/* ----------------------------------------------------------------- editor */

.editor {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.editor__frame {
  border: var(--line);
  box-shadow: var(--drop);
  background: var(--paper);
  line-height: 0;
  touch-action: none;
}

.editor__canvas {
  cursor: crosshair;
  touch-action: none;
}

.editor__canvas[data-tool='marquee'] {
  cursor: cell;
}

.previews {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  padding-top: 4px;
  border-top: var(--line);
  width: 100%;
  justify-content: center;
  flex-wrap: wrap;
}

.preview {
  display: grid;
  justify-items: center;
  gap: 3px;
  font-size: var(--size-small);
}

.preview canvas {
  border: var(--line);
  background: var(--paper);
}

.preview--invert canvas {
  background: var(--ink);
}

/* ----------------------------------------------------------- bank browser */

.bank__bar {
  display: flex;
  gap: 4px;
  align-items: center;
  padding-bottom: 6px;
}

.bank__bar select {
  flex: 1 1 auto;
  min-width: 0;
}

.bank__search {
  width: 100%;
  margin-bottom: 6px;
}

.bank__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(62px, 1fr));
  gap: 2px;
  align-content: start;
  max-height: 42vh;
  min-height: 120px;
  padding: 4px;
  border: var(--line);
  background: var(--paper);
}

.tile {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 4px 2px 3px;
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  overflow: hidden;
}

.tile canvas {
  width: 32px;
  height: 32px;
  border: var(--line);
  background: var(--paper);
}

.tile__name {
  max-width: 100%;
  font-size: var(--size-small);
  line-height: 1.1;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 2px;
}

.tile[aria-selected='true'] {
  background: var(--ink);
  color: var(--paper);
}

.tile[aria-selected='true'] canvas {
  filter: invert(1);
  border-color: var(--paper);
}

.bank__empty {
  grid-column: 1 / -1;
  padding: 24px 8px;
  text-align: center;
  color: var(--dim);
  font-size: var(--size-small);
}

/* -------------------------------------------------------------- inspector */

.inspector {
  display: grid;
  gap: 6px;
  padding-top: 8px;
  margin-top: 8px;
  border-top: var(--line);
}

.inspector__facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1px 10px;
  font-size: var(--size-small);
}

.inspector__facts dt {
  font-weight: 700;
}

.inspector__facts dd {
  margin: 0;
}

/* -------------------------------------------------------- dialog specifics */

.export-preview {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 8px;
  border: var(--line);
  background-color: var(--paper);
  background-image: var(--dither-12);
  background-size: 4px 4px;
}

.export-preview canvas {
  border: var(--line);
  background: var(--paper);
}

.form-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px 10px;
}

.form-grid > .full {
  grid-column: 1 / -1;
}

.shortcuts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 4px 24px;
  font-size: var(--size-small);
}

.shortcuts h3 {
  grid-column: 1 / -1;
  margin-top: 8px;
  font-size: var(--size-small);
  border-bottom: var(--line);
}

.shortcuts dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1px 12px;
  margin: 0;
}

.shortcuts dd {
  margin: 0;
  font-family: var(--font-mono);
}

.about {
  display: grid;
  justify-items: center;
  gap: 10px;
  text-align: center;
  max-width: 380px;
}

.about canvas {
  border: var(--line);
}

.about h2 {
  font-size: 18px;
}

/* A grid centres its children on their own width; the divider wants the lot. */
.about .rule {
  width: 100%;
  margin: 2px 0;
}

.about__credit {
  font-weight: 700;
}
