@font-face {
    font-family: "JetBrains Mono";
    src: url("https://css.sbdm.lol/static/JetBrainsMono-VariableFont_wght.ttf")
        format("truetype-variations");
    font-weight: 100 800;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg: #0e0b16;
    --bg-elevated: #171225;
    --border: #2a2338;
    --text: #ece9f2;
    --text-dim: #948da3;
    --accent: #9b5de5;
    --accent-2: #e0499b;
    --accent-dim: #3a2650;
    --accent-grad: linear-gradient(135deg, var(--accent), var(--accent-2));
    --ok: #3ecf6a;
    --radius: 14px;
    --header-h: 60px;
    --footer-h: 48px;
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
}

body {
    font-family: "JetBrains Mono", monospace;
    background: var(--bg);
    color: var(--text);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    font-size: 14px;
}

header {
    height: var(--header-h);
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 clamp(1rem, 3vw, 2rem);
    border-bottom: 1px solid var(--border);
    background: var(--bg-elevated);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    font-size: 1rem;
}

.brand .dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--accent-grad);
    flex: 0 0 auto;
}

.brand .brand-name {
    background: var(--accent-grad);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.brand small {
    color: var(--text-dim);
    font-weight: 400;
    font-size: 0.75rem;
}

main {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.stage {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    position: relative;
}

.dropzone-wrap {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(1rem, 4vw, 3rem);
}

.dropzone {
    width: min(560px, 100%);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    background: var(--bg-elevated);
    padding: clamp(1.5rem, 5vw, 3rem);
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone:hover,
.dropzone.dragover {
    border-color: var(--accent-2);
    background: #1c1530;
}

.dropzone .icon {
    font-size: 2.2rem;
    margin-bottom: 0.75rem;
    opacity: 0.8;
}

.dropzone h1 {
    font-size: 1.05rem;
    margin: 0 0 0.4rem;
    font-weight: 600;
}

.dropzone p {
    margin: 0;
    color: var(--text-dim);
    font-size: 0.82rem;
    line-height: 1.5;
}

.dropzone .hint {
    margin-top: 1rem;
    font-size: 0.72rem;
    color: var(--text-dim);
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
}

#fileInput {
    display: none;
}

.error-box {
    width: min(560px, 100%);
    margin-top: 1rem;
    border: 1px solid #7a2e4a;
    background: #200f1a;
    color: #ff9ac4;
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
    display: none;
    line-height: 1.5;
    word-break: break-word;
}

.error-box.show {
    display: block;
}

.progress-wrap {
    flex: 1 1 auto;
    display: none;
    align-items: center;
    justify-content: center;
    padding: clamp(1rem, 4vw, 3rem);
}

.progress-wrap.show {
    display: flex;
}

.progress-card {
    width: min(480px, 100%);
    text-align: center;
}

.progress-label {
    font-size: 0.82rem;
    color: var(--text-dim);
    margin-bottom: 0.75rem;
}

.progress-track {
    width: 100%;
    height: 10px;
    border-radius: 6px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent-grad);
    transition: width 0.12s ease;
}

.progress-percent {
    margin-top: 0.6rem;
    font-size: 1.3rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.progress-stage {
    margin-top: 0.3rem;
    font-size: 0.72rem;
    color: var(--text-dim);
}

.viewer-wrap {
    flex: 1 1 auto;
    display: none;
    flex-direction: column;
    min-height: 0;
}

.viewer-wrap.show {
    display: flex;
}

.viewer-toolbar {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem 1rem;
    padding: 0.6rem clamp(0.75rem, 2vw, 1.5rem);
    border-bottom: 1px solid var(--border);
    background: var(--bg-elevated);
    font-size: 0.78rem;
    color: var(--text-dim);
}

.viewer-toolbar strong {
    color: var(--text);
}

.viewer-toolbar .spacer {
    flex: 1 1 auto;
}

.btn {
    font-family: inherit;
    font-size: 0.78rem;
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.45rem 0.9rem;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.btn:hover {
    border-color: var(--accent-2);
    color: #fff;
}

.btn.primary {
    border-color: transparent;
    color: #fff;
    background: var(--accent-grad);
}

.btn.primary:hover {
    filter: brightness(1.08);
}

#viewerCanvas {
    flex: 1 1 auto;
    min-height: 0;
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

footer {
    flex: 0 0 auto;
    height: auto;
    min-height: var(--footer-h);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--bg-elevated);
    font-size: 0.75rem;
    color: var(--text-dim);
    text-align: center;
    flex-wrap: wrap;
}

footer a {
    color: var(--accent-2);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

@media (max-width: 640px) {
    body {
        font-size: 13px;
    }

    .viewer-toolbar {
        font-size: 0.72rem;
    }
}

@media (min-width: 1600px) {
    .dropzone {
        width: min(640px, 100%);
    }
}
