:root {
        --bg-color: #020617;
        --bg-gradient: radial-gradient(circle at top left, rgba(99, 102, 241, 0.25), transparent 45%),
                        radial-gradient(circle at bottom right, rgba(16, 185, 129, 0.18), transparent 50%),
                        radial-gradient(circle at top right, rgba(56, 189, 248, 0.12), transparent 40%),
                        #020617;
        --surface-primary: rgba(15, 23, 42, 0.85);
        --surface-secondary: rgba(30, 41, 59, 0.9);
        --surface-elevated: rgba(17, 24, 39, 0.95);
        --border-color: rgba(148, 163, 184, 0.25);
        --text-primary: #f8fafc;
        --text-secondary: #cbd5f5;
        --text-muted: rgba(148, 163, 184, 0.85);
        --accent: #6366f1;
        --accent-hover: #4f46e5;
        --success: #22c55e;
        --success-hover: #16a34a;
        --shadow-soft: 0 28px 80px -40px rgba(15, 23, 42, 0.9);
        --radius-lg: 24px;
        --radius-md: 16px;
        --transition: all 180ms ease;
}

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

html {
        font-size: 16px;
}

body {
        margin: 0;
        min-height: 100vh;
        font-family: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
        background: var(--bg-gradient);
        color: var(--text-primary);
        line-height: 1.6;
        display: flex;
        justify-content: center;
}

body::before {
        content: "";
        position: fixed;
        inset: 0;
        background: linear-gradient(180deg, rgba(15, 23, 42, 0.8) 0%, rgba(2, 6, 23, 0.94) 60%, rgba(2, 6, 23, 1) 100%);
        pointer-events: none;
        z-index: -1;
}

a {
        color: var(--accent);
        text-decoration: none;
        transition: color 160ms ease;
}

a:hover,
a:focus-visible {
        color: var(--accent-hover);
}

h1, h2, h3 {
        margin: 0;
        font-weight: 600;
        color: var(--text-primary);
        line-height: 1.2;
}

p {
        margin: 0;
        color: var(--text-secondary);
}

code {
        font-family: 'JetBrains Mono', 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
        font-size: 0.85em;
        color: #a855f7;
        background-color: rgba(76, 29, 149, 0.2);
        padding: 0.15rem 0.35rem;
        border-radius: 999px;
}

.app-wrapper {
        width: min(1200px, 100%);
        padding: 48px 24px 72px;
        display: flex;
        flex-direction: column;
        gap: 32px;
}

.app-header {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 24px;
        padding: 28px 32px;
        border-radius: var(--radius-lg);
        background: var(--surface-primary);
        border: 1px solid var(--border-color);
        box-shadow: var(--shadow-soft);
        backdrop-filter: blur(18px);
}

.brand {
        display: flex;
        align-items: center;
        gap: 20px;
}

.brand-logo {
        border-radius: 20px;
        box-shadow: 0 12px 30px -18px rgba(99, 102, 241, 0.85);
}

.brand-copy h1 {
        font-size: clamp(1.75rem, 2.1vw, 2.2rem);
}

.brand-copy p {
        margin-top: 6px;
        color: var(--text-muted);
        font-size: 0.98rem;
}


.app-main {
        display: grid;
        grid-template-columns: minmax(0, 360px) minmax(0, 1fr);
        gap: 32px;
        align-items: start;
}

.panel-card,
.preview-card,
.results-card {
        background: var(--surface-secondary);
        border-radius: var(--radius-lg);
        border: 1px solid var(--border-color);
        box-shadow: var(--shadow-soft);
        padding: 28px;
        backdrop-filter: blur(22px);
}

.preview-card {
        margin-top: 24px;
        background: var(--surface-elevated);
}

.panel-heading {
        display: flex;
        flex-direction: column;
        gap: 8px;
        margin-bottom: 22px;
}

.panel-subtitle {
        color: var(--text-muted);
        font-size: 0.95rem;
}

.field-group {
        display: flex;
        flex-direction: column;
        gap: 10px;
        margin-bottom: 22px;
}

.field-group label {
        font-weight: 600;
        color: var(--text-primary);
}

.field-hint {
        color: var(--text-muted);
        font-size: 0.85rem;
}

.file-input {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
}

.panel-input,
select.panel-input {
        width: 100%;
        padding: 0.75rem 0.9rem;
        border-radius: var(--radius-md);
        border: 1px solid rgba(148, 163, 184, 0.35);
        background: rgba(15, 23, 42, 0.75);
        color: var(--text-primary);
        font-size: 1rem;
        transition: border-color 160ms ease, box-shadow 160ms ease;
}

.panel-input::placeholder {
        color: rgba(148, 163, 184, 0.6);
}

.panel-input:focus,
select.panel-input:focus {
        border-color: rgba(99, 102, 241, 0.7);
        box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
        outline: none;
}

button {
        font: inherit;
        border: none;
        border-radius: var(--radius-md);
        padding: 0.75rem 1.1rem;
        cursor: pointer;
        transition: var(--transition);
        font-weight: 600;
        color: var(--text-primary);
        background: rgba(99, 102, 241, 0.2);
}

button:focus-visible {
        outline: 3px solid rgba(99, 102, 241, 0.4);
        outline-offset: 2px;
}

button.open {
        background: var(--accent);
        box-shadow: 0 18px 40px -22px rgba(99, 102, 241, 0.9);
}

button.open:hover,
button.open:focus-visible {
        background: var(--accent-hover);
        transform: translateY(-1px);
}

button.resize {
        width: 100%;
        background: var(--success);
        color: #032616;
        font-size: 1.05rem;
        padding: 0.9rem 1.1rem;
        box-shadow: 0 22px 45px -28px rgba(34, 197, 94, 0.85);
        text-transform: none;
        letter-spacing: 0.01em;
}

button.resize:hover,
button.resize:focus-visible {
        background: var(--success-hover);
        color: #f0fdf4;
        transform: translateY(-1px);
}

.panel-actions {
        margin-top: 32px;
}

.file-details {
        display: flex;
        flex-direction: column;
        gap: 4px;
        padding: 12px 14px;
        border-radius: var(--radius-md);
        background: rgba(15, 23, 42, 0.6);
        border: 1px dashed rgba(148, 163, 184, 0.35);
        transition: var(--transition);
        color: var(--text-muted);
}

.file-details.has-file {
        border-style: solid;
        border-color: rgba(34, 197, 94, 0.65);
        background: rgba(34, 197, 94, 0.08);
        color: #bbf7d0;
}

.file-details .file-name {
        font-weight: 600;
        color: var(--text-primary);
}

.file-details.has-file .file-name {
        color: #bbf7d0;
}

.file-details .file-meta {
        font-size: 0.85rem;
        color: var(--text-muted);
}

.file-details.has-file .file-meta {
        color: rgba(134, 239, 172, 0.9);
}

.preview-card img {
        display: block;
        width: 100%;
        max-height: 320px;
        object-fit: contain;
        border-radius: var(--radius-md);
        background: rgba(15, 23, 42, 0.75);
        border: 1px dashed rgba(148, 163, 184, 0.25);
        padding: 18px;
}

.results-card {
        background: var(--surface-elevated);
        min-height: 100%;
}

.result-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
        gap: 20px;
}

.empty-state {
        background: rgba(15, 23, 42, 0.7);
        border: 1px dashed rgba(148, 163, 184, 0.35);
        border-radius: var(--radius-md);
        padding: 28px;
        text-align: left;
        display: flex;
        flex-direction: column;
        gap: 16px;
        color: var(--text-secondary);
}

.empty-state h3 {
        font-size: 1.25rem;
}

.empty-state ol {
        padding-left: 18px;
        margin: 0;
        display: flex;
        flex-direction: column;
        gap: 8px;
        color: var(--text-muted);
}

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

.empty-note {
        color: var(--text-muted);
}

.imgcontainer {
        background: rgba(15, 23, 42, 0.65);
        border: 1px solid rgba(99, 102, 241, 0.2);
        border-radius: var(--radius-md);
        padding: 18px;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
        transition: var(--transition);
        box-shadow: 0 22px 55px -38px rgba(99, 102, 241, 0.75);
}

.imgcontainer a {
        display: flex;
        flex-direction: column;
        gap: 12px;
        align-items: center;
        text-decoration: none;
        color: inherit;
}

.imgcontainer canvas {
        display: block;
        width: 100%;
        height: auto;
        max-height: 220px;
        object-fit: contain;
        border-radius: var(--radius-md);
        background: rgba(2, 6, 23, 0.9);
        border: 1px dashed rgba(148, 163, 184, 0.35);
        padding: 14px;
}

.imgcontainer div {
        font-size: 0.9rem;
        color: var(--text-secondary);
        text-align: center;
}

.imgcontainer:hover,
.imgcontainer:focus-within {
        transform: translateY(-4px);
        border-color: rgba(99, 102, 241, 0.55);
        box-shadow: 0 30px 55px -35px rgba(99, 102, 241, 0.85);
}

.app-footer {
        display: flex;
        justify-content: flex-end;
}

.debug {
        font-size: 0.75rem;
        color: var(--text-muted);
        max-height: 120px;
        overflow: auto;
        padding: 8px 12px;
        border-radius: var(--radius-md);
        border: 1px solid rgba(148, 163, 184, 0.2);
        background: rgba(15, 23, 42, 0.6);
}

.hidden {
        display: none !important;
}

@media (max-width: 1100px) {
        .app-main {
                grid-template-columns: 100%;
        }

        .preview-card {
                margin-top: 32px;
        }
}

@media (max-width: 640px) {
        .app-wrapper {
                padding: 32px 18px 64px;
                gap: 24px;
        }

        .app-header {
                flex-direction: column;
                align-items: flex-start;
        }

        .repo-link {
                align-self: stretch;
                justify-content: center;
        }

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

        .panel-card,
        .preview-card,
        .results-card {
                padding: 22px;
        }
}
