/* === Icons === */
.icon {
  display: inline-block;
  width: 14px;
  height: 14px;
  vertical-align: middle;
  flex-shrink: 0;
}
.icon-lg {
  width: 22px;
  height: 22px;
}

/* === Reset & Base === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: #0a0a0a;
  color: #e0e0e0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  overflow: hidden;
  height: 100dvh;
  width: 100vw;
  display: flex;
  flex-direction: column;
}

/* === Viewer === */
#viewer {
  flex: 1;
  min-height: 0;
  position: relative;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Fill wrapper — holds companions + main media in a row */
#fill-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: row;
  align-items: stretch;
}

#media-container {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

#media-image, #media-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  position: absolute;
  display: none;
}

#media-image.active, #media-video.active {
  display: block;
}

/* Companion slots */
.companion-slot {
  display: none;
  overflow: hidden;
  position: relative;
}
.companion-slot.active {
  display: flex;
  align-items: center;
  justify-content: center;
}
/* Companion media — a sharp object-fit:contain copy showing the WHOLE clip,
   never cropped, over a blurred cover backdrop that fills the leftover space.
   Tiles are sized to each clip's aspect ratio so the blurred border stays
   small. */
.companion-sub-slot img,
.companion-sub-slot video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.companion-bg {
  object-fit: cover;
  filter: blur(18px) brightness(0.6);
  transform: scale(1.15);
}
.companion-fg {
  object-fit: contain;
}

/* Top / bottom fill strips — used when the main media is WIDE (it fills the
   viewer width but leaves black bars above/below). Absolute overlays on the
   gap regions; a horizontal row of cells. */
#companion-top,
#companion-bottom {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 5;
  overflow: hidden;
  display: none;
}
#companion-top { top: 0; }
#companion-bottom { bottom: 0; }
#companion-top.active,
#companion-bottom.active {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  justify-content: flex-start;
}

/* Stacked fill mode: a vertical column of cells (side strips) */
.companion-slot.stacked {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
}
.companion-sub-slot {
  flex: 1;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* A band — one line of companion cells laid ACROSS the strip. Bands stack
   along the strip; within a band the cells sit side by side. */
.companion-band {
  display: flex;
  overflow: hidden;
  align-items: stretch;
}

/* Fill-mode grid — tiles the WHOLE viewer with a packed grid of equal videos
   (rows of clips). No "main" video; every clip gets the same treatment. */
#grid {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  background: #000;
}
#grid.active { display: flex; }

/* Checkbox in settings */
.checkbox-label {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 8px !important;
}
.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #8338ec;
  cursor: pointer;
}
.checkbox-label .setting-hint {
  margin-bottom: 0;
  margin-left: 4px;
}

/* === Welcome === */
#welcome {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  z-index: 5;
  pointer-events: none;
}
#welcome h1 {
  font-size: 3rem;
  font-weight: 800;
  background: linear-gradient(135deg, #ff006e, #8338ec, #3a86ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.5rem;
}
#welcome p {
  font-size: 1.1rem;
  color: #888;
}
#welcome.hidden { display: none; }

/* === Counter === */
#counter {
  position: absolute;
  top: 12px;
  right: 16px;
  font-size: 0.85rem;
  color: rgba(255,255,255,0.5);
  font-variant-numeric: tabular-nums;
  z-index: 10;
}

/* === Controls Bar === */
#controls {
  flex-shrink: 0;
  background: #111;
  border-top: 1px solid #222;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 8px;
  min-height: 56px;
  z-index: 20;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.control-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: #aaa;
}

/* Buttons */
button, select, input[type="text"] {
  font-family: inherit;
  cursor: pointer;
}

#folder-input {
  width: 280px;
  padding: 6px 10px;
  background: #1a1a1a;
  color: #ddd;
  border: 1px solid #333;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: text;
}
#folder-input:focus {
  outline: none;
  border-color: #8338ec;
}

button {
  padding: 6px 14px;
  background: #222;
  color: #ddd;
  border: 1px solid #333;
  border-radius: 6px;
  font-size: 0.8rem;
  transition: background 0.15s;
}
button:hover:not(:disabled) { background: #333; }
button:disabled { opacity: 0.4; cursor: default; }

#scramble-btn {
  background: linear-gradient(135deg, #ff006e, #8338ec);
  border: none;
  color: #fff;
  font-weight: 700;
  padding: 8px 20px;
  font-size: 0.85rem;
}
#scramble-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #ff1a7a, #9448ff);
}

select {
  padding: 5px 8px;
  background: #1a1a1a;
  color: #ddd;
  border: 1px solid #333;
  border-radius: 5px;
  font-size: 0.8rem;
}

/* === Settings Panel === */
#settings-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 320px;
  height: 100dvh;
  background: #141414;
  border-left: 1px solid #222;
  z-index: 30;
  overflow-y: auto;
  transition: transform 0.3s ease;
}
#settings-panel.hidden {
  transform: translateX(100%);
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid #222;
}
.settings-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
}
#settings-close {
  background: none;
  border: none;
  color: #888;
  font-size: 1.5rem;
  padding: 0 6px;
}
#settings-close:hover { color: #fff; }

.settings-body {
  padding: 16px;
}

.setting-group {
  margin-bottom: 20px;
}
.setting-group h3 {
  font-size: 0.85rem;
  color: #ff006e;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}
.setting-group label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.8rem;
  color: #bbb;
  margin-bottom: 10px;
}
.setting-group input[type="range"] {
  width: 100%;
  accent-color: #8338ec;
  margin-top: 4px;
}
.setting-group input[type="color"] {
  width: 40px;
  height: 28px;
  border: 1px solid #333;
  border-radius: 4px;
  background: none;
  cursor: pointer;
}
.setting-group select {
  width: 100%;
  margin-top: 4px;
}
.setting-hint {
  font-size: 0.75rem;
  color: #666;
  margin-bottom: 8px;
}
#text-lines-input {
  width: 100%;
  background: #1a1a1a;
  color: #ddd;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 0.8rem;
  resize: vertical;
  line-height: 1.5;
}
#text-lines-input:focus {
  outline: none;
  border-color: #8338ec;
}

/* === Flash Overlay === */
#flash-overlay {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 8;
  transition: opacity 0.05s;
}
#flash-overlay.active {
  opacity: 1;
}

/* === Text Overlay === */
#text-overlay {
  position: absolute;
  z-index: 9;
  pointer-events: none;
  font-weight: 800;
  text-align: center;
  white-space: pre-wrap;
  word-wrap: break-word;
  max-width: 80%;
  padding: 10px 24px;
  border-radius: 8px;
  opacity: 0;
  text-shadow: 2px 2px 8px rgba(0,0,0,0.8);
}
#text-overlay.visible { opacity: 1; }

/* Background box on a pseudo-element so gradient text effects (which use
   `background` themselves) don't wipe it out. Opacity comes from --text-bg. */
#text-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--text-bg, transparent);
  border-radius: 8px;
  z-index: -1;
}

/* === Text effects (visual style — independent of transitions) === */
#text-overlay.text-fx-neon {
  text-shadow:
    0 0 4px currentColor,
    0 0 10px currentColor,
    0 0 22px currentColor,
    0 0 42px currentColor;
}
#text-overlay.text-fx-outline {
  -webkit-text-stroke: 3px #000;
  paint-order: stroke fill;
  text-shadow: none;
}
#text-overlay.text-fx-3d {
  text-shadow:
    1px 1px 0 #000, 2px 2px 0 #000, 3px 3px 0 #000,
    4px 4px 0 #000, 5px 5px 0 #000, 6px 6px 0 #000,
    7px 7px 12px rgba(0,0,0,0.55);
}
#text-overlay.text-fx-gradient {
  background: linear-gradient(135deg, var(--fx-c1, #ffffff), var(--fx-c2, #ff8a00));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: none;
}
#text-overlay.text-fx-chrome {
  background: linear-gradient(180deg, #ffffff 0%, #d6d6d6 42%, #8a8a8a 52%, #ededed 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  -webkit-text-stroke: 1px #3a3a3a;
  text-shadow: 0 3px 5px rgba(0,0,0,0.55);
}
#text-overlay.text-fx-fire {
  background: linear-gradient(0deg, var(--fx-c1, #ffffff), var(--fx-c2, #ff8a00));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 14px var(--fx-c2, #ff8a00), 0 0 30px var(--fx-c1, #ffffff);
}

/* Text transitions */
#text-overlay.text-fade {
  transition: opacity 0.3s ease;
}
#text-overlay.text-bounce {
  animation: textBounce 0.5s ease;
}
#text-overlay.text-typewriter {
  overflow: hidden;
  border-right: 3px solid currentColor;
  animation: textTypewriter 0.8s steps(20) forwards, textBlink 0.5s step-end infinite;
}
#text-overlay.text-glitch {
  animation: textGlitch 0.4s ease;
}
#text-overlay.text-scale-up {
  animation: textScaleUp 0.4s ease;
}
#text-overlay.text-slide-down {
  animation: textSlideDown 0.4s ease;
}

@keyframes textBounce {
  0% { transform: scale(0) translateY(-40px); }
  50% { transform: scale(1.2) translateY(10px); }
  70% { transform: scale(0.9) translateY(-5px); }
  100% { transform: scale(1) translateY(0); }
}

@keyframes textTypewriter {
  from { width: 0; }
  to { width: 100%; }
}

@keyframes textBlink {
  50% { border-color: transparent; }
}

@keyframes textGlitch {
  0% { transform: translate(-5px, 3px) skewX(10deg); opacity: 0; filter: hue-rotate(90deg); }
  20% { transform: translate(5px, -3px) skewX(-5deg); opacity: 0.6; }
  40% { transform: translate(-3px, 1px) skewX(3deg); opacity: 0.8; filter: hue-rotate(180deg); }
  60% { transform: translate(2px, -2px) skewX(-2deg); opacity: 1; }
  100% { transform: translate(0) skewX(0); opacity: 1; filter: hue-rotate(0deg); }
}

@keyframes textScaleUp {
  0% { transform: scale(0); opacity: 0; }
  70% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes textSlideDown {
  0% { transform: translateY(-60px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

/* === Animated text effects ===
   Placed AFTER the transitions so their `animation` wins the cascade — a
   continuously-animated effect replaces the one-time entry animation.
   --fx-c1 / --fx-c2 are set per-render from the two colour pickers. */
#text-overlay.text-fx-rainbow {
  background: linear-gradient(90deg,
    #ff1f1f, #ff8a00, #ffe600, #28d152, #00b3ff, #7b2ff7, #ff1f1f);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: none;
  animation: fxRainbow 2s linear infinite;
}
@keyframes fxRainbow {
  from { background-position: 0% 0; }
  to   { background-position: 200% 0; }
}

#text-overlay.text-fx-pulse {
  animation: fxPulse 1.1s ease-in-out infinite;
}
@keyframes fxPulse {
  0%, 100% { text-shadow: 0 0 6px var(--fx-c1, #fff), 0 0 12px var(--fx-c1, #fff); transform: scale(1); }
  50%      { text-shadow: 0 0 18px var(--fx-c1, #fff), 0 0 40px var(--fx-c1, #fff); transform: scale(1.06); }
}

#text-overlay.text-fx-shimmer {
  background: linear-gradient(110deg,
    var(--fx-c1, #fff) 38%, #ffffff 50%, var(--fx-c1, #fff) 62%);
  background-size: 280% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: fxShimmer 1.9s linear infinite;
}
@keyframes fxShimmer {
  from { background-position: 160% 0; }
  to   { background-position: -160% 0; }
}

#text-overlay.text-fx-flicker {
  text-shadow: 0 0 6px var(--fx-c1, #fff), 0 0 18px var(--fx-c1, #fff);
  animation: fxFlicker 3s steps(1) infinite;
}
@keyframes fxFlicker {
  0%, 18%, 22%, 53%, 57%, 83%, 100% { opacity: 1; }
  20%, 55%, 85% { opacity: 0.35; }
}

#text-overlay.text-fx-strobe {
  animation: fxStrobe 0.5s steps(1) infinite;
}
@keyframes fxStrobe {
  0%, 49%   { color: var(--fx-c1, #fff); }
  50%, 100% { color: var(--fx-c2, #ff8a00); }
}

/* === TRANSITION ANIMATIONS === */

/* Fade */
.transition-fade { animation: transitionFade 0.4s ease forwards; }
@keyframes transitionFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Zoom In */
.transition-zoom-in { animation: transitionZoomIn 0.4s ease forwards; }
@keyframes transitionZoomIn {
  from { opacity: 0; transform: scale(0.3); }
  to { opacity: 1; transform: scale(1); }
}

/* Zoom Out */
.transition-zoom-out { animation: transitionZoomOut 0.4s ease forwards; }
@keyframes transitionZoomOut {
  from { opacity: 0; transform: scale(2); }
  to { opacity: 1; transform: scale(1); }
}

/* Spin */
.transition-spin { animation: transitionSpin 0.5s ease forwards; }
@keyframes transitionSpin {
  from { opacity: 0; transform: rotate(360deg) scale(0.3); }
  to { opacity: 1; transform: rotate(0deg) scale(1); }
}

/* Slide Left */
.transition-slide-left { animation: transitionSlideLeft 0.35s ease forwards; }
@keyframes transitionSlideLeft {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}

/* Slide Right */
.transition-slide-right { animation: transitionSlideRight 0.35s ease forwards; }
@keyframes transitionSlideRight {
  from { opacity: 0; transform: translateX(-100%); }
  to { opacity: 1; transform: translateX(0); }
}

/* Glitch */
.transition-glitch { animation: transitionGlitch 0.4s ease forwards; }
@keyframes transitionGlitch {
  0% { opacity: 0; transform: translate(-10px, 5px) skewX(15deg); filter: hue-rotate(90deg) saturate(3); }
  15% { opacity: 0.4; transform: translate(10px, -5px) skewX(-10deg); }
  30% { opacity: 0.6; transform: translate(-5px, 3px) skewX(5deg); filter: hue-rotate(180deg) saturate(2); }
  50% { opacity: 0.8; transform: translate(5px, -2px) skewX(-3deg); }
  70% { opacity: 0.9; transform: translate(-2px, 1px) skewX(1deg); filter: hue-rotate(270deg); }
  100% { opacity: 1; transform: translate(0) skewX(0); filter: hue-rotate(0) saturate(1); }
}

/* Flash */
.transition-flash { animation: transitionFlash 0.3s ease forwards; }
@keyframes transitionFlash {
  0% { opacity: 0; }
  50% { opacity: 1; }
  100% { opacity: 1; }
}

/* Flip */
.transition-flip { animation: transitionFlip 0.5s ease forwards; perspective: 800px; }
@keyframes transitionFlip {
  from { opacity: 0; transform: perspective(800px) rotateY(90deg); }
  to { opacity: 1; transform: perspective(800px) rotateY(0deg); }
}

/* Blur In */
.transition-blur-in { animation: transitionBlurIn 0.4s ease forwards; }
@keyframes transitionBlurIn {
  from { opacity: 0; filter: blur(30px); }
  to { opacity: 1; filter: blur(0); }
}

/* Dissolve */
.transition-dissolve { animation: transitionDissolve 0.6s ease forwards; }
@keyframes transitionDissolve {
  0% { opacity: 0; filter: brightness(3) contrast(0.5); }
  50% { opacity: 0.7; filter: brightness(1.5) contrast(0.8); }
  100% { opacity: 1; filter: brightness(1) contrast(1); }
}


/* === HYPNOTIC EFFECTS === */

/* Color Cycle */
.effect-color-cycle { animation: effectColorCycle 3s linear infinite; }
@keyframes effectColorCycle {
  0% { filter: hue-rotate(0deg); }
  100% { filter: hue-rotate(360deg); }
}

/* Pulse */
.effect-pulse { animation: effectPulse 1.2s ease-in-out infinite; }
@keyframes effectPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* Pulse Separate — each cell pulses on its own phase, so they drift in and
   out of sync (vs effect-pulse which scales the whole grid together). */
.effect-pulse-separate .companion-sub-slot,
.effect-pulse-separate #media-image,
.effect-pulse-separate #media-video {
  animation: effectPulse 1.2s ease-in-out infinite;
}
.effect-pulse-separate .companion-sub-slot:nth-child(2) { animation-delay: -0.17s; }
.effect-pulse-separate .companion-sub-slot:nth-child(3) { animation-delay: -0.41s; }
.effect-pulse-separate .companion-sub-slot:nth-child(4) { animation-delay: -0.73s; }
.effect-pulse-separate .companion-sub-slot:nth-child(5) { animation-delay: -0.29s; }
.effect-pulse-separate .companion-sub-slot:nth-child(6) { animation-delay: -0.91s; }
.effect-pulse-separate .companion-sub-slot:nth-child(7) { animation-delay: -0.55s; }
.effect-pulse-separate .companion-sub-slot:nth-child(8) { animation-delay: -0.83s; }

/* Pulse with Beat — JS sets transform: scale() momentarily on each detected
   beat of the audio overlay; the transition smooths the snap-back. */
.effect-pulse-beat { transition: transform 110ms ease-out; }

/* Invert */
.effect-invert { filter: invert(1); }

/* Sepia Wave */
.effect-sepia-wave { animation: effectSepiaWave 2s ease-in-out infinite; }
@keyframes effectSepiaWave {
  0%, 100% { filter: sepia(0) brightness(1); }
  50% { filter: sepia(1) brightness(1.2); }
}

/* RGB Split */
.effect-rgb-split {
  animation: effectRGBSplit 0.8s ease-in-out infinite alternate;
}
@keyframes effectRGBSplit {
  0% { text-shadow: -3px 0 red, 3px 0 cyan; filter: drop-shadow(-3px 0 red) drop-shadow(3px 0 cyan); }
  100% { text-shadow: 3px 0 red, -3px 0 cyan; filter: drop-shadow(3px 0 red) drop-shadow(-3px 0 cyan); }
}

/* Kaleidoscope */
.effect-kaleidoscope { animation: effectKaleidoscope 4s linear infinite; }
@keyframes effectKaleidoscope {
  0% { filter: hue-rotate(0deg) saturate(2) contrast(1.2); transform: scale(1); }
  25% { filter: hue-rotate(90deg) saturate(3) contrast(1.4); transform: scale(1.02) rotate(2deg); }
  50% { filter: hue-rotate(180deg) saturate(2) contrast(1.2); transform: scale(1) rotate(0deg); }
  75% { filter: hue-rotate(270deg) saturate(3) contrast(1.4); transform: scale(1.02) rotate(-2deg); }
  100% { filter: hue-rotate(360deg) saturate(2) contrast(1.2); transform: scale(1); }
}

/* Hyper Saturate */
.effect-saturate-boost { filter: saturate(3) contrast(1.3); }

/* Hue Rotate */
.effect-hue-rotate { animation: effectHueRotate 6s linear infinite; }
@keyframes effectHueRotate {
  0% { filter: hue-rotate(0deg) brightness(1); }
  50% { filter: hue-rotate(180deg) brightness(1.1); }
  100% { filter: hue-rotate(360deg) brightness(1); }
}


/* Buttons with icon + label */
.btn-icon {
  display: none;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Icon-only buttons */
.icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.icon-btn svg {
  width: 18px;
  height: 18px;
}

/* Privacy badge (always-on in controls bar) */
.privacy-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(51, 255, 170, 0.08);
  color: #33ffaa;
  border: 1px solid rgba(51, 255, 170, 0.3);
  letter-spacing: 0.04em;
  cursor: default;
  user-select: none;
}

/* === Folder status / tier badge === */
.folder-status {
  font-size: 0.75rem;
  color: #888;
  margin-left: 4px;
  max-width: 240px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tier-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 4px;
  background: #2a2a2a;
  color: #888;
  border: 1px solid #333;
}
.tier-badge.pro {
  background: linear-gradient(135deg, #ff006e, #8338ec);
  color: #fff;
  border: none;
}

/* Record button */
#record-btn {
  background: #2a1a1a;
  border-color: #5a2a2a;
  color: #ff6666;
}
#record-btn:hover:not(:disabled) { background: #3a1a1a; }
#record-btn.recording {
  background: #aa1f1f;
  color: #fff;
  border-color: #aa1f1f;
  animation: recPulse 1.2s ease-in-out infinite;
}
@keyframes recPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 0, 0, 0.5); }
  50% { box-shadow: 0 0 0 6px rgba(255, 0, 0, 0); }
}

/* Welcome privacy block */
.welcome-privacy {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding: 12px 20px;
  border: 1px solid rgba(51, 255, 170, 0.25);
  border-radius: 10px;
  background: rgba(51, 255, 170, 0.06);
  font-size: 0.9rem;
  color: #aaa;
  line-height: 1.5;
  max-width: 380px;
  text-align: left;
}
.welcome-privacy strong { color: #33ffaa; }

/* === Pro badge inside settings === */
.pro-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  background: linear-gradient(135deg, #ff006e, #8338ec);
  color: #fff;
  margin-left: 6px;
  vertical-align: middle;
  letter-spacing: 0.05em;
}
.pro-note {
  color: #ff006e;
  font-weight: 600;
}
.pro-group {
  position: relative;
  padding: 12px;
  border: 1px solid #2a1a3a;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(131, 56, 236, 0.05), rgba(255, 0, 110, 0.02));
}

/* Text-line counter */
.lines-count {
  font-size: 0.7rem;
  color: #666;
  margin-top: 6px;
  text-align: right;
}
.lines-count.over-cap {
  color: #ff006e;
  font-weight: 600;
}

/* File input (audio) styled as button */
.file-input-label {
  display: block !important;
  margin-bottom: 8px;
}
.file-input-btn {
  display: inline-block;
  padding: 6px 14px;
  background: #222;
  color: #ddd;
  border: 1px solid #333;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s;
}
.file-input-btn:hover { background: #333; }

.audio-track-list {
  list-style: none;
  padding: 0;
  margin: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.audio-track-empty {
  font-size: 0.75rem;
  color: #555;
  padding: 4px 0;
}
.audio-track-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 5px;
  padding: 5px 8px;
}
.audio-track-name {
  flex: 1;
  font-size: 0.75rem;
  color: #bbb;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.audio-track-remove {
  background: none;
  border: none;
  color: #555;
  font-size: 1rem;
  padding: 0 2px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  min-height: unset;
}
.audio-track-remove:hover { color: #ff006e; }

/* Upgrade / secondary buttons in settings */
.account-pro-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(131, 56, 236, 0.12);
  border: 1px solid rgba(131, 56, 236, 0.35);
  color: #b57fff;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
}
.account-pro-status .icon { color: #8338ec; }
.account-pro-status.hidden { display: none; }
#account-free-status.hidden { display: none; }
#account-signed-in.hidden { display: none; }
#account-signed-out.hidden { display: none; }
#account-portal-btn.hidden { display: none; }
#paywall-signin-hint.hidden { display: none; }
#auth-confirm-hint.hidden { display: none; }
#auth-error.hidden { display: none; }

.upgrade-btn {
  display: block;
  width: 100%;
  padding: 10px;
  background: linear-gradient(135deg, #ff006e, #8338ec);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  margin-bottom: 8px;
}
.upgrade-btn:hover { background: linear-gradient(135deg, #ff1a7a, #9448ff); }

.secondary-btn {
  display: block;
  width: 100%;
  padding: 8px;
  background: transparent;
  color: #888;
  border: 1px solid #333;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
}
.secondary-btn:hover { background: #1a1a1a; color: #ddd; }

/* === Recording indicator === */
#rec-indicator {
  position: absolute;
  top: 12px;
  left: 16px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.62);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #fff;
  pointer-events: none;
}
#rec-indicator.hidden { display: none; }

.rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ff2d2d;
  animation: recBlink 1.1s ease-in-out infinite;
}
@keyframes recBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

#rec-time {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.75);
}

/* === Paywall Modal === */
#paywall-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
#paywall-modal.hidden { display: none; }

#paywall-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  cursor: pointer;
}

.paywall-card {
  position: relative;
  background: #141414;
  border: 1px solid #333;
  border-radius: 16px;
  padding: 32px;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(131, 56, 236, 0.3);
}

.paywall-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: #888;
  font-size: 1.5rem;
  padding: 0 6px;
  cursor: pointer;
}
.paywall-close-btn:hover { color: #fff; }

.paywall-card h2 {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 12px;
  background: linear-gradient(135deg, #ff006e, #8338ec);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.paywall-reason {
  color: #bbb;
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.paywall-features {
  list-style: none;
  padding: 0;
  margin-bottom: 24px;
}
.paywall-features li {
  padding: 6px 0;
  color: #ddd;
  font-size: 0.9rem;
  position: relative;
  padding-left: 24px;
}
.paywall-features li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: #8338ec;
  font-weight: 700;
}
.paywall-features li.feature-privacy {
  color: #33ffaa;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 0;
}
.paywall-features li.feature-privacy::before {
  display: none;
}
.paywall-features li.feature-privacy .icon {
  color: #33ffaa;
  flex-shrink: 0;
}

.upgrade-btn-lg {
  display: block;
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #ff006e, #8338ec);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  margin-bottom: 10px;
}
.upgrade-btn-lg:hover { background: linear-gradient(135deg, #ff1a7a, #9448ff); }

/* === Plan grid (paywall) === */
.plan-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.plan-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 10px 14px;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 10px;
  color: #ddd;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}
.plan-card:hover {
  border-color: #8338ec;
  background: #1f1a2a;
  transform: translateY(-1px);
}
.plan-card-featured {
  border-color: #8338ec;
  background: linear-gradient(180deg, #1f1a2a 0%, #1a1a1a 100%);
}
.plan-card-featured:hover {
  border-color: #ff006e;
}

.plan-badge {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  padding: 3px 8px;
  background: linear-gradient(135deg, #ff006e, #8338ec);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  border-radius: 999px;
  white-space: nowrap;
}

.plan-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #888;
}
.plan-price {
  font-size: 1.4rem;
  font-weight: 800;
  color: #fff;
  line-height: 1;
}
.plan-period {
  font-size: 0.75rem;
  font-weight: 500;
  color: #888;
  margin-left: 2px;
}
.plan-note {
  font-size: 0.65rem;
  color: #666;
  text-align: center;
  margin-top: 2px;
}

/* === Auth Modal === */
#auth-modal {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
}
#auth-modal.hidden { display: none; }

#auth-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(8px);
  cursor: pointer;
}

.auth-card {
  position: relative;
  background: #141414;
  border: 1px solid #333;
  border-radius: 16px;
  padding: 32px;
  max-width: 380px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  z-index: 1;
}

.auth-card h2 {
  font-size: 1.3rem;
  font-weight: 800;
  margin-bottom: 4px;
  background: linear-gradient(135deg, #ff006e, #8338ec);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth-label {
  display: block;
  font-size: 0.8rem;
  color: #bbb;
  margin-bottom: 12px;
}

.auth-label input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 10px 12px;
  background: #0a0a0a;
  border: 1px solid #333;
  border-radius: 8px;
  color: #e0e0e0;
  font-family: inherit;
  font-size: 0.9rem;
}
.auth-label input:focus {
  outline: none;
  border-color: #8338ec;
}

.auth-error {
  color: #ff5588;
  font-size: 0.8rem;
  margin-bottom: 10px;
  padding: 8px 10px;
  background: rgba(255, 0, 110, 0.1);
  border-radius: 6px;
}

.auth-toggle-row {
  margin-top: 14px;
  text-align: center;
  font-size: 0.8rem;
  color: #888;
}
.auth-toggle-btn {
  background: none;
  border: none;
  color: #b78aff;
  font-size: inherit;
  font-family: inherit;
  cursor: pointer;
  padding: 0 4px;
  text-decoration: underline;
}
.auth-toggle-btn:hover { color: #d4b3ff; }

.oauth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 11px;
  background: #fff;
  color: #1a1a1a;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  margin-bottom: 14px;
}
.oauth-btn:hover { background: #f5f5f5; }
.oauth-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #555;
  font-size: 0.75rem;
  margin: 14px 0;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #2a2a2a;
}

/* === Account section === */
.account-email-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  background: #0a0a0a;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  margin-bottom: 12px;
}
.account-email-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #666;
}
.account-email-value {
  font-size: 0.85rem;
  color: #ddd;
  word-break: break-all;
}

.account-pro-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(51, 255, 170, 0.08);
  border: 1px solid rgba(51, 255, 170, 0.3);
  border-radius: 8px;
  color: #33ffaa;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 12px;
}

/* === Mobile plan grid === */
@media (max-width: 480px) {
  .plan-grid {
    grid-template-columns: 1fr;
  }
  .plan-card {
    flex-direction: row;
    justify-content: space-between;
    text-align: left;
    padding: 12px 14px;
  }
  .plan-card-featured .plan-badge {
    position: static;
    transform: none;
    margin-right: auto;
  }
  .plan-note {
    text-align: right;
    flex: 1 1 auto;
  }
}

/* === Scrollbar === */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #111; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* === Mobile === */
@media (max-width: 600px) {
  #controls {
    padding: 0 10px;
    gap: 6px;
    flex-wrap: nowrap;
    min-height: 52px;
  }

  .control-group {
    gap: 6px;
    flex-shrink: 1;
    min-width: 0;
  }

  /* Bigger tap targets */
  button, select {
    min-height: 40px;
    padding: 6px 10px;
    font-size: 0.8rem;
    white-space: nowrap;
  }

  /* Hide folder status — too cramped */
  .folder-status { display: none; }

  /* Hide privacy badge and tier badge — both visible in Settings */
  .privacy-badge { display: none; }
  #premium-status { display: none; }

  /* Load + scramble become icon-only */
  #load-btn, #scramble-btn {
    width: 44px;
    height: 44px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  #load-btn .btn-label, #scramble-btn .btn-label { display: none; }
  #load-btn .btn-icon, #scramble-btn .btn-icon { display: block; }


  /* Settings panel full-width */
  #settings-panel {
    width: 100%;
    border-left: none;
  }

  /* Welcome privacy block — tighter */
  .welcome-privacy {
    max-width: 90vw;
    font-size: 0.82rem;
  }
}

/* === Landscape phone === */
@media (max-height: 500px) and (orientation: landscape) {
  #controls {
    min-height: 44px;
    padding: 0 10px;
    gap: 6px;
    flex-wrap: nowrap;
  }

  button, select {
    min-height: 36px;
    padding: 4px 10px;
    font-size: 0.75rem;
  }

  .privacy-badge { display: none; }
  .folder-status { display: none; }

  #welcome h1 { font-size: 2rem; }
  .welcome-privacy { display: none; }
}
