:root {
    --primary-color: #6c5ce7;
    --primary-hover: #5649c0;
    --secondary-bg: rgba(255, 255, 255, 0.1);
    --text-color: #ffffff;
    --text-muted: #a2a8d3;
    --bg-gradient: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --font-family: 'Outfit', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background: var(--bg-gradient);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    position: relative;
}

/* Background Animated Blobs */
.background-blobs {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: -1;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.6;
}

.blob-1 {
    top: -10%;
    left: -10%;
    width: 50vw;
    height: 50vw;
    background: #FF0080;
    animation: move1 20s infinite alternate;
}

.blob-2 {
    bottom: -10%;
    right: -10%;
    width: 60vw;
    height: 60vw;
    background: #7928CA;
    animation: move2 25s infinite alternate;
}

@keyframes move1 {
    from {
        transform: translate(0, 0);
    }

    to {
        transform: translate(50px, 100px);
    }
}

@keyframes move2 {
    from {
        transform: translate(0, 0);
    }

    to {
        transform: translate(-50px, -100px);
    }
}

/* Glassmorphism Container */
.glass-container {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: var(--glass-shadow);
    width: 90%;
    max-width: 600px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-height: 90vh;
}

header {
    text-align: center;
}

header h1 {
    font-weight: 700;
    font-size: 2rem;
    margin-bottom: 0.25rem;
    background: linear-gradient(to right, #fff, #a2a8d3);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Input Section */
.input-section {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-height: 200px;
    position: relative;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    overflow: hidden;
    /* Contains the toolbar and textarea */
}

.toolbar {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid var(--glass-border);
}

.btn-text {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-family);
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    transition: all 0.2s;
}

.btn-text:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

textarea,
.text-editor {
    width: 100%;
    height: 100%;
    min-height: 180px;
    /* Adjusted */
    background: transparent;
    /* Background now on container */
    border: none;
    border-radius: 0;
    padding: 1rem;
    color: var(--text-color);
    font-family: var(--font-family);
    font-size: 1rem;
    line-height: 1.5;
    resize: none;
    outline: none;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

textarea:focus,
.text-editor:focus {
    /* Focus styles handled by container or subtle change */
    background: rgba(0, 0, 0, 0.1);
}

textarea::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.char-count {
    text-align: right;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* Placeholder for contenteditable */
.text-editor:empty:before {
    content: attr(data-placeholder);
    color: rgba(255, 255, 255, 0.3);
    pointer-events: none;
}

/* Highlighted word style */
.text-editor .highlight {
    background: linear-gradient(120deg, #ffd700 0%, #ffed4e 100%);
    color: #000;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 500;
    transition: all 0.15s ease;
}

/* Controls */
.controls-section {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.settings-row {
    display: flex;
    gap: 1rem;
}

.setting-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

select {
    appearance: none;
    -webkit-appearance: none;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    color: white;
    font-family: var(--font-family);
    font-size: 0.95rem;
    outline: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23FFFFFF%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem top 50%;
    background-size: 0.65rem auto;
}

option {
    background: #24243e;
    /* Solid background for dropdown options */
    color: white;
}

input[type=range] {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    margin-top: -6px;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

/* Buttons */
.action-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
}

.btn {
    border: none;
    outline: none;
    border-radius: 12px;
    cursor: pointer;
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 1rem;
    padding: 0.8rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.btn-primary {
    flex: 2;
    background: white;
    color: var(--primary-color);
}

.btn-primary:hover {
    background: #f0f0f0;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 255, 255, 0.2);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    flex: 0.5;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Lock Screen */
.lock-screen {
    text-align: center;
    padding: 3rem 2rem;
    gap: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.lock-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.lock-screen h2 {
    font-size: 1.6rem;
    font-weight: 700;
    background: linear-gradient(to right, #fff, #a2a8d3);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.lock-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.lock-input-row {
    display: flex;
    gap: 0.5rem;
    width: 100%;
    max-width: 280px;
}

.lock-input-row input[type='password'] {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.8rem 1rem;
    color: white;
    font-family: var(--font-family);
    font-size: 1rem;
    outline: none;
    text-align: center;
    letter-spacing: 0.3em;
    transition: border-color 0.2s;
}

.lock-input-row input[type='password']:focus {
    border-color: var(--primary-color);
}

.lock-btn {
    flex: 0 0 auto;
    padding: 0.8rem 1.5rem;
}

.lock-error {
    color: #ff6b6b;
    font-size: 0.85rem;
    min-height: 1.3em;
}

.hidden {
    display: none;
}

/* Voice Mode Toggle */
.voice-mode-toggle {
    display: flex;
    gap: 0.5rem;
    padding: 4px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.mode-btn {
    flex: 1;
    padding: 0.6rem 1rem;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-family);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mode-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

.mode-btn.active {
    background: rgba(255, 255, 255, 0.12);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Worker URL Configuration */
.worker-input-row {
    display: flex;
    gap: 0.5rem;
}

.worker-input-row input[type='url'] {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 0.6rem 0.8rem;
    color: white;
    font-family: var(--font-family);
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s;
}

.worker-input-row input[type='url']::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.worker-input-row input[type='url']:focus {
    border-color: var(--primary-color);
}

.btn-small {
    padding: 0.6rem 1rem;
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    color: white;
    font-family: var(--font-family);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.btn-small:hover {
    background: rgba(255, 255, 255, 0.15);
}

.worker-status {
    font-size: 0.8rem;
    margin-top: 0.4rem;
    min-height: 1.2em;
    transition: all 0.2s;
}

.worker-status.success {
    color: #69db7c;
}

.worker-status.error {
    color: #ff6b6b;
}

.worker-status.warning {
    color: #ffd43b;
}

.worker-status.info {
    color: var(--text-muted);
}

/* Compatibility Banner */
.compat-banner {
    background: rgba(255, 152, 0, 0.15);
    border: 1px solid rgba(255, 152, 0, 0.4);
    border-radius: 12px;
    padding: 0.8rem 1rem;
    font-size: 0.85rem;
    line-height: 1.5;
    color: #ffd180;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    animation: bannerSlide 0.3s ease-out;
}

.compat-banner code {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
}

.banner-close {
    background: transparent;
    border: none;
    color: #ffd180;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.banner-close:hover {
    opacity: 1;
}

@keyframes bannerSlide {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile responsiveness — height-based */
@media (max-height: 700px) {
    .glass-container {
        padding: 1.5rem;
        height: 100vh;
        height: 100dvh;
        width: 100%;
        max-width: 100%;
        border-radius: 0;
        border: none;
    }

    header h1 {
        font-size: 1.5rem;
    }
}

/* Mobile responsiveness — width-based */
@media (max-width: 768px) {
    body {
        align-items: flex-start;
    }

    .glass-container {
        width: 100%;
        max-width: 100%;
        min-height: 100vh;
        min-height: 100dvh;
        border-radius: 0;
        border: none;
        padding: 1.2rem;
        gap: 1rem;
    }

    header h1 {
        font-size: 1.6rem;
    }

    header p {
        font-size: 0.85rem;
    }

    textarea,
    .text-editor {
        min-height: 150px;
        font-size: 0.95rem;
    }

    .btn {
        padding: 0.9rem 1.2rem;
        min-height: 48px;
    }

    .btn-text {
        padding: 0.5rem 0.8rem;
        min-height: 44px;
    }

    select {
        padding: 0.85rem 1rem;
        min-height: 48px;
    }

    .settings-row {
        flex-direction: column;
        gap: 0.8rem;
    }

    .mode-btn {
        font-size: 0.8rem;
        padding: 0.5rem 0.6rem;
    }

    .worker-input-row {
        flex-direction: column;
    }

    .blob-1,
    .blob-2 {
        animation-duration: 30s;
        opacity: 0.4;
    }
}