/* ══════════════════════════════════════════
   YT 下載工具 — 深色玻璃態主題（混合架構 v2）
   ══════════════════════════════════════════ */

/* ── 設計變數 ── */
:root {
    --bg-primary: #07071a;
    --bg-gradient: linear-gradient(145deg, #07071a 0%, #1a0a30 40%, #0a1a30 100%);
    --glass-bg: rgba(255, 255, 255, 0.035);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-hover: rgba(255, 255, 255, 0.07);
    --accent: #ff4757;
    --accent-light: #ff6b81;
    --accent-glow: rgba(255, 71, 87, 0.25);
    --accent-gradient: linear-gradient(135deg, #ff4757, #ff6b81, #ff4757);
    --success: #2ed573;
    --success-glow: rgba(46, 213, 115, 0.25);
    --info: #1e90ff;
    --info-glow: rgba(30, 144, 255, 0.2);
    --purple: #a55eea;
    --purple-glow: rgba(165, 94, 234, 0.2);
    --text-primary: #f0f0f5;
    --text-secondary: rgba(255, 255, 255, 0.5);
    --text-muted: rgba(255, 255, 255, 0.25);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --radius: 18px;
    --radius-sm: 12px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset ── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html { font-size: 16px; }

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ── 背景動態光暈 ── */
.bg-shapes {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    background: var(--bg-gradient);
}

.shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(140px);
    opacity: 0.12;
    will-change: transform;
}

.shape-1 {
    width: 650px;
    height: 650px;
    background: var(--accent);
    top: -250px;
    right: -200px;
    animation: floatA 22s ease-in-out infinite;
}

.shape-2 {
    width: 450px;
    height: 450px;
    background: #6c5ce7;
    bottom: -120px;
    left: -120px;
    animation: floatB 28s ease-in-out infinite;
}

.shape-3 {
    width: 350px;
    height: 350px;
    background: #00b4d8;
    top: 45%;
    left: 45%;
    animation: floatC 20s ease-in-out infinite;
}

@keyframes floatA {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33%      { transform: translate(40px, -40px) scale(1.06); }
    66%      { transform: translate(-25px, 25px) scale(0.95); }
}

@keyframes floatB {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50%      { transform: translate(35px, -30px) scale(1.08); }
}

@keyframes floatC {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50%      { transform: translate(-45%, -55%) scale(1.1); }
}

/* ── 主容器 ── */
.container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 720px;
    padding: 48px 24px 32px;
    margin: 0 auto;
}

/* ── Header ── */
.header {
    text-align: center;
    margin-bottom: 44px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 14px;
}

.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: var(--accent-gradient);
    background-size: 200% 200%;
    font-size: 24px;
    animation: shimmer 4s ease-in-out infinite;
    box-shadow: 0 6px 24px var(--accent-glow);
}

@keyframes shimmer {
    0%, 100% { background-position: 0% 50%; }
    50%      { background-position: 100% 50%; }
}

.header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, #fff 30%, rgba(255,255,255,0.6) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 300;
    letter-spacing: 0.18em;
}

/* ── 輸入區 ── */
.input-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 28px;
}

.input-wrapper {
    display: flex;
    align-items: center;
    background: var(--glass-bg);
    border: 1.5px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 4px;
    transition: var(--transition);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
}

.input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow:
        0 0 0 4px rgba(255, 71, 87, 0.12),
        0 8px 40px rgba(0, 0, 0, 0.4);
}

.input-icon {
    padding: 0 10px 0 18px;
    font-size: 1.25rem;
    opacity: 0.4;
    flex-shrink: 0;
}

#url-input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 1.05rem;
    padding: 18px 8px 18px 4px;
}

#url-input::placeholder {
    color: var(--text-muted);
    font-weight: 300;
}

.paste-btn {
    background: var(--glass-hover);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin-right: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition);
    flex-shrink: 0;
}

.paste-btn:hover {
    background: rgba(255, 255, 255, 0.12);
}

/* ── 主按鈕 ── */
.btn-primary {
    width: 100%;
    padding: 18px;
    border: none;
    border-radius: var(--radius);
    background: var(--accent-gradient);
    background-size: 200% 200%;
    color: white;
    font-family: var(--font);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    letter-spacing: 0.02em;
}

.btn-primary::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        105deg,
        transparent 35%,
        rgba(255, 255, 255, 0.12) 45%,
        rgba(255, 255, 255, 0.12) 55%,
        transparent 65%
    );
    background-size: 250% 100%;
    animation: btn-shine 4s ease-in-out infinite;
    pointer-events: none;
}

@keyframes btn-shine {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 36px var(--accent-glow);
}

.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary:disabled::after { display: none; }

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

.spinner-sm {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.btn-loading {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* ── 錯誤訊息 ── */
.error-msg {
    background: rgba(255, 71, 87, 0.08);
    border: 1px solid rgba(255, 71, 87, 0.25);
    border-radius: var(--radius-sm);
    padding: 14px 20px;
    color: var(--accent-light);
    font-size: 0.9rem;
    margin-bottom: 20px;
    animation: fadeShake 0.45s ease-out;
}

@keyframes fadeShake {
    0%   { opacity: 0; transform: translateX(-10px); }
    30%  { transform: translateX(8px); }
    60%  { transform: translateX(-5px); }
    100% { opacity: 1; transform: translateX(0); }
}

/* ── 影片資訊 ── */
.video-info {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    margin-bottom: 20px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    animation: fadeSlideUp 0.4s ease-out;
}

.video-thumb {
    width: 140px;
    height: 79px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    background: rgba(255,255,255,0.05);
}

.video-meta {
    flex: 1;
    min-width: 0;
}

.video-meta h3 {
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1.45;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.video-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 500;
    background: rgba(255,255,255,0.06);
    color: var(--text-secondary);
    border: 1px solid rgba(255,255,255,0.06);
}

.badge-accent {
    background: rgba(255, 71, 87, 0.12);
    color: var(--accent-light);
    border-color: rgba(255, 71, 87, 0.2);
}

/* ══════════════════════════════════════════
   功能選擇區 — 三張獨立卡片
   ══════════════════════════════════════════ */
.action-section {
    animation: fadeSlideUp 0.4s ease-out;
    margin-bottom: 8px;
}

.action-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}

.action-card {
    background: var(--glass-bg);
    border: 1.5px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 28px 16px 20px;
    text-align: center;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: var(--transition);
    animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.action-card:nth-child(1) { animation-delay: 0.05s; }
.action-card:nth-child(2) { animation-delay: 0.15s; }
.action-card:nth-child(3) { animation-delay: 0.25s; }

@keyframes popIn {
    from { opacity: 0; transform: translateY(20px) scale(0.92); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.action-card:hover {
    transform: translateY(-4px);
    border-color: rgba(255, 255, 255, 0.14);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

/* 完成狀態 */
.action-card.done {
    border-color: rgba(46, 213, 115, 0.3);
    box-shadow: 0 0 20px var(--success-glow);
}

.action-icon {
    font-size: 2.4rem;
    margin-bottom: 12px;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
}

.action-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 4px;
    letter-spacing: 0.02em;
}

.action-desc {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

/* 卡片內按鈕 */
.btn-action {
    width: 100%;
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--glass-hover);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-action:hover:not(:disabled) {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 4px 16px var(--accent-glow);
    transform: translateY(-1px);
}

.btn-action:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-action-loading {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* 卡片內進度條 */
.action-progress {
    width: 100%;
    margin-top: 14px;
}

.mini-progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 8px;
}

.mini-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent-gradient);
    background-size: 200% 200%;
    border-radius: 2px;
    transition: width 0.5s ease;
    animation: shimmer 2.5s ease-in-out infinite;
}

.mini-progress-text {
    font-size: 0.68rem;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.4;
    min-height: 2.8em;
    word-break: break-word;
}

/* 下載結果按鈕 */
.btn-download-result {
    display: inline-block;
    margin-top: 12px;
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--success), #7bed9f);
    border: none;
    border-radius: var(--radius-sm);
    color: #0a2a1a;
    text-decoration: none;
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn-download-result:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--success-glow);
}

.result-size {
    display: block;
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 6px;
}

/* 逐字稿預覽 */
.transcript-preview {
    width: 100%;
    margin-top: 12px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    font-size: 0.68rem;
    color: var(--text-secondary);
    line-height: 1.6;
    max-height: 80px;
    overflow-y: auto;
    text-align: left;
    word-break: break-word;
}

/* ── 次要按鈕 ── */
.btn-secondary {
    display: block;
    width: 100%;
    padding: 16px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-secondary:hover {
    background: var(--glass-hover);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.16);
}

/* ── Cookie 管理區 ── */
.cookie-section {
    margin-top: 32px;
}

.cookie-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.78rem;
    cursor: pointer;
    transition: var(--transition);
}

.cookie-toggle:hover {
    color: var(--text-secondary);
    border-color: var(--glass-border);
    background: rgba(255, 255, 255, 0.02);
}

.toggle-arrow {
    margin-left: auto;
    transition: transform 0.3s ease;
}

.cookie-toggle.open .toggle-arrow {
    transform: rotate(180deg);
}

.cookie-badge {
    background: var(--success);
    color: var(--bg-primary);
    font-size: 0.6rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 8px;
}

.cookie-panel {
    padding: 16px;
    margin-top: 8px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    animation: fadeSlideUp 0.25s ease-out;
}

.cookie-hint {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 14px;
}

.cookie-hint a {
    color: var(--accent);
    text-decoration: none;
}

.cookie-hint a:hover { text-decoration: underline; }

.cookie-hint small {
    color: var(--text-muted);
}

.cookie-hint strong {
    color: var(--text-primary);
    display: block;
    margin-bottom: 4px;
}

/* Cookie 教學步驟 */
.cookie-steps {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 14px 0 18px;
}

.cookie-step {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.cookie-step-num {
    width: 26px;
    height: 26px;
    min-width: 26px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    margin-top: 2px;
}

.cookie-step-content { flex: 1; }

.cookie-step-content strong {
    display: block;
    font-size: 0.8rem;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.cookie-step-content p {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

.cookie-step-content a {
    color: var(--accent);
    text-decoration: none;
}

.cookie-step-content a:hover { text-decoration: underline; }

.cookie-step-content code {
    background: rgba(255, 255, 255, 0.06);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.72rem;
    color: var(--accent-light);
}

.cookie-note {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    line-height: 1.5;
}

.cookie-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.btn-cookie-upload {
    padding: 8px 16px;
    background: var(--glass-hover);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.78rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-cookie-upload:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent);
}

.cookie-status {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.cookie-status.active {
    color: var(--success);
}

.btn-cookie-delete {
    padding: 6px 12px;
    background: transparent;
    border: 1px solid rgba(231, 76, 60, 0.3);
    border-radius: var(--radius-sm);
    color: var(--accent);
    font-family: var(--font);
    font-size: 0.72rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-cookie-delete:hover {
    background: rgba(231, 76, 60, 0.15);
    border-color: var(--accent);
}

/* ── Footer ── */
.footer {
    text-align: center;
    margin-top: 48px;
    color: var(--text-muted);
    font-size: 0.72rem;
    letter-spacing: 0.04em;
}

/* ── 動畫 ── */
@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── RWD ── */
@media (max-width: 600px) {
    .container {
        padding: 28px 16px 24px;
    }

    .header h1 { font-size: 1.65rem; }

    .logo-icon {
        width: 46px;
        height: 46px;
        font-size: 20px;
    }

    #url-input {
        font-size: 0.95rem;
        padding: 14px 6px 14px 2px;
    }

    .btn-primary { padding: 16px; font-size: 1rem; }

    /* 卡片在手機上改為垂直排列 */
    .action-cards {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .action-card {
        display: grid;
        grid-template-columns: auto 1fr auto;
        grid-template-rows: auto auto;
        gap: 4px 14px;
        padding: 16px 20px;
        text-align: left;
    }

    .action-icon {
        grid-row: 1 / 3;
        font-size: 2rem;
        margin-bottom: 0;
        align-self: center;
    }

    .action-title {
        grid-column: 2;
        font-size: 0.92rem;
        margin-bottom: 0;
        align-self: end;
    }

    .action-desc {
        grid-column: 2;
        margin-bottom: 0;
        align-self: start;
    }

    .btn-action {
        grid-row: 1 / 3;
        grid-column: 3;
        width: auto;
        align-self: center;
        padding: 10px 16px;
    }

    .action-progress {
        grid-column: 1 / -1;
        margin-top: 10px;
    }

    .btn-download-result {
        grid-column: 1 / -1;
        text-align: center;
    }

    .result-size {
        grid-column: 1 / -1;
        text-align: center;
    }

    .transcript-preview {
        grid-column: 1 / -1;
    }

    .video-info {
        flex-direction: column;
        align-items: stretch;
    }

    .video-thumb {
        width: 100%;
        height: auto;
        aspect-ratio: 16 / 9;
    }
}
