* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

button,
a,
label,
.nav-item,
.tool-card,
.feature-tab,
.tab-btn,
.btn,
.upload-box,
.crop-ratio-btn,
.tool-panel,
.tool-panel-title,
[onclick],
[role="button"] {
    user-select: none;
    -webkit-user-select: none;
}

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --accent: #06b6d4;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg-dark: #0a0a0f;
    --bg-card: #12121a;
    --bg-card-hover: #1a1a25;
    --bg-input: #1e1e2d;
    --border: #2a2a3a;
    --text: #f1f1f1;
    --text-muted: #9ca3af;
    --gradient-1: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);
    --gradient-2: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
    --shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 260px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text);
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--gradient-1);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.logo-text {
    font-weight: 700;
    font-size: 18px;
}

.logo-text span {
    color: var(--primary-light);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 20px;
}

.nav-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0 12px;
    margin-bottom: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 4px;
    color: var(--text-muted);
    text-decoration: none;
}

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

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

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

.nav-item-text {
    font-size: 14px;
    font-weight: 500;
}

.nav-item-badge {
    margin-left: auto;
    background: var(--primary);
    color: white;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.nav-item.active .nav-item-badge {
    background: rgba(255, 255, 255, 0.2);
}

/* Main Content */
.main-content {
    margin-left: 260px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-title {
    font-size: 20px;
    font-weight: 600;
}

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

.api-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--bg-input);
    border-radius: 8px;
    font-size: 13px;
}

.api-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger);
}

.api-status-dot.connected {
    background: var(--success);
}

.settings-btn {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text);
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
}

.settings-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--primary);
}

/* Page Content */
.page-content {
    flex: 1;
    padding: 24px;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 16px;
}

/* Tool Card */
.tool-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.tool-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-1);
    opacity: 0;
    transition: opacity 0.3s;
}

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

.tool-card:hover::before {
    opacity: 1;
}

.tool-card-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 14px;
}

.tool-card-icon.video {
    background: linear-gradient(135deg, #ef4444 0%, #f97316 100%);
}

.tool-card-icon.transcribe {
    background: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
}

.tool-card-icon.translate {
    background: linear-gradient(135deg, #8b5cf6 0%, #d946ef 100%);
}

.tool-card-icon.subtitle {
    background: linear-gradient(135deg, #10b981 0%, #06b6d4 100%);
}

.tool-card-icon.voice {
    background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
}

.tool-card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
}

.tool-card-desc {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 14px;
    line-height: 1.5;
}

.tool-card-features {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tool-feature-tag {
    font-size: 10px;
    padding: 3px 8px;
    background: var(--bg-input);
    border-radius: 5px;
    color: var(--text-muted);
}

/* Tool Pages */
.tool-page {
    display: none;
}

.tool-page.active {
    display: block;
}

.tool-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.tool-header-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.tool-header-icon.video {
    background: linear-gradient(135deg, #ef4444 0%, #f97316 100%);
}

.tool-header-icon.transcribe {
    background: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
}

.tool-header-icon.translate {
    background: linear-gradient(135deg, #8b5cf6 0%, #d946ef 100%);
}

.tool-header-icon.subtitle {
    background: linear-gradient(135deg, #10b981 0%, #06b6d4 100%);
}

.tool-header-icon.voice {
    background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
}

.tool-header-info h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.tool-header-info p {
    color: var(--text-muted);
    font-size: 14px;
}

.tool-content {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
}

.tool-main {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    min-height: 400px;
}

.tool-sidebar {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tool-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
}

.tool-panel-title {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 14px;
}

/* Forms */
.form-group {
    margin-bottom: 14px;
}

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-muted);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    transition: all 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-textarea {
    min-height: 120px;
    resize: vertical;
}

/* Upload Zone */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.upload-zone:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.upload-zone-icon {
    font-size: 40px;
    margin-bottom: 12px;
}

.upload-zone-title {
    font-size: 15px;
    font-weight: 600;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
}

.btn-primary {
    background: var(--gradient-1);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
}

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

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* File Info */
.file-info {
    padding: 14px;
    background: var(--bg-input);
    border-radius: 10px;
    margin-top: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Result Area */
.result-area {
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-input);
    border-radius: 10px;
    display: none;
}

.result-area.active {
    display: block;
}

/* Translate Grid */
.translate-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 90%;
    max-width: 440px;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--bg-input);
    border: none;
    color: var(--text);
    cursor: pointer;
    font-size: 18px;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Notification */
.notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s;
    z-index: 1001;
}

.notification.show {
    transform: translateY(0);
    opacity: 1;
}

.notification.success {
    border-color: var(--success);
}

.notification.error {
    border-color: var(--danger);
}

/* Spinner */
.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Downloader Styles */

/* Platform Tabs */
.platform-tabs {
    display: flex;
    gap: 8px;
    padding: 0 24px;
    margin-bottom: 20px;
}

.platform-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--bg-card);
    border: 2px solid transparent;
    border-radius: 12px;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.platform-tab:hover {
    background: var(--bg-input);
    color: var(--text-primary);
}

.platform-tab.active {
    background: var(--bg-card);
    border-color: var(--primary);
    color: var(--primary);
}

.platform-tab.active[data-platform="youtube"] {
    border-color: #ff0000;
    color: #ff0000;
}

.platform-tab.active[data-platform="tiktok"] {
    border-color: #00f2ea;
    color: #00f2ea;
}

.platform-tab.active[data-platform="facebook"] {
    border-color: #1877f2;
    color: #1877f2;
}

.tab-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.platform-tab[data-platform="youtube"] .tab-icon {
    fill: currentColor;
}

.platform-tab[data-platform="tiktok"] .tab-icon {
    fill: currentColor;
}

.platform-tab[data-platform="facebook"] .tab-icon {
    fill: currentColor;
}

/* Platform Panels */
.platform-panel {
    display: none;
}

.platform-panel.active {
    display: block;
}

/* Platform Header */
.platform-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    font-size: 16px;
    font-weight: 600;
}

.platform-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 10px;
    border-radius: 12px;
}

.platform-logo svg {
    width: 24px;
    height: 24px;
}

.platform-logo.youtube {
    background: rgba(255, 0, 0, 0.1);
}

.platform-logo.tiktok {
    background: rgba(0, 0, 0, 0.1);
}

.platform-logo.facebook {
    background: rgba(24, 119, 242, 0.1);
}

.downloader-input-area {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 20px;
}

.url-input-group {
    display: flex;
    gap: 12px;
}

.url-input {
    flex: 1;
    font-size: 15px;
    padding: 14px 18px;
}

.video-info-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.video-info-thumbnail {
    position: relative;
    flex-shrink: 0;
    max-width: 220px;
    min-width: 120px;
}

.video-info-thumbnail img {
    width: 100%;
    height: auto;
    max-height: 400px;
    object-fit: contain;
    border-radius: 10px;
    background: var(--bg-input);
    display: block;
}

.video-platform-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: var(--primary);
    color: white;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.video-info-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.video-info-details h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    line-height: 1.4;
}

.video-info-details p {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 4px;
}

.btn-thumbnail-download {
    margin-top: 12px;
    padding: 8px 16px;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-thumbnail-download:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.download-progress {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 24px;
    text-align: center;
}

.progress-bar-container {
    height: 8px;
    background: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-bar-fill {
    height: 100%;
    background: var(--gradient-1);
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s;
}

.download-result {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 24px;
    text-align: center;
}

.download-result .result-success {
    font-size: 18px;
    font-weight: 600;
    color: var(--success);
    margin-bottom: 16px;
}

.tool-card-icon.download {
    background: linear-gradient(135deg, #10b981 0%, #06b6d4 100%);
}

.nav-item-badge.new {
    background: var(--success);
}

/* ═══════════════════════════════════════════════
   USER DROPDOWN & HISTORY TABLE
   ═══════════════════════════════════════════════ */

.user-dropdown {
    position: relative;
}

.user-dropdown-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 10px;
    padding: 6px 12px;
    color: #e0e0e0;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.user-dropdown-btn:hover {
    background: rgba(99, 102, 241, 0.2);
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    color: #fff;
}

.user-name {
    font-weight: 500;
}

.user-role-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
}

.user-role-badge.admin {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

.user-role-badge.user {
    background: rgba(99, 102, 241, 0.2);
    color: #818cf8;
}

.dropdown-arrow {
    font-size: 10px;
    color: #666;
}

.user-dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: #1a1a2e;
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 12px;
    min-width: 200px;
    padding: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.user-dropdown-menu.show {
    display: block;
}

.user-dropdown-menu .dropdown-user-info {
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-dropdown-menu .dropdown-user-info strong {
    color: #fff;
    font-size: 14px;
}

.user-dropdown-menu .dropdown-user-info small {
    color: #888;
    font-size: 12px;
}

.user-dropdown-menu hr {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    margin: 4px 0;
}

.user-dropdown-menu button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 9px 12px;
    background: none;
    border: none;
    color: #ccc;
    font-size: 13px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.15s;
}

.user-dropdown-menu button:hover {
    background: rgba(99, 102, 241, 0.15);
    color: #fff;
}

.user-dropdown-menu .logout-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

/* History Table */
.history-table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(17, 17, 34, 0.6);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(99, 102, 241, 0.1);
}

.history-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    background: rgba(99, 102, 241, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.history-table td {
    padding: 12px 16px;
    font-size: 13px;
    color: #ccc;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.history-table tr:hover td {
    background: rgba(99, 102, 241, 0.05);
}

.history-table .tool-icon {
    font-size: 18px;
}

.history-table .status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.status-badge.completed {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.status-badge.processing {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
}

.status-badge.failed {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.status-badge.pending {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.history-title-cell {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-type-cell {
    width: 60px;
    text-align: center;
}

.history-thumb {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    vertical-align: middle;
}

.history-type-label {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    background: rgba(99, 102, 241, 0.12);
    color: #818cf8;
    text-transform: capitalize;
}

.history-dl-btn {
    background: rgba(16, 185, 129, 0.12);
    color: #10b981;
    border: none;
    border-radius: 8px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.history-dl-btn:hover {
    background: rgba(16, 185, 129, 0.25);
}

.history-actions button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 4px 6px;
    border-radius: 6px;
    transition: background 0.15s;
}

.history-actions button:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* ═══════════════════════════════════════════════
   RESPONSIVE — Laptop / Tablet / Mobile
   ═══════════════════════════════════════════════ */

/* Hamburger menu button (hidden on desktop) */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 200;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 20px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

/* Sidebar overlay backdrop (mobile) */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 90;
}

.sidebar-backdrop.active {
    display: block;
}

/* ── Laptop (≤1366px) — Slim sidebar ── */
@media (max-width: 1366px) {
    .sidebar {
        width: 220px;
    }

    .main-content {
        margin-left: 220px;
    }

    .nav-item {
        padding: 9px 12px;
    }

    .nav-item-text {
        font-size: 13px;
    }

    .page-content {
        padding: 20px;
    }

    .tool-content {
        grid-template-columns: 1fr 280px;
    }
}

/* ── Tablet (≤1024px) — Sidebar collapses, single column ── */
@media (max-width: 1024px) {
    .sidebar-toggle {
        display: flex;
    }

    .sidebar {
        width: 260px;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 100;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .header {
        padding-left: 60px;
        /* room for hamburger */
    }

    .tool-content {
        grid-template-columns: 1fr;
    }

    .tool-header-info h1 {
        font-size: 20px;
    }

    .platform-tabs {
        padding: 0 16px;
        flex-wrap: wrap;
    }

    .platform-tab {
        padding: 10px 16px;
        font-size: 13px;
    }

    .video-info-card {
        flex-direction: column;
    }

    .video-info-thumbnail {
        width: 100%;
        max-width: 300px;
        max-height: none;
    }

    .url-input-group {
        flex-direction: column;
    }

    .url-input-group .btn {
        width: 100%;
    }
}

/* ── Small Tablet / Large Phone (≤768px) ── */
@media (max-width: 768px) {
    .header {
        padding: 12px 16px 12px 56px;
    }

    .header-title {
        font-size: 16px;
    }

    .api-status {
        display: none;
    }

    .page-content {
        padding: 14px;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

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

    .tool-header-icon {
        width: 44px;
        height: 44px;
        font-size: 22px;
    }

    .tool-header-info h1 {
        font-size: 18px;
    }

    .translate-grid {
        grid-template-columns: 1fr;
    }

    .upload-zone {
        padding: 24px 16px;
    }

    .upload-zone-icon {
        font-size: 32px;
    }

    .tool-panel {
        padding: 12px;
    }

    .platform-tabs {
        gap: 6px;
    }

    .platform-tab {
        padding: 8px 12px;
        font-size: 12px;
        border-radius: 8px;
    }

    .downloader-input-area {
        padding: 16px;
    }

    .modal {
        width: 95%;
        max-width: 400px;
    }
}

/* ── Phone (≤480px) ── */
@media (max-width: 480px) {
    .header {
        padding: 10px 12px 10px 52px;
    }

    .header-title {
        font-size: 15px;
    }

    .settings-btn {
        width: 34px;
        height: 34px;
        font-size: 14px;
    }

    .page-content {
        padding: 10px;
    }

    .dashboard-grid {
        gap: 10px;
    }

    .tool-card {
        padding: 14px;
    }

    .tool-card-icon {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    .tool-card-title {
        font-size: 14px;
    }

    .tool-card-desc {
        font-size: 12px;
    }

    .btn {
        padding: 8px 14px;
        font-size: 13px;
    }

    .form-input,
    .form-select {
        padding: 8px 12px;
        font-size: 13px;
    }

    .platform-tab {
        padding: 6px 10px;
        font-size: 11px;
        gap: 4px;
    }

    .tab-icon {
        width: 16px;
        height: 16px;
    }
}

/* Resizable Overlay Styles */
.resizable-overlay {
    user-select: none;
}

.resizable-overlay:hover {
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3), 0 4px 12px rgba(0, 0, 0, 0.4);
}

.resize-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #fff;
    border: 2px solid var(--primary);
    border-radius: 50%;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    transition: transform 0.15s ease, background 0.15s ease;
}

.resize-handle:hover {
    transform: scale(1.3);
    background: var(--primary);
}

.resize-handle-nw {
    top: -6px;
    left: -6px;
    cursor: nw-resize;
}

.resize-handle-ne {
    top: -6px;
    right: -6px;
    cursor: ne-resize;
}

.resize-handle-sw {
    bottom: -6px;
    left: -6px;
    cursor: sw-resize;
}

.resize-handle-se {
    bottom: -6px;
    right: -6px;
    cursor: se-resize;
}

/* Canvas editor font picker */
.font-picker {
    position: relative;
    margin-top: 4px;
}

.font-picker-native {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.font-picker-trigger {
    width: 100%;
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    color: #fff;
    text-align: left;
    cursor: pointer;
    background: #1a1a2e;
    border: 1px solid rgba(99, 102, 241, 0.35);
    border-radius: 7px;
    transition: border-color .15s ease, background .15s ease;
}

.font-picker-trigger:hover,
.font-picker-trigger[aria-expanded="true"] {
    background: #20203a;
    border-color: var(--primary-light);
}

.font-picker-trigger-copy {
    min-width: 0;
    display: grid;
    gap: 1px;
}

.font-picker-selected-name,
.font-picker-option-sample {
    overflow: hidden;
    color: #fff;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.font-picker-selected-name {
    font-size: 17px;
}

.font-picker-selected-file,
.font-picker-option-file {
    overflow: hidden;
    color: #8f91aa;
    font-family: Inter, sans-serif;
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.font-picker-chevron {
    flex: 0 0 auto;
    color: #a5b4fc;
    font-size: 20px;
    line-height: 1;
    transition: transform .15s ease;
}

.font-picker-trigger[aria-expanded="true"] .font-picker-chevron {
    transform: rotate(180deg);
}

.font-picker-menu {
    position: absolute;
    z-index: 110;
    top: calc(100% + 5px);
    right: 0;
    left: 0;
    overflow: hidden;
    background: #151524;
    border: 1px solid rgba(129, 140, 248, .55);
    border-radius: 9px;
    box-shadow: 0 18px 38px rgba(0, 0, 0, .45);
}

.font-picker-search-wrap {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 9px 10px 5px;
    color: #a5b4fc;
}

.font-picker-search {
    width: 100%;
    min-width: 0;
    padding: 7px 8px;
    color: #fff;
    background: #0f0f1b;
    border: 1px solid #30304a;
    border-radius: 6px;
    outline: none;
    font-size: 11px;
}

.font-picker-search:focus {
    border-color: var(--primary-light);
}

.font-picker-hint {
    padding: 0 10px 7px;
    color: #777994;
    font-size: 10px;
}

.font-picker-list {
    max-height: 286px;
    padding: 4px;
    overflow-y: auto;
    border-top: 1px solid rgba(129, 140, 248, .16);
}

.font-picker-option {
    width: 100%;
    display: grid;
    gap: 3px;
    padding: 9px;
    color: inherit;
    text-align: left;
    cursor: pointer;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 7px;
}

.font-picker-option:hover {
    background: rgba(99, 102, 241, .13);
}

.font-picker-option.selected {
    background: rgba(99, 102, 241, .19);
    border-color: rgba(129, 140, 248, .56);
}

.font-picker-option-sample {
    font-size: 18px;
    min-height: 25px;
}

.font-picker-option-details {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
}

.font-picker-option-name {
    overflow: hidden;
    color: #d9d9ef;
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.font-picker-option-file {
    flex: 0 1 48%;
    text-align: right;
}

.font-picker-option.font-preview-fallback::after {
    content: 'Preview fallback';
    color: #fbbf24;
    font-size: 9px;
}

.font-picker-empty {
    padding: 18px 10px;
    color: #8f91aa;
    text-align: center;
    font-size: 11px;
}

@media (max-width: 600px) {
    .font-picker-menu {
        position: fixed;
        top: auto;
        right: 12px;
        bottom: 12px;
        left: 12px;
    }

    .font-picker-list {
        max-height: min(52vh, 360px);
    }
}