:root {
    --theme-bg: #f6f8fb;
    --theme-text: #172033;
    --theme-primary: #2563eb;
    --theme-secondary: #0f766e;
    --theme-gradient: linear-gradient(135deg, #2563eb 0%, #0f766e 100%);
    --app-bg: linear-gradient(180deg, var(--theme-bg) 0%, color-mix(in srgb, var(--theme-bg) 86%, #ffffff) 100%);
    --surface-1: color-mix(in srgb, var(--theme-bg) 8%, #ffffff);
    --surface-2: color-mix(in srgb, var(--theme-bg) 22%, #ffffff);
    --surface-3: color-mix(in srgb, var(--theme-bg) 40%, #ffffff);
    --surface-border: rgba(15, 23, 42, 0.09);
    --surface-border-strong: rgba(15, 23, 42, 0.14);
    --surface-shadow: 0 16px 45px rgba(15, 23, 42, 0.08);
    --surface-shadow-soft: 0 8px 24px rgba(15, 23, 42, 0.06);
    --muted-text: #64748b;
    --input-bg: color-mix(in srgb, var(--surface-1) 88%, var(--theme-primary) 4%);
    --panel-glow: color-mix(in srgb, var(--theme-primary) 14%, transparent);

    --bg: var(--theme-bg);
    --paper: var(--surface-1);
    --paper-2: var(--surface-2);
    --ink: var(--theme-text);
    --muted: var(--muted-text);
    --line: var(--surface-border);
    --gold: var(--theme-primary);
    --gold-deep: var(--theme-secondary);
    --rose: var(--theme-secondary);
    --ok: #22c55e;
    --shadow: var(--surface-shadow);
    --radius-sm: 10px;
    --radius: 14px;
    --radius-lg: 20px;
    --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
    --dur: 0.28s;
}

.dark {
    --app-bg:
        radial-gradient(circle at top left, color-mix(in srgb, var(--theme-primary) 16%, transparent) 0, transparent 28rem),
        linear-gradient(180deg, var(--theme-bg) 0%, color-mix(in srgb, var(--theme-bg) 58%, #000) 100%);
    --surface-1: color-mix(in srgb, var(--theme-bg) 72%, #ffffff 9%);
    --surface-2: color-mix(in srgb, var(--theme-bg) 78%, #ffffff 6%);
    --surface-3: color-mix(in srgb, var(--theme-bg) 84%, #ffffff 4%);
    --surface-border: rgba(255, 255, 255, 0.09);
    --surface-border-strong: rgba(255, 255, 255, 0.14);
    --surface-shadow: 0 18px 55px rgba(0, 0, 0, 0.34);
    --surface-shadow-soft: 0 10px 28px rgba(0, 0, 0, 0.24);
    --muted-text: #9ca3af;
    --input-bg: color-mix(in srgb, var(--surface-2) 80%, transparent);
    --panel-glow: color-mix(in srgb, var(--theme-primary) 18%, transparent);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; overscroll-behavior-x: none; }
html { scrollbar-color: color-mix(in srgb, var(--theme-primary) 50%, #94a3b8) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--theme-primary) 50%, #94a3b8);
    border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover { background: var(--theme-secondary); }

body {
    min-height: 100vh;
    font-family: "Songti SC", "Noto Serif SC", "Source Han Serif SC", system-ui, Georgia, serif;
    background:
        radial-gradient(1200px 520px at 8% -12%, color-mix(in srgb, var(--theme-primary) 16%, transparent), transparent 50%),
        radial-gradient(960px 460px at 100% 0%, color-mix(in srgb, var(--theme-secondary) 13%, transparent), transparent 46%),
        var(--app-bg);
    background-attachment: fixed;
    color: var(--ink);
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
}

.grain {
    pointer-events: none;
    position: fixed;
    inset: 0;
    opacity: 0.05;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.9'/%3E%3C/svg%3E");
    z-index: 0;
}

a { color: var(--theme-primary); text-decoration: none; transition: color var(--dur) var(--ease); }
a:hover { color: var(--theme-secondary); }
:where(a, button, input, textarea, select, [tabindex]):focus-visible {
    outline: 2px solid var(--theme-primary);
    outline-offset: 3px;
}

.glass-panel {
    border: 1px solid var(--surface-border);
    background: color-mix(in srgb, var(--surface-1) 78%, transparent);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--surface-shadow-soft);
}
.ui-card {
    border: 1px solid var(--surface-border);
    background: linear-gradient(180deg, color-mix(in srgb, var(--surface-1) 96%, #ffffff 4%), var(--surface-1));
    box-shadow: var(--surface-shadow-soft);
    border-radius: var(--radius);
}
.ui-card-elevated {
    border: 1px solid var(--surface-border);
    background: linear-gradient(180deg, color-mix(in srgb, var(--surface-1) 92%, #ffffff 8%), var(--surface-1));
    box-shadow: var(--surface-shadow);
    border-radius: var(--radius);
}
.ui-subtle-panel {
    border: 1px solid var(--surface-border);
    background: color-mix(in srgb, var(--surface-2) 86%, transparent);
    border-radius: var(--radius);
}
.metric-card { position: relative; overflow: hidden; border-radius: var(--radius); }
.metric-card::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(135deg, var(--panel-glow), transparent 42%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 34%);
}
.metric-card > * { position: relative; }

@media (pointer: coarse) {
    button, [role='button'] { min-height: 44px; min-width: 44px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
@media (prefers-contrast: more) {
    :root { --surface-border: #475569; --muted-text: #334155; }
    .dark { --surface-border: #cbd5e1; --muted-text: #e2e8f0; }
}

@keyframes pageIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}
.wrap { animation: pageIn 0.4s var(--ease) both; }
.login-card { animation: pageIn 0.5s var(--ease) both; }

@keyframes flashIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: none; }
}

.app-shell {
    position: relative;
    z-index: 1;
    display: flex;
    height: 100dvh;
    overflow: hidden;
}
.nav-icon {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

.drawer {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 50;
    width: 18rem;
    height: 100%;
    padding: 12px;
    background: color-mix(in srgb, var(--surface-1) 90%, transparent);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-right: 1px solid var(--surface-border);
    transform: translateX(-105%);
    transition: transform 0.28s var(--ease);
    color: var(--theme-text);
}
body.nav-open .drawer { transform: translateX(0); }
.drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 6px 14px;
}
.drawer-user { display: flex; align-items: center; gap: 12px; min-width: 0; }
.drawer-user-text { min-width: 0; }
.drawer-title {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--theme-text);
}
.drawer-sub {
    color: var(--muted-text);
    margin-top: 2px;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.drawer-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    color: var(--muted-text);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.drawer-close:hover { background: var(--surface-2); color: var(--theme-text); }
.sidebar-divider {
    height: 1px;
    margin: 0 6px 12px;
    background: linear-gradient(90deg, color-mix(in srgb, var(--theme-primary) 45%, transparent), transparent);
}
.drawer-nav {
    flex: 1;
    overflow-y: auto;
    padding: 4px 2px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    scrollbar-width: thin;
}
.drawer-nav::-webkit-scrollbar { width: 4px; }
.drawer-nav::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--theme-text) 14%, transparent); border-radius: 2px; }

.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    border-radius: 12px;
    color: color-mix(in srgb, var(--theme-text) 78%, transparent);
    font-size: 14px;
    font-weight: 500;
    opacity: 0.85;
    transition: background 0.2s, color 0.2s, opacity 0.2s;
}
.nav-item .nav-icon {
    width: 22px;
    height: 22px;
    padding: 7px;
    box-sizing: content-box;
    border-radius: 10px;
    color: color-mix(in srgb, var(--theme-text) 58%, transparent);
    transition: background 0.2s, color 0.2s;
}
.nav-item:hover { background: var(--surface-2); color: var(--theme-text); opacity: 1; }
.nav-item:hover .nav-icon { background: color-mix(in srgb, var(--theme-text) 7%, transparent); color: var(--theme-text); }
.nav-item.is-active { background: color-mix(in srgb, var(--theme-primary) 9%, transparent); color: var(--theme-primary); opacity: 1; }
.nav-item.is-active .nav-icon {
    background: var(--theme-gradient);
    color: #fff;
    box-shadow: 0 4px 12px color-mix(in srgb, var(--theme-primary) 28%, transparent);
}
.nav-item.is-active::before {
    content: '';
    position: absolute;
    top: 50%;
    left: -4px;
    width: 3px;
    height: 56%;
    transform: translateY(-50%);
    border-radius: 0 4px 4px 0;
    background: var(--theme-gradient);
}
.nav-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 10px 2px 0;
    padding: 10px 12px;
    border-radius: 12px;
    background: color-mix(in srgb, var(--surface-2) 80%, transparent);
}
.sidebar-user-avatar { flex-shrink: 0; padding: 0; border: none; background: none; cursor: pointer; border-radius: 50%; }
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 14px; font-weight: 600; color: var(--theme-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 11px; color: var(--muted-text); }
.sidebar-logout {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    color: var(--muted-text);
    transition: background 0.2s, color 0.2s;
}
.sidebar-logout:hover { background: color-mix(in srgb, var(--theme-text) 8%, transparent); color: var(--theme-text); }

.sidebar-foot {
    position: relative;
    margin: 10px 2px 2px;
    padding: 8px 10px;
    border-radius: 12px;
    background: color-mix(in srgb, var(--surface-2) 80%, transparent);
    display: flex;
    align-items: center;
    justify-content: flex-end;
}
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    border: none;
    background: transparent;
    color: var(--theme-primary);
    cursor: pointer;
    transition: background 0.2s;
}
.theme-toggle:hover { background: color-mix(in srgb, var(--theme-text) 8%, transparent); }
.theme-panel {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    margin-bottom: 8px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    padding: 8px;
    border-radius: 12px;
    z-index: 60;
    border: 1px solid var(--surface-border);
    background: color-mix(in srgb, var(--surface-1) 92%, transparent);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: var(--surface-shadow);
}
.theme-panel[hidden] { display: none; }
.theme-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 4px;
    border: none;
    border-radius: 10px;
    background: var(--chip-bg);
    color: #fff;
    cursor: pointer;
    position: relative;
    transition: transform 0.15s;
}
.theme-chip:hover { transform: translateY(-2px); }
.theme-chip.is-current { box-shadow: 0 0 0 2px var(--surface-1), 0 0 0 4px var(--theme-primary); }
.theme-chip-name { font-size: 11px; font-weight: 600; }

body.nav-open { overflow: hidden; }
.nav-mask {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 40;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
body.nav-open .nav-mask { opacity: 1; pointer-events: auto; }

.main-col {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    height: 100%;
    overflow: hidden;
}

.topbar {
    position: relative;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    height: 64px;
    margin: 8px;
    padding: 0 16px;
    border-radius: 12px;
    border: 1px solid var(--surface-border);
    background: color-mix(in srgb, var(--surface-1) 78%, transparent);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--surface-shadow-soft);
    flex-shrink: 0;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--theme-text);
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
    min-width: 0;
}
.brand-name { overflow: hidden; text-overflow: ellipsis; }
.brand:hover { color: var(--theme-text); }
.brand-mark {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--theme-gradient);
    box-shadow: 0 0 12px color-mix(in srgb, var(--theme-primary) 60%, transparent);
    transition: transform 0.4s var(--ease);
    flex-shrink: 0;
}
.brand:hover .brand-mark { transform: rotate(360deg) scale(1.15); }
.menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: var(--muted-text);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.menu-toggle:hover { background: var(--surface-2); color: var(--theme-text); }
.topbar-avatar { flex-shrink: 0; padding: 0; border: none; background: none; cursor: pointer; border-radius: 50%; }

.wrap {
    position: relative;
    z-index: 1;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    overscroll-behavior-x: none;
    padding: 20px max(20px, calc((100% - 1120px) / 2)) calc(28px + env(safe-area-inset-bottom));
}
.page-head { margin-bottom: 28px; }
.album-head { margin-top: 48px; }
.page-head h1 {
    margin: 0 0 8px;
    font-weight: 500;
    font-size: 34px;
    letter-spacing: 0.08em;
}
.page-head p { margin: 0; color: var(--muted); }

.hero { margin-bottom: 48px; }
.hero .eyebrow {
    margin: 0 0 10px;
    color: var(--gold);
    letter-spacing: 0.32em;
    font-size: 13px;
}
.hero h1 {
    margin: 0 0 12px;
    font-weight: 500;
    font-size: 42px;
    letter-spacing: 0.08em;
}
.hero p { margin: 0; color: var(--muted); max-width: 36em; line-height: 1.7; }
.block { margin-bottom: 48px; }
.block-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}
.block-head h2 {
    margin: 0;
    font-weight: 500;
    letter-spacing: 0.12em;
}

.flash {
    margin-bottom: 20px;
    padding: 12px 16px;
    border: 1px solid var(--line);
    background: var(--paper);
    border-radius: var(--radius-sm);
    animation: flashIn 0.3s var(--ease) both;
}
.flash-ok { border-color: #22c55e; color: var(--ok); }
.flash-err { border-color: #ef4444; color: #e8a090; }

.masonry {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 18px;
}
.card {
    break-inside: avoid;
    margin-bottom: 18px;
    background: var(--paper);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 22px 48px rgba(0, 0, 0, 0.38);
    border-color: color-mix(in srgb, var(--theme-primary) 45%, transparent);
}
.card .thumb-link { display: block; position: relative; overflow: hidden; }
.card img {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    transition: transform 0.5s var(--ease), opacity 0.4s var(--ease);
    -webkit-touch-callout: default;
    -webkit-user-select: none;
    user-select: none;
}
.card:hover img { transform: scale(1.035); }
.card figcaption {
    padding: 12px 14px 14px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.6;
}
.card .meta { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; }
.save-btn {
    margin-top: 10px;
    width: 100%;
    text-align: center;
    font-size: 13px;
}
.danger-btn {
    margin-top: 8px;
    width: 100%;
    background: linear-gradient(180deg, var(--theme-secondary), color-mix(in srgb, var(--theme-secondary) 70%, #000));
    color: #fff;
}
.wall-form { margin-top: 10px; }
.wall-form .check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}
.wall-form .check input,
.panel .check input {
    width: auto;
    margin: 0;
}
.panel .check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    color: var(--muted);
    font-size: 13px;
}
.wall-slider {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
}
.wall-track {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    gap: 16px;
    scrollbar-width: none;
    background: transparent;
}
.wall-track::-webkit-scrollbar { display: none; }
.wall-slide {
    flex: 0 0 min(520px, 100%);
    margin-bottom: 0;
    scroll-snap-align: start;
}
.wall-slide .thumb-link img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    -webkit-touch-callout: default;
    pointer-events: auto;
    user-select: none;
}
.wall-slide img.thumb-img {
    min-height: 0;
}
.wall-prev, .wall-next {
    position: absolute;
    top: 42%;
    z-index: 2;
    width: auto;
    padding: 8px 12px;
    opacity: 0.92;
    border-radius: var(--radius-sm);
}
.wall-prev { left: 8px; }
.wall-next { right: 8px; }

.view-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.view-bar .seg {
    display: inline-flex;
    padding: 3px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 11px;
    gap: 3px;
}
.view-bar .seg button {
    width: auto;
    padding: 6px 12px;
    background: transparent;
    color: var(--muted);
    letter-spacing: 0.06em;
    border: 0;
    font-size: 13px;
    border-radius: 8px;
    cursor: pointer;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.view-bar .seg button.on {
    background: linear-gradient(180deg, var(--gold), var(--gold-deep));
    color: var(--theme-text);
}

.masonry-wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.masonry-wall .card { margin-bottom: 0; }
.masonry-wall .wall-slide { flex: none; }
.masonry-wall .thumb-link img,
.masonry-wall .wall-slide .thumb-link img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
}

.panel {
    background: var(--paper);
    border: 1px solid var(--line);
    padding: 22px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
    border-radius: var(--radius);
}
label { display: block; color: var(--muted); margin-bottom: 6px; font-size: 13px; letter-spacing: 0.04em; }
input, textarea, select {
    width: 100%;
    margin-bottom: 14px;
    padding: 11px 12px;
    border: 1px solid var(--line);
    background: var(--input-bg);
    color: var(--ink);
    font: inherit;
    border-radius: var(--radius-sm);
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--gold-deep);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--theme-primary) 16%, transparent);
    background: var(--input-bg);
}
textarea { min-height: 110px; resize: vertical; }
button, .btn {
    display: inline-block;
    border: 0;
    background: linear-gradient(180deg, var(--gold), var(--gold-deep));
    color: var(--theme-text);
    padding: 10px 18px;
    cursor: pointer;
    font: inherit;
    letter-spacing: 0.08em;
    border-radius: var(--radius-sm);
    transition: filter var(--dur) var(--ease), transform 0.12s var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
}
button:hover, .btn:hover { filter: brightness(1.08); box-shadow: 0 6px 18px color-mix(in srgb, var(--theme-primary) 25%, transparent); }
button:active, .btn:active { transform: translateY(1px) scale(0.99); }
.hint { color: var(--muted); font-size: 13px; margin-top: -6px; margin-bottom: 14px; }
.nav-group-title {
    color: var(--gold);
    font-size: 13px;
    letter-spacing: 0.12em;
    margin: 8px 0 10px;
}
.nav-group-title:first-child { margin-top: 0; }

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}
.login-card {
    width: min(420px, 100%);
    background: var(--paper);
    border: 1px solid var(--line);
    padding: 36px 32px 28px;
    box-shadow: var(--shadow);
    border-radius: var(--radius-lg);
}
.login-card h1 {
    margin: 0 0 6px;
    letter-spacing: 0.28em;
    font-weight: 500;
}
.login-card p { color: var(--muted); margin: 0 0 24px; }
.back-home { margin: 18px 0 0; }

.table {
    width: 100%;
    border-collapse: collapse;
}
.table th, .table td {
    text-align: left;
    padding: 10px 8px;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
}
.table tr { transition: background 0.2s var(--ease); }
.table tbody tr:hover { background: color-mix(in srgb, var(--theme-primary) 4.5%, transparent); }
.table th { color: var(--ink); font-weight: 500; }
.msg {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    border-bottom: 1px solid var(--line);
    padding: 16px 0;
}
.msg .avatar { flex-shrink: 0; }
.msg-main { flex: 1; min-width: 0; }
.msg .who-line { color: var(--gold); margin-bottom: 6px; }
.msg p { margin: 0; line-height: 1.7; white-space: pre-wrap; }
.msg.reply {
    margin: 12px 0 0 18px;
    padding: 12px 0 0;
    border-bottom: 0;
    border-top: 1px solid var(--line);
}
.reply-form {
    margin-top: 12px;
    padding: 12px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
}
.reply-form textarea { min-height: 72px; margin-bottom: 10px; }
.memo-card {
    background: var(--paper);
    border: 1px solid var(--line);
    padding: 18px 20px;
    margin-bottom: 14px;
    box-shadow: var(--shadow);
    border-radius: var(--radius);
    transition: transform var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.memo-card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--theme-primary) 40%, transparent); }
.memo-card h3 {
    margin: 0 0 6px;
    font-weight: 500;
    letter-spacing: 0.04em;
}
.memo-time { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.memo-card p { margin: 0; line-height: 1.7; white-space: pre-wrap; color: var(--muted); }
.empty { color: var(--muted); padding: 40px 0; text-align: center; }
.foot {
    text-align: center;
    color: #7d7163;
    padding: 0 16px 40px;
    font-size: 13px;
}
.notice-mask,
.confirm-mask {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100%;
    height: 100%;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.72);
    padding: 0;
    margin: 0;
    overflow: hidden;
}
.notice-mask[hidden],
.confirm-mask[hidden] {
    display: none !important;
}
.notice-box,
.confirm-box {
    position: absolute;
    top: 50%;
    left: 50%;
    -webkit-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
    width: 88%;
    max-width: 420px;
    margin: 0;
    background: var(--paper);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    padding: 24px 22px 20px;
    border-radius: var(--radius);
}
.notice-box h2,
.confirm-box h2 {
    margin: 0 0 12px;
    font-weight: 500;
    letter-spacing: 0.08em;
}
.notice-body {
    color: var(--muted);
    line-height: 1.7;
    white-space: pre-wrap;
    margin-bottom: 18px;
    max-height: 50vh;
    overflow: auto;
}
.notice-ok { width: 100%; }
.confirm-box p {
    color: var(--muted);
    line-height: 1.7;
    margin: 0 0 18px;
}
.confirm-actions {
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-flex-direction: row;
    flex-direction: row;
    gap: 10px;
}
.confirm-actions .btn,
.confirm-actions button {
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    flex: 1;
    width: auto;
    margin-top: 0;
    text-align: center;
}
.ghost-btn {
    background: transparent;
    color: var(--ink);
    border: 1px solid var(--line);
}
.ghost-btn:hover {
    background: var(--surface-2);
    box-shadow: none;
}
body.modal-open {
    overflow: hidden;
    height: 100%;
}

.like-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 10px;
    width: auto;
    padding: 6px 14px;
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 13px;
    letter-spacing: 0.04em;
    transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease), background var(--dur) var(--ease), transform 0.12s var(--ease);
}
.like-btn:hover { color: var(--rose); border-color: color-mix(in srgb, var(--theme-secondary) 60%, transparent); box-shadow: none; }
.like-btn .heart { display: inline-block; transition: transform var(--dur) var(--ease); }
.like-btn:hover .heart { transform: scale(1.25); }
.like-btn.is-liked {
    color: var(--rose);
    border-color: color-mix(in srgb, var(--theme-secondary) 65%, transparent);
    background: color-mix(in srgb, var(--theme-secondary) 10%, transparent);
}
.like-btn.is-liked .heart { transform: scale(1.15); }
.like-btn .cnt { min-width: 1.4em; text-align: left; }
.like-btn:active { transform: scale(0.95); }
.like-btn:disabled { opacity: 0.6; cursor: default; }

.lightbox {
    position: fixed !important;
    inset: 0;
    z-index: 10000;
    background: color-mix(in srgb, var(--theme-bg) 92%, #000);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    -webkit-transform: none !important;
    transform: none !important;
}
.lightbox[hidden] { display: none !important; }
.lightbox-stage {
    margin: 0;
    max-width: calc(100vw - 96px);
    max-height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
}
.lightbox-stage img {
    display: block;
    max-width: calc(100vw - 96px);
    max-height: calc(100vh - 190px);
    object-fit: contain;
    border-radius: var(--radius);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
    background: var(--surface-2);
    animation: pageIn 0.3s var(--ease) both;
}
.lightbox-cap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin: 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.6;
    text-align: center;
    flex-wrap: wrap;
}
.lightbox-cap .btn { width: auto; margin: 0; padding: 6px 14px; font-size: 13px; }
.lightbox-close {
    position: absolute;
    top: calc(14px + env(safe-area-inset-top));
    right: 18px;
    z-index: 2;
    width: auto;
    height: 46px;
    min-width: 46px;
    padding: 0 14px;
    background: rgba(42, 36, 28, 0.85);
    color: var(--ink);
    font-size: 26px;
    line-height: 1;
    border: 1px solid var(--line);
    border-radius: 12px;
}
.lightbox-close:hover { background: var(--surface-border); box-shadow: none; }
.lightbox-nav {
    position: absolute;
    top: 50%;
    -webkit-transform: translateY(-50%);
    transform: translateY(-50%);
    z-index: 2;
    width: auto;
    min-width: 48px;
    height: 60px;
    padding: 0 14px;
    background: rgba(42, 36, 28, 0.85);
    color: var(--ink);
    font-size: 30px;
    line-height: 1;
    border: 1px solid var(--line);
    border-radius: 12px;
}
.lightbox-nav:hover { background: var(--surface-border); box-shadow: none; }
.lightbox-prev { left: 14px; }
.lightbox-next { right: 14px; }
.lightbox-nav:disabled { opacity: 0.35; cursor: default; }

@media (max-width: 900px) {
    .lightbox-stage {
        max-width: calc(100vw - 24px);
    }
    .lightbox-stage img {
        max-width: calc(100vw - 24px);
        max-height: calc(100vh - 170px);
    }
    .lightbox-close {
        top: calc(8px + env(safe-area-inset-top));
        right: 10px;
        height: 42px;
        min-width: 42px;
        padding: 0 10px;
    }
    .lightbox-nav {
        top: auto;
        bottom: calc(24px + env(safe-area-inset-bottom));
        -webkit-transform: none;
        transform: none;
        width: 54px;
        height: 48px;
        padding: 0;
        font-size: 28px;
    }
    .lightbox-prev { left: calc(50% - 64px); }
    .lightbox-next { right: calc(50% - 64px); }
}

@media (max-width: 1000px) {
    .menu-toggle { display: inline-flex; }
    .topnav { display: none; }
}
@media (min-width: 1001px) {
    .menu-toggle { display: none; }
    .topnav { display: flex; }
}

@media (max-width: 900px) {
    .topbar {
        padding: 10px 14px;
        gap: 12px;
        padding-top: calc(10px + env(safe-area-inset-top));
    }
    .brand {
        font-size: 18px;
        letter-spacing: 0.12em;
    }
    .wrap {
        width: calc(100% - 28px);
        margin: 20px auto 48px;
        margin-bottom: calc(48px + env(safe-area-inset-bottom));
        touch-action: pan-y;
    }
    .page-head { margin-bottom: 18px; }
    .page-head h1 {
        font-size: 24px;
        letter-spacing: 0.04em;
    }
    .hero h1 { font-size: 26px; }
    .masonry {
        grid-template-columns: 1fr;
    }
    .masonry-wall { grid-template-columns: 1fr; }
    .panel { padding: 16px; }
    .card .meta { flex-direction: column; gap: 4px; align-items: flex-start; }
    .msg.reply { margin-left: 8px; }
    .login-card { padding: 28px 18px 22px; }
    button, .btn {
        width: 100%;
        text-align: center;
        padding: 12px 16px;
    }
    .drawer-close, .menu-toggle, .drawer-logout, .wall-prev, .wall-next,
    .emoji-toggle, .ddz-btn, .ddz-mini {
        width: auto;
    }
    .emoji-toggle, .emoji-item {
        padding: 0;
    }
    .notice-mask,
    .confirm-mask {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
    }
    .notice-box,
    .confirm-box {
        width: 86%;
        max-width: 420px;
    }
    .confirm-actions {
        -webkit-flex-direction: column;
        flex-direction: column;
    }
    .confirm-actions .btn,
    .confirm-actions button {
        width: 100%;
    }
    .wall-slide {
        flex-basis: 100%;
    }
    .wall-slide .thumb-link img {
        max-height: 62vh;
        min-height: 220px;
    }
    .wall-prev, .wall-next {
        top: 36%;
        padding: 8px 10px;
        font-size: 13px;
    }
    .panel:has(.table) {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .table { min-width: 520px; }
    .view-bar { width: 100%; }
}

@media (min-width: 721px) and (max-width: 1100px) {
    .masonry { grid-template-columns: repeat(2, 1fr); }
    .masonry-wall { grid-template-columns: repeat(2, 1fr); }
}
/* ===== 头像 ===== */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--surface-2);
    color: var(--ink);
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0;
    user-select: none;
    overflow: hidden;
}
img.avatar { display: block; }
.avatar-fallback {
    background: var(--theme-gradient);
    color: #fff;
}
.avatar-top { width: 30px; height: 30px; font-size: 14px; }
.avatar-lg { width: 64px; height: 64px; font-size: 26px; }
.topbar-avatar {
    flex-shrink: 0;
    width: auto;
    min-width: 38px;
    height: 38px;
    padding: 2px;
    margin-left: 0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.topbar-avatar:hover {
    border-color: color-mix(in srgb, var(--theme-primary) 55%, transparent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--theme-primary) 12%, transparent);
}
.drawer-user {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}
.drawer-user .drawer-title,
.drawer-user .drawer-sub {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.drawer-avatar {
    flex-shrink: 0;
    width: auto;
    padding: 2px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: border-color var(--dur) var(--ease);
}
.drawer-avatar:hover { border-color: color-mix(in srgb, var(--theme-primary) 55%, transparent); }

/* ===== 设置页头像区块 ===== */
.avatar-panel { margin-bottom: 24px; }
.avatar-row {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}
.avatar-row .avatar { flex-shrink: 0; }
.avatar-row-text { flex: 1; min-width: 200px; }
.avatar-row-text p { margin: 0 0 12px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.avatar-row-text .btn { width: auto; padding: 10px 22px; }

/* ===== 头像裁剪弹窗 ===== */
.crop-mask {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.crop-mask[hidden] { display: none !important; }
.crop-box {
    width: min(92vw, 420px);
    background: var(--paper);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    padding: 22px 20px 18px;
    border-radius: var(--radius);
    animation: pageIn 0.25s var(--ease) both;
}
.crop-box h2 {
    margin: 0 0 14px;
    font-weight: 500;
    letter-spacing: 0.08em;
}
.crop-stage {
    border-radius: 12px;
    overflow: hidden;
    background: var(--surface-2);
    border: 1px solid var(--line);
}
.crop-stage canvas {
    display: block;
    width: 100%;
    height: auto;
    touch-action: none;
    cursor: grab;
}
.crop-stage canvas:active { cursor: grabbing; }
.crop-tip {
    color: var(--muted);
    font-size: 13px;
    text-align: center;
    margin: 12px 0 14px;
}

/* ===== 上传进度卡片 ===== */
.uprog {
    position: fixed;
    top: calc(72px + env(safe-area-inset-top));
    right: 16px;
    z-index: 10001;
    width: 300px;
    max-width: calc(100vw - 32px);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    animation: pageIn 0.3s var(--ease) both;
}
.uprog[hidden] { display: none !important; }
.uprog-label {
    font-size: 13px;
    color: var(--ink);
    margin-bottom: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.uprog-bar {
    height: 8px;
    border-radius: 999px;
    background: var(--surface-2);
    overflow: hidden;
}
.uprog-fill {
    height: 100%;
    width: 0%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--gold), var(--rose));
    transition: width 0.15s linear;
}
.uprog-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 8px;
    font-size: 13px;
    color: var(--muted);
}
.uprog-row.is-dim { font-size: 12px; }
.uprog-pct { color: var(--ink); font-weight: 600; }
.uprog.is-ok .uprog-fill { background: var(--ok); }
.uprog.is-ok .uprog-state { color: var(--ok); }
.uprog.is-err .uprog-fill { background: var(--rose); }
.uprog.is-err .uprog-state { color: var(--rose); }

@media (max-width: 1000px) {
    .topbar-avatar { margin-left: auto; }
}
@media (max-width: 900px) {
    .uprog {
        top: calc(64px + env(safe-area-inset-top));
        right: 14px;
    }
    .avatar-row-text .btn { width: 100%; }
    .crop-box { padding: 16px 14px 14px; }
}

/* ===== 响应式：桌面侧边栏常驻，移动抽屉 ===== */
@media (min-width: 1024px) {
    .drawer {
        position: static;
        transform: none;
        height: 100%;
        flex-shrink: 0;
    }
    .menu-toggle { display: none; }
    .nav-mask { display: none !important; }
    .drawer-close { display: none; }
}
@media (max-width: 1023px) {
    .topbar { margin: 6px; height: 56px; }
    .brand-name { font-size: 15px; }
    .theme-panel { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
    .wrap { padding: 14px 14px calc(20px + env(safe-area-inset-bottom)); }
    .topbar { margin: 4px; padding: 0 10px; }
    .drawer { width: min(82vw, 320px); }
}

/* ===== 留言头像 ===== */
.avatar-sm { width: 32px; height: 32px; font-size: 14px; }
.avatar-md { width: 48px; height: 48px; font-size: 20px; }

/* ===== 好友列表 ===== */
.friend-list { display: flex; flex-direction: column; }
.friend-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}
.friend-item:last-child { border-bottom: 0; }
.friend-item .avatar { flex-shrink: 0; }
.friend-info { flex: 1; min-width: 0; }
.friend-name {
    color: var(--ink);
    font-weight: 500;
    letter-spacing: 0.02em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.friend-sub {
    color: var(--muted);
    font-size: 13px;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.friend-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.friend-actions form { margin: 0; }
.friend-actions .btn { width: auto; padding: 8px 16px; margin: 0; }
.tag {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 13px;
    background: var(--surface-2);
    color: var(--muted);
    border: 1px solid var(--line);
}
.tag-ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.nav-badge {
    margin-left: auto;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #e53935;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn .nav-badge { margin-left: 6px; }

/* ===== 私信聊天 ===== */
.chat-head {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.chat-peer { display: flex; align-items: center; gap: 12px; }
.chat-box {
    height: 60vh;
    min-height: 320px;
    overflow-y: auto;
    padding: 16px;
    margin-bottom: 16px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.chat-line { display: flex; align-items: flex-end; gap: 10px; }
.chat-line .avatar { flex-shrink: 0; }
.chat-line.is-mine { justify-content: flex-end; }
.chat-line.is-theirs { justify-content: flex-start; }
.chat-bubble {
    max-width: min(78%, 560px);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: var(--paper);
    border: 1px solid var(--line);
}
.chat-line.is-mine .chat-bubble {
    background: color-mix(in srgb, var(--theme-primary) 12%, transparent);
    border-color: color-mix(in srgb, var(--theme-primary) 32%, transparent);
}
.chat-text { line-height: 1.65; white-space: pre-wrap; word-break: break-word; }
.chat-time { margin-top: 4px; font-size: 11px; color: var(--muted); text-align: right; }
.chat-form textarea { min-height: 72px; margin-bottom: 10px; }

@media (max-width: 640px) {
    .chat-box { height: 56vh; }
    .friend-item { flex-wrap: wrap; }
}

/* ===== 可点击头像 ===== */
.avatar-btn {
    flex-shrink: 0;
    width: auto;
    padding: 0;
    margin: 0;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 50%;
    line-height: 0;
}
.avatar-btn:hover { filter: none; box-shadow: none; transform: none; }
.avatar-btn:hover .avatar { box-shadow: 0 0 0 3px color-mix(in srgb, var(--theme-primary) 25%, transparent); }

/* ===== 用户资料卡片 ===== */
.user-mask {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.user-mask[hidden] { display: none !important; }
.user-card {
    position: relative;
    width: min(92vw, 340px);
    padding: 28px 22px 22px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
}
.user-card-close {
    position: absolute;
    top: 6px;
    right: 8px;
    width: auto;
    padding: 2px 8px;
    margin: 0;
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}
.user-card-close:hover { color: var(--ink); filter: none; box-shadow: none; }
.user-card-avatar { display: flex; justify-content: center; margin-bottom: 12px; }
.user-card-name { font-size: 18px; font-weight: 600; color: var(--ink); letter-spacing: 0.02em; }
.user-card-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.user-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    align-items: center;
    margin-top: 18px;
}
.user-card-actions .btn { width: auto; padding: 9px 20px; margin: 0; }

/* ===== 用户空间 ===== */
.space-head {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.space-form-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 10px 0;
}
.space-form-row label { margin: 0; }
.space-form-row select { width: auto; min-width: 140px; }
.diary-text { min-height: 160px; }
.shuoshuo-list,
.diary-list { display: flex; flex-direction: column; gap: 12px; }
.shuoshuo-item,
.diary-item {
    padding: 14px 16px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
}
.shuoshuo-top {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 12px;
    flex-wrap: wrap;
}
.mood-tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--theme-primary) 14%, transparent);
    color: var(--theme-primary);
    font-size: 12px;
}
.vis-tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 999px;
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
}
.shuoshuo-time { color: var(--muted); }
.shuoshuo-text { margin: 0; line-height: 1.7; white-space: pre-wrap; word-break: break-word; }
.shuoshuo-del { margin-top: 10px; }
.shuoshuo-del .btn { width: auto; padding: 6px 14px; margin: 0; }
.diary-title {
    display: inline-block;
    font-size: 16px;
    font-weight: 600;
    color: var(--theme-primary);
    text-decoration: none;
    letter-spacing: 0.02em;
}
.diary-title:hover { text-decoration: underline; }
.diary-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 6px 0;
    font-size: 12px;
    color: var(--muted);
    flex-wrap: wrap;
}
.diary-excerpt { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.7; }
.diary-view .diary-content { line-height: 1.9; white-space: pre-wrap; word-break: break-word; }
.diary-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
}
.diary-actions .btn { width: auto; padding: 8px 18px; margin: 0; }

.msg-text { margin: 0; line-height: 1.7; white-space: pre-wrap; word-break: break-word; }
.msg-text .emoji-face,
.chat-text .emoji-face {
    width: 28px;
    height: 28px;
    vertical-align: text-bottom;
    display: inline-block;
}
.msg-text .emoji-sticker,
.chat-text .emoji-sticker {
    width: 96px;
    height: 96px;
    object-fit: contain;
    vertical-align: bottom;
    display: inline-block;
    border-radius: 8px;
    background: var(--surface-2);
    margin: 4px 2px;
}

.emoji-composer { position: relative; margin-bottom: 14px; }
.emoji-composer textarea { margin-bottom: 8px; }
.emoji-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.emoji-toggle {
    width: 36px;
    height: 36px;
    padding: 0;
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-2);
    color: var(--ink);
    border: 1px solid var(--line);
    box-shadow: none;
    letter-spacing: 0;
}
.emoji-toggle .nav-icon { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.emoji-toggle:hover { filter: none; box-shadow: none; background: var(--surface-3); }
.emoji-toggle.is-on {
    background: color-mix(in srgb, var(--theme-primary) 16%, transparent);
    border-color: color-mix(in srgb, var(--theme-primary) 40%, transparent);
    color: var(--theme-primary);
}
.emoji-panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(100% + 6px);
    z-index: 40;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 10px;
    height: min(70vh, 420px);
    max-height: min(70vh, 420px);
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow: hidden;
    overscroll-behavior: contain;
}
.emoji-panel.is-sheet {
    position: fixed;
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    z-index: 120;
    width: 100%;
    height: var(--emoji-sheet-h, 78dvh);
    max-height: var(--emoji-sheet-h, 78dvh);
    min-height: 0;
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px));
    border-radius: 18px 18px 0 0;
    box-sizing: border-box;
}
.emoji-panel[hidden] {
    display: none !important;
}
.emoji-tabs {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    flex: 0 0 auto;
}
.emoji-tabs button {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 100% !important;
    min-width: 0;
    height: 36px !important;
    min-height: 36px !important;
    padding: 0 4px !important;
    margin: 0 !important;
    background: var(--surface-2);
    color: var(--ink);
    border: 1px solid var(--line);
    box-shadow: none;
    letter-spacing: 0.02em;
    font-size: 13px;
    white-space: nowrap;
}
.emoji-tabs button:hover { filter: none; box-shadow: none; background: var(--surface-3); }
.emoji-tabs button.is-on {
    background: linear-gradient(180deg, var(--gold), var(--gold-deep));
    color: var(--theme-text);
    border-color: transparent;
}
.emoji-search-wrap {
    position: relative;
    display: block;
    margin: 0;
    flex-shrink: 0;
}
.emoji-search-wrap .nav-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    width: 16px;
    height: 16px;
    transform: translateY(-50%);
    stroke: var(--muted);
    fill: none;
    stroke-width: 1.8;
    pointer-events: none;
}
.emoji-search {
    margin: 0;
    padding: 8px 10px 8px 32px;
    min-height: 0;
}
.emoji-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
    gap: 6px;
    overflow-x: hidden;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    padding: 2px;
    align-content: start;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
}
.emoji-grid.is-sticker-grid {
    grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
}
.emoji-item {
    width: 100%;
    height: 44px;
    padding: 0;
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-2);
    border: 1px solid transparent;
    box-shadow: none;
    letter-spacing: 0;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}
.emoji-item img {
    pointer-events: none;
    -webkit-user-drag: none;
    user-select: none;
}
.emoji-item:hover {
    filter: none;
    transform: none;
    box-shadow: none;
    border-color: color-mix(in srgb, var(--theme-primary) 40%, transparent);
    background: color-mix(in srgb, var(--theme-primary) 10%, transparent);
}
.emoji-item.is-sticker { height: 72px; }
.emoji-item .emoji-face { width: 28px; height: 28px; }
.emoji-item .emoji-sticker {
    width: 64px;
    height: 64px;
    object-fit: contain;
    border-radius: 6px;
}
.emoji-empty {
    grid-column: 1 / -1;
    color: var(--muted);
    font-size: 13px;
    padding: 18px 8px;
    text-align: center;
}
.chat-form .emoji-composer { margin-bottom: 10px; }
.reply-form .emoji-composer { margin-bottom: 10px; }

@media (max-width: 900px) {
    body.emoji-open .wrap {
        overflow: hidden;
        touch-action: none;
    }
    .emoji-toggle {
        width: 44px;
        height: 44px;
        flex: 0 0 44px;
    }
    .emoji-panel {
        position: fixed;
        left: 0;
        right: 0;
        top: auto;
        bottom: 0;
        z-index: 120;
        width: 100%;
        height: var(--emoji-sheet-h, 78dvh);
        max-height: var(--emoji-sheet-h, 78dvh);
        min-height: 0;
        padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px));
        border-radius: 18px 18px 0 0;
        box-sizing: border-box;
    }
    .emoji-tabs button {
        min-height: 36px;
        height: 36px;
        font-size: 13px;
        padding: 0 4px;
        touch-action: manipulation;
    }
    .emoji-grid {
        flex: 1 1 auto;
        min-height: 0;
        grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
        gap: 8px;
    }
    .emoji-grid.is-sticker-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .emoji-item {
        height: 48px;
    }
    .emoji-item.is-sticker {
        height: 96px;
    }
    .emoji-item .emoji-sticker {
        width: 80px;
        height: 80px;
    }
}

/* ===== 消息提醒 ===== */
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.topbar-actions .topbar-avatar { margin-left: 0; }
.notif { position: relative; }
.notif-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--muted-text);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.notif-toggle:hover { background: var(--surface-2); color: var(--theme-text); }
.notif-toggle .nav-icon { width: 22px; height: 22px; }
.notif-dot {
    position: absolute;
    top: 4px;
    right: 3px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: #e53935;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.notif-dot[hidden] { display: none; }
.notif-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: min(340px, 86vw);
    max-height: 70vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border-radius: 14px;
    border: 1px solid var(--surface-border);
    background: var(--surface-1);
    box-shadow: var(--surface-shadow-soft, 0 12px 40px rgba(0, 0, 0, 0.28));
    z-index: 60;
}
.notif-panel[hidden] { display: none; }
.notif-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
}
.notif-readall {
    border: none;
    background: none;
    color: var(--theme-primary);
    font-size: 12px;
    cursor: pointer;
    padding: 2px 4px;
}
.notif-readall:hover { text-decoration: underline; }
.notif-list { overflow-y: auto; }
.notif-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 14px;
    border-bottom: 1px solid var(--line);
    color: var(--ink);
    text-decoration: none;
    transition: background 0.2s;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--surface-2); }
.notif-item.is-unread { background: color-mix(in srgb, var(--theme-primary) 8%, transparent); }
.notif-avatar { flex-shrink: 0; }
.notif-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.notif-text { font-size: 13px; line-height: 1.5; word-break: break-word; }
.notif-time { font-size: 11px; color: var(--muted-text); }
.notif-empty { padding: 28px 14px; text-align: center; color: var(--muted-text); font-size: 13px; }
.notif-head-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}
.notif-sound {
    border: none;
    background: none;
    color: var(--muted-text);
    font-size: 12px;
    cursor: pointer;
    padding: 2px 4px;
}
.notif-sound:hover { color: var(--theme-primary); }
