:root {
    --primary: #8B5CF6;
    --primary-dim: rgba(139, 92, 246, 0.12);
    --accent: #EC4899;
    --success: #10B981;
    --warning: #F59E0B;
    --bg: #0F172A;
    --bg-card: rgba(30, 41, 59, 0.8);
    --bg-elevated: #1E293B;
    --bg-input: rgba(15, 23, 42, 0.9);
    --text: #F1F5F9;
    --text-sec: #94A3B8;
    --text-muted: #475569;
    --border: rgba(148, 163, 184, 0.08);
    --radius: 12px;
    --radius-sm: 8px;
    --font: 'Inter', -apple-system, sans-serif;
}

[data-theme="light"] {
    --bg: #F8FAFC;
    --bg-card: rgba(255, 255, 255, 0.9);
    --bg-elevated: #FFFFFF;
    --bg-input: rgba(241, 245, 249, 0.9);
    --text: #0F172A;
    --text-sec: #475569;
    --text-muted: #94A3B8;
    --border: rgba(15, 23, 42, 0.06);
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    transition: background 300ms, color 300ms;
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}

[data-theme="light"] .app-header {
    background: rgba(248, 250, 252, 0.95);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.logo-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-icon {
    font-size: 1.25rem;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-dim);
    border-radius: var(--radius-sm);
}

.app-title {
    font-size: 1rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.app-subtitle {
    font-size: 0.65rem;
    color: var(--text-sec);
}

.header-actions {
    display: flex;
    gap: 4px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 7px 12px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 150ms ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #7C3AED);
    color: #fff;
}

.btn-primary:hover {
    box-shadow: 0 4px 14px rgba(139, 92, 246, 0.4);
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: var(--text-sec);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--bg-elevated);
    color: var(--text);
}

.main-content {
    flex: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: 16px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* URL Input */
.url-input-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.url-bar {
    display: flex;
    gap: 8px;
    align-items: center;
}

.url-prefix {
    font-size: 1rem;
}

.url-input {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.875rem;
    outline: none;
}

.url-input:focus {
    border-color: var(--primary);
}

.url-history {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.history-chip {
    padding: 3px 8px;
    background: var(--primary-dim);
    border-radius: 20px;
    font-size: 0.5625rem;
    color: var(--primary);
    cursor: pointer;
    border: none;
    font-family: var(--font);
    transition: all 150ms;
}

.history-chip:hover {
    background: rgba(139, 92, 246, 0.2);
}

/* Device Bar */
.device-bar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.device-btn {
    padding: 7px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-sec);
    font-family: var(--font);
    font-size: 0.6875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 150ms;
}

.device-btn:hover {
    color: var(--text);
    background: var(--bg-elevated);
}

.device-btn.active {
    background: var(--primary-dim);
    border-color: var(--primary);
    color: var(--primary);
}

/* Custom Size */
.custom-size {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
}

.custom-x {
    color: var(--text-muted);
    font-weight: 700;
}

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

.form-input {
    width: 80px;
    padding: 7px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.8125rem;
    outline: none;
}

/* Preview Grid */
.preview-grid {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
}

.preview-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all 250ms ease;
}

.preview-card:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transform: translateY(-2px);
}

.preview-header {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .preview-header {
    background: rgba(0, 0, 0, 0.02);
}

.preview-device {
    font-size: 0.6875rem;
    font-weight: 700;
}

.preview-dims {
    font-size: 0.5625rem;
    color: var(--text-muted);
}

.preview-frame {
    border: none;
    display: block;
    background: #fff;
}

.app-footer {
    text-align: center;
    padding: 12px;
    font-size: 0.625rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}

kbd {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 4px;
    font-size: 0.5625rem;
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .preview-grid {
        flex-direction: column;
        align-items: center;
    }
}

::-webkit-scrollbar {
    width: 5px;
}

::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.15);
    border-radius: 3px;
}