:root {
  --bg-gradient: linear-gradient(0deg,#1D1E21 0%, #202328 150%);
  --bg: #1e1f26;
  --surface: #2a2d35;
  --surface-inset: #16171c;
  --surface-gradient: linear-gradient(0deg,#3C3F44 0%, #0B0E13 150%);
  --sh-dark: #121317;
  --sh-light: #2a2b31;
  --accent: #ff00cc;
  --accent-muted: #85567b;
  --accent-glow: #ff00cc80;
  --accent-shadow-dark: #4d1060;
  --accent-shadow-light: #5e1ab0;
  --gradient-main: linear-gradient(135deg, #ff00cc, #3333ff);
  --font-color: #d0d1d6;
  --font-color-muted: #6a6d78;
  --radius-l: 1.5rem;
  --radius-m: 1rem;
}

* {
  box-sizing: border-box;
  font-family: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

html,
body {
  height: 100%;
  user-select: none;
}

body {
  margin: 0;
  background: var(--bg-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  color: var(--font-color);
  overflow: hidden;
}

.card-wrapper {
  background: linear-gradient(135deg, #ff00cc, #3333ff);
  padding: 4px;
  border-radius: var(--radius-l);
  width: fit-content;
  margin: auto;
  box-shadow: 10px 10px 20px var(--sh-dark), -10px -10px 20px var(--sh-light);
}

.card {
  background: var(--surface-gradient);
  border-radius: var(--radius-l);
  width: clamp(320px, 90vw, 420px);
  padding: 2rem;
}

h1 {
  margin: 0 0 2rem;
  text-align: center;
  font-size: 2rem;
  font-weight: 400;
  color: var(--font-color);
}

 /* ───────────── First screen ───────────── */

#uploadScreen,
.video-area {
  width: 100%;
  max-width: 380px;
  margin: 0 auto;
}

.touch-me-label {
  position: relative;
  display: flex;
  width: 100%;
  padding-top: 100%;
  border-radius: 50%;
  background: var(--surface);
  justify-content: center;
  align-items: center;
  cursor: pointer;
  box-shadow: inset 3px 3px 4px var(--sh-dark), inset -3px -3px 4px var(--sh-light);
  transition: all 0.15s linear;
}

.touch-me-label:hover {
  filter: brightness(1.1);
}

.touch-me-label:active {
  box-shadow: inset 10px 10px 20px var(--sh-dark), inset -10px -10px 20px var(--sh-light);
}

.touch-me-label span {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2.5rem;
  font-weight: 600;
  color: var(--font-color-muted);
  text-align: center;
  line-height: 1.2;
  user-select: none;
  text-transform: uppercase;
}

 /* ───────────── Second screen ───────────── */

#playerScreen {
  display: flex;
  flex-direction: column;
}

.video-container {
  position: relative;
  width: 100%;
  padding-top: 100%;
  border-radius: 50%;
  background: var(--bg);
  box-shadow: 10px 10px 20px var(--sh-dark), -10px -10px 20px var(--sh-light);
  overflow: hidden;
}

#videoPreview {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1);
  background-color: #000;
  cursor: pointer;
}

.video-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: opacity 0.2s ease;
  background: rgba(0, 0, 0, 0.6);
  z-index: 2;
}

.play-icon {
  fill: rgba(255, 255, 255, 0.7);
  width: 70%;
  height: 70%;
}

.scrubber-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
  z-index: 5;
}

.scrubber-track-bg,
.scrubber-track-fg {
  fill: none;
  stroke-linecap: round;
}

.scrubber-track-bg {
  stroke: rgba(0, 0, 0, 0.2);
}

.scrubber-track-fg {
  stroke: var(--accent);
  filter: drop-shadow(0 0 5px var(--accent-glow));
  transition: stroke-dashoffset 0.1s linear;
}

.scrubber-handle {
  fill: var(--accent);
  stroke: var(--surface);
  filter: drop-shadow(0 2px 4px var(--sh-dark));
  pointer-events: all;
  cursor: pointer;
}

.tool-controls {
  display: flex;
  justify-content: space-around;
  align-items: center;
  margin: 2rem auto 0;
  width: 100%;
  max-width: 380px;
}

.tool-button,
.time-display {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(145deg, #46436a, #1c1d22);
  border: 2px solid #1e1f26;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    5px 5px 10px rgba(0, 0, 0, 0.5),
    -5px -5px 10px rgba(255, 255, 255, 0.03),
    inset 0 0 0 0 transparent;
  transition: all 0.2s ease-out;
}

.tool-button {
  cursor: pointer;
}

.tool-button:active {
  box-shadow:
    inset 5px 5px 10px rgba(0, 0, 0, 0.6),
    inset -5px -5px 10px rgba(255, 255, 255, 0.02);
  transform: scale(0.97);
}

.tool-button svg {
  fill: var(--font-color-muted);
  width: 24px;
  height: 24px;
  transition: fill 0.15s;
}

.tool-button:hover {
  filter: brightness(1.05);
}

.tool-button:hover svg {
  fill: var(--font-color);
}

.time-display {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--font-color);
}

.controls {
  margin-top: 2rem;
}

.control-group {
  margin-bottom: 1.5rem;
  position: relative;
}

.label-container {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  color: var(--font-color);
  font-weight: 600;
}

.label-container span:last-child {
  color: var(--font-color-muted);
}

input[type=text] {
  width: 100%;
  padding: calc(1rem - 2px); 
  /* Add a transparent frame to avoid "jumping" when focusing */
  border: 2px solid transparent; 
  border-radius: var(--radius-m);
  font-size: 1rem;
  color: var(--font-color);
  margin-top: 1.5rem;
  background: var(--surface);
  box-shadow: inset 1px 1px 2px var(--sh-dark), inset -1px -1px 2px var(--sh-light);
  transition: all 0.2s ease-in-out; 
}

input[type=text]:focus {
  outline: none;
  border-color: var(--accent-muted);
}

#chat {
  user-select: text;
}

#convertButton {
  width: 100%;
  padding: 1rem;
  border: 2px solid var(--accent-muted);
  border-radius: var(--radius-m);
  font-size: 1.2rem;
  margin-top: 2rem;
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(145deg, #292c34, #1c1d22);
  color: var(--font-color);
  box-shadow:
    12px 12px 20px #00000080,
    -5px -2px 3px #ffffff05,
    1px 1px 3px var(--accent);
  transition: all 0.05s ease-out;
}

#convertButton:hover {
  filter: brightness(1.25);
}

#convertButton:active {
  transform: scale(0.99);
  box-shadow:
    inset 5px 5px 10px rgba(0, 0, 0, 0.5),
    inset -5px -5px 10px rgba(255, 255, 255, 0.02);
}

#convertButton:disabled {
  background: var(--surface);
  color: var(--font-color-muted);
  border-color: var(--font-color-muted);
  box-shadow: none;
  cursor: not-allowed;
}

 /* ───────────── Styles for noUiSlider ───────────── */
.noUi-target {
  background: var(--surface-inset);
  border-radius: 5px;
  border: none;
  box-shadow: inset 3px 3px 6px var(--sh-dark), inset -3px -3px 6px var(--sh-light);
  height: 8px;
  padding: 0 11px;
  box-sizing: border-box;
}

.noUi-connects {
  margin: 0 -11px;
}

.noUi-connect {
  background: var(--gradient-main);
}

/* .noUi-connect .noUi-draggable {
  transform: translate(0%, 2px) scale(0.5, 0.5);
} */

.noUi-handle {
  border-radius: 50%;
  border: 3px solid var(--surface);
  background: var(--accent);
  box-shadow: 3px 3px 6px var(--sh-dark), -3px -3px 6px var(--sh-light);
  cursor: pointer;
}

.noUi-handle:before,
.noUi-handle:after {
  display: none;
}

.noUi-horizontal .noUi-handle {
  width: 22px;
  height: 22px;
  top: -7px;
  right: -11px;
}

.noUi-tooltip {
  display: none;
}

.combined-tooltip {
  position: absolute;
  bottom: -1.6rem;
  background: var(--surface);
  color: var(--font-color);
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.8rem;
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
  transition: opacity 0.1s;
  box-shadow: 3px 3px 6px var(--sh-dark);
}

input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  background: transparent;
  outline: none;
}

input[type=range]::-webkit-slider-runnable-track {
  height: 8px;
  background: var(--surface-inset);
  border-radius: 5px;
  box-shadow: inset 3px 3px 6px var(--sh-dark), inset -3px -3px 6px var(--sh-light);
}

input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -7px;
  border-radius: 50%;
  border: 3px solid var(--surface);
  background: var(--font-color);
  cursor: pointer;
  box-shadow: 3px 3px 6px var(--sh-dark), -3px -3px 6px var(--sh-light);
}

.hidden {
  display: none !important;
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
    -webkit-text-fill-color: var(--font-color) !important;

    /* Shadow hack to recolor background. This should be here to 
       to cover any background changes from the browser. */
    -webkit-box-shadow: 0 0 0 40px var(--surface) inset !important;
}

@media(max-width:600px) {
  .card-wrapper {
    width: 100vw;
    height: 100dvh; 
    border-radius: 0;
    padding: 0;
  }

  .card {
    background: var(--surface-gradient);
    border-radius: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 1rem; 
    justify-content: center;
  }

  .tool-controls,
  .controls {
    margin-top: 1rem;
  }

  #convertButton {
      margin-top: 1rem;
  }

  input[type=text] {
      margin-top: 1rem;
  }

  #uploadScreen,
  .video-area {
    max-width: none;
  }
}