/* =========================================================
      Profiilikuvan piirtoeditori
      ========================================================= */

#profileImageEditorModal {
  --profile-editor-text: #f8f5ff;
  --profile-editor-muted: rgba(248, 245, 255, 0.7);
  --profile-editor-border: rgba(255, 255, 255, 0.16);
  --profile-editor-accent: #71ef8b;
  z-index: 20600 !important;
}

.modal-backdrop.profile-image-editor-backdrop {
  z-index: 20590 !important;
}

#profileImageEditorModal .modal-dialog {
  width: min(1120px, calc(100% - 1rem));
  max-width: 1120px;
}

#profileImageEditorModal .modal-content {
  overflow: hidden;
  border: 1px solid var(--profile-editor-border);
  border-radius: 7px;
  color: var(--profile-editor-text);
  background: radial-gradient(circle at 10% 5%, rgba(133, 72, 210, 0.22), transparent 34%),
        radial-gradient(circle at 92% 12%, rgba(65, 214, 111, 0.15), transparent 30%),
        linear-gradient(145deg, rgba(24, 18, 35, 0.98), rgba(19, 43, 29, 0.98));
  box-shadow: 0 20px 65px rgba(0, 0, 0, 0.48);
}

#profileImageEditorModal .modal-header {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(430px, 620px) auto;
  align-items: center;
  gap: 0.8rem;
  border-bottom-color: rgba(255, 255, 255, 0.13);
  background: linear-gradient(110deg, rgba(112, 55, 164, 0.68), rgba(37, 113, 61, 0.68));
}

#profileImageEditorModal .modal-title-wrap {
  min-width: 0;
}

#profileImageEditorModal .modal-title-wrap p {
  margin: 0.22rem 0 0;
  color: var(--profile-editor-muted);
  font-size: 0.82rem;
}

#profileImageEditorModal .modal-body {
  padding: 1rem;
}

.profile-image-editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(350px, 380px);
  gap: 1rem;
}

.profile-image-editor-drawing,
.profile-image-editor-controls {
  min-width: 0;
  border: 1px solid var(--profile-editor-border);
  border-radius: 7px;
  background: rgba(11, 10, 17, 0.48);
}

.profile-image-editor-drawing {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem;
}

.profile-image-editor-toolbar,
.profile-image-editor-brush-settings {
  width: min(100%, 620px);
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 7px;
  background: linear-gradient(120deg, rgba(93, 47, 133, 0.2), rgba(47, 111, 65, 0.18));
}

.profile-image-editor-toolbar {
  padding: 0.55rem;
}

#profileImageEditorModal .modal-header .profile-image-editor-toolbar {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0.42rem;
  background: rgba(10, 9, 16, 0.28);
}

#profileImageEditorModal .modal-header .profile-image-editor-tool {
  min-height: 39px;
  padding: 0.38rem 0.45rem;
}

.profile-image-editor-tool-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.45rem;
}

.profile-image-editor-tool {
  display: inline-flex;
  min-width: 0;
  min-height: 43px;
  align-items: center;
  justify-content: center;
  gap: 0.38rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid rgba(255, 255, 255, 0.19);
  border-radius: 11px;
  color: var(--profile-editor-text);
  background: rgba(255, 255, 255, 0.08);
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.profile-image-editor-tool:hover,
.profile-image-editor-tool:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.38);
  background: rgba(255, 255, 255, 0.14);
  box-shadow: 0 7px 18px rgba(0, 0, 0, 0.22);
}

.profile-image-editor-tool.is-active {
  border-color: rgba(123, 255, 151, 0.78);
  background: linear-gradient(120deg, rgba(143, 88, 220, 0.44), rgba(73, 182, 94, 0.46));
  box-shadow: 0 0 0 2px rgba(103, 240, 131, 0.13);
}

.profile-image-editor-tool:disabled {
  opacity: 0.36;
  cursor: default;
  transform: none;
  box-shadow: none;
}

.profile-image-editor-tool.is-danger:hover,
.profile-image-editor-tool.is-danger:focus-visible {
  border-color: rgba(255, 90, 106, 0.74);
  background: rgba(255, 90, 106, 0.18);
}

.profile-image-editor-tool .material-symbols-outlined {
  flex: 0 0 auto;
  font-size: 1.35rem;
}

.profile-image-editor-clear-icon {
  display: inline-grid;
  width: 1.35rem;
  height: 1.35rem;
  place-items: center;
}

.profile-image-editor-clear-icon svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.8;
}

.profile-image-editor-tool-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.78rem;
}

.profile-image-editor-canvas-frame {
  position: relative;
  width: min(100%, 620px);
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 7px;
  touch-action: none;
  background: linear-gradient(45deg, #dadada 25%, transparent 25%),
        linear-gradient(-45deg, #dadada 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #dadada 75%),
        linear-gradient(-45deg, transparent 75%, #dadada 75%),
        #fff;
  background-position: 0 0, 0 14px, 14px -14px, -14px 0;
  background-size: 28px 28px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18), 0 12px 35px rgba(0, 0, 0, 0.27);
}

#profileImageDrawingCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

#profileImageDrawingCanvas.is-fill-tool {
  cursor: cell;
}

.profile-image-editor-brush-cursor {
  position: absolute;
  z-index: 4;
  left: 0;
  top: 0;
  width: 18px;
  height: 18px;
  border: 1.5px solid #000000;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.72), 0 0 6px rgba(255, 255, 255, 0.28);
  transition: width 80ms ease, height 80ms ease, opacity 90ms ease;
}

.profile-image-editor-brush-cursor.is-visible {
  opacity: 1;
}

.profile-image-editor-brush-cursor.is-eraser {
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.92) !important;
  background: rgba(0, 0, 0, 0.08);
}

.profile-image-editor-brush-settings.is-inactive {
  opacity: 0.42;
  pointer-events: none;
}

.profile-image-editor-brush-settings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

.profile-image-editor-setting {
  min-width: 0;
}

.profile-image-editor-setting-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  margin-bottom: 0.3rem;
  color: var(--profile-editor-muted);
  font-size: 0.76rem;
}

.profile-image-editor-value {
  min-width: 48px;
  padding: 0.26rem 0.4rem;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 9px;
  text-align: center;
  background: rgba(0, 0, 0, 0.22);
  color: var(--profile-editor-text);
  font-size: 0.76rem;
}

#profileImageEditorModal input[type="range"] {
  width: 100%;
  min-width: 0;
  accent-color: var(--profile-editor-accent);
  touch-action: none;
  user-select: none;
  cursor: pointer;
}

.profile-image-editor-controls {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  padding: 0.85rem;
}

.profile-image-editor-section {
  min-width: 0;
  padding: 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 7px;
  background: linear-gradient(145deg, rgba(93, 47, 133, 0.2), rgba(47, 111, 65, 0.18));
}

.profile-image-editor-section h6 {
  margin: 0;
}

.profile-image-editor-color-top {
  display: flex;
  align-items: center;
  margin-bottom: 0.72rem;
}

.profile-image-editor-color-heading {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

#profileImageHexValue {
  width: 86px;
  min-width: 86px;
  max-width: 86px;
  padding: 0.34rem 0.48rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 9px;
  color: var(--profile-editor-text);
  background: rgba(0, 0, 0, 0.26);
  text-align: center;
  text-transform: uppercase;
  font-size: 0.78rem;
  line-height: 1.2;
}

#profileImageHexValue:focus {
  border-color: rgba(113, 239, 139, 0.72);
  outline: none;
  box-shadow: 0 0 0 2px rgba(113, 239, 139, 0.14);
}

.profile-image-editor-slider-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 0.45rem;
  min-width: 0;
}

.profile-image-editor-slider-row label {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
  color: var(--profile-editor-muted);
  font-size: 0.8rem;
}

.profile-image-editor-palette-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 5px;
  margin-bottom: 0.78rem;
}

.profile-image-editor-palette-color {
  position: relative;
  min-width: 0;
  height: 31px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 7px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.14);
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.profile-image-editor-palette-color:hover,
.profile-image-editor-palette-color:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.62);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.14), 0 4px 10px rgba(0, 0, 0, 0.22);
}

.profile-image-editor-palette-color::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  opacity: 0;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

.profile-image-editor-palette-color.is-selected::after {
  opacity: 1;
}

.profile-image-editor-palette-color.is-light::after {
  color: #151515;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.7);
}

.profile-image-editor-color-main {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

.profile-image-editor-color-sliders {
  display: grid;
  align-content: center;
  gap: 0.85rem;
  min-width: 0;
}

.profile-image-editor-color-wheel-wrap {
  position: relative;
  width: 160px;
  max-width: 100%;
  aspect-ratio: 1;
  margin: 0 auto;
  touch-action: none;
}

#profileImageColorWheel {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  cursor: crosshair;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.32);
}

.profile-image-editor-color-marker {
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid #fff;
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.45), 0 2px 5px rgba(0, 0, 0, 0.5);
}

.profile-image-editor-preview {
  width: 100px;
  height: 100px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
  background-size: 18px 18px;
}

#profileImagePreviewCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

#profileImageEditorStatus {
  min-height: 1.25rem;
  margin-top: auto;
  color: var(--profile-editor-muted);
  text-align: center;
  font-size: 0.8rem;
}

#profileImageEditorStatus.is-error {
  color: #ff9aa5;
}

#profileImageEditorStatus.is-success {
  color: #9dffac;
}

#profileImageEditorModal .modal-footer {
  border-top-color: rgba(255, 255, 255, 0.13);
}

@media (min-width: 901px) {
  .profile-image-editor-color-main {
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    justify-items: center;
  }

  .profile-image-editor-color-sliders {
    width: 100%;
    align-content: initial;
  }
}

@media (hover: hover) and (pointer: fine) {
  #profileImageDrawingCanvas {
    cursor: none;
  }
}

@media (max-width: 900px) {
  #profileImageEditorModal .modal-header {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  #profileImageEditorModal .modal-header .profile-image-editor-toolbar {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  #profileImageEditorModal .modal-dialog {
    width: min(760px, calc(100% - 0.6rem));
    margin: 0.3rem auto;
  }

  .profile-image-editor-layout {
    grid-template-columns: 1fr;
  }

  .profile-image-editor-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #profileImageEditorStatus {
    grid-column: 1 / -1;
  }
}

@media (max-width: 600px) {
  #profileImageEditorModal .modal-header {
    padding: 0.75rem 0.85rem;
  }

  #profileImageEditorModal .modal-title-wrap p {
    display: none;
  }

  #profileImageEditorModal .modal-body {
    padding: 0.5rem;
  }

  .profile-image-editor-layout {
    gap: 0.55rem;
  }

  .profile-image-editor-drawing,
  .profile-image-editor-controls {
    padding: 0.5rem;
  }

  .profile-image-editor-toolbar {
    padding: 0.42rem;
  }

  .profile-image-editor-tool-grid {
    gap: 0.3rem;
  }

  .profile-image-editor-tool {
    min-height: 40px;
    padding: 0.35rem 0.2rem;
  }

  .profile-image-editor-tool-label {
    display: none;
  }

  .profile-image-editor-tool .material-symbols-outlined,
  .profile-image-editor-clear-icon {
    font-size: 1.3rem;
    width: 1.3rem;
    height: 1.3rem;
  }

  .profile-image-editor-brush-settings {
    gap: 0.42rem;
    padding: 0.5rem;
  }

  .profile-image-editor-setting-header {
    font-size: 0.68rem;
  }

  .profile-image-editor-value {
    min-width: 42px;
    padding: 0.2rem 0.28rem;
    font-size: 0.68rem;
  }

  .profile-image-editor-controls {
    display: flex;
    padding: 0.5rem;
  }

  .profile-image-editor-color-top {
    display: flex;
  }

  .profile-image-editor-color-main {
    grid-template-columns: 140px minmax(0, 1fr);
    gap: 0.6rem;
  }

  .profile-image-editor-color-sliders {
    gap: 0.65rem;
  }

  .profile-image-editor-color-wheel-wrap {
    width: 140px;
  }

  .profile-image-editor-palette-color {
    height: 28px;
  }

  .profile-image-editor-preview {
    width: 82px;
    height: 82px;
  }

  #profileImageEditorModal .modal-footer {
    padding: 0.55rem;
  }
}

/* =========================================================
      Profiilikuvaeditorin tiivistetty integraatio
      ========================================================= */

.profile-image-editor-header {
  align-items: center;
}

.profile-image-editor-header .modal-title-wrap {
  min-width: 0;
}

.profile-image-editor-header-preview {
  flex: 0 0 82px;
  width: 82px;
  height: 82px;
  margin-left: auto;
}

.profile-image-editor-brush-settings {
  border: 0;
  background: transparent;
  padding: 0;
}

.profile-image-editor-setting-card {
  display: block;
  min-width: 0;
  padding: 0.65rem;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 7px;
  background: linear-gradient(120deg, rgba(93, 47, 133, 0.2), rgba(47, 111, 65, 0.18));
}

#profileImageSkipConfirmModal {
  z-index: 20750 !important;
}

.modal-backdrop.profile-image-skip-confirm-backdrop {
  z-index: 20740 !important;
}

#profileImageSkipConfirmModal .modal-dialog {
  width: min(520px, calc(100% - 1rem));
}

#profileImageSkipConfirmModal .modal-content {
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 7px;
  color: #f8f5ff;
  background: radial-gradient(circle at 8% 5%, rgba(133, 72, 210, 0.2), transparent 36%),
        radial-gradient(circle at 94% 14%, rgba(65, 214, 111, 0.14), transparent 32%),
        linear-gradient(145deg, rgba(24, 18, 35, 0.99), rgba(19, 43, 29, 0.99));
}

#profileImageSkipConfirmModal .modal-header {
  border-bottom-color: rgba(255, 255, 255, 0.13);
  background: linear-gradient(110deg, rgba(112, 55, 164, 0.68), rgba(37, 113, 61, 0.68));
}

#profileImageSkipConfirmModal .modal-body {
  color: rgba(248, 245, 255, 0.88);
  line-height: 1.5;
}

@media (max-width: 600px) {
  .profile-image-editor-header-preview {
    flex-basis: 58px;
    width: 58px;
    height: 58px;
    margin-left: 0.6rem;
  }

  .profile-image-editor-setting-card {
    padding: 0.5rem;
  }

  #profileImageHexValue {
    width: 82px;
    min-width: 82px;
    max-width: 82px;
  }
}


@media (max-width: 380px) {
  .profile-image-editor-color-main {
    grid-template-columns: 128px minmax(0, 1fr);
    gap: 0.48rem;
  }

  .profile-image-editor-color-wheel-wrap {
    width: 128px;
  }

  .profile-image-editor-color-sliders .profile-image-editor-slider-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.25rem;
  }

  .profile-image-editor-color-sliders .profile-image-editor-value {
    justify-self: end;
  }
}


/* =========================================================
   Profiilikuvan koko piirtoalueen esikatselu
   ========================================================= */
.profile-image-editor-preview {
  overflow: hidden;
  border: 0;
  border-radius: 7px;
  background: transparent;
  box-shadow: none;
}

#profileImagePreviewCanvas {
  border-radius: inherit;
}

/* =========================================================
   Siveltimen koko ja esikatselu
   ========================================================= */
.profile-image-editor-brush-settings {
  grid-template-columns: minmax(0, 1.45fr) minmax(112px, 0.55fr);
}

.profile-image-editor-size-card,
.profile-image-editor-brush-preview-card {
  min-height: 100px;
}

.profile-image-editor-size-card {
  justify-content: center;
}

#profileImageBrushSize {
  height: 32px;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
}

#profileImageBrushSize::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(143, 88, 220, 0.9), rgba(73, 182, 94, 0.92));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}

#profileImageBrushSize::-webkit-slider-thumb {
  width: 24px;
  height: 24px;
  margin-top: -8px;
  appearance: none;
  -webkit-appearance: none;
  border: 2px solid rgba(255, 255, 255, 0.94);
  border-radius: 50%;
  background: #f8f5ff;
  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.42);
}

#profileImageBrushSize::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(143, 88, 220, 0.9), rgba(73, 182, 94, 0.92));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}

#profileImageBrushSize::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border: 2px solid rgba(255, 255, 255, 0.94);
  border-radius: 50%;
  background: #f8f5ff;
  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.42);
}

.profile-image-editor-brush-preview-card {
  display: flex;
  flex-direction: column;
}

.profile-image-editor-brush-preview-card .profile-image-editor-setting-header {
  justify-content: center;
}

.profile-image-editor-brush-preview-stage {
  display: grid;
  flex: 1 1 auto;
  min-height: 64px;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 7px;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.12) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.12) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.12) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.12) 75%),
    rgba(0, 0, 0, 0.24);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
}

.profile-image-editor-brush-preview-dot {
  display: block;
  width: 18px;
  height: 18px;
  max-width: calc(100% - 10px);
  max-height: calc(100% - 10px);
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 50%;
  background: #000;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.72),
    0 5px 14px color-mix(in srgb, var(--profile-brush-preview-color, #000) 42%, transparent);
  transition: width 100ms ease, height 100ms ease, background-color 100ms ease, box-shadow 100ms ease;
}

.profile-image-editor-brush-preview-stage.is-eraser .profile-image-editor-brush-preview-dot {
  border-style: dashed;
}

@media (max-width: 600px) {
  .profile-image-editor-brush-settings {
    grid-template-columns: minmax(0, 1.4fr) minmax(98px, 0.6fr);
  }

  .profile-image-editor-size-card,
  .profile-image-editor-brush-preview-card {
    min-height: 88px;
  }

  .profile-image-editor-brush-preview-stage {
    min-height: 54px;
  }
}

/* =========================================================
   Sivellinasetusten mobiilijärjestys ja suurempi esikatselu
   ========================================================= */
.profile-image-editor-brush-settings {
  grid-template-columns: minmax(0, 1.5fr) minmax(132px, 0.5fr);
  align-items: stretch;
}

.profile-image-editor-size-card,
.profile-image-editor-brush-preview-card {
  min-height: 190px;
}

.profile-image-editor-size-card {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.profile-image-editor-size-setting {
  display: block;
}

.profile-image-editor-brush-color-shortcuts {
  display: grid;
  gap: 0.48rem;
  margin-top: 0.72rem;
  padding-top: 0.62rem;
  border-top: 1px solid rgba(255, 255, 255, 0.11);
}

.profile-image-editor-brush-color-shortcuts .profile-image-editor-color-heading {
  justify-content: space-between;
}

.profile-image-editor-inline-color-title {
  color: var(--profile-editor-muted);
  font-size: 0.76rem;
}

.profile-image-editor-brush-color-shortcuts .profile-image-editor-palette-grid {
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 5px;
  margin: 0;
}

.profile-image-editor-brush-color-shortcuts .profile-image-editor-palette-color {
  height: 28px;
}

.profile-image-editor-brush-preview-stage {
  min-height: 146px;
}

.profile-image-editor-precise-color-section .profile-image-editor-color-top {
  margin-bottom: 0.55rem;
}

@media (max-width: 600px) {
  .profile-image-editor-brush-settings {
    grid-template-columns: minmax(0, 1.45fr) minmax(118px, 0.55fr);
  }

  .profile-image-editor-size-card,
  .profile-image-editor-brush-preview-card {
    min-height: 178px;
  }

  .profile-image-editor-brush-preview-stage {
    min-height: 132px;
  }

  .profile-image-editor-brush-color-shortcuts {
    margin-top: 0.58rem;
    padding-top: 0.52rem;
  }

  .profile-image-editor-brush-color-shortcuts .profile-image-editor-palette-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 4px;
  }

  .profile-image-editor-brush-color-shortcuts .profile-image-editor-palette-color {
    height: 25px;
  }
}

@media (max-width: 380px) {
  .profile-image-editor-brush-settings {
    grid-template-columns: minmax(0, 1.35fr) minmax(106px, 0.65fr);
  }

  .profile-image-editor-size-card,
  .profile-image-editor-brush-preview-card {
    min-height: 184px;
  }

  .profile-image-editor-brush-color-shortcuts .profile-image-editor-palette-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* =========================================================
   Kompakti siveltimen esikatselu
   ========================================================= */
.profile-image-editor-brush-settings {
  align-items: start;
}

.profile-image-editor-brush-preview-card {
  align-self: start;
  min-height: 0;
}

.profile-image-editor-brush-preview-stage {
  flex: 0 0 auto;
  height: 112px;
  min-height: 112px;
}

@media (max-width: 600px) {
  .profile-image-editor-brush-preview-card {
    min-height: 0;
  }

  .profile-image-editor-brush-preview-stage {
    height: 110px;
    min-height: 110px;
  }
}

/* =========================================================
   Täyttötyökalun värivalinta ja esikatselu
   ========================================================= */
.profile-image-editor-brush-settings.is-fill-mode {
  opacity: 1;
  pointer-events: auto;
}

.profile-image-editor-brush-settings.is-fill-mode .profile-image-editor-size-setting {
  opacity: 0.38;
  pointer-events: none;
}

.profile-image-editor-brush-settings.is-fill-mode .profile-image-editor-brush-color-shortcuts,
.profile-image-editor-brush-settings.is-fill-mode .profile-image-editor-brush-preview-card {
  opacity: 1;
  pointer-events: auto;
}

.profile-image-editor-brush-preview-stage.is-fill .profile-image-editor-brush-preview-dot {
  border-width: 2px;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.78),
    0 0 0 5px rgba(255, 255, 255, 0.12),
    0 7px 20px color-mix(in srgb, var(--profile-brush-preview-color, #000) 58%, transparent);
}

/* Tallentamattomien piirrosmuutosten vahvistus editorin yläpuolella. */
#profileImageUnsavedConfirmModal {
  z-index: 20770 !important;
}

.modal-backdrop.profile-image-unsaved-confirm-backdrop {
  z-index: 20760 !important;
}

#profileImageUnsavedConfirmModal .modal-dialog {
  width: min(520px, calc(100% - 1rem));
}

#profileImageUnsavedConfirmModal .modal-content {
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 7px;
  color: #f8f5ff;
  background: radial-gradient(circle at 8% 5%, rgba(133, 72, 210, 0.2), transparent 36%),
        radial-gradient(circle at 94% 14%, rgba(65, 214, 111, 0.14), transparent 32%),
        linear-gradient(145deg, rgba(24, 18, 35, 0.99), rgba(19, 43, 29, 0.99));
}

#profileImageUnsavedConfirmModal .modal-header {
  border-bottom-color: rgba(255, 255, 255, 0.13);
  background: linear-gradient(110deg, rgba(112, 55, 164, 0.68), rgba(37, 113, 61, 0.68));
}

#profileImageUnsavedConfirmModal .modal-body {
  color: rgba(248, 245, 255, 0.88);
  line-height: 1.5;
}


/* =========================================================
   Ruotsalaisbileet – profiilikuvan piirtoeditori
   ---------------------------------------------------------
   Editorin oma CSS ladataan pääteeman jälkeen ja käyttää ID-selektoreita,
   joten huoneteeman palette on määriteltävä täällä editorin viimeisenä
   kerroksena. Näin defaultin violetti–vihreä väritys ei vuoda editoriin.
   ========================================================= */
body.theme-ruotsalaisbileet #profileImageEditorModal {
  --profile-editor-text: #fff7f0;
  --profile-editor-muted: rgba(255, 238, 224, 0.74);
  --profile-editor-border: rgba(246, 198, 159, 0.22);
  --profile-editor-accent: #e79232;
}

body.theme-ruotsalaisbileet #profileImageEditorModal .modal-content {
  border-color: rgba(246, 198, 159, 0.26);
  color: var(--profile-editor-text);
  background:
    radial-gradient(circle at 10% 5%, rgba(224, 131, 66, 0.20), transparent 34%),
    radial-gradient(circle at 92% 12%, rgba(176, 83, 34, 0.15), transparent 30%),
    linear-gradient(145deg, rgba(45, 25, 14, 0.99), rgba(65, 31, 13, 0.99));
  box-shadow: 0 20px 65px rgba(0, 0, 0, 0.46);
}

body.theme-ruotsalaisbileet #profileImageEditorModal .modal-header {
  border-bottom-color: rgba(249, 215, 186, 0.16);
  background: linear-gradient(110deg, rgba(126, 61, 27, 0.90), rgba(182, 91, 36, 0.84));
}

body.theme-ruotsalaisbileet #profileImageEditorModal .modal-header .profile-image-editor-toolbar {
  background: rgba(42, 21, 11, 0.34);
}

body.theme-ruotsalaisbileet .profile-image-editor-drawing,
body.theme-ruotsalaisbileet .profile-image-editor-controls {
  border-color: rgba(246, 198, 159, 0.18);
  background: rgba(38, 21, 12, 0.58);
}

body.theme-ruotsalaisbileet .profile-image-editor-toolbar,
body.theme-ruotsalaisbileet .profile-image-editor-brush-settings,
body.theme-ruotsalaisbileet .profile-image-editor-section,
body.theme-ruotsalaisbileet .profile-image-editor-setting-card {
  border-color: rgba(246, 198, 159, 0.16);
  background: linear-gradient(120deg, rgba(151, 72, 30, 0.24), rgba(101, 50, 25, 0.22));
}

body.theme-ruotsalaisbileet .profile-image-editor-brush-settings {
  /* Myöhempi editorisääntö tekee tästä normaalisti läpinäkyvän. */
  background: transparent;
}

body.theme-ruotsalaisbileet .profile-image-editor-tool.is-active {
  border-color: rgba(250, 190, 125, 0.82);
  background: linear-gradient(120deg, rgba(178, 82, 31, 0.74), rgba(226, 139, 57, 0.72));
  box-shadow: 0 0 0 2px rgba(232, 146, 67, 0.16), 0 0 14px rgba(219, 126, 52, 0.12);
}

body.theme-ruotsalaisbileet #profileImageHexValue:focus {
  border-color: rgba(235, 153, 78, 0.82);
  box-shadow: 0 0 0 2px rgba(231, 146, 50, 0.16);
}

body.theme-ruotsalaisbileet #profileImageEditorStatus.is-success {
  color: #ffd18f;
}

body.theme-ruotsalaisbileet #profileImageBrushSize::-webkit-slider-runnable-track {
  background: linear-gradient(90deg, #8e431f, #e79232);
}

body.theme-ruotsalaisbileet #profileImageBrushSize::-moz-range-track {
  background: linear-gradient(90deg, #8e431f, #e79232);
}

body.theme-ruotsalaisbileet #profileImageSkipConfirmModal .modal-content,
body.theme-ruotsalaisbileet #profileImageUnsavedConfirmModal .modal-content {
  border-color: rgba(246, 198, 159, 0.26);
  color: #fff7f0;
  background:
    radial-gradient(circle at 8% 5%, rgba(224, 131, 66, 0.18), transparent 36%),
    radial-gradient(circle at 94% 14%, rgba(176, 83, 34, 0.14), transparent 32%),
    linear-gradient(145deg, rgba(45, 25, 14, 0.995), rgba(65, 31, 13, 0.995));
}

body.theme-ruotsalaisbileet #profileImageSkipConfirmModal .modal-header,
body.theme-ruotsalaisbileet #profileImageUnsavedConfirmModal .modal-header {
  border-bottom-color: rgba(249, 215, 186, 0.16);
  background: linear-gradient(110deg, rgba(126, 61, 27, 0.92), rgba(182, 91, 36, 0.86));
}

body.theme-ruotsalaisbileet #profileImageSkipConfirmModal .modal-body,
body.theme-ruotsalaisbileet #profileImageUnsavedConfirmModal .modal-body {
  color: rgba(255, 241, 229, 0.90);
}
