:root {
    --scarlet: #ff2400;
    --scarlet-dark: #d91f00;
    --background: #ffffff;
    --surface: #ffffff;
    --surface-soft: #f7f8fa;
    --surface-hover: #f0f2f4;
    --text: #202124;
    --text-secondary: #687078;
    --text-muted: #8b9299;
    --border: #e1e4e8;
    --border-strong: #d2d6da;
    --shadow: 0 10px 30px rgba(31, 35, 40, 0.07);
    --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--background); }
body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    color: var(--text);
    background: var(--background);
}
button, input, select, textarea { font: inherit; }
a { color: inherit; }
button { color: inherit; }

.settings-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
}

.settings-header-inner {
    width: min(1180px, calc(100% - 40px));
    height: 72px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 16px;
}

.settings-header h1 {
    margin: 0;
    font-size: 20px;
    font-weight: 720;
    letter-spacing: -0.02em;
    text-align: center;
}

.back-link {
    width: max-content;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    padding: 8px 10px 8px 6px;
    border-radius: 8px;
}
.back-link:hover {
    color: var(--text);
    background: var(--surface-soft);
}
.back-link svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}
.header-spacer { min-width: 1px; }

.settings-shell {
    width: min(1180px, calc(100% - 40px));
    margin: 0 auto;
    padding: 42px 0 80px;
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 48px;
    align-items: start;
}

.settings-sidebar {
    position: sticky;
    top: 106px;
}

.settings-nav {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.settings-nav-item {
    width: 100%;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--text-secondary);
    text-align: left;
    font-size: 13px;
    font-weight: 620;
    cursor: pointer;
}
.settings-nav-item:hover {
    background: var(--surface-soft);
    color: var(--text);
}
.settings-nav-item.active {
    background: #f2f3f5;
    color: var(--text);
}
.settings-nav-item svg {
    width: 19px;
    height: 19px;
    flex: 0 0 19px;
    fill: currentColor;
    opacity: 0.82;
}
.settings-nav-item.active svg { opacity: 1; }

.logout-nav-item {
    width: 100%;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 11px;
    margin-top: 7px;
    padding: 9px 12px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: #d93025;
    text-align: left;
    font-size: 13px;
    font-weight: 650;
    cursor: pointer;
}
.logout-nav-item:hover {
    background: #fff1f0;
    color: #b3261e;
}
.logout-nav-item:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}
.logout-nav-item:disabled {
    opacity: 0.6;
    cursor: wait;
}
.logout-nav-item svg {
    width: 19px;
    height: 19px;
    flex: 0 0 19px;
    fill: currentColor;
}

.settings-content {
    min-width: 0;
    max-width: 830px;
}

.settings-panel[hidden] { display: none !important; }

.panel-heading {
    margin-bottom: 26px;
}
.panel-heading h2 {
    margin: 0 0 7px;
    font-size: 28px;
    font-weight: 740;
    letter-spacing: -0.035em;
}
.panel-heading p {
    max-width: 690px;
    margin: 0;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}

.settings-card {
    width: 100%;
    margin-bottom: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
}

.profile-card { padding: 24px; }
.profile-picture-row {
    display: flex;
    align-items: center;
    gap: 22px;
}
.profile-picture {
    width: 92px;
    height: 92px;
    flex: 0 0 92px;
    overflow: hidden;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 1px solid var(--border-strong);
    background: var(--surface-soft);
    color: #747b82;
    font-size: 30px;
    font-weight: 700;
}
.profile-picture img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}
.profile-picture-copy {
    min-width: 0;
    flex: 1;
}
.profile-picture-copy h3,
.card-heading h3 {
    margin: 0 0 6px;
    font-size: 16px;
    font-weight: 680;
    letter-spacing: -0.015em;
}
.profile-picture-copy p,
.card-heading p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.55;
}
.profile-picture-actions {
    margin-top: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.form-card { padding: 24px; }
.field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px 18px;
}
.field-group {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 7px;
}
.field-full { grid-column: 1 / -1; }
.field-label {
    color: var(--text);
    font-size: 12px;
    font-weight: 680;
}
.field-help {
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.45;
}

input[type="text"],
input[type="email"],
select,
textarea {
    width: 100%;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    outline: none;
    background: #ffffff;
    color: var(--text);
    transition: border-color 140ms ease, box-shadow 140ms ease;
}
input[type="text"],
input[type="email"],
select {
    height: 44px;
    padding: 0 12px;
    font-size: 13px;
}
textarea {
    min-height: 180px;
    padding: 12px 13px;
    resize: vertical;
    font-size: 13px;
    line-height: 1.55;
}
input:focus,
select:focus,
textarea:focus {
    border-color: #aeb4ba;
    box-shadow: 0 0 0 3px rgba(32, 33, 36, 0.07);
}
input[readonly] {
    background: var(--surface-soft);
    color: #777f86;
    cursor: default;
}

.textarea-meta {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
}
.character-count {
    flex: 0 0 auto;
    color: var(--text-muted);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.form-footer {
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
}
.save-status {
    min-width: 0;
    flex: 1;
    color: var(--text-secondary);
    font-size: 11px;
    text-align: right;
}

.primary-button,
.secondary-button,
.text-button {
    border: 0;
    cursor: pointer;
    text-decoration: none;
}
.primary-button {
    min-height: 40px;
    padding: 0 17px;
    border-radius: 9px;
    background: var(--text);
    color: #ffffff;
    font-size: 12px;
    font-weight: 680;
}
.primary-button:hover { background: #08090a; }
.secondary-button {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 13px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text);
    font-size: 11px;
    font-weight: 650;
}
.secondary-button:hover { background: var(--surface-soft); }
.text-button {
    padding: 6px 3px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 620;
}
.text-button:hover { color: var(--scarlet-dark); }

.goals-card { padding: 24px; }
.card-heading { margin-bottom: 18px; }
.goal-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}
.goal-option {
    display: block;
    position: relative;
    cursor: pointer;
}
.goal-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.goal-option-box {
    min-height: 104px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 5px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #ffffff;
    transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}
.goal-option:hover .goal-option-box {
    border-color: #cfd4d9;
    background: #fcfcfd;
}
.goal-option input:focus-visible + .goal-option-box {
    box-shadow: 0 0 0 3px rgba(32, 33, 36, 0.08);
}
.goal-option input:checked + .goal-option-box {
    border-color: #9ca3aa;
    background: var(--surface-soft);
    box-shadow: inset 3px 0 0 var(--scarlet-dark);
}
.goal-option-box strong {
    font-size: 13px;
    font-weight: 680;
}
.goal-option-box small {
    color: var(--text-secondary);
    font-size: 11px;
    line-height: 1.45;
}

@media (max-width: 780px) {
    .settings-header-inner {
        width: min(100% - 28px, 1180px);
        height: 64px;
    }
    .settings-header h1 { font-size: 17px; }
    .back-link span { display: none; }
    .back-link { padding-right: 7px; }

    .settings-shell {
        width: min(100% - 28px, 1180px);
        padding: 24px 0 56px;
        grid-template-columns: 1fr;
        gap: 24px;
    }
    .settings-sidebar {
        position: static;
        overflow-x: auto;
        scrollbar-width: none;
    }
    .settings-sidebar::-webkit-scrollbar { display: none; }
    .settings-nav {
        min-width: max-content;
        flex-direction: row;
        gap: 6px;
    }
    .settings-nav-item,
    .logout-nav-item {
        width: auto;
        min-height: 40px;
        margin-top: 0;
        padding: 8px 11px;
    }
    .panel-heading h2 { font-size: 24px; }
    .field-grid { grid-template-columns: 1fr; }
    .field-full { grid-column: auto; }
    .goal-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
    .settings-header-inner,
    .settings-shell { width: calc(100% - 24px); }
    .profile-card,
    .form-card,
    .goals-card { padding: 18px; }
    .profile-picture-row {
        align-items: flex-start;
        gap: 15px;
    }
    .profile-picture {
        width: 72px;
        height: 72px;
        flex-basis: 72px;
        font-size: 24px;
    }
    .profile-picture-actions {
        align-items: flex-start;
        flex-direction: column;
        gap: 5px;
    }
    .textarea-meta {
        flex-direction: column;
        gap: 5px;
    }
    .form-footer {
        align-items: stretch;
        flex-direction: column;
    }
    .save-status { text-align: left; }
    .primary-button { width: 100%; }
}
