:root {
    --main-pink: #FFA1C9;
    --sky-blue: #87CEEB;
    --mint-green: #98FB98;
    --deep-purple: #9370DB;
    --bg-blur: blur(12px);
}

[data-theme="dark"] {
    --main-pink: #FF69B4;
    --sky-blue: #4682B4;
    --deep-purple: #6A5ACD;
}

*, *:before, *:after {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(145deg, var(--sky-blue) 0%, var(--main-pink) 100%);
    min-height: 100vh;
    padding: 10px;
    position: relative;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

[data-theme="dark"] body {
    background: linear-gradient(145deg, #2F4F4F, #4B0082);
}

.anime-character {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 0;
    pointer-events: none;
    max-width: 200px;
    opacity: 0.9;
    display: none;
    transition: transform 0.3s ease;
}

.anime-character:hover {
    transform: scale(1.1);
}

.widgets-container {
    position: fixed;
    top: 5px;
    right: 5px;
    display: flex;
    gap: 8px;
    z-index: 1000;
}

.widget-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: var(--bg-blur);
    padding: 6px 12px;
    border-radius: 15px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
}

@supports not (backdrop-filter: blur(12px)) {
    .widget-card, .main-container, .media-card, .footer {
        background: rgba(255, 255, 255, 0.8);
    }
}

.main-container {
    position: relative;
    max-width: 800px;
    margin: 10px auto;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: var(--bg-blur);
    border-radius: 20px;
    padding: 15px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

#theme-toggle {
    position: absolute;
    top: 15px;
    right: 15px;
    padding: 8px;
    border-radius: 50%;
    background: var(--deep-purple);
    color: white;
    border: none;
    cursor: pointer;
    transition: background 0.3s;
}

#theme-toggle:hover {
    background: var(--main-pink);
}

#random-quote {
    text-align: center;
    color: #6A5ACD;
    background: rgba(255, 255, 255, 0.7);
    padding: 10px;
    border-radius: 10px;
    margin-bottom: 15px;
    font-size: 14px;
    cursor: pointer;
}

.input-box {
    position: relative;
    margin: 15px 0;
    background: #fff;
    border-radius: 40px;
    box-shadow: 0 3px 12px rgba(255, 161, 201, 0.2);
    overflow: hidden;
}

#urlInput {
    width: 100%;
    padding: 12px 100px 12px 40px;
    border: none;
    background: transparent;
    font-size: 14px;
    color: #6A5ACD;
    outline: none;
}

#urlInput::placeholder {
    color: #A9A9A9;
    font-size: 13px;
}

#urlInput:focus {
    box-shadow: 0 0 0 2px var(--deep-purple);
}

.input-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #C8A2C8;
    font-size: 16px;
}

.parse-btn, .download-btn, .download-all-btn, .share-btn, #feedback-btn {
    padding: 8px 15px;
    background: linear-gradient(135deg, var(--deep-purple), var(--main-pink));
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    touch-action: manipulation;
    transition: filter 0.2s, transform 0.2s;
}

.download-btn, .download-all-btn, .share-btn, #feedback-btn {
    position: static;
}

.parse-btn:hover, .download-btn:hover, .download-all-btn:hover, .share-btn:hover, #feedback-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.parse-btn:focus, .download-btn:focus, .download-all-btn:focus, .share-btn:focus, #feedback-btn:focus {
    outline: 2px solid var(--deep-purple);
}

.parse-btn:active {
    transform: scale(0.95);
    transition: transform 0.1s;
}

.parse-btn.parsing {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.parse-btn:disabled, .download-btn:disabled, .download-all-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    animation: none;
}

.media-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 15px;
    margin: 15px 0;
    overflow: hidden;
}

.video-container {
    position: relative;
    padding-top: 56.25%;
    border-radius: 12px;
    overflow: hidden;
}

.video-cover {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.progress-bar {
    width: 100%;
    height: 8px;
    margin: 10px 0;
    border-radius: 5px;
    background: #eee;
    accent-color: var(--deep-purple);
}

.download-info {
    text-align: center;
    color: #6A5ACD;
    font-size: 12px;
}

.gallery-item {
    position: relative;
    cursor: zoom-in;
    transition: transform 0.2s;
}

.gallery-item:hover {
    transform: scale(1.05);
}

.gallery-item:focus {
    outline: 2px solid var(--deep-purple);
}

.image-index {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 4px;
    border-radius: 8px;
}

.bouncing-loader {
    display: flex;
    justify-content: center;
    margin: 12px 0;
}

.bouncing-loader div {
    width: 10px;
    height: 10px;
    margin: 3px;
    background: var(--deep-purple);
    border-radius: 50%;
    animation: bouncing 0.6s infinite alternate;
    will-change: transform;
}

.bouncing-loader div:nth-child(2) {
    animation-delay: 0.2s;
}

.bouncing-loader div:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes bouncing {
    to {
        translate: 0 -10px;
    }
}

.debug-info {
    position: fixed;
    bottom: 5px;
    left: 5px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 6px;
    border-radius: 4px;
    font-size: 11px;
    z-index: 9999;
    max-width: 90%;
}

.platform-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
    margin: 15px 0;
}

.platform-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 10px;
    text-decoration: none;
    color: #6A5ACD;
    transition: transform 0.2s;
    position: relative;
}

.platform-item:hover, .platform-item:focus {
    transform: scale(1.05);
}

.platform-item:focus {
    outline: 2px solid var(--deep-purple);
}

.platform-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
    border-radius: 4px;
    cursor: zoom-in;
}

.platform-tooltip {
    display: none;
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: #6A5ACD;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    z-index: 10;
    white-space: nowrap;
}

.platform-item:hover .platform-tooltip, .platform-item:focus .platform-tooltip {
    display: block;
}

.tutorial-content {
    background: rgba(255, 255, 255, 0.8);
    padding: 15px;
    border-radius: 10px;
}

.tutorial-content ol {
    margin: 0;
    padding-left: 20px;
}

.faq details {
    margin: 10px 0;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 10px;
    padding: 10px;
}

.faq summary {
    cursor: pointer;
    font-weight: bold;
    color: #6A5ACD;
}

.faq p {
    margin: 10px 0;
}

.share-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

#feedback-btn {
    display: block;
    margin: 15px auto;
}

#feedback-form {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    max-width: 90%;
}

#feedback-form textarea {
    width: 100%;
    height: 100px;
    margin: 10px 0;
    border-radius: 10px;
    border: 1px solid #ccc;
    padding: 10px;
}

#feedback-form button {
    margin: 5px;
}

#visitor-count {
    text-align: center;
    color: #6A5ACD;
    margin: 15px 0;
    font-size: 14px;
}

.history-box {
    margin-top: 15px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.8);
    padding: 8px;
    margin: 5px 0;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s;
}

.history-item:hover {
    background: rgba(255, 255, 255, 1);
}

.history-item:focus {
    outline: 2px solid var(--deep-purple);
}

.delete-history {
    background: none;
    border: none;
    color: #FF4500;
    cursor: pointer;
    font-size: 16px;
}

.footer {
    text-align: center;
    margin-top: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 10px;
    color: #6A5ACD;
    font-size: 12px;
}

.back-to-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 10px;
    background: var(--deep-purple);
    color: white;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    z-index: 1000;
}

.back-to-top:hover {
    background: var(--main-pink);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

@media (max-width: 360px) {
    .main-container {
        padding: 10px;
    }
    #urlInput {
        font-size: 12px;
        padding-right: 90px;
    }
    .parse-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    .platform-icon {
        width: 18px;
        height: 18px;
    }
}

@media (max-width: 480px) {
    .main-container {
        padding: 12px;
    }
    #urlInput {
        font-size: 13px;
        padding-right: 95px;
    }
    .parse-btn {
        padding: 7px 14px;
        font-size: 12px;
    }
    .widgets-container {
        top: 5px;
        right: 5px;
    }
    .platform-list {
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    }
    .platform-item {
        padding: 6px;
        font-size: 12px;
    }
    .platform-icon {
        width: 20px;
        height: 20px;
    }
}

@media (min-width: 768px) {
    .main-container {
        padding: 25px;
        margin: 15px auto;
    }
    #urlInput {
        font-size: 15px;
        padding: 14px 120px 14px 45px;
    }
    .parse-btn {
        padding: 10px 20px;
        font-size: 14px;
    }
    .anime-character {
        display: block;
    }
}

@media (min-width: 1024px) {
    .main-container {
        max-width: 900px;
    }
}