/* ============================================================
   全站用户系统 · 样式
   和 zhouai 保持同一套黑白语言：只有灰阶，靠明度/边框/字重分层
   ============================================================ */

:root {
    --bg:            #ffffff;
    --bg-soft:       #fafafa;
    --surface:       #f5f5f5;
    --surface-2:     #ededed;
    --border:        #e4e4e4;
    --border-strong: #d0d0d0;

    /* 页面底色：和网站首页 index.html 保持一致（#f5f5f7） */
    --page-bg:       #f5f5f7;
    --card-bg:       #ffffff;
    --card-border:   rgba(0, 0, 0, .06);

    --text:          #101010;
    --text-2:        #565656;
    --text-3:        #6b6b6b;

    --invert-bg:     #101010;
    --invert-text:   #ffffff;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .05);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, .08);

    --radius:    14px;
    --radius-lg: 20px;
    --pill:      999px;

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
            "Hiragino Sans GB", "Microsoft YaHei", Roboto, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --speed: .18s;
}

body.dark-mode {
    --bg:            #0a0a0a;
    --bg-soft:       #101010;
    --surface:       #161616;
    --surface-2:     #1e1e1e;
    --border:        #262626;
    --border-strong: #3a3a3a;
    --text:          #f4f4f4;
    --text-2:        #a6a6a6;
    --text-3:        #8a8a8a;
    --invert-bg:     #f4f4f4;
    --invert-text:   #0a0a0a;
    --page-bg:       #0a0a0a;
    --card-bg:       #101010;
    --card-border:   rgba(255, 255, 255, .08);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, .5);
}

@media (prefers-color-scheme: dark) {
    body:not(.light-mode):not(.dark-mode) {
        --bg:            #0a0a0a;
        --bg-soft:       #101010;
        --surface:       #161616;
        --surface-2:     #1e1e1e;
        --border:        #262626;
        --border-strong: #3a3a3a;
        --text:          #f4f4f4;
        --text-2:        #a6a6a6;
        --text-3:        #8a8a8a;
        --invert-bg:     #f4f4f4;
        --invert-text:   #0a0a0a;
        --page-bg:       #0a0a0a;
        --card-bg:       #101010;
        --card-border:   rgba(255, 255, 255, .08);
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
        --shadow-md: 0 4px 16px rgba(0, 0, 0, .5);
    }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    min-height: 100vh;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.65;
    color: var(--text);
    background: var(--page-bg);
    -webkit-font-smoothing: antialiased;
    transition: background var(--speed), color var(--speed);
}

a { color: var(--text); }

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }

/* ---------- 顶栏 ---------- */
.uc-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: .6rem;
    height: 56px;
    padding: 0 1rem;
    background: color-mix(in srgb, var(--page-bg) 88%, transparent);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--border);
}

.uc-brand {
    font-weight: 650;
    letter-spacing: -.01em;
    text-decoration: none;
    white-space: nowrap;
}

.uc-spacer { flex: 1; }

.uc-user {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .85rem;
    color: var(--text-2);
}

.uc-avatar {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .8rem;
    font-weight: 600;
    color: var(--invert-text);
    background: var(--invert-bg);
    border-radius: 50%;
    overflow: hidden;
}
.uc-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- 按钮 ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    padding: .45rem 1rem;
    font-size: .82rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--pill);
    text-decoration: none;
    transition: var(--speed);
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }

.btn-primary {
    color: var(--invert-text);
    background: var(--invert-bg);
    border-color: var(--invert-bg);
}
.btn-primary:hover { background: var(--invert-bg); opacity: .86; }

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--text-2);
}
.btn-ghost:hover { background: var(--surface); color: var(--text); border-color: var(--border); }

.btn-block { width: 100%; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- 布局 ---------- */
.uc-wrap {
    max-width: 880px;
    margin: 0 auto;
    padding: 2rem 1rem 4rem;
}

.uc-title {
    font-size: 1.5rem;
    font-weight: 650;
    letter-spacing: -.02em;
}
.uc-sub {
    margin-top: .25rem;
    font-size: .85rem;
    color: var(--text-2);
}

.uc-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-top: 1.5rem;
}

.card {
    padding: 1.1rem 1.15rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
}

.card-title {
    font-size: .95rem;
    font-weight: 650;
    margin-bottom: .2rem;
}
.card-desc {
    font-size: .78rem;
    color: var(--text-3);
    margin-bottom: .9rem;
}

/* ---------- 资料概览 ---------- */
.profile-head {
    display: flex;
    align-items: center;
    gap: .9rem;
}
.profile-avatar {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--invert-text);
    background: var(--invert-bg);
    border-radius: 50%;
    overflow: hidden;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- 头像编辑 ---------- */
.avatar-editor {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}
.avatar-editor .msg { margin-top: .5rem; }

/* 文件选择控件：隐藏原生 input，用 label 当按钮 */
.file-field {
    position: relative;
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-wrap: wrap;
}
.file-field input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}
.file-btn {
    flex-shrink: 0;
    padding: .42rem 1rem;
    font-size: .78rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--pill);
    cursor: pointer;
    transition: var(--speed);
}
.file-btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.file-field input[type="file"]:focus-visible + .file-btn {
    border-color: var(--text);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--text) 12%, transparent);
}
.file-name {
    min-width: 0;
    flex: 1;
    font-size: .76rem;
    color: var(--text-2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.profile-name {
    font-size: 1.15rem;
    font-weight: 650;
    letter-spacing: -.01em;
}

.tag {
    display: inline-block;
    padding: .1rem .55rem;
    font-size: .7rem;
    color: var(--text-2);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--pill);
}

.kv {
    display: grid;
    grid-template-columns: 7rem 1fr;
    gap: .45rem 1rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    font-size: .84rem;
}
.kv dt { color: var(--text-3); }
.kv dd { color: var(--text); word-break: break-all; }

/* ---------- 表单 ---------- */
.field { margin-bottom: .8rem; }
.field label {
    display: block;
    margin-bottom: .28rem;
    font-size: .78rem;
    color: var(--text-2);
}
.field input,
.field textarea {
    width: 100%;
    padding: .6rem .85rem;
    font-size: .88rem;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    outline: none;
    transition: var(--speed);
}
.field textarea { min-height: 84px; resize: vertical; }
.field input:focus,
.field textarea:focus {
    border-color: var(--border-strong);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--text) 8%, transparent);
}
.field-hint {
    margin-top: .25rem;
    font-size: .72rem;
    color: var(--text-3);
}

.form-actions {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin-top: 1rem;
}

.msg {
    margin-top: .7rem;
    font-size: .8rem;
    min-height: 1.2em;
}
.msg.error { color: var(--text); font-weight: 600; }
.msg.ok    { color: var(--text-2); }

/* ---------- 通用登录 / 注册页（简约） ---------- */
.signin-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem 1rem;
}

.signin-back {
    position: fixed;
    top: 1.1rem;
    left: 1.2rem;
    font-size: .82rem;
    color: var(--text-3);
    text-decoration: none;
    transition: var(--speed);
}
.signin-back:hover { color: var(--text); }

.signin-wrap {
    width: 100%;
    max-width: 360px;
}

.signin-card {
    padding: 2rem 1.6rem 1.5rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.signin-mark {
    width: 48px;
    height: 48px;
    margin: 0 auto .9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .82rem;
    font-weight: 600;
    color: var(--invert-text);
    background: var(--invert-bg);
    border-radius: 14px;
}

.signin-title {
    font-size: 1.3rem;
    font-weight: 650;
    text-align: center;
    letter-spacing: -.01em;
}
.signin-desc {
    margin: .25rem 0 1.4rem;
    font-size: .78rem;
    text-align: center;
    color: var(--text-3);
}

.signin-card .field { margin-bottom: .85rem; }
.signin-card .btn-block { margin-top: .3rem; }

.signin-switch {
    margin-top: 1.1rem;
    padding-top: 1.05rem;
    border-top: 1px solid var(--border);
    font-size: .8rem;
    text-align: center;
    color: var(--text-2);
}
.signin-switch a {
    color: var(--text);
    text-decoration: underline;
    text-underline-offset: 2px;
    margin-left: .15rem;
}

.hidden { display: none !important; }

/* ---------- 弹窗（上传头像） ---------- */
.uc-mask {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, .42);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--speed), visibility var(--speed);
}
.uc-mask.open { opacity: 1; visibility: visible; }

.uc-modal {
    width: 100%;
    max-width: 380px;
    padding: 1.2rem 1.2rem 1rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 60px rgba(0, 0, 0, .22);
    transform: translateY(8px) scale(.98);
    transition: transform var(--speed);
}
.uc-mask.open .uc-modal { transform: none; }

.uc-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .9rem;
}
.uc-modal-head h3 {
    font-size: 1rem;
    font-weight: 650;
}

.uc-modal-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .9rem;
    color: var(--text-3);
    background: transparent;
    border: none;
    border-radius: 8px;
    transition: var(--speed);
}
.uc-modal-close:hover { color: var(--text); background: var(--surface); }

.uc-modal-body {
    display: flex;
    flex-direction: column;
    gap: .9rem;
    align-items: center;
}

.avatar-modal-preview {
    width: 112px;
    height: 112px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.4rem;
    font-weight: 600;
    color: var(--invert-text);
    background: var(--invert-bg);
    border-radius: 50%;
    overflow: hidden;
}
.avatar-modal-preview img { width: 100%; height: 100%; object-fit: cover; }

.uc-modal-body .file-field {
    width: 100%;
    justify-content: center;
}

.uc-modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.uc-modal .msg {
    margin-top: .5rem;
    font-size: .8rem;
    text-align: center;
    min-height: 1.2em;
}

@media (max-width: 560px) {
    .kv { grid-template-columns: 1fr; gap: .1rem 0; }
    .kv dt { margin-top: .45rem; }
    .uc-wrap { padding: 1.2rem .8rem 3rem; }
    .signin-card { padding: 1.6rem 1.2rem 1.3rem; }
}
