:root {
    --bg-color: #050510;
    --panel-bg: rgba(15, 20, 35, 0.75);
    --primary-cyan: #00f3ff;
    --secondary-pink: #d946ef;
    --alert-red: #ff3333;
    --warning-yellow: #facc15;
    --text-color: #e2e8f0;
    --grid-line: rgba(0, 243, 255, 0.05);
    --font-main: 'Inter', 'Noto Sans JP', sans-serif;
    --font-display: 'Orbitron', 'Inter', sans-serif;
    --glass-border: 1px solid rgba(0, 243, 255, 0.2);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-main);
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-image:
        radial-gradient(circle at 50% 0%, #1a1a3a 0%, transparent 60%),
        linear-gradient(0deg, transparent 24%, var(--grid-line) 25%, var(--grid-line) 26%, transparent 27%, transparent 74%, var(--grid-line) 75%, var(--grid-line) 76%, transparent 77%, transparent),
        linear-gradient(90deg, transparent 24%, var(--grid-line) 25%, var(--grid-line) 26%, transparent 27%, transparent 74%, var(--grid-line) 75%, var(--grid-line) 76%, transparent 77%, transparent);
    background-size: 100% 100%, 60px 60px, 60px 60px;
    padding: 20px;
}

/* Utilities */
.hidden {
    display: none !important;
}

/* Tabs */
.tab-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    background: rgba(0, 0, 0, 0.2);
    padding: 4px;
    border-radius: 6px;
    width: fit-content;
}

.cyber-btn.sm {
    padding: 6px 16px;
    font-size: 0.85rem;
    min-width: auto;
    border-radius: 4px;
}

.cyber-btn.active {
    background: rgba(0, 243, 255, 0.15);
    color: var(--primary-cyan);
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.2);
    border-color: var(--primary-cyan);
}

/* File Input */
input[type="file"] {
    display: none;
}

.file-trigger {
    display: inline-block;
    margin-right: 15px;
}

#file-name-display {
    font-family: var(--font-display);
    color: #94a3b8;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
}

#file-playback-controls {
    margin-top: 20px;
    display: flex;
    gap: 12px;
}

.btn-group {
    display: flex;
    gap: 12px;
    width: 100%;
    justify-content: center;
    margin-bottom: 15px;
}

.container {
    width: 100%;
    max-width: 960px;
    background: var(--panel-bg);
    border: var(--glass-border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden;
}

/* Decorative corner lines */
.container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 60px;
    height: 60px;
    border-top: 2px solid var(--primary-cyan);
    border-left: 2px solid var(--primary-cyan);
    border-radius: 16px 0 0 0;
    opacity: 0.8;
}

.container::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 60px;
    height: 60px;
    border-bottom: 2px solid var(--secondary-pink);
    border-right: 2px solid var(--secondary-pink);
    border-radius: 0 0 16px 0;
    opacity: 0.8;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 20px;
    margin-bottom: 30px;
}

h1 {
    font-family: var(--font-display);
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--primary-cyan);
    text-shadow: 0 0 20px rgba(0, 243, 255, 0.3);
    letter-spacing: 1px;
}

.subtitle {
    font-size: 0.9rem;
    color: var(--secondary-pink);
    vertical-align: super;
    font-weight: 400;
    opacity: 0.9;
}

.status-panel {
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: var(--font-display);
    font-size: 0.85rem;
    color: var(--primary-cyan);
    letter-spacing: 1px;
}

.pulse-indicator {
    width: 8px;
    height: 8px;
    background-color: var(--alert-red);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--alert-red);
    transition: all 0.3s ease;
}

.pulse-indicator.active {
    background-color: var(--primary-cyan);
    box-shadow: 0 0 15px var(--primary-cyan);
    animation: pulse 1.5s infinite ease-in-out;
}

@keyframes pulse {
    0% {
        opacity: 0.4;
        transform: scale(0.8);
    }

    50% {
        opacity: 1;
        transform: scale(1.1);
    }

    100% {
        opacity: 0.4;
        transform: scale(0.8);
    }
}

/* Visualizer */
.visualizer-container {
    width: 100%;
    height: 160px;
    background: rgba(0, 5, 10, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    margin-bottom: 30px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.8);
}

#waveform-canvas {
    width: 100%;
    height: 100%;
    display: block;
    opacity: 0.8;
}

/* Controls */
.controls-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
    margin-bottom: 35px;
}

.control-group {
    background: rgba(255, 255, 255, 0.02);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-left: 3px solid var(--grid-line);
    transition: all 0.3s ease;
}

.control-group:hover {
    background: rgba(255, 255, 255, 0.04);
    border-left-color: var(--primary-cyan);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
}

.control-group h2 {
    font-family: var(--font-display);
    font-size: 0.85rem;
    color: var(--secondary-pink);
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    opacity: 0.9;
}

.slider-wrapper {
    margin-bottom: 20px;
}

.slider-wrapper label {
    display: block;
    margin-bottom: 10px;
    font-size: 0.85rem;
    color: #94a3b8;
    font-weight: 500;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    outline: none;
    transition: background 0.3s;
}

input[type="range"]:hover {
    background: rgba(255, 255, 255, 0.2);
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--bg-color);
    border: 2px solid var(--primary-cyan);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 243, 255, 0.5);
    transition: all 0.2s ease;
    margin-top: -6px;
    /* Align center */
}

input[type="range"]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: transparent;
    border-radius: 2px;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.3);
    background: var(--primary-cyan);
    box-shadow: 0 0 15px var(--primary-cyan);
}

.value-display {
    font-family: var(--font-display);
    font-size: 0.9rem;
    color: var(--primary-cyan);
    float: right;
    margin-top: -24px;
    /* Align with label line or slider */
    position: relative;
    top: -2px;
    background: rgba(0, 243, 255, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
}

/* Actions */
.actions-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 30px;
}

.io-controls,
.export-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
    justify-content: center;
}

.record-controls,
.export-controls {
    opacity: 0.3;
    pointer-events: none;
    transition: all 0.5s ease;
    filter: grayscale(0.8);
}

.record-controls.active,
.export-controls.active {
    opacity: 1;
    pointer-events: all;
    filter: grayscale(0);
}

.disabled {
    cursor: not-allowed !important;
}

.cyber-btn {
    background: transparent;
    border: 1px solid var(--primary-cyan);
    color: var(--primary-cyan);
    padding: 12px 28px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    min-width: 140px;
    border-radius: 6px;
    z-index: 1;
}

.cyber-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 0%;
    height: 100%;
    background: var(--primary-cyan);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: -1;
    opacity: 0.1;
}

.cyber-btn:hover::before {
    width: 100%;
    opacity: 1;
}

.cyber-btn:hover {
    color: #000;
    box-shadow: 0 0 25px rgba(0, 243, 255, 0.4);
    text-shadow: none;
    border-color: var(--primary-cyan);
}

.cyber-btn.danger {
    border-color: var(--alert-red);
    color: var(--alert-red);
}

.cyber-btn.danger::before {
    background: var(--alert-red);
}

.cyber-btn.danger:hover {
    color: #fff;
    box-shadow: 0 0 25px rgba(255, 51, 51, 0.4);
}

.cyber-btn.warning {
    border-color: var(--warning-yellow);
    color: var(--warning-yellow);
}

.cyber-btn.warning::before {
    background: var(--warning-yellow);
}

.cyber-btn.warning:hover {
    color: #000;
    box-shadow: 0 0 25px rgba(255, 238, 0, 0.4);
}

.cyber-btn.success {
    border-color: var(--secondary-pink);
    color: var(--secondary-pink);
}

.cyber-btn.success::before {
    background: var(--secondary-pink);
}

.cyber-btn.success:hover {
    color: #fff;
    box-shadow: 0 0 25px rgba(255, 0, 255, 0.4);
}

input[type="text"] {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    padding: 12px 16px;
    font-family: monospace;
    width: 240px;
    border-radius: 6px;
    transition: all 0.3s;
}

input[type="text"]:focus {
    border-color: var(--primary-cyan);
    background: rgba(0, 0, 0, 0.5);
    outline: none;
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.2);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease-out;
}

.modal.hidden {
    display: none !important;
}

.modal-content {
    background: var(--panel-bg);
    border: 1px solid var(--primary-cyan);
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 0 40px rgba(0, 243, 255, 0.3);
    max-width: 500px;
    width: 90%;
    position: absolute;
    top: 40%;
    /* PC: Slightly above center */
    left: 50%;
    transform: translate(-50%, -50%);
    animation: slideUp 0.3s ease-out;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.modal-content p {
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 10px;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

.modal-actions .cyber-btn {
    width: 100%;
    max-width: 300px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translate(-50%, -40%);
        opacity: 0;
    }

    to {
        transform: translate(-50%, -50%);
        opacity: 1;
    }
}

/* Footer */
footer {
    margin-top: 40px;
    text-align: center;
    font-size: 0.75rem;
    color: #64748b;
    font-family: var(--font-display);
    letter-spacing: 1px;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.footer-btn {
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-color);
}

.footer-btn.support-btn {
    color: var(--secondary-pink);
    border-color: rgba(217, 70, 239, 0.3);
}

.footer-btn.support-btn:hover {
    background: rgba(217, 70, 239, 0.1);
    box-shadow: 0 0 15px rgba(217, 70, 239, 0.2);
}

.footer-btn.back-btn-footer {
    color: var(--primary-cyan);
    border-color: rgba(0, 243, 255, 0.3);
}

.footer-btn.back-btn-footer:hover {
    background: rgba(0, 243, 255, 0.1);
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.2);
}

@media (max-width: 768px) {
    .footer-links {
        gap: 10px;
        margin-bottom: 15px;
    }

    .footer-btn {
        width: 100%;
        text-align: center;
    }
}

.copyright {
    margin-top: 8px;
    font-size: 0.7rem;
    opacity: 0.8;
}

.blink {
    animation: blink 3s infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

@media (max-width: 768px) {
    .container {
        width: 100%;
        max-width: 100%;
        border-radius: 0;
        min-height: 100vh;
        height: auto;
        margin: 0;
        border: none;
        backdrop-filter: none;
        /* Improve performance on mobile */
        background: rgba(10, 10, 20, 0.95);
    }

    .container::before,
    .container::after {
        display: none;
        /* Remove decorative corners on mobile */
    }

    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    h1 {
        font-size: 1.8rem;
        display: flex;
        flex-direction: column;
        line-height: 1.2;
    }

    .subtitle {
        font-size: 0.8rem;
        margin-left: 0;
        margin-top: 5px;
        vertical-align: baseline;
    }

    .status-panel {
        width: 100%;
        justify-content: space-between;
        background: rgba(0, 243, 255, 0.05);
        padding: 5px 10px;
        border-radius: 4px;
    }

    .controls-container {
        grid-template-columns: 1fr;
        /* Force single column */
        gap: 15px;
    }

    .io-controls,
    .export-controls {
        flex-direction: column;
        width: 100%;
        gap: 10px;
    }

    .btn-group {
        flex-direction: column;
    }

    .cyber-btn {
        width: 100%;
        /* Full width buttons on mobile */
        padding: 12px;
    }

    #filename-input {
        width: 100%;
        margin-bottom: 10px;
    }

    audio {
        width: 100%;
        margin-top: 10px;
    }

    .visualizer-container {
        height: 120px;
    }

    /* Modal Mobile Overrides */
    .modal-content {
        top: auto;
        bottom: 20px;
        transform: translateX(-50%);
        animation: slideUpMobile 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
        width: 95%;
        padding: 20px;
        border-bottom: none;
        /* Looks better on mobile bottom sheet style */
        border-radius: 16px 16px 16px 16px;
    }

    @keyframes slideUpMobile {
        from {
            transform: translate(-50%, 100%);
            opacity: 0;
        }

        to {
            transform: translate(-50%, 0);
            opacity: 1;
        }
    }
}

/* Back Button */
/* Back Button */
.rovoice-back-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 100;
    text-decoration: none;
    background: rgba(0, 5, 10, 0.6);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
}

@media (max-width: 768px) {
    .rovoice-back-btn {
        top: 15px;
        left: 15px;
        width: 44px;
        height: 44px;
        padding: 0;
        border-radius: 50%;
        min-width: unset;
    }

    .rovoice-back-btn .btn-text {
        display: none;
    }

    .rovoice-back-btn .btn-icon {
        font-size: 1.2rem;
        margin-right: 0;
        transform: translateY(-1px);
        /* Slight optical alignment */
    }
}
