/* =============================================
   ResponsiveView — Design System & Styles
   ============================================= */

:root {
    /* Colors */
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-tertiary: #1a2236;
    --bg-surface: #1e293b;
    --bg-surface-hover: #263044;
    --bg-surface-active: #2d3a50;

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-tertiary: #64748b;
    --text-muted: #475569;

    --accent: #372FFF;
    --accent-hover: #5c55ff;
    --accent-glow: rgba(55, 47, 255, 0.25);
    --accent-soft: rgba(55, 47, 255, 0.1);

    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;

    --border: rgba(148, 163, 184, 0.08);
    --border-strong: rgba(148, 163, 184, 0.15);
    --border-accent: rgba(55, 47, 255, 0.4);

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px var(--accent-glow);

    /* Layout */
    --topbar-height: 60px;
    --sidebar-width: 280px;

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Mode */
[data-theme="light"] {
    --bg-primary: #f0f2f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8eaed;
    --bg-surface: #f5f6f8;
    --bg-surface-hover: #e2e4e8;
    --bg-surface-active: #d5d8dd;

    --text-primary: #1a1a2e;
    --text-secondary: #4a5568;
    --text-tertiary: #718096;
    --text-muted: #a0aec0;

    --accent: #372FFF;
    --accent-hover: #2921cc;
    --accent-glow: rgba(55, 47, 255, 0.2);
    --accent-soft: rgba(55, 47, 255, 0.08);

    --border: rgba(0, 0, 0, 0.06);
    --border-strong: rgba(0, 0, 0, 0.12);
    --border-accent: rgba(55, 47, 255, 0.4);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
    --shadow-glow: 0 0 20px var(--accent-glow);
}

/* Light mode adjustments */
[data-theme="light"] .device-frame {
    background: #1a1a2e;
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .device-frame::before {
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="light"] .empty-state h1,
[data-theme="light"] .landing-section-header h2 {
    background: linear-gradient(135deg, var(--text-primary), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
}

[data-theme="light"] .loading-overlay {
    background: rgba(240, 242, 245, 0.85);
}

/* =============================================
   Reset & Base
   ============================================= */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

input,
button {
    font-family: inherit;
    border: none;
    outline: none;
    background: none;
    color: inherit;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* =============================================
   Top Bar
   ============================================= */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 16px;
    z-index: 100;
    position: relative;
    backdrop-filter: blur(12px);
}

.topbar-left {
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    transition: transform var(--transition-fast);
}

.logo:hover {
    transform: scale(1.02);
}

.logo-img {
    height: 28px;
    width: auto;
    object-fit: contain;
}

/* Theme Toggle for Logo */
.logo-light {
    display: none;
}

[data-theme="light"] .logo-dark {
    display: none;
}

[data-theme="light"] .logo-light {
    display: block;
}

.topbar-center {
    flex: 1;
    max-width: 700px;
    margin: 0 auto;
}

.url-bar {
    display: flex;
    align-items: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    padding: 0 4px 0 14px;
    height: 42px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.url-bar:focus-within {
    border-color: var(--border-accent);
    box-shadow: var(--shadow-glow);
}

.url-icon {
    width: 18px;
    height: 18px;
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.url-bar input {
    flex: 1;
    height: 100%;
    padding: 0 12px;
    font-size: 14px;
    color: var(--text-primary);
    background: transparent;
}

.url-bar input::placeholder {
    color: var(--text-muted);
}

.btn-load {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: var(--accent);
    color: white;
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--transition-fast), transform var(--transition-fast);
}

.btn-load svg {
    width: 18px;
    height: 18px;
}

.btn-load:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

.btn-load:active {
    transform: scale(0.95);
}

.topbar-right {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 4px;
}

.zoom-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 42px;
    text-align: center;
    user-select: none;
}

/* =============================================
   Share Button
   ============================================= */
.btn-share {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 14px;
    height: 38px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, var(--accent), #00d2ff);
    border: none;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), opacity var(--transition-fast);
}

.btn-share svg {
    width: 15px;
    height: 15px;
}

.btn-share:hover {
    transform: scale(1.04);
    box-shadow: 0 4px 16px rgba(55, 47, 255, 0.4);
}

.btn-share:active {
    transform: scale(0.96);
}

/* =============================================
   Language Switcher (Dropdown)
   ============================================= */
.lang-switcher {
    position: relative;
}

.lang-current {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 20px 9px;
    border-radius: var(--radius-md);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-strong);
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s;
    height: 32px;
}

.lang-current:hover {
    border-color: var(--accent);
}

.lang-chevron {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    transition: transform 0.15s;
    color: var(--text-secondary);
}

.lang-switcher.open .lang-chevron {
    transform: rotate(180deg);
}

.lang-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
    z-index: 1000;
    min-width: 118px;
}

.lang-switcher.open .lang-dropdown {
    display: block;
    animation: fadeIn 0.12s ease-out;
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 9px 14px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background 0.12s;
    white-space: nowrap;
}

.lang-option:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.lang-option.active {
    color: var(--accent);
    font-weight: 700;
}

/* Share Modal */
.share-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease-out;
}

.share-modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    padding: 28px;
    width: 90%;
    max-width: 520px;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.25s ease-out;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.share-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.share-modal-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.share-modal-header h3 svg {
    width: 20px;
    height: 20px;
    color: var(--accent);
}

.share-modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-tertiary);
    background: none;
    border: none;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.share-modal-close svg {
    width: 18px;
    height: 18px;
}

.share-modal-close:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.share-url-group {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.share-url-input {
    flex: 1;
    height: 44px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 0 14px;
    font-size: 13px;
    font-family: 'Inter', monospace;
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition-fast);
}

.share-url-input:focus {
    border-color: var(--border-accent);
}

.btn-copy {
    height: 44px;
    padding: 0 18px;
    display: flex;
    align-items: center;
    gap: 6px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: white;
    background: var(--accent);
    border: none;
    white-space: nowrap;
    transition: background var(--transition-fast), transform var(--transition-fast);
}

.btn-copy svg {
    width: 16px;
    height: 16px;
}

.btn-copy:hover {
    background: var(--accent-hover);
}

.btn-copy:active {
    transform: scale(0.96);
}

.btn-copy.copied {
    background: var(--success);
}

.share-config-summary {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
}

.share-config-summary p {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-tertiary);
    margin-bottom: 8px;
}

.share-config-items {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.share-config-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--accent-soft);
    border: 1px solid var(--border-accent);
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    color: var(--accent-hover);
}

[data-theme="light"] .share-config-tag {
    color: var(--accent);
}

/* =============================================
   Help Button
   ============================================= */
.btn-help {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    text-decoration: none;
    flex-shrink: 0;
    transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast), border-color var(--transition-fast);
}

.btn-help svg {
    width: 18px;
    height: 18px;
}

.btn-help:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
    transform: scale(1.08);
    border-color: var(--border-strong);
}

.btn-help:active {
    transform: scale(0.92);
}

/* Mobile variant — hidden by default, shown only on phones */
.btn-help-mobile,
.btn-share-mobile,
#btnThemeToggleMobile {
    display: none !important;
    text-decoration: none;
    color: var(--text-secondary);
}

/* =============================================
   Theme Toggle Button
   ============================================= */
.btn-theme-toggle {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
    transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast), border-color var(--transition-fast);
}

.btn-theme-toggle:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
    transform: scale(1.08);
    border-color: var(--border-strong);
}

.btn-theme-toggle:active {
    transform: scale(0.92);
}

.btn-theme-toggle svg {
    width: 18px;
    height: 18px;
    position: absolute;
    transition: opacity 0.3s ease, transform 0.4s ease;
}

/* Dark mode: show moon, hide sun */
.btn-theme-toggle .icon-moon {
    opacity: 1;
    transform: rotate(0deg);
}

.btn-theme-toggle .icon-sun {
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}

/* Light mode: show sun, hide moon */
[data-theme="light"] .btn-theme-toggle .icon-moon {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

[data-theme="light"] .btn-theme-toggle .icon-sun {
    opacity: 1;
    transform: rotate(0deg);
}

[data-theme="light"] .btn-theme-toggle {
    color: #f59e0b;
}

[data-theme="light"] .btn-theme-toggle:hover {
    color: #d97706;
    background: #fef3c7;
    border-color: #f59e0b;
}

/* Light mode adjustments */
[data-theme="light"] .device-frame {
    background: #1a1a2e;
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .device-frame::before {
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="light"] .empty-state h1,
[data-theme="light"] .landing-section-header h2 {
    background: linear-gradient(135deg, var(--text-primary), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
}

[data-theme="light"] .loading-overlay {
    background: rgba(240, 242, 245, 0.85);
}

/* =============================================
   Buttons
   ============================================= */
.btn-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}

.btn-icon svg {
    width: 16px;
    height: 16px;
}

.btn-icon:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.btn-icon:active {
    transform: scale(0.92);
}

.btn-rotate {
    width: auto !important;
    padding: 0 12px;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
}

/* =============================================
   Main Layout
   ============================================= */
.main-layout {
    display: flex;
    height: calc(100vh - var(--topbar-height));
}

/* =============================================
   Sidebar
   ============================================= */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: relative;
    transition: width var(--transition-smooth), min-width var(--transition-smooth);
    min-width: var(--sidebar-width);
    z-index: 50;
}

.sidebar.collapsed {
    width: 0;
    min-width: 0;
    border-right: none;
}

.sidebar.collapsed .sidebar-content {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.1s;
}

.sidebar-toggle {
    position: absolute;
    right: -14px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-strong);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 60;
    transition: background var(--transition-fast), transform var(--transition-fast);
}

.sidebar-toggle svg {
    width: 14px;
    height: 14px;
    color: var(--text-secondary);
    transition: transform var(--transition-normal);
}

.sidebar.collapsed .sidebar-toggle {
    right: -36px;
}

.sidebar.collapsed .sidebar-toggle svg {
    transform: rotate(180deg);
}

.sidebar-toggle:hover {
    background: var(--accent);
}

.sidebar-toggle:hover svg {
    color: white;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

/* =============================================
   Sidebar Sections
   ============================================= */
.sidebar-section {
    margin-bottom: 8px;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-tertiary);
    padding: 10px 8px 6px;
}

.section-title svg {
    width: 14px;
    height: 14px;
}

.device-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.device-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast), box-shadow var(--transition-fast);
    user-select: none;
}

.device-item:hover {
    background: var(--bg-surface-hover);
}

.device-item.active {
    background: var(--accent-soft);
    box-shadow: inset 3px 0 0 var(--accent);
}

.device-item-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.device-item.active .device-item-name {
    color: var(--accent-hover);
}

.device-item-res {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
    margin-left: 8px;
}

.device-item.active .device-item-res {
    color: var(--accent);
}

/* =============================================
   Custom Resolution
   ============================================= */
.custom-resolution {
    padding: 8px;
}

.custom-inputs {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.input-group {
    flex: 1;
    position: relative;
}

.input-group label {
    position: absolute;
    top: 50%;
    left: 10px;
    transform: translateY(-50%);
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    pointer-events: none;
}

.input-group input {
    width: 100%;
    height: 36px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 0 8px 0 28px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    transition: border-color var(--transition-fast);
    font-variant-numeric: tabular-nums;
}

.input-group input:focus {
    border-color: var(--border-accent);
}

.input-group input::-webkit-inner-spin-button,
.input-group input::-webkit-outer-spin-button {
    -webkit-appearance: none;
}

.input-separator {
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 300;
}

.btn-apply {
    width: 100%;
    height: 34px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-apply:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.btn-apply:active {
    transform: scale(0.97);
}

/* =============================================
   Viewport Area
   ============================================= */
.viewport-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-primary);
    position: relative;
}

/* Subtle grid pattern */
.viewport-area::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 1px 1px, var(--border) 1px, transparent 0);
    background-size: 40px 40px;
    opacity: 0.4;
    pointer-events: none;
    z-index: 0;
}

.viewport-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    z-index: 10;
    position: relative;
}

.device-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.device-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.device-resolution {
    font-size: 12px;
    color: var(--text-tertiary);
    font-variant-numeric: tabular-nums;
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
}

.viewport-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Auto-reload control */
.auto-reload-control {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 2px;
}

.auto-reload-switch {
    position: relative;
    display: inline-flex;
    cursor: pointer;
    flex-shrink: 0;
}

.auto-reload-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.switch-track {
    width: 28px;
    height: 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    transition: background 0.18s, border-color 0.18s;
    position: relative;
    flex-shrink: 0;
}

.switch-track::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--text-secondary);
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.18s, background 0.18s;
}

.auto-reload-switch input:checked + .switch-track {
    background: var(--accent);
    border-color: var(--accent);
}

.auto-reload-switch input:checked + .switch-track::after {
    transform: translateX(12px);
    background: #fff;
}

.auto-reload-input {
    width: 34px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 11px;
    font-family: inherit;
    text-align: center;
    padding: 2px 3px;
    height: 22px;
    -moz-appearance: textfield;
}

.auto-reload-input::-webkit-outer-spin-button,
.auto-reload-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.auto-reload-unit {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1;
}

#btnRefresh:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

#btnScrollToggle.active {
    color: var(--accent);
    background: var(--accent-soft);
}

/* =============================================
   Viewport Container
   ============================================= */
.viewport-container {
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow: auto;
    position: relative;
    z-index: 1;
    padding: 24px;
}

.iframe-wrapper {
    margin: 0 auto;
}

/* =============================================
   Empty State
   ============================================= */
.empty-state {
    text-align: center;
    max-width: 800px;
    width: 100%;
    animation: fadeIn 0.6s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.empty-icon {
    margin-bottom: 24px;
}

.empty-icon svg {
    width: 80px;
    height: 80px;
    color: var(--text-muted);
    opacity: 0.5;
}

.empty-state h1 {
    font-size: 30px;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-hover));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.empty-state > h3 {
    font-size: 20px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
    -webkit-text-fill-color: unset;
}

.empty-state p {
    font-size: 16px;
    color: var(--text-tertiary);
    margin-bottom: 32px;
    line-height: 1.6;
}

.empty-features {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.feature-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    text-align: left;
    transition: border-color var(--transition-fast), transform var(--transition-fast);
}

.feature-item:hover {
    border-color: var(--border-accent);
    transform: translateY(-2px);
}

.feature-icon {
    width: 44px;
    height: 44px;
    background: var(--accent-soft);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}

.feature-icon svg {
    width: 22px;
    height: 22px;
    color: var(--accent);
}

.feature-text {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.feature-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.feature-desc {
    font-size: 16px;
    font-weight: 400;
    color: var(--text-tertiary);
    line-height: 1.6;
    margin: 0;
}

/* =============================================
   Landing Sections (How it works + FAQ)
   ============================================= */
.landing-section-header {
    margin: 40px 0 24px;
}

.landing-section-header h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 6px;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-hover));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.landing-section-header p {
    font-size: 16px;
    color: var(--text-tertiary);
    margin-bottom: 0;
}

/* Steps */
.steps-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    text-align: left;
}

.step-item {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: border-color var(--transition-fast), transform var(--transition-fast);
}

.step-item:hover {
    border-color: var(--border-accent);
    transform: translateY(-2px);
}

.step-icon {
    position: relative;
    width: 44px;
    height: 44px;
    background: var(--accent-soft);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}

.step-icon svg {
    width: 22px;
    height: 22px;
    color: var(--accent);
}

.step-number {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    background: var(--accent);
    color: white;
    font-size: 11px;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.step-item h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.step-item p {
    font-size: 16px;
    color: var(--text-tertiary);
    line-height: 1.6;
    margin-bottom: 0;
}

/* FAQ */
.faq-section {
    text-align: left;
}

.faq-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.faq-item {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: border-color var(--transition-fast);
}

.faq-item.open {
    border-color: var(--border-accent);
}

.faq-question {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    cursor: pointer;
    background: none;
    border: none;
    text-align: left;
    gap: 12px;
}

.faq-question span {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.faq-chevron {
    width: 16px;
    height: 16px;
    color: var(--text-tertiary);
    flex-shrink: 0;
    transition: transform var(--transition-normal);
}

.faq-item.open .faq-chevron {
    transform: rotate(180deg);
}

.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.faq-answer p {
    font-size: 16px;
    color: var(--text-tertiary);
    line-height: 1.7;
    padding: 0 16px 14px;
    margin: 0;
}

.faq-item.open .faq-answer {
    max-height: 200px;
}

@media (max-width: 700px) {
    .steps-grid {
        grid-template-columns: 1fr;
    }
}

/* =============================================
   CTA Section
   ============================================= */
.cta-section {
    margin-top: 40px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--accent) 0%, #00d2ff 100%);
    padding: 2px;
}

.cta-inner {
    background: var(--bg-secondary);
    border-radius: calc(var(--radius-lg) - 2px);
    padding: 28px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
}

.cta-text {
    flex: 1;
    min-width: 220px;
    text-align: left;
}

.cta-text h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    line-height: 1.4;
}

.cta-text p {
    font-size: 16px;
    color: var(--text-tertiary);
    line-height: 1.6;
    margin: 0;
}

.btn-cta {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    padding: 12px 22px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--accent), #00d2ff);
    color: white;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    flex-shrink: 0;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), opacity var(--transition-fast);
}

.btn-cta:hover {
    transform: scale(1.04);
    box-shadow: 0 6px 20px rgba(55, 47, 255, 0.4);
}

.btn-cta:active {
    transform: scale(0.97);
}

/* =============================================
   Empty Footer (social + copyright)
   ============================================= */
.empty-footer {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding-bottom: 8px;
}

.social-links {
    display: flex;
    align-items: center;
    gap: 12px;
}

.social-link {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-tertiary);
    text-decoration: none;
    transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}

.social-link svg {
    width: 16px;
    height: 16px;
}

.social-link:hover {
    background: var(--accent-soft);
    border-color: var(--border-accent);
    color: var(--accent-hover);
    transform: translateY(-2px);
}

.footer-copy {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0;
}

/* =============================================
   iframe Wrapper & Device Frame
   ============================================= */
.iframe-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    transition: transform var(--transition-smooth);
}

.device-frame {
    background: #000;
    border-radius: var(--radius-xl);
    padding: 8px;
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255, 255, 255, 0.05);
    transition: width var(--transition-smooth), height var(--transition-smooth);
    position: relative;
    overflow: hidden;
}

.device-frame::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-xl);
    border: 1px solid rgba(255, 255, 255, 0.08);
    pointer-events: none;
    z-index: 2;
}

.device-screen {
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: calc(var(--radius-xl) - 4px);
    background: white;
}

.device-frame iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

.dimension-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    display: flex;
    align-items: center;
    gap: 4px;
}

.dimension-label::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
}

/* =============================================
   Toast Notifications
   ============================================= */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: 12px 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toastIn 0.3s ease-out;
    max-width: 360px;
    backdrop-filter: blur(12px);
}

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.error {
    border-left: 3px solid var(--error);
}

.toast.info {
    border-left: 3px solid var(--accent);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(20px);
    }
}

/* =============================================
   Hamburger Button (mobile/tablet only)
   ============================================= */
.btn-hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    flex-shrink: 0;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.btn-hamburger svg {
    width: 20px;
    height: 20px;
}

.btn-hamburger:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* =============================================
   Mobile Search Bar (tablet/phone only)
   ============================================= */
.mobile-search-bar {
    display: none;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    z-index: 10;
    position: relative;
}

.mobile-search-bar .url-bar {
    height: 46px;
}

/* Hint text variants */
.hint-desktop { display: inline; }
.hint-mobile  { display: none; }

/* =============================================
   Sidebar Backdrop (mobile overlay)
   ============================================= */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    z-index: 49;
}

.sidebar-backdrop.active {
    display: block;
}

/* =============================================
   Responsive (for the tool itself)
   ============================================= */
@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: var(--topbar-height);
        height: calc(100% - var(--topbar-height));
        z-index: 100;
        box-shadow: var(--shadow-lg);
    }

    .sidebar.collapsed {
        box-shadow: none;
    }

    /* Hide the in-sidebar toggle on mobile — hamburger handles it */
    .sidebar-toggle {
        display: none;
    }

    /* Show hamburger button */
    .btn-hamburger {
        display: flex;
    }

    /* Show logo on mobile */
    .topbar-left {
        display: flex !important;
    }

    /* Hide desktop URL bar */
    .topbar-center {
        display: none;
    }

    /* Show mobile URL bar */
    .mobile-search-bar {
        display: block;
    }

    /* Switch hint text */
    .hint-desktop { display: none; }
    .hint-mobile  { display: inline; }

    /* Push theme toggle all the way to the right */
    .topbar-right {
        margin-left: auto;
    }

    /* Hide share button label on tablet/mobile */
    .btn-share span {
        display: none;
    }

    .btn-share {
        padding: 0 10px;
        min-width: 38px;
    }
}

@media (max-width: 600px) {
    :root {
        --topbar-height: 54px;
    }

    .topbar {
        padding: 0 10px;
        gap: 8px;
    }

    /* Compact zoom controls on mobile */
    .zoom-controls {
        display: flex;
        padding: 2px;
        gap: 2px;
    }

    .zoom-controls .btn-icon {
        width: 26px;
        height: 26px;
    }

    .zoom-controls .btn-icon svg {
        width: 13px;
        height: 13px;
    }

    .zoom-label {
        font-size: 10px;
        min-width: 30px;
    }

    /* Hide share button entirely on small phones */
    .btn-share {
        display: none;
    }

    /* Hide topbar help and theme toggle on phones, show viewport-bar versions instead */
    .btn-help,
    #btnThemeToggle {
        display: none;
    }

    .btn-help-mobile,
    .btn-share-mobile,
    #btnThemeToggleMobile {
        display: flex !important;
    }

    .empty-features {
        grid-template-columns: 1fr;
    }

    .empty-state h1 {
        font-size: 26px;
        line-height: 28px;
    }

    .empty-state > h3{
        line-height: 24px;
    }

    .empty-state p {
        font-size: 16px;
        margin-bottom: 20px;
    }

    .lang-current {
        padding: 15px 9px;
    }

    .viewport-container {
        padding: 10px;
    }

    .viewport-info {
        padding: 6px 10px;
        flex-wrap: wrap;
        gap: 4px;
    }

    .device-info {
        flex-wrap: wrap;
        gap: 4px;
    }

    .device-name {
        font-size: 12px;
    }

    .device-resolution {
        font-size: 11px;
    }

    /* Banner smaller on mobile */
    .floating-banner {
        bottom: 12px;
        right: 12px;
    }

    .floating-banner__img {
        max-width: 180px;
    }
}

/* =============================================
   Loading spinner
   ============================================= */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 14, 23, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    border-radius: calc(var(--radius-xl) - 4px);
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border-strong);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
/* =============================================
   Floating Banner (bottom-left)
   ============================================= */

.floating-banner {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    border-radius: 12px;
    overflow: visible;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    animation: bannerSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.floating-banner.hidden {
    display: none;
}

.floating-banner__img {
    display: block;
    border-radius: 12px;
    max-width: 280px;
    width: 100%;
    height: auto;
}

.floating-banner__close {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: none;
    background: var(--bg-primary, #0a0e17);
    color: var(--text-primary, #f1f5f9);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    transition: background 0.2s, transform 0.2s;
    z-index: 1;
}

.floating-banner__close:hover {
    background: var(--accent, #3b82f6);
    color: #ffffff;
    transform: scale(1.1);
}

@keyframes bannerSlideIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =============================================
   Hide tools until a URL is loaded
   ============================================= */
body:not(.has-url) .sidebar,
body:not(.has-url) .btn-hamburger,
body:not(.has-url) .zoom-controls,
body:not(.has-url) .viewport-info {
    display: none !important;
}

/* On mobile with no URL, restore topbar share/help/theme since viewport-info is hidden */
@media (max-width: 600px) {
    body:not(.has-url) .btn-share,
    body:not(.has-url) .btn-help,
    body:not(.has-url) #btnThemeToggle {
        display: flex !important;
    }
}
