:root {
    --bg: #dcebfa;
    --panel: #ffffff;
    --line: rgba(30, 41, 59, 0.09);
    --text: #141c2b;
    --muted: #7d8794;
    --accent: #2080ff;
    --submit: #8bbef2;
    --chip: #f3f5f8;
    --below: #bfe7c7;
    --on: #f5da92;
    --above: #f5c0be;
    --danger: #db6a6a;
    --shadow: 0 22px 44px rgba(74, 98, 124, 0.12);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body.sheet-open {
    overflow: hidden;
}

body {
    font-family: "Avenir Next", "SF Pro Display", "Helvetica Neue", sans-serif;
    color: var(--text);
    background: linear-gradient(180deg, rgba(255,255,255,0.36), rgba(255,255,255,0.12)), var(--bg);
}

body.theme-vadim {
    --bg: #dcebfa;
    --submit: #8bbef2;
}

body.theme-vlad {
    --bg: #e4f6e3;
    --submit: #94d38e;
}

body.theme-aleksei {
    --bg: #fff1c9;
    --submit: #f0c86f;
}

.screen {
    min-height: 100vh;
    padding: max(18px, env(safe-area-inset-top)) 16px max(26px, env(safe-area-inset-bottom));
}

.app-shell {
    max-width: 430px;
    margin: 0 auto;
}

.app-header,
.panel,
.rest-panel,
.error-banner,
.success-banner {
    background: var(--panel);
    border: 1px solid rgba(255,255,255,0.75);
    border-radius: 28px;
    box-shadow: var(--shadow);
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    margin-bottom: 18px;
}

.app-title {
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.header-person-form {
    flex: 1;
    min-width: 0;
    margin: 0 10px;
}

.header-person-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.app-title-select {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.app-title-select select {
    border: none;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-weight: 700;
    text-align: center;
    appearance: none;
    -webkit-appearance: none;
    padding: 0;
    max-width: 170px;
}

.header-actions,
.icon-form {
    display: flex;
    align-items: center;
    gap: 10px;
}

.icon-btn {
    width: 54px;
    height: 54px;
    border: none;
    border-radius: 18px;
    background: #eef0f4;
    font-size: 1.55rem;
    color: #fff;
}

.icon-btn.muted {
    color: rgba(255,255,255,0.92);
}

.icon-btn.close {
    color: var(--danger);
}

.icon-btn:disabled {
    opacity: 0.55;
}

.panel,
.rest-panel {
    padding: 14px 14px 16px;
}

.panel-meta {
    margin-bottom: 18px;
    padding: 18px 16px;
}

.compact-form + .compact-form {
    margin-top: 14px;
}

.form-label {
    display: block;
    margin: 0 0 12px;
    font-size: 0.98rem;
    font-weight: 700;
}

.control-pill {
    border: 1px solid #e9edf3;
    border-radius: 22px;
    background: #fff;
    min-height: 68px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.control-pill input,
.control-pill select {
    width: 100%;
    border: none;
    background: transparent;
    text-align: center;
    font-size: 1.15rem;
    color: #353d49;
    padding: 18px 20px;
    appearance: none;
    -webkit-appearance: none;
}

.static-pill {
    justify-content: center;
    color: #353d49;
    font-size: 1.15rem;
}

.rest-date-form {
    margin-top: 18px;
}

.error-banner,
.success-banner {
    padding: 14px 16px;
    margin-bottom: 16px;
    font-size: 0.95rem;
    line-height: 1.35;
}

.error-banner {
    color: #b23333;
    background: #fff3f2;
}

.success-banner {
    color: #2f7d4a;
    background: #f3fff4;
}

.rest-panel {
    text-align: center;
}

.stack {
    display: grid;
    gap: 16px;
}

.info-panel {
    padding: 0;
    overflow: hidden;
}

.info-row {
    display: grid;
    grid-template-columns: 104px 1fr;
    gap: 12px;
    align-items: start;
    padding: 16px 16px 14px;
}

.info-row-button {
    width: 100%;
    border: none;
    background: transparent;
    text-align: left;
    color: inherit;
    font: inherit;
}

.info-row label {
    padding-top: 2px;
    font-size: 1.02rem;
}

.row-divider {
    height: 1px;
    margin: 0 16px;
    background: #eceef2;
}

.value-block {
    min-width: 0;
    text-align: right;
}

.value-select,
.value-input {
    width: 100%;
    border: none;
    background: transparent;
    color: var(--accent);
    font-size: 1.06rem;
    text-align: right;
    padding: 0;
    margin: 0;
    appearance: none;
    -webkit-appearance: none;
}

.value-select-text {
    color: var(--accent);
    font-size: 1.06rem;
}

.value-input::-webkit-outer-spin-button,
.value-input::-webkit-inner-spin-button,
.mini-input::-webkit-outer-spin-button,
.mini-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.value-input[type=number],
.mini-input[type=number] {
    appearance: textfield;
    -moz-appearance: textfield;
}

.value-subtitle,
.full-history-subtitle {
    margin-top: 6px;
    font-size: 0.83rem;
    color: var(--muted);
}

.section-head {
    text-align: center;
    color: var(--muted);
    font-size: 1.05rem;
    font-weight: 700;
    margin-top: 2px;
}

.section-head.small {
    margin-bottom: 12px;
}

.edit-form input,
.edit-form select {
    min-height: 52px;
    border-radius: 18px;
    border: 1px solid #ebedf2;
    background: rgba(255,255,255,0.92);
    padding: 0 16px;
    font: inherit;
}

.weight-inline,
.time-inline {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.mini-select,
.mini-input {
    border: 1px solid #ebedf2;
    background: #fff;
    color: var(--accent);
    border-radius: 16px;
    min-height: 42px;
    padding: 0 12px;
    font-size: 0.98rem;
}

.mini-select {
    min-width: 66px;
    appearance: none;
    -webkit-appearance: none;
}

.mini-input {
    width: 82px;
    text-align: center;
}

.mini-input.number {
    width: 78px;
}

.half-pill {
    min-height: 42px;
    padding: 0 12px;
    border-radius: 16px;
    border: 1px solid #ebedf2;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--accent);
}

.half-pill input {
    margin: 0;
}

.unit-tag {
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 700;
}

.value-live {
    margin-top: 8px;
    color: var(--accent);
    font-size: 1.08rem;
    font-weight: 600;
}

.done-panel {
    text-align: center;
    color: #4d9b67;
    font-weight: 700;
}

.history-panel,
.full-history {
    padding: 16px 14px 14px;
}

.history-grid {
    display: grid;
    grid-template-columns: 68px repeat(4, minmax(0, 1fr));
    gap: 8px;
    align-items: stretch;
}

.history-grid + .history-grid {
    margin-top: 10px;
}

.history-grid-head {
    margin-bottom: 12px;
    color: #111;
    font-size: 0.79rem;
    font-weight: 800;
    text-align: center;
}

.history-label {
    display: flex;
    align-items: center;
    font-size: 0.82rem;
    font-weight: 700;
    color: #1d2430;
}

.history-label.compact {
    color: var(--muted);
}

.history-chip {
    min-height: 70px;
    background: var(--chip);
    border-radius: 14px;
    display: grid;
    align-content: center;
    justify-items: center;
    gap: 4px;
    padding: 8px 6px;
    text-align: center;
    font-size: 0.92rem;
}

.history-chip strong {
    font-weight: 500;
}

.history-chip.compact {
    min-height: 62px;
    font-size: 0.82rem;
}

.history-chip.is-below {
    background: var(--below);
}

.history-chip.is-on {
    background: var(--on);
}

.history-chip.is-above {
    background: var(--above);
}

.history-chip.is-inactive {
    opacity: 0.4;
}

.chip-form {
    width: 100%;
}

.chip-tap {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    color: inherit;
    font: inherit;
    display: grid;
    align-content: center;
    justify-items: center;
    gap: 4px;
    padding: 0;
}

.record {
    font-weight: 800;
}

.main-submit,
.submit-btn {
    width: 100%;
    min-height: 52px;
    border: none;
    border-radius: 18px;
    background: var(--submit);
    color: #0d1118;
    font-size: 1rem;
    font-weight: 700;
    box-shadow: var(--shadow);
}

.edit-form {
    display: grid;
    gap: 12px;
}

.cancel-text {
    margin-top: 10px;
    width: 100%;
    border: none;
    background: transparent;
    color: var(--muted);
    font: inherit;
}

.hidden-submit {
    display: none;
}

.sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(20, 28, 43, 0.26);
    backdrop-filter: blur(4px);
    z-index: 40;
}

.picker-sheet {
    position: fixed;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: min(430px, calc(100vw - 16px));
    max-height: 72vh;
    overflow: auto;
    background: rgba(255, 255, 255, 0.97);
    border-radius: 28px 28px 0 0;
    box-shadow: 0 -18px 40px rgba(20, 28, 43, 0.16);
    padding: 18px 18px 24px;
    z-index: 50;
}

.sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.sheet-head h3 {
    margin: 0;
    font-size: 1.06rem;
}

.sheet-close,
.sheet-toggle,
.sheet-submit {
    border: none;
    background: transparent;
    color: var(--accent);
    font: inherit;
    font-weight: 700;
}

.sheet-divider {
    height: 1px;
    margin: 14px 0;
    background: #eceef2;
}

.wheel-grid {
    display: grid;
    grid-template-columns: 0.85fr 1.3fr 0.85fr;
    gap: 10px;
}

.wheel-grid.two {
    grid-template-columns: 1fr 1fr;
}

.wheel-column {
    position: relative;
    display: grid;
    gap: 6px;
    max-height: 220px;
    overflow-y: auto;
    padding: 56px 0;
    scroll-snap-type: y proximity;
    mask-image: linear-gradient(to bottom, transparent 0%, black 18%, black 82%, transparent 100%);
}

.wheel-column.single {
    max-width: 100%;
}

.wheel-column.tall {
    max-height: 280px;
}

.wheel-item {
    min-height: 44px;
    border: none;
    background: transparent;
    border-radius: 14px;
    color: #7d8794;
    font: inherit;
    font-size: 1.02rem;
    scroll-snap-align: center;
}

.wheel-item.active {
    background: #f0f5fb;
    color: var(--text);
    font-weight: 700;
}

.wheel-empty {
    color: var(--muted);
    font-size: 0.92rem;
    text-align: left;
    padding: 10px 6px;
}

.sheet-add-panel {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}

.sheet-add-panel input {
    min-height: 50px;
    border-radius: 18px;
    border: 1px solid #ebedf2;
    background: rgba(255,255,255,0.92);
    padding: 0 16px;
    font: inherit;
}

.sheet-submit {
    min-height: 48px;
    border-radius: 18px;
    background: var(--submit);
    color: #111827;
}

@media (max-width: 480px) {
    .app-title {
        font-size: 1.25rem;
    }

    .icon-btn {
        width: 48px;
        height: 48px;
    }

    .info-row {
        grid-template-columns: 92px 1fr;
    }

    .history-grid {
        grid-template-columns: 60px repeat(4, minmax(0, 1fr));
        gap: 6px;
    }

    .history-chip {
        min-height: 64px;
        font-size: 0.84rem;
    }
}
