/* === 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: 100vh;
  width: 100vw;
}

/* === Viewer === */
#viewer {
  position: fixed;
  inset: 0;
  bottom: 56px;
  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 {
  max-width: 100%;
  max-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-slot img,
.companion-slot video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 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 {
  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 {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: #111;
  border-top: 1px solid #222;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 12px;
  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: calc(100vh - 56px);
  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: fixed;
  inset: 0;
  bottom: 56px;
  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; }

/* 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; }
}

/* === 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); }
}

/* 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); }
}


/* === 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 sub-line */
.welcome-sub {
  font-size: 0.85rem;
  color: #555;
  margin-top: 8px;
}

/* === 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-status-text {
  font-size: 0.75rem;
  color: #888;
  margin-bottom: 10px;
}

/* Upgrade / secondary buttons in settings */
.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; }

/* === 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;
}

.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); }

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