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

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #0e0e18;
    color: #e8eaf0;
    line-height: 1.5;
}

:focus-visible {
    outline: 2px solid #4da3ff;
    outline-offset: 2px;
}

.app {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem 2rem;
}

.app__header {
    text-align: center;
    margin-bottom: 2rem;
}

.app__title {
    margin: 0 0 0.35rem;
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: 600;
    letter-spacing: -0.02em;
}

.app__subtitle {
    margin: 0;
    color: #9aa0b4;
    font-size: 0.95rem;
}

.model-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    margin: 1rem auto 0;
    min-height: 3.25rem;
}

.model-status[hidden] {
    display: none;
}

.model-status__text {
    margin: 0;
    font-size: 0.85rem;
    color: #9aa0b4;
}

.model-status--error .model-status__text {
    color: #f0a0a0;
}

.app__hint {
    margin: 0.5rem auto 0;
    max-width: 28rem;
    color: #6b7280;
    font-size: 0.8rem;
}

.app__main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.app__footer {
    text-align: center;
    margin-top: 2rem;
    font-size: 0.85rem;
    color: #6b7280;
}

.app__footer a {
    color: #6b9fd4;
    text-decoration: none;
}

.app__footer a:hover {
    text-decoration: underline;
}

.app__footer-sep {
    margin: 0 0.15rem;
}

.panel {
    width: 100%;
    max-width: 56rem;
    background: #1a1a28;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 1.5rem;
    display: grid;
    gap: 1.25rem;
    grid-template-columns: 1fr;
    grid-template-areas:
        "drop"
        "status"
        "result";
}

.panel__drop {
    grid-area: drop;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.panel__status {
    grid-area: status;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 2.5rem;
}

.panel__result {
    grid-area: result;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

@media (min-width: 720px) {
    .panel {
        grid-template-columns: 1fr auto 1fr;
        grid-template-areas: "drop status result";
        gap: 1.5rem;
        padding: 2rem;
        align-items: start;
    }

    .panel__status {
        min-width: 7.5rem;
        max-width: 8.5rem;
        align-self: center;
        min-height: 12rem;
    }
}

.box {
    width: 100%;
    aspect-ratio: 1 / 1;
    min-height: 0;
}

.dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 1.5rem;
    background: #12121c;
    border: 1.5px dashed rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, opacity 0.15s, filter 0.15s;
}

.dropzone:hover:not(.dropzone--locked):not(.dropzone--busy),
.dropzone:focus-visible:not(.dropzone--locked):not(.dropzone--busy) {
    border-color: rgba(77, 163, 255, 0.55);
    background: #141422;
}

.dropzone--active:not(.dropzone--locked):not(.dropzone--busy) {
    border-color: #4da3ff;
    background: #16162a;
}

.dropzone--locked,
.dropzone--busy {
    cursor: not-allowed;
    pointer-events: none;
    border-style: solid;
    border-color: rgba(255, 255, 255, 0.08);
    background: #101018;
    opacity: 0.5;
    filter: grayscale(0.4);
}

.dropzone__hint {
    margin: 0;
    color: #6b7280;
    font-size: 0.95rem;
}

.status {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-align: center;
}

.status__text {
    margin: 0;
    font-size: 0.8rem;
    color: #9aa0b4;
    max-width: 10rem;
}

.status--error .status__text {
    color: #f0a0a0;
}

.progress {
    width: 100%;
    max-width: 12rem;
    height: 0.35rem;
    background: #12121c;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    overflow: hidden;
}

.progress[hidden] {
    display: none;
}

.progress__bar {
    height: 100%;
    width: 0%;
    background: #3b82c4;
    border-radius: inherit;
    transition: width 0.2s ease;
}

.result {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

.result__frame {
    position: relative;
    background:
        repeating-conic-gradient(#2a2a38 0% 25%, #1a1a28 0% 50%)
        50% / 16px 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    overflow: hidden;
}

.result__placeholder {
    margin: 0;
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 0.9rem;
    color: #6b7280;
    padding: 0 1rem;
}

.result__placeholder[hidden] {
    display: none;
}

.result__image {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: calc(100% - 1.5rem);
    max-height: calc(100% - 1.5rem);
    width: auto;
    height: auto;
    object-fit: contain;
}

.result__image[hidden] {
    display: none;
}

.btn {
    padding: 0.65rem 1.5rem;
    border: none;
    border-radius: 8px;
    font: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
}

.btn--primary {
    background: #3b82c4;
    color: #fff;
}

.btn--primary:hover:not(:disabled) {
    background: #4da3ff;
}

.btn--primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.spinner {
    width: 2rem;
    height: 2rem;
    border: 2.5px solid rgba(255, 255, 255, 0.12);
    border-top-color: #4da3ff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.spinner--sm {
    width: 1.35rem;
    height: 1.35rem;
    border-width: 2px;
}

.spinner[hidden] {
    display: none;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
