/* -- Account and options controls ------------------ */
.account-nav {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 1rem);
    right: calc(env(safe-area-inset-right, 0px) + 0.85rem);
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 0.32rem;
    padding: 0.22rem;
    border-radius: 999px;
    border: 1px solid rgba(213, 196, 185, 0.75);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 8px 22px rgba(45, 52, 54, 0.08);
}

.account-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.account-nav-icon {
    display: grid;
    place-items: center;
    width: 2.3rem;
    height: 2.3rem;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #71645f;
    font: inherit;
    font-size: 1.1rem;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    line-height: 1;
}

.account-nav-primary {
    background: #6c5ce7;
    color: #ffffff;
    box-shadow: 0 6px 18px rgba(108, 92, 231, 0.22);
}

.account-nav-dots {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.18rem;
    width: 100%;
    height: 100%;
}

.account-nav-dot {
    width: 0.24rem;
    height: 0.24rem;
    border-radius: 50%;
    background: currentColor;
    display: block;
}

.account-options {
    display: inline-flex;
}

.account-options.is-open::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 41;
    background: rgba(45, 42, 53, 0.22);
    pointer-events: none;
}

.account-sheet[hidden] {
    display: none;
}

.account-sheet {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 80;
    width: min(100%, 520px);
    margin: 0 auto;
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - 4rem);
    overflow-y: auto;
    padding: 0.8rem 1rem calc(env(safe-area-inset-bottom, 0px) + 1rem);
    border: 1px solid rgba(232, 221, 211, 0.95);
    border-bottom: 0;
    border-radius: 26px 26px 0 0;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 -18px 42px rgba(45, 52, 54, 0.16);
}

.account-sheet-handle {
    width: 2.6rem;
    height: 0.3rem;
    margin: 0 auto 0.85rem;
    border-radius: 999px;
    background: #ded4ce;
}

.account-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.8rem;
}

.account-sheet-kicker {
    color: #8e817b;
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: uppercase;
}

.account-sheet h2 {
    margin: 0;
    color: #2d3436;
    font-size: 1.15rem;
    font-weight: 950;
}

.account-sheet-close {
    display: grid;
    place-items: center;
    width: 2.4rem;
    height: 2.4rem;
    border: 0;
    border-radius: 50%;
    background: #f4f1ff;
    color: #6c5ce7;
    font: inherit;
    font-size: 1.2rem;
    font-weight: 900;
    cursor: pointer;
}

.account-sheet-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
}

.account-sheet-settings {
    display: grid;
    gap: 0.75rem;
    padding: 0.72rem;
    border: 2px solid #efe4de;
    border-radius: 16px;
    background: #fffdfb;
}

.account-sheet-actions + .account-sheet-settings {
    margin-top: 0.75rem;
}

.account-selector-row {
    justify-content: space-between;
    gap: 0.65rem;
    margin-bottom: 0;
}

.account-selector-row .btn-group {
    flex-wrap: wrap;
    justify-content: flex-end;
}

.account-selector-row .btn-group-btn {
    min-height: 2.3rem;
}

.account-sheet-section + .account-sheet-section {
    margin-top: 0.9rem;
}

.account-sheet-section-title {
    margin-bottom: 0.45rem;
    color: #8e817b;
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: uppercase;
}

.account-sheet-form {
    display: contents;
}

.account-sheet-action {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-height: 4rem;
    width: 100%;
    border: 2px solid #efe4de;
    border-radius: 16px;
    padding: 0.8rem;
    background: #fffdfb;
    color: #2d3436;
    font: inherit;
    font-weight: 900;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.account-sheet-action[hidden] {
    display: none;
}

.account-sheet-action > span:first-child {
    font-size: 1.25rem;
    line-height: 1;
}

.account-sheet-action-copy {
    display: grid;
    gap: 0.12rem;
    min-width: 0;
}

.account-sheet-action-copy strong {
    font-size: 0.9rem;
    line-height: 1.15;
}

.account-sheet-action-copy small {
    min-height: 1rem;
    overflow: hidden;
    color: #8e817b;
    font-size: 0.78rem;
    font-weight: 800;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-sheet-action:disabled {
    color: #9b908b;
    cursor: not-allowed;
    opacity: 0.62;
}

.account-sheet-primary {
    border-color: rgba(108, 92, 231, 0.25);
    background: #f4f1ff;
    color: #5948c7;
}

.account-sheet-danger {
    color: #a95743;
}

/* -- Account pages --------------------------------- */
.account-body {
    display: block;
    align-items: initial;
    justify-content: initial;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 0;
    overflow-x: hidden;
}

.account-page {
    position: relative;
    z-index: 1;
    width: min(100%, 840px);
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0 auto;
    padding: calc(env(safe-area-inset-top, 0px) + 1rem) 1rem calc(env(safe-area-inset-bottom, 0px) + 1.25rem);
}

.account-page-profile {
    width: min(100%, 1120px);
}

.account-page-streak {
    width: min(100%, 430px);
    display: grid;
    align-content: center;
}

.account-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.9rem;
    padding: 0.35rem 0.65rem;
    border: 1px solid rgba(232, 221, 216, 0.85);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    color: #7b6d68;
    font-weight: 800;
    text-decoration: none;
}

.account-card,
.account-profile {
    border: 2px solid #f0e4df;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 10px 34px rgba(201, 142, 104, 0.13);
}

.account-profile {
    padding: 1.25rem;
}

.account-card {
    padding: 1.25rem;
}

.account-card-form {
    max-width: 440px;
    margin: 0 auto;
}

.account-card-header {
    margin-bottom: 0.8rem;
    text-align: center;
}

.account-kicker {
    margin-bottom: 0.25rem;
    color: #8e817b;
    font-size: 0.75rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.account-card h1,
.account-profile h1 {
    margin-bottom: 0;
    color: #e17055;
    text-align: inherit;
}

.account-card h2 {
    margin-bottom: 0.85rem;
    color: #2d3436;
    font-size: 1rem;
    font-weight: 900;
}

.account-card p,
.account-muted,
.account-switch {
    color: #887a74;
    font-weight: 700;
    line-height: 1.45;
}

.account-switch {
    margin-top: 0.85rem;
    text-align: center;
}

.account-switch a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.4rem;
    padding: 0 0.8rem;
    border: 2px solid rgba(108, 92, 231, 0.18);
    border-radius: 999px;
    background: #f7f4ff;
    color: #6c5ce7;
    font-weight: 900;
    text-decoration: none;
}

.account-form {
    display: grid;
    gap: 0.75rem;
}

.account-form label {
    display: grid;
    gap: 0.35rem;
    color: #625651;
    font-weight: 900;
}

.account-form input {
    width: 100%;
    min-height: 2.85rem;
    border: 2px solid #e8ddd8;
    border-radius: 14px;
    padding: 0.75rem 0.9rem;
    background: #fffdfb;
    color: #2d3436;
    font: inherit;
    font-weight: 800;
}

.account-form input:-webkit-autofill,
.account-form input:-webkit-autofill:hover,
.account-form input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px #fffdfb inset;
    -webkit-text-fill-color: #2d3436;
}

.account-form input:focus {
    border-color: #6c5ce7;
    box-shadow: 0 0 0 4px rgba(108, 92, 231, 0.12);
    outline: none;
}

.account-form ul,
.account-form-errors {
    list-style: none;
    color: #9b5647;
    font-size: 0.8rem;
    font-weight: 800;
    line-height: 1.25;
}

.account-form-errors ul {
    margin: 0;
    padding: 0;
}

.account-submit,
.account-profile-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 3rem;
    border: 0;
    border-radius: 16px;
    background: #6c5ce7;
    color: #ffffff;
    font: inherit;
    font-weight: 900;
    text-decoration: none;
    box-shadow: 0 10px 24px rgba(108, 92, 231, 0.24);
    cursor: pointer;
}

.account-avatar-card {
    max-width: 620px;
    margin: 0 auto;
}

.account-avatar-card > p {
    margin: 0 auto 1rem;
    max-width: 32rem;
    text-align: center;
}

.account-avatar-form {
    display: grid;
    gap: 1rem;
}

.account-avatar-upload-form {
    display: grid;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid #e9dff5;
    border-radius: 18px;
    background: linear-gradient(135deg, #faf7ff, #fffdfb);
}

.account-avatar-current {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.account-avatar-current p {
    margin: 0.2rem 0 0;
    color: #756964;
    font-size: 0.82rem;
    line-height: 1.45;
}

.account-avatar-current-image {
    display: grid;
    flex: 0 0 auto;
    width: 4.5rem;
    height: 4.5rem;
    place-items: center;
    border-radius: 50%;
    object-fit: cover;
    overflow: hidden;
    background: #f0ebff;
    box-shadow: 0 7px 20px rgba(76, 58, 135, 0.16);
}

.account-avatar-current-fallback {
    font-size: 2.3rem;
}

.account-avatar-file-picker {
    position: relative;
    display: block;
    cursor: pointer;
}

.account-avatar-file-picker input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.account-avatar-file-action {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 3rem;
    padding: 0.7rem 1rem;
    border: 2px solid #6c5ce7;
    border-radius: 14px;
    background: #fff;
    color: #5948c7;
    font-weight: 950;
    text-align: center;
}

.account-avatar-file-picker:focus-within .account-avatar-file-action {
    outline: 3px solid rgba(108, 92, 231, 0.25);
    outline-offset: 2px;
}

.account-avatar-file-name {
    color: #756964;
    font-size: 0.8rem;
    font-weight: 800;
    text-align: center;
}

.account-avatar-divider {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    margin: 1.2rem 0;
    color: #8a7d77;
    font-size: 0.78rem;
    font-weight: 900;
    text-transform: uppercase;
}

.account-avatar-divider::before,
.account-avatar-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: #eee4df;
}

.account-avatar-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.7rem;
}

.account-avatar-option {
    position: relative;
    display: grid;
    place-items: center;
    gap: 0.35rem;
    min-height: 7rem;
    padding: 0.7rem;
    border: 2px solid #eee4df;
    border-radius: 16px;
    background: #fffdfb;
    color: #655a55;
    font-weight: 900;
    cursor: pointer;
}

.account-avatar-option:has(input:checked),
.account-avatar-option.is-selected {
    border-color: #6c5ce7;
    background: #f5f1ff;
    color: #5948c7;
    box-shadow: 0 8px 20px rgba(108, 92, 231, 0.15);
}

.account-avatar-option input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.account-avatar-option:focus-within {
    outline: 3px solid rgba(108, 92, 231, 0.25);
    outline-offset: 2px;
}

.account-avatar-preview {
    display: grid;
    width: 3.4rem;
    height: 3.4rem;
    place-items: center;
    border-radius: 50%;
    background: #f0ebff;
    font-size: 2rem;
    line-height: 1;
}

.account-avatar-form .account-submit,
.account-avatar-upload-form .account-submit {
    width: 100%;
}

@media (max-width: 480px) {
    .account-avatar-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .account-avatar-option {
        min-height: 6.5rem;
    }
}

.account-profile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.account-profile-header h1 {
    margin: 0;
    text-align: left;
}

.account-profile-cta {
    min-height: 2.7rem;
    padding: 0 1rem;
}

.account-stat-grid,
.account-columns {
    display: grid;
    gap: 0.8rem;
}

.account-stat-grid {
    grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
    margin-bottom: 0.8rem;
}

.account-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 0.8rem;
}

.account-profile > .account-card + .account-card {
    margin-top: 0.8rem;
}

.account-stat {
    min-width: 0;
    padding: 0.95rem;
    border: 2px solid #f0e4df;
    border-radius: 16px;
    background: #fffdfb;
}

.account-stat span {
    display: block;
    color: #8e817b;
    font-size: 0.78rem;
    font-weight: 900;
}

.account-stat strong {
    display: block;
    color: #2d3436;
    font-size: 1.45rem;
    font-weight: 950;
}

.account-table {
    display: grid;
    gap: 0.45rem;
}

.account-table-row,
.account-recent-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
}

.account-table-row {
    padding: 0.55rem 0;
    border-bottom: 1px solid #f0e4df;
    color: #514641;
    font-weight: 800;
}

.account-table-row:last-child {
    border-bottom: 0;
}

.account-word-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.account-word-chip {
    display: inline-flex;
    gap: 0.35rem;
    align-items: center;
    padding: 0.4rem 0.65rem;
    border-radius: 999px;
    background: #f7f3ff;
    color: #5948c7;
    font-weight: 900;
}

.account-word-chip strong {
    color: #8e817b;
}

.account-recent-list {
    display: grid;
    gap: 0.65rem;
}

.account-recent {
    padding: 0.8rem;
    border-left: 4px solid #d0c7c2;
    border-radius: 14px;
    background: #fffdfb;
}

.account-recent.correct {
    border-left-color: #00a889;
}

.account-recent.incorrect {
    border-left-color: #d46a50;
}

.account-recent-top {
    color: #8e817b;
    font-size: 0.8rem;
    font-weight: 900;
}

.account-recent-prompt,
.account-recent-answer {
    margin-top: 0.35rem;
    overflow-wrap: anywhere;
    color: #2d3436;
    font-weight: 800;
}

.account-recent-answer {
    color: #6d625d;
}

.account-empty {
    text-align: center;
}

.account-empty .account-profile-cta {
    margin-top: 1rem;
}

/* -- Streak page ----------------------------------- */
.account-streak-card {
    border: 2px solid #f0e4df;
    border-radius: 18px;
    background: rgba(255, 253, 251, 0.96);
    box-shadow: 0 22px 55px rgba(63, 49, 35, 0.12);
    padding: 1.65rem 1.35rem 1.55rem;
    text-align: center;
}

.account-streak-badge {
    display: grid;
    place-items: center;
    width: 7.25rem;
    height: 7.25rem;
    margin: 0 auto 1.1rem;
    border: 7px solid transparent;
    border-radius: 50%;
    background:
        linear-gradient(#fff, #fff) padding-box,
        linear-gradient(140deg, #14bfa5, #6c5ce7) border-box;
    box-shadow: 0 15px 30px rgba(20, 191, 165, 0.16);
}

.account-streak-badge span {
    font-size: 3rem;
    line-height: 1;
}

.account-streak-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2rem;
    padding: 0 0.85rem;
    border-radius: 999px;
    background: #f0ebff;
    color: #6c5ce7;
    font-size: 0.8rem;
    font-weight: 950;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.account-streak-display {
    display: grid;
    justify-items: center;
    gap: 0.25rem;
    margin: 0.85rem 0 1.25rem;
}

.account-streak-number {
    color: #d66a55;
    font-size: clamp(4rem, 21vw, 5.75rem);
    font-weight: 950;
    font-variant-numeric: tabular-nums;
    line-height: 0.92;
}

.account-streak-unit {
    color: #d66a55;
    font-size: clamp(1.55rem, 8vw, 2.15rem);
    font-weight: 950;
    line-height: 1;
}

.account-streak-trail {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.38rem;
    margin-bottom: 1.35rem;
}

.account-streak-day {
    display: grid;
    min-width: 0;
    min-height: 2.75rem;
    place-items: center;
    align-content: center;
    gap: 0.12rem;
    border: 1px solid #e7dfda;
    border-radius: 13px;
    background: #f5f2ef;
    color: #aaa09d;
    font-weight: 950;
}

.account-streak-day.done {
    border-color: rgba(20, 191, 165, 0.34);
    background: #ecfbf7;
    color: #14bfa5;
}

.account-streak-day.today {
    border-color: #6c5ce7;
    background: #6c5ce7;
    color: #ffffff;
    box-shadow: 0 10px 22px rgba(108, 92, 231, 0.22);
}

.account-streak-mark {
    font-size: 0.95rem;
    line-height: 1;
}

.account-streak-day-label {
    color: inherit;
    font-size: 0.62rem;
    line-height: 1;
    opacity: 0.82;
}

.account-streak-mini-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
    margin-bottom: 1.35rem;
}

.account-streak-mini {
    min-width: 0;
    padding: 0.75rem 0.5rem;
    border: 1px solid #eadfd9;
    border-radius: 12px;
    background: #ffffff;
}

.account-streak-mini strong {
    display: block;
    color: #232832;
    font-size: 1.25rem;
    font-weight: 950;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.account-streak-mini span {
    display: block;
    margin-top: 0.35rem;
    color: #8b8280;
    font-size: 0.75rem;
    font-weight: 900;
    line-height: 1.15;
}

.account-streak-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 3.6rem;
    border-radius: 16px;
    background: #6c5ce7;
    color: #ffffff;
    font-size: 1.05rem;
    font-weight: 950;
    text-decoration: none;
    box-shadow: 0 14px 28px rgba(108, 92, 231, 0.28);
}

.account-streak-note {
    margin: 0.9rem 0 0;
    color: #9c908d;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 800;
    line-height: 1.35;
}

@media (min-width: 721px) {
    .account-body {
        width: 100%;
        background: #ffffff;
    }

    .account-body::before {
        display: none;
    }

    .account-page-streak {
        width: 100%;
        max-width: none;
        justify-items: center;
        background: #ffffff;
    }

    .account-page-streak .account-back-link,
    .account-page-streak .account-streak-card,
    .account-page-streak .account-streak-note {
        width: min(100%, 430px);
    }
}

@media (max-width: 720px) {
    .account-page {
        width: 100%;
        padding-top: calc(env(safe-area-inset-top, 0px) + 1rem);
    }

    .account-page-profile {
        width: 100%;
    }

    .account-sheet {
        inset: 0;
        width: 100%;
        height: 100vh;
        height: 100dvh;
        max-height: none;
        margin: 0;
        padding: calc(env(safe-area-inset-top, 0px) + 0.9rem) 1rem calc(env(safe-area-inset-bottom, 0px) + 1rem);
        border: 0;
        border-radius: 0;
        overscroll-behavior: contain;
    }

    .account-stat-grid,
    .account-columns {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 420px) {
    .account-nav {
        max-width: calc(100vw - 1.2rem);
    }

    .account-nav-icon {
        width: 2.15rem;
        height: 2.15rem;
        font-size: 1rem;
    }

    .account-profile {
        padding: 0.9rem;
    }

    .account-page-streak {
        padding-top: calc(env(safe-area-inset-top, 0px) + 0.85rem);
        padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 1rem);
    }

    .account-streak-card {
        padding: 1.25rem 1rem;
    }

    .account-streak-trail,
    .account-streak-mini-grid {
        gap: 0.32rem;
    }

    .account-stat-grid {
        gap: 0.55rem;
    }

    .account-stat {
        padding: 0.75rem;
    }

    .account-stat strong {
        font-size: 1.25rem;
    }
}
