:root {
    --bg-primary: #f8f9fa;
    --bg-card: #ffffff;
    --bg-hover: #f1f3f4;
    --bg-input: #f8f9fa;

    --text-primary: #202124;
    --text-secondary: #5f6368;
    --text-tertiary: #80868b;

    --border-color: #dadce0;
    --border-focus: #1a73e8;

    --accent-blue: #1a73e8;
    --accent-blue-hover: #1557b0;
    --accent-blue-light: #e8f0fe;

    --accent-red: #d93025;
    --accent-red-hover: #b3261e;

    --accent-green: #1e8e3e;
    --accent-orange: #f57c00;

    --shadow-sm:
        0 1px 2px rgba(60, 64, 67, 0.2),
        0 1px 3px 1px rgba(60, 64, 67, 0.1);

    --shadow-md:
        0 1px 3px rgba(60, 64, 67, 0.24),
        0 4px 8px 3px rgba(60, 64, 67, 0.12);

    --shadow-lg:
        0 2px 6px rgba(60, 64, 67, 0.25),
        0 8px 28px rgba(60, 64, 67, 0.2);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-full: 999px;

    --transition-fast:
        0.15s cubic-bezier(0.4, 0, 0.2, 1);

    --transition-smooth:
        0.25s cubic-bezier(0.4, 0, 0.2, 1);

    --avatar-size: 96px;
    --avatar-size-mobile: 76px;
}

/* 基础重置 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    background: var(--bg-primary);
    color: var(--text-primary);

    font-family:
        "Roboto",
        "Google Sans",
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    line-height: 1.5;

    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

button,
input,
textarea,
select {
    font: inherit;
}

button {
    color: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

body.modal-open {
    overflow: hidden;
}

/* 顶部导航栏 */
.top-nav {
    position: sticky;
    top: 0;
    z-index: 100;

    display: flex;
    align-items: center;
    gap: 16px;

    height: 64px;
    padding: 0 24px;

    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--border-color);

    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;

    color: var(--text-primary);
    text-decoration: none;

    min-width: 0;
}

.brand-icon {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
}

.brand-name {
    font-family:
        "Google Sans",
        "Roboto",
        sans-serif;

    font-size: 18px;
    font-weight: 500;
    letter-spacing: -0.01em;
}

.nav-spacer {
    flex: 1;
}

.nav-avatar-sm {
    width: 36px;
    height: 36px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    border: 2px solid transparent;
    border-radius: 50%;

    background:
        linear-gradient(135deg,
            #ff9800,
            #ef6c00);

    background-size: cover;
    background-position: center;

    color: #ffffff;

    font-size: 14px;
    font-weight: 600;

    cursor: pointer;

    transition:
        border-color var(--transition-fast),
        transform var(--transition-fast),
        box-shadow var(--transition-fast);
}

.nav-avatar-sm:hover {
    border-color: #f6b26b;
    transform: scale(1.04);
    box-shadow: 0 2px 8px rgba(245, 124, 0, 0.22);
}

.nav-avatar-sm.has-image {
    color: transparent;
}

/* 页面主体 */
.main-container {
    width: min(100%, 760px);
    margin: 0 auto;
    padding: 36px 24px 64px;
}

.page-header {
    margin-bottom: 28px;
}

.page-header h1 {
    font-family:
        "Google Sans",
        "Roboto",
        sans-serif;

    color: var(--text-primary);

    font-size: 30px;
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: -0.025em;
}

.page-header .subtitle {
    margin-top: 6px;

    color: var(--text-secondary);

    font-size: 14px;
    font-weight: 400;
}

/* 用户头像卡片 */
.profile-hero-card {
    display: flex;
    flex-direction: column;
    align-items: center;

    padding: 38px 32px 32px;
    margin-bottom: 28px;

    background:
        linear-gradient(180deg,
            #ffffff 0%,
            #fffdf9 100%);

    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);

    text-align: center;

    transition:
        box-shadow var(--transition-smooth),
        transform var(--transition-smooth);
}

.profile-hero-card:hover {
    box-shadow: var(--shadow-sm);
}

.avatar-wrapper {
    position: relative;
    display: block;

    width: var(--avatar-size);
    height: var(--avatar-size);

    margin: 0 0 16px;
    padding: 0;

    border: 0;
    border-radius: 50%;

    background: transparent;
    cursor: pointer;

    /* 关键：隐藏圆形范围外的内容 */
    overflow: hidden;

    transition:
        transform var(--transition-fast),
        box-shadow var(--transition-fast);
}

.avatar-wrapper:hover {
    transform: scale(1.035);
    box-shadow: var(--shadow-md);
}

.avatar-image,
.avatar-placeholder {
    /* 关键：让图片和占位头像重合，而不是上下排列 */
    position: absolute;
    inset: 0;

    width: 100%;
    height: 100%;

    border-radius: 50%;
}

.avatar-image {
    display: block;
    object-fit: cover;
}

/* 关键：防止 display:block 覆盖 hidden 属性 */
.avatar-image[hidden] {
    display: none !important;
}

.avatar-image,
.avatar-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;

    background:
        linear-gradient(135deg,
            #ff9800,
            #ef6c00);

    color: #ffffff;
    font-size: 36px;
    font-weight: 600;

    user-select: none;
}

.avatar-placeholder[hidden] {
    display: none !important;
}

.avatar-placeholder.color-1 {
    background:
        linear-gradient(
            135deg,
            #7c4dff,
            #651fff
        );
}

.avatar-placeholder.color-2 {
    background: linear-gradient(135deg, #ff9800, #ef6c00);
}

.avatar-placeholder.color-3 {
    background:
        linear-gradient(
            135deg,
            #ea4335,
            #d93025
        );
}

.avatar-placeholder.color-4 {
    background: linear-gradient(135deg, #34a853, #1e8e3e);
}

.avatar-overlay {
    position: absolute;
    inset: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 50%;

    background: rgba(32, 33, 36, 0.55);

    opacity: 0;

    pointer-events: none;

    transition: opacity var(--transition-fast);
}

.avatar-wrapper:hover .avatar-overlay,
.avatar-wrapper:focus-visible .avatar-overlay {
    opacity: 1;
}

.camera-icon {
    width: 29px;
    height: 29px;

    fill: #ffffff;

    filter:
        drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

.profile-username-display {
    color: var(--text-primary);

    font-family:
        "Google Sans",
        "Roboto",
        sans-serif;

    font-size: 23px;
    font-weight: 500;
    line-height: 1.3;
    letter-spacing: -0.015em;

    word-break: break-word;
}

.profile-name-display {
    margin-top: 4px;

    color: var(--text-secondary);

    font-size: 14px;

    word-break: break-word;
}

/* 信息分组 */
.section-block {
    margin-bottom: 28px;
}

.section-heading {
    margin: 0 4px 12px;
}

.section-heading h2 {
    color: var(--text-primary);

    font-family:
        "Google Sans",
        "Roboto",
        sans-serif;

    font-size: 18px;
    font-weight: 500;
}

.section-heading p {
    margin-top: 2px;

    color: var(--text-secondary);

    font-size: 13px;
}

.info-card {
    overflow: hidden;

    background: var(--bg-card);

    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);

    transition: box-shadow var(--transition-smooth);
}

.info-card:hover {
    box-shadow: var(--shadow-sm);
}

.card-section {
    width: 100%;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;

    padding: 21px 28px;

    border: 0;
    border-bottom: 1px solid var(--border-color);

    background: transparent;

    text-align: left;

    cursor: default;

    transition: background var(--transition-fast);
}

.card-section:last-child {
    border-bottom: 0;
}

button.card-section {
    appearance: none;
}

.card-section.editable {
    cursor: pointer;
}

.card-section.editable:hover {
    background: var(--bg-hover);
}

.card-section.editable:focus-visible {
    position: relative;
    z-index: 1;

    outline: 2px solid var(--accent-blue);
    outline-offset: -2px;
}

.section-info {
    display: block;
    flex: 1;
    min-width: 0;
}

.section-label {
    display: block;

    margin-bottom: 3px;

    color: var(--text-secondary);

    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.045em;

    text-transform: uppercase;
}

.section-value {
    display: block;

    color: var(--text-primary);

    font-size: 15px;
    font-weight: 400;
    line-height: 1.45;

    word-break: break-word;
}

.section-value.placeholder-text {
    color: var(--text-tertiary);
    font-style: italic;
}

.edit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;

    flex-shrink: 0;

    min-height: 38px;
    padding: 8px 16px;

    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);

    background: transparent;
    color: var(--accent-blue);

    font-family:
        "Google Sans",
        "Roboto",
        sans-serif;

    font-size: 13px;
    font-weight: 500;

    transition:
        color var(--transition-fast),
        background var(--transition-fast),
        border-color var(--transition-fast),
        box-shadow var(--transition-fast),
        transform var(--transition-fast);
}

.editable:hover .edit-btn {
    background: var(--accent-blue-light);
    border-color: var(--accent-blue);

    box-shadow:
        0 1px 3px rgba(26, 115, 232, 0.18);
}

.editable:active .edit-btn {
    transform: scale(0.97);
}

.edit-btn.danger-btn {
    color: var(--accent-red);
    border-color: transparent;
}

.editable:hover .edit-btn.danger-btn {
    color: var(--accent-red-hover);
    background: #fce8e6;
    border-color: var(--accent-red);

    box-shadow:
        0 1px 3px rgba(217, 48, 37, 0.18);
}

.btn-icon {
    width: 16px;
    height: 16px;

    fill: currentColor;

    flex-shrink: 0;
}

.read-only-tag {
    flex-shrink: 0;

    padding: 6px 12px;

    border-radius: var(--radius-full);

    background: #f1f3f4;
    color: var(--text-secondary);

    font-size: 12px;
    font-weight: 500;
}

/* 弹窗 */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 18px;

    background: rgba(32, 33, 36, 0.56);

    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);

    animation: fade-in 0.2s ease both;
}

.modal-backdrop.closing {
    animation: fade-out 0.18s ease both;
}

.modal-dialog {
    width: min(100%, 490px);
    max-height: calc(100vh - 36px);

    overflow: auto;

    background: var(--bg-card);

    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: var(--radius-lg);

    box-shadow: var(--shadow-lg);

    animation:
        modal-in 0.25s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.modal-dialog.closing {
    animation:
        modal-out 0.18s ease both;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;

    padding: 20px 24px 16px;

    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    color: var(--text-primary);

    font-family:
        "Google Sans",
        "Roboto",
        sans-serif;

    font-size: 19px;
    font-weight: 500;
    letter-spacing: -0.015em;
}

.modal-close-btn {
    width: 38px;
    height: 38px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    flex-shrink: 0;

    border: 0;
    border-radius: 50%;

    background: transparent;
    color: var(--text-secondary);

    cursor: pointer;

    transition:
        color var(--transition-fast),
        background var(--transition-fast);
}

.modal-close-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-close-btn:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
}

.modal-close-btn svg {
    width: 20px;
    height: 20px;

    fill: currentColor;
}

.modal-body {
    padding: 22px 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;

    padding: 16px 24px 20px;

    border-top: 1px solid var(--border-color);
}

/* 表单 */
.form-group {
    margin-bottom: 20px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-label {
    display: block;

    margin-bottom: 7px;

    color: var(--text-primary);

    font-size: 13px;
    font-weight: 500;
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;

    padding: 12px 14px;

    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);

    outline: none;

    background: var(--bg-input);
    color: var(--text-primary);

    font-family:
        "Roboto",
        sans-serif;

    font-size: 15px;
    line-height: 1.45;

    transition:
        border-color var(--transition-fast),
        box-shadow var(--transition-fast),
        background var(--transition-fast);
}

.form-input:hover,
.form-textarea:hover,
.form-select:hover {
    border-color: #bdc1c6;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    background: #ffffff;
    border-color: var(--border-focus);

    box-shadow:
        0 0 0 3px rgba(26, 115, 232, 0.12);
}

.form-input.error,
.form-textarea.error,
.form-select.error {
    border-color: var(--accent-red);

    box-shadow:
        0 0 0 3px rgba(217, 48, 37, 0.1);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: #9aa0a6;
}

.form-textarea {
    min-height: 105px;
    max-height: 240px;

    resize: vertical;
}

.form-select {
    appearance: none;
    -webkit-appearance: none;

    padding-right: 46px;

    cursor: pointer;
}

.select-wrapper {
    position: relative;
}

.select-wrapper::after {
    content: "";

    position: absolute;
    top: 50%;
    right: 17px;

    width: 8px;
    height: 8px;

    border-right: 2px solid var(--text-secondary);
    border-bottom: 2px solid var(--text-secondary);

    transform:
        translateY(-70%) rotate(45deg);

    pointer-events: none;
}

input[type="date"].form-input {
    min-height: 48px;
}

.form-error-msg {
    display: none;

    margin-top: 5px;

    color: var(--accent-red);

    font-size: 12px;
}

.form-error-msg.visible {
    display: block;
}

.form-hint {
    margin-top: 5px;

    color: var(--text-tertiary);

    font-size: 12px;
}

.form-hint[data-level="weak"] {
    color: #ea4335;
}

.form-hint[data-level="fair"] {
    color: #f29900;
}

.form-hint[data-level="good"] {
    color: #1a73e8;
}

.form-hint[data-level="strong"] {
    color: #188038;
}

/* 密码输入框 */
.password-field {
    position: relative;
}

.password-field .form-input {
    padding-right: 68px;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 7px;

    min-width: 52px;
    padding: 7px 8px;

    transform: translateY(-50%);

    border: 0;
    border-radius: 6px;

    background: transparent;
    color: var(--accent-blue);

    font-size: 12px;
    font-weight: 500;

    cursor: pointer;
}

.password-toggle:hover {
    background: var(--accent-blue-light);
}

.password-strength {
    height: 4px;

    margin-top: 9px;

    overflow: hidden;

    border-radius: 2px;

    background: #e0e0e0;
}

.strength-bar {
    width: 0;
    height: 100%;

    border-radius: 2px;

    transition:
        width 0.3s ease,
        background 0.3s ease;
}

.strength-weak {
    width: 25%;
    background: #ea4335;
}

.strength-fair {
    width: 50%;
    background: #fbbc04;
}

.strength-good {
    width: 75%;
    background: #4285f4;
}

.strength-strong {
    width: 100%;
    background: #34a853;
}

/* 普通按钮 */
.btn {
    min-width: 82px;
    min-height: 42px;

    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;

    padding: 10px 22px;

    border: 0;
    border-radius: var(--radius-full);

    font-family:
        "Google Sans",
        "Roboto",
        sans-serif;

    font-size: 14px;
    font-weight: 500;
    line-height: 1.3;

    cursor: pointer;

    transition:
        background var(--transition-fast),
        color var(--transition-fast),
        border-color var(--transition-fast),
        box-shadow var(--transition-fast),
        transform var(--transition-fast);
}

.btn:active:not(:disabled) {
    transform: scale(0.97);
}

.btn:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
}

.btn:disabled {
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: var(--accent-blue);
    color: #ffffff;

    box-shadow:
        0 1px 3px rgba(26, 115, 232, 0.3);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-blue-hover);

    box-shadow:
        0 2px 7px rgba(26, 115, 232, 0.34);
}

.btn-primary:disabled {
    background: #a8c7fa;
    box-shadow: none;
}

.btn-outline {
    border: 1px solid var(--border-color);

    background: transparent;
    color: var(--accent-blue);
}

.btn-outline:hover:not(:disabled) {
    background: var(--accent-blue-light);
    border-color: var(--accent-blue);
}

.btn-danger {
    background: var(--accent-red);
    color: #ffffff;

    box-shadow:
        0 1px 3px rgba(217, 48, 37, 0.28);
}

.btn-danger:hover:not(:disabled) {
    background: var(--accent-red-hover);

    box-shadow:
        0 2px 7px rgba(217, 48, 37, 0.34);
}

.btn-danger:disabled {
    background: #e8a09a;
    box-shadow: none;
}

.btn-loading {
    position: relative;

    color: transparent !important;

    pointer-events: none;
}

.btn-loading::after {
    content: "";

    position: absolute;

    width: 18px;
    height: 18px;

    border: 2px solid rgba(255, 255, 255, 0.45);
    border-top-color: #ffffff;
    border-radius: 50%;

    animation: spin 0.65s linear infinite;
}

.btn-outline.btn-loading::after {
    border-color: rgba(26, 115, 232, 0.25);
    border-top-color: var(--accent-blue);
}

/* Toast */
.toast-container {
    position: fixed;
    left: 50%;
    bottom: 28px;
    z-index: 2000;

    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 9px;

    transform: translateX(-50%);

    pointer-events: none;
}

.toast {
    max-width: min(90vw, 520px);

    padding: 12px 20px;

    overflow: hidden;

    border-radius: var(--radius-full);

    background: #323232;
    color: #ffffff;

    box-shadow: var(--shadow-md);

    font-size: 14px;
    font-weight: 500;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;

    pointer-events: auto;

    animation:
        toast-in 0.3s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.toast.success {
    border-left: 4px solid #34a853;
}

.toast.error {
    border-left: 4px solid #ea4335;
}

.toast.info {
    border-left: 4px solid #4285f4;
}

.toast.removing {
    animation:
        toast-out 0.25s ease both;
}

/* 文件输入 */
.hidden-file-input {
    position: absolute;

    width: 1px;
    height: 1px;

    overflow: hidden;

    opacity: 0;

    pointer-events: none;
}

/* 动画 */
@keyframes fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fade-out {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

@keyframes modal-in {
    from {
        opacity: 0;
        transform:
            translateY(24px) scale(0.96);
    }

    to {
        opacity: 1;
        transform:
            translateY(0) scale(1);
    }
}

@keyframes modal-out {
    from {
        opacity: 1;
        transform:
            translateY(0) scale(1);
    }

    to {
        opacity: 0;
        transform:
            translateY(16px) scale(0.96);
    }
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toast-out {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(-14px);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* 平板和手机 */
@media (max-width: 600px) {
    .top-nav {
        height: 58px;
        padding: 0 16px;
    }

    .brand-icon {
        width: 34px;
        height: 34px;
    }

    .brand-name {
        font-size: 16px;
    }

    .nav-avatar-sm {
        width: 34px;
        height: 34px;
    }

    .main-container {
        padding: 24px 16px 48px;
    }

    .page-header {
        margin-bottom: 22px;
    }

    .page-header h1 {
        font-size: 26px;
    }

    .profile-hero-card {
        padding: 30px 20px 25px;
        margin-bottom: 24px;
        border-radius: var(--radius-md);
    }

    .avatar-wrapper {
        width: var(--avatar-size-mobile);
        height: var(--avatar-size-mobile);
    }

    .avatar-placeholder {
        font-size: 29px;
    }

    .profile-username-display {
        font-size: 20px;
    }

    .section-block {
        margin-bottom: 24px;
    }

    .info-card {
        border-radius: var(--radius-md);
    }

    .card-section {
        padding: 18px 20px;
        gap: 12px;
    }

    .edit-btn {
        min-width: 40px;
        padding: 9px 12px;
    }

    .modal-backdrop {
        padding: 12px;
        align-items: flex-end;
    }

    .modal-dialog {
        width: 100%;
        max-height: calc(100vh - 24px);

        border-radius:
            var(--radius-lg) var(--radius-lg) 0 0;
    }

    .modal-header {
        padding: 18px 18px 14px;
    }

    .modal-body {
        padding: 18px;
    }

    .modal-footer {
        padding: 14px 18px 18px;

        flex-wrap: wrap;
        gap: 9px;
    }

    .modal-footer .btn {
        flex: 1;
    }

    .toast {
        padding: 11px 16px;
        font-size: 13px;
    }
}

@media (max-width: 430px) {
    .brand-name {
        display: none;
    }

    .page-header h1 {
        font-size: 24px;
    }

    .card-section {
        align-items: flex-start;
    }

    .edit-btn {
        font-size: 0;
        gap: 0;

        width: 38px;
        min-width: 38px;
        padding: 9px;
    }

    .edit-btn .btn-icon {
        width: 17px;
        height: 17px;
    }

    .read-only-tag {
        padding: 5px 9px;
        font-size: 11px;
    }
}

@media (max-width: 360px) {
    .main-container {
        padding-inline: 12px;
    }

    .profile-hero-card {
        padding-inline: 14px;
    }

    .card-section {
        padding: 16px;
    }

    .modal-backdrop {
        padding-inline: 0;
        padding-bottom: 0;
    }
}

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;

        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;

        transition-duration: 0.01ms !important;
    }
}
