/* =====================================================
   DESIGN TOKENS
===================================================== */

:root {
    --font:
        "Plus Jakarta Sans",
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        sans-serif;

    --bg: #f4f6fb;
    --bg-accent-1: #eef2ff;
    --bg-accent-2: #fce7f3;
    --bg-accent-3: #ecfdf5;

    --surface: #ffffff;
    --surface-muted: #f8fafc;

    --text: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --border: #e2e8f0;
    --border-strong: #cbd5e1;

    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-soft: rgba(99, 102, 241, 0.12);

    --accent: #f43f5e;
    --accent-hover: #e11d48;
    --accent-soft: rgba(244, 63, 94, 0.1);

    --success: #10b981;
    --success-soft: rgba(16, 185, 129, 0.15);

    --danger: #ef4444;
    --danger-soft: rgba(239, 68, 68, 0.1);

    --radius-sm: 10px;
    --radius: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;

    --shadow-sm:
        0 1px 2px rgba(15, 23, 42, 0.04),
        0 1px 3px rgba(15, 23, 42, 0.06);
    --shadow:
        0 4px 6px -1px rgba(15, 23, 42, 0.06),
        0 10px 20px -5px rgba(15, 23, 42, 0.08);
    --shadow-lg:
        0 20px 40px -12px rgba(15, 23, 42, 0.14),
        0 8px 16px -8px rgba(99, 102, 241, 0.12);

    --header-height: 68px;
    --transition: 0.2s ease;
}


/* =====================================================
   GLOBAL
===================================================== */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    position: relative;
    overflow-x: hidden;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
    transition:
        background var(--transition),
        border-color var(--transition),
        color var(--transition),
        box-shadow var(--transition),
        transform var(--transition);
}

button:active:not(:disabled) {
    transform: scale(0.98);
}

a {
    color: inherit;
    text-decoration: none;
}

.container {
    width: min(880px, calc(100% - 48px));
    margin: 0 auto;
}

.hidden {
    display: none !important;
}


/* =====================================================
   BACKGROUND DECORATION
===================================================== */

.bg-decoration {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
}

.bg-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.55;
    animation: float 18s ease-in-out infinite;
}

.bg-blob-1 {
    width: 520px;
    height: 520px;
    top: -180px;
    right: -120px;
    background: radial-gradient(circle, #c7d2fe 0%, transparent 70%);
}

.bg-blob-2 {
    width: 440px;
    height: 440px;
    bottom: 10%;
    left: -140px;
    background: radial-gradient(circle, #fbcfe8 0%, transparent 70%);
    animation-delay: -6s;
}

.bg-blob-3 {
    width: 360px;
    height: 360px;
    top: 45%;
    right: 15%;
    background: radial-gradient(circle, #a7f3d0 0%, transparent 70%);
    animation-delay: -12s;
}

@keyframes float {
    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    33% {
        transform: translate(24px, -18px) scale(1.04);
    }

    66% {
        transform: translate(-16px, 12px) scale(0.96);
    }
}


/* =====================================================
   HEADER
===================================================== */

.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-height);
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
}

.header-inner {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text);
}

.logo img {
    width: 36px;
    height: 36px;
    filter: drop-shadow(0 4px 8px rgba(99, 102, 241, 0.25));
}

.main-nav {
    display: flex;
    gap: 8px;
}

.main-nav a {
    padding: 8px 14px;
    border-radius: 999px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    transition:
        background var(--transition),
        color var(--transition);
}

.main-nav a:hover {
    background: var(--primary-soft);
    color: var(--primary);
}


/* =====================================================
   HERO
===================================================== */

.hero {
    padding: 56px 0 40px;
}

.hero-content {
    text-align: center;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 20px;
    padding: 6px 14px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 600;
}

.hero-badge::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 3px var(--success-soft);
}

.hero-heading h1 {
    margin: 0;
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.04em;
    background: linear-gradient(135deg, var(--text) 0%, #4338ca 50%, var(--accent) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-heading p {
    margin: 14px auto 0;
    max-width: 420px;
    color: var(--text-secondary);
    font-size: 1.0625rem;
}


/* =====================================================
   URL FORM
===================================================== */

.url-form {
    max-width: 620px;
    margin: 36px auto 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
}

.url-input {
    flex: 1;
    min-width: 0;
    height: auto;
    max-width: none;
    margin: 0;
}

.url-input input {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    background: var(--surface-muted);
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text);
    text-align: center;
}

.url-input input:focus {
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.url-input input::placeholder {
    color: var(--text-muted);
}


.url-input input::placeholder {
    color: var(--text-muted);
}

.load-video-row {
    display: flex;
    margin: 0;
    flex-shrink: 0;
}

.load-video-row button {
    height: 52px;
    padding: 0 24px;
    border: 0;
    border-radius: calc(var(--radius-xl) - 6px);
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    color: #ffffff;
    font-weight: 700;
    font-size: 0.9375rem;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.load-video-row button:hover {
    background: linear-gradient(135deg, var(--primary-hover) 0%, #6d28d9 100%);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

.error-message {
    min-height: 22px;
    margin-top: 12px;
    text-align: center;
    color: var(--danger);
    font-size: 0.8125rem;
    font-weight: 500;
}


/* =====================================================
   PLAYER SECTION
===================================================== */

.player-section {
    padding: 8px 0 32px;
}

.player-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
}

.player-wrapper {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #0f172a;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.06) inset,
        0 20px 40px rgba(15, 23, 42, 0.25);
}

.youtube-player {
    width: 100%;
    height: 100%;
}


/* =====================================================
   CONTROLS PANEL
===================================================== */

.controls-panel {
    margin-top: 20px;
    padding: 22px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.current-time {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0 auto 18px;
    padding: 6px 14px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-weight: 500;
    text-align: center;
    width: fit-content;
    max-width: 100%;
}

.controls-panel > .current-time {
    display: flex;
    justify-content: center;
    width: 100%;
}

.current-time span {
    color: var(--text);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}


/* =====================================================
   LOOP CONTROLS
===================================================== */

.loop-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    max-width: none;
    margin: 0;
}

.time-control {
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.time-control label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text);
}

.time-input-row {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 8px;
}

.time-input-row input {
    flex: 1;
    min-width: 0;
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    background: var(--surface-muted);
    font-weight: 600;
    font-size: 0.875rem;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    text-align: center;
}

.time-input-row input:focus {
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.set-time-btn {
    flex-shrink: 0;
    width: auto;
    min-width: 110px;
    height: 40px;
    border: 0;
    border-radius: var(--radius-sm);
    padding: 0 14px;
    font-weight: 700;
    font-size: 0.8125rem;
    letter-spacing: -0.01em;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.set-time-btn::before {
    font-size: 0.6875rem;
    line-height: 1;
    opacity: 0.95;
}

.set-start-btn {
    background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.set-start-btn::before {
    content: "▶";
}

.set-start-btn:hover {
    background: linear-gradient(135deg, var(--primary-hover) 0%, #4338ca 100%);
    box-shadow: 0 3px 12px rgba(99, 102, 241, 0.4);
}

.set-end-btn {
    background: linear-gradient(135deg, var(--accent) 0%, #e11d48 100%);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(244, 63, 94, 0.3);
}

.set-end-btn::before {
    content: "◼";
    font-size: 0.5625rem;
}

.set-end-btn:hover {
    background: linear-gradient(135deg, var(--accent-hover) 0%, #be123c 100%);
    box-shadow: 0 3px 12px rgba(244, 63, 94, 0.4);
}


/* =====================================================
   LOOP BUTTON
===================================================== */

.main-loop-buttons {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin: 22px 0 0;
    max-width: none;
}

.loop-status-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--danger);
    box-shadow: 0 0 0 4px var(--danger-soft);
    transition:
        background var(--transition),
        box-shadow var(--transition);
}

.loop-status-dot.looping {
    background: var(--success);
    box-shadow: 0 0 0 4px var(--success-soft);
    animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
    0%,
    100% {
        box-shadow: 0 0 0 4px var(--success-soft);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(16, 185, 129, 0.08);
    }
}

.primary-button {
    height: 48px;
    min-width: 160px;
    border-radius: var(--radius-sm);
    padding: 0 28px;
    border: 0;
    background: linear-gradient(135deg, var(--accent) 0%, #fb7185 100%);
    color: #ffffff;
    font-weight: 700;
    font-size: 0.9375rem;
    box-shadow: 0 4px 16px rgba(244, 63, 94, 0.35);
}

.primary-button:hover {
    background: linear-gradient(135deg, var(--accent-hover) 0%, var(--accent) 100%);
    box-shadow: 0 6px 22px rgba(244, 63, 94, 0.45);
}


/* =====================================================
   PLAYBACK SPEED
===================================================== */

.speed-section {
    margin: 22px 0 0;
    padding-top: 22px;
    border-top: 1px solid var(--border);
    text-align: center;
    max-width: none;
}

.speed-section h3 {
    margin: 0 0 12px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.speed-buttons {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    padding: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.speed-buttons button {
    min-width: 58px;
    height: 36px;
    padding: 0 12px;
    border: 0;
    background: transparent;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.speed-buttons button:hover {
    background: var(--surface-muted);
    color: var(--text);
}

.speed-buttons button.active {
    background: var(--primary);
    color: #ffffff;
    box-shadow: var(--shadow-sm);
}


/* =====================================================
   SAVE LOOP
===================================================== */

.save-section-wrapper {
    padding: 16px 0 24px;
}

.save-section {
    max-width: 620px;
    margin: 0 auto;
    padding: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.save-section h3 {
    margin: 0 0 16px;
    text-align: center;
    font-size: 1.0625rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.save-row {
    display: flex;
    gap: 10px;
}

.save-row input {
    flex: 1; 
    min-width: 0;
    height: 48px;
    line-height: 48px; 
    box-sizing: border-box; /* ← ensures height includes padding */
    display: block; /* ← prevents flex shrink bug */
    padding: 0 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    background: var(--surface-muted);
    color: var(--text);
    transition: border-color var(--transition),
        box-shadow var(--transition);
}

.save-row input:focus {
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.save-row input::placeholder {
    color: var(--text-muted);
}

.save-row button {
    height: 48px;
    border: 0;
    border-radius: var(--radius-sm);
    padding: 0 22px;
    background: var(--text);
    color: #ffffff;
    font-weight: 700;
    font-size: 0.875rem;
    white-space: nowrap;
}

.save-row button:hover {
    background: #1e293b;
}


/* =====================================================
   SAVED LOOPS
===================================================== */

.saved-section {
    padding: 48px 0 64px;
}

.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 24px;
}

.section-heading h2 {
    margin: 0;
    font-size: clamp(1.5rem, 3vw, 1.875rem);
    font-weight: 800;
    letter-spacing: -0.03em;
}

.section-heading p {
    margin: 6px 0 0;
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

.danger-button {
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    padding: 9px 16px;
    font-size: 0.8125rem;
    font-weight: 600;
}

.danger-button:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: var(--danger-soft);
}


/* =====================================================
   EMPTY STATE
===================================================== */

.empty-state {
    padding: 56px 24px;
    text-align: center;
    background: var(--surface);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-lg);
}

.empty-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    border-radius: 50%;
    background: var(--primary-soft);
    font-size: 1.75rem;
}

.empty-state h3 {
    margin: 0 0 6px;
    font-size: 1.125rem;
    font-weight: 700;
}

.empty-state p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.9375rem;
}


/* =====================================================
   SAVED CARDS
===================================================== */

.saved-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 18px 20px;
    margin-bottom: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition:
        border-color var(--transition),
        box-shadow var(--transition),
        transform var(--transition);
}

.saved-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.saved-info {
    min-width: 0;
}

.saved-name {
    margin: 0;
    font-weight: 700;
    font-size: 0.9375rem;
    letter-spacing: -0.01em;
    word-break: break-word;
}

.saved-details {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.saved-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.load-loop-btn,
.delete-loop-btn {
    border-radius: var(--radius-sm);
    padding: 9px 14px;
    font-size: 0.8125rem;
    font-weight: 600;
}

.load-loop-btn {
    border: 0;
    background: var(--primary);
    color: #ffffff;
}

.load-loop-btn:hover {
    background: var(--primary-hover);
}

.delete-loop-btn {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
}

.delete-loop-btn:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: var(--danger-soft);
}


/* =====================================================
   HOW IT WORKS
===================================================== */

.how-section {
    padding: 64px 0 72px;
}

.how-section h2 {
    margin: 0 0 36px;
    text-align: center;
    font-size: clamp(1.5rem, 3vw, 1.875rem);
    font-weight: 800;
    letter-spacing: -0.03em;
}

.steps {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.step {
    position: relative;
    padding: 28px 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition:
        border-color var(--transition),
        box-shadow var(--transition),
        transform var(--transition);
}

.step:hover {
    border-color: rgba(99, 102, 241, 0.35);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.step-number {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    color: #ffffff;
    font-weight: 800;
    font-size: 0.9375rem;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.step h3 {
    margin: 0 0 8px;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.step p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.55;
}


/* =====================================================
   FOOTER
===================================================== */

.site-footer {
    padding: 28px 0 36px;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-weight: 500;
}


/* =====================================================
   MOBILE
===================================================== */

@media (max-width: 700px) {
    .save-row input {
        flex: 0 0 auto; 
    }
    
    .container {
        width: calc(100% - 28px);
    }

    .site-header {
        height: 60px;
    }

    .logo {
        font-size: 1rem;
    }

    .logo img {
        width: 32px;
        height: 32px;
    }

    .main-nav {
        display: none;
    }

    .hero {
        padding: 36px 0 28px;
    }

    .hero-badge {
        font-size: 0.75rem;
        margin-bottom: 16px;
    }

    .hero-heading p {
        font-size: 0.9375rem;
    }

    .url-form {
        flex-direction: column;
        padding: 10px;
        border-radius: var(--radius-lg);
        margin-top: 28px;
    }

    .url-input {
        width: 100%;
    }

    .url-input input {
        width: 100%;
        height: 48px;
        text-align: center;
        padding: 0 16px;
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        background: var(--surface-muted);
        font-weight: 600;
        font-size: 0.875rem;
    }

    .load-video-row {
        width: 100%;
    }

    .load-video-row button {
        width: 100%;
        height: 48px;
    }

    .player-card {
        padding: 14px;
        border-radius: var(--radius);
    }

    .controls-panel {
        padding: 16px;
    }

    .loop-controls {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .time-control {
        padding: 10px;
    }

    .main-loop-buttons {
        flex-direction: column;
        gap: 10px;
    }

    .main-loop-buttons .primary-button {
        width: 100%;
    }

    .speed-buttons {
        width: 100%;
        justify-content: center;
    }

    .save-section {
        padding: 20px 16px;
    }

    .save-row {
        flex-direction: column;
    }

    .saved-section {
        padding: 36px 0 48px;
    }

    .section-heading {
        flex-direction: column;
        align-items: flex-start;
    }

    .saved-card {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
    }

    .saved-actions {
        width: 100%;
    }

    .saved-actions button {
        flex: 1;
    }

    .how-section {
        padding: 48px 0 56px;
    }

    .steps {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .bg-blob {
        opacity: 0.35;
    }
}
