/* profile.css */
#profile {
    background: var(--bg-dashboard) !important;
}

.profile-section {
    margin-bottom: 16px;
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 14px;
    box-shadow: var(--shadow-card);
    border: 1px solid rgba(0, 0, 0, 0.04);
}

/* Делаем экраны профиля скроллируемыми */
#profile .main-content,
#edit-profile .main-content {
    overflow-y: auto;
    padding-bottom: 100px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#profile .main-content::-webkit-scrollbar,
#edit-profile .main-content::-webkit-scrollbar {
    display: none;
}

.profile-section h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--gray-light);
}

.days-grid-edit {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: 8px;
}

.day-card-edit {
    background: var(--white);
    border: 1.5px solid var(--gray-light);
    border-radius: 12px;
    padding: 8px 4px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    user-select: none;
}

.day-card-edit:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

.day-card-edit.selected {
    border-color: var(--primary);
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-lg);
}

.day-card-edit .day-short {
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 2px;
}

.day-card-edit .day-full {
    font-size: 8px;
    opacity: 0.8;
}

.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 6px;
}

.form-input, .form-select {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--gray-light);
    border-radius: 10px;
    font-size: 14px;
    transition: var(--transition);
    background: var(--white);
}

.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.profile-header {
    text-align: center;
    margin-bottom: 12px;
}

.avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    margin: 0 auto 8px;
}

.profile-name {
    font-size: 22px;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 2px;
}

.profile-subtitle {
    color: var(--gray);
    font-size: 13px;
}

.profile-item {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 14px;
    margin-bottom: 6px;
    box-shadow: var(--shadow-card);
    border: 1px solid rgba(0, 0, 0, 0.04);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.profile-item:hover {
    border-color: rgba(var(--primary-rgb), 0.2);
    background: rgba(var(--primary-rgb), 0.02);
}

.profile-item-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.profile-item-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--light);
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-item-icon svg {
    color: var(--accent-ink);
}

.profile-item-text {
    flex: 1;
}

.profile-item-title {
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 1px;
    font-size: 14px;
}

.profile-item-subtitle {
    font-size: 11px;
    color: var(--gray);
}

.profile-item-arrow {
    color: var(--gray);
    font-size: 16px;
}

/* Сетка оборудования в профиле */
.equipment-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 8px;
}

.equipment-item {
    background: var(--white);
    border: 1.5px solid var(--gray-light);
    border-radius: 12px;
    padding: 10px 8px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 13px;
    font-weight: 500;
    color: var(--dark);
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.equipment-item:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

.equipment-item.selected {
    border-color: var(--primary);
    background: rgba(var(--primary-rgb), 0.05);
    color: var(--primary);
    font-weight: 600;
}


.profile-disliked-foods-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.profile-disliked-foods-grid .disliked-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.profile-disliked-item {
    padding: 10px 12px;
    min-height: auto;
    font-size: 14px;
}

.profile-round-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px;
}
.profile-quick-settings .profile-round-row { justify-content: flex-start; gap: 12px; }
.profile-quick-settings .palette-picker { padding: 12px 0 0; }
.profile-app-mark { width: 36px; height: 36px; border-radius: 9px; }
.profile-utilities .profile-item { margin-top: 12px; }
#profileInstallHint:empty { display: none; }
#profileInstallHint .pwa-inline-guide { padding: 0; margin: 10px 0 0; }
.profile-unlink {
    min-height: 44px;
    padding: 6px 8px;
    border: 0;
    background: none;
    color: var(--danger);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.profile-item-icon .profile-brand-telegram { color: #1683b5; }
.profile-item-icon .profile-brand-max { color: #6557db; }
[data-theme="dark"] .profile-item-icon .profile-brand-telegram { color: #65c4ef; }
[data-theme="dark"] .profile-item-icon .profile-brand-max { color: #ac9fff; }

/* =============== PALETTE PICKER =============== */
.palette-picker { padding: 8px 14px 4px; }
.palette-options { display: flex; gap: 10px; flex-wrap: wrap; }
.palette-dot {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--dot-clr); border: 2px solid transparent;
    cursor: pointer; transition: transform 0.2s, box-shadow 0.2s;
    padding: 0; position: relative;
}
.palette-dot.active {
    box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--dot-clr);
}
.palette-dot:active { transform: scale(0.93); }
.palette-custom {
    background: var(--gray-light); display: flex;
    align-items: center; justify-content: center;
    font-size: 18px; color: var(--gray); cursor: pointer;
}
.palette-custom input { position: absolute; opacity: 0; width: 0; height: 0; }

/* =============== DARK THEME OVERRIDES =============== */
[data-theme="dark"] .profile-section,
[data-theme="dark"] .profile-item {
    border-color: var(--border);
}
[data-theme="dark"] .profile-item-icon {
    background: rgba(var(--primary-rgb), 0.15);
}

/* === P1 Журнал тренировок === */
.wj-group {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary, #8a8a8a);
    margin: 18px 4px 10px;
}
.wj-group:first-child { margin-top: 4px; }
.wj-card {
    background: var(--surface, #fff);
    border-radius: var(--border-radius-small, 14px);
    padding: 14px 16px;
    margin-bottom: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border, rgba(0,0,0,0.04));
}
.wj-date {
    font-size: 11px;
    color: var(--text-secondary, #9a9a9a);
    margin-bottom: 4px;
}
.wj-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text, #2a2a2a);
    margin-bottom: 10px;
}
.wj-meta {
    display: flex;
    align-items: center;
    gap: 10px;
}
.wj-bar {
    flex: 1;
    height: 6px;
    background: var(--gray-light, #ececec);
    border-radius: 3px;
    overflow: hidden;
}
.wj-bar-fill {
    height: 100%;
    background: var(--gradient-primary, var(--primary, #C0643E));
    border-radius: 3px;
}
.wj-pct {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary, #C0643E);
    min-width: 34px;
    text-align: right;
}
.wj-dur {
    font-size: 12px;
    color: var(--text-secondary, #9a9a9a);
}
.wj-state {
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-secondary, #7a7a7a);
}
.wj-empty, .wj-empty-hint {
    text-align: center;
    color: var(--text-secondary, #9a9a9a);
    padding: 40px 20px;
}
.wj-empty-icon { font-size: 40px; margin-bottom: 14px; }
.wj-empty-text { font-size: 14px; line-height: 1.5; margin-bottom: 18px; }

/* === P3 Достижения === */
#achievements .main-content { overflow-y: auto; scrollbar-width: none; -ms-overflow-style: none; padding-bottom: 90px; }
#achievements .main-content::-webkit-scrollbar { display: none; }
.ach-dot { position: absolute; top: -2px; right: -2px; width: 9px; height: 9px; border-radius: 50%; background: var(--primary, #C0643E); border: 2px solid var(--surface, #fff); }
.ach-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.ach-tab {
    flex: 1; padding: 9px;
    border: 1px solid var(--border, rgba(0,0,0,0.08));
    border-radius: var(--border-radius-small, 14px);
    background: transparent; color: var(--text-secondary, #8a8a8a);
    font-size: 13px; font-weight: 600; cursor: pointer;
}
.ach-tab.active { background: var(--accent-fill); color: #fff; border-color: transparent; }
.ach-card {
    display: flex; align-items: center; gap: 14px;
    background: var(--surface, #fff);
    border-radius: var(--border-radius-small, 14px);
    padding: 14px; margin-bottom: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    border: 1px solid var(--border, rgba(0,0,0,0.04));
}
.ach-card.locked { opacity: 0.55; }
.ach-card.locked .ach-icon { filter: grayscale(1); opacity: 0.5; }
.ach-icon { font-size: 32px; line-height: 1; width: 44px; text-align: center; flex-shrink: 0; }
.ach-info { min-width: 0; }
.ach-title { font-size: 15px; font-weight: 600; color: var(--text, #2a2a2a); margin-bottom: 3px; }
.ach-sub { font-size: 13px; color: var(--text-secondary, #8a8a8a); line-height: 1.35; }

/* Экран награды */
.ach-reward-overlay {
    position: fixed; inset: 0; z-index: 9999;
    display: flex; align-items: center; justify-content: center; padding: 28px;
    background: var(--gradient-primary, var(--primary, #C0643E));
    animation: fadeIn 0.3s ease-out;
}
.ach-reward-card { text-align: center; max-width: 340px; }
.ach-reward-icon { font-size: 72px; line-height: 1; margin-bottom: 18px; animation: achPop 0.45s cubic-bezier(0.34,1.56,0.64,1); }
.ach-reward-title { font-size: 22px; font-weight: 700; color: #fff; margin-bottom: 14px; }
.ach-reward-text { font-size: 16px; line-height: 1.5; color: rgba(255,255,255,0.92); margin-bottom: 18px; }
.ach-reward-caption { font-size: 13px; color: rgba(255,255,255,0.6); margin-bottom: 28px; }
.ach-reward-btn {
    padding: 13px 28px; border: 1.5px solid rgba(255,255,255,0.85);
    border-radius: var(--border-radius-small, 14px);
    background: transparent; color: #fff; font-size: 15px; font-weight: 600; cursor: pointer;
}
.ach-reward-btn:active { background: rgba(255,255,255,0.15); }
@keyframes achPop { 0% { transform: scale(0.5); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

/* === P2 Графики прогресса === */
#progress-screen .main-content { overflow-y: auto; scrollbar-width: none; -ms-overflow-style: none; padding-bottom: 90px; }
#progress-screen .main-content::-webkit-scrollbar { display: none; }
.prog-period { display: flex; gap: 8px; margin-bottom: 16px; }
.prog-period-tab {
    flex: 1; padding: 9px;
    border: 1px solid var(--border, rgba(0,0,0,0.08));
    border-radius: var(--border-radius-small, 14px);
    background: transparent; color: var(--text-secondary, #8a8a8a);
    font-size: 13px; font-weight: 600; cursor: pointer;
}
.prog-period-tab.active { background: var(--accent-fill); color: #fff; border-color: transparent; }
.prog-card {
    background: var(--surface, #fff);
    border-radius: var(--border-radius, 18px);
    padding: 16px; margin-bottom: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    border: 1px solid var(--border, rgba(0,0,0,0.04));
}
.prog-card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.prog-card-title { font-size: 15px; font-weight: 600; color: var(--text, #2a2a2a); }
.prog-card-val { font-size: 14px; font-weight: 600; color: var(--primary, #C0643E); }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-empty { text-align: center; color: var(--text-secondary, #9a9a9a); font-size: 13px; padding: 22px 8px; line-height: 1.4; }
.prog-weight-btn {
    width: 100%; margin-top: 12px; padding: 11px; border: none;
    border-radius: var(--border-radius-small, 14px);
    background: var(--accent-fill);
    color: #fff; font-size: 14px; font-weight: 600; cursor: pointer;
}
.prog-card-note { font-size: 12px; color: var(--text-secondary, #8a8a8a); margin-top: 8px; text-align: center; }

/* Инлайн-ввод веса */
.prog-weight-edit { display: flex; gap: 8px; margin-top: 12px; }
.prog-weight-input {
    flex: 1; padding: 10px 12px;
    border: 1.5px solid var(--gray-light, #ddd);
    border-radius: var(--border-radius-small, 14px);
    font-size: 14px; background: var(--surface, #fff); color: var(--text, #2a2a2a);
}
.prog-weight-input:focus { outline: none; border-color: var(--primary, #C0643E); }
.prog-weight-save {
    padding: 10px 18px; border: none;
    border-radius: var(--border-radius-small, 14px);
    background: var(--gradient-primary, var(--primary, #C0643E));
    color: #fff; font-weight: 600; font-size: 14px; cursor: pointer;
}

/* Подпись дат под графиком + журнал внутри карточки прогресса */
.prog-card-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-secondary, #9a9a9a); margin-top: 6px; }
.prog-card-axis span:only-child { margin: 0 auto; }
#progJournalCard .wj-card { box-shadow: none; border: none; border-bottom: 1px solid var(--border, rgba(0,0,0,0.06)); border-radius: 0; padding: 12px 0; margin: 0; }
#progJournalCard .wj-card:last-child { border-bottom: none; padding-bottom: 0; }
#progJournalCard .wj-group { margin: 12px 0 6px; }
#progJournalCard .wj-group:first-of-type { margin-top: 4px; }

/* Ограничения по здоровью в профиле — тот же вид, что в первой анкете:
   мультивыбор карточками из полного справочника (Тимур, 19.08.2026). */
.profile-health-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 6px;
}
.profile-health-grid .choice-card {
    min-height: 56px;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 10px;
    border: 1px solid var(--border, #E0D7CA);
    border-radius: 12px;
    background: var(--surface, #fff);
    cursor: pointer;
}
.profile-health-grid .choice-card.selected {
    border-color: var(--primary, #C0643E);
    background: var(--primary-very-light, rgba(192, 100, 62, .1));
}
.profile-health-grid .choice-card.selected .choice-text { color: var(--text-primary); }
.profile-health-grid .profile-health-none { grid-column: 1 / -1; }

/* Compact account and profile-edit views. */
#profile .main-content { padding-inline: 16px; }
#profile .profile-header { margin-bottom: 12px; }
#profile .profile-section {
    padding: 10px 12px;
    margin-bottom: 10px;
}
#profile .profile-section h3 {
    padding-bottom: 6px;
    margin-bottom: 4px;
    font-size: 14px;
    color: var(--text-secondary);
}
#profile .profile-item {
    min-height: 45px;
    margin: 0;
    padding: 4px 1px;
    box-shadow: none;
    border: none;
    border-radius: 0;
    background: transparent;
}
#profile .profile-item + .profile-item { border-top: 1px solid var(--border); }
#profile .profile-item-left { min-width: 0; gap: 7px; }
#profile .profile-item-icon { width: 32px; height: 32px; flex: 0 0 32px; }
#profile .profile-item-title { margin: 0; }
#profile .profile-utilities > .profile-item { margin-top: 6px; }
#profile .profile-device-row { gap: 4px; cursor: default; }
#profile .profile-unlink { padding-inline: 3px; flex: 0 0 auto; }
.profile-device-caption {
    display: flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
    white-space: nowrap;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
}
.profile-device-caption > span { overflow: hidden; text-overflow: ellipsis; }
.profile-device-caption time {
    flex: 0 0 auto;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

#edit-profile .main-content { padding: 12px 16px 10px; }
#edit-profile .profile-section { padding: 12px; margin-bottom: 10px; }
#edit-profile .profile-section h3 { font-size: 14px; margin-bottom: 8px; padding-bottom: 6px; }
#edit-profile .form-group { min-width: 0; margin-bottom: 10px; }
#edit-profile .form-group:last-child { margin-bottom: 0; }
#edit-profile .form-label { margin-bottom: 3px; line-height: 1.25; }
#edit-profile .form-input,
#edit-profile .form-select { min-width: 0; padding: 9px 8px; color: var(--text-primary); }
#edit-profile .profile-form-grid {
    display: grid;
    grid-template-columns: repeat(2,minmax(0,1fr));
    gap: 8px;
}
#edit-profile .profile-form-grid > *,
#edit-profile .profile-form-grid > .form-group.profile-field-wide { grid-column: 1 / -1; }
#edit-profile .profile-form-grid--personal > .form-group:not(.profile-field-wide),
#edit-profile .profile-form-grid--goals > .form-group:has(#edit-activity, #edit-fitness),
#edit-profile .profile-form-grid--food > .form-group:has(#edit-meals-count, #edit-cooking-time) {
    grid-column: auto;
}
#edit-profile .profile-form-grid > .form-group,
#edit-profile .profile-form-grid > h3 { margin-bottom: 0; }
#edit-profile .day-card-edit { padding: 6px 4px; min-height: 38px; }
#edit-profile .profile-training-link { margin-bottom: 0; padding: 7px 9px; }
.profile-edit-actions {
    display: grid;
    grid-template-columns: minmax(0,.86fr) minmax(0,1.14fr);
    gap: 8px;
    flex: 0 0 auto;
    margin: 0 16px calc(58px + env(safe-area-inset-bottom, 0px));
    padding-top: 5px;
    background: var(--surface);
}
.profile-edit-actions button { min-height: 44px; }

body:has(#edit-profile.active, #equipment-select.active) #testEnvBanner {
    --test-badge-bottom: auto;
    top: max(8px, env(safe-area-inset-top,0px));
}


.homeza-avatar-photo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}

.profile-avatar-button {
    position: relative;
    width: 58px;
    height: 58px;
    border: 1px solid var(--border);
    padding: 0;
    cursor: pointer;
}

.profile-avatar-button:disabled { cursor: wait; }
.profile-avatar-button:focus-visible,
.hero-avatar:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.profile-avatar-edit {
    position: absolute;
    inset-inline-end: -3px;
    bottom: -2px;
    width: 25px;
    height: 25px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    color: var(--accent-ink);
    pointer-events: none;
}

.profile-avatar-status {
    margin: 8px auto;
    color: var(--text-secondary);
    font-size: .8125rem;
    line-height: 1.35;
}

.profile-avatar-reset {
    margin-block: 2px 8px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-primary);
    font: 600 .75rem/1.3 var(--font-family);
    cursor: pointer;
}
