* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  min-height: 100%;
  background: #090909;
  font-family: Arial, Helvetica, sans-serif;
  overflow: hidden;
}

.cah-draw-app {
  width: 100vw;
  height: 100vh;
  color: #f7f4ed;
  background: linear-gradient(180deg, #111 0%, #050505 100%);
  overflow: hidden;
}

.cah-draw-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

button,
select,
input,
textarea {
  font-family: Arial, Helvetica, sans-serif;
}

button {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.015)),
    rgba(18, 18, 18, 0.72);
  color: #f7f4ed;
  border-radius: 4px;
  padding: 5px 7px;
  font-weight: 800;
  font-size: 9px;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 5px 14px rgba(0, 0, 0, 0.16);
}

button:hover {
  border-color: rgba(105, 151, 240, 0.38);
  background:
    linear-gradient(180deg, rgba(105, 151, 240, 0.14), rgba(255, 255, 255, 0.025)),
    rgba(22, 22, 22, 0.92);
}

button:active {
  transform: scale(0.98);
}

button.active {
  background:
    linear-gradient(180deg, rgba(81, 130, 226, 0.88), rgba(43, 78, 154, 0.88)),
    rgba(25, 25, 25, 0.9);
  color: #f7faff;
  border-color: rgba(105, 151, 240, 0.78);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.cah-canvas-area {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  background:
    linear-gradient(45deg, rgba(255,255,255,0.025) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255,255,255,0.025) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255,255,255,0.025) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255,255,255,0.025) 75%),
    #1b1b1b;
  background-size: 26px 26px;
  background-position: 0 0, 0 13px, 13px -13px, -13px 0;
  touch-action: none;
}

.cah-canvas-viewport {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
}

.cah-canvas-stage {
  position: absolute;
  left: 0;
  top: 0;
  width: 1920px;
  height: 1080px;
  background: #fffaf4;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.14),
    0 0 0 8px rgba(0, 0, 0, 0.18),
    0 28px 95px rgba(0, 0, 0, 0.62);
  transform-origin: 0 0;
  will-change: transform;
}

.cah-layer-stack {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.cah-layer-stack.pan-active,
.cah-canvas-stage.pan-active {
  cursor: grab;
}

.cah-layer-stack.pan-dragging,
.cah-canvas-stage.pan-dragging {
  cursor: grabbing;
}

.cah-layer-stack canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.cah-panel {
  position: absolute;
  z-index: 24;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.095);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.065), rgba(255, 255, 255, 0.018)),
    rgba(18, 18, 18, 0.74);
  backdrop-filter: blur(20px) saturate(1.12);
  box-shadow:
    0 16px 44px rgba(0, 0, 0, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

.cah-panel.is-moving,
.cah-nav-gizmo.is-moving {
  outline: 2px solid rgba(105, 151, 240, 0.72);
}

.cah-panel-min {
  position: absolute;
  z-index: 6;
  top: 6px;
  right: 6px;
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 4px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.78);
  background: rgba(0, 0, 0, 0.36);
  box-shadow: none;
}

.cah-panel-title {
  color: rgba(247, 244, 237, 0.82);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 5px;
  padding-right: 24px;
}

.cah-panel-content {
  width: 100%;
}

.cah-topbar {
  top: 10px;
  left: 58px;
  right: 58px;
  width: auto;
  min-height: 48px;
  padding: 7px 34px 7px 12px;
  transform: none;
}

.cah-topbar-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.cah-brand-block {
  min-width: 130px;
}

.cah-kicker {
  color: rgba(160, 188, 245, 0.94);
  font-size: 7px;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 3px;
  opacity: 0.95;
}

.cah-floating-header h1,
.cah-submit-modal-card h2 {
  margin: 0;
  font-size: clamp(16px, 2.2vw, 21px);
  line-height: 1;
  letter-spacing: 0.02em;
}

.cah-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.cah-header-actions button {
  padding: 6px 7px;
  min-width: 58px;
}

.cah-submit-top-btn {
  background:
    linear-gradient(180deg, rgba(81, 130, 226, 0.92), rgba(43, 78, 154, 0.92)),
    rgba(20, 20, 20, 0.9);
  color: #f7faff;
  border-color: rgba(105, 151, 240, 0.78);
}

.cah-ui-toggle {
  position: absolute;
  z-index: 120;
  top: 18px;
  right: 16px;
  border-radius: 999px;
  border-color: rgba(105, 151, 240, 0.28);
  background:
    linear-gradient(180deg, rgba(105, 151, 240, 0.18), rgba(255, 255, 255, 0.04)),
    rgba(10, 10, 10, 0.82);
  backdrop-filter: blur(14px);
}

.cah-left-rail {
  left: 10px;
  top: 70px;
  width: 174px;
  padding: 10px 32px 10px 10px;
}

.cah-tool-button-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
  margin-bottom: 6px;
}

.cah-right-panel {
  right: 10px;
  width: 226px;
  padding: 10px 32px 10px 10px;
}

.cah-color-panel {
  bottom: 14px;
}

.cah-layer-dock {
  top: 70px;
  max-height: 390px;
}

.cah-canvas-settings-panel {
  left: 10px;
  bottom: 14px;
  right: auto;
  width: 174px;
}

.cah-select,
.cah-text-input,
.cah-textarea {
  width: 100%;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.105);
  background: rgba(5, 5, 5, 0.58);
  color: #f7f4ed;
  font-weight: 800;
  font-size: 10px;
  outline: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 5px 14px rgba(0, 0, 0, 0.16);
}

.cah-select:focus,
.cah-text-input:focus,
.cah-textarea:focus {
  border-color: rgba(105, 151, 240, 0.58);
}

.cah-select,
.cah-text-input {
  height: 24px;
  padding: 0 6px;
}

.cah-textarea {
  min-height: 54px;
  resize: vertical;
  padding: 7px;
  line-height: 1.35;
}

.cah-text-input::placeholder,
.cah-textarea::placeholder {
  color: rgba(247, 244, 237, 0.38);
}

.cah-control {
  display: grid;
  gap: 3px;
  color: rgba(247, 244, 237, 0.68);
  font-size: 7.5px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-bottom: 5px;
}

.cah-control b {
  color: rgba(160, 188, 245, 0.96);
}

.cah-control input[type="range"] {
  width: 100%;
  accent-color: #6d94ee;
}

.cah-color-control input[type="color"] {
  width: 100%;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

.cah-color-swatch {
  width: 100%;
  height: 28px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 5px 14px rgba(0, 0, 0, 0.16);
}

.cah-button-stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
  margin-top: 5px;
}

.cah-conditional-control {
  display: none;
}

body.cah-brush-smudge #smudgeStrengthWrap,
body.cah-brush-blend #blendStrengthWrap {
  display: grid;
}

.cah-guardian-wrap {
  display: none;
}

body.cah-submit-child .cah-guardian-wrap {
  display: grid;
}

.cah-layers-list {
  min-height: 0;
  max-height: 190px;
  overflow-y: auto;
  overflow-x: hidden;
  display: grid;
  grid-template-columns: 1fr;
  align-content: start;
  gap: 5px;
}

.cah-layer-item {
  width: 100%;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.025)),
    rgba(5, 5, 5, 0.42);
  color: #f7f4ed;
  padding: 2px 3px;
  font-size: 8px;
  text-align: left;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 3px;
  box-shadow: none;
}

.cah-layer-item.active {
  border-color: rgba(105, 151, 240, 0.72);
  background:
    linear-gradient(180deg, rgba(81, 130, 226, 0.32), rgba(40, 70, 135, 0.20)),
    rgba(5, 5, 5, 0.42);
}

.cah-layer-check {
  width: 12px;
  height: 12px;
  accent-color: #6d94ee;
}

.cah-layer-name {
  width: 100%;
  min-width: 0;
  padding: 2px 2px;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: inherit;
  font-size: 8px;
  text-align: left;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.cah-layer-name:hover {
  background: rgba(255, 255, 255, 0.05);
}

.cah-layer-mini {
  min-width: 0;
  width: 17px;
  height: 15px;
  padding: 0;
  font-size: 8px;
}

.cah-nav-gizmo {
  position: absolute;
  z-index: 40;
  left: 196px;
  bottom: 14px;
  width: 126px;
  height: 126px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background:
    radial-gradient(circle at center, rgba(105, 151, 240, 0.18), transparent 37%),
    conic-gradient(
      from -22.5deg,
      rgba(105, 151, 240, 0.11) 0deg 45deg,
      rgba(255, 255, 255, 0.045) 45deg 90deg,
      rgba(255, 255, 255, 0.055) 90deg 135deg,
      rgba(105, 151, 240, 0.11) 135deg 180deg,
      rgba(255, 255, 255, 0.045) 180deg 225deg,
      rgba(255, 255, 255, 0.055) 225deg 270deg,
      rgba(105, 151, 240, 0.11) 270deg 315deg,
      rgba(255, 255, 255, 0.045) 315deg 360deg
    ),
    rgba(14, 14, 14, 0.78);
  backdrop-filter: blur(18px);
  box-shadow:
    0 18px 50px rgba(0, 0, 0, 0.35),
    inset 0 0 30px rgba(0, 0, 0, 0.20);
  touch-action: none;
  user-select: none;
}

.cah-gizmo-min {
  top: -2px;
  right: -2px;
  border-radius: 6px;
}

.cah-nav-gizmo button {
  position: absolute;
  min-width: 0;
  padding: 0;
  height: 25px;
  width: 30px;
  font-size: 11px;
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.025)),
    rgba(10, 10, 10, 0.62);
  backdrop-filter: blur(6px);
  touch-action: none;
}

.cah-gizmo-center {
  left: 50%;
  top: 50%;
  width: 42px !important;
  height: 42px !important;
  transform: translate(-50%, -50%);
  border-radius: 8px !important;
  color: #211411;
  background: linear-gradient(180deg, #6d94ee, #2f5fb8) !important;
  border-color: rgba(105, 151, 240, 0.85);
  font-size: 8px !important;
  cursor: move;
}

.cah-gizmo-up { left: 48px; top: 7px; }
.cah-gizmo-right { right: 7px; top: 50px; }
.cah-gizmo-down { left: 48px; bottom: 7px; }
.cah-gizmo-left { left: 7px; top: 50px; }
.cah-gizmo-zoom-in { right: 14px; top: 16px; }
.cah-gizmo-zoom-out { left: 14px; bottom: 16px; }
.cah-gizmo-rotate-left { left: 14px; top: 16px; }
.cah-gizmo-rotate-right { right: 14px; bottom: 16px; }

.cah-gizmo-reset {
  left: 50%;
  bottom: 31px;
  width: 39px !important;
  height: 19px !important;
  transform: translateX(-50%);
  font-size: 8px !important;
  color: rgba(160, 188, 245, 0.96);
  background: rgba(10, 10, 10, 0.70) !important;
}

.cah-submit-modal {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

body.cah-submit-modal-open .cah-submit-modal {
  display: flex;
}

.cah-submit-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(10px);
}

.cah-submit-modal-card {
  position: relative;
  z-index: 2;
  width: min(880px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  background:
    radial-gradient(circle at 12% 10%, rgba(105, 151, 240, 0.12), transparent 26%),
    radial-gradient(circle at 88% 5%, rgba(255, 255, 255, 0.08), transparent 24%),
    linear-gradient(180deg, rgba(28, 28, 28, 0.96), rgba(9, 9, 9, 0.96));
  box-shadow: 0 28px 100px rgba(0, 0, 0, 0.62);
  padding: 16px;
}

.cah-submit-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 14px;
  margin-bottom: 12px;
}

.cah-submit-modal-header p {
  margin: 8px 0 0;
  color: rgba(247, 244, 237, 0.68);
  font-size: 12px;
  line-height: 1.4;
}

.cah-modal-close {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

.cah-submit-preview-wrap {
  width: 100%;
  margin-bottom: 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background:
    linear-gradient(45deg, rgba(255,255,255,0.035) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255,255,255,0.035) 25%, transparent 25%),
    #151515;
  background-size: 22px 22px;
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: 10px;
}

.cah-submit-preview {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  background: #fffaf4;
}

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

.cah-description-control {
  grid-column: 1 / -1;
}

.cah-check-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: start;
  color: rgba(247, 244, 237, 0.78);
  font-size: 10px;
  line-height: 1.35;
  margin: 6px 0 10px;
}

.cah-check-row input {
  width: 16px;
  height: 16px;
  accent-color: #6d94ee;
  margin-top: 1px;
}

.cah-submit-modal-actions {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 8px;
}

.cah-submit-action {
  background:
    linear-gradient(180deg, rgba(81, 130, 226, 0.98), rgba(43, 78, 154, 0.96));
  color: #f7faff;
  border-color: rgba(105, 151, 240, 0.8);
}

.cah-submit-status {
  min-height: 18px;
  margin-top: 8px;
  color: rgba(160, 188, 245, 0.96);
  font-size: 10px;
  line-height: 1.35;
  font-weight: 800;
}

.cah-submit-status.error {
  color: #ff9a7a;
}

.cah-submit-status.success {
  color: #aaf0a6;
}

body.cah-ui-hidden .cah-floating-header,
body.cah-ui-hidden .cah-canvas-panel,
body.cah-ui-hidden .cah-brush-panel,
body.cah-ui-hidden .cah-color-panel,
body.cah-ui-hidden .cah-layers-panel {
  opacity: 0;
  pointer-events: none;
  transform: translateY(14px);
}

body.cah-ui-hidden .cah-nav-gizmo {
  opacity: 0.72;
}

body.cah-ui-hidden .cah-ui-toggle {
  top: 12px;
  right: 12px;
  opacity: 0.72;
}

body.cah-panel-header-minimized .cah-floating-header,
body.cah-panel-canvas-minimized .cah-canvas-panel,
body.cah-panel-brushes-minimized .cah-brush-panel,
body.cah-panel-color-minimized .cah-color-panel,
body.cah-panel-layers-minimized .cah-layers-panel {
  width: 105px;
  height: 42px;
  overflow: hidden;
  transform: none;
}

body.cah-panel-header-minimized .cah-floating-header .cah-panel-content,
body.cah-panel-canvas-minimized .cah-canvas-panel .cah-panel-content,
body.cah-panel-brushes-minimized .cah-brush-panel .cah-panel-content,
body.cah-panel-color-minimized .cah-color-panel .cah-panel-content,
body.cah-panel-layers-minimized .cah-layers-panel .cah-panel-content {
  display: none;
}

body.cah-panel-header-minimized .cah-floating-header::before {
  content: "Header";
  color: rgba(160, 188, 245, 0.96);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: block;
  margin-top: 5px;
}

body.cah-panel-canvas-minimized .cah-canvas-panel .cah-panel-title,
body.cah-panel-brushes-minimized .cah-brush-panel .cah-panel-title,
body.cah-panel-color-minimized .cah-color-panel .cah-panel-title,
body.cah-panel-layers-minimized .cah-layers-panel .cah-panel-title {
  margin: 5px 0 0;
  padding-right: 30px;
}

body.cah-panel-gizmo-minimized .cah-nav-gizmo {
  width: 82px;
  height: 42px;
  border-radius: 18px;
  overflow: hidden;
}

body.cah-panel-gizmo-minimized .cah-nav-gizmo .cah-gizmo-content {
  display: none;
}

.cah-floating-header,
.cah-canvas-panel,
.cah-brush-panel,
.cah-color-panel,
.cah-layers-panel,
.cah-nav-gizmo {
  transition:
    opacity 0.18s ease,
    transform 0.18s ease,
    width 0.18s ease,
    height 0.18s ease;
}

@media (max-width: 1000px) {
  .cah-topbar {
    right: 86px;
  }

  .cah-topbar-inner {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .cah-header-actions {
    justify-content: start;
  }

  .cah-left-rail {
    top: 132px;
  }

  .cah-color-panel {
    top: 132px;
  }

  .cah-layer-dock {
    top: 254px;
  }

  .cah-submit-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .cah-ui-toggle {
    top: 12px;
    right: 10px;
    padding: 8px 10px;
    font-size: 10px;
  }

  .cah-topbar {
    top: 8px;
    left: 8px;
    right: 82px;
    min-height: 48px;
    padding: 10px 38px 10px 12px;
    border-radius: 16px;
  }

  .cah-floating-header h1 {
    font-size: 18px;
  }

  .cah-header-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .cah-header-actions button {
    min-width: 0;
  }

  .cah-left-rail {
    left: 8px;
    top: 142px;
    width: 150px;
    padding: 12px 38px 12px 12px;
  }

  .cah-right-panel {
    right: 8px;
    width: 170px;
    padding: 12px 38px 12px 12px;
  }

  .cah-color-panel {
    top: 142px;
  }

  .cah-layer-dock {
    top: 336px;
    max-height: 245px;
  }

  .cah-canvas-settings-panel {
    display: none;
  }

  .cah-layers-list {
    max-height: 140px;
  }

  .cah-nav-gizmo {
    left: 8px;
    bottom: 8px;
    width: 132px;
    height: 132px;
  }

  .cah-nav-gizmo button {
    width: 31px;
    height: 25px;
    font-size: 11px;
  }

  .cah-gizmo-center {
    width: 45px !important;
    height: 45px !important;
    font-size: 8px !important;
  }

  .cah-gizmo-up { left: 50px; top: 7px; }
  .cah-gizmo-right { right: 7px; top: 53px; }
  .cah-gizmo-down { left: 50px; bottom: 7px; }
  .cah-gizmo-left { left: 7px; top: 53px; }
  .cah-gizmo-zoom-in { right: 14px; top: 17px; }
  .cah-gizmo-zoom-out { left: 14px; bottom: 17px; }
  .cah-gizmo-rotate-left { left: 14px; top: 17px; }
  .cah-gizmo-rotate-right { right: 14px; bottom: 17px; }

  .cah-gizmo-reset {
    bottom: 33px;
    width: 40px !important;
    height: 21px !important;
    font-size: 7px !important;
  }

  .cah-submit-modal {
    padding: 10px;
  }

  .cah-submit-modal-card {
    width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
    border-radius: 18px;
    padding: 14px;
  }

  .cah-submit-modal-actions {
    grid-template-columns: 1fr;
  }
}

/* Build label and text tool */
.cah-build-number {
  display: inline-block !important;
  margin-left: 6px !important;
  padding: 2px 5px;
  border-radius: 4px;
  border: 1px solid rgba(109, 148, 238, 0.34);
  background: rgba(109, 148, 238, 0.14);
  color: rgba(220, 230, 255, 0.9) !important;
  font-size: 8px !important;
  font-weight: 800;
  vertical-align: 1px;
}

.cah-text-panel {
  left: 304px;
  bottom: 58px;
  width: 222px;
  padding: 8px 28px 8px 8px;
}

.cah-text-panel .cah-control {
  margin-bottom: 5px;
}

.cah-tool-textarea {
  min-height: 48px;
  max-height: 92px;
  resize: vertical;
}

.cah-text-control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.cah-text-style-row {
  display: grid;
  grid-template-columns: 30px 30px 1fr;
  gap: 5px;
}

.cah-text-style-row button {
  height: 26px;
  min-width: 0;
  padding: 0 7px;
  border-radius: 5px;
}

.cah-text-style-row button.active {
  background: rgba(109, 148, 238, 0.28);
  border-color: rgba(109, 148, 238, 0.78);
  color: #fff;
}

body.cah-text-mode .cah-text-panel {
  outline: 1px solid rgba(109, 148, 238, 0.72);
}

body.cah-ui-hidden .cah-text-panel {
  opacity: 0;
  pointer-events: none;
  transform: translateY(14px);
}

body.cah-panel-text-minimized .cah-text-panel {
  width: 105px;
  height: 42px;
  overflow: hidden;
}

body.cah-panel-text-minimized .cah-text-panel .cah-control,
body.cah-panel-text-minimized .cah-text-panel .cah-text-control-grid,
body.cah-panel-text-minimized .cah-text-panel .cah-text-style-row {
  display: none;
}

@media (max-width: 1000px) {
  .cah-text-panel {
    left: 304px;
    width: 220px;
  }
}

@media (max-width: 820px) {
  .cah-text-panel {
    left: 62px;
    bottom: 58px;
    width: min(240px, calc(100vw - 74px));
  }
}

@media (max-height: 740px) and (max-width: 820px) {
  .cah-layer-dock {
    display: none;
  }

  .cah-color-panel {
    display: none;
  }

  .cah-left-rail {
    top: auto;
    bottom: 8px;
    width: calc(100vw - 156px);
  }
}

html,
body,
.cah-draw-app,
.cah-draw-shell,
.cah-panel,
.cah-panel *,
.cah-canvas-area,
.cah-canvas-viewport,
.cah-canvas-stage,
.cah-layer-stack,
.cah-nav-gizmo,
.cah-nav-gizmo * {
  -webkit-user-select: none !important;
  user-select: none !important;
  -webkit-touch-callout: none !important;
  -webkit-tap-highlight-color: transparent !important;
}

input,
textarea,
select,
input *,
textarea *,
select * {
  -webkit-user-select: text !important;
  user-select: text !important;
}

.cah-canvas-area,
.cah-canvas-viewport,
.cah-layer-stack,
.cah-canvas-stage {
  touch-action: none !important;
  overscroll-behavior: none !important;
  -webkit-touch-callout: none !important;
}

button,
.cah-panel-title,
.cah-layer-item,
.cah-gizmo-center {
  -webkit-user-drag: none !important;
  user-drag: none !important;
}

/* Tablet art-app layout */
.cah-app-bar {
  left: 48px;
  right: 48px;
  top: 10px;
  height: 38px;
  padding: 5px 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.cah-project-block {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 220px;
}

.cah-project-block h1 {
  margin: 0;
  font-size: 13px;
  line-height: 1.05;
  letter-spacing: 0;
}

.cah-project-block span {
  display: block;
  margin-top: 3px;
  color: rgba(247, 244, 237, 0.54);
  font-size: 9px;
}

.cah-icon-button {
  width: 25px;
  height: 25px;
  min-width: 0;
  padding: 0;
  font-size: 16px;
}

.cah-tool-rail {
  left: 8px;
  top: 58px;
  bottom: 14px;
  width: 40px;
  padding: 5px 4px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 3px;
}

.cah-tool-button {
  height: 36px;
  min-width: 0;
  padding: 3px 1px;
  display: grid;
  place-items: center;
  gap: 2px;
  border-radius: 4px;
  background: transparent;
  box-shadow: none;
}

.cah-tool-button span {
  font-size: 13px;
  line-height: 1;
}

.cah-tool-button b {
  font-size: 7px;
  line-height: 1;
  font-weight: 700;
  color: rgba(247, 244, 237, 0.72);
}

.cah-tool-button.active b {
  color: #fff;
}

.cah-rail-color {
  width: 25px;
  height: 25px;
  min-width: 0;
  padding: 0;
  border-radius: 50%;
  margin: auto auto 4px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  background: #111;
}

.cah-brush-library {
  left: 56px;
  top: 58px;
  width: 250px;
  max-height: 430px;
  padding: 8px 28px 8px 8px;
}

.cah-brush-library-grid {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 6px;
}

.cah-brush-categories,
.cah-brush-list {
  display: grid;
  gap: 5px;
  align-content: start;
}

.cah-brush-categories button {
  width: 100%;
  height: 24px;
  min-width: 0;
  padding: 5px 5px;
  text-align: left;
  background: transparent;
  box-shadow: none;
  color: rgba(247, 244, 237, 0.72);
  display: flex;
  align-items: center;
  font-size: 8px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cah-brush-categories button.active {
  background: rgba(105, 151, 240, 0.18);
  color: #fff;
}

.cah-brush-list {
  max-height: 360px;
  overflow-y: auto;
}

.cah-brush-card {
  min-width: 0;
  height: 45px;
  max-height: 45px;
  padding: 4px 5px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto 1fr;
  gap: 3px;
  text-align: left;
  background: rgba(255, 255, 255, 0.035);
  overflow: hidden;
}

.cah-brush-card span {
  grid-column: 1;
  font-size: 8px;
  color: rgba(247, 244, 237, 0.72);
}

.cah-brush-card em {
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
  color: rgba(247, 244, 237, 0.35);
  font-style: normal;
  font-size: 10px;
  line-height: 1;
}

.cah-brush-card.is-favorite em {
  color: rgba(160, 188, 245, 0.96);
}

.cah-brush-card.active {
  outline: 1px solid rgba(105, 151, 240, 0.8);
  background: rgba(81, 130, 226, 0.18);
}

.stroke {
  grid-column: 1 / -1;
  display: block;
  width: 100%;
  height: 20px;
  border-radius: 999px;
  opacity: 0.9;
}

.stroke-soft { background: radial-gradient(ellipse at center, rgba(255,255,255,0.95), rgba(255,255,255,0.2) 42%, transparent 70%); filter: blur(1px); }
.stroke-ink { background: linear-gradient(175deg, transparent 30%, rgba(255,255,255,0.95) 46%, rgba(255,255,255,0.35) 54%, transparent 70%); }
.stroke-charcoal { background: repeating-linear-gradient(170deg, transparent 0 5px, rgba(255,255,255,0.6) 5px 8px, transparent 8px 14px); filter: blur(0.5px); }
.stroke-marker { background: linear-gradient(175deg, transparent 25%, rgba(255,255,255,0.62) 38%, rgba(255,255,255,0.9) 55%, transparent 72%); filter: blur(1.5px); }
.stroke-blend { background: radial-gradient(ellipse at center, rgba(255,255,255,0.7), rgba(255,255,255,0.14) 55%, transparent 75%); filter: blur(2px); }
.stroke-pencil { background: linear-gradient(175deg, transparent 38%, rgba(255,255,255,0.7) 48%, transparent 58%); }
.stroke-water { background: radial-gradient(ellipse at center, rgba(180,210,255,0.65), rgba(255,255,255,0.22) 48%, transparent 72%); filter: blur(2px); }
.stroke-smudge { background: linear-gradient(90deg, transparent, rgba(255,255,255,0.22), rgba(255,255,255,0.72), rgba(255,255,255,0.14), transparent); filter: blur(2px); }
.stroke-flat { background: linear-gradient(180deg, transparent 22%, rgba(255,255,255,0.86) 38%, rgba(255,255,255,0.72) 62%, transparent 78%); }
.stroke-bright { background: repeating-linear-gradient(180deg, transparent 0 5px, rgba(255,255,255,0.82) 5px 8px, transparent 8px 12px); }
.stroke-filbert { background: radial-gradient(ellipse at center, rgba(255,255,255,0.86), rgba(255,255,255,0.34) 52%, transparent 72%); }
.stroke-round { background: linear-gradient(175deg, transparent 38%, rgba(255,255,255,0.96) 48%, transparent 58%); }
.stroke-fan { background: conic-gradient(from 245deg at 50% 100%, transparent 0deg, rgba(255,255,255,0.75) 18deg, transparent 26deg, rgba(255,255,255,0.55) 38deg, transparent 50deg, rgba(255,255,255,0.65) 64deg, transparent 82deg); }
.stroke-glaze { background: radial-gradient(ellipse at center, rgba(255,255,255,0.38), rgba(255,255,255,0.12) 58%, transparent 78%); filter: blur(2px); }
.stroke-shader { background: repeating-linear-gradient(180deg, transparent 0 4px, rgba(255,255,255,0.92) 4px 7px, transparent 7px 10px); }
.stroke-cat { background: radial-gradient(ellipse at 50% 42%, rgba(255,255,255,0.85), rgba(255,255,255,0.24) 48%, transparent 70%); clip-path: polygon(50% 6%, 84% 35%, 72% 92%, 28% 92%, 16% 35%); }
.stroke-liner { background: linear-gradient(175deg, transparent 44%, rgba(255,255,255,0.98) 49%, transparent 54%); }
.stroke-script { background: linear-gradient(170deg, transparent 42%, rgba(255,255,255,0.88) 49%, transparent 56%); filter: blur(0.4px); }
.stroke-detail { background: linear-gradient(175deg, transparent 47%, rgba(255,255,255,1) 50%, transparent 53%); }
.stroke-egbert {
  background:
    linear-gradient(165deg, transparent 10%, rgba(255,255,255,0.18) 22%, transparent 28%),
    radial-gradient(ellipse at 58% 45%, rgba(255,255,255,0.88), rgba(255,255,255,0.46) 48%, transparent 72%);
  clip-path: polygon(4% 54%, 15% 30%, 82% 16%, 98% 34%, 78% 64%, 16% 76%);
  filter: blur(0.25px);
}
.stroke-mop { background: radial-gradient(circle at center, rgba(255,255,255,0.52), rgba(255,255,255,0.16) 58%, transparent 76%); filter: blur(2.2px); }

.cah-hidden-select {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.cah-brush-settings {
  left: 72px;
  bottom: 58px;
  width: 218px;
  padding: 8px 28px 8px 8px;
}

.cah-brush-preview {
  height: 36px;
  margin-bottom: 6px;
  border-radius: 6px;
  background:
    radial-gradient(ellipse at center, rgba(255,255,255,0.72), rgba(255,255,255,0.16) 48%, transparent 72%),
    rgba(255, 255, 255, 0.025);
  filter: blur(0.4px);
}

.cah-brush-settings .cah-control {
  margin-bottom: 5px;
}

.cah-brush-settings button:last-child {
  width: 100%;
  margin-top: 4px;
}

.cah-layers-panel {
  right: 48px;
  top: 58px;
  width: 218px;
  max-height: 540px;
  padding: 8px 28px 8px 8px;
}

.cah-panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.cah-layer-top-add {
  width: 24px;
  height: 24px;
  min-width: 0;
  padding: 0;
}

.cah-layers-list {
  max-height: 375px;
}

.cah-layer-item {
  grid-template-columns: auto minmax(0, 1fr) 54px auto auto auto;
  min-height: 18px;
}

.cah-layer-name::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 4px;
  vertical-align: middle;
  border-radius: 3px;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.16), rgba(255,255,255,0.02)),
    rgba(120, 130, 145, 0.35);
}

.cah-layer-name span,
.cah-layer-name small {
  display: inline;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cah-layer-name small {
  margin-top: 0;
  margin-left: 4px;
  color: rgba(247, 244, 237, 0.46);
  font-size: 8px;
  font-weight: 700;
}

.cah-layer-opacity-inline {
  width: 54px;
  height: 14px;
  accent-color: #6d94ee;
}

.cah-color-panel {
  right: 48px;
  bottom: 18px;
  width: 218px;
  padding: 8px 28px 8px 8px;
}

.cah-color-picker-ui {
  display: grid;
  justify-items: center;
  gap: 10px;
}

.cah-color-wheel {
  position: relative;
  width: 146px;
  height: 146px;
  border-radius: 50%;
  background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
  touch-action: none;
}

.cah-color-wheel::after {
  content: "";
  position: absolute;
  inset: 26px;
  border-radius: 50%;
  background: rgba(18, 18, 18, 0.92);
}

.cah-color-square {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 50%;
  width: 78px;
  height: 78px;
  transform: translate(-50%, -50%);
  border-radius: 4px;
  background:
    linear-gradient(0deg, #000, transparent),
    linear-gradient(90deg, #fff, hsl(220, 100%, 50%));
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.22);
  touch-action: none;
}

.cah-color-wheel-handle,
.cah-color-square-handle {
  position: absolute;
  z-index: 4;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.55);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.cah-color-square-handle {
  left: 92%;
  top: 7%;
}

.cah-native-color {
  width: 1px;
  height: 1px;
  opacity: 0;
  position: absolute;
  pointer-events: none;
}

.cah-swatch-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  width: 100%;
}

.cah-swatch-row button {
  height: 20px;
  min-width: 0;
  padding: 0;
  border-radius: 3px;
}

.cah-canvas-panel {
  left: 72px;
  bottom: 12px;
  right: auto;
  width: 218px;
  padding: 8px 28px 8px 8px;
}

.cah-nav-gizmo {
  left: auto;
  right: 278px;
  bottom: 18px;
}

body.cah-ui-hidden .cah-tool-rail,
body.cah-ui-hidden .cah-brush-library,
body.cah-ui-hidden .cah-brush-settings,
body.cah-ui-hidden .cah-layers-panel,
body.cah-ui-hidden .cah-color-panel,
body.cah-ui-hidden .cah-canvas-panel,
body.cah-ui-hidden .cah-app-bar {
  opacity: 0;
  pointer-events: none;
}

body.cah-panel-settings-minimized .cah-brush-settings,
body.cah-panel-brushes-minimized .cah-brush-library,
body.cah-panel-color-minimized .cah-color-panel,
body.cah-panel-layers-minimized .cah-layers-panel,
body.cah-panel-canvas-minimized .cah-canvas-panel {
  width: 105px;
  height: 42px;
  overflow: hidden;
}

body.cah-panel-settings-minimized .cah-brush-settings .cah-panel-content,
body.cah-panel-settings-minimized .cah-brush-settings .cah-brush-preview,
body.cah-panel-settings-minimized .cah-brush-settings .cah-control,
body.cah-panel-settings-minimized .cah-brush-settings #resetBrushSettingsBtn,
body.cah-panel-brushes-minimized .cah-brush-library .cah-brush-library-grid,
body.cah-panel-color-minimized .cah-color-panel .cah-color-picker-ui,
body.cah-panel-layers-minimized .cah-layers-panel .cah-select,
body.cah-panel-layers-minimized .cah-layers-panel .cah-layers-list,
body.cah-panel-canvas-minimized .cah-canvas-panel .cah-control,
body.cah-panel-canvas-minimized .cah-canvas-panel #applyCanvasPresetBtn {
  display: none;
}

@media (max-width: 1000px) {
  .cah-app-bar {
    left: 56px;
    right: 10px;
  }

  .cah-brush-library {
    width: 260px;
  }

  .cah-brush-settings,
  .cah-canvas-panel {
    width: 220px;
  }

  .cah-layers-panel,
  .cah-color-panel {
    right: 10px;
    width: 220px;
  }

  .cah-nav-gizmo {
    right: 240px;
  }
}

@media (max-width: 820px) {
  .cah-app-bar {
    left: 8px;
    right: 8px;
    top: 8px;
  }

  .cah-tool-rail {
    left: 8px;
    top: 62px;
    width: 46px;
  }

  .cah-brush-library {
    left: 62px;
    top: 62px;
    width: min(280px, calc(100vw - 74px));
  }

  .cah-brush-settings,
  .cah-canvas-panel {
    left: 62px;
    width: min(240px, calc(100vw - 74px));
  }

  .cah-layers-panel,
  .cah-color-panel {
    right: 8px;
    width: min(230px, calc(100vw - 74px));
  }
}
