:root {
    --bg: #121214;
    --panel: #1e1e24;
    --field: #2a2a32;
    --line: #3a3a45;
    --text: #f0f0f5;
    --muted: #a0a0b0;
    --accent: #83aa8f;
    --accent-soft: rgba(131, 170, 143, .1);
    --ok: #8abf98;
    --warn: #e3bd72;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    box-sizing: border-box;
    padding-top: env(safe-area-inset-top, 0);
    padding-bottom: env(safe-area-inset-bottom, 0)
}

*,
*::before,
*::after {
    box-sizing: inherit
}

[hidden] {
    display: none !important;
}

html {
    scroll-padding-top: env(safe-area-inset-top, 0);
    -webkit-text-size-adjust: 100%
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 var(--font)
}

main {
    max-width: 30rem;
    margin: 0 auto;
    padding: 1rem .85rem 5rem
}

h1 {
    color: var(--accent);
    font-size: 1.55rem;
    line-height: 1.15;
    margin: .15rem 0 .25rem
}

section {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: .9rem;
    margin-bottom: .75rem
}

h2 {
    font-size: 1.05rem;
    font-weight: 500;
    margin: 0 0 .65rem;
    display: flex;
    gap: .55rem;
    align-items: baseline
}

h2 .n {
    color: var(--accent);
    font-size: .95rem
}

label {
    display: block;
    font-size: .95rem;
    font-weight: 600;
    margin: 0 0 .3rem
}

.required-mark {
    color: var(--accent);
    margin-right: .15rem
}

input {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    font: inherit;
    color: var(--text);
    background: var(--field);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: .7rem .8rem;
    min-height: 48px;
    box-sizing: border-box
}

input:focus-visible,
button:focus-visible,
.drop:focus-within {
    outline: 3px solid var(--accent);
    outline-offset: 2px
}

.row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .6rem;
    margin-bottom: .65rem
}

.row>div {
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between
}

.weight-row label[for="tare"] {
    color: var(--muted);
    font-weight: 400
}

#tare {
    background: transparent;
    border-color: rgba(160, 160, 176, .35)
}

.drop {
    display: flex;
    align-items: center;
    gap: .7rem;
    border: 2px dashed var(--accent);
    background: var(--accent-soft);
    border-radius: 12px;
    padding: .75rem;
    cursor: pointer;
    margin-bottom: .75rem
}

.drop input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none
}

.drop img {
    width: 52px;
    height: 52px;
    object-fit: cover;
    object-position: top;
    border-radius: 8px;
    display: none
}

.drop strong {
    display: block;
    font-weight: 500;
    line-height: 1.35
}

.drop span,
.status,
.check,
.help,
.how,
.net,
.hint,
.out {
    color: var(--muted)
}

.drop span,
.status,
.check,
.hint,
.out {
    font-size: .95rem
}

.status {
    min-height: 1.3em;
    margin: -.4rem 0 .9rem
}

.status.ok,
.check.ok {
    color: var(--muted)
}

.status.ok::before {
    content: '\2713\0020';
    color: var(--ok);
    font-weight: 700
}

.check.ok .check-mark {
    color: var(--ok);
    font-weight: 700
}

.status.warn,
.check.warn {
    color: var(--warn)
}

.bar {
    height: 4px;
    background: var(--line);
    border-radius: 4px;
    overflow: hidden;
    margin-top: .35rem
}

.bar i {
    display: block;
    height: 100%;
    width: 0;
    background: var(--accent)
}

.check {
    margin: .2rem 0 0;
    min-height: 1.3em
}

.help {
    font-size: .9rem;
    margin: .25rem 0 .65rem
}

.how {
    margin: 0 0 .85rem;
    padding-left: 1.25rem;
    font-size: .95rem
}

.how li {
    margin: .1rem 0
}

.how-tools .how {
    color: var(--text);
    font-size: 1rem;
    line-height: 1.55;
    margin: .1rem 0 0;
    padding-left: 1.4rem
}

.how-tools .how li+li {
    margin-top: .55rem
}

.net {
    font-size: .9rem;
    margin: -.2rem 0 .65rem
}

.scale {
    background: var(--panel);
    border-radius: 16px;
    padding: .9rem
}

.lcd {
    background: var(--field);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: .35rem .65rem
}

.nutrition-item {
    all: unset;
    box-sizing: border-box;
    display: grid;
    grid-template-columns: 1.6rem 1fr auto;
    align-items: center;
    gap: .45rem;
    width: 100%;
    min-height: 48px;
    padding: .3rem .15rem;
    border-bottom: 1px solid var(--line);
    cursor: pointer
}

.nutrition-item:last-child {
    border-bottom: 0
}

.nutrition-item:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
    border-radius: 6px
}

.nutrition-item:first-child .nutrition-number,
.nutrition-item:first-child .nutrition-value {
    color: var(--accent)
}

.nutrition-number {
    font: 700 .85rem var(--font);
    color: var(--muted)
}

.nutrition-value {
    font: 700 1.15rem/1.2 var(--font);
    font-variant-numeric: tabular-nums
}

.value-caption {
    padding: .3rem .15rem .35rem;
    color: var(--muted);
    font-size: .9rem;
    font-weight: 600
}

.portion-tools {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--panel);
    margin: .25rem 0 .75rem
}

.portion-tools summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .75rem;
    min-height: 48px;
    padding: .75rem .9rem;
    color: var(--text);
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    list-style: none
}

.portion-tools summary::-webkit-details-marker {
    display: none
}

.portion-tools summary::after {
    content: '+';
    font-size: 1.2rem;
    color: var(--muted)
}

.portion-tools[open] summary::after {
    content: '\2212'
}

.portion-tools summary:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 12px
}

.portion-tag {
    font-size: .85rem;
    font-weight: 400;
    color: var(--muted)
}

.portion-content {
    padding: 0 .9rem .9rem
}

.btns {
    display: flex;
    gap: .6rem;
    flex-wrap: wrap
}

.btn {
    font: inherit;
    font-weight: 700;
    border: 0;
    border-radius: 10px;
    padding: .75rem 1rem;
    min-height: 48px;
    cursor: pointer;
    flex: 1 1 9rem
}

.btn.primary,
.step-jump {
    background: var(--accent);
    color: var(--bg)
}

.btn.ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--line)
}

.out {
    margin-top: .2rem
}

.out b {
    color: var(--text)
}

.step-jump {
    position: fixed;
    right: max(1rem, env(safe-area-inset-right));
    bottom: calc(1rem + env(safe-area-inset-bottom));
    z-index: 5;
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    min-height: 48px;
    padding: .65rem .9rem;
    border: 1px solid var(--accent);
    border-radius: 999px;
    font: inherit;
    font-weight: 600;
    box-shadow: 0 3px 12px rgba(0, 0, 0, .22);
    cursor: pointer
}

.step-jump:focus-visible {
    outline: 3px solid var(--text);
    outline-offset: 3px
}

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(1.2rem + env(safe-area-inset-bottom, 0));
    transform: translateX(-50%) translateY(10px);
    opacity: 0;
    pointer-events: none;
    background: var(--text);
    color: var(--bg);
    padding: .6rem 1rem;
    border-radius: 999px;
    font-size: .95rem;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .35);
    transition: opacity .2s ease, transform .2s ease;
    z-index: 100;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

@media (max-width:22rem) {
    main {
        padding-left: .65rem;
        padding-right: .65rem
    }

    section,
    .scale {
        padding: .75rem
    }

    .nutrition-value {
        font-size: 1.08rem
    }
}

@media (prefers-reduced-motion:reduce) {
    * {
        transition: none !important
    }
}