/* ============ 基础 ============ */
:root {
    --bg: #f7f5f0;
    --surface: #ffffff;
    --surface-2: #efece4;
    --text: #2f2c27;
    --muted: #8d887e;
    --line: #e6e1d7;
    --accent: #6f8f86;
    --accent-dark: #587a70;
    --accent-soft: #e7efeb;
    --clay: #c08a72;
    --danger: #b4544a;
    --danger-soft: #f7ebe9;
    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 8px 30px rgba(60, 50, 35, .07);
    --topbar: 57px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0 0 8px; font-weight: 600; letter-spacing: .01em; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 14px; }

p { margin: 0 0 8px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.center { text-align: center; }
.spacer { flex: 1; }
.hidden, [hidden] { display: none !important; }

/* ============ 顶部导航 ============ */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    height: var(--topbar);
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 0 22px;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}

.brand {
    font-weight: 700;
    font-size: 17px;
    color: var(--text);
    letter-spacing: .06em;
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-shrink: 0;
    white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand span {
    font-size: 11px;
    font-weight: 400;
    color: var(--muted);
    letter-spacing: .12em;
}

.mainnav { display: flex; gap: 6px; }
.mainnav a {
    padding: 6px 12px;
    border-radius: 999px;
    color: var(--muted);
    font-size: 14px;
}
.mainnav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.mainnav a.active { background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.net-badge {
    font-size: 12px;
    color: var(--accent-dark);
    background: var(--accent-soft);
    border-radius: 999px;
    padding: 2px 10px;
}
.net-badge.offline { color: var(--muted); background: var(--surface-2); }

.nick-badge {
    font-size: 13px;
    padding: 3px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============ 通用组件 ============ */
.page {
    max-width: 1180px;
    margin: 0 auto;
    padding: 24px 20px 48px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 9px 16px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.3;
    cursor: pointer;
    background: var(--surface-2);
    color: var(--text);
    transition: background .15s, border-color .15s, color .15s, transform .05s;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); color: #fff; }

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

.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: #efd9d6; }
.btn-danger:hover { background: #f2ddda; }

.btn-sm { padding: 5px 11px; font-size: 13px; }
.btn-block { width: 100%; }

.link-btn {
    border: 0;
    background: none;
    padding: 0;
    font: inherit;
    font-size: 12px;
    color: var(--muted);
    cursor: pointer;
}
.link-btn:hover { color: var(--accent-dark); text-decoration: underline; }

.icon-btn {
    border: 0;
    background: transparent;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 6px;
    border-radius: 8px;
    color: var(--muted);
}
.icon-btn:hover { background: var(--surface-2); }

.pill {
    font-size: 12px;
    background: var(--surface-2);
    color: var(--muted);
    border-radius: 999px;
    padding: 1px 9px;
}

.eyebrow {
    font-size: 11px;
    letter-spacing: .16em;
    color: var(--muted);
    text-transform: uppercase;
}

.field { display: block; margin-bottom: 16px; }
.field > span {
    display: block;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 6px;
}
.field > span em { font-style: normal; font-size: 12px; color: #b3ada2; }
.field legend {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 8px;
    padding: 0;
}

input[type="text"], input[type="password"], input[type="url"], input[type="number"], input[type="email"], textarea, select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font: inherit;
    font-size: 14px;
    color: var(--text);
    background: #fdfcf9;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(111, 143, 134, .14);
}
textarea { resize: vertical; min-height: 54px; }

.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; }

.radio-line { display: block; font-size: 14px; color: var(--text); margin-bottom: 4px; cursor: pointer; }
.radio-line input { margin-right: 6px; }

.check-line {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    margin: 8px 0;
}
.check-line input { width: 15px; height: 15px; accent-color: var(--accent); }

.form-error {
    color: var(--danger);
    background: var(--danger-soft);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 13px;
    margin: 0 0 12px;
}

.alert {
    background: var(--accent-soft);
    color: var(--accent-dark);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 16px;
}
.alert-error { background: var(--danger-soft); color: var(--danger); }

.row-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.empty-hint, .empty-card {
    color: var(--muted);
    text-align: center;
    padding: 40px 16px;
    font-size: 14px;
}

/* ============ 首页 ============ */
.hero { padding: 34px 4px 26px; max-width: 720px; }
.hero h1 { font-size: 34px; letter-spacing: .02em; }
.hero-sub { color: var(--muted); font-size: 15px; margin-top: 10px; }

.nick-panel { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.nick-current { display: flex; flex-direction: column; gap: 4px; }
.nick-current strong { font-size: 20px; }
.nick-form { max-width: 460px; width: 100%; }
.nick-form .field { margin-bottom: 12px; }

.entry-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-top: 22px;
}
.entry-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px 20px;
    color: var(--text);
    transition: transform .18s, box-shadow .18s, border-color .18s;
}
.entry-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
    border-color: #d8d0c2;
    text-decoration: none;
}
.entry-card h2 { font-size: 16px; margin: 6px 0 2px; }
.entry-card p { color: var(--muted); font-size: 13px; margin: 0; flex: 1; }
.entry-emoji { font-size: 24px; }
.entry-hint {
    margin-top: 12px;
    font-size: 11px;
    color: var(--accent-dark);
    background: var(--accent-soft);
    border-radius: 999px;
    padding: 2px 10px;
    align-self: flex-start;
}

.notice-strip {
    margin-top: 22px;
    padding: 14px 20px;
    border-radius: var(--radius);
    background: #f1ede4;
    color: #7c7568;
    font-size: 13px;
}
.notice-strip p { margin: 0; }

/* ============ 首页：云朵树洞 ============ */
.hero.cloud-stage {
    position: relative;
    max-width: none;
    min-height: 380px;
    display: flex;
    align-items: center;
    padding: 30px 4px;
    overflow: hidden;
}
.cloud-stage .hero-copy {
    position: relative;
    z-index: 4;
    max-width: 560px;
    pointer-events: none;
}
.cloud-stage .hero-copy a { pointer-events: auto; }

.cloud-layer {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
}

.cloud {
    position: absolute;
    left: 0;
    top: 0;
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: max-content;
    max-width: 220px;
    min-height: 62px;
    padding: 14px 22px;
    border: 0;
    border-radius: 24px 28px 22px 26px / 26px 30px 24px 22px;
    background: #ffffff;
    box-shadow: 0 12px 28px rgba(120, 108, 88, .13);
    color: #5f594e;
    font: inherit;
    font-size: 12.5px;
    line-height: 1.55;
    text-align: center;
    cursor: pointer;
    transform: translate3d(var(--x, 0px), var(--y, 0px), 0) rotate(var(--tilt, 0deg)) scale(var(--s, 1));
    transform-origin: 50% 50%;
    transition: box-shadow .2s ease, opacity .3s ease, filter .2s ease;
    will-change: transform;
}
/* 云朵随机色调：暖白、雾绿、淡蓝、浅粉、米黄、藕紫 */
.cloud.tone-1 { background: #fffdf8; }
.cloud.tone-2 { background: #f2f7f4; }
.cloud.tone-3 { background: #eef4fa; }
.cloud.tone-4 { background: #fbf2ee; }
.cloud.tone-5 { background: #f8f5e7; }
.cloud.tone-6 { background: #f3f0f8; }

/* 随机生成的小云团，拼出自然起伏的轮廓 */
.cloud-puff {
    position: absolute;
    z-index: 0;
    background: inherit;
    pointer-events: none;
}
.cloud-text {
    position: relative;
    z-index: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}
.cloud:hover,
.cloud:focus-visible {
    --s: 1.06;
    z-index: 8;
    box-shadow: 0 18px 40px rgba(120, 108, 88, .2);
}
.cloud:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}
.cloud.is-swapping { opacity: 0; }

.cloud-tools {
    position: absolute;
    left: 4px;
    right: 4px;
    bottom: 10px;
    z-index: 9;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}
.cloud-sub {
    margin: 0;
    min-width: 0;
    flex: 0 1 auto;
    font-size: clamp(11px, 1vw, 14px);
    font-weight: 500;
    line-height: 1.5;
    color: #46665e;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .12);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(247, 245, 240, .9);
    backdrop-filter: blur(2px);
}
.cloud-toggle,
.cloud-more { flex: none; }
.cloud-toggle {
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, .82);
    color: var(--muted);
    font: inherit;
    font-size: 12px;
    padding: 5px 12px;
    border-radius: 999px;
    cursor: pointer;
    transition: color .15s, border-color .15s, background .15s;
}
.cloud-toggle:hover {
    color: var(--accent-dark);
    border-color: #d6cec0;
    background: #fff;
}
.cloud-more {
    font-size: 12px;
    color: var(--accent-dark);
    background: var(--accent-soft);
    border-radius: 999px;
    padding: 5px 13px;
    transition: background .15s;
}
.cloud-more:hover {
    text-decoration: none;
    background: #dce9e3;
}

/* 云朵详情弹窗 */
.cloud-modal-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--muted);
    margin: 6px 0 12px;
}
.cloud-modal-meta .th-card-time { margin-left: auto; }
.cloud-modal-content {
    font-size: 15px;
    line-height: 1.85;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0 0 14px;
}
.cloud-modal-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    border-top: 1px dashed var(--line);
    padding-top: 10px;
}
.cloud-modal-actions .cloud-detail-count { margin-left: auto; }
.cloud-guest-hint {
    margin: 10px 0 0;
    padding: 8px 12px;
    background: #fbf8f1;
    border-radius: var(--radius-sm);
}
.cloud-comments { margin-top: 14px; }
.cloud-comments:empty { display: none; }

@media (max-width: 860px) {
    .hero.cloud-stage { min-height: 340px; padding: 24px 4px; }
}
@media (max-width: 760px) {
    .cloud-tools { flex-wrap: wrap; }
    .cloud-sub { flex: 0 0 auto; margin-left: auto; max-width: 100%; text-align: right; }
}
@media (max-width: 520px) {
    .hero.cloud-stage { min-height: 320px; }
    .cloud { max-width: 180px; font-size: 12px; padding: 12px 18px; }
    .cloud-tools { left: 0; right: 0; bottom: 4px; }
}
@media (max-width: 430px) {
    .cloud-sub { white-space: normal; overflow: visible; text-overflow: clip; }
}

/* ============ 聊天布局 ============ */
.page.page-hall, .page.page-room {
    max-width: 1240px;
    height: calc(100vh - var(--topbar));
    display: flex;
    padding: 16px 20px;
    overflow: hidden;
}

.chat-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 16px;
    width: 100%;
    min-height: 0;
}

.side-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    overflow: hidden;
}

.side-head { display: flex; align-items: center; justify-content: space-between; flex: none; }
.side-head h3 { margin: 0; }

.online-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 14px;
    flex: 1 1 auto;
    min-height: 60px;
    overflow-y: auto;
}
.online-list li {
    flex: none;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    border-radius: 8px;
}
.online-list li:hover { background: var(--surface-2); }
.online-list li::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #a9c6a2;
    flex: none;
}
.online-list li.muted::before { background: #cbc4b7; }
.online-list .owner-tag {
    font-size: 10px;
    color: var(--clay);
    border: 1px solid #ecd6ca;
    border-radius: 999px;
    padding: 0 6px;
    margin-left: auto;
}
.online-list .kick-btn { margin-left: auto; }
.online-list .owner-tag + .kick-btn { margin-left: 4px; }

.side-note {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px dashed var(--line);
    color: var(--muted);
    font-size: 12px;
    line-height: 1.7;
    flex: none;
}
.side-note p { margin: 0 0 4px; }
.side-actions { display: flex; gap: 8px; flex-wrap: wrap; flex: none; }

.room-brief h2 { font-size: 17px; margin-bottom: 4px; }
.room-code {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    padding: 7px 10px;
    margin: 10px 0 8px;
    font-size: 12px;
    color: var(--muted);
}
.room-code strong { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .12em; color: var(--text); font-size: 14px; }
.room-code .link-btn { margin-left: auto; }

.owner-panel {
    border-top: 1px dashed var(--line);
    padding-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.owner-panel h3 { margin-bottom: 2px; }
.field.compact { margin-bottom: 0; }
.field.compact > span { font-size: 12px; }

.chat-main {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.chat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--line);
}
.chat-head h2 { font-size: 16px; margin: 0; }
.chat-head p { margin: 2px 0 0; }

.conn-state { font-size: 12px; color: var(--muted); }
.conn-state.ok { color: var(--accent-dark); }
.conn-state.bad { color: var(--danger); }

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px 20px 8px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 0;
}

.msg { max-width: 78%; align-self: flex-start; }
.msg.self { align-self: flex-end; text-align: right; }
.msg-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 3px;
}
.msg.self .msg-meta { justify-content: flex-end; }
.msg-nick { color: #6d675d; }
.msg-time { color: #b6b0a5; }
.report-btn, .recall-btn { opacity: 0; transition: opacity .15s; }
.msg:hover .report-btn, .msg:hover .recall-btn { opacity: 1; }

.msg-body {
    display: inline-block;
    background: var(--surface-2);
    border-radius: 12px;
    padding: 9px 13px;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    text-align: left;
}
.msg.self .msg-body { background: var(--accent); color: #fff; }
.msg-body.recalled { color: var(--muted); font-style: italic; background: transparent; border: 1px dashed var(--line); }
.msg.self .msg-body.recalled { color: var(--muted); background: transparent; }

/* 消息操作：更多按钮 / 引用预览 / 定位高亮 */
.msg-actions-btn { opacity: 0; transition: opacity .15s; }
.msg:hover .msg-actions-btn { opacity: 1; }
@media (hover: none) {
    .msg-actions-btn { display: none; }
}

.msg-quote {
    max-width: 100%;
    margin: 0 0 6px;
    padding: 4px 9px;
    border-left: 3px solid rgba(111, 143, 134, .55);
    background: rgba(111, 143, 134, .1);
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.45;
    text-align: left;
    cursor: pointer;
}
.msg-quote:hover { background: rgba(111, 143, 134, .18); }
.msg-quote-nick { display: block; font-weight: 600; color: var(--accent-dark); }
.msg-quote-text {
    display: block;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.msg.self .msg-quote {
    border-left-color: rgba(255, 255, 255, .6);
    background: rgba(255, 255, 255, .16);
}
.msg.self .msg-quote-nick { color: #fff; }
.msg.self .msg-quote-text { color: rgba(255, 255, 255, .85); }

@keyframes msgFlash {
    0%, 100% { box-shadow: 0 0 0 0 rgba(192, 138, 114, 0); }
    20%, 60% { box-shadow: 0 0 0 3px rgba(192, 138, 114, .55); }
}
.msg.msg-flash .msg-body { animation: msgFlash 1.4s ease; }

.msg-menu {
    position: fixed;
    z-index: 260;
    min-width: 176px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}
.msg-menu[hidden] { display: none; }
.msg-menu-item {
    display: block;
    width: 100%;
    padding: 8px 10px;
    border: 0;
    border-radius: 7px;
    background: none;
    color: var(--text);
    font-size: 13px;
    text-align: left;
    cursor: pointer;
}
.msg-menu-item:hover { background: var(--surface-2); }
.msg-menu-title { padding: 6px 10px 2px; font-size: 11px; color: var(--muted); }
.msg-menu-reacts { display: flex; gap: 4px; padding: 0 4px 4px; }
.msg-menu-reacts button {
    flex: 1;
    padding: 5px 4px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font-size: 12px;
    white-space: nowrap;
    cursor: pointer;
}
.msg-menu-reacts button:hover { background: var(--surface-2); }
.msg-menu-reacts button.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.msg-menu-sep { height: 1px; margin: 5px 4px; background: var(--line); }

/* 大厅：.msg-body 内新增了引用/正文块，模板缩进空白不能被 pre-wrap 渲染成空行 */
.page-hall .msg-body { white-space: normal; }
.page-hall .msg-text { white-space: pre-wrap; word-break: break-word; }

.composer {
    position: relative;
    border-top: 1px solid var(--line);
    padding: 10px 16px 12px;
    background: #fbfaf6;
}
.composer-row { display: flex; align-items: flex-end; gap: 8px; }
.composer-quote {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    padding: 6px 10px;
    background: var(--surface-2);
    border-left: 3px solid var(--accent);
    border-radius: 8px;
}
.composer-quote[hidden] { display: none; }
.composer-quote-main { flex: 1; min-width: 0; }
.composer-quote-nick { font-size: 12px; font-weight: 600; color: var(--accent-dark); }
.composer-quote-text {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.composer textarea {
    flex: 1;
    min-height: 42px;
    max-height: 120px;
    resize: none;
    background: var(--surface);
}
.composer-meta {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--muted);
    padding: 4px 4px 0;
}

.emoji-panel {
    position: absolute;
    bottom: calc(100% - 6px);
    left: 16px;
    width: 268px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    padding: 8px;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    z-index: 20;
}
.emoji-panel button {
    border: 0;
    background: none;
    font-size: 18px;
    padding: 4px;
    cursor: pointer;
    border-radius: 6px;
}
.emoji-panel button:hover { background: var(--surface-2); }

/* ============ 表单页 ============ */
.page.page-form { max-width: 620px; }
.form-wrap { padding-top: 18px; }
.form-head { margin-bottom: 18px; }
.form-head h1 { font-size: 26px; }
.form-card { padding: 26px; }
.form-card .btn-block { margin-top: 6px; }

/* ============ 树洞 ============ */
.page.page-treehole { max-width: 780px; }
.th-page { padding-top: 6px; }

.th-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 0 14px;
}
.th-head h1 { font-size: 28px; }
.th-head p { margin: 4px 0 0; }

.th-tabs {
    display: flex;
    align-items: center;
    gap: 6px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 14px;
    padding-bottom: 8px;
}
.th-tab {
    border: 0;
    background: none;
    font: inherit;
    font-size: 14px;
    color: var(--muted);
    padding: 6px 12px;
    border-radius: 999px;
    cursor: pointer;
}
.th-tab.active { background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }
.th-tabs-note { margin-left: auto; }

.th-toolbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.th-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--muted);
    font: inherit;
    font-size: 12px;
    padding: 4px 11px;
    border-radius: 999px;
    cursor: pointer;
    transition: all .15s;
}
.chip:hover { border-color: #d6cec0; color: var(--text); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--muted);
    cursor: pointer;
    white-space: nowrap;
    padding-top: 3px;
}
.switch input { width: 15px; height: 15px; accent-color: var(--clay); }

.th-list { display: flex; flex-direction: column; gap: 14px; }

.th-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 18px 12px;
    box-shadow: 0 2px 10px rgba(60, 50, 35, .03);
}
.th-card-head {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 8px;
}
.th-card-tag {
    background: var(--accent-soft);
    color: var(--accent-dark);
    border-radius: 999px;
    padding: 1px 9px;
    font-size: 11px;
}
.th-card-mine {
    color: var(--clay);
    font-size: 11px;
    border: 1px solid #ecd6ca;
    border-radius: 999px;
    padding: 0 7px;
}
.th-card-time { margin-left: auto; }
.th-card-content {
    font-size: 15px;
    line-height: 1.75;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0 0 10px;
}
.th-card-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    border-top: 1px dashed var(--line);
    padding-top: 8px;
}
.react-btn {
    border: 0;
    background: none;
    font: inherit;
    font-size: 12px;
    color: var(--muted);
    padding: 3px 9px;
    border-radius: 999px;
    cursor: pointer;
}
.react-btn:hover { background: var(--surface-2); color: var(--text); }
.react-btn.active { background: #f6eee9; color: var(--clay); }
.th-card-actions .link-btn { margin-left: 6px; }
.th-card-actions .mine-actions { margin-left: auto; display: flex; gap: 10px; }

.load-more { text-align: center; padding: 20px 0 0; }

.th-footer-note {
    margin-top: 28px;
    padding: 16px 18px;
    border-radius: var(--radius);
    background: #f1ede4;
    color: #7c7568;
    font-size: 13px;
}
.th-footer-note p { margin: 0 0 4px; }
.th-footer-note a { color: var(--accent-dark); }

.diary-card .th-card-content { font-size: 14px; }

/* 限时置顶区 */
.th-pin-zone {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius);
    background: #f8f3ea;
    border: 1px dashed #e2d6c2;
}
.th-card.is-pinned {
    border-color: #e3d3b8;
    box-shadow: 0 2px 12px rgba(160, 120, 60, .08);
}
.th-card-pin {
    background: #f2e2c8;
    color: #8a5a20;
    border-radius: 999px;
    padding: 1px 9px;
    font-size: 11px;
    font-weight: 600;
}

/* ============ 弹窗 ============ */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(45, 40, 32, .38);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(2px);
}
.modal-card {
    width: 100%;
    max-width: 460px;
    max-height: 88vh;
    overflow-y: auto;
    background: var(--surface);
    border-radius: 16px;
    padding: 22px;
    box-shadow: 0 24px 60px rgba(40, 30, 20, .2);
}
.modal-wide { max-width: 560px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; align-items: center; }

.convention {
    background: #fbf8f1;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin: 10px 0 16px;
    font-size: 12px;
    color: #6d675d;
}
.convention strong { display: block; margin-bottom: 4px; color: var(--text); }
.convention ul { margin: 0 0 6px; padding-left: 16px; line-height: 1.75; }
.convention li { margin-bottom: 2px; }

.counter {
    display: block;
    text-align: right;
    font-size: 11px;
    color: var(--muted);
    margin-top: 4px;
}

.draft-box {
    border: 1px dashed var(--line);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-top: 10px;
}
.draft-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.draft-list { list-style: none; margin: 6px 0 0; padding: 0; max-height: 110px; overflow-y: auto; }
.draft-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #6d675d;
    padding: 4px 0;
    border-top: 1px solid #f2eee6;
}
.draft-list li:first-child { border-top: 0; }
.draft-list .draft-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}
.draft-list .draft-text:hover { color: var(--accent-dark); text-decoration: underline; }

.copy-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-bottom: 10px;
}
.copy-label { font-size: 12px; color: var(--muted); width: 44px; }
.copy-box strong { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .1em; }
.copy-box .btn { margin-left: auto; }

.comment-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 340px;
    overflow-y: auto;
    margin: 10px 0;
}
.comment-item { background: #fbfaf6; border-radius: var(--radius-sm); padding: 9px 12px; font-size: 13px; }
.comment-item .comment-meta { display: flex; gap: 8px; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.comment-item .comment-meta .link-btn { margin-left: auto; }
.comment-composer { display: flex; gap: 8px; }
.comment-composer input { flex: 1; }

.warm-card { text-align: center; padding: 30px 24px; }
.warm-text { font-size: 18px; line-height: 1.8; color: var(--accent-dark); margin: 6px 0 18px; }

/* ============ 后台 ============ */
.page-admin { background: #f4f2ec; }
.admin-login {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.admin-login .form-card { width: 100%; max-width: 380px; }
.admin-login h1 { font-size: 22px; }

.admin-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}
.admin-top strong { margin-right: 10px; }

.admin-main { max-width: 1120px; margin: 0 auto; padding: 22px 20px 60px; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin-bottom: 18px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.stat-card span { font-size: 12px; color: var(--muted); }
.stat-card strong { font-size: 22px; font-weight: 600; }

.admin-tabs { display: flex; gap: 4px; margin-bottom: 14px; flex-wrap: wrap; }
.admin-tabs a {
    padding: 7px 14px;
    border-radius: 999px;
    font-size: 13px;
    color: var(--muted);
}
.admin-tabs a:hover { background: var(--surface-2); text-decoration: none; }
.admin-tabs a.active { background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }

.admin-section { margin-bottom: 18px; padding: 18px 20px; }
.admin-section h2 { font-size: 16px; margin-bottom: 12px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.section-head h2 { margin: 0; }

.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th, .admin-table td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}
.admin-table th { color: var(--muted); font-weight: 500; font-size: 12px; }
.cell-text { max-width: 380px; word-break: break-word; white-space: pre-wrap; }
.cell-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.cell-actions form { display: inline; }
.tag-pending { color: var(--clay); }

.inline-form { display: flex; gap: 8px; max-width: 360px; margin-bottom: 14px; }
.admin-section .inline-form { max-width: 640px; flex-wrap: wrap; }
.admin-section .inline-form input[type="text"] { flex: 1; min-width: 180px; }
.admin-section .inline-form select { padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }
.admin-table .pin-form { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 0 0 6px; }
.admin-table .pin-form:last-child { margin-bottom: 0; }
.admin-table .pin-form input[type="datetime-local"] {
    padding: 5px 7px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 12px;
}
.ai-checks { display: flex; flex-wrap: wrap; gap: 10px 24px; margin-bottom: 14px; font-size: 13px; }
.ai-checks label { display: flex; align-items: center; gap: 6px; }
.ai-form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 14px; margin-bottom: 14px; }
.ai-edit-box { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; margin: 14px 0; background: var(--surface-soft, rgba(0, 0, 0, .02)); }
.ai-edit-box h3 { margin: 0 0 10px; font-size: 14px; }
.ai-role-edit { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; max-width: 420px; }
.ai-role-edit input { flex: 1; min-width: 120px; }
.msg.is-ai .msg-nick { color: var(--accent-dark); }
.th-card-ai {
    font-size: 11px;
    color: var(--accent-dark);
    background: var(--accent-soft);
    border-radius: 999px;
    padding: 1px 8px;
}
.word-list { display: flex; flex-wrap: wrap; gap: 8px; }
.word-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-2);
    border-radius: 999px;
    padding: 3px 12px;
    font-size: 13px;
}

/* ============ 响应式 ============ */
@media (max-width: 980px) {
    .entry-grid { grid-template-columns: repeat(2, 1fr); }
    .stat-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 860px) {
    .ai-form-grid { grid-template-columns: 1fr 1fr; }
    .topbar { gap: 12px; padding: 0 14px; }
    .brand span { display: none; }
    .mainnav a { padding: 5px 9px; font-size: 13px; }
    .nick-badge { display: none; }

    .page.page-hall, .page.page-room {
        height: auto;
        min-height: calc(100vh - var(--topbar));
        overflow: visible;
        padding: 12px;
    }
    .chat-layout { grid-template-columns: 1fr; }
    .side-panel { max-height: none; }
    .online-list { max-height: 38vh; }
    .chat-main { min-height: 68vh; }
    .messages { max-height: 60vh; }
    .msg { max-width: 88%; }

    .th-head { flex-direction: column; }
    .th-tabs-note { display: none; }
    .hero h1 { font-size: 26px; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .admin-table { font-size: 12px; }
    .cell-text { max-width: 180px; }
}

@media (max-width: 520px) {
    .entry-grid { grid-template-columns: 1fr; }
    .page { padding: 16px 14px 40px; }
    .modal { padding: 10px; align-items: flex-end; }
    .modal-card { max-height: 92vh; }
}

/* ============ 站点设置：Logo 与页脚 ============ */
.brand-logo {
    height: 28px;
    width: auto;
    max-width: 120px;
    object-fit: contain;
    border-radius: 6px;
}

.site-footer {
    max-width: 1180px;
    margin: 0 auto;
    padding: 18px 20px 34px;
    text-align: center;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.9;
}
.site-footer p { margin: 0; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--accent-dark); }
.friend-links .sep { margin: 0 6px; color: #c8c2b6; }

.link-grid {
    display: grid;
    grid-template-columns: 1fr 2fr 100px 120px;
    gap: 0 14px;
}
.link-grid > .field { min-width: 0; margin-bottom: 12px; }

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 18px;
}
.settings-grid .field.full { grid-column: 1 / -1; }
.site-logo-preview img {
    max-height: 64px;
    width: auto;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 6px;
    background: #fdfcf9;
}

@media (max-width: 760px) {
    .settings-grid { grid-template-columns: 1fr; }
    .link-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 520px) {
    .link-grid { grid-template-columns: 1fr; }
}

/* ============ 手机端：导航分两行、输入框尺寸 ============ */
@media (max-width: 520px) {
    :root { --topbar: 86px; }

    .topbar {
        height: var(--topbar);
        flex-wrap: wrap;
        align-content: center;
        gap: 6px 8px;
        padding: 8px 12px;
    }
    .brand { font-size: 16px; }
    .brand-logo { height: 24px; max-width: 40px; }
    .topbar-right { gap: 6px; }
    .net-badge { font-size: 11px; padding: 2px 8px; }
    .topbar-right .btn-sm { padding: 5px 10px; font-size: 12px; }

    .mainnav {
        order: 3;
        width: 100%;
        gap: 4px;
    }
    .mainnav a {
        flex: 1;
        padding: 7px 2px;
        font-size: 13px;
        text-align: center;
        white-space: nowrap;
    }

    .composer {
        padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    }
    .composer-row { align-items: center; gap: 6px; }
    .composer textarea {
        min-height: 44px;
        padding: 10px 12px;
        font-size: 16px;
        line-height: 1.4;
    }
    .composer-row .btn { height: 44px; padding: 0 14px; flex-shrink: 0; }
    .composer-row .icon-btn { width: 44px; height: 44px; flex-shrink: 0; }
    .composer-meta { padding: 3px 2px 0; }

    .chat-head { padding: 12px; }
    .messages { padding: 12px 12px 6px; gap: 12px; }
}
