:root {
    color-scheme: light;
    --background: #f3f5f8;
    --surface: #ffffff;
    --text: #172033;
    --muted: #697589;
    --line: #dfe4eb;
    --primary: #1f63e9;
    --primary-dark: #194fac;
    --success: #13784a;
    --success-bg: #ebf8f1;
    --warning: #965b00;
    --warning-bg: #fff7e6;
    --danger: #b52f3a;
    --danger-bg: #fff0f1;
    font-family: Tahoma, Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--text);
    background: var(--background);
    line-height: 1.75;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

.hardbox-app {
    width: min(1060px, calc(100% - 32px));
    margin: 0 auto;
    padding: 52px 0 72px;
}

.page-header {
    max-width: 760px;
    margin-bottom: 30px;
}

.page-header h1 {
    margin: 2px 0 7px;
    font-size: clamp(1.85rem, 4vw, 2.65rem);
    line-height: 1.35;
}

.page-header p,
.section-heading p {
    margin: 0;
    color: var(--muted);
}

.eyebrow {
    color: var(--primary) !important;
    font-size: 0.82rem;
    font-weight: 700;
    direction: ltr;
    text-align: right;
}

.panel {
    margin-top: 22px;
    padding: clamp(20px, 4vw, 34px);
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: 0 12px 34px rgba(23, 32, 51, 0.055);
}

.section-heading {
    display: flex;
    align-items: flex-start;
    gap: 13px;
    margin-bottom: 25px;
}

.section-heading h2 {
    margin: 0 0 2px;
    font-size: 1.24rem;
}

.step-number {
    display: grid;
    flex: 0 0 34px;
    height: 34px;
    place-items: center;
    border-radius: 10px;
    color: #ffffff;
    background: var(--primary);
    font-weight: 700;
}

.dimensions-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.field {
    display: grid;
    gap: 7px;
    color: #3f495b;
    font-size: 0.92rem;
    font-weight: 600;
}

.number-field {
    display: flex;
    align-items: center;
    min-width: 0;
    border: 1px solid #cbd2dd;
    border-radius: 11px;
    overflow: hidden;
    transition: border-color 160ms, box-shadow 160ms;
}

.number-field:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(31, 99, 233, 0.12);
}

.number-field input {
    width: 100%;
    min-width: 0;
    padding: 11px 12px;
    border: 0;
    outline: 0;
    color: var(--text);
    background: transparent;
    direction: ltr;
    text-align: right;
}

.number-field small {
    padding: 0 11px;
    border-right: 1px solid var(--line);
    color: var(--muted);
    direction: ltr;
    font-weight: 400;
}

.template-summary {
    min-height: 47px;
    margin: 18px 0;
    padding: 10px 13px;
    border-radius: 10px;
    color: #465269;
    background: #f5f7fa;
    font-size: 0.9rem;
}

.button {
    min-height: 44px;
    padding: 9px 18px;
    border: 1px solid transparent;
    border-radius: 10px;
    font-weight: 700;
    transition: background 160ms, border-color 160ms, opacity 160ms, transform 160ms;
}

.button:not(:disabled):active {
    transform: translateY(1px);
}

.button--primary {
    color: #ffffff;
    background: var(--primary);
}

.button--primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.upload-box {
    display: grid;
    min-height: 188px;
    place-items: center;
    align-content: center;
    gap: 4px;
    padding: 24px;
    border: 1.5px dashed #acb7c7;
    border-radius: 14px;
    text-align: center;
    background: #fafbfc;
    cursor: pointer;
    transition: border-color 160ms, background 160ms;
}

.upload-box:hover,
.upload-box:focus-within {
    border-color: var(--primary);
    background: #f5f8ff;
}

.upload-box small {
    color: var(--muted);
}

.upload-box input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.upload-icon {
    display: grid;
    width: 42px;
    height: 42px;
    margin-bottom: 6px;
    place-items: center;
    border-radius: 12px;
    color: var(--primary);
    background: #eaf0ff;
    font-size: 1.5rem;
    font-weight: 700;
}

.notice {
    margin-top: 14px;
    padding: 10px 13px;
    border: 1px solid var(--line);
    border-radius: 10px;
    color: #3f4b5f;
    background: #f6f8fa;
    font-size: 0.9rem;
}

.notice--success {
    border-color: #bfe5d2;
    color: var(--success);
    background: var(--success-bg);
}

.notice--warning {
    border-color: #f0d7a5;
    color: var(--warning);
    background: var(--warning-bg);
}

.notice--error {
    border-color: #efc4c7;
    color: var(--danger);
    background: var(--danger-bg);
}

.viewer-shell {
    position: relative;
    width: 100%;
    height: clamp(420px, 61vw, 650px);
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #f2f4f7;
    overflow: hidden;
    touch-action: none;
}

.viewer-shell canvas {
    display: block;
    width: 100%;
    height: 100%;
    outline: 0;
    cursor: grab;
}

.viewer-shell canvas:active {
    cursor: grabbing;
}

.viewer-badge {
    position: absolute;
    z-index: 3;
    top: 14px;
    left: 14px;
    padding: 5px 9px;
    border: 1px solid rgba(87, 99, 117, 0.2);
    border-radius: 8px;
    color: #5d697a;
    background: rgba(255, 255, 255, 0.76);
    backdrop-filter: blur(5px);
    direction: ltr;
    font-size: 0.73rem;
    pointer-events: none;
}

.viewer-loading,
.viewer-error {
    position: absolute;
    z-index: 4;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    color: var(--muted);
    text-align: center;
    background: #f2f4f7;
}

.viewer-loading[hidden],
.viewer-error[hidden] {
    display: none;
}

.viewer-error {
    color: var(--danger);
}

.viewer-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 16px;
}

.viewer-dimensions {
    color: var(--muted);
    font-size: 0.88rem;
}

noscript {
    display: block;
    margin-top: 20px;
    padding: 14px;
    border-radius: 10px;
    color: var(--danger);
    background: var(--danger-bg);
}

@media (max-width: 760px) {
    .hardbox-app {
        width: min(100% - 20px, 680px);
        padding: 30px 0 50px;
    }

    .dimensions-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .viewer-shell {
        height: min(112vw, 520px);
    }
}

@media (max-width: 430px) {
    .panel {
        padding: 18px;
        border-radius: 14px;
    }

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

    .button {
        width: 100%;
    }

    .viewer-actions {
        align-items: stretch;
        flex-direction: column;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
