/* === Design Tokens === */
:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --primary-gradient-hover: linear-gradient(135deg, #7b8ff0 0%, #8b5fbf 100%);
    --secondary-gradient: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    --accent: #ff6b6b;
    --accent-glow: rgba(255, 107, 107, 0.3);

    --bg-dark: #0b0b1a;
    --bg-darker: #06060f;
    --bg-card: rgba(255, 255, 255, 0.04);
    --bg-card-hover: rgba(255, 255, 255, 0.08);
    --bg-card-active: rgba(102, 126, 234, 0.12);
    --text-primary: #f0f0f5;
    --text-secondary: rgba(240, 240, 245, 0.78);
    --text-tertiary: rgba(240, 240, 245, 0.55);
    --border: rgba(255, 255, 255, 0.1);
    --border-hover: rgba(102, 126, 234, 0.45);
    --glass-bg: rgba(255, 255, 255, 0.06);
    --glass-border: rgba(255, 255, 255, 0.1);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.35);
    --shadow-glow: 0 0 40px rgba(102, 126, 234, 0.15);
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 8px;
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

[data-theme="light"] {
    --bg-dark: #f4f4f8;
    --bg-darker: #eaeaf0;
    --bg-card: rgba(255, 255, 255, 0.7);
    --bg-card-hover: rgba(255, 255, 255, 0.9);
    --bg-card-active: rgba(102, 126, 234, 0.08);
    --text-primary: #1a1a2e;
    --text-secondary: rgba(26, 26, 46, 0.74);
    --text-tertiary: rgba(26, 26, 46, 0.55);
    --border: rgba(0, 0, 0, 0.1);
    --border-hover: rgba(102, 126, 234, 0.45);
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(0, 0, 0, 0.08);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.08);
    --shadow-glow: 0 0 40px rgba(102, 126, 234, 0.08);
}

[data-theme="high-contrast"] {
    --primary-gradient: linear-gradient(135deg, #7aa2ff 0%, #c08aff 100%);
    --primary-gradient-hover: linear-gradient(135deg, #93b2ff 0%, #d3a4ff 100%);
    --accent: #ff7b72;
    --accent-glow: rgba(255, 123, 114, 0.4);
    --bg-dark: #00000f;
    --bg-darker: #05050d;
    --bg-card: rgba(255, 255, 255, 0.06);
    --bg-card-hover: rgba(255, 255, 255, 0.12);
    --bg-card-active: rgba(122, 162, 255, 0.2);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.92);
    --text-tertiary: rgba(255, 255, 255, 0.72);
    --border: rgba(255, 255, 255, 0.16);
    --border-hover: rgba(122, 162, 255, 0.65);
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.18);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px rgba(122, 162, 255, 0.25);
}

[data-theme="sepia"] {
    --primary-gradient: linear-gradient(135deg, #b4652d 0%, #a34d8a 100%);
    --primary-gradient-hover: linear-gradient(135deg, #c4763a 0%, #b45a99 100%);
    --secondary-gradient: linear-gradient(135deg, #0f8f7f 0%, #2fbf71 100%);
    --accent: #c0392b;
    --accent-glow: rgba(192, 57, 43, 0.3);
    --bg-dark: #f6eedb;
    --bg-darker: #efe3c9;
    --bg-card: rgba(255, 252, 245, 0.72);
    --bg-card-hover: rgba(255, 252, 245, 0.95);
    --bg-card-active: rgba(180, 101, 45, 0.1);
    --text-primary: #38291a;
    --text-secondary: rgba(56, 41, 26, 0.78);
    --text-tertiary: rgba(56, 41, 26, 0.6);
    --border: rgba(56, 41, 26, 0.12);
    --border-hover: rgba(180, 101, 45, 0.5);
    --glass-bg: rgba(255, 252, 245, 0.8);
    --glass-border: rgba(56, 41, 26, 0.12);
    --shadow-sm: 0 2px 8px rgba(56, 41, 26, 0.1);
    --shadow-card: 0 8px 32px rgba(56, 41, 26, 0.12);
    --shadow-glow: 0 0 40px rgba(180, 101, 45, 0.1);
}

/* === Reset & Base === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* === Background Atmosphere === */
.bg-gradient {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: 0;
    background:
        radial-gradient(ellipse 80% 60% at 50% -25%, rgba(102, 126, 234, 0.18), transparent 70%),
        radial-gradient(ellipse 50% 40% at 100% 0%, rgba(118, 75, 162, 0.12), transparent 60%),
        radial-gradient(ellipse 40% 30% at 0% 100%, rgba(17, 153, 142, 0.06), transparent 50%);
}
[data-theme="light"] .bg-gradient {
    background:
        radial-gradient(ellipse 80% 60% at 50% -25%, rgba(102, 126, 234, 0.08), transparent 70%),
        radial-gradient(ellipse 50% 40% at 100% 0%, rgba(118, 75, 162, 0.04), transparent 60%);
}
[data-theme="sepia"] .bg-gradient {
    background:
        radial-gradient(ellipse 80% 60% at 50% -25%, rgba(180, 101, 45, 0.1), transparent 70%),
        radial-gradient(ellipse 50% 40% at 100% 0%, rgba(163, 77, 138, 0.06), transparent 60%);
}

/* === Navbar === */
.navbar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
    padding: 0.75rem 2rem;
    background: rgba(11, 11, 26, 0.75);
    -webkit-backdrop-filter: blur(24px) saturate(1.5);
    backdrop-filter: blur(24px) saturate(1.5);
    border-bottom: 1px solid var(--border);
}
[data-theme="light"] .navbar {
    background: rgba(244, 244, 248, 0.85);
}
[data-theme="sepia"] .navbar {
    background: rgba(246, 238, 219, 0.85);
}
[data-theme="high-contrast"] .navbar {
    background: rgba(0, 0, 15, 0.85);
    border-bottom-color: rgba(255, 255, 255, 0.2);
}
.nav-container {
    max-width: 1200px; margin: 0 auto;
    display: flex; align-items: center; justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: 0.75rem; text-decoration: none; }
.logo-icon {
    width: 38px; height: 38px; background: var(--primary-gradient);
    border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center;
    font-size: 1.15rem; box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    transition: transform var(--transition-bounce);
}
.logo:hover .logo-icon { transform: rotate(-8deg) scale(1.08); }
.logo-text {
    font-family: 'Poppins', sans-serif; font-weight: 800; font-size: 1.35rem;
    background: var(--primary-gradient); -webkit-background-clip: text;
    -webkit-text-fill-color: transparent; background-clip: text;
}
.nav-right { display: flex; align-items: center; gap: 1rem; }
.server-status {
    font-size: 0.72rem; padding: 0.3rem 0.7rem; border-radius: 20px;
    background: rgba(56, 239, 125, 0.12); color: #38ef7d; font-weight: 600;
    letter-spacing: 0.02em; border: 1px solid rgba(56, 239, 125, 0.15);
}
.server-status.offline {
    background: rgba(255, 107, 107, 0.12); color: #ff6b6b;
    border-color: rgba(255, 107, 107, 0.15);
}
.server-status.ai-ready {
    background: rgba(99, 102, 241, 0.12); color: #818cf8;
    border-color: rgba(99, 102, 241, 0.15);
}

/* === Main Content === */
.main-content {
    position: relative; z-index: 1;
    max-width: 1200px; margin: 0 auto; padding: 6.5rem 2rem 2rem;
}

/* === Hero === */
.hero { text-align: center; padding: 2.5rem 0 1.5rem; }
.hero h1 {
    font-family: 'Poppins', sans-serif; font-size: 2.8rem; font-weight: 800;
    margin-bottom: 0.6rem; letter-spacing: -0.02em;
}
.hero h1 span {
    background: var(--primary-gradient); -webkit-background-clip: text;
    -webkit-text-fill-color: transparent; background-clip: text;
}
.hero p {
    color: var(--text-secondary); font-size: 1rem; max-width: 520px; margin: 0 auto;
    line-height: 1.7;
}

/* === Featured Card === */
.main-tool-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius); padding: 2rem; margin-top: 1.5rem;
    box-shadow: var(--shadow-card);
    transition: border-color var(--transition-smooth);
}
.main-tool-card:hover { border-color: var(--border-hover); }
.tool-formats-bar {
    display: flex; align-items: center; justify-content: center;
    gap: 0.5rem; margin-bottom: 1.5rem; flex-wrap: wrap;
}
.format-badge {
    padding: 0.3rem 0.7rem; border-radius: var(--radius-xs); font-size: 0.78rem;
    font-weight: 600; background: var(--glass-bg); border: 1px solid var(--glass-border);
    font-family: 'JetBrains Mono', monospace; letter-spacing: 0.02em;
    transition: all var(--transition-fast);
}
.format-badge:hover { background: var(--bg-card-hover); border-color: var(--border-hover); }
.format-badge.arrow { background: none; border: none; font-size: 1.2rem; color: var(--text-tertiary); }
.format-badge.output {
    background: rgba(102, 126, 234, 0.15); border-color: rgba(102, 126, 234, 0.3);
    color: #8b9cf7; box-shadow: 0 0 12px rgba(102, 126, 234, 0.1);
}

/* === Dropzone === */
.main-dropzone {
    border: 2px dashed var(--border); border-radius: 14px;
    padding: 3rem 2rem; text-align: center; cursor: pointer;
    transition: all var(--transition-smooth); position: relative; overflow: hidden;
}
.main-dropzone::before {
    content: ''; position: absolute; inset: 0;
    background: radial-gradient(circle at center, rgba(102, 126, 234, 0.06), transparent 70%);
    opacity: 0; transition: opacity var(--transition-smooth);
    /* Decorative only: must not swallow clicks on Retry/Cancel. */
    pointer-events: none;
}
.main-dropzone:hover::before, .main-dropzone.dragover::before { opacity: 1; }
.main-dropzone:hover, .main-dropzone.dragover {
    border-color: #667eea;
    box-shadow: 0 0 30px rgba(102, 126, 234, 0.08);
}
.main-dropzone.dragover {
    transform: scale(1.01);
    border-style: solid;
}
.main-dropzone.has-file {
    border-color: #38ef7d; border-style: solid;
    background: rgba(56, 239, 125, 0.03);
}
.main-file-input {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer;
    /* The dropzone forwards clicks; an overlay must not block its buttons. */
    pointer-events: none;
}
.dropzone-icon-large {
    font-size: 3.2rem; margin-bottom: 1rem;
    animation: dropzonePulse 3s ease-in-out infinite;
}
@keyframes dropzonePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.06); }
}
.dropzone-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.4rem; }
.dropzone-subtitle { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 0.3rem; }
.dropzone-subtitle strong { color: #8b9cf7; font-weight: 600; }
.dropzone-hint { color: var(--text-tertiary); font-size: 0.78rem; }

/* === Convert Button (Main) === */
.convert-btn-large {
    width: 100%; margin-top: 1rem; padding: 1rem;
    background: var(--primary-gradient); color: white; border: none;
    border-radius: 12px; font-size: 1rem; font-weight: 600;
    cursor: pointer; display: none; align-items: center; justify-content: center; gap: 0.5rem;
    transition: all var(--transition-smooth);
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.3);
    position: relative; overflow: hidden;
}
.convert-btn-large::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent 60%);
    opacity: 0; transition: opacity var(--transition-fast);
}
.convert-btn-large.active { display: flex; }
.convert-btn-large:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(102, 126, 234, 0.4);
}
.convert-btn-large:hover::after { opacity: 1; }
.convert-btn-large:active { transform: translateY(0); }

/* === Section Label === */
.section-label {
    font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.12em; color: var(--text-tertiary); margin: 2.5rem 0 1rem;
    padding-left: 0.25rem;
}

/* === Tools Grid === */
.tools-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
    gap: 0.875rem;
}
.tool-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px; padding: 1.25rem 1rem; cursor: pointer;
    transition: all var(--transition-smooth); text-align: center;
    position: relative; overflow: hidden;
}
.tool-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
    background: var(--primary-gradient); opacity: 0;
    transition: opacity var(--transition-smooth);
}
.tool-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
    transform: translateY(-3px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(102, 126, 234, 0.1);
}
.tool-card:hover::before { opacity: 1; }
.tool-card:active { transform: translateY(-1px); }
.tool-card:focus-visible {
    outline: 2px solid #667eea; outline-offset: 2px;
}
.tool-header { margin-bottom: 0.6rem; }
.tool-icons { display: flex; align-items: center; justify-content: center; gap: 0.5rem; }
.tool-icon {
    width: 42px; height: 42px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center; font-size: 1.35rem;
    background: var(--glass-bg); border: 1px solid var(--glass-border);
    transition: all var(--transition-smooth);
}
.tool-card:hover .tool-icon {
    background: var(--bg-card-active);
    border-color: rgba(102, 126, 234, 0.25);
    transform: scale(1.05);
}
.tool-arrow {
    color: var(--text-tertiary); font-size: 0.85rem;
    transition: color var(--transition-fast), transform var(--transition-fast);
}
.tool-card:hover .tool-arrow { color: #8b9cf7; transform: translateX(2px); }
.tool-title {
    font-size: 0.82rem; font-weight: 600; margin-bottom: 0.4rem;
    letter-spacing: 0.01em;
}
.tool-formats { display: flex; gap: 0.3rem; justify-content: center; flex-wrap: wrap; }
.tool-formats .format-badge { font-size: 0.68rem; padding: 0.2rem 0.4rem; }

/* === Tool Modal === */
.tool-modal {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 2000;
    background: rgba(0, 0, 0, 0.65);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    display: none; align-items: center; justify-content: center; padding: 2rem;
    animation: modalBackdropIn 0.3s ease;
}
.tool-modal.active { display: flex; }
@keyframes modalBackdropIn { from { opacity: 0; } to { opacity: 1; } }

.tool-modal-content {
    background: var(--bg-darker); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 2rem; width: 100%; max-width: 480px;
    position: relative;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5), var(--shadow-glow);
    animation: modalSlideIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.tool-modal-close {
    position: absolute; top: 1rem; right: 1rem; background: var(--glass-bg);
    border: 1px solid var(--glass-border); color: var(--text-secondary);
    font-size: 1.2rem; cursor: pointer; width: 32px; height: 32px;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    transition: all var(--transition-fast);
}
.tool-modal-close:hover {
    background: rgba(255, 107, 107, 0.15); color: #ff6b6b;
    border-color: rgba(255, 107, 107, 0.3); transform: rotate(90deg);
}
.tool-modal-header { text-align: center; margin-bottom: 1.5rem; }
.tool-modal-header .tool-icons { margin-bottom: 0.5rem; }
.tool-modal-header .tool-icon {
    background: var(--glass-bg); border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-sm);
}
.tool-modal-header h2 { font-size: 1.15rem; font-weight: 700; margin-top: 0.75rem; }

/* === Modal Dropzone === */
.tool-modal-dropzone {
    border: 2px dashed var(--border); border-radius: 12px;
    padding: 2rem; text-align: center; cursor: pointer;
    transition: all var(--transition-smooth); position: relative;
}
.tool-modal-dropzone:hover, .tool-modal-dropzone.dragover {
    border-color: #667eea; background: rgba(102, 126, 234, 0.04);
}
.tool-modal-dropzone .main-file-input {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer;
    /* The dropzone forwards clicks; an overlay must not block its buttons. */
    pointer-events: none;
}

/* === Modal Options === */
.tool-modal-options {
    display: none; margin-top: 1rem; padding: 1rem 1.1rem;
    background: var(--glass-bg); border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm); max-height: 320px; overflow-y: auto;
}
.tool-modal-options.active { display: block; animation: fadeSlideIn 0.3s ease; }
.tool-modal-options:empty { display: none !important; }
@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}
.tool-options-title {
    font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.1em; color: var(--text-tertiary); margin-bottom: 0.75rem;
}
.tool-opt-group { margin-bottom: 0.75rem; }
.tool-opt-group:last-child { margin-bottom: 0; }
.tool-opt-label {
    display: block; font-size: 0.78rem; font-weight: 600;
    color: var(--text-secondary); margin-bottom: 0.3rem;
}
.tool-opt-hint {
    font-size: 0.68rem; color: var(--text-tertiary); margin-top: 0.25rem;
    font-style: italic;
}
.tool-opt-input, .tool-opt-select {
    width: 100%; padding: 0.55rem 0.8rem; border-radius: var(--radius-xs);
    border: 1px solid var(--border); background: var(--bg-card);
    color: var(--text-primary); font-size: 0.85rem; font-family: inherit;
    outline: none; transition: all var(--transition-fast);
}
.tool-opt-input:focus, .tool-opt-select:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.12);
}
.tool-opt-input::placeholder { color: var(--text-tertiary); }
.tool-opt-select { cursor: pointer; appearance: auto; }
.tool-opt-row { display: flex; gap: 0.75rem; }
.tool-opt-row .tool-opt-group { flex: 1; }
.tool-opt-check {
    display: flex; align-items: center; gap: 0.5rem; cursor: pointer;
    font-size: 0.85rem; color: var(--text-secondary);
}
.tool-opt-check input[type="checkbox"] {
    width: 16px; height: 16px; accent-color: #667eea; cursor: pointer;
}

/* === Modal Convert Button === */
.tool-modal-convert-btn {
    width: 100%; margin-top: 1rem; padding: 0.8rem;
    background: var(--primary-gradient); color: white; border: none;
    border-radius: var(--radius-sm); font-size: 0.95rem; font-weight: 600;
    cursor: pointer; display: none; transition: all var(--transition-smooth);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.25);
    position: relative; overflow: hidden;
}
.tool-modal-convert-btn::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent 60%);
    opacity: 0; transition: opacity var(--transition-fast);
}
.tool-modal-convert-btn.active { display: block; }
.tool-modal-convert-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.35);
}
.tool-modal-convert-btn:hover::after { opacity: 1; }
.tool-modal-convert-btn:active { transform: translateY(0); }

/* === Progress === */
.tool-modal-progress, .tool-modal-success { display: none; text-align: center; padding: 2rem 0; }
.tool-modal-progress.active, .tool-modal-success.active { display: block; animation: fadeSlideIn 0.3s ease; }

.progress-bar {
    height: 6px; background: var(--border); border-radius: 3px; overflow: hidden;
    margin-bottom: 1rem;
}
.progress-fill {
    height: 100%; background: var(--primary-gradient); border-radius: 3px;
    width: 0%; transition: width 0.3s ease;
    position: relative;
}
.progress-fill::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 1.5s infinite;
}
@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}
.progress-text { color: var(--text-secondary); font-size: 0.88rem; font-weight: 500; }

/* === Success State === */
.success-icon {
    width: 64px; height: 64px; border-radius: 50%;
    background: var(--secondary-gradient); display: flex; align-items: center;
    justify-content: center; font-size: 1.6rem; margin: 0 auto 1rem; color: white;
    box-shadow: 0 8px 25px rgba(56, 239, 125, 0.3);
    animation: successPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes successPop {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}
.tool-modal-success h3 { font-size: 1.1rem; margin-bottom: 0.4rem; font-weight: 700; }
.tool-modal-success p { color: var(--text-secondary); font-size: 0.88rem; margin-bottom: 1.25rem; }

.download-btn {
    padding: 0.75rem 2.2rem; background: var(--primary-gradient); color: white;
    border: none; border-radius: var(--radius-sm); font-size: 0.95rem; font-weight: 600;
    cursor: pointer; transition: all var(--transition-smooth);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    position: relative; overflow: hidden;
}
.download-btn::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent 60%);
    opacity: 0; transition: opacity var(--transition-fast);
}
.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}
.download-btn:hover::after { opacity: 1; }

/* === File Preview === */
.file-preview {
    display: none; margin-top: 1rem; padding: 1rem;
    background: var(--glass-bg); border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    animation: fadeSlideIn 0.25s ease;
}
.file-preview.active { display: block; }
.file-preview-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.file-preview-icon {
    width: 44px; height: 44px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center; font-size: 1.4rem;
    background: var(--primary-gradient); box-shadow: var(--shadow-sm);
}
.file-preview-info h4 { font-size: 0.88rem; font-weight: 600; word-break: break-all; }
.file-preview-info p { font-size: 0.75rem; color: var(--text-secondary); }
.file-preview-content {
    max-height: 180px; overflow: auto; border-radius: var(--radius-xs);
    background: rgba(0, 0, 0, 0.2); padding: 0.75rem;
    font-family: 'JetBrains Mono', monospace; font-size: 0.7rem;
    scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
[data-theme="light"] .file-preview-content { background: rgba(0, 0, 0, 0.03); }
[data-theme="sepia"] .file-preview-content { background: rgba(56, 41, 26, 0.04); }

.file-preview-table { width: 100%; border-collapse: collapse; font-size: 0.75rem; }
.file-preview-table th, .file-preview-table td {
    padding: 0.3rem 0.6rem; border-bottom: 1px solid var(--border);
    text-align: left; white-space: nowrap;
}
.file-preview-table th { color: var(--text-secondary); font-weight: 600; background: var(--glass-bg); }

.batch-list { max-height: 150px; overflow-y: auto; }
.batch-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.45rem 0; border-bottom: 1px solid var(--border);
    font-size: 0.8rem;
}
.batch-item:last-child { border-bottom: none; }

.conversion-stats { display: flex; gap: 1rem; margin-top: 1rem; }
.stat-item { flex: 1; text-align: center; }
.stat-value {
    font-size: 1.05rem; font-weight: 700; color: #8b9cf7;
    font-family: 'JetBrains Mono', monospace;
}
.stat-label { font-size: 0.68rem; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.05em; }

/* === Error State === */
.error-state { text-align: center; padding: 1rem; }
.error-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.error-message { color: #ff6b6b; font-size: 0.85rem; margin-bottom: 1rem; }
.retry-btn, .retry-alt {
    padding: 0.5rem 1.2rem; border-radius: var(--radius-xs); border: none;
    font-size: 0.85rem; font-weight: 600; cursor: pointer; margin: 0 0.3rem;
    transition: all var(--transition-fast);
}
.retry-btn {
    background: var(--primary-gradient); color: white;
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.2);
}
.retry-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3); }
.retry-alt {
    background: var(--glass-bg); color: var(--text-secondary);
    border: 1px solid var(--border);
}
.retry-alt:hover { background: var(--bg-card-hover); }

/* === Toast === */
.toast-container {
    position: fixed; top: 5rem; right: 2rem; z-index: 3000;
    display: flex; flex-direction: column; gap: 0.5rem;
}
.toast {
    padding: 0.8rem 1.3rem; border-radius: var(--radius-sm); font-size: 0.85rem;
    font-weight: 500;
    background: var(--bg-darker); border: 1px solid var(--border);
    box-shadow: var(--shadow-card);
    animation: toastIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 340px; backdrop-filter: blur(10px);
}
.toast.error { border-color: rgba(255, 107, 107, 0.4); color: #ff6b6b; }
.toast.success { border-color: rgba(56, 239, 125, 0.4); color: #38ef7d; }
@keyframes toastIn {
    from { opacity: 0; transform: translateX(30px) scale(0.95); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}

/* === History Trigger === */
.history-trigger {
    position: fixed; bottom: 2rem; right: 2rem; z-index: 1000;
    width: 50px; height: 50px; border-radius: 50%;
    background: var(--glass-bg); border: 1px solid var(--glass-border);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; box-shadow: var(--shadow-card);
    transition: all var(--transition-smooth);
}
.history-trigger:hover {
    transform: scale(1.1);
    background: var(--bg-card-hover);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}
.history-count {
    position: absolute; top: -3px; right: -3px;
    background: var(--accent); color: white; font-size: 0.65rem;
    font-weight: 700; min-width: 18px; height: 18px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    padding: 0 4px;
    box-shadow: 0 2px 8px var(--accent-glow);
}

/* === History Panel === */
.history-panel {
    position: fixed; top: 0; right: -400px; width: 380px; height: 100vh;
    background: var(--bg-darker); border-left: 1px solid var(--border);
    z-index: 1500; transition: right var(--transition-smooth);
    display: flex; flex-direction: column;
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.3);
}
.history-panel.active { right: 0; }
.history-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border);
}
.history-header h3 { font-size: 1rem; font-weight: 700; }
.history-close {
    background: var(--glass-bg); border: 1px solid var(--glass-border);
    color: var(--text-secondary); font-size: 1.2rem; cursor: pointer;
    width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transition: all var(--transition-fast);
}
.history-close:hover {
    background: rgba(255, 107, 107, 0.15); color: #ff6b6b;
    border-color: rgba(255, 107, 107, 0.3);
}
.history-search {
    padding: 0.75rem 1rem; border-bottom: 1px solid var(--border);
}
.history-search input {
    width: 100%; padding: 0.55rem 0.85rem; border-radius: var(--radius-xs);
    border: 1px solid var(--border); background: var(--bg-card);
    color: var(--text-primary); font-size: 0.85rem; outline: none;
    transition: all var(--transition-fast);
}
.history-search input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.12);
}
.history-search input::placeholder { color: var(--text-tertiary); }
.history-list { flex: 1; overflow-y: auto; padding: 0.5rem; }
.history-empty { text-align: center; color: var(--text-tertiary); padding: 3rem 1rem; font-size: 0.9rem; }
.history-item {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.75rem; border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}
.history-item:hover { background: var(--bg-card-hover); }
.history-item-icon {
    width: 38px; height: 38px; border-radius: var(--radius-xs); flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 1rem;
    background: var(--primary-gradient); box-shadow: var(--shadow-sm);
}
.history-item-info { flex: 1; min-width: 0; }
.history-item-name { font-size: 0.8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-item-meta { font-size: 0.7rem; color: var(--text-tertiary); }
.history-item-download {
    background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: var(--radius-xs);
    color: var(--text-secondary); padding: 0.35rem 0.6rem; cursor: pointer; font-size: 0.82rem;
    transition: all var(--transition-fast);
}
.history-item-download:hover {
    background: var(--primary-gradient); color: white; border-color: transparent;
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.3);
}

/* === Theme Toggle === */
.theme-toggle {
    position: fixed; bottom: 2rem; right: 5.5rem; z-index: 1000;
    width: 50px; height: 50px; border-radius: 50%;
    background: var(--glass-bg); border: 1px solid var(--glass-border);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; box-shadow: var(--shadow-card);
    transition: all var(--transition-smooth);
}
.theme-toggle:hover {
    transform: scale(1.1) rotate(15deg);
    background: var(--bg-card-hover);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

/* === Confetti === */
.confetti-container {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: 9999; overflow: hidden;
}
.confetti {
    position: absolute; top: -10px; width: 10px; height: 10px;
    animation: confettiFall 3s ease-in forwards;
}
@keyframes confettiFall {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* === Footer === */
.footer {
    text-align: center; padding: 2.5rem 2rem; margin-top: 3rem;
    border-top: 1px solid var(--border); color: var(--text-tertiary); font-size: 0.78rem;
    letter-spacing: 0.02em;
}

/* === Scrollbar === */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* === Selection === */
::selection { background: rgba(102, 126, 234, 0.3); color: var(--text-primary); }

/* === Responsive === */
@media (max-width: 640px) {
    .hero h1 { font-size: 2rem; }
    .tools-grid { grid-template-columns: repeat(2, 1fr); gap: 0.65rem; }
    .tool-card { padding: 1rem 0.75rem; }
    .tool-icon { width: 36px; height: 36px; font-size: 1.15rem; }
    .history-panel { width: 100%; right: -100%; }
    .main-content { padding: 5.5rem 1rem 1rem; }
    .theme-toggle { right: auto; left: 2rem; }
    .tool-modal-content { padding: 1.5rem; }
}
@media (min-width: 641px) and (max-width: 900px) {
    .tools-grid { grid-template-columns: repeat(3, 1fr); }
}

/* === Navbar Buttons (history + theme live in navbar now) === */
.navbar .history-trigger,
.navbar .theme-toggle {
    position: static; transform: none; box-shadow: none;
}
.navbar .history-trigger:hover,
.navbar .theme-toggle:hover {
    transform: none; box-shadow: none;
}

/* === Nav Action Buttons === */
.nav-btn {
    display: flex; align-items: center; gap: 0.45rem;
    padding: 0.45rem 0.85rem; border-radius: var(--radius-sm);
    background: var(--glass-bg); border: 1px solid var(--glass-border);
    color: var(--text-secondary); font-size: 0.82rem; font-weight: 600;
    cursor: pointer; transition: all var(--transition-fast); font-family: inherit;
}
.nav-btn:hover {
    background: var(--bg-card-hover); color: var(--text-primary);
    border-color: var(--border-hover);
}
.nav-btn-icon { font-size: 1rem; }
@media (max-width: 640px) {
    .nav-btn-label { display: none; }
    .nav-btn { padding: 0.45rem; }
}

/* === How It Works === */
.how-it-works {
    display: flex; align-items: center; justify-content: center; gap: 0.6rem;
    margin-top: 1.4rem; flex-wrap: wrap;
}
.how-step {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.45rem 0.9rem; border-radius: 20px;
    background: var(--glass-bg); border: 1px solid var(--glass-border);
    font-size: 0.8rem; font-weight: 600; color: var(--text-secondary);
}
.how-num {
    width: 20px; height: 20px; border-radius: 50%;
    background: var(--primary-gradient); color: white; font-size: 0.7rem;
    display: flex; align-items: center; justify-content: center;
}
.how-arrow { color: var(--text-tertiary); font-size: 1rem; }

/* === Step Bar === */
.step-bar {
    display: flex; align-items: center; justify-content: center;
    gap: 0.75rem; margin-bottom: 1.5rem;
}
.step-label {
    display: flex; align-items: center; gap: 0.45rem;
    font-size: 0.8rem; font-weight: 600; color: var(--text-tertiary);
    transition: color var(--transition-fast);
}
.step-label.active { color: #8b9cf7; }
.step-num {
    width: 24px; height: 24px; border-radius: 50%; font-size: 0.72rem;
    display: flex; align-items: center; justify-content: center;
    background: var(--glass-bg); border: 1px solid var(--glass-border);
    transition: all var(--transition-fast);
}
.step-label.active .step-num {
    background: var(--primary-gradient); color: white; border-color: transparent;
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.35);
}
.step-connector { width: 34px; height: 1px; background: var(--border); }
@media (max-width: 640px) {
    .step-connector { width: 12px; }
    .step-label { font-size: 0.72rem; }
}

/* === Sheet Picker === */
.sheet-picker {
    margin-top: 1rem; padding: 1rem 1.1rem;
    background: var(--glass-bg); border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm); animation: fadeSlideIn 0.25s ease;
}
.sheet-picker-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 1rem; margin-bottom: 0.6rem;
}
.sheet-picker-title { font-size: 0.85rem; font-weight: 700; }
.sheet-picker-hint { font-size: 0.72rem; color: var(--text-tertiary); margin-top: 0.15rem; }
.sheet-picker-list {
    max-height: 220px; overflow-y: auto; border: 1px solid var(--border);
    border-radius: var(--radius-xs);
}
.sheet-picker-item {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.55rem 0.85rem; border-bottom: 1px solid var(--border);
    cursor: pointer; transition: background var(--transition-fast);
    user-select: none;
}
.sheet-picker-item:last-child { border-bottom: none; }
.sheet-picker-item:hover { background: var(--bg-card-hover); }
.sheet-picker-item input[type="checkbox"] {
    width: 16px; height: 16px; accent-color: #667eea; cursor: pointer; flex-shrink: 0;
}
.sheet-picker-item-name { font-size: 0.82rem; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-picker-item-meta { font-size: 0.7rem; color: var(--text-tertiary); flex-shrink: 0; }

/* === Result Panel === */
.result-panel {
    margin-top: 1.25rem; border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden;
    background: var(--bg-card); animation: fadeSlideIn 0.35s ease;
}
.result-panel.hidden { display: none; }

/* Shared visibility utility (sheet picker, result panel). */
.hidden { display: none !important; }
.result-header {
    display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: 0.5rem;
    padding: 1rem 1.25rem;
    background: rgba(56, 239, 125, 0.06);
    border-bottom: 1px solid var(--border);
}
.result-title { font-size: 0.95rem; font-weight: 700; color: #38ef7d; }
.result-meta { font-size: 0.75rem; color: var(--text-secondary); font-family: 'JetBrains Mono', monospace; }
.result-stats {
    display: flex; gap: 0.75rem; flex-wrap: wrap;
    padding: 0.85rem 1.25rem; border-bottom: 1px solid var(--border);
}
.result-stat {
    flex: 1; min-width: 90px; text-align: center;
    padding: 0.55rem 0.6rem; border-radius: var(--radius-xs);
    background: var(--glass-bg); border: 1px solid var(--glass-border);
}
.result-stat-value { font-size: 1rem; font-weight: 700; color: #8b9cf7; font-family: 'JetBrains Mono', monospace; }
.result-stat-label { font-size: 0.66rem; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.06em; }
.result-stat.warn .result-stat-value { color: #ffb020; }
.result-stat.bad .result-stat-value { color: #ff6b6b; }
.result-warnings { padding: 0.75rem 1.25rem; display: none; }
.result-warnings.active { display: block; background: rgba(255, 107, 107, 0.07); border-bottom: 1px solid var(--border); }
.result-warning-item { font-size: 0.78rem; color: #ffb020; display: flex; gap: 0.5rem; align-items: baseline; }
.result-warning-item .warn-icon { flex-shrink: 0; }
.result-quality { padding: 0.75rem 1.25rem; display: none; }
.result-quality.active { display: block; background: rgba(102, 126, 234, 0.07); border-bottom: 1px solid var(--border); }
.result-quality-title { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: #8b9cf7; margin-bottom: 0.4rem; }
.result-quality-item { font-size: 0.78rem; color: var(--text-secondary); display: flex; gap: 0.5rem; align-items: baseline; padding: 0.12rem 0; }
.result-quality-item .q-icon { flex-shrink: 0; color: #8b9cf7; }
.result-tabs { display: flex; border-bottom: 1px solid var(--border); }
.result-tab {
    flex: 1; padding: 0.7rem; background: none; border: none;
    color: var(--text-tertiary); font-size: 0.85rem; font-weight: 600;
    cursor: pointer; font-family: inherit;
    border-bottom: 2px solid transparent; transition: all var(--transition-fast);
}
.result-tab:hover { color: var(--text-secondary); }
.result-tab.active { color: #8b9cf7; border-bottom-color: #667eea; }
.result-body { max-height: 480px; overflow-y: auto; }
.result-markdown { display: none; }
.result-markdown.active { display: block; }
.result-markdown pre {
    padding: 1.25rem; font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem; line-height: 1.55; white-space: pre-wrap;
    word-break: break-word; color: var(--text-secondary);
}
.result-preview { padding: 1.25rem; display: none; }
.result-preview.active { display: block; }
.result-actions {
    display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap;
    padding: 1rem 1.25rem; border-top: 1px solid var(--border);
}

/* === Markdown Body (rendered preview) === */
.markdown-body { font-size: 0.88rem; line-height: 1.65; }
.markdown-body h1 { font-size: 1.5rem; margin: 0.8em 0 0.4em; }
.markdown-body h2 { font-size: 1.2rem; margin: 0.8em 0 0.4em; color: #8b9cf7; border-bottom: 1px solid var(--border); padding-bottom: 0.3em; }
.markdown-body h3 { font-size: 1.02rem; margin: 0.8em 0 0.35em; }
.markdown-body h4 { font-size: 0.95rem; margin: 0.7em 0 0.3em; }
.markdown-body p { margin: 0.4em 0; }
.markdown-body ul, .markdown-body ol { padding-left: 1.5em; margin: 0.4em 0; }
.markdown-body li { margin: 0.2em 0; }
.markdown-body table { border-collapse: collapse; margin: 0.6em 0; width: 100%; font-size: 0.82rem; }
.markdown-body th, .markdown-body td {
    border: 1px solid var(--border); padding: 0.35rem 0.6rem; text-align: left;
}
.markdown-body th { background: var(--glass-bg); font-weight: 600; }
.markdown-body code {
    background: rgba(102, 126, 234, 0.12); padding: 0.1em 0.35em;
    border-radius: 4px; font-family: 'JetBrains Mono', monospace; font-size: 0.8em;
}
.markdown-body pre {
    background: rgba(0, 0, 0, 0.25); padding: 0.9rem 1rem; border-radius: var(--radius-xs);
    overflow-x: auto; margin: 0.6em 0;
}
.markdown-body pre code { background: none; padding: 0; }
[data-theme="light"] .markdown-body pre { background: rgba(0, 0, 0, 0.05); }
[data-theme="sepia"] .markdown-body pre { background: rgba(56, 41, 26, 0.06); }
[data-theme="high-contrast"] .markdown-body pre { background: rgba(0, 0, 0, 0.55); border-color: rgba(255, 255, 255, 0.2); }

/* === About / Guide Modal === */
.about-modal, .lan-modal {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 2500;
    background: rgba(0, 0, 0, 0.7);
    -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
    display: none; align-items: center; justify-content: center; padding: 2rem;
    animation: modalBackdropIn 0.3s ease;
}
.about-modal.active, .lan-modal.active { display: flex; }
.about-modal-content {
    background: var(--bg-darker); border: 1px solid var(--border);
    border-radius: var(--radius); width: 100%; max-width: 680px; max-height: 88vh;
    position: relative; box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex; flex-direction: column; overflow: hidden;
}
.about-modal-close {
    position: absolute; top: 1rem; right: 1rem; background: var(--glass-bg);
    border: 1px solid var(--glass-border); color: var(--text-secondary);
    font-size: 1.2rem; cursor: pointer; width: 34px; height: 34px;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    transition: all var(--transition-fast); z-index: 2;
}
.about-modal-close:hover {
    background: rgba(255, 107, 107, 0.15); color: #ff6b6b;
    border-color: rgba(255, 107, 107, 0.3); transform: rotate(90deg);
}
.about-header { text-align: center; padding: 2rem 2rem 1.25rem; border-bottom: 1px solid var(--border); }
.about-logo {
    width: 52px; height: 52px; margin: 0 auto 0.75rem;
    background: var(--primary-gradient); border-radius: 14px;
    display: flex; align-items: center; justify-content: center; font-size: 1.5rem;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.35);
}
.about-header h1 { font-family: 'Poppins', sans-serif; font-size: 1.5rem; font-weight: 800; margin-bottom: 0.3rem; }
.about-header p { color: var(--text-secondary); font-size: 0.85rem; }
.about-body { padding: 1.5rem 2rem 2rem; overflow-y: auto; }
.about-body h2 {
    font-size: 1rem; font-weight: 700; margin: 1.25rem 0 0.5rem;
    color: #8b9cf7;
}
.about-body h2:first-child { margin-top: 0; }
.about-body p { font-size: 0.85rem; color: var(--text-secondary); margin: 0.4rem 0; line-height: 1.7; }
.about-body ul, .about-body ol { padding-left: 1.4em; margin: 0.4rem 0; }
.about-body li { font-size: 0.85rem; color: var(--text-secondary); margin: 0.3rem 0; line-height: 1.6; }
.about-body strong { color: var(--text-primary); }
.about-body code {
    background: rgba(102, 126, 234, 0.12); padding: 0.1em 0.35em;
    border-radius: 4px; font-family: 'JetBrains Mono', monospace; font-size: 0.78em;
}
.about-body pre {
    background: rgba(0, 0, 0, 0.25); padding: 0.8rem 1rem; border-radius: var(--radius-xs);
    overflow-x: auto; margin: 0.5rem 0;
}
.about-body pre code { background: none; padding: 0; font-size: 0.78rem; }
[data-theme="light"] .about-body pre { background: rgba(0, 0, 0, 0.05); }
[data-theme="sepia"] .about-body pre { background: rgba(56, 41, 26, 0.06); }
.about-table { border-collapse: collapse; margin: 0.6rem 0; width: 100%; font-size: 0.8rem; }
.about-table th, .about-table td {
    border: 1px solid var(--border); padding: 0.45rem 0.7rem; text-align: left;
}
.about-table th { background: var(--glass-bg); font-weight: 600; font-size: 0.74rem; }

/* === LAN Modal === */
.lan-modal-content {
    background: var(--bg-darker); border: 1px solid var(--border);
    border-radius: var(--radius); width: 100%; max-width: 360px;
    position: relative; box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    padding: 2rem; text-align: center;
}
.lan-modal-content h2 { font-family: 'Poppins', sans-serif; font-size: 1.2rem; font-weight: 800; margin-bottom: 0.4rem; }
.lan-hint { color: var(--text-secondary); font-size: 0.82rem; margin-bottom: 1.25rem; }
.lan-qr {
    width: 200px; height: 200px; margin: 0 auto 1.25rem;
    padding: 0.6rem; background: white; border-radius: var(--radius-sm);
    box-shadow: var(--shadow-card);
}
.lan-qr img { width: 100%; height: 100%; display: block; border-radius: 4px; }
.lan-details { font-size: 0.82rem; color: var(--text-secondary); }
.lan-details .lan-url {
    display: block; margin: 0.5rem auto 0.75rem; font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem; color: #8b9cf7; word-break: break-all;
}
.lan-note {
    margin-top: 1rem; padding: 0.6rem 0.8rem; border-radius: var(--radius-xs);
    background: rgba(255, 176, 32, 0.08); border: 1px solid rgba(255, 176, 32, 0.2);
    color: #ffb020; font-size: 0.74rem; line-height: 1.5;
}
.lan-note.info {
    background: rgba(102, 126, 234, 0.08); border-color: rgba(102, 126, 234, 0.2);
    color: #8b9cf7;
}

/* === Footer Link === */
.footer-link {
    background: none; border: none; color: var(--text-tertiary);
    text-decoration: underline; cursor: pointer; font-family: inherit; font-size: inherit;
    transition: color var(--transition-fast);
}
.footer-link:hover { color: #8b9cf7; }

/* === Paste-to-convert === */
.paste-row { margin-top: 0.75rem; text-align: center; }
.paste-btn {
    padding: 0.55rem 1.3rem; border-radius: var(--radius-sm);
    background: var(--glass-bg); border: 1px dashed var(--border);
    color: var(--text-secondary); font-size: 0.85rem; font-weight: 600;
    cursor: pointer; font-family: inherit; transition: all var(--transition-fast);
}
.paste-btn:hover {
    background: var(--bg-card-hover); color: var(--text-primary);
    border-color: var(--border-hover);
}
.paste-modal-content {
    background: var(--bg-darker); border: 1px solid var(--border);
    border-radius: var(--radius); width: 100%; max-width: 560px;
    position: relative; box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    padding: 2rem;
}
.paste-modal-content h2 { font-family: 'Poppins', sans-serif; font-size: 1.2rem; font-weight: 800; margin-bottom: 0.3rem; }
.paste-format-row { margin: 1rem 0 0.5rem; }
.paste-textarea {
    width: 100%; min-height: 220px; padding: 0.9rem 1rem;
    border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: var(--bg-card); color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace; font-size: 0.8rem; line-height: 1.5;
    outline: none; resize: vertical; transition: all var(--transition-fast);
}
.paste-textarea:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.12);
}

/* === Theme Picker (navbar popover) === */
.theme-wrap { position: relative; }
.navbar .theme-toggle {
    position: static; width: 40px; height: 40px; font-size: 1.05rem;
    box-shadow: none; transform: none; border-radius: 12px;
}
.navbar .theme-toggle:hover { transform: none; }
.theme-menu {
    position: absolute; top: calc(100% + 10px); right: 0; z-index: 1100;
    width: 190px; padding: 0.6rem;
    background: var(--bg-darker); border: 1px solid var(--border);
    border-radius: var(--radius-sm); box-shadow: var(--shadow-card);
    display: none; animation: fadeSlideIn 0.2s ease;
}
.theme-menu.open { display: block; }
.theme-menu-title {
    font-size: 0.65rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.08em; color: var(--text-tertiary); padding: 0.3rem 0.5rem 0.5rem;
}
.theme-option {
    display: flex; align-items: center; gap: 0.6rem; width: 100%;
    padding: 0.5rem 0.6rem; border: none; background: none; border-radius: 8px;
    color: var(--text-secondary); font-size: 0.85rem; font-weight: 600;
    cursor: pointer; font-family: inherit; transition: all var(--transition-fast);
}
.theme-option:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.theme-option.active { color: var(--text-primary); background: var(--bg-card-active); }
.theme-swatch {
    width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--border);
    flex-shrink: 0; display: inline-block;
}
.sw-dark { background: linear-gradient(135deg, #0b0b1a 0%, #23233f 100%); }
.sw-light { background: linear-gradient(135deg, #f4f4f8 0%, #d9d9e4 100%); }
.sw-hc { background: linear-gradient(135deg, #00000f 0%, #1c1c3a 100%); border-color: #7aa2ff; }
.sw-sepia { background: linear-gradient(135deg, #f6eedb 0%, #d9c49a 100%); }

/* === Auto-download switch === */
.auto-dl {
    display: flex; align-items: center; justify-content: center; gap: 0.55rem;
    margin: 0.9rem auto 0; cursor: pointer; user-select: none;
    color: var(--text-secondary); font-size: 0.8rem; font-weight: 600; width: fit-content;
}
.auto-dl input { position: absolute; opacity: 0; width: 0; height: 0; }
.auto-dl-track {
    width: 38px; height: 21px; border-radius: 20px; position: relative;
    background: var(--border); border: 1px solid var(--border);
    transition: all var(--transition-fast); flex-shrink: 0;
}
.auto-dl-thumb {
    position: absolute; top: 2px; left: 2px; width: 15px; height: 15px;
    border-radius: 50%; background: var(--text-secondary);
    transition: all var(--transition-fast);
}
.auto-dl input:checked + .auto-dl-track { background: #667eea; border-color: #667eea; }
.auto-dl input:checked + .auto-dl-track .auto-dl-thumb { left: 19px; background: #fff; }
.auto-dl:hover .auto-dl-text { color: var(--text-primary); }

/* === Result layout + TOC sidebar === */
.result-layout {
    display: grid; grid-template-columns: 200px 1fr; gap: 1.25rem;
    padding: 0 1.25rem; align-items: start;
}
.result-toc { display: none; }
.result-toc.active {
    display: block; position: sticky; top: 90px;
    max-height: 460px; overflow-y: auto;
    border-left: 2px solid var(--border); padding-left: 0.9rem;
}
.result-toc-title {
    font-size: 0.65rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.08em; color: var(--text-tertiary); margin-bottom: 0.5rem;
}
.result-toc-list { display: flex; flex-direction: column; gap: 0.15rem; }
.toc-item {
    background: none; border: none; text-align: left; cursor: pointer;
    font-family: inherit; font-size: 0.78rem; line-height: 1.35;
    color: var(--text-secondary); padding: 0.25rem 0.4rem; border-radius: 6px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    transition: all var(--transition-fast);
}
.toc-item.lvl-3 { padding-left: 1.2rem; font-size: 0.74rem; }
.toc-item:hover { color: var(--text-primary); background: var(--bg-card-hover); }
.toc-item.current { color: #8b9cf7; font-weight: 700; background: var(--bg-card-active); }
.toc-empty { font-size: 0.75rem; color: var(--text-tertiary); font-style: italic; }
.result-main { min-width: 0; }
.markdown-body h2, .markdown-body h3 { scroll-margin-top: 90px; }

@media (max-width: 860px) {
    .result-layout { grid-template-columns: 1fr; }
    .result-toc.active { position: static; max-height: 220px; margin-bottom: 0.75rem; }
}

/* === Copy buttons wrap nicely in the actions row === */
.result-actions { flex-wrap: wrap; }

/* === Command Palette === */
.palette-overlay {
    position: fixed; inset: 0; z-index: 2000; display: none;
    align-items: flex-start; justify-content: center;
    background: rgba(0, 0, 0, 0.55); -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px); padding: 12vh 1rem 1rem;
}
.palette-overlay.open { display: flex; animation: fadeIn 0.15s ease; }
.palette {
    width: 100%; max-width: 560px; background: var(--bg-darker);
    border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-card); overflow: hidden;
    animation: modalSlideIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.palette-input {
    width: 100%; padding: 1rem 1.2rem; font-size: 0.95rem;
    background: transparent; border: none; outline: none;
    color: var(--text-primary); font-family: inherit;
    border-bottom: 1px solid var(--border);
}
.palette-input::placeholder { color: var(--text-tertiary); }
.palette-list { max-height: 46vh; overflow-y: auto; padding: 0.5rem; }
.palette-item {
    display: flex; align-items: center; gap: 0.7rem; width: 100%;
    padding: 0.55rem 0.75rem; border: none; background: none; border-radius: 8px;
    color: var(--text-secondary); font-size: 0.85rem; font-weight: 600;
    cursor: pointer; font-family: inherit; text-align: left;
    transition: background var(--transition-fast);
}
.palette-item .palette-icon {
    width: 26px; height: 26px; flex-shrink: 0; border-radius: 6px;
    background: var(--glass-bg); display: flex; align-items: center;
    justify-content: center; font-size: 0.9rem;
}
.palette-item .palette-meta { margin-left: auto; font-size: 0.68rem; color: var(--text-tertiary); }
.palette-item:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.palette-item.selected { background: var(--bg-card-active); color: var(--text-primary); }
.palette-empty { padding: 1.2rem; text-align: center; color: var(--text-tertiary); font-size: 0.85rem; }
.palette-footer {
    padding: 0.5rem 1.2rem; font-size: 0.68rem; color: var(--text-tertiary);
    border-top: 1px solid var(--border); letter-spacing: 0.03em;
}
