.paint-app {
  background: #d7dbe1;
  color: #1f2937;
  font-family: "Segoe UI", "Manrope", "Inter", sans-serif;
  margin: 0;
  display: block;
}

.paint-app .site-header .container {
  width: 100%;
  max-width: none;
  padding: 0 16px;
}

.paint-app main {
  padding: 0;
  background: #e6e9ee;
}

.paint-main {
  min-height: calc(100vh - 74px);
  display: flex;
}

.paint-window {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 74px);
  background: #e6e9ee;
}

.paint-titlebar {
  height: 32px;
  background: #f7f7f7;
  border-bottom: 1px solid #cfd3d8;
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 10px;
}

.paint-title-input {
  flex: 1;
  text-align: center;
  font-size: 12px;
  color: #2f2f2f;
  letter-spacing: 0.2px;
  border: 1px solid transparent;
  background: transparent;
  padding: 2px 6px;
}

.paint-title-input:focus {
  outline: none;
  border-color: #9bb4d8;
  background: #ffffff;
  border-radius: 4px;
}

.paint-quickbar {
  display: flex;
  gap: 6px;
}

.quick-btn {
  border: 1px solid #bfc5cc;
  background: #ffffff;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.paint-tabs {
  height: 30px;
  background: #f2f2f2;
  border-bottom: 1px solid #cfd3d8;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 0 6px;
}

.paint-tab {
  border: 1px solid transparent;
  background: transparent;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #3b3b3b;
  cursor: pointer;
}

.paint-tab.active {
  background: #ffffff;
  border-color: #cfd3d8;
  border-bottom-color: #ffffff;
  border-radius: 4px 4px 0 0;
}

.file-tab {
  background: #2b7cd3;
  color: #ffffff;
  border-radius: 4px 4px 0 0;
  border-color: #2b7cd3;
}

.paint-ribbon {
  background: #f8f8f8;
  border-bottom: 1px solid #cfd3d8;
  display: flex;
  gap: 6px;
  padding: 6px 8px 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  align-items: stretch;
}

.ribbon-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 8px 2px;
  border-right: 1px solid #d0d4da;
  min-width: 130px;
}

.ribbon-group:last-child {
  border-right: none;
}

.ribbon-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.ribbon-row--palette {
  align-items: flex-start;
  gap: 12px;
  flex-wrap: nowrap;
}

.ribbon-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.ribbon-tools .ribbon-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.shapes-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
}

.ribbon-btn {
  border: 1px solid #c2c7cf;
  background: #ffffff;
  border-radius: 3px;
  padding: 4px 6px;
  font-size: 11px;
  font-weight: 600;
  color: #2b2b2b;
  cursor: pointer;
  min-width: 44px;
  text-align: center;
}

.ribbon-btn--big {
  min-width: 84px;
  padding: 10px 8px;
  font-size: 12px;
}

.ribbon-btn--quick {
  min-width: 64px;
  padding: 6px 10px;
  font-size: 12px;
  height: 30px;
}

.ribbon-btn--primary {
  background: #4b86d6;
  border-color: #3c73bf;
  color: #ffffff;
}

.ribbon-btn--primary:hover {
  background: #3c73bf;
}

.ribbon-btn--primary:active {
  background: #2f5fa1;
}

.ribbon-btn--icon {
  min-width: 34px;
  width: 34px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ribbon-icon {
  width: 18px;
  height: 18px;
  stroke: #1f2937;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  pointer-events: none;
}

.ribbon-btn--icon:hover .ribbon-icon {
  stroke: #0f172a;
}

.ribbon-btn:disabled,
.quick-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ribbon-btn.active {
  outline: 2px solid #4b86d6;
  outline-offset: -2px;
}

.tool-icon-btn {
  width: 38px;
  min-width: 38px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tool-icon {
  width: 23px;
  height: 23px;
  stroke: #1f2937;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  pointer-events: none;
}

.tool-icon-btn:hover .tool-icon {
  stroke: #0f172a;
}

.tool-icon--filled {
  fill: #1f2937;
}

.tool-icon--filled path {
  stroke: none;
}

.tool-icon-color {
  width: 23px;
  height: 23px;
  display: block;
  pointer-events: none;
}

.ribbon-label {
  font-size: 11px;
  color: #4b5563;
  font-weight: 600;
}

.ribbon-input {
  width: 60px;
  border: 1px solid #c2c7cf;
  border-radius: 3px;
  padding: 3px 6px;
  font-size: 11px;
}

.ribbon-select {
  border: 1px solid #c2c7cf;
  border-radius: 3px;
  padding: 3px 6px;
  font-size: 11px;
  background: #ffffff;
}

.ribbon-input--compact {
  width: 54px;
}

.ribbon-select--compact {
  width: 68px;
}

.ribbon-range {
  width: 110px;
  accent-color: #4b86d6;
}

.ribbon-title {
  font-size: 11px;
  color: #6b7280;
  text-align: center;
  margin-top: auto;
}

.size-picker {
  display: flex;
  align-items: center;
  gap: 6px;
}

.size-btn {
  width: 18px;
  height: 18px;
  border-radius: 3px;
  border: 1px solid #9aa1a9;
  background: #ffffff;
  position: relative;
  cursor: pointer;
}

.size-btn::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #1f2937;
  transform: translate(-50%, -50%);
}

.size-btn[data-size="4"]::after { width: 6px; height: 6px; }
.size-btn[data-size="8"]::after { width: 8px; height: 8px; }
.size-btn[data-size="12"]::after { width: 10px; height: 10px; }
.size-btn[data-size="16"]::after { width: 12px; height: 12px; }

.size-btn.active {
  outline: 2px solid #4b86d6;
  outline-offset: -2px;
}

.color-stack {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  flex-direction: column;
  justify-content: space-between;
  height: 68px;
}

.color-box {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.color-label {
  font-size: 10px;
  color: #4b5563;
  font-weight: 600;
  line-height: 1;
}

.color-sample {
  width: 20px;
  height: 20px;
  border: 1px solid #7b7b7b;
  background: #ffffff;
  cursor: pointer;
  position: relative;
}

.color-sample.is-transparent,
.color-chip--transparent {
  background-color: #ffffff;
  background-image:
    linear-gradient(45deg, #d1d5db 25%, transparent 25%, transparent 75%, #d1d5db 75%),
    linear-gradient(45deg, #d1d5db 25%, transparent 25%, transparent 75%, #d1d5db 75%);
  background-position: 0 0, 5px 5px;
  background-size: 10px 10px;
}

.color-sample.is-transparent::after,
.color-chip--transparent::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 44%, #ef4444 44%, #ef4444 56%, transparent 56%);
  pointer-events: none;
}

.ribbon-btn--compact {
  min-width: 86px;
  height: 26px;
  padding: 4px 8px;
}

.ribbon-row--palette > .ribbon-btn--compact {
  align-self: center;
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(10, 16px);
  gap: 4px;
}

.palette-column {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.color-chip {
  width: 16px;
  height: 16px;
  border: 1px solid #8a8a8a;
  cursor: pointer;
  position: relative;
}

.paint-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #dfe3ea;
}

.canvas-stage {
  flex: 1;
  overflow: auto;
  padding: 0;
  background: #dfe3ea;
}

.canvas-wrap {
  position: relative;
  background: #ffffff;
  border: 1px solid #bcc2c9;
  box-shadow: 0 2px 4px rgba(31, 41, 55, 0.2);
  overflow: hidden;
}

#paint-canvas {
  display: block;
  background: #ffffff;
  cursor: crosshair;
}

.overlay-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.selection-box {
  position: absolute;
  border: 1px dashed #4b86d6;
  background: rgba(75, 134, 214, 0.12);
  display: none;
}

.selection-layer {
  position: absolute;
  border: 1px dashed #4b86d6;
  background: rgba(255, 255, 255, 0.8);
  display: none;
  pointer-events: auto;
  z-index: 3;
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.18);
}

.selection-layer canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.selection-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #ffffff;
  border: 1px solid #4b86d6;
  box-shadow: 0 2px 4px rgba(31, 41, 55, 0.2);
  pointer-events: auto;
  z-index: 2;
}

.selection-rotate {
  position: absolute;
  left: 50%;
  top: -26px;
  width: 14px;
  height: 14px;
  background: #ffffff;
  border: 1px solid #4b86d6;
  border-radius: 50%;
  transform: translateX(-50%);
  box-shadow: 0 2px 4px rgba(31, 41, 55, 0.2);
  pointer-events: auto;
  cursor: grab;
  z-index: 3;
}

.selection-rotate::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 14px;
  width: 1px;
  height: 10px;
  background: #4b86d6;
  transform: translateX(-50%);
}

.image-layer {
  position: absolute;
  border: 2px solid #f97316;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.24), 0 2px 6px rgba(15, 23, 42, 0.18);
  display: none;
  cursor: grab;
  pointer-events: auto;
  box-sizing: border-box;
  z-index: 4;
}

.image-layer:active {
  cursor: grabbing;
}

.image-layer img {
  width: 100%;
  height: 100%;
  display: block;
}

.image-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #ffffff;
  border: 1px solid #f97316;
  box-shadow: 0 2px 6px rgba(31, 41, 55, 0.3);
  pointer-events: auto;
}

.handle-nw { top: -6px; left: -6px; cursor: nwse-resize; }
.handle-ne { top: -6px; right: -6px; cursor: nesw-resize; }
.handle-sw { bottom: -6px; left: -6px; cursor: nesw-resize; }
.handle-se { bottom: -6px; right: -6px; cursor: nwse-resize; }
.handle-n { top: -6px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.handle-s { bottom: -6px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.handle-e { right: -6px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }
.handle-w { left: -6px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }

.text-entry {
  position: absolute;
  min-width: 160px;
  min-height: 38px;
  border: 1px solid #4b86d6;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.95);
  color: #111827;
  display: none;
  resize: both;
  pointer-events: auto;
  z-index: 5;
}

.status-bar {
  height: 28px;
  border-top: 1px solid #cfd3d8;
  background: #f2f2f2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  font-size: 12px;
  color: #4b5563;
}

.status-left {
  display: flex;
  gap: 16px;
  align-items: center;
}

.zoom-control {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
}

.zoom-pill {
  font-size: 12px;
  font-weight: 700;
  color: #1f2937;
  background: #ffffff;
  border: 1px solid #c2c7cf;
  border-radius: 4px;
  padding: 2px 6px;
}

@media (max-width: 1100px) {
  .paint-ribbon {
    gap: 6px;
  }

  .ribbon-group {
    min-width: 120px;
  }

  .shapes-grid {
    grid-template-columns: repeat(8, minmax(0, 1fr));
  }

  .ribbon-tools .ribbon-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .paint-title-input {
    display: none;
  }

  .paint-main,
  .paint-window {
    min-height: 100vh;
  }

  .ribbon-group {
    min-width: 120px;
    border-right: 1px solid #d0d4da;
    border-bottom: none;
    padding-bottom: 2px;
  }

  .ribbon-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .shapes-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .palette-grid {
    grid-template-columns: repeat(10, 14px);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto;
  }
}
