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

:root {
    --bg: #F5F5F7;
    --surface: #FFFFFF;
    --text: #1D1D1F;
    --text-secondary: #86868B;
    --accent: #0071E3;
    --accent-hover: #0077ED;
    --accent-pressed: #005BB5;
    --error: #FF3B30;
    --success: #34C759;
    --border: #D2D2D7;
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --shadow: 0 2px 12px rgba(0,0,0,0.06);
    --shadow-hover: 0 4px 20px rgba(0,0,0,0.1);
    --transition: 0.2s ease;
}

/* === Dark Mode === */
.dark {
    --bg: #1C1C1E;
    --surface: #2C2C2E;
    --text: #F5F5F7;
    --text-secondary: #98989D;
    --border: #3A3A3C;
    --shadow: 0 2px 12px rgba(0,0,0,0.3);
    --shadow-hover: 0 4px 20px rgba(0,0,0,0.4);
}

html {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 16px;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    padding: 0 16px;
}

/* === App Container === */
.app {
    width: 100%;
    max-width: 480px;
    padding: 48px 0 32px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* === Tool Nav === */
.tool-nav {
    display: flex;
    gap: 8px;
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 6px;
    box-shadow: var(--shadow);
}

.tool-nav-item {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    color: var(--text-secondary);
    transition: all var(--transition);
}

.tool-nav-item:hover {
    background: var(--bg);
    color: var(--text);
}

.tool-nav-item.active {
    background: var(--accent);
    color: white;
}

.tool-nav-icon { font-size: 16px; }

/* === Card Title === */
.card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}

/* === Platform Tags === */
.platform-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.platform-tag {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg);
    border-radius: 20px;
    padding: 3px 10px;
    white-space: nowrap;
}

/* === Tools Banner === */
.tools-banner {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tools-banner-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0 4px;
}

.tool-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow);
    text-decoration: none;
    color: var(--text);
    transition: box-shadow var(--transition), transform 0.15s;
    border: 1.5px solid transparent;
}

.tool-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-1px);
    border-color: var(--accent);
}

.tool-card-icon {
    font-size: 32px;
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    background: var(--bg);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tool-card-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tool-card-name {
    font-size: 14px;
    font-weight: 700;
}

.tool-card-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.tool-card-arrow {
    font-size: 22px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

/* === Header === */
.header {
    text-align: center;
    margin-bottom: 8px;
    position: relative;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.logo h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

/* === Card === */
.card {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 14px;
    animation: fadeUp 0.3s ease;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === Input === */
.input-group {
    position: relative;
}

.input-group input {
    width: 100%;
    padding: 14px 40px 14px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.input-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15);
}

.input-group input::placeholder {
    color: var(--text-secondary);
}

.btn-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    display: none;
}

.input-group input:not(:placeholder-shown) ~ .btn-clear {
    display: block;
}

/* === Buttons === */
.btn-primary {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: white;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background var(--transition), transform 0.1s;
    text-align: center;
    text-decoration: none;
    display: inline-block;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { background: var(--accent-pressed); transform: scale(0.98); }
.btn-primary:disabled {
    background: var(--border);
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    width: 100%;
    padding: 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text);
    font-size: 15px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background var(--transition);
}

.btn-secondary:hover { background: var(--bg); }

/* === Spinner === */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
}

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

/* === Error === */
.error-text {
    color: var(--error);
    font-size: 13px;
    text-align: center;
}

/* === Video Preview === */
.video-preview {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.video-preview img {
    width: 120px;
    height: 68px;
    object-fit: cover;
    border-radius: 8px;
    background: var(--bg);
    flex-shrink: 0;
}

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

.video-meta h2 {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.video-sub {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
    display: flex;
    gap: 8px;
}

/* === Toggle Group === */
.toggle-group {
    display: flex;
    background: var(--bg);
    border-radius: 8px;
    padding: 3px;
}

.toggle {
    flex: 1;
    padding: 8px;
    border: none;
    border-radius: 6px;
    background: transparent;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.toggle.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

/* === Quality Group === */
.quality-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.quality-chip {
    padding: 6px 14px;
    border: 1.5px solid var(--border);
    border-radius: 20px;
    background: transparent;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.quality-chip.active {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(0, 113, 227, 0.06);
}

/* === Progress === */
.progress-bar {
    height: 6px;
    background: var(--bg);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 30%;
    background: var(--accent);
    border-radius: 3px;
    animation: progress-indeterminate 1.5s ease-in-out infinite;
}

@keyframes progress-indeterminate {
    0% { width: 10%; margin-left: 0; }
    50% { width: 40%; margin-left: 30%; }
    100% { width: 10%; margin-left: 90%; }
}

.progress-text {
    text-align: center;
    font-size: 14px;
    color: var(--text-secondary);
}

/* === Done === */
.done-icon {
    width: 56px;
    height: 56px;
    background: var(--success);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
    margin: 0 auto;
    animation: popIn 0.3s ease;
}

@keyframes popIn {
    from { transform: scale(0.6); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.done-text {
    text-align: center;
    font-size: 18px;
    font-weight: 600;
}

.btn-download-link {
    text-align: center;
}

/* === Footer === */
.footer {
    text-align: center;
    padding: 24px 0;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.8;
}

/* === Desktop === */
@media (min-width: 640px) {
    .app {
        padding-top: 80px;
    }

    .card {
        padding: 24px;
    }

    .logo h1 {
        font-size: 32px;
    }
}

/* === Terms Page === */
.back-link {
    display: inline-block;
    color: var(--accent);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
}

.back-link:hover { text-decoration: underline; }

.terms-title {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.terms-card h2 {
    font-size: 15px;
    font-weight: 600;
    margin-top: 16px;
}

.terms-card h2:first-child { margin-top: 0; }

.terms-card p, .terms-card li {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-top: 6px;
}

.terms-card ul {
    padding-left: 20px;
    margin-top: 6px;
}

.terms-card li { margin-top: 4px; }

.contact-email {
    background: var(--bg);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
}

.terms-date {
    margin-top: 20px;
    font-size: 12px;
    color: var(--border);
    text-align: right;
}

.footer a {
    color: var(--text-secondary);
    text-decoration: none;
}

.footer a:hover {
    color: var(--accent);
    text-decoration: underline;
}

/* === Dark Toggle === */
.dark-toggle {
    position: absolute;
    right: 16px;
    top: 48px;
    background: none;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 16px;
    cursor: pointer;
    transition: background var(--transition);
}
.dark-toggle:hover { background: var(--bg); }

/* === Clipboard Toast === */
.clipboard-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: var(--text);
    color: var(--surface);
    padding: 10px 18px;
    border-radius: 20px;
    font-size: 13px;
    white-space: nowrap;
    z-index: 999;
    transition: transform 0.3s ease, opacity 0.3s ease;
    opacity: 0;
}
.clipboard-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* === History === */
.section-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.history-item:last-child { border-bottom: none; }

.history-item img {
    width: 56px;
    height: 32px;
    object-fit: cover;
    border-radius: 6px;
    background: var(--bg);
    flex-shrink: 0;
}

.history-meta {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.history-title {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-url {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-use {
    background: none;
    border: 1.5px solid var(--border);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 14px;
    cursor: pointer;
    color: var(--accent);
    flex-shrink: 0;
    transition: background var(--transition);
}
.history-use:hover { background: var(--bg); }

/* === Chip filesize === */
.chip-size {
    font-size: 11px;
    color: var(--text-secondary);
    margin-left: 4px;
    font-weight: 400;
}

/* === Thumbnail Modal === */
.thumb-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    cursor: zoom-out;
}
.thumb-modal img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 12px;
    object-fit: contain;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* === Convert Page === */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
}
.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--accent);
    background: rgba(0, 113, 227, 0.04);
}
.drop-icon { font-size: 40px; }
.drop-text { font-size: 15px; font-weight: 600; }
.drop-sub  { font-size: 13px; color: var(--text-secondary); }
.drop-hint { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

.btn-upload-label {
    cursor: pointer;
    padding: 10px 24px;
    width: auto;
    display: inline-block;
}

.file-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
}
.file-icon { font-size: 24px; }
.file-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.file-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { font-size: 12px; color: var(--text-secondary); }

.btn-remove {
    background: none;
    border: none;
    font-size: 16px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    flex-shrink: 0;
}
.btn-remove:hover { color: var(--error); }

.option-group { display: flex; flex-direction: column; gap: 8px; }
.option-label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }

.quality-options { display: flex; flex-direction: column; gap: 8px; }
.quality-option { cursor: pointer; }
.quality-option input { display: none; }
.quality-card {
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    gap: 2px;
    transition: all var(--transition);
}
.quality-card:hover { border-color: var(--accent); }
.quality-card.active {
    border-color: var(--accent);
    background: rgba(0, 113, 227, 0.06);
}
.quality-name { font-size: 14px; font-weight: 600; }
.quality-desc { font-size: 12px; color: var(--text-secondary); }

.res-group { flex-wrap: wrap; }
.res-group .toggle { flex: none; padding: 6px 12px; font-size: 13px; }

/* ── Feedback Section ──────────────────────────────────────────────────────── */
.feedback-section {
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-top: 4px;
}
.fb-toggle {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: none;
    border: none;
    padding: 14px 16px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    text-align: left;
    transition: background var(--transition);
}
.fb-toggle:hover { background: rgba(0,0,0,.03); }
html.dark .fb-toggle:hover { background: rgba(255,255,255,.05); }
.fb-toggle-arrow { font-size: 11px; color: var(--text-secondary); transition: transform .2s; }
.fb-toggle-arrow.open { transform: rotate(180deg); }

.fb-body {
    padding: 0 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
#fb-text {
    width: 100%;
    min-height: 100px;
    padding: 10px 12px;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    outline: none;
    transition: border-color var(--transition);
}
#fb-text:focus { border-color: var(--accent); }
#fb-text::placeholder { color: var(--text-secondary); }

.fb-file-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--bg);
    border: 1.5px dashed var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: border-color var(--transition), color var(--transition);
    width: fit-content;
}
.fb-file-label:hover { border-color: var(--accent); color: var(--accent); }
.fb-file-name {
    font-size: 12px;
    color: var(--accent);
    font-weight: 600;
    min-height: 16px;
}
.fb-submit-btn {
    padding: 11px 24px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background var(--transition);
    align-self: flex-start;
}
.fb-submit-btn:hover { background: var(--accent-hover); }
.fb-submit-btn:disabled { opacity: .5; cursor: default; }
.fb-status {
    font-size: 13px;
    min-height: 18px;
    font-weight: 600;
}
.fb-status.ok  { color: var(--success); }
.fb-status.err { color: var(--error); }
