body {
  margin: 0;
  overflow: hidden;
  font-family: sans-serif;
}

#mainImage { z-index: 1; }
#drawLayer { z-index: 5; }
#tagLayer  { z-index: 10; }

@media (max-width: 768px) {
  /* phones */
}

@media (max-width: 768px) {
  #thumbnailBar {
    height: 50px;
    padding: 6px;
    gap: 6px;
  }
}

@media (max-width: 768px) {
  #toolbar {
    right: 6px;
    gap: 6px;
    padding: 6px;
	
	max-height: 75vh;
  }

  #toolbar button {
    font-size: 12px;
    padding: 8px;
  }
}

@media (max-width: 768px) {
  #inspector {
    bottom: 60px;

    max-height: 70vh;   /* 👈 prevent overflow */
    overflow-y: auto;   /* 👈 allow scrolling inside */

    width: 180px;
    padding: 10px;
  }

  #inspector input,
  #inspector select {
    font-size: 12px;
  }
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  touch-action: manipulation;
}

#mainImage {
  width: 100%;
  height: 100%;
  object-fit: contain;
  z-index: 1;
}

#tagLayer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  touch-action: none;
}

html, body {
  touch-action: manipulation;
  height: 100%;
  overflow: hidden;
}

button {
  padding: 12px 16px;
  font-size: 16px;
  touch-action: manipulation;
}

#toolbarToggle {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);

  z-index: 100000;

  padding: 10px 14px;
  border-radius: 10px;

  background: rgba(0,0,0,0.4); /* 👈 semi-transparent */
  color: white;
  border: 1px solid rgba(255,255,255,0.2);

  backdrop-filter: blur(4px); /* 👈 nice modern touch (optional) */

  opacity: 0.6;              /* 👈 subtle by default */
  transition: opacity 0.2s ease;

  display: none;
}

#toolbarToggle:hover,
#toolbarToggle:active {
  transform: translateX(-50%) scale(0.95);
  opacity: 1;
}

#drawLayer {
  position: absolute;
  top: 0;
  left: 0;

  width: 100%;
  height: 100%;

  z-index: 5;

  touch-action: none;
}

#tagVisibilitySelect {
  appearance: none;
  -webkit-appearance: none;

  background: rgba(128,128,128,0.8);
  color: white;

  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 12px;

  padding: 10px 38px 10px 14px;

  font-size: 15px;

  backdrop-filter: blur(10px);

  cursor: pointer;

  outline: none;

  transition:
    background 0.2s ease,
    border 0.2s ease;
}

#tagVisibilitySelect:hover {
  background: rgba(128,128,128,0.8);
}

#tagVisibilitySelect:focus {
  border-color: rgba(0,150,255,0.8);
}

#tagVisibilityWrapper {
  position: relative;
  display: inline-block;
}

#tagVisibilityWrapper::after {
  content: "⌄";

  position: absolute;
  right: 12px;
  top: 50%;

  transform: translateY(-50%);

  color: white;

  pointer-events: none;
}

#tooltip {
  position: fixed;
  z-index: 999999;

  left: 50%;
  top: 50%;

  transform: translate(-50%, -50%) scale(0.95);

  background: rgba(0,0,0,0.9);
  color: white;

  padding: 16px 22px;
  border-radius: 16px;

  font-size: 18px;
  line-height: 1.4;
  text-align: center;

  max-width: 320px;

  pointer-events: none;

  opacity: 0;

  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

#tooltip.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

#exportSummary {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 99999;
}

#exportSummary.hidden {
  display: none;
}

.export-box {
  background: #222;
  color: white;
  padding: 20px;
  border-radius: 16px;
  width: 260px;
  text-align: center;
}

.export-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 15px;
}

.tag {
  position: absolute;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  touch-action: none;
  overflow: hidden;
  transition: all 0.2s ease;
}

.ripple {
  position: absolute;
  border-radius: 50%;
  transform: scale(0);
  background: rgba(41,193,217,0.5);
  animation: rippleAnim 0.5s ease-out;
  pointer-events: none;
}

@keyframes rippleAnim {
  to {
    transform: scale(3);
    opacity: 0;
  }
}

.tag-label {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  text-align: center;
  font-size: 14px;
  color: white;
  background: rgba(0,0,0,0.4);
  pointer-events: none;
}

#tagTextInput {
  padding: 8px;
  font-size: 14px;
  width: 90%;
}

#tagTextEditor {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
}

#playTextDisplay {
  position: absolute;
  top: 10px;              /* 👈 move to top */
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;

  font-size: 24px;
  color: white;
  background: rgba(0,0,0,0.6);
  padding: 10px 20px;
  border-radius: 10px;

  display: none;

  opacity: 0;
  transition: opacity 0.4s ease;
}

#startScreen {
  position: absolute;
  inset: 0;
  background: black;
  color: white;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;

  z-index: 9999;
  cursor: pointer;
}

#splashLogo {
  width: 160px;
  height: 160px;
  border-radius: 20px;
}

#splashText {
  font-size: 24px;
  font-weight: bold;
}

#splashSub {
  font-size: 14px;
  opacity: 0.7;
}

#startScreen.hidden {
  display: none;
}

#editorToggle {
  position: absolute;
  top: 0px;
  left: 0px;
  z-index: 10000;

  width: 100px;
  height: 100px;

  opacity: 0;           /* 👈 invisible */
  background: transparent;
  border: none;
  touch-action: none;
}

#editorToggle.holding {
  transform: scale(0.95);
  opacity: 0.7;
  transition: transform 0.2s, opacity 0.2s;
}

#holdIndicator {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 80px;
  height: 80px;
  z-index: 9999;

  border-radius: 50%;
  pointer-events: none;

  background: conic-gradient(
    rgba(0, 150, 255, 0.8) 0deg,
    rgba(0, 150, 255, 0.8) 0deg,
    transparent 0deg
  );

  opacity: 0;
  transition: opacity 0.2s;
}

#saveBtn {
  margin-top: 10px;
  background: #4caf50;
  color: white;
}

/* ===== TOOL GROUPS ===== */
.tool-group {
  display: flex;
  flex-direction: column;
  gap: 6px;

  padding: 6px;
  border-radius: 6px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
}

.tool-title {
  font-size: 14px;
  color: white;
  margin-bottom: 2px;
}

#pageIndicator {
  position: fixed;
  top: 0px;
  left: 10px;
  z-index: 50;

  background: rgba(0,0,0,0.6);
  color: white;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 14px;
}

#toolbar {
  position: fixed;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  
  z-index: 99999;

  display: none; /* default OFF */

  flex-direction: column;
  gap: 10px;

  max-height: 60vh;
  overflow-y: auto;

  background: rgba(0,0,0,0.8);
  padding: 10px;
  border-radius: 10px;
}

body.editor #toolbar {
  display: flex;
}

#toolbar button {
  padding: 10px;
  font-size: 14px;
  border-radius: 8px;
  border: none;
  background: #222;
  color: white;
  touch-action: manipulation;
}

.tool-group + .tool-group {
  margin-top: 6px;
}

#toolbar button.active {
  background: #4caf50;
}

/* Hover (desktop only, harmless on mobile) */
#toolbar button:hover {
  background: #333;
}

#playTextDisplay.show {
  opacity: 1;
}

.resize-handle {
  position: absolute;
  width: 16px;
  height: 16px;
  right: 0;
  bottom: 0;
  background: yellow;
  cursor: se-resize;
  display: none;
}

#inspector {
  position: fixed;
  bottom: 60px;
  left: 10px;
  z-index: 99999;

  background: rgba(0,0,0,0.8);
  color: white;

  padding: 15px;
  border-radius: 16px;

  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;

  flex-direction: column;
  gap: 10px;

  width: 240px;

  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

#inspector.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

body.editor #inspector {
  display: flex;
}

/* LABELS */
#inspector label {
  font-size: 13px;
  opacity: 0.8;
  margin-bottom: -4px;
}

/* TEXT INPUT */
#inspector input {
  width: 100%;

  background: rgba(255,255,255,0.12);
  color: white;

  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 12px;

  padding: 12px 14px;

  font-size: 16px;

  outline: none;

  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    transform 0.1s ease;
}

#inspector input:focus {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.35);
}

/* SELECT */
#inspector select {
  width: 100%;

  background: rgba(255,255,255,0.12);
  color: white;

  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 12px;

  padding: 12px 14px;

  font-size: 16px;

  outline: none;

  appearance: none;
  -webkit-appearance: none;

  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    transform 0.1s ease;
}

#inspector select:focus {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.35);
}

/* dropdown options */
#inspector option {
  color: black;
}

/* BUTTONS */
#inspector button {
  border: none;
  border-radius: 12px;

  background: rgba(255,255,255,0.12);
  color: white;

  padding: 12px;

  font-size: 15px;

  transition:
    background 0.15s ease,
    transform 0.08s ease;
}

#inspector button:active {
  transform: scale(0.97);
  background: rgba(255,255,255,0.2);
}

* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

#navLeft, #navRight {
  position: fixed;
  top: 25%;          /* 👈 centered vertically */
  height: 40%;       /* 👈 middle 50% of screen */
  width: 10%;        /* 👈 nice touch zone */
  z-index: 10000;
}

#navLeft {
  left: 0;
}

#navRight {
  right: 0;
}

#navLeft:active,
#navRight:active {
  background: rgba(255,255,255,0.1);
}

#navLeft,
#navRight {
  overflow: hidden;
  position: fixed;
  isolation: isolate;
}

.navRipple {
  position: absolute;
  top: 50%;
  width: 120px;
  height: 120px;
  border-radius: 999px;

  background: rgba(0,255,233,0.6);

  filter: blur(4px);

  transform: translateY(-50%) scale(0.2);
  opacity: 0;

  pointer-events: none;
}

#navLeft .navRipple {
  left: -60px;
}

#navRight .navRipple {
  right: -60px;
}

.navRipple.animate {
  animation: navPulse 1.6s ease-out;
}

@keyframes navPulse {
  0% {
    opacity: 0;
    transform: translateY(-50%) scale(0.2);
  }

  25% {
    opacity: 0.7;
  }

  100% {
    opacity: 0;
    transform: translateY(-50%) scale(1.5);
  }
}

#thumbnailBar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 50px;
  background: rgba(0,0,0,0.6);

  display: flex;
  gap: 8px;
  padding: 8px;

  overflow-x: auto;
  overflow-y: hidden;

  z-index: 9999;

  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;

  scroll-snap-type: x mandatory;
  scroll-padding-inline: 50%;

  scrollbar-width: none;
  -ms-overflow-style: none;
}

#thumbnailBar::-webkit-scrollbar {
  display: none;
}

.thumbnail {
  height: 100%;
  aspect-ratio: 1.5;
  object-fit: cover;
  border: 2px solid transparent;
  border-radius: 6px;

  transition: border-color 0.15s ease; /* 👈 ONLY border animates */

  scroll-snap-align: center;

  will-change: transform; /* 👈 smooth GPU rendering */
}

.thumbnail.active {
  border-color: yellow;
}

#versionLabel {
  position: fixed;
  bottom: 5px;
  right: 8px;
  font-size: 10px;
  color: rgba(255,255,255,0.5);
  z-index: 99999;
}

#playAudioBtn {
  position: absolute;
  top: 5px;
  right: 10px;
  z-index: 9999;

  padding: 10px 14px;
  border-radius: 8px;

  background: rgba(0,0,0,0.6);
  color: white;
  border: 1px solid white;
}

#playFramesBtn {
  position: absolute;
  top: 50px;
  right: 10px;
  z-index: 9999;

  padding: 10px 14px;
  border-radius: 8px;

  background: rgba(0,0,0,0.6);
  color: white;
  border: 1px solid white;
}

#drawIndicator {
  position: absolute;
  top: 5px;
  right: 65px;
  z-index: 9999;

  padding: 10px 14px;
  border-radius: 8px;

  background: rgba(0,0,0,0.6);
  color: white;
  border: 1px solid white;
  font-size: 16px;
  opacity: 0.7;

  pointer-events: none; /* 👈 IMPORTANT */
  display: none;
  
  animation: drawPulse 5s infinite
}

@keyframes drawPulse {
  0% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1); opacity: 0.6; }
}

#albumScreen {
  position: fixed;
  inset: 0;
  background: #111;
  color: white;
  z-index: 10000;

  display: flex;
  flex-direction: column;
}

#albumHeader {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  padding: 12px;
}

#addAlbumBtn {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

#albumGrid {
  flex: 1;
  overflow-y: auto;

  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  padding: 12px;

  align-items: start;   /* 👈 THIS FIXES THE COLUMN STRETCH */
}

.album-card {
  background: #222;
  border-radius: 12px;
  padding: 10px;
  cursor: pointer;

  max-width: 180px;
  margin: 0 auto;

  display: flex;
  flex-direction: column;
  gap: 6px;
  
  align-self: start; /* extra safety */
}

.album-thumb {
  width: 100%;
  height: 90px;
  background: #333;
  border-radius: 8px;
  object-fit: cover;
}

.album-title {
  font-size: 14px;
  text-align: center;
}

.hidden {
  display: none !important;
}

#recordIndicator {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%); /* 👈 KEY CHANGE */

  z-index: 99999;

  display: flex;
  align-items: center;
  gap: 12px;

  background: rgba(0,0,0,0.75);
  color: white;
  padding: 14px 20px;
  border-radius: 24px;

  font-size: 18px; /* 👈 slightly bigger */
}

#recordIndicator.hidden {
  display: none;
}

#recordIndicator .dot {
  width: 14px;
  height: 14px;
  background: red;
  border-radius: 50%;

  animation: pulse 1s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.6; }
  100% { transform: scale(1); opacity: 1; }
}

#albumActionSheet {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 20000;

  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet-content {
  width: 100%;
  max-width: 400px;
  background: #222;
  border-radius: 16px 16px 0 0;
  padding: 12px;

  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sheet-content button {
  padding: 14px;
  font-size: 16px;
  border-radius: 10px;
  border: none;
  background: #444;
  color: white;
}

.sheet-content button:last-child {
  background: #666;
}

body.album-open #toolbar {
  display: none !important;
}

#albumsBtn {
  background: #2196f3;
}