:root {
    color-scheme: light;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #102a43;
    background: #f4f7fa;
}

* { box-sizing: border-box; }

html, body {
    width: 100%;
    min-height: 100%;
    margin: 0;
    overscroll-behavior: none;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    background: #f4f7fa;
}

.topbar {
    min-height: 3.5rem;
    padding: max(.65rem, env(safe-area-inset-top)) 1rem .65rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    color: #fff;
    background: #102a43;
}

.brand, .menu-link {
    color: inherit;
    text-decoration: none;
}

.brand { font-size: 1.05rem; font-weight: 800; letter-spacing: .08em; }
.menu-link { padding: .55rem .1rem; font-size: .95rem; text-decoration: underline; text-underline-offset: .2em; }

.app {
    position: relative;
    height: calc(100vh - 3.5rem);
    height: calc(100dvh - 3.5rem);
    min-height: 20rem;
    padding: 1rem max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
}

.state-view { width: min(100%, 42rem); height: 100%; margin: 0 auto; }
.state-view[hidden] { display: none !important; }

.message-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.status-title, .ready-title { margin: 0; font-size: clamp(1.5rem, 8vw, 2.4rem); line-height: 1.15; }
.scan-icon { margin: 0 0 1rem; font-size: 4.5rem; line-height: 1; color: #2878b5; }
.secondary-link { margin-top: 1.5rem; color: #0b63a5; font-size: 1.1rem; font-weight: 700; }
.error-message { color: #8b1e1e; }

.result-view {
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.result-card {
    min-height: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: .75rem;
    border: 3px solid #1d7a46;
    border-radius: 1rem;
    background: #fff;
    box-shadow: 0 .25rem 1rem rgb(16 42 67 / 10%);
}

.result-card.aside {
    color: #821b1b;
    border-color: #b42318;
    background: #fff5f3;
}

.position {
    width: 100%;
    margin: 0;
    color: #155d36;
    font-size: 5rem;
    font-weight: 900;
    line-height: 1;
    letter-spacing: -.035em;
    text-align: center;
    white-space: nowrap;
}

.aside .position {
    color: #a11c15;
    letter-spacing: -.045em;
}

.product-name {
    width: 100%;
    max-height: 38%;
    min-height: 0;
    margin: 1.1rem 0 0;
    overflow-y: auto;
    font-size: clamp(1.15rem, 5vw, 1.75rem);
    font-weight: 650;
    line-height: 1.25;
    text-align: center;
    overflow-wrap: anywhere;
}

.product-name:empty { display: none; }

.ok-button {
    flex: 0 0 auto;
    width: 100%;
    min-height: clamp(5rem, 18vh, 7rem);
    border: 0;
    border-radius: 1rem;
    color: #fff;
    background: #1261a0;
    font: inherit;
    font-size: clamp(2.25rem, 11vw, 4rem);
    font-weight: 900;
    box-shadow: 0 .3rem 0 #0b426e;
    touch-action: manipulation;
}

.ok-button:active { transform: translateY(.2rem); box-shadow: 0 .1rem 0 #0b426e; }

.scanner-input {
    position: fixed;
    left: -10000px;
    top: 0;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

@media (max-height: 480px) {
    .app { padding-top: .6rem; padding-bottom: .6rem; }
    .result-view { gap: .6rem; }
    .product-name { margin-top: .55rem; max-height: 30%; }
    .ok-button { min-height: 4rem; }
}

