* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: Tahoma, Verdana, sans-serif;
  font-size: 11px;
  background: #ece9d8;
  color: #000;
}

button, select, input { font: inherit; }
button { cursor: default; }

.paint-app {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #ece9d8;
  user-select: none;
}

.menubar {
  height: 25px;
  display: flex;
  align-items: stretch;
  flex: 0 0 auto;
  padding-left: 2px;
  border-bottom: 1px solid #aca899;
  background: #ece9d8;
  position: relative;
  z-index: 50;
}

.menu { position: relative; }
.menu-button {
  height: 24px;
  padding: 0 8px;
  border: 1px solid transparent;
  background: transparent;
  color: #000;
}
.menu-button:hover,
.menu.open > .menu-button {
  color: white;
  background: #316ac5;
  border-color: #316ac5;
}

.dropdown {
  display: none;
  position: absolute;
  top: 24px;
  left: 0;
  min-width: 210px;
  padding: 2px;
  background: #ece9d8;
  border: 1px solid #777;
  box-shadow: 2px 2px 4px rgba(0,0,0,.35);
}
.menu.open .dropdown { display: block; }
.dropdown button {
  width: 100%;
  height: 24px;
  padding: 0 8px 0 22px;
  border: 0;
  background: transparent;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.dropdown button:hover { background: #316ac5; color: white; }
.dropdown hr { border: 0; border-top: 1px solid #aaa; margin: 3px 2px; }

.paint-main {
  min-height: 0;
  flex: 1;
  display: flex;
  border-top: 1px solid white;
}

.toolbox {
  width: 92px;
  flex: 0 0 auto;
  padding: 5px;
  display: grid;
  grid-template-columns: repeat(2, 38px);
  align-content: start;
  gap: 3px;
  background: #ece9d8;
  border-right: 1px solid #aca899;
}

.tool {
  width: 38px;
  height: 34px;
  padding: 0;
  border: 1px solid #888;
  border-right-color: #fff;
  border-bottom-color: #fff;
  background: #ece9d8;
  font-size: 18px;
  line-height: 1;
}
.tool:hover { background: #f8f6ee; }
.tool.active {
  border-top-color: #555;
  border-left-color: #555;
  border-right-color: #fff;
  border-bottom-color: #fff;
  background: #d7e4f7;
  outline: 1px dotted #316ac5;
  outline-offset: -4px;
}

.tool-options {
  grid-column: 1 / -1;
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid #aca899;
}
.tool-options label { display: block; margin: 5px 0 2px; }
.tool-options select { width: 100%; height: 22px; }

.workspace {
  min-width: 0;
  min-height: 0;
  flex: 1;
  overflow: auto;
  padding: 8px;
  background: #7f7f7f;
}

.canvas-stage {
  position: relative;
  width: 640px;
  height: 480px;
  transform-origin: 0 0;
  background: white;
  box-shadow: 0 0 0 1px #444, 3px 3px 0 rgba(0,0,0,.15);
}

#paint-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: white;
  image-rendering: pixelated;
  touch-action: none;
  cursor: crosshair;
}

.pixel-grid {
  pointer-events: none;
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(0,0,0,.18) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0,0,0,.18) 1px, transparent 1px);
  background-size: var(--grid-size, 2px) var(--grid-size, 2px);
}
.hidden { display: none !important; }

.bottom-panel {
  min-height: 52px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 7px;
  background: #ece9d8;
  border-top: 1px solid white;
  border-bottom: 1px solid #aca899;
}

.current-colors {
  width: 50px;
  height: 38px;
  position: relative;
  flex: 0 0 auto;
  background: #c0c0c0;
  border: 1px inset #fff;
}
.primary-swatch,
.secondary-swatch {
  position: absolute;
  width: 25px;
  height: 25px;
  border: 1px solid #111;
}
.secondary-swatch { right: 5px; bottom: 4px; background: white; }
.primary-swatch { left: 5px; top: 4px; background: black; }

.palette {
  display: grid;
  grid-template-columns: repeat(14, 18px);
  grid-auto-rows: 18px;
  gap: 2px;
  align-content: center;
}
.color-cell {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 1px solid #555;
  box-shadow: inset 1px 1px white, inset -1px -1px #777;
}
.color-cell:hover { outline: 1px dotted #000; outline-offset: 1px; }
.local-note { margin-left: auto; color: #666; white-space: nowrap; }

.statusbar {
  height: 22px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  background: #ece9d8;
  color: #444;
}
.statusbar span {
  height: 18px;
  display: flex;
  align-items: center;
  padding: 0 7px;
  border-right: 1px solid #aca899;
}
#tool-status { flex: 1; }
#coord-status { width: 110px; justify-content: center; }
#size-status { width: 100px; justify-content: center; }

@media (max-width: 650px) {
  .toolbox { width: 80px; grid-template-columns: repeat(2, 32px); }
  .tool { width: 32px; }
  .palette { grid-template-columns: repeat(8, 18px); }
  .local-note { display: none; }
}
