* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --white: #ffffff;
    --black: #000000;
    --purple: #9900ff;
    --lavender: #b66dff;
    --teal: #48d4c4;
    --coral: #ff6f91;
    --pink: #ff1493;
    --font: 'Bebas Neue', 'Anton', Impact, 'Arial Black', sans-serif;
    --surface: rgba(255, 255, 255, 0.04);
    --surface-input: rgba(0, 0, 0, 0.4);
    --border: rgba(255, 255, 255, 0.12);
    --border-strong: rgba(255, 255, 255, 0.22);
    --text-muted: rgba(255, 255, 255, 0.45);
    --text-soft: rgba(255, 255, 255, 0.72);
    /* Коралл — замеры, тело, прогресс, ввод данных */
    --accent: var(--coral);
    --accent-rgb: 255, 111, 145;
    /* Лаванда — навигация, подсказки, календарь, вторичный UI */
    --guide: var(--lavender);
    --guide-rgb: 182, 109, 255;
    --optional: var(--lavender);
    --optional-rgb: 182, 109, 255;
    --glow-accent: 0 0 14px rgba(255, 111, 145, 0.38),
                   0 0 28px rgba(255, 111, 145, 0.18);
    --glow-guide: 0 0 14px rgba(182, 109, 255, 0.34),
                  0 0 28px rgba(182, 109, 255, 0.16);
    --glow-optional: var(--glow-guide);
    --focus-ring: 0 0 0 3px rgba(255, 111, 145, 0.22);
    --focus-ring-guide: 0 0 0 3px rgba(182, 109, 255, 0.2);
    --focus-ring-optional: var(--focus-ring-guide);
}

html {
    background: var(--black);
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    background:
        radial-gradient(ellipse 72% 52% at 22% 8%, rgba(var(--accent-rgb), 0.075) 0%, transparent 58%),
        radial-gradient(ellipse 58% 42% at 88% 92%, rgba(var(--guide-rgb), 0.06) 0%, transparent 60%),
        var(--black);
    font-family: var(--font);
    color: var(--white);
    -webkit-tap-highlight-color: transparent;
}

/* ── Верхняя панель ── */

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: 46px 1fr auto;
    align-items: center;
    gap: 10px;
    padding: max(12px, env(safe-area-inset-top)) clamp(12px, 4vw, 24px) 12px;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}

.topbar__icon-btn {
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: var(--surface);
    color: var(--text-soft);
    text-decoration: none;
    font: inherit;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.topbar__actions {
    display: flex;
    gap: 6px;
    justify-self: end;
}

.topbar__reset {
    font-size: 1.15rem;
}

.topbar__glyph {
    width: 1.35rem;
    height: 1.35rem;
    display: block;
}

.topbar__glyph--stroke {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.topbar__analytics:hover {
    color: var(--lavender);
    border-color: rgba(182, 109, 255, 0.45);
    background: rgba(182, 109, 255, 0.1);
}

.topbar__icon-btn:hover {
    color: var(--white);
    border-color: var(--border-strong);
    background: rgba(255, 255, 255, 0.07);
}

.topbar__icon-btn:active {
    transform: scale(0.94);
}

.topbar__info {
    text-align: center;
    min-width: 0;
}

.topbar__label {
    font-size: 0.82rem;
    letter-spacing: 0.28em;
    color: var(--text-muted);
    padding-left: 0.28em;
}

.topbar__title {
    font-size: clamp(1.3rem, 5.4vw, 1.7rem);
    letter-spacing: 0.07em;
    line-height: 1.05;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar__date {
    margin-top: 3px;
    font-size: clamp(0.95rem, 3.8vw, 1.1rem);
    letter-spacing: 0.1em;
    line-height: 1.1;
    color: var(--white);
}

.topbar__sub,
#measureProgress {
    margin-top: 2px;
    font-size: clamp(0.72rem, 3vw, 0.85rem);
    letter-spacing: 0.16em;
    color: var(--guide);
    text-shadow: 0 0 14px rgba(var(--guide-rgb), 0.45);
}

.topbar__compare {
    margin-top: 2px;
    font-size: clamp(0.82rem, 2.6vw, 0.72rem);
    letter-spacing: 0.14em;
    color: var(--text-muted);
}

/* ── Раскладка ── */

.measure {
    width: min(960px, 100%);
    margin: 0 auto;
    padding: clamp(14px, 3vw, 24px) clamp(12px, 4vw, 24px) 32px;
}

.measure-layout {
    display: flex;
    align-items: flex-start;
    gap: clamp(16px, 3vw, 28px);
}

/* ── Телосложение (слева) ── */

.figure {
    flex: 0 0 clamp(240px, 34vw, 320px);
    position: sticky;
    top: calc(86px + env(safe-area-inset-top, 0px));
}

.figure__card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 22px 18px 20px;
    border: 1px solid rgba(var(--accent-rgb), 0.18);
    border-radius: 22px;
    background:
        radial-gradient(ellipse 82% 58% at 50% 0%, rgba(var(--accent-rgb), 0.1) 0%, transparent 58%),
        radial-gradient(ellipse 72% 38% at 50% 100%, rgba(var(--guide-rgb), 0.06) 0%, transparent 52%),
        linear-gradient(180deg, #0f0a10 0%, var(--black) 72%);
    overflow: hidden;
}

.figure__aura {
    position: absolute;
    top: 40%;
    left: 50%;
    width: 130%;
    height: 70%;
    transform: translate(-50%, -50%);
    background: radial-gradient(ellipse at center, rgba(255, 111, 145, 0.12) 0%, transparent 65%);
    pointer-events: none;
}

.figure__progress {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.figure__progress-bar {
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--guide), var(--purple));
    box-shadow: 0 0 12px rgba(var(--guide-rgb), 0.5);
    transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.figure__svg {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 260px;
    height: auto;
    display: block;
    filter: drop-shadow(0 0 24px rgba(255, 111, 145, 0.12));
}

.figure__svg .body {
    stroke: rgba(var(--accent-rgb), 0.5);
}

.figure__svg.has-active .body {
    opacity: 0.55;
    transition: opacity 0.25s ease;
}

.marker-group {
    cursor: pointer;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.marker-group .marker-hit {
    fill: transparent;
    stroke: none;
    pointer-events: all;
}

.marker-group .marker-line {
    stroke: rgba(var(--guide-rgb), 0.48);
    stroke-width: 2;
    stroke-dasharray: 5 4;
    pointer-events: none;
    transition: stroke 0.2s ease, stroke-width 0.2s ease, stroke-dasharray 0.2s ease;
}

.marker-group:hover .marker-line,
.marker-group:focus-visible .marker-line {
    stroke: rgba(var(--guide-rgb), 0.92);
}

.marker-group.is-filled .marker-line {
    stroke: rgba(var(--guide-rgb), 0.92);
    stroke-dasharray: none;
}

.marker-group.is-active .marker-line {
    stroke: var(--white);
    stroke-width: 3;
    stroke-dasharray: none;
    animation: marker-pulse 1.6s ease-in-out infinite;
}

.marker-group.is-dimmed {
    opacity: 0.28;
}

.marker-group.is-dimmed .marker-value,
.marker-group.is-dimmed .marker-value-bg,
.marker-group.is-dimmed .marker-value-hit {
    opacity: 0;
}

.marker-value-hit {
    fill: transparent;
    stroke: none;
    pointer-events: all;
    cursor: pointer;
    visibility: hidden;
}

.marker-group.is-filled .marker-value-hit {
    visibility: visible;
}

.marker-value-bg {
    fill: rgba(0, 0, 0, 0.88);
    stroke: rgba(var(--accent-rgb), 0.45);
    stroke-width: 1;
    opacity: 0;
    pointer-events: all;
    cursor: pointer;
    transition: opacity 0.2s ease, stroke 0.2s ease;
}

.marker-group.is-filled .marker-value-bg,
.marker-group.is-active .marker-value-bg {
    opacity: 1;
}

.marker-group.is-active .marker-value-bg {
    stroke: rgba(var(--accent-rgb), 0.85);
    filter: drop-shadow(0 0 10px rgba(var(--accent-rgb), 0.35));
}

.marker-value {
    fill: var(--accent);
    font-family: var(--font);
    font-size: 12px;
    letter-spacing: 0.05em;
    opacity: 0;
    pointer-events: all;
    cursor: pointer;
    transition: opacity 0.2s ease, fill 0.2s ease;
    paint-order: stroke fill;
    stroke: rgba(0, 0, 0, 0.9);
    stroke-width: 3px;
    stroke-linejoin: round;
    filter: drop-shadow(0 0 8px rgba(var(--accent-rgb), 0.55));
}

.marker-group.is-filled .marker-value {
    opacity: 1;
}

.marker-group.is-active .marker-value {
    fill: var(--white);
    stroke: rgba(0, 0, 0, 0.95);
    filter: drop-shadow(0 0 8px rgba(var(--accent-rgb), 0.65)) drop-shadow(0 0 12px rgba(255, 255, 255, 0.25));
}

@keyframes marker-pulse {
    0%, 100% { filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.5)); }
    50% { filter: drop-shadow(0 0 10px rgba(var(--guide-rgb), 0.95)); }
}

.figure__status {
    position: relative;
    z-index: 1;
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.35);
    text-align: center;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.figure__status.is-active.is-circumference,
.figure__status.is-active.is-optional {
    border-color: rgba(var(--guide-rgb), 0.55);
    box-shadow: var(--glow-guide);
}

.figure__status.is-active.is-weight {
    border-color: rgba(var(--accent-rgb), 0.55);
    box-shadow: var(--glow-accent);
}

.figure__status-label {
    font-size: clamp(1.1rem, 4vw, 1.35rem);
    letter-spacing: 0.08em;
    line-height: 1.1;
    color: var(--text-soft);
}

.figure__status.is-active .figure__status-label {
    color: var(--white);
}

.figure__status-value {
    margin-top: 4px;
    font-size: clamp(1.35rem, 5vw, 1.65rem);
    letter-spacing: 0.06em;
    line-height: 1;
    color: var(--guide);
    text-shadow: 0 0 12px rgba(var(--guide-rgb), 0.4);
}

.figure__status.is-weight .figure__status-value {
    color: var(--accent);
    text-shadow: 0 0 14px rgba(var(--accent-rgb), 0.45);
}

.figure__status.is-filled .figure__status-value {
    color: var(--white);
}

.figure__status-hint {
    margin-top: 8px;
    font-size: 0.72rem;
    letter-spacing: 0.02em;
    line-height: 1.35;
    color: var(--text-muted);
    text-transform: none;
}

.figure__status.is-active .figure__status-hint {
    color: rgba(var(--guide-rgb), 0.72);
}

/* ── Заметка к дню ── */

.figure__note {
    position: relative;
    z-index: 1;
    align-self: stretch;
    width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.figure__note-label {
    font-size: 0.82rem;
    letter-spacing: 0.24em;
    padding-left: 0.24em;
    text-align: center;
    color: rgba(var(--guide-rgb), 0.72);
}

.figure__note-input {
    display: block;
    width: 100%;
    max-width: 100%;
    min-height: 38px;
    padding: 8px 10px;
    border: 1px solid rgba(var(--guide-rgb), 0.22);
    border-radius: 11px;
    background: rgba(0, 0, 0, 0.38);
    color: var(--white);
    font-family: var(--font);
    font-size: 0.78rem;
    font-weight: 400;
    letter-spacing: 0.01em;
    line-height: 1.35;
    resize: none;
    overflow: hidden;
    overflow-wrap: break-word;
    word-break: break-word;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

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

.figure__note-input:focus {
    border-color: rgba(var(--guide-rgb), 0.55);
    box-shadow: var(--focus-ring-guide);
}

/* ── Календарь под схемой ── */

.figure__calendar-wrap {
    position: relative;
    z-index: 1;
    width: 100%;
    padding: 10px 12px 12px;
    border: 1px solid rgba(var(--guide-rgb), 0.22);
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.38);
    transition: padding 0.28s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.figure__calendar-wrap.is-collapsed {
    padding-bottom: 10px;
}

.figure__calendar-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 4px 2px;
    border: none;
    background: none;
    font: inherit;
    color: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.figure__calendar-toggle-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.figure__calendar-label {
    font-size: 0.82rem;
    letter-spacing: 0.26em;
    padding-left: 0.26em;
    text-align: center;
    color: rgba(var(--guide-rgb), 0.72);
}

.figure__calendar-toggle-date {
    font-size: clamp(0.88rem, 3.2vw, 1rem);
    letter-spacing: 0.08em;
    line-height: 1;
    color: var(--accent);
    text-shadow: 0 0 10px rgba(var(--accent-rgb), 0.38);
}

.figure__calendar-chevron {
    flex: 0 0 auto;
    width: 8px;
    height: 8px;
    margin-top: 2px;
    border-right: 2px solid var(--guide);
    border-bottom: 2px solid var(--guide);
    transform: rotate(45deg);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.figure__calendar-wrap.is-collapsed .figure__calendar-chevron {
    transform: rotate(-135deg);
}

.figure__calendar-body {
    display: grid;
    grid-template-rows: 1fr;
    transition: grid-template-rows 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

.figure__calendar-wrap.is-collapsed .figure__calendar-body {
    grid-template-rows: 0fr;
}

.figure__calendar-inner {
    overflow: hidden;
}

.figure-calendar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 10px;
}

.figure-calendar__quick {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.figure-calendar__quick-btn {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 30px;
    padding: 0 8px;
    border: 1px solid rgba(var(--guide-rgb), 0.28);
    border-radius: 9px;
    background: rgba(var(--guide-rgb), 0.06);
    color: var(--text-soft);
    font: inherit;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    line-height: 1;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.figure-calendar__quick-btn:hover:not(:disabled) {
    color: var(--white);
    border-color: rgba(var(--guide-rgb), 0.5);
    background: rgba(var(--guide-rgb), 0.12);
}

.figure-calendar__quick-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.figure-calendar__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.figure-calendar__title {
    flex: 1;
    font-size: clamp(1rem, 3.6vw, 1.2rem);
    letter-spacing: 0.06em;
    text-align: center;
    line-height: 1;
}

.figure-calendar__nav {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(var(--guide-rgb), 0.28);
    border-radius: 10px;
    background: rgba(var(--guide-rgb), 0.08);
    color: var(--text-soft);
    font: inherit;
    font-size: 1.15rem;
    line-height: 1;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.figure-calendar__nav:hover {
    color: var(--white);
    border-color: rgba(var(--guide-rgb), 0.52);
    background: rgba(var(--guide-rgb), 0.16);
}

.figure-calendar__weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
}

.figure-calendar__weekday {
    text-align: center;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 2px 0;
}

.figure-calendar__days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
}

.figure-calendar__day {
    position: relative;
    aspect-ratio: 1;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: var(--text-soft);
    font: inherit;
    font-size: clamp(0.78rem, 2.2vw, 0.9rem);
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.figure-calendar__day:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.08);
    color: var(--white);
}

.figure-calendar__day--outside {
    visibility: hidden;
    pointer-events: none;
}

.figure-calendar__day--today:not(.figure-calendar__day--selected) {
    outline: 1px solid rgba(255, 255, 255, 0.45);
    outline-offset: -1px;
}

.figure-calendar__day--selected {
    background: var(--accent);
    color: var(--black);
    box-shadow: 0 0 14px rgba(var(--accent-rgb), 0.45);
}

.figure-calendar__day--has-data:not(.figure-calendar__day--selected)::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 4px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    box-shadow: 0 0 6px rgba(var(--accent-rgb), 0.7);
}

.figure-calendar__hint {
    margin-top: 2px;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    line-height: 1.3;
    text-align: center;
    color: var(--text-muted);
    text-transform: none;
}

/* ── Замеры (справа) ── */

.panel {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: clamp(16px, 3vw, 22px);
}

.panel__group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.panel__group-toggle {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 0 0.26em;
    border: none;
    background: none;
    font: inherit;
    color: inherit;
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.panel__group-toggle-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.panel__group-chevron {
    flex: 0 0 auto;
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--text-muted);
    border-bottom: 2px solid var(--text-muted);
    transform: rotate(45deg);
    transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.2s ease;
}

.panel__group.is-open .panel__group-chevron {
    transform: rotate(-135deg);
    border-color: rgba(var(--guide-rgb), 0.75);
}

.panel__group--optional.is-open .panel__group-chevron {
    border-color: var(--guide);
}

.panel__group-badge {
    flex: 0 0 auto;
    min-width: 2.8em;
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
    font-size: 0.82rem;
    letter-spacing: 0.08em;
    line-height: 1.2;
    text-align: center;
    color: var(--text-muted);
}

.panel__group-badge.is-complete {
    border-color: rgba(var(--guide-rgb), 0.45);
    color: var(--guide);
    background: rgba(var(--guide-rgb), 0.1);
}

.panel__group--optional .panel__group-badge.is-complete {
    border-color: rgba(var(--optional-rgb), 0.45);
    color: var(--optional);
    background: rgba(var(--optional-rgb), 0.1);
}

.mobile-section-nav {
    display: none;
}

.mobile-context {
    display: none;
}

.panel__group-title {
    font-size: 0.78rem;
    font-weight: 400;
    letter-spacing: 0.26em;
    padding-left: 0.26em;
    color: rgba(var(--guide-rgb), 0.62);
}

.panel__group-head {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.panel__group-note {
    margin: 0;
    padding-left: 0.26em;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    line-height: 1.35;
    color: rgba(var(--guide-rgb), 0.52);
}

.panel__group--optional .panel__group-title {
    color: rgba(var(--guide-rgb), 0.82);
}

.measure-item--optional {
    border-color: rgba(var(--optional-rgb), 0.24);
    background: rgba(var(--optional-rgb), 0.05);
}

.measure-item--circumference {
    border-color: rgba(var(--guide-rgb), 0.2);
    background: rgba(var(--guide-rgb), 0.04);
}

.measure-item--circumference.is-active,
.measure-item--optional.is-active,
.measure-item--optional.is-hint-open {
    border-color: rgba(var(--guide-rgb), 0.58);
    background: rgba(var(--guide-rgb), 0.07);
    box-shadow: var(--glow-guide);
}

.measure-item--optional.is-active,
.measure-item--optional.is-hint-open {
    border-color: rgba(var(--optional-rgb), 0.58);
    background: rgba(var(--optional-rgb), 0.09);
    box-shadow: var(--glow-optional);
}

.measure-item--optional.is-filled .measure-row__dot {
    border-color: var(--optional);
    background: var(--optional);
    box-shadow: 0 0 10px rgba(var(--optional-rgb), 0.7);
}

.measure-item--circumference.is-filled .measure-row__dot {
    border-color: var(--guide);
    background: var(--guide);
    box-shadow: 0 0 10px rgba(var(--guide-rgb), 0.7);
}

.measure-item--optional .measure-row__hint-btn {
    background: rgba(var(--optional-rgb), 0.08);
    color: var(--optional);
}

.measure-item--optional .measure-row__hint-btn:hover {
    border-color: rgba(var(--optional-rgb), 0.55);
    background: rgba(var(--optional-rgb), 0.16);
    box-shadow: 0 0 12px rgba(var(--optional-rgb), 0.25);
}

.measure-item--optional.is-active .measure-row__hint-btn,
.measure-item--optional.is-hint-open .measure-row__hint-btn {
    border-color: rgba(var(--optional-rgb), 0.6);
    background: rgba(var(--optional-rgb), 0.14);
}

.measure-item--optional.is-hint-open .measure-item__hint-inner {
    border-top-color: rgba(var(--optional-rgb), 0.2);
}

.measure-item--optional .measure-item__hint-label {
    color: var(--optional);
    text-shadow: 0 0 12px rgba(var(--optional-rgb), 0.35);
}

.panel__rows {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.measure-item {
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    overflow: hidden;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.measure-item.is-active:not(.measure-item--optional):not(.measure-item--circumference) {
    border-color: rgba(var(--accent-rgb), 0.58);
    background: rgba(var(--accent-rgb), 0.06);
    box-shadow: var(--glow-accent);
}

.measure-item.is-hint-open:not(.is-active):not(.measure-item--optional):not(.measure-item--circumference) {
    border-color: rgba(var(--guide-rgb), 0.42);
    background: rgba(var(--guide-rgb), 0.05);
    box-shadow: var(--glow-guide);
}

.measure-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
}

.measure-row__dot {
    flex: 0 0 auto;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--border-strong);
    background: transparent;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.measure-item.is-filled:not(.measure-item--circumference):not(.measure-item--optional) .measure-row__dot {
    border-color: var(--accent);
    background: var(--accent);
    box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.7);
}

.measure-row__main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.measure-row__label {
    flex: 1 1 auto;
    min-width: 0;
    font-size: clamp(1.05rem, 2.4vw, 1.25rem);
    letter-spacing: 0.06em;
    line-height: 1.1;
    color: var(--text-soft);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.measure-item.is-active .measure-row__label,
.measure-item.is-filled .measure-row__label {
    color: var(--white);
}

.measure-row__hint-btn {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(var(--guide-rgb), 0.22);
    border-radius: 9px;
    background: rgba(var(--guide-rgb), 0.07);
    color: var(--guide);
    font: inherit;
    font-size: 0.95rem;
    line-height: 1;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.measure-row__hint-btn:hover {
    color: var(--white);
    border-color: rgba(var(--guide-rgb), 0.48);
    background: rgba(var(--guide-rgb), 0.14);
    box-shadow: 0 0 10px rgba(var(--guide-rgb), 0.2);
}

.measure-row__hint-btn:active {
    transform: scale(0.94);
}

.measure-item.is-active .measure-row__hint-btn,
.measure-item.is-hint-open .measure-row__hint-btn {
    border-color: rgba(var(--guide-rgb), 0.55);
    background: rgba(var(--guide-rgb), 0.12);
    color: var(--white);
}

.measure-item__hint-wrap {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

.measure-item.is-hint-open .measure-item__hint-wrap {
    grid-template-rows: 1fr;
}

.measure-item__hint {
    overflow: hidden;
}

.measure-item__hint-inner {
    padding: 0 14px 12px 38px;
    border-top: 1px solid transparent;
    transition: border-color 0.2s ease;
}

.measure-item.is-hint-open .measure-item__hint-inner {
    border-top-color: rgba(var(--guide-rgb), 0.18);
    padding-top: 10px;
}

.measure-item__hint-label {
    display: block;
    margin-bottom: 4px;
    font-size: 0.8rem;
    letter-spacing: 0.24em;
    padding-left: 0.24em;
    color: var(--guide);
    text-shadow: 0 0 10px rgba(var(--guide-rgb), 0.28);
}

.measure-item__hint-text {
    font-size: 0.82rem;
    letter-spacing: 0.01em;
    line-height: 1.4;
    color: var(--text-soft);
    text-transform: none;
}

.measure-row__field {
    flex: 0 0 auto;
    display: flex;
    align-items: baseline;
    gap: 5px;
    width: 108px;
    padding: 6px 12px;
    border-radius: 11px;
    background: var(--surface-input);
    border: 1px solid var(--border);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.measure-row__values {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    min-width: 108px;
}

.measure-row__values .measure-row__field {
    width: 100%;
}

.measure-row__delta {
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    line-height: 1;
    color: var(--text-muted);
    white-space: nowrap;
}

.measure-row__delta--up {
    color: #86efac;
}

.measure-row__delta--down {
    color: #f87171;
}

.measure-row__delta--same {
    color: var(--text-muted);
}

.measure-row__field:focus-within {
    border-color: rgba(var(--accent-rgb), 0.7);
    box-shadow: var(--focus-ring);
}

.measure-item--circumference .measure-row__field:focus-within,
.measure-item--optional .measure-row__field:focus-within {
    border-color: rgba(var(--guide-rgb), 0.7);
    box-shadow: var(--focus-ring-guide);
}

.measure-row__input {
    width: 100%;
    min-width: 0;
    border: none;
    background: transparent;
    font-family: var(--font);
    font-size: clamp(1.25rem, 3vw, 1.5rem);
    letter-spacing: 0.04em;
    color: var(--white);
    text-align: right;
    outline: none;
    -moz-appearance: textfield;
    appearance: textfield;
}

.measure-row__input::-webkit-outer-spin-button,
.measure-row__input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.measure-row__input::placeholder {
    color: rgba(255, 255, 255, 0.25);
}

.measure-row__unit {
    flex: 0 0 auto;
    font-size: 0.82rem;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}

/* ── Адаптация под телефон ── */

@media (max-width: 760px) {
    body.has-mobile-context {
        padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px));
    }

    .measure-layout {
        flex-direction: column;
        align-items: stretch;
    }

    .figure {
        position: static;
        flex: 0 0 auto;
        align-self: center;
        width: min(300px, 78vw);
    }

    .figure__card {
        padding: 18px 16px 16px;
    }

    .figure__svg {
        max-width: 220px;
    }

    .figure__status-hint {
        font-size: 0.78rem;
    }

    .panel {
        width: 100%;
    }

    .panel__group-toggle {
        display: flex;
    }

    .panel__group:not(.is-open) .panel__rows {
        display: none;
    }

    .panel__group.is-open .panel__group-toggle {
        margin-bottom: 2px;
    }

    .panel__group--optional .panel__group-note {
        padding-left: 0;
    }

    .mobile-context {
        display: block;
        position: fixed;
        left: 12px;
        right: 12px;
        bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        z-index: 26;
        padding: 10px 14px;
        border: 1px solid rgba(var(--guide-rgb), 0.45);
        border-radius: 16px;
        background: rgba(8, 6, 12, 0.94);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        box-shadow: var(--glow-guide);
        opacity: 0;
        transform: translateY(12px);
        pointer-events: none;
        transition: opacity 0.22s ease, transform 0.22s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    }

    .mobile-context.is-visible {
        opacity: 1;
        transform: translateY(0);
    }

    .mobile-context.is-weight {
        border-color: rgba(var(--accent-rgb), 0.45);
        box-shadow: var(--glow-accent);
    }

    .mobile-context.is-optional {
        border-color: rgba(var(--optional-rgb), 0.45);
        box-shadow: var(--glow-optional);
    }

    .mobile-context__main {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 12px;
    }

    .mobile-context__label {
        font-size: 1.15rem;
        letter-spacing: 0.08em;
        line-height: 1.1;
        color: var(--white);
    }

    .mobile-context__value {
        flex: 0 0 auto;
        font-size: 1.2rem;
        letter-spacing: 0.06em;
        line-height: 1;
        color: var(--guide);
        text-shadow: 0 0 12px rgba(var(--guide-rgb), 0.45);
    }

    .mobile-context.is-weight .mobile-context__value {
        color: var(--accent);
        text-shadow: 0 0 12px rgba(var(--accent-rgb), 0.45);
    }

    .mobile-context.is-optional .mobile-context__value {
        color: var(--optional);
        text-shadow: 0 0 12px rgba(var(--optional-rgb), 0.45);
    }

    .mobile-context__hint {
        margin-top: 6px;
        font-size: 0.78rem;
        letter-spacing: 0.02em;
        line-height: 1.35;
        color: rgba(var(--guide-rgb), 0.68);
        text-transform: none;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
}

@media (max-width: 420px) {
    .measure-row {
        gap: 10px;
        padding: 9px 12px;
    }

    .measure-item__hint-inner {
        padding-left: 34px;
        padding-right: 12px;
    }

    .measure-row__field {
        width: 96px;
        padding: 5px 10px;
    }

    .measure-row__values {
        min-width: 96px;
    }

    .figure {
        width: min(260px, 84vw);
    }
}

/* ── Плавные анимации ── */

@keyframes pu-fade-up {
    from {
        opacity: 0;
        transform: translate3d(0, 10px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes pu-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes pu-aura-breathe {
    0%, 100% { opacity: 0.62; }
    50% { opacity: 1; }
}

.topbar {
    animation: pu-fade-up 0.42s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.figure {
    animation: pu-fade-up 0.46s cubic-bezier(0.22, 1, 0.36, 1) 0.07s both;
}

.figure__aura {
    animation: pu-aura-breathe 5.5s ease-in-out infinite;
}

.figure__svg {
    animation: pu-fade-in 0.55s ease 0.12s both;
}

.panel__group {
    animation: pu-fade-up 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.panel__group:nth-child(1) { animation-delay: 0.1s; }
.panel__group:nth-child(2) { animation-delay: 0.14s; }
.panel__group:nth-child(3) { animation-delay: 0.18s; }
.panel__group:nth-child(4) { animation-delay: 0.22s; }
.panel__group:nth-child(5) { animation-delay: 0.26s; }

.measure-item {
    animation: pu-fade-up 0.34s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.panel__rows .measure-item:nth-child(1) { animation-delay: 0.2s; }
.panel__rows .measure-item:nth-child(2) { animation-delay: 0.24s; }
.panel__rows .measure-item:nth-child(3) { animation-delay: 0.28s; }
.panel__rows .measure-item:nth-child(4) { animation-delay: 0.32s; }
.panel__rows .measure-item:nth-child(5) { animation-delay: 0.36s; }
.panel__rows .measure-item:nth-child(6) { animation-delay: 0.4s; }

/* ── Уведомление об ошибке сохранения ── */

.save-toast {
    position: fixed;
    left: 50%;
    bottom: max(16px, env(safe-area-inset-bottom));
    z-index: 80;
    display: flex;
    align-items: center;
    gap: 10px;
    width: min(420px, calc(100% - 24px));
    padding: 12px 12px 12px 14px;
    border: 1px solid rgba(248, 113, 113, 0.45);
    border-radius: 14px;
    background: rgba(24, 8, 12, 0.96);
    box-shadow:
        0 12px 40px rgba(0, 0, 0, 0.45),
        0 0 24px rgba(248, 113, 113, 0.12);
    transform: translate(-50%, 12px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s ease;
}

.save-toast--visible {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
}

.save-toast__text {
    flex: 1;
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 400;
    letter-spacing: 0.01em;
    line-height: 1.35;
    color: #fecaca;
}

.save-toast__close {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-soft);
    font: inherit;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
    .marker-group.is-active .marker-line {
        animation: none;
    }

    .topbar,
    .figure,
    .figure__aura,
    .figure__svg,
    .panel__group,
    .measure-item {
        animation: none;
    }

    .figure__calendar-wrap,
    .figure__calendar-body,
    .figure__calendar-chevron,
    .measure-nav__btn,
    .mobile-context,
    .panel__group-chevron {
        transition: none;
    }

    .measure-item,
    .measure-item__hint-wrap,
    .measure-row,
    .measure-row__dot,
    .measure-row__field,
    .measure-row__hint-btn,
    .topbar__icon-btn {
        transition: none;
    }

    .save-toast {
        transition: none;
    }
}
