:root {
    --bg: #000000;
    --surface: #141414;
    --surface-2: #2a2a2a;
    --surface-3: #4d4d4d;
    --text: #ffffff;
    --text-muted: #9a9a9a;
    --green: #a4d037;
    --green-bright: #b8e04a;
    --green-dim: #8ab82e;
    --green-glow: rgba(164, 208, 55, 0.2);
    --danger: #ff6b6b;
    --radius: 12px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --font: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100dvh;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

.hidden {
    display: none !important;
}

.app {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: 1rem 1rem calc(1rem + var(--safe-bottom));
}

.header {
    text-align: center;
    padding: 0.75rem 0 1.5rem;
    position: relative;
}

.header::before {
    content: '';
    position: absolute;
    inset: -1rem -1rem auto;
    height: 120px;
    background:
        linear-gradient(115deg, transparent 42%, var(--surface-3) 42%, var(--surface-3) 52%, transparent 52%),
        linear-gradient(115deg, transparent 58%, var(--surface-3) 58%, var(--surface-3) 68%, transparent 68%);
    opacity: 0.35;
    pointer-events: none;
}

.header__logo {
    display: block;
    width: min(280px, 85%);
    height: auto;
    margin: 0 auto 1rem;
    position: relative;
}

.header__title {
    margin: 0;
    font-size: 1.375rem;
    font-weight: 800;
    font-style: italic;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--green);
    position: relative;
}

.header__subtitle {
    margin: 0.625rem 0 0;
    font-size: 0.9375rem;
    color: var(--text-muted);
    position: relative;
}

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.capture__zone {
    display: block;
    position: relative;
    border: 2px dashed var(--surface-3);
    border-radius: var(--radius);
    background: var(--surface);
    min-height: 220px;
    cursor: pointer;
    overflow: hidden;
    transition: border-color 0.2s, background 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.capture__zone:active {
    border-color: var(--green);
    background: #1a1a1a;
}

.capture__placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 220px;
    padding: 1.5rem;
    text-align: center;
    gap: 0.35rem;
}

.capture__camera-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    margin-bottom: 0.25rem;
    border-radius: 50%;
    background: var(--green-glow);
    color: var(--green);
    font-size: 1.5rem;
}

.capture__label {
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--text);
}

.capture__hint {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.capture__preview {
    display: block;
    width: 100%;
    max-height: 320px;
    object-fit: cover;
}

.divider {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    color: var(--text-muted);
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--surface-2);
}

.manual {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.manual__label {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--green);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.manual__input {
    width: 100%;
    min-height: 52px;
    padding: 0.875rem 1rem;
    border: 1px solid var(--surface-3);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
    -webkit-tap-highlight-color: transparent;
}

.manual__input::placeholder {
    color: var(--text-muted);
}

.manual__input:focus {
    outline: none;
    border-color: var(--green);
    box-shadow: 0 0 0 3px var(--green-glow);
}

.manual__hint {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.actions {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 52px;
    padding: 0.875rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 800;
    font-style: italic;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s, background 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.btn:active:not(:disabled) {
    transform: scale(0.98);
}

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

.btn--primary {
    background: var(--green);
    color: #000000;
}

.btn--primary:not(:disabled):hover {
    background: var(--green-bright);
}

.btn--ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--surface-3);
    font-style: normal;
    text-transform: none;
    font-weight: 600;
    letter-spacing: normal;
}

.loader {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.94);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    padding: 1.5rem;
    padding-bottom: calc(1.5rem + var(--safe-bottom));
}

.loader__content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.75rem;
    text-align: center;
    max-width: 320px;
}

.loader__spinner {
    width: 88px;
    height: 88px;
    border: 6px solid var(--surface-2);
    border-top-color: var(--green);
    border-right-color: var(--green-bright);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
    box-shadow: 0 0 40px var(--green-glow);
}

.loader__text {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 700;
    font-style: italic;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--green);
}

body.is-loading {
    overflow: hidden;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--surface-2);
    border-top-color: var(--green);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

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

.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.125rem 1.25rem;
    border: 1px solid var(--surface-2);
}

.card--accent {
    border: 1px solid rgba(164, 208, 55, 0.35);
    background: linear-gradient(180deg, #1a1f0f 0%, var(--surface) 100%);
}

.card__title {
    margin: 0 0 0.875rem;
    font-size: 0.8125rem;
    font-weight: 800;
    font-style: italic;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--green);
}

.spec-list {
    margin: 0;
    display: grid;
    gap: 0.625rem;
}

.spec-list div {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
}

.spec-list dt {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.spec-list dd {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 600;
    text-align: right;
}

.spec-list--highlight dd {
    font-size: 1.0625rem;
}

.spec-list--highlight .spec-list__grams dd {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--green);
}

.engines__hint {
    margin: -0.25rem 0 0.875rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.engines {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.engine-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
    width: 100%;
    min-height: 52px;
    padding: 0.75rem 1rem;
    border: 1px solid var(--surface-3);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.engine-btn:active:not(:disabled) {
    transform: scale(0.99);
}

.engine-btn:disabled {
    opacity: 0.6;
    cursor: wait;
}

.engine-btn.is-selected {
    border-color: var(--green);
    background: rgba(164, 208, 55, 0.1);
    box-shadow: inset 0 0 0 1px rgba(164, 208, 55, 0.25);
}

.engine-btn__meta {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
}

.ac-engine {
    margin: -0.25rem 0 0.875rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--green);
}

.notes {
    margin: 1rem 0 0;
    padding-left: 1.125rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.notes li + li {
    margin-top: 0.35rem;
}

.notes li::marker {
    color: var(--green);
}

.disclaimer {
    margin: 1rem 0 0;
    padding-top: 0.875rem;
    border-top: 1px solid var(--surface-2);
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-style: italic;
}

.error {
    padding: 1rem 1.125rem;
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid rgba(255, 107, 107, 0.35);
    border-radius: var(--radius);
}

.error__text {
    margin: 0 0 0.75rem;
    font-size: 0.9375rem;
    color: var(--danger);
}

.results {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.footer {
    margin-top: 1.5rem;
    text-align: center;
    padding-top: 1rem;
    border-top: 1px solid var(--surface-2);
}

.footer p {
    margin: 0;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.footer__brand {
    margin-top: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 800;
    font-style: italic;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--green);
}

@media (min-width: 480px) {
    .app {
        padding-top: 2rem;
    }

    .header__title {
        font-size: 1.5rem;
    }
}
