:root {
  --win-gray: #c0c0c0;
  --win-gray-lt: #dfdfdf;
  --win-gray-dk: #808080;
  --win-gray-dk2: #000000;
  --title-a: #000080;
  --title-b: #1084d0;
  --title-inact-a: #808080;
  --title-inact-b: #b5b5b5;
  --sel-bg: #000080;
  --sel-fg: #ffffff;
  --text: #000000;
  --text-dim: #808080;
  --font-ui: Tahoma, "MS Sans Serif", Verdana, Geneva, "Segoe UI", sans-serif;
  --font-mono: "Lucida Console", "Courier New", monospace;
  --checker: repeating-conic-gradient(#e8e8e8 0% 25%, #ffffff 0% 50%) 0 0 / 16px 16px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  padding: 0;
  height: 100dvh;
  overflow: hidden;
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--text);
  background: var(--win-gray);
  -webkit-text-size-adjust: 100%;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.bevel-out {
  border: 1px solid;
  border-color: var(--win-gray-lt) var(--win-gray-dk2) var(--win-gray-dk2) var(--win-gray-lt);
  box-shadow: inset -1px -1px 0 var(--win-gray-dk), inset 1px 1px 0 #fff;
}

.bevel-in {
  border: 1px solid;
  border-color: var(--win-gray-dk) var(--win-gray-lt) var(--win-gray-lt) var(--win-gray-dk);
  box-shadow: inset 1px 1px 0 var(--win-gray-dk2), inset -1px -1px 0 #fff;
}

.window {
  width: 100%;
  height: 100dvh;
  max-width: none;
  background: var(--win-gray);
  padding: 2px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.titlebar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 3px 3px 4px;
  margin-bottom: 1px;
  background: linear-gradient(90deg, var(--title-b) 0%, var(--title-a) 60%);
  user-select: none;
}

.window.is-idle .titlebar {
  background: linear-gradient(90deg, var(--title-inact-b), var(--title-inact-a));
}

.titlebar__icon {
  width: 16px;
  height: 16px;
  flex: none;
  display: grid;
  place-items: center;
  background: var(--win-gray);
  font-size: 11px;
  font-weight: 700;
  color: var(--title-a);
}

.titlebar__text {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 700;
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, .45);
}

.titlebar__btns {
  display: flex;
  gap: 2px;
  flex: none;
}

.tb-btn {
  min-width: 16px;
  height: 14px;
  padding: 0 3px;
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  color: #000;
  background: var(--win-gray);
  border: 1px solid;
  cursor: pointer;
  border-color: var(--win-gray-lt) var(--win-gray-dk2) var(--win-gray-dk2) var(--win-gray-lt);
  box-shadow: inset -1px -1px 0 var(--win-gray-dk), inset 1px 1px 0 #fff;
}

.tb-btn:active {
  box-shadow: inset 1px 1px 0 var(--win-gray-dk2), inset -1px -1px 0 #fff;
  padding: 1px 2px 0 4px;
}

.tb-btn:focus-visible {
  outline: 1px dotted #000;
  outline-offset: -4px;
}

.tb-btn--close {
  font-size: 11px;
}

.tb-btn--back {
  width: 22px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 11px;
  text-decoration: none;
  color: #000;
}

.menubar {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  padding: 1px 0 2px;
  border-bottom: 1px solid var(--win-gray-lt);
  box-shadow: 0 1px 0 var(--win-gray-dk);
  position: relative;
  z-index: 30;
}

.menubar__item {
  position: relative;
  padding: 3px 8px;
  font-size: 12px;
  background: none;
  border: 0;
  font-family: var(--font-ui);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.menubar__item:disabled {
  color: var(--text-dim);
  text-shadow: 1px 1px 0 #fff;
  cursor: default;
}

.menubar__item[aria-expanded="true"],
.menubar__item:not(:disabled):hover {
  background: var(--sel-bg);
  color: var(--sel-fg);
}

.menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 210px;
  padding: 2px;
  background: var(--win-gray);
  z-index: 40;
  animation: menu-in .08s ease-out;
}

.menu[hidden] {
  display: none;
}

@keyframes menu-in {
  from {
    opacity: 0;
    transform: translateY(-3px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.menu__item {
  display: flex;
  width: 100%;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  font-family: var(--font-ui);
  font-size: 12px;
  text-align: left;
  color: var(--text);
  background: none;
  border: 0;
  cursor: pointer;
}

.menu__item:hover:not(:disabled) {
  background: var(--sel-bg);
  color: var(--sel-fg);
}

.menu__item:disabled {
  color: var(--text-dim);
  text-shadow: 1px 1px 0 #fff;
  cursor: default;
}

.menu__sep {
  height: 0;
  margin: 3px 2px;
  border-top: 1px solid var(--win-gray-dk);
  border-bottom: 1px solid #fff;
}

.menu__key {
  font-family: var(--font-mono);
  font-size: 10px;
  opacity: .75;
}

.client {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas: "tools stage";
  gap: 3px;
  padding: 2px 0 0;
  flex: 1 1 auto;
  min-height: 0;
}

.toolbox {
  grid-area: tools;
  width: 32px;
  padding: 3px;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.toolbox__group {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
}

.toolbox__sep {
  height: 2px;
  margin: 0;
  border-top: 1px solid var(--win-gray-dk);
  border-bottom: 1px solid #fff;
}

.tool {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  background: var(--win-gray);
  border: 1px solid;
  border-color: var(--win-gray-lt) var(--win-gray-dk2) var(--win-gray-dk2) var(--win-gray-lt);
  box-shadow: inset -1px -1px 0 var(--win-gray-dk);
  cursor: pointer;
  padding: 0;
}

.tool:hover {
  background: #c8c8c8;
}

.tool[aria-pressed="true"],
.tool-btn.active,
.tool:active {
  border: 1px inset #808080;
  background-color: #dfdfdf;
  box-shadow: none;
}

.tool:focus-visible {
  outline: 1px dotted #000;
  outline-offset: -3px;
}

.tool__glyph {
  width: 16px;
  height: 16px;
  display: block;
  image-rendering: pixelated;
}

.tool__glyph svg {
  display: block;
  width: 16px;
  height: 16px;
  shape-rendering: crispEdges;
}

.stage {
  grid-area: stage;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  min-height: 0;
}

.canvas-frame {
  position: relative;
  background: var(--checker);
  padding: 8px;
  display: grid;
  place-items: center;
  overflow: hidden;
  flex: 1 1 auto;
  min-height: 120px;
}

.canvas-frame.is-plain {
  background: #fff;
}

.canvas-frame.is-grid::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(to right, rgba(0, 0, 0, .16) 1px, transparent 1px), linear-gradient(to bottom, rgba(0, 0, 0, .16) 1px, transparent 1px);
  background-size: 24px 24px;
  z-index: 2;
}

#artwork {
  position: relative;
  z-index: 1;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  transition: opacity .12s linear;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, .25);
}

#artwork.is-loading {
  opacity: .35;
}

.art-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 2px 1px;
}

.art-meta__name {
  font-weight: 700;
}

.art-meta__tag {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 5px;
  background: var(--win-gray);
  border: 1px solid;
  border-color: var(--win-gray-lt) var(--win-gray-dk2) var(--win-gray-dk2) var(--win-gray-lt);
  color: var(--title-a);
  text-decoration: none;
  white-space: nowrap;
}

.art-meta__tag:hover {
  background: #b0b0b0;
}

.tray {
  padding: 2px;
}

.tray__label {
  font-size: 11px;
  color: var(--title-a);
  padding: 1px 2px 3px;
}

.tray__scroller {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px;
  scroll-behavior: smooth;
  scrollbar-color: var(--win-gray-lt) var(--win-gray);
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.tray__scroller::-webkit-scrollbar {
  height: 14px;
}

.tray__scroller::-webkit-scrollbar-track {
  background: var(--checker);
}

.tray__scroller::-webkit-scrollbar-thumb {
  background: var(--win-gray);
  border: 1px solid;
  border-color: var(--win-gray-lt) var(--win-gray-dk2) var(--win-gray-dk2) var(--win-gray-lt);
}

.thumb {
  flex: none;
  width: 74px;
  padding: 2px 2px 0;
  background: var(--win-gray);
  border: 1px solid;
  border-color: var(--win-gray-lt) var(--win-gray-dk2) var(--win-gray-dk2) var(--win-gray-lt);
  box-shadow: inset -1px -1px 0 var(--win-gray-dk);
  cursor: pointer;
  font-family: var(--font-ui);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.thumb__img {
  width: 100%;
  aspect-ratio: 1/1;
  object-fit: contain;
  background: var(--checker);
  box-shadow: inset 1px 1px 0 var(--win-gray-dk), inset -1px -1px 0 #fff;
  display: block;
}

.thumb__cap {
  font-size: 9px;
  line-height: 1.2;
  padding: 1px 0 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.thumb:hover {
  background: #c8c8c8;
}

.thumb[aria-current="true"] {
  background: var(--sel-bg);
  border-color: var(--win-gray-dk2) var(--win-gray-lt) var(--win-gray-lt) var(--win-gray-dk2);
  box-shadow: inset 1px 1px 0 var(--win-gray-dk2);
}

.thumb[aria-current="true"] .thumb__cap {
  color: #fff;
  font-weight: 700;
}

.thumb:focus-visible {
  outline: 1px dotted #000;
  outline-offset: -4px;
}

.palette {
  padding: 2px;
}

.palette__row {
  display: flex;
  gap: 1px;
  flex-wrap: wrap;
}

.swatch {
  width: 16px;
  height: 16px;
  padding: 0;
  border: 1px solid;
  border-color: var(--win-gray-lt) var(--win-gray-dk2) var(--win-gray-dk2) var(--win-gray-lt);
  cursor: pointer;
  flex: none;
}

.swatch:hover {
  outline: 1px dotted #000;
  outline-offset: 1px;
}

.swatch.is-active {
  box-shadow: inset 1px 1px 0 var(--win-gray-dk2), inset -1px -1px 0 #fff;
}

.swatch__fill {
  display: block;
  width: 100%;
  height: 100%;
}

.statusbar {
  display: flex;
  gap: 2px;
  padding: 2px;
  margin-top: 3px;
}

.statusbar__pane {
  flex: 1 1 0;
  min-width: 0;
  padding: 2px 4px;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.statusbar__pane--w {
  flex: 0 0 150px;
}

.statusbar__pane--h {
  flex: 0 0 78px;
}

.statusbar__pane--zoom {
  flex: 0 0 92px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.tray__scroller.is-square {
  display: grid;
  grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr));
  overflow-x: hidden;
  gap: 6px;
}

.tray__scroller.is-square .thumb {
  width: auto;
  aspect-ratio: 1/1;
  padding: 4px 4px 0;
  min-height: 0;
  overflow: hidden;
}

.tray__scroller.is-square .thumb__img {
  aspect-ratio: auto;
  height: auto;
  flex: 1 1 0;
  min-height: 0;
}

.tray__scroller.is-square .thumb__cap {
  font-size: 10px;
}

#embed-only {
  display: none;
}

html.is-embed body {
  padding: 0;
  background: #fff;
  display: block;
}

html.is-embed .window {
  display: none;
}

html.is-embed #embed-only {
  display: grid;
  place-items: center;
  min-height: 100vh;
}

html.is-embed #embed-art {
  width: min(100%, 512px);
  height: auto;
  display: block;
}

@media (max-width: 820px) {
  .client {
    grid-template-columns: 1fr;
    grid-template-areas: "tools" "stage";
  }

  .toolbox {
    width: auto;
    flex-direction: row;
    align-items: center;
    gap: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
  }

  .toolbox__group {
    display: flex;
    flex-direction: row;
    gap: 0;
  }

  .toolbox__sep {
    width: 2px;
    height: auto;
    margin: 0;
    border-top: 0;
    border-bottom: 0;
    border-left: 1px solid var(--win-gray-dk);
    border-right: 1px solid #fff;
  }

  .canvas-frame {
    min-height: 200px;
    padding: 6px;
  }

  #artwork {
    max-height: 52vh;
  }
}

@media (max-width: 560px) {
  body {
    height: auto;
    min-height: 100dvh;
    overflow: auto;
  }

  .window {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .client {
    flex: 0 0 auto;
  }

  .canvas-frame {
    flex: 0 0 auto;
    min-height: 240px;
  }

  #artwork {
    max-height: 50vh;
  }

  .toolbox {
    overflow-y: visible;
    overflow-x: auto;
  }

  .titlebar__text {
    font-size: 11px;
  }

  .thumb {
    width: 64px;
  }

  .tray__scroller.is-square .thumb {
    width: auto;
  }

  .statusbar__pane--h,
  .statusbar__pane--zoom {
    display: none;
  }
  .swatch {
    width: 15px;
    height: 15px;
  }
}

@media (max-width: 380px) {
  .thumb {
    width: 56px;
  }
}

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

@media (prefers-contrast: more) {
  :root {
    --win-gray: #d4d0c8;
  }
}
