body {
  box-sizing: border-box;
  width: min(100%, 750px);
  margin: 0 auto;
  padding: 16px;
  font-family: sans-serif;
}

h1 {
  margin: 0 0 12px;
  font-size: 24px;
  font-weight: 600;
  line-height: 1.3;
  color: #523F38;
}

*,
*::before,
*::after {
  box-sizing: inherit;
}

button,
input,
label {
  font: inherit;
}

button,
.file-select-button {
  -webkit-tap-highlight-color: transparent;
}

.editor-area {
  position: relative;
  width: 100%;
  max-height: min(65vh, 560px);
  overflow: auto;
  border: 1px solid rgba(76, 84, 84, 0.12);
  border-radius: 12px;
  background: #FFFFFF;
  margin-bottom: 12px;
}

canvas {
  display: block;
  width: 100%;
  max-width: none;
  height: auto;
}

.file-select-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 48px;
  padding: 0 16px;
  margin-bottom: 12px;
  border: 1px solid #4C5454;
  border-radius: 999px;
  background: #FFFFFF;
  color: #4C5454;
  cursor: pointer;
  transition: background-color 0.2s ease;
  white-space: nowrap;
}

.file-select-button:hover {
  background: rgba(30, 168, 150, 0.08);
}

.file-select-button .material-symbols-outlined {
  font-size: 20px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.top-actions .file-select-button {
  margin-bottom: 0;
}

.top-actions > * {
  align-self: center;
}

.top-actions {
  min-height: 48px;
}

.top-actions button,
.top-actions .file-select-button {
  margin-top: 0;
  margin-bottom: 0;
}

#detectPrivacyButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  min-height: 48px;
  padding: 0 16px;
  margin: 0;
  border: 1px solid #4C5454;
  border-radius: 999px;
  background: #FFFFFF;
  color: #4C5454;
  line-height: 1;
  vertical-align: middle;
  white-space: nowrap;
}

.editor-area canvas {
  border-radius: 11px;
}

.crop-overlay {
  position: absolute;
  left: 50px;
  top: 50px;
  width: 200px;
  height: 150px;
  border: 2px solid #1EA896;
  background: rgba(30, 168, 150, 0.12);
  cursor: move;
  box-sizing: border-box;
  z-index: 10;
  touch-action: none;
}

.tool-panel {
  display: grid;
  gap: 12px;
  margin: 16px 0;
}

.editor-tabs {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border: 1px solid #4C5454;
  border-radius: 12px;
  background: #FFFFFF;
  overflow: hidden;
}

.editor-tabs::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: calc((100% - 16px) / 3);
  height: calc(100% - 8px);
  border-radius: 8px;
  background: #1EA896;
  transition: transform 0.2s ease;
  z-index: 0;
}

.editor-tabs:has(.tab-button:nth-child(2).is-active)::before {
  transform: translateX(calc(100% + 4px));
}

.editor-tabs:has(.tab-button:nth-child(3).is-active)::before {
  transform: translateX(calc((100% + 4px) * 2));
}

.tab-button {
  position: relative;
  z-index: 1;
  min-width: 0;
  padding: 10px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #4C5454;
  font-size: 14px;
  white-space: nowrap;
  transition: color 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.tab-button.is-active {
  color: #fff;
}

.tab-button .material-symbols-outlined {
  font-size: 20px;
}

#saveButton,
#resetButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  line-height: 1;
}

#saveButton .material-symbols-outlined,
#resetButton .material-symbols-outlined {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  line-height: 1;
}

.tab-content {
  border: 1px solid #4C5454;
  border-radius: 12px;
  padding: 12px;
  background: #fff;
  overflow: hidden;
}

label {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.blur-mode-switch {
  display: flex;
  gap: 4px;
  margin-top: 12px;
  padding: 4px;
  border-radius: 999px;
  background: #FFFFFF;
}

.blur-mode-switch button {
  flex: 1;
  padding: 10px 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-size: 16px;
}

.blur-mode-switch button.is-active {
  background: #1EA896;
  color: #fff;
}

.tool-buttons {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  margin-top: 12px;
  padding-bottom: 4px;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

.tool-buttons::-webkit-scrollbar {
  display: none;
}

.tool-buttons button {
  flex: 0 0 auto;
  width: auto;
  min-width: 100px;
  margin-top: 0;
  padding: 12px 16px;
  border: 1px solid #4C5454;
  border-radius: 10px;
  background: #FFFFFF;
  color: #4C5454;
  font-size: 16px;
  white-space: nowrap;
  line-height: 1;
}

input[type="range"] {
  --range-progress: 50%;
  width: 100%;
  appearance: none;
  background: transparent;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    #1EA896 0%,
    #1EA896 var(--range-progress),
    rgba(76, 84, 84, 0.18) var(--range-progress),
    rgba(76, 84, 84, 0.18) 100%
  );
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  margin-top: -10px;
  border: 1px solid rgba(76, 84, 84, 0.16);
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 2px 8px rgba(82, 63, 56, 0.22);
}

input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(76, 84, 84, 0.18);
}

input[type="range"]::-moz-range-progress {
  height: 8px;
  border-radius: 999px;
  background: #1EA896;
}

input[type="range"]::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border: 1px solid rgba(76, 84, 84, 0.16);
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 2px 8px rgba(82, 63, 56, 0.22);
}

.action-buttons {
  align-items: center;
}

.action-buttons button {
  min-width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#applyCropButton {
  min-width: 120px;
  background: #FF715B;
  border-color: #FF715B;
  color: #FFFFFF;
  font-weight: bold;
}

#undoButton,
#redoButton {
  width: 48px;
  padding: 0;
  border-radius: 50%;
}

.material-symbols-outlined {
  font-size: 28px;
  line-height: 1;
}


.zoom-controls {
  display: grid;
  grid-template-columns: 48px 1fr 48px auto;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}

.zoom-controls label {
  margin-top: 0;
}

.zoom-controls button {
  height: 48px;
  min-width: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid #4C5454;
  border-radius: 999px;
  background: #FFFFFF;
  color: #4C5454;
  font-size: 15px;
}

#zoomResetButton {
  min-width: 64px;
  padding: 0 14px;
}

#loadingOverlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.9);
  z-index: 9999;
}

#loadingOverlay[hidden] {
  display: none;
}

#loadingOverlay p {
  margin: 0;
  font-size: 16px;
  color: #4C5454;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(76, 84, 84, 0.2);
  border-top-color: #1EA896;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}