/* =========================
   TTS PANEL (scoped to #tts)
   ========================= */

/* keep native dropdowns above panel glows */
#tts{
  position: relative;
  z-index: 3000;          /* above panel effects */
  overflow: visible;      /* allow native menus to escape */
  isolation: isolate;     /* its own stacking context */
  margin-top: 1rem;
}

/* -------------------------
   Toolbar grid
   row1: lang | voice
   row2: sliders
   row3: ocr
   row4: actions
   ------------------------- */
#tts .tts-toolbar{
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-areas:
    "lang   voice"
    "sliders sliders"
    "ocr     ocr"
    "actions actions";
  gap: 16px 20px;
  align-items: end;
  margin-bottom: 16px;
}

/* map areas (no HTML change required) */
#tts .tts-toolbar .field:nth-of-type(1){ grid-area: lang; }   /* Language */
#tts .tts-toolbar .field:nth-of-type(2){ grid-area: voice; }  /* Voice    */
#tts .tts-toolbar .sliders{ grid-area: sliders; }
#tts .tts-toolbar .ocr{ grid-area: ocr; }
#tts .tts-toolbar .actions{ grid-area: actions; }

/* -------------------------
   Field/Select styling (inside TTS)
   ------------------------- */
#tts .field label{ display:block; margin-bottom:.4rem; opacity:.9; }

#tts .field select{
  appearance: none;
  height: 44px;
  width: 100%;
  background: linear-gradient(180deg, rgba(12,18,26,.85), rgba(10,16,24,.85));
  border: 1px solid rgba(120,200,255,.18);
  color: #e8f6ff;
  border-radius: 12px;
  padding: 0 .9rem;
  outline: none;
  box-shadow:
    inset 0 0 0 1px rgba(0,255,255,.02),
    0 0 0 1px rgba(0,0,0,.2);
  position: relative;
  z-index: 3001; /* keep above glow */
  background-image:
    linear-gradient(45deg, transparent 50%, #9ed9ff 50%),
    linear-gradient(135deg, #9ed9ff 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 18px,
    calc(100% - 12px) 18px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

#tts textarea{
  width: 100%;
  background: rgba(10,15,22,.7);
  border: 1px solid rgba(120,200,255,.15);
  color: #e8f6ff;
  border-radius: 12px;
  padding: .75rem .9rem;
  outline: none;
  box-shadow: inset 0 0 0 1px rgba(0,255,255,.02);
  min-height: 160px;
  resize: none;
  overflow-y: hidden;
}

/* -------------------------
   Sliders row (custom range)
   ------------------------- */
#tts .sliders{
  display: flex;
  gap: 22px;
  align-items: center;
  justify-content: flex-start;
}
#tts .slider{ display:flex; align-items:center; gap:10px; white-space:nowrap; }
#tts .slider span{ min-width:110px; opacity:.9; }

/* base track size */
#tts input[type="range"]{
  -webkit-appearance:none; appearance:none;
  width:260px; height:10px;
  background: transparent;
}

/* WebKit track */
#tts input[type="range"]::-webkit-slider-runnable-track{
  height:10px; border-radius:999px;
  background: linear-gradient(90deg, #0b2230, #0c2f44);
  box-shadow: inset 0 0 0 1px rgba(120,200,255,.2), 0 0 8px rgba(0,180,255,.1);
}

/* WebKit thumb */
#tts input[type="range"]::-webkit-slider-thumb{
  -webkit-appearance:none; appearance:none;
  width:18px; height:18px; margin-top:-4px; border-radius:50%;
  background:#9fe8ff;
  border:1px solid rgba(0,180,255,.6);
  box-shadow: 0 0 10px rgba(0,200,255,.6);
}

/* Firefox track */
#tts input[type="range"]::-moz-range-track{
  height:10px; border-radius:999px;
  background: linear-gradient(90deg, #0b2230, #0c2f44);
  box-shadow: inset 0 0 0 1px rgba(120,200,255,.2), 0 0 8px rgba(0,180,255,.1);
}
/* Firefox thumb */
#tts input[type="range"]::-moz-range-thumb{
  width:18px; height:18px; border-radius:50%;
  background:#9fe8ff;
  border:1px solid rgba(0,180,255,.6);
  box-shadow: 0 0 10px rgba(0,200,255,.6);
}

/* -------------------------
   OCR row — flush-left under sliders
   ------------------------- */
#tts .ocr{
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  gap:14px 18px;
  justify-content:flex-start;
}

/* label + live status on one line */
#tts .ocr .label-row{
  flex-basis:100%;
  display:flex;
  align-items:center;
  gap:10px;
  justify-content:flex-start;
  margin-bottom:2px;
}
#tts #ttsOCRStatus{ font-size:.95rem; opacity:.85; }

/* styled file input + extract button side-by-side */
#tts .file{ display:inline-flex; align-items:center; gap:12px; padding:0; }
#tts .file input[type="file"]{
  position:absolute; width:1px; height:1px; overflow:hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space:nowrap; border:0; padding:0; margin:-1px;
}
#tts .file .file__btn{
  display:inline-flex; align-items:center; justify-content:center;
  height:42px; min-width:110px; padding:0 .9rem; border-radius:10px;
  background: linear-gradient(180deg,#0b2a3a,#081a24);
  border:1px solid rgba(120,200,255,.2); color:#cfefff; cursor:pointer;
  box-shadow: 0 0 8px rgba(0,200,255,.08);
  transition: transform .08s ease, box-shadow .2s ease;
}
#tts .file .file__btn:hover{ transform: translateY(-1px); box-shadow: 0 10px 25px rgba(0,200,255,.15); }
#tts .file .file__name{ min-height:42px; display:inline-flex; align-items:center; opacity:.8; }

#tts .ocr #ttsOCR{ margin-left:8px; flex-shrink:0; } /* Extract right after file */

/* -------------------------
   Actions row + unified buttons
   ------------------------- */
#tts .actions.btn-row{ display:flex; gap:10px; flex-wrap:wrap; }

#tts .btn,
#tts .file .file__btn{
  display:inline-flex; align-items:center; justify-content:center;
  min-width:110px; height:42px; padding:0 .9rem;
  border-radius:10px; font-size:.95rem; font-weight:600; line-height:1;
  transition: transform .1s ease, box-shadow .2s ease, background .2s ease;
  cursor:pointer;
}
#tts .btn:hover{ transform:translateY(-1px); box-shadow:0 0 15px rgba(0,200,255,.25); }

/* -------------------------
   Responsive
   ------------------------- */
@media (max-width:980px){
  #tts .tts-toolbar{
    grid-template-columns:1fr;
    grid-template-areas:
      "lang"
      "voice"
      "sliders"
      "ocr"
      "actions";
  }
  #tts input[type="range"]{ width:200px; }
}
/* ============================================
   Neon Upgrades for TTS Buttons
   ============================================ */

/* --- PLAY (Primary) --- */
#tts .btn-primary {
  background: radial-gradient(
    circle at 50% -40%,
    rgba(0, 255, 255, 0.35) 0%,
    rgba(0, 160, 255, 0.25) 45%,
    rgba(0, 100, 255, 0.2) 100%
  );
  color: #e6fbff;
  border: 1px solid rgba(0, 240, 255, 0.6);
  box-shadow:
    0 0 10px rgba(0, 240, 255, 0.75),
    0 0 25px rgba(0, 180, 255, 0.65),
    0 0 55px rgba(0, 180, 255, 0.4),
    inset 0 0 10px rgba(0, 255, 255, 0.2);
  text-shadow: 0 0 6px rgba(0, 255, 255, 0.8);
  transition: all 0.25s ease;
}
#tts .btn-primary:hover {
  background: radial-gradient(
    circle at 50% -40%,
    rgba(0, 255, 255, 0.55) 0%,
    rgba(0, 180, 255, 0.45) 40%,
    rgba(0, 120, 255, 0.35) 100%
  );
  box-shadow:
    0 0 15px rgba(0, 255, 255, 0.85),
    0 0 35px rgba(0, 200, 255, 0.75),
    0 0 65px rgba(0, 180, 255, 0.55),
    inset 0 0 12px rgba(255, 255, 255, 0.15);
  transform: translateY(-2px) scale(1.03);
}
#tts .btn-primary:active {
  transform: scale(0.97);
  box-shadow:
    0 0 10px rgba(0, 255, 255, 0.6),
    0 0 25px rgba(0, 180, 255, 0.5);
}

/* --- STOP (Danger) --- */
#tts .btn-danger {
  background: radial-gradient(
    circle at 50% -40%,
    rgba(255, 90, 90, 0.3) 0%,
    rgba(255, 40, 40, 0.25) 40%,
    rgba(180, 0, 0, 0.2) 100%
  );
  color: #fff;
  border: 1px solid rgba(255, 100, 100, 0.6);
  box-shadow:
    0 0 10px rgba(255, 50, 50, 0.7),
    0 0 30px rgba(255, 30, 30, 0.5),
    inset 0 0 8px rgba(255, 100, 100, 0.3);
  text-shadow: 0 0 6px rgba(255, 60, 60, 0.8);
  transition: all 0.25s ease;
}
#tts .btn-danger:hover {
  background: radial-gradient(
    circle at 50% -40%,
    rgba(255, 120, 120, 0.45) 0%,
    rgba(255, 60, 60, 0.35) 40%,
    rgba(180, 0, 0, 0.25) 100%
  );
  box-shadow:
    0 0 20px rgba(255, 80, 80, 0.9),
    0 0 45px rgba(255, 40, 40, 0.7);
  transform: translateY(-2px) scale(1.03);
}
#tts .btn-danger:active {
  transform: scale(0.97);
  box-shadow:
    0 0 10px rgba(255, 60, 60, 0.6),
    0 0 25px rgba(255, 30, 30, 0.5);
}

/* --- CLEAR (Ghost) --- */
#tts .btn-ghost {
  background: radial-gradient(
    circle at 50% -40%,
    rgba(0, 180, 200, 0.15) 0%,
    rgba(0, 120, 160, 0.12) 45%,
    rgba(0, 80, 120, 0.1) 100%
  );
  color: #d8faff;
  border: 1px solid rgba(100, 200, 255, 0.35);
  box-shadow:
    0 0 8px rgba(0, 200, 255, 0.25),
    inset 0 0 6px rgba(0, 255, 255, 0.1);
  text-shadow: 0 0 4px rgba(0, 255, 255, 0.6);
  transition: all 0.25s ease;
}
#tts .btn-ghost:hover {
  box-shadow:
    0 0 12px rgba(0, 240, 255, 0.5),
    0 0 30px rgba(0, 180, 255, 0.35),
    inset 0 0 8px rgba(0, 255, 255, 0.2);
  transform: translateY(-2px) scale(1.02);
}
#tts .btn-ghost:active {
  transform: scale(0.97);
  box-shadow: 0 0 12px rgba(0, 220, 255, 0.4);
}

@keyframes neonPulse {
  0%, 100% { filter: brightness(1) saturate(1); }
  50% { filter: brightness(1.15) saturate(1.1); }
}

#tts .btn-primary,
#tts .btn-danger,
#tts .btn-ghost {
  animation: neonPulse 2.5s infinite ease-in-out;
}

/* Dark themed popup list for dropdowns (WebKit/Chromium & Firefox) */
#tts select {
  color-scheme: dark; /* tells browsers to render native menus dark */
}

/* Safari/WebKit fix – darker dropdown panel */
@supports (-webkit-appearance: none) {
  #tts select option {
    background-color: #0a1018;
    color: #e8f6ff;
  }
}

/* Firefox fallback */
@-moz-document url-prefix() {
  #tts select option {
    background-color: #0a1018;
    color: #e8f6ff;
  }
}

/* --- Snip overlay --- */
.snip-overlay{
  position:fixed; inset:0;
  z-index:9999;
  background: rgba(0,0,0,0.35); /* dim the page */
  display:flex; align-items:center; justify-content:center;
}

.snip-stage {
  position: relative;
  max-width: 95vw;
  max-height: 95vh;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.1), 0 25px 80px rgba(0,0,0,0.5);
}

.snip-canvas {
  display: block;
  max-width: 95vw;
  max-height: 95vh;
  image-rendering: pixelated;
}

.snip-hint {
  position: fixed;
  left: 50%;
  top: 24px;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.6);
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 12px;
  color: #fff;
  pointer-events: none;
  box-shadow: 0 0 20px rgba(0,0,0,0.35);
}

.snip-toolbar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
}

.snip-toolbar .btn {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(20,20,28,0.9);
  color: #fff;
  backdrop-filter: blur(6px);
}
.tts-capture-overlay{
  position: fixed !important;
  inset: 0 !important;
  z-index: 2147483647 !important; /* sit above everything */
  display: flex !important;
  align-items: center;
  justify-content: center;
  background: rgba(7,16,28,.65);
  backdrop-filter: blur(2px);
}

.tts-capture-stage{
  position: relative;
  max-width: 92vw;
  max-height: 82vh;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0,0,0,.55),
              0 0 0 1px rgba(0,255,255,.25) inset;
  background: #000;
}

.tts-capture-stage img{
  display:block;
  max-width: 92vw;
  max-height: 82vh;
}

.tts-capture-toolbar{
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display:flex;
  gap: 12px;
  padding: 10px 12px;
  background: rgba(0,10,20,.78);
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(0,0,0,.45);
  border: 1px solid rgba(0,255,255,.25);
}

.tts-btn{
  font: inherit;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid rgba(0,255,255,.35);
  background: rgba(0,24,36,.9);
  color: #dffbff;
  cursor: pointer;
}

.tts-btn:focus-visible{ box-shadow: 0 0 0 3px rgba(255,255,255,.15); }

.tts-btn.primary{ border-color: rgba(0,255,255,.6); box-shadow: 0 0 12px rgba(0,255,255,.35); }
.tts-btn.primary:hover{ transform: translateY(-1px); }
.tts-btn.primary:active{ transform: translateY(0); filter: brightness(.95); }

.tts-btn.ghost{
  color: var(--text);
  background: transparent;
  border: 1px solid rgba(255,255,255,.16);
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
}
.tts-btn.ghost:hover{ background: rgba(255,255,255,.06); }

/* Selection rectangle + handles */
.tts-select-rect{
  position: absolute;
  border: 2px solid rgba(0,255,255,.95);
  border-radius: 8px;
  background: rgba(0,180,220,.08);
  box-shadow: 0 0 18px rgba(0,255,255,.35),
              inset 0 0 12px rgba(0,255,255,.2);
  pointer-events: none;
}

.tts-handle{
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--brand); box-shadow: 0 0 14px var(--brand-weak);
  position: absolute; transform: translate(-50%, -50%);
  pointer-events: all;
}

/* Optional danger style if you add a “Stop” or abort state later */
.tts-btn.danger{
  background: var(--danger); color: #140202;
  box-shadow: 0 0 22px var(--danger-weak), 0 6px 16px rgba(0,0,0,.35);
}