.resident-card {
    width: 100%;
    max-width: 380px;
    aspect-ratio: 3 / 2;
    margin: 0 auto;
    position: relative;
    z-index: 1;
    color: #122540;
    border-radius: 20px;
    overflow: hidden;
    isolation: isolate;
    background-color: #f8f0df;
    background-image: url('../assets/profile/resident-card-background.webp?v=20260729b');
    background-repeat: no-repeat;
    background-position: center;
    background-size: 100% 100%;
    box-shadow:
        0 18px 40px rgba(0, 0, 0, 0.32),
        0 2px 0 rgba(255, 255, 255, 0.65) inset;
    touch-action: pan-y;
}

.resident-card-edit-actions {
    position: absolute;
    top: calc(8% - 4px);
    right: 18px;
    z-index: 6;
}

.resident-card-edit-actions .app-icon-action-btn {
    padding: 3px;
}

.resident-card-edit-actions .app-icon-action-btn img {
    width: 22px;
    height: 22px;
}

.resident-card[data-card-theme="silver"] {
    background-color: #f7f8fa;
    background-image: url('../assets/profile/resident-card-background-silver.webp?v=20260729b');
}

.resident-card[data-card-theme="dawn"] {
    background-color: #faf6fb;
    background-image: url('../assets/profile/resident-card-background-dawn.webp?v=20260729b');
}

.resident-card[data-card-theme="moonblue"] {
    color: #eef6ff;
    background-color: #294360;
    background-image: url('../assets/profile/resident-card-background-moonblue.webp?v=20260729b');
}

.resident-card[data-card-theme="moonblue"] .resident-card-heading h2,
.resident-card[data-card-theme="moonblue"] .resident-card-row dd {
    color: #f5f9ff;
    text-shadow: 0 1px 3px rgba(3, 17, 35, 0.42);
}

.resident-card[data-card-theme="moonblue"] .resident-card-heading p,
.resident-card[data-card-theme="moonblue"] .resident-card-registration,
.resident-card[data-card-theme="moonblue"] .resident-card-registration span,
.resident-card[data-card-theme="moonblue"] .resident-card-row dt {
    color: #cedceb;
    text-shadow: 0 1px 2px rgba(3, 17, 35, 0.36);
}

.resident-card[data-card-theme="moonblue"] .resident-card-row {
    border-bottom-color: rgba(224, 237, 249, 0.28);
}

.resident-card[data-card-theme="moonblue"] .resident-card-row dt::before {
    color: #b8d7eb;
}

.resident-card[data-card-theme="moonblue"][data-editing="true"] .resident-card-row:has(.resident-card-field-editor) {
    background: rgba(211, 231, 247, 0.12);
}

.resident-card-theme-editor {
    width: calc(100% - 24px);
    max-width: 356px;
    margin: -7px auto 0;
    padding: 18px 10px 11px;
    position: relative;
    z-index: 0;
    color: #fff8e8;
    border: 1px solid rgba(232, 194, 116, 0.3);
    border-top: 0;
    border-radius: 0 0 15px 15px;
    background:
        linear-gradient(90deg, transparent, rgba(239, 202, 124, 0.15), transparent) top / 76% 1px no-repeat,
        linear-gradient(145deg, rgba(15, 43, 74, 0.98), rgba(6, 27, 53, 0.99));
    box-shadow: 0 13px 24px rgba(0, 0, 0, 0.18);
}

.resident-card-theme-editor[hidden] {
    display: none;
}

.resident-card-theme-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.resident-card-theme-heading h2,
.resident-card-theme-heading p {
    margin: 0;
}

.resident-card-theme-heading h2 {
    color: #f2cb7d;
    font-family: "NanumSquareNeo", sans-serif;
    font-size: 12px;
    font-weight: 800;
}

.resident-card-theme-heading p {
    margin-top: 2px;
    color: rgba(255, 248, 232, 0.65);
    font-size: 9px;
}

.resident-card-theme-heading > span {
    color: #f2cb7d;
}

.resident-card-theme-carousel {
    position: relative;
}

.resident-card-theme-arrow {
    width: 22px;
    height: 32px;
    padding: 0 0 2px;
    position: absolute;
    top: 50%;
    z-index: 2;
    display: grid;
    place-items: center;
    transform: translateY(-50%);
    border: 1px solid rgba(239, 202, 124, 0.3);
    border-radius: 999px;
    color: #f2cb7d;
    background: rgba(255, 255, 255, 0.045);
    font-family: Georgia, serif;
    font-size: 19px;
    line-height: 1;
    cursor: pointer;
    transition: opacity 0.16s ease, transform 0.16s ease, background-color 0.16s ease;
}

.resident-card-theme-arrow:first-child {
    left: -8px;
}

.resident-card-theme-arrow:last-child {
    right: -8px;
}

.resident-card-theme-arrow:active:not(:disabled) {
    transform: translateY(-50%) scale(0.93);
    background: rgba(239, 202, 124, 0.13);
}

.resident-card-theme-arrow:disabled {
    visibility: hidden;
    opacity: 0;
    cursor: default;
}

.resident-card-theme-options {
    width: 100%;
    min-width: 0;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: calc(31.25% - 4.7px);
    gap: 5px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    touch-action: pan-x;
}

.resident-card-theme-options::-webkit-scrollbar {
    display: none;
}

.resident-card-theme-option {
    min-width: 0;
    padding: 2px 2px 4px;
    scroll-snap-align: start;
    color: rgba(255, 248, 232, 0.76);
    border: 0;
    border-radius: 7px;
    background: transparent;
    font: inherit;
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
    transition: color 160ms ease, transform 160ms ease;
}

.resident-card-theme-option:active {
    transform: scale(0.98);
}

.resident-card-theme-option[aria-checked="true"] {
    color: #fff7df;
}

.resident-card-theme-name,
.resident-card-theme-milestone {
    display: block;
    line-height: 1.25;
}

.resident-card-theme-milestone {
    margin-top: 2px;
    color: rgba(239, 202, 124, 0.72);
    font-size: 8px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.resident-card-theme-option[aria-checked="true"] .resident-card-theme-milestone {
    color: #f2cb7d;
}

.resident-card-theme-thumbnail {
    display: block;
    width: 100%;
    aspect-ratio: 3 / 2;
    margin-bottom: 5px;
    border-radius: 6px;
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
    border: 2px solid transparent;
    box-shadow: 0 3px 9px rgba(0, 0, 0, 0.22);
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.resident-card-theme-option[aria-checked="true"] .resident-card-theme-thumbnail {
    border-color: #efca7c;
    box-shadow:
        0 0 0 1px rgba(255, 247, 222, 0.32),
        0 4px 12px rgba(0, 0, 0, 0.28);
}

.resident-card-theme-thumbnail.is-gold {
    background-image: url('../assets/profile/resident-card-background.webp?v=20260729b');
}

.resident-card-theme-thumbnail.is-silver {
    background-image: url('../assets/profile/resident-card-background-silver.webp?v=20260729b');
}

.resident-card-theme-thumbnail.is-dawn {
    background-image: url('../assets/profile/resident-card-background-dawn.webp?v=20260729b');
}

.resident-card-theme-thumbnail.is-moonblue {
    background-image: url('../assets/profile/resident-card-background-moonblue.webp?v=20260729b');
}

.resident-card,
.resident-card :is(h2, p, dt, dd) {
    user-select: text;
    -webkit-user-select: text;
}

.resident-card[data-loading="true"]::before {
    content: '별주민 정보를 불러오는 중…';
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 28px;
    color: #765b35;
    font-size: 12px;
    font-weight: 800;
    background: rgba(250, 244, 232, 0.82);
    backdrop-filter: blur(2px);
}

.resident-card[data-loading="true"][data-loading-mode="saving"]::before {
    content: '별주민 정보를 저장 중…';
}

.resident-card[data-loading="true"]::after {
    content: '✦';
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 21;
    width: 18px;
    margin: -19px 0 0 -9px;
    color: #d2a557;
    font-size: 18px;
    line-height: 1;
    text-align: center;
    text-shadow: 0 0 8px rgba(210, 165, 87, 0.5);
    animation: profile-photo-saving-spin 1.05s linear infinite;
}

.resident-card-heading {
    position: absolute;
    z-index: 2;
    top: 8%;
    left: 8%;
    right: 8%;
    text-align: center;
    pointer-events: auto;
}

.resident-card-heading h2 {
    margin: 0;
    color: #132745;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: clamp(10px, 3vw, 12px);
    line-height: 1.05;
    letter-spacing: 0.065em;
}

.resident-card-heading p {
    margin: 1px 0 0;
    color: #987143;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: clamp(5px, 1.7vw, 8px);
    font-weight: 700;
    letter-spacing: 0.12em;
}

.resident-card-body {
    position: absolute;
    z-index: 3;
    inset: 20% 7% 7%;
    display: grid;
    grid-template-columns: 35% minmax(0, 1fr);
    gap: 5%;
}

.resident-card-portrait-column {
    min-width: 0;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 0;
}

.resident-card-portrait {
    width: calc(104% - 12px);
    flex: 0 0 calc(100% - 36px);
    min-height: 0;
    margin-top: 5px;
    position: relative;
    display: grid;
    place-items: center;
    overflow: hidden;
    border-radius: 12px;
    cursor: pointer;
    transform: translateX(calc(3.5% + 3px));
    touch-action: pan-y;
    background:
        radial-gradient(circle at 50% 34%, rgba(255, 255, 255, 0.16), transparent 46%),
        linear-gradient(160deg, #17385d 0%, #081d39 100%);
}

.resident-card-portrait > img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    border-radius: 12px;
    pointer-events: none;
}

.resident-card-portrait:focus-within {
    outline: 2px solid rgba(255, 249, 222, 0.9);
    outline-offset: 2px;
}

.resident-card-photo-placeholder {
    display: grid;
    place-items: center;
    gap: 3px;
    color: rgba(255, 244, 216, 0.82);
    font-size: clamp(7px, 2.2vw, 10px);
    font-weight: 800;
    text-align: center;
}

.resident-card-photo-placeholder[hidden] {
    display: none;
}

.resident-card-portrait[data-photo-loading="true"] {
    cursor: progress;
}

.resident-card-portrait[data-photo-loading="true"] .resident-card-photo-placeholder {
    display: grid;
    color: rgba(255, 244, 216, 0.78);
}

.resident-card-portrait[data-photo-loading="true"] .resident-card-photo-placeholder::before {
    content: '✦';
    color: #f2cd83;
    font-size: 15px;
    line-height: 1;
    text-shadow: 0 0 8px rgba(242, 205, 131, 0.62);
    animation: profile-photo-saving-spin 1.05s linear infinite;
}

.resident-card-portrait[data-photo-loading="true"] .resident-card-photo-icon {
    display: none;
}

.resident-card-photo-icon {
    width: 27px;
    height: 27px;
    border: 1px solid rgba(238, 197, 119, 0.7);
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: #f2cd83;
    font-size: 20px;
    font-weight: 400;
    line-height: 1;
}

.resident-card-registration {
    max-width: 112%;
    margin: 9px 0 0;
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 3px;
    color: #76552e;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: clamp(6px, 1.9vw, 8px);
    line-height: 1.1;
    letter-spacing: 0.025em;
    white-space: nowrap;
    transform: translateX(calc(3.5% + 3px));
}

.resident-card-registration span,
.resident-card-registration time {
    font-family: Georgia, 'Times New Roman', serif;
}

.resident-card-registration span {
    color: #b1854b;
    font-weight: 700;
}

.resident-card-details {
    min-width: 0;
    margin: 0;
    padding: 4% 2% 2% 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    transform: translateY(-9px);
}

.resident-card-row {
    min-height: 0;
    flex: 1 1 0;
    display: grid;
    grid-template-columns: minmax(58px, 42%) minmax(0, 1fr);
    align-items: center;
    gap: 5px;
    border-bottom: 1px dashed rgba(161, 116, 63, 0.35);
}

.resident-card-row:last-child {
    border-bottom: 0;
}

.resident-card-row dt,
.resident-card-row dd {
    margin: 0;
    min-width: 0;
}

.resident-card-row dt {
    color: #765d3e;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: clamp(6px, 1.9vw, 8px);
    white-space: nowrap;
}

.resident-card-row dt::before {
    content: '✦';
    color: #c39145;
    margin-right: 5px;
}

.resident-card-row dd {
    overflow: hidden;
    color: #102441;
    font-size: clamp(8px, 2.7vw, 12px);
    font-weight: 800;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.resident-card-field-editor {
    min-width: 0;
    align-items: center;
    gap: 3px;
}

.resident-card-field-editor label {
    min-width: 0;
}

.resident-card-field-editor select {
    max-width: 100%;
    height: 21px;
    padding: 0 13px 0 4px;
    border: 1px solid rgba(151, 112, 61, 0.45);
    border-radius: 5px;
    color: #102441;
    background-color: rgba(255, 252, 243, 0.94);
    font-family: inherit;
    font-size: clamp(7px, 2.3vw, 10px);
    line-height: 1;
    font-weight: 700;
}

.resident-card-birthday-editor select {
    width: 53px;
}

.resident-card-birthday-editor #resident-card-birthday-day {
    width: 58px;
}

.resident-card[data-editing="true"] .resident-card-row:has(.resident-card-field-editor) {
    background: rgba(255, 248, 225, 0.34);
}

.resident-card[data-editing="true"] .resident-card-row dd {
    overflow: visible;
    text-overflow: clip;
}

.resident-card-field-editor select:focus-visible {
    outline: 2px solid #fff2cf;
    outline-offset: 2px;
}

.profile-header-save-btn:disabled {
    cursor: wait;
    opacity: 0.58;
}

.resident-card-seal {
    width: 52px;
    aspect-ratio: 1;
    position: absolute;
    z-index: 4;
    right: 3.2%;
    bottom: 3.8%;
    border: 1px solid rgba(151, 117, 202, 0.55);
    border-radius: 50%;
    opacity: 0.84;
    background:
        radial-gradient(circle, #fff6c9 0 12%, transparent 13%),
        conic-gradient(from 30deg, #9fbeff, #dec3ff, #ffe6a2, #9dd9e9, #9fbeff);
    box-shadow:
        0 0 0 3px rgba(255, 255, 255, 0.42) inset,
        0 0 0 5px rgba(123, 145, 220, 0.18) inset;
    clip-path: polygon(50% 0%, 61% 7%, 74% 5%, 83% 17%, 95% 24%, 93% 38%, 100% 50%, 93% 62%, 95% 76%, 83% 83%, 74% 95%, 61% 93%, 50% 100%, 39% 93%, 26% 95%, 17% 83%, 5% 76%, 7% 62%, 0% 50%, 7% 38%, 5% 24%, 17% 17%, 26% 5%, 39% 7%);
}

.resident-card-seal::after {
    content: '★';
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: rgba(255, 255, 255, 0.92);
    font-size: 20px;
    text-shadow: 0 1px 4px rgba(48, 64, 121, 0.45);
}

#view-profile.is-friend-profile .resident-card-seal {
    border-color: rgba(177, 104, 206, 0.66);
    background:
        radial-gradient(circle, #fff1fb 0 12%, transparent 13%),
        conic-gradient(from 28deg, #8e81e8, #d68fd7, #f0a4c9, #b799ee, #8e81e8);
    box-shadow:
        0 0 0 3px rgba(255, 244, 253, 0.48) inset,
        0 0 0 5px rgba(165, 111, 210, 0.2) inset,
        0 3px 11px rgba(171, 93, 197, 0.2);
}

#view-profile.is-friend-profile .resident-card-seal::after {
    color: rgba(255, 247, 253, 0.96);
    text-shadow:
        0 1px 4px rgba(97, 54, 139, 0.52),
        0 0 7px rgba(255, 205, 239, 0.48);
}


.profile-photo-editor {
    position: absolute;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    padding: 14px;
    background: rgba(2, 13, 31, 0.62);
    backdrop-filter: blur(2px);
}

.profile-photo-editor[hidden] {
    display: none;
}

.profile-photo-editor-panel {
    width: min(286px, 100%);
    max-height: calc(100dvh - 28px);
    overflow-y: auto;
    padding: 16px 16px 15px;
    border: 1px solid rgba(226, 188, 113, 0.58);
    border-radius: 20px;
    color: #fff8e8;
    background: linear-gradient(180deg, #102b4b 0%, #071a34 100%);
    box-shadow: 0 22px 58px rgba(0, 0, 0, 0.46);
}

.profile-photo-editor-viewport {
    width: min(190px, 68vw);
    aspect-ratio: 7 / 10;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
    border: 2px solid #e4ba70;
    border-radius: 16px;
    cursor: grab;
    touch-action: none;
    background: #07182e;
    box-shadow: 0 0 0 4px rgba(255, 244, 217, 0.16);
}

.profile-photo-editor-viewport.is-dragging {
    cursor: grabbing;
}

.profile-photo-editor-viewport > img {
    max-width: none;
    position: absolute;
    left: 50%;
    top: 50%;
    transform-origin: center;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
}

.profile-photo-editor-guide {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(90deg, transparent 33.1%, rgba(255, 255, 255, 0.18) 33.3% 33.7%, transparent 33.9% 66.1%, rgba(255, 255, 255, 0.18) 66.3% 66.7%, transparent 66.9%),
        linear-gradient(transparent 33.1%, rgba(255, 255, 255, 0.18) 33.3% 33.7%, transparent 33.9% 66.1%, rgba(255, 255, 255, 0.18) 66.3% 66.7%, transparent 66.9%);
}

.profile-photo-editor-delete-notice {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: grid;
    place-items: center;
    margin: 0;
    padding: 22px;
    color: #fff1d0;
    background: rgba(5, 21, 43, 0.88);
    font-size: 12px;
    font-weight: 800;
    line-height: 1.6;
    text-align: center;
}

.profile-photo-editor-delete-notice[hidden] {
    display: none;
}

.profile-photo-editor-description {
    margin: 9px 2px 0;
    color: rgba(255, 255, 255, 0.68);
    font-size: 10px;
    line-height: 1.45;
    text-align: center;
}

.profile-photo-editor-tools {
    display: grid;
    grid-template-columns: 1.35fr 1fr;
    gap: 8px;
    margin: 10px 2px 0;
}

.profile-photo-editor-tools button {
    min-height: 32px;
    padding: 6px 10px;
    border: 1px solid rgba(229, 190, 113, 0.34);
    border-radius: 10px;
    color: #f7dfb1;
    background: rgba(255, 255, 255, 0.055);
    font-family: inherit;
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s, background-color 0.2s;
}

.profile-photo-editor-tools button[aria-pressed="true"] {
    color: #fff4df;
    border-color: rgba(238, 160, 151, 0.62);
    background: rgba(153, 62, 70, 0.34);
}

.profile-photo-editor-tools button:disabled {
    cursor: wait;
    opacity: 0.52;
}

.profile-photo-editor-tools button:active:not(:disabled) {
    transform: scale(0.97);
}

.profile-photo-editor-zoom {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    margin: 12px 2px 0;
    color: #f5d79e;
    font-size: 11px;
    font-weight: 800;
}

.profile-photo-editor-zoom input {
    width: 100%;
    accent-color: #e3b965;
}

.profile-photo-editor-saving {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    margin: 11px 2px -3px;
    color: #f6d995;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.02em;
}

.profile-photo-editor-saving[hidden] {
    display: none;
}

.profile-photo-editor-saving-star {
    display: inline-block;
    color: #ffe1a0;
    font-size: 14px;
    line-height: 1;
    text-shadow: 0 0 8px rgba(255, 220, 145, 0.72);
    animation: profile-photo-saving-spin 1.05s linear infinite;
}

@keyframes profile-photo-saving-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .profile-photo-editor-saving-star,
    .resident-card[data-loading="true"]::after,
    .resident-card-portrait[data-photo-loading="true"] .resident-card-photo-placeholder::before {
        animation: none;
    }
}

.profile-photo-editor-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 13px;
}

.profile-photo-editor-actions button {
    min-height: 0;
    padding: 8px 14px;
    border: 1px solid rgba(229, 190, 113, 0.45);
    border-radius: 10px;
    color: #f9e7c4;
    background: rgba(255, 255, 255, 0.07);
    font-family: inherit;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s, background-color 0.2s;
}

.profile-photo-editor-actions button:last-child {
    color: #10213b;
    background: linear-gradient(180deg, #ffe3aa 0%, #dbad5a 100%);
}

.profile-photo-editor-actions button:disabled {
    cursor: wait;
    opacity: 0.58;
}

.profile-photo-editor-actions button:active:not(:disabled) {
    transform: scale(0.95);
}

@media screen and (max-width: 350px) {
    .resident-card-row {
        grid-template-columns: minmax(52px, 43%) minmax(0, 1fr);
    }

    .resident-card-row dt::before {
        margin-right: 3px;
    }

    .resident-card-seal {
        width: 44px;
    }
}
