body.tsc-photo-editor-open {
  overflow: hidden;
}

.tsc-photo-editor {
  position: fixed;
  inset: 0;
  z-index: 220;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.86);
  color: #f8f8f8;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
}

.tsc-photo-editor *,
.tsc-photo-editor *::before,
.tsc-photo-editor *::after {
  box-sizing: border-box;
}

.tsc-photo-editor__panel {
  display: flex;
  width: min(1080px, 100%);
  max-height: calc(100dvh - 32px);
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(244, 196, 48, 0.45);
  border-radius: 8px;
  background: #171717;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.74);
}

.tsc-photo-editor__header,
.tsc-photo-editor__footer {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  background: #111;
}

.tsc-photo-editor__header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.tsc-photo-editor__footer {
  justify-content: flex-end;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.tsc-photo-editor__header h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
  line-height: 1.3;
}

.tsc-photo-editor__filename {
  max-width: min(70vw, 620px);
  margin: 4px 0 0;
  overflow: hidden;
  color: #bdbdbd;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tsc-photo-editor__body {
  display: grid;
  min-height: 0;
  flex: 1 1 auto;
  grid-template-columns: minmax(0, 1fr) 310px;
  overflow: auto;
}

.tsc-photo-editor__stage {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: #080808;
}

.tsc-photo-editor__stage canvas {
  display: block;
  width: 100%;
  max-width: 720px;
  height: auto;
  max-height: calc(100dvh - 190px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  background: #111;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  cursor: grab;
  touch-action: none;
}

.tsc-photo-editor__stage canvas[data-mode="mark"] {
  cursor: crosshair;
}

.tsc-photo-editor__controls {
  min-width: 0;
  overflow-y: auto;
  border-left: 1px solid rgba(255, 255, 255, 0.14);
  padding: 20px;
  background: #202020;
}

.tsc-photo-editor__segment {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 20px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
}

.tsc-photo-editor__segment button {
  min-height: 42px;
  border: 0;
  background: #292929;
  color: #d1d1d1;
  font-weight: 700;
}

.tsc-photo-editor__segment button[aria-pressed="true"] {
  background: #d62828;
  color: #fff;
}

.tsc-photo-editor__control-group {
  display: grid;
  gap: 10px;
}

.tsc-photo-editor__control-group[hidden] {
  display: none;
}

.tsc-photo-editor__control-group label,
.tsc-photo-editor__label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
  color: #f4f4f4;
  font-size: 13px;
  font-weight: 700;
}

.tsc-photo-editor__control-group output {
  color: #f4c430;
  font-variant-numeric: tabular-nums;
}

.tsc-photo-editor input[type="range"] {
  width: 100%;
  accent-color: #f4c430;
}

.tsc-photo-editor__swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 4px;
}

.tsc-photo-editor__swatches button {
  width: 36px;
  height: 36px;
  border: 2px solid transparent;
  border-radius: 50%;
  background: var(--swatch);
}

.tsc-photo-editor__swatches button[data-colour="#ef4444"] { --swatch: #ef4444; }
.tsc-photo-editor__swatches button[data-colour="#facc15"] { --swatch: #facc15; }
.tsc-photo-editor__swatches button[data-colour="#ffffff"] { --swatch: #ffffff; }
.tsc-photo-editor__swatches button[data-colour="#111111"] { --swatch: #111111; border-color: rgba(255, 255, 255, 0.35); }

.tsc-photo-editor__swatches button.is-active {
  outline: 3px solid #f4c430;
  outline-offset: 2px;
}

.tsc-photo-editor__button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 6px;
}

.tsc-photo-editor button {
  cursor: pointer;
  font: inherit;
}

.tsc-photo-editor button:focus-visible,
.tsc-photo-editor input:focus-visible {
  outline: 2px solid #f4c430;
  outline-offset: 2px;
}

.tsc-photo-editor__icon-button {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  background: #242424;
  color: #fff;
  font-weight: 800;
}

.tsc-photo-editor__primary,
.tsc-photo-editor__secondary {
  min-height: 44px;
  border-radius: 6px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 800;
}

.tsc-photo-editor__primary {
  border: 1px solid #d62828;
  background: #d62828;
  color: #fff;
}

.tsc-photo-editor__primary:hover {
  background: #b91c1c;
}

.tsc-photo-editor__primary:disabled {
  cursor: wait;
  opacity: 0.65;
}

.tsc-photo-editor__secondary {
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: #292929;
  color: #f4f4f4;
}

.tsc-photo-editor__secondary:hover,
.tsc-photo-editor__icon-button:hover {
  background: #353535;
}

.tsc-photo-editor-error {
  margin: 12px 0 0;
  color: #ff8080;
  font-size: 13px;
  font-weight: 700;
}

@media (max-width: 820px) {
  .tsc-photo-editor {
    padding: 0;
  }

  .tsc-photo-editor__panel {
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .tsc-photo-editor__header {
    padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  }

  .tsc-photo-editor__body {
    display: block;
    overflow-y: auto;
  }

  .tsc-photo-editor__stage {
    padding: 12px;
  }

  .tsc-photo-editor__stage canvas {
    max-height: none;
  }

  .tsc-photo-editor__controls {
    border-top: 1px solid rgba(255, 255, 255, 0.14);
    border-left: 0;
    padding: 16px;
  }

  .tsc-photo-editor__footer {
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  }
}
