.paint-window {
  left: clamp(118px, 15vw, 280px);
  top: clamp(58px, 9vh, 112px);
  width: min(1040px, 82vw);
  height: min(720px, calc(100vh - var(--taskbar-h) - 56px));
  min-width: 760px;
  min-height: 520px;
  z-index: 10;
}

.paint-window.is-active {
  z-index: 14;
}

.paint-shell {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) 23px;
  min-height: 0;
  height: 100%;
  color: #172a3b;
  background: #edf4fb;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  font-size: 12px;
}

.paint-menu {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 25px;
  padding: 1px 6px;
  background: linear-gradient(#fbfdff, #d8e9f7);
  border-bottom: 1px solid #aebfd1;
}

.paint-menu button,
.paint-ribbon button,
.paint-side-panel button {
  color: #17324b;
  font: inherit;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 2px;
}

.paint-menu button {
  min-height: 22px;
  padding: 2px 9px;
}

.paint-menu button:hover,
.paint-menu button:focus-visible,
.paint-ribbon button:hover,
.paint-ribbon button:focus-visible,
.paint-side-panel button:hover,
.paint-side-panel button:focus-visible {
  border-color: #82b4dc;
  background: linear-gradient(#ffffff, #def1fd 50%, #c1e2f5);
  outline: 0;
}

.paint-ribbon {
  display: flex;
  align-items: stretch;
  gap: 0;
  min-height: 105px;
  padding: 6px 7px 7px;
  overflow-x: auto;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .9), rgba(219, 235, 248, .82)),
    #dcecf8;
  border-bottom: 1px solid #9eb8cf;
  box-shadow: inset 0 1px 0 #fff;
}

.paint-ribbon-group {
  display: grid;
  align-content: start;
  gap: 5px;
  min-width: 96px;
  padding: 0 9px;
  border-right: 1px solid rgba(120, 151, 180, .45);
}

.paint-ribbon-group:last-child {
  border-right: 0;
}

.paint-big-button {
  display: grid;
  justify-items: center;
  gap: 2px;
  min-width: 58px;
  min-height: 62px;
  padding: 5px;
}

.paint-doc-icon {
  width: 30px;
  height: 34px;
  background:
    linear-gradient(135deg, transparent 0 8px, rgba(41, 102, 166, .26) 8px),
    linear-gradient(#ffffff, #d7e9f7);
  border: 1px solid #6f9bc2;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.8), 0 1px 2px rgba(45, 80, 110, .22);
}

.paint-tool-grid {
  display: grid;
  grid-template-columns: repeat(3, 56px);
  gap: 3px;
}

.paint-tool-grid button,
.paint-actions-row button,
.paint-side-panel button {
  min-height: 25px;
  padding: 3px 7px;
  background: linear-gradient(#fdfefe, #e6f0f8);
  border-color: #aabed0;
}

.paint-tool-grid button.is-active,
.paint-palette button.is-active {
  border-color: #2f87c6;
  background: linear-gradient(#dff3ff, #9dd2f2);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.88), 0 0 0 1px rgba(36, 119, 177, .22);
}

.paint-size-control {
  display: grid;
  grid-template-columns: 48px 112px 42px;
  gap: 7px;
  align-items: center;
  white-space: nowrap;
}

.paint-size-control input {
  width: 112px;
}

.paint-actions-row {
  display: flex;
  gap: 4px;
}

.paint-color-group {
  min-width: 250px;
}

.paint-current-colors {
  display: flex;
  align-items: center;
  gap: 8px;
}

.paint-current-colors > span {
  width: 34px;
  height: 34px;
  background: var(--paint-color);
  border: 1px solid #5d7893;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.65), 0 1px 2px rgba(0,0,0,.18);
}

.paint-current-colors label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.paint-current-colors input {
  width: 42px;
  height: 24px;
  padding: 0;
  border: 1px solid #8faabe;
  background: #fff;
}

.paint-palette {
  display: grid;
  grid-template-columns: repeat(6, 26px);
  gap: 4px;
}

.paint-palette button {
  width: 26px;
  height: 22px;
  padding: 0;
  background: var(--paint-color);
  border-color: #6d8398;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.38);
}

.paint-workspace {
  display: grid;
  grid-template-columns: 156px minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
  background:
    linear-gradient(90deg, #d7e5f1, #f5f9fd 156px, #c8d7e5 156px),
    #d6e3ef;
}

.paint-side-panel {
  display: grid;
  align-content: start;
  gap: 7px;
  min-width: 0;
  padding: 12px 9px;
  border-right: 1px solid #b5c9dc;
}

.paint-side-panel strong {
  color: #254b6d;
  font-size: 13px;
  font-weight: 600;
}

.paint-side-panel p {
  margin: 5px 0 0;
  color: #526d82;
  line-height: 1.35;
}

.paint-canvas-stage {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 18px;
  background:
    linear-gradient(45deg, rgba(120, 143, 162, .16) 25%, transparent 25% 75%, rgba(120, 143, 162, .16) 75%),
    linear-gradient(45deg, rgba(120, 143, 162, .16) 25%, transparent 25% 75%, rgba(120, 143, 162, .16) 75%),
    #b9c8d6;
  background-position: 0 0, 10px 10px;
  background-size: 20px 20px;
}

.paint-canvas-stage.is-plain {
  background: #b9c8d6;
}

.paint-canvas {
  display: block;
  width: 960px;
  height: 600px;
  max-width: none;
  background: #fff;
  border: 1px solid #7a8fa3;
  box-shadow:
    0 1px 0 rgba(255,255,255,.8),
    0 12px 28px rgba(59, 83, 106, .28);
  cursor: crosshair;
  touch-action: none;
}

.paint-canvas[data-paint-tool="eraser"] {
  cursor: cell;
}

.paint-statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  padding: 0 9px;
  color: #334d64;
  background: linear-gradient(#f7fbff, #dce9f5);
  border-top: 1px solid #b6c9da;
}

.paint-statusbar span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 899px), (max-height: 690px) {
  .paint-window {
    left: auto;
    right: auto;
    top: auto;
    bottom: auto;
    width: calc(100vw - 16px);
    min-width: 0;
    height: min(84vh, 760px);
  }

  .paint-shell {
    min-height: 650px;
  }

  .paint-ribbon {
    min-height: 0;
  }

  .paint-workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .paint-side-panel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border-right: 0;
    border-bottom: 1px solid #b5c9dc;
  }

  .paint-side-panel strong,
  .paint-side-panel p {
    display: none;
  }
}

@media (max-width: 620px) {
  .paint-tool-grid {
    grid-template-columns: repeat(2, 56px);
  }

  .paint-size-control {
    grid-template-columns: 1fr;
  }

  .paint-actions-row {
    flex-wrap: wrap;
  }
}
