:root {
    color-scheme: dark;

    --font:
            "SF Pro Rounded",
            ui-rounded,
            -apple-system,
            BlinkMacSystemFont,
            "Segoe UI",
            sans-serif;

    --background: #000;
    --surface: #242424;
    --surface-light: #383838;
    --line: #494949;
    --text: #fff;
    --muted: #999;
    --blue: #1938d3;
    --cyan: #14a9f2;
    --orange: #ff9d00;
    --green: #58f58c;
    --yellow: #ffe35c;
    --red: #ff5266;
    --purple: #ef4ff5;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: #111;
}

body {
    margin: 0;
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.35;
    -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
a,
input,
select,
textarea {
    -webkit-tap-highlight-color: transparent;
}

button {
    border: 0;
    color: inherit;
    cursor: pointer;
}

button:disabled {
    cursor: default;
    opacity: .45;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--cyan);
    outline-offset: 4px;
}

button:active:not(:disabled) {
    opacity: .78;
}

[hidden] {
    display: none !important;
}

.app {
    position: relative;
    max-width: 430px;
    min-height: 100dvh;
    margin: 0 auto;
    padding:
            max(18px, env(safe-area-inset-top))
            23px
            max(36px, env(safe-area-inset-bottom));

    overflow: hidden;
    background: var(--background);
}

.app.is-home::before {
    position: absolute;
    z-index: 0;
    top: 0;
    right: 0;
    left: 0;
    height: 250px;

    background:
            linear-gradient(to bottom, transparent 45%, #000 100%),
            radial-gradient(ellipse at 3% 3%, #923ea4 0, transparent 65%),
            radial-gradient(ellipse at 44% 0, #805858 0, transparent 65%),
            radial-gradient(ellipse at 88% 12%, #393492 0, transparent 65%),
            radial-gradient(ellipse at 100% 80%, #07667b 0, transparent 58%);

    content: "";
    pointer-events: none;
}

main,
.page-header {
    position: relative;
    z-index: 1;
}

.page-header {
    display: grid;
    grid-template-columns: 44px 1fr 44px;
    align-items: center;
    min-height: 44px;
    margin-bottom: 24px;
    text-align: center;
}

.page-header h1 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
}

.back-button,
.close-button {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border-radius: 50%;
    background: transparent;
    font-size: 30px;
}

.home-content {
    padding-top: 128px;
}

section + section {
    margin-top: 25px;
}

.section-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin: 0 10px 8px;
}

.section-title h2,
h2.section-heading {
    margin: 0;
    font-size: 22px;
    line-height: 1.15;
    font-weight: 700;
}

.section-heading {
    margin: 24px 10px 10px !important;
}

.card {
    padding: 16px;
    border-radius: 23px;
    background: var(--surface);
}

.card + .card {
    margin-top: 12px;
}

.card-button {
    display: block;
    width: 100%;
    text-align: left;
}

.checkups {
    padding: 10px;
}

.check-row {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 57px;
    padding: 6px 0;
    background: transparent;
    text-align: left;
}

.check-icon {
    display: grid;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    margin-right: 12px;
    place-items: center;
    border-radius: 15px;
    background: var(--blue);
}

.check-icon::after {
    width: 17px;
    height: 17px;
    border-radius: 50%;
    background: #d6dcff;
    content: "";
}

.check-copy {
    display: flex;
    flex: 1;
    min-width: 0;
    min-height: 51px;
    flex-direction: column;
    justify-content: center;
    padding: 3px 0 8px;
}

.check-row:not(:last-child) .check-copy {
    border-bottom: 1px solid var(--line);
}

.check-copy strong {
    font-size: 21px;
    font-weight: 700;
    line-height: 1.1;
}

.check-copy small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 11px;
}

.complaint-card {
    min-height: 73px;
    color: var(--muted);
}

.complaint-preview {
    display: block;
    margin-bottom: 5px;
    color: var(--text);
}

.food-card {
    padding: 18px 15px 12px;
}

.macro-row {
    display: grid;
    grid-template-columns: 44px 1fr 71px;
    align-items: center;
    gap: 7px;
    min-height: 19px;
    font-size: 10px;
}

.macro-name {
    text-align: right;
    font-weight: 700;
}

.macro-value {
    text-align: right;
    white-space: nowrap;
}

.macro-track {
    height: 9px;
    overflow: hidden;
    border-radius: 99px;
    background: var(--track, #333);
}

.macro-fill {
    width: var(--fill, 0%);
    height: 100%;
    border-radius: inherit;
    background: var(--color, #fff);
}

.food-caption {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 10px;
}

.divider {
    height: 1px;
    margin: 16px 0;
    background: var(--line);
}

.hunger-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    width: 100%;
    padding: 0;
    background: transparent;
    text-align: left;
}

.hunger-row span:first-child {
    max-width: 160px;
    font-size: 12px;
}

.time-chip {
    min-width: 62px;
    padding: 4px 9px;
    border-radius: 6px;
    background: #454545;
    color: #fff;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.quick-head {
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 11px;
    text-align: right;
}

.quick-head strong {
    color: white;
}

.quick-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.quick-button {
    min-height: 52px;
    padding: 10px;
    border-radius: 9px;
    background: #424242;
    font-size: 14px;
}

.home-footer {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-top: 26px;
}

.text-button {
    padding: 5px 0;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
}

.text-button.blue {
    color: var(--cyan);
}

.primary-button {
    width: 100%;
    min-height: 46px;
    padding: 11px 16px;
    border-radius: 14px;
    background: var(--cyan);
    color: #fff;
    font-size: 17px;
    font-weight: 600;
}

.secondary-button {
    min-height: 42px;
    padding: 10px 14px;
    border-radius: 11px;
    background: var(--surface-light);
    color: white;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin-top: 14px;
}

.button-row > * {
    flex: 1;
}

.muted,
.empty {
    color: var(--muted);
}

.empty {
    padding: 12px 0;
    font-size: 13px;
}

.small {
    font-size: 12px;
}

.stat-heading {
    color: var(--muted);
    font-size: 11px;
}

.stat-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin: 2px 0 14px;
}

.stat-value {
    font-size: 44px;
    font-weight: 700;
    line-height: 1.1;
}

.stat-note {
    max-width: 135px;
    color: var(--muted);
    font-size: 10px;
}

.chart {
    display: block;
    width: 100%;
    height: 210px;
}

.sleep-chart {
    height: 260px;
}

.chart-note {
    margin: 14px 0 0;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 11px;
}

.period {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 8px 8px 12px;
}

.period strong {
    font-size: 18px;
}

.period button {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: transparent;
    font-size: 24px;
}

.reason-list,
.rule-list {
    display: grid;
    gap: 12px;
}

.reason-choice,
.rule-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 14px;
}

input[type="checkbox"],
input[type="radio"] {
    flex: 0 0 auto;
    width: 19px;
    height: 19px;
    margin: 0;
    accent-color: var(--cyan);
}

.reason-stat {
    display: grid;
    grid-template-columns: 1fr 36px;
    gap: 7px 12px;
    margin: 12px 0;
    font-size: 12px;
}

.reason-stat .macro-track {
    grid-column: 1 / -1;
    height: 6px;
}

.list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 14px 0;
    background: transparent;
    text-align: left;
}

.list-row + .list-row {
    border-top: 1px solid var(--line);
}

.list-row:first-child {
    padding-top: 0;
}

.list-row:last-child {
    padding-bottom: 0;
}

.list-row small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 11px;
}

.chevron {
    color: var(--muted);
    font-size: 23px;
}

.week-day {
    display: grid;
    grid-template-columns: 48px 1fr;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 13px 0;
    background: transparent;
    text-align: left;
}

.week-day + .week-day {
    border-top: 1px solid var(--line);
}

.week-day > span {
    color: var(--muted);
    font-size: 12px;
}

.meal-name {
    margin-bottom: 4px;
    font-size: 16px;
}

.meal-info {
    color: var(--muted);
    font-size: 12px;
}

.meal-actions {
    display: flex;
    gap: 15px;
    margin-top: 10px;
}

.recipe-steps {
    padding-left: 21px;
}

.recipe-steps li {
    margin: 12px 0;
    padding-left: 3px;
}

.product-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    padding: 12px 0;
    font-size: 14px;
}

.product-row + .product-row {
    border-top: 1px solid var(--line);
}

.product-row small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
}

.total {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    font-size: 19px;
    font-weight: 700;
}

.history-entry {
    margin-bottom: 12px;
}

.history-entry p {
    margin: 8px 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.history-entry time {
    color: var(--muted);
    font-size: 12px;
}

.history-actions {
    display: flex;
    gap: 18px;
    margin-top: 8px;
}

.danger {
    color: #ff8791;
}

dialog {
    width: min(430px, calc(100% - 18px));
    max-height: calc(100dvh - 32px);
    margin: auto;
    padding: 18px;
    overflow-y: auto;
    border: 1px solid #333;
    border-radius: 24px;
    background: #0c0c0e;
    color: white;
}

dialog::backdrop {
    background: rgb(0 0 0 / 76%);
}

body:has(dialog[open]) {
    overflow: hidden;
}

.sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 15px;
}

.sheet-header h2 {
    margin: 0;
    font-size: 18px;
}

.sheet-footer {
    margin-top: 18px;
}

.field {
    display: grid;
    gap: 7px;
    margin: 15px 0;
    color: #ddd;
    font-size: 13px;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    min-width: 0;
    min-height: 46px;
    padding: 10px 12px;
    border: 1px solid #4a4a4a;
    border-radius: 10px;
    background: #242424;
    color: #fff;
}

.field textarea {
    min-height: 88px;
    resize: vertical;
}

.field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

fieldset {
    min-width: 0;
    margin: 16px 0;
    padding: 0;
    border: 0;
}

legend {
    margin-bottom: 12px;
    font-weight: 600;
}

.rating-list {
    display: grid;
    gap: 8px;
}

.rating-option {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 50px;
    padding: 12px;
    border-radius: 12px;
    background: var(--surface);
    cursor: pointer;
}

.rating-option:has(input:checked) {
    background: #153f69;
}

.error {
    margin: 12px 0 0;
    color: #ff8791;
    font-size: 13px;
}

.error:empty {
    display: none;
}

.toast {
    position: fixed;
    z-index: 10;
    right: 16px;
    bottom: max(20px, env(safe-area-inset-bottom));
    left: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    max-width: 398px;
    margin: auto;
    padding: 15px 18px;
    border: 1px solid #515151;
    border-radius: 15px;
    background: #303030;
    box-shadow: 0 8px 30px #0008;
    font-size: 13px;
}

.toast button {
    padding: 5px;
    background: transparent;
    color: #64c9ff;
}

@media (min-width: 600px) {
    body {
        padding: 24px 0;
    }

    .app {
        min-height: calc(100dvh - 48px);
        border-radius: 30px;
    }
}

@media (max-width: 350px) {
    .app {
        padding-right: 15px;
        padding-left: 15px;
    }

    .check-copy strong {
        font-size: 19px;
    }

    .macro-row {
        grid-template-columns: 37px 1fr 65px;
        gap: 5px;
    }
}

/* Место под фиксированную нижнюю панель */
.app {
    padding-bottom: calc(135px + env(safe-area-inset-bottom));
}

.bottom-nav {
    position: fixed;
    z-index: 5;
    right: 0;
    bottom: 0;
    left: 0;

    display: grid;
    grid-template-columns: 1fr 1fr 1.35fr 1fr 1fr;
    align-items: center;

    width: min(430px, 100%);
    min-height: 88px;
    margin: 0 auto;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));

    border-top: 1px solid #777;
    background: #292929;
}

.bottom-nav > button:not(.photo-button) {
    display: flex;
    min-height: 58px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 0;
    background: transparent;
}

.nav-square {
    width: 28px;
    height: 28px;
    background: #bdbdbd;
}

.bottom-nav small {
    color: #bdbdbd;
    font-size: 9px;
}

.bottom-nav .photo-button {
    position: relative;
    top: -18px;

    width: 88px;
    height: 88px;
    justify-self: center;

    border: 9px solid #fff;
    border-radius: 50%;
    background: #707070;
    box-shadow: inset 0 3px 12px #0006;
}

.toast {
    z-index: 15;
    bottom: calc(110px + env(safe-area-inset-bottom));
}

.title-link {
    padding: 0;
    background: transparent;
    color: inherit;
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
    text-align: left;
}

.complaint-card {
    display: block;
    width: 100%;
    min-height: 73px;
}

/* Быстрый выбор времени */
.time-picker {
    margin: 18px 0;
}

.time-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.time-option {
    cursor: pointer;
}

.time-option input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.time-option span {
    display: block;
    min-width: 65px;
    padding: 10px 13px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: #303030;
    text-align: center;
    font-size: 15px;
}

.time-option input:checked + span {
    border-color: var(--cyan);
    background: #133f62;
}

.time-option input:focus-visible + span {
    outline: 2px solid var(--cyan);
    outline-offset: 3px;
}

.exact-time {
    display: none;
}

.time-picker:has(
  .time-options input[value="custom"]:checked
) .exact-time {
    display: grid;
}

.sleep-date-details {
    margin: 18px 0;
    color: var(--muted);
    font-size: 13px;
}

.sleep-date-details summary {
    padding: 8px 0;
    cursor: pointer;
}

.nutrient-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 15px;
    padding: 10px 0;
    font-size: 13px;
}

.nutrient-row + .nutrient-row {
    border-top: 1px solid #383838;
}

.nutrient-row small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 10px;
}

.nutrient-row strong {
    flex-shrink: 0;
    font-weight: 600;
}

.photo-preview {
    display: flex;
    gap: 9px;
    overflow-x: auto;
    margin-bottom: 16px;
}

.photo-preview img {
    flex: 0 0 auto;
    width: 125px;
    height: 155px;
    border-radius: 12px;
    object-fit: cover;
}

.history-photos {
    margin-top: 12px;
}

.history-photos img {
    width: 95px;
    height: 110px;
}

@media (min-width: 600px) {
    .bottom-nav {
        bottom: 24px;
        border-radius: 0 0 30px 30px;
    }

    .toast {
        bottom: 140px;
    }
}

html,
body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    overscroll-behavior-x: none;
}

.app {
    width: 100%;
    min-width: 0;
}

main,
.card {
    min-width: 0;
}

canvas,
img {
    max-width: 100%;
}

/*html,*/
/*body {*/
/*    overscroll-behavior-y: none;*/
/*}*/

html {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: none;
}

body {
    height: auto;
    min-height: 100dvh;
    margin: 0;
    overflow: visible;
}

.app {
    width: 100%;
    height: auto;
    min-height: 100dvh;
    min-width: 0;
    overflow: clip;
}
/* Account entry: the existing tracking screens keep their layout. */
[hidden] { display: none !important; }
body[data-auth="locked"] > .app,
body[data-auth="locked"] > .bottom-nav,
body[data-auth="locked"] > .account-bar { display: none; }
.auth-screen { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: radial-gradient(ellipse at 10% 0%, #784080 0%, transparent 45%), radial-gradient(ellipse at 95% 0%, #173c70 0%, transparent 45%), #000; }
.auth-card { width: 100%; max-width: 360px; padding: 30px 22px; border-radius: 28px; background: #242424; }
.auth-card h1 { font-size: 32px; margin: 15px 0; }
.auth-card p { color: #bbb; line-height: 1.6; margin-bottom: 24px; overflow-wrap: anywhere; }
.auth-mark { color: #cbd7ff; background: #1938d3; padding: 12px 17px; border-radius: 17px; font-size: 28px; }
#google-signin { display: flex; justify-content: center; min-height: 4px; }
#auth-retry { margin-top: 18px; }
.account-bar { max-width: 430px; margin: 0 auto; padding: 12px 23px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: #181818; font-size: 12px; }
.account-bar > div { flex: 1; min-width: 0; }
.account-bar strong, .account-bar small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-bar small { color: #aaa; }
.account-bar button { background: #333; border-radius: 12px; min-height: 44px; padding: 8px 14px; }
#account-error:empty { display: none; }
#account-error { flex-basis: 100%; color: #ff9999; }
