:root {
    --bg-dark: #000000;
    --glass-bg: rgba(20, 20, 20, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --primary: #6366f1;
    --primary-glow: rgba(99, 102, 241, 0.5);
    --accent: #22d3ee;
    --text-main: #ffffff;
    --text-muted: #9ca3af;
    --danger: #ef4444;
    --font-stack: 'Inter', system-ui, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-stack);
    height: 100vh;
    overflow: hidden;
    position: relative;
    -webkit-font-smoothing: antialiased;
}

.hidden {
    display: none !important;
}

/* BACKGROUND FX */
.bg-gradient {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    z-index: -2;
    background: radial-gradient(circle at 15% 50%, rgba(99, 102, 241, 0.1), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(34, 211, 238, 0.1), transparent 25%);
    animation: bgPulse 10s ease-in-out infinite alternate;
}

.bg-noise {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('https://grainy-gradients.vercel.app/noise.svg');
    opacity: 0.05;
    z-index: -1;
    pointer-events: none;
}

@keyframes bgPulse {
    0% {
        transform: scale(1);
    }

    100% {
        transform: scale(1.1);
    }
}

/* LAYOUT */
.app-layout {
    display: flex;
    height: 100vh;
    padding: 16px;
    gap: 16px;
}

/* MOBILE HEADER */
.mobile-header {
    display: none;
    height: 60px;
    padding: 0 20px;
    align-items: center;
    justify-content: space-between;
    background: rgba(20, 20, 20, 0.9);
    border-bottom: 1px solid var(--glass-border);
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 50;
}

.brand-mobile {
    font-weight: 700;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-btn {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* SIDEBAR */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.sidebar {
    width: 340px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.close-sidebar-btn {
    display: none;
    width: 100%;
    padding: 12px;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.logo-box {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 15px var(--primary-glow);
}

.badge-pro {
    font-size: 0.6rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 1px;
    color: var(--accent);
}

.scroll-area {
    flex-grow: 1;
    overflow-y: auto;
    padding-right: 10px;
}

.scroll-area::-webkit-scrollbar {
    width: 4px;
}

.scroll-area::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 2px;
}

/* CONTROLS */
.section-title {
    font-size: 0.7rem;
    font-weight: 700;
    color: #666;
    margin: 20px 0 10px 0;
    letter-spacing: 1px;
}

.control-group {
    margin-bottom: 18px;
}

.label-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.85rem;
}

.label-title {
    color: #e5e5e5;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.val-tag {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-family: monospace;
    color: var(--accent);
}

/* SLIDERS */
.slider-container {
    position: relative;
    height: 30px;
    display: flex;
    align-items: center;
}

input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    height: 30px;
    background: transparent;
    cursor: pointer;
    margin: 0;
    position: relative;
    z-index: 2;
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    border: none;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background: white;
    margin-top: -7px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
    transition: transform 0.1s;
}

input[type=range]:hover::-webkit-slider-thumb {
    transform: scale(1.15);
}

/* BUTTONS */
.segmented-control {
    background: rgba(0, 0, 0, 0.4);
    padding: 4px;
    border-radius: 8px;
    display: flex;
    gap: 4px;
}

.seg-btn {
    flex: 1;
    padding: 8px;
    background: transparent;
    border: none;
    color: #888;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 6px;
    transition: 0.2s;
}

.seg-btn:hover {
    color: white;
}

.seg-btn.active {
    background: #333;
    color: white;
}

.color-wrapper {
    width: 100%;
    height: 36px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
    cursor: pointer;
    background: rgba(0, 0, 0, 0.3);
}

input[type="color"] {
    -webkit-appearance: none;
    border: none;
    width: 110%;
    height: 110%;
    margin: -2px;
    padding: 0;
    background: transparent;
    cursor: pointer;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}

.btn-glass {
    width: 100%;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: 0.2s;
    font-size: 0.85rem;
    font-weight: 600;
}

.btn-glass:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-color: rgba(255, 255, 255, 0.3);
}

.btn-glass.active {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-primary-glow {
    width: 100%;
    padding: 16px;
    margin-top: 10px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), #4f46e5);
    color: white;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 20px var(--primary-glow);
    transition: 0.3s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.btn-primary-glow:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px var(--primary-glow);
}

.divider {
    height: 1px;
    background: var(--glass-border);
    margin: 20px 0;
}

/* NEW: SUPPORT BUTTON STYLES */
.btn-coffee {
    color: #fbbf24 !important;
    /* Gold Text */
    border-color: rgba(251, 191, 36, 0.3) !important;
}

.btn-coffee:hover {
    background: rgba(251, 191, 36, 0.1) !important;
    box-shadow: 0 0 15px rgba(251, 191, 36, 0.2);
    border-color: #fbbf24 !important;
}

/* EDITOR AREA */
.editor-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    margin-bottom: 10px;
    border-radius: 12px;
}

.glass-bar {
    background: rgba(20, 20, 20, 0.4);
    border: 1px solid var(--glass-border);
}

.stats {
    font-size: 0.8rem;
    color: #aaa;
    display: flex;
    align-items: center;
    gap: 8px;
}

.save-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #aaa;
}

.pulse-dot {
    width: 6px;
    height: 6px;
    background: #22c55e;
    border-radius: 50%;
    box-shadow: 0 0 8px #22c55e;
}

textarea {
    flex-grow: 1;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    border: 1px solid transparent;
    padding: 30px;
    color: #fff;
    font-size: 1.5rem;
    line-height: 1.6;
    resize: none;
    font-family: var(--font-stack);
    transition: 0.2s;
}

textarea:focus {
    border-color: rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.4);
}

textarea::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

/* --- PROMPTER LAYER --- */
.prompter-layer {
    position: fixed;
    inset: 0;
    background: black;
    z-index: 1000;
    overflow: hidden;
}

.prompter-layer::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(to bottom, black 0%, transparent 10%, transparent 90%, black 100%);
    z-index: 10;
}

.text-content {
    width: 90%;
    max-width: 1400px;
    margin: 0 auto;
    overflow-wrap: anywhere;
    word-break: normal;
    white-space: pre-wrap;
    color: white;
    font-weight: 800;
    text-align: left;
    padding-top: 50vh;
    padding-bottom: 100vh;
    will-change: transform;
    position: relative;
    z-index: 1;
    text-shadow: 1px 1px 0px rgba(0, 0, 0, 1);
    line-height: 1.5;
}

.mirrored {
    transform: scaleX(-1);
}

.flipped-y {
    transform: scaleY(-1);
}

.mirrored.flipped-y {
    transform: scale(-1, -1);
}

/* --- HUD & CAPTIONS --- */
.glass-hud {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 20, 20, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(15px);
    padding: 12px 25px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 20px;
    z-index: 2000;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
    opacity: 0;
    transition: 0.3s;
}

.prompter-layer:hover .glass-hud,
.glass-hud.mobile-visible {
    opacity: 1;
}

.hud-icon {
    background: none;
    border: none;
    color: #aaa;
    font-size: 1.1rem;
    cursor: pointer;
    transition: 0.2s;
}

.hud-icon:hover {
    color: white;
}

.hud-main-icon {
    background: white;
    border: none;
    color: black;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hud-sep {
    width: 1px;
    height: 16px;
    background: rgba(255, 255, 255, 0.1);
}

#liveCaption {
    position: fixed;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 10px 20px;
    border-radius: 50px;
    color: #4ade80;
    font-size: 1.2rem;
    font-weight: 600;
    z-index: 2000;
    pointer-events: none;
    max-width: 80%;
    text-align: center;
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s;
}

#liveCaption.visible {
    opacity: 1;
}

.highlight-word {
    background-color: rgba(99, 102, 241, 0.5);
    color: white;
    border-radius: 4px;
    padding: 0 2px;
    transition: background 0.2s;
}

.countdown-layer {
    position: fixed;
    inset: 0;
    background: black;
    z-index: 3000;
    display: flex;
    justify-content: center;
    align-items: center;
}

#countNum {
    font-size: 12rem;
    font-weight: 900;
    color: white;
    text-shadow: 0 0 50px var(--primary);
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    80% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 4000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: #18181b;
    border: 1px solid #333;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    animation: slideIn 0.3s ease-out forwards;
    min-width: 250px;
}

.toast i {
    color: var(--accent);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    z-index: 3000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-box {
    padding: 30px;
    width: 320px;
    text-align: center;
    background: #111;
    border: 1px solid #333;
    border-radius: 16px;
}

.modal-icon {
    width: 50px;
    height: 50px;
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin: 0 auto 15px auto;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    justify-content: center;
}

.btn-danger {
    background: var(--danger);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

.btn-ghost {
    background: transparent;
    border: 1px solid #444;
    color: #ccc;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
}

#webcamFeed {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    opacity: 0.6;
    transform: scaleX(-1);
}

.camera-active .text-content {
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 1);
}

#cameraBtn.active,
#voiceBtn.active {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--danger);
    color: var(--danger);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.2);
}

/* --- MOBILE BREAKPOINTS --- */
@media (max-width: 768px) {
    .app-layout {
        flex-direction: column;
        padding: 0;
        height: calc(100vh - 60px);
        margin-top: 60px;
    }

    .mobile-header {
        display: flex;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 85%;
        max-width: 300px;
        transform: translateX(-100%);
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
        padding-top: 20px;
        z-index: 2000;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .close-sidebar-btn {
        display: block;
    }

    .hidden-mobile {
        display: none;
    }

    .hidden-desktop {
        display: block;
    }

    .editor-area {
        height: 100%;
        padding: 10px;
    }

    textarea {
        padding: 15px;
        font-size: 1.1rem;
    }

    .glass-hud {
        width: 90%;
        padding: 10px 15px;
        bottom: 20px;
        opacity: 1;
    }

    .toast-container {
        top: 70px;
        left: 20px;
        right: 20px;
        width: auto;
    }
}
