:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #9fd4ff;
  color: #3a2b16;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
}

button,
select,
input,
a {
  font: inherit;
}

.zooApp {
  position: relative;
  width: 100vw;
  height: 100vh;
  background: #9fd4ff;
}

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

.toolbar {
  position: absolute;
  top: 72px;
  left: 18px;
  right: auto;
  max-width: min(620px, calc(100vw - 36px));
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  pointer-events: auto;
  transition:
    opacity 180ms ease,
    transform 180ms ease,
    visibility 180ms ease;
}

.toolbar button,
.toolbar select,
.fileButton,
.navButton,
.rangeControl,
.status {
  border: 3px solid rgba(255, 255, 255, 0.78);
  border-radius: 18px;
  background: rgba(255, 250, 218, 0.92);
  color: #4a3219;
  box-shadow:
    0 7px 0 rgba(91, 61, 28, 0.14),
    0 14px 28px rgba(77, 98, 45, 0.16);
  backdrop-filter: blur(10px);
}

.toolbar span,
.status span {
  color: #6f583a;
  font-size: 12px;
}

.toolbar button,
.toolbar select,
.fileButton,
.navButton,
.rangeControl {
  min-height: 42px;
  padding: 0 15px;
  cursor: pointer;
  pointer-events: auto;
  font-weight: 800;
}

.navButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  background: #ffb45c;
}

.toolbar button {
  background: #ffcf5c;
}

.toolbar select {
  min-width: 132px;
  background: #c3f28f;
}

.fileButton {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #ff9fc7;
}

.cameraButton {
  background: #a9e7ff;
}

.cameraButton svg {
  width: 25px;
  height: 25px;
  flex: 0 0 auto;
}

.cameraButton path,
.cameraButton circle,
.floatingCamera path,
.floatingCamera circle {
  fill: none;
  stroke: #31536a;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.floatingCamera {
  display: none;
}

.floatingCamera input {
  display: none;
}

.menuToggle {
  position: absolute;
  top: 18px;
  left: 18px;
  z-index: 2;
  min-height: 44px;
  padding: 0 18px;
  border: 3px solid rgba(255, 255, 255, 0.82);
  border-radius: 22px;
  background: #fff1a8;
  color: #3f7d35;
  box-shadow:
    0 7px 0 rgba(91, 61, 28, 0.14),
    0 14px 28px rgba(77, 98, 45, 0.16);
  cursor: pointer;
  font-weight: 900;
  pointer-events: auto;
}

.toolbar.isClosed {
  visibility: hidden;
  opacity: 0;
  transform: translateY(-8px) scale(0.98);
  pointer-events: none;
}

.rangeControl {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: #bfefff;
  color: #4a3219;
  font-size: 12px;
}

.rangeControl input {
  width: 118px;
  accent-color: #ff8a3d;
}

.fileButton input {
  display: none;
}

.status {
  position: absolute;
  right: 18px;
  bottom: 18px;
  display: flex;
  gap: 14px;
  padding: 10px 14px;
}

.processingOverlay {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(112, 190, 255, 0.22);
  pointer-events: auto;
}

.processingOverlay[hidden] {
  display: none;
}

.processingCard {
  width: min(320px, 100%);
  border: 4px solid rgba(255, 255, 255, 0.88);
  border-radius: 22px;
  padding: 18px;
  background: #fff8c6;
  color: #4a3219;
  box-shadow:
    0 9px 0 rgba(91, 61, 28, 0.14),
    0 18px 34px rgba(45, 83, 92, 0.24);
}

.processingCard strong {
  display: block;
  margin-bottom: 12px;
  font-size: 18px;
}

.progressTrack {
  width: 100%;
  height: 18px;
  overflow: hidden;
  border: 3px solid rgba(74, 50, 25, 0.16);
  border-radius: 999px;
  background: #ffffff;
}

.progressTrack span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff9fc7, #ffcf5c, #9fe870);
  transition: width 160ms ease;
}

.progressText {
  display: block;
  margin-top: 10px;
  color: #6f583a;
  font-size: 13px;
  font-weight: 800;
}

.manualCutout {
  position: fixed;
  inset: 0;
  z-index: 7;
  display: grid;
  place-items: center;
  padding: 14px;
  background: rgba(66, 91, 115, 0.42);
}

.manualCutout[hidden] {
  display: none;
}

.manualPanel {
  width: min(760px, 100%);
  max-height: calc(100vh - 28px);
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 10px;
  border: 4px solid rgba(255, 255, 255, 0.9);
  border-radius: 22px;
  padding: 12px;
  background: #fff8c6;
  box-shadow:
    0 9px 0 rgba(91, 61, 28, 0.14),
    0 18px 34px rgba(45, 83, 92, 0.28);
}

.manualCanvasWrap {
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 16px;
  background: #ffffff;
}

#manualCutoutCanvas {
  max-width: 100%;
  max-height: min(68vh, 620px);
  touch-action: none;
}

.manualTools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.manualHint {
  flex: 1 1 100%;
  color: #6f583a;
  font-size: 13px;
  font-weight: 900;
}

.manualTools button,
.manualTools label {
  min-height: 40px;
  border: 0;
  border-radius: 14px;
  padding: 0 12px;
  font-weight: 900;
}

.manualTools button {
  cursor: pointer;
  background: #ffcf5c;
  color: #4a3219;
}

.manualTools button.isActive {
  background: #9fe870;
  color: #315522;
}

.manualTools label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #bfefff;
  color: #4a3219;
}

.manualTools .checkboxTool {
  background: #ffe29b;
}

.manualTools input {
  width: 96px;
  accent-color: #ff8a3d;
}

.manualTools .checkboxTool input {
  width: 20px;
  height: 20px;
}

@media (max-width: 720px) {
  .toolbar {
    top: 72px;
    left: 12px;
    right: 12px;
    max-width: none;
    align-items: stretch;
    gap: 10px;
  }

  .toolbar button,
  .toolbar select,
  .fileButton,
  .navButton,
  .rangeControl {
    flex: 1 1 calc(50% - 10px);
    justify-content: center;
  }

  .toolbar .cameraButton {
    display: none;
  }

  .floatingCamera {
    position: fixed;
    right: 14px;
    bottom: 14px;
    z-index: 4;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    border: 3px solid rgba(255, 255, 255, 0.86);
    border-radius: 50%;
    background: linear-gradient(135deg, #ffffff, #9ee9ff);
    box-shadow:
      0 8px 0 rgba(36, 92, 116, 0.18),
      0 16px 30px rgba(35, 76, 94, 0.22);
    pointer-events: auto;
  }

  .floatingCamera svg {
    width: 38px;
    height: 38px;
  }

  .menuToggle {
    left: 12px;
    top: 12px;
  }

  .status {
    left: 12px;
    bottom: 12px;
    right: auto;
    flex-direction: column;
    gap: 4px;
  }

  .processingCard {
    align-self: end;
    margin-bottom: 92px;
  }

  .manualPanel {
    align-self: end;
    max-height: calc(100vh - 24px);
  }

  .manualTools button,
  .manualTools label {
    flex: 1 1 calc(50% - 8px);
    justify-content: center;
  }
}

.listBody {
  min-height: 100vh;
  overflow: auto;
  background:
    linear-gradient(#9fd4ff 0 44%, #7fca5b 44% 100%);
}

.listPage {
  width: min(980px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 18px 0 48px;
}

.listHeader {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 56px;
}

.listHeader h1 {
  margin: 0;
  color: #3f7d35;
  font-size: 28px;
  letter-spacing: 0;
}

.characterGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 16px;
}

.characterCard,
.emptyState {
  border: 3px solid rgba(255, 255, 255, 0.82);
  border-radius: 18px;
  background: rgba(255, 250, 218, 0.94);
  box-shadow:
    0 7px 0 rgba(91, 61, 28, 0.14),
    0 14px 28px rgba(77, 98, 45, 0.16);
}

.characterCard {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.characterCard img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: 14px;
  background: #ffffff;
}

.characterCard strong {
  color: #4a3219;
  overflow-wrap: anywhere;
}

.characterCard span {
  color: #6f583a;
  font-size: 13px;
}

.characterCard button {
  min-height: 40px;
  border: 0;
  border-radius: 14px;
  font-weight: 900;
  cursor: pointer;
}

.characterActions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.characterActions button:first-child {
  background: #9fe870;
  color: #315522;
}

.characterActions button:last-child {
  background: #ff8c9e;
  color: #5b1d2a;
}

.characterActions button:disabled {
  cursor: progress;
  opacity: 0.72;
}

.emptyState {
  grid-column: 1 / -1;
  margin: 0;
  padding: 24px;
  color: #6f583a;
  font-weight: 800;
}
