:root {
    --bg-color: #0F1219;
    --panel-bg: rgba(255, 255, 255, 0.03);
    --panel-border: rgba(255, 255, 255, 0.08);
    --text-main: #F8FAFC;
    --text-muted: #94A3B8;

    --primary: #6366F1;
    --primary-hover: #4F46E5;
    --secondary: #8B5CF6;
    --accent: #22D3EE;

    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;

    --font-sans: 'Inter', -apple-system, sans-serif;
    --transition: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

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

.hidden {
    display: none !important;
}

.mt-4 {
    margin-top: 1.5rem;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* -- Header -- */
.app-header {
    border-bottom: 1px solid var(--panel-border);
    background: rgba(15, 18, 25, 0.7);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

/* -- Buttons -- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all var(--transition);
    font-family: inherit;
}

.btn-sm {
    padding: 0.5rem 0.875rem;
    font-size: 0.85rem;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--panel-bg);
    border-color: var(--panel-border);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-outline {
    background: transparent;
    border-color: var(--panel-border);
    color: var(--text-main);
}

.btn-outline:hover {
    border-color: var(--text-muted);
    background: rgba(255, 255, 255, 0.02);
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    display: flex;
}

.btn-icon:hover {
    color: var(--text-main);
    background: var(--panel-bg);
}

.btn-icon.active {
    color: var(--primary);
}

/* -- Main Layout -- */
.app-main {
    flex: 1;
    padding: 2rem 1.5rem;
}

.grid-container {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 2rem;
}

@media (max-width: 900px) {
    .grid-container {
        grid-template-columns: 1fr;
    }
}

.glass-panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    backdrop-filter: blur(16px);
}

/* -- Form Sections -- */
.section-title h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    color: var(--text-main);
}

.divider {
    height: 1px;
    background: var(--panel-border);
    margin: 2rem 0;
}

/* Ratio/Dim Inputs Matrix */
.ratio-inputs,
.dim-inputs {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.input-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

.input-group input {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-md);
    padding: 1rem;
    color: var(--text-main);
    font-size: 1.25rem;
    font-weight: 600;
    font-family: inherit;
    text-align: center;
    transition: border-color var(--transition);
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.input-group label {
    position: absolute;
    top: -0.6rem;
    left: 1rem;
    background: var(--bg-color);
    /* fake knockout */
    padding: 0 0.25rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    border-radius: 4px;
}

.ratio-divider,
.dim-divider {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-muted);
}

/* Presets */
.presets-scroll {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    scrollbar-width: none;
}

.presets-scroll::-webkit-scrollbar {
    display: none;
}

.preset-btn {
    white-space: nowrap;
    padding: 0.5rem 0.8rem;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.preset-btn span {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.preset-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.preset-btn.active {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--primary);
    color: var(--primary);
}

.preset-btn.active span {
    color: inherit;
    opacity: 0.8;
}

/* Stats */
.stats-box {
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-md);
    padding: 1rem;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    padding: 0.4rem 0;
}

.stat-row span:first-child {
    color: var(--text-muted);
}

.stat-row span:last-child {
    font-weight: 600;
    font-family: monospace;
}

.stat-row:not(:last-child) {
    border-bottom: 1px dashed var(--panel-border);
}

/* Dim Actions */
.dim-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

/* -- Preview Panel -- */
.preview-panel {
    display: flex;
    flex-direction: column;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.preview-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.badge {
    background: rgba(34, 211, 238, 0.1);
    color: var(--accent);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.preview-container {
    flex: 1;
    min-height: 350px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-md);
    border: 1px dashed var(--panel-border);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    overflow: hidden;
}

.preview-box {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.2));
    border: 2px solid var(--primary);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: width 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
        height 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 0 40px rgba(99, 102, 241, 0.1);
    max-width: 100%;
    max-height: 100%;
}

.preview-text {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

/* Resolution Guide */
.resolution-guide h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    font-weight: 500;
}

.res-list {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.5rem;
}

.res-item {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--panel-border);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.res-item:hover {
    border-color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
}

.res-item strong {
    color: var(--text-main);
}

.res-item span {
    color: var(--text-muted);
}