:root {
    --bg: #faf7f0;
    --card: #ffffff;
    --ink: #3a3a35;
    --muted: #666258;
    --gold: #8a6508;
    --gold-dark: #6f5205;
    --line: #e6e0d0;
    --ok: #4c8a4f;
    --warn: #c0392b;
    --hl: #ffe9a8;
}

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

html, body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.7;
}

a { color: var(--gold-dark); text-decoration: none; }

.btn {
    display: inline-block;
    border: 1px solid #6f5205;
    background: linear-gradient(180deg, #8a6508 0%, #6f5205 100%);
    color: #fff;
    padding: 10px 22px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    box-shadow: 0 2px 6px rgba(150, 112, 15, .22);
    transition: background .2s, border-color .2s, box-shadow .2s;
    -webkit-user-select: none;
    user-select: none;
}
.btn:hover {
    background: linear-gradient(180deg, #765406 0%, #5c4304 100%);
    border-color: #523b03;
    box-shadow: 0 4px 12px rgba(150, 112, 15, .3);
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.ghost {
    background: #fff;
    color: #8a6d1f;
    border: 1px solid #dccfa8;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .05);
}
.btn.ghost:hover {
    background: #faf6ea;
    border-color: #c3a55c;
    color: #6b5b2f;
    box-shadow: 0 2px 6px rgba(150, 112, 15, .15);
}
.btn.danger {
    background: linear-gradient(180deg, #c25a52 0%, #b0392f 100%);
    border-color: #9e2f26;
    box-shadow: 0 2px 6px rgba(160, 57, 47, .25);
}
.btn.danger:hover {
    background: linear-gradient(180deg, #b0392f 0%, #992a21 100%);
    border-color: #8a251d;
    box-shadow: 0 4px 12px rgba(160, 57, 47, .3);
}
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; }

input[type="text"], input[type="password"], textarea, select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    font-size: 15px;
    background: #fff;
    color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: 2px solid #e6c96a; border-color: var(--gold); }
textarea { resize: vertical; min-height: 80px; }

label { display: block; margin-bottom: 6px; font-size: 14px; color: var(--muted); }

.hint { font-size: 13px; color: var(--muted); }

/* ---------- 首页 ---------- */
.page-home {
    height: 100vh;
    height: 100svh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 20px;
    overflow: hidden;
    background: linear-gradient(180deg, #f6efe0 0%, var(--bg) 100%);
}
.home-main {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.home-card {
    width: 100%;
    max-width: 420px;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    margin: auto;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 28px 24px;
    text-align: center;
    box-shadow: 0 8px 30px rgba(120, 90, 20, .08);
}
.home-card > *:not(.home-pick) { flex-shrink: 0; }
.home-card > .btn { align-self: center; }
.home-card h1 { font-size: 24px; letter-spacing: 2px; color: #6b5b2f; margin-bottom: 4px; }
.home-card .sub { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.home-card .actions { display: flex; flex-direction: column; gap: 14px; margin-bottom: 26px; }
.home-card .enter { display: flex; gap: 10px; }
.home-card .pick-hint { color: #6b5b2f; font-size: 15px; margin-bottom: 8px; }
.home-card .home-steps {
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
    counter-reset: home-step;
    text-align: left;
}
.home-card .home-steps li {
    counter-increment: home-step;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    color: #555148;
    font-size: 15px;
    line-height: 1.6;
    margin-top: 6px;
}
.home-card .home-steps li::before {
    content: counter(home-step);
    flex: 0 0 22px;
    width: 22px;
    height: 22px;
    margin-top: 1px;
    border-radius: 50%;
    background: #f0e7cc;
    color: #6f5205;
    font-size: 13px;
    line-height: 22px;
    text-align: center;
    font-weight: 600;
}
.active-session-card {
    margin: 4px 0 14px;
    padding: 12px;
    border: 1px solid #dccfa8;
    border-radius: 8px;
    background: #faf6ea;
    text-align: left;
}
.active-session-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 10px;
}
.active-session-main strong { color: #5e4505; font-size: 16px; }
.active-session-main span { color: var(--muted); font-size: 14px; }
.active-session-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.enter input { flex: 1; }

/* ---------- 首页底部：账号 / 快捷操作 / 帮助 ---------- */
.home-footer {
    flex: 0 0 auto;
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
}
.home-account {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    min-height: 30px;
}
.account-badge { font-size: 13px; color: var(--muted); }
.home-quick {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

/* ---------- 通用头部 ---------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: #fff;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: 44px;
}
.topbar .brand { font-size: 17px; color: #6b5b2f; letter-spacing: 1px; white-space: nowrap; flex-shrink: 0; }
.topbar .row { display: flex; align-items: center; gap: 10px; flex-shrink: 1; min-width: 0; }
.topbar .home-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    color: #6b5b2f;
    text-decoration: none;
    flex-shrink: 0;
}
.topbar .home-link:hover { background: rgba(0, 0, 0, .06); }
.topbar .home-link svg { width: 22px; height: 22px; display: block; }

/* ---------- 页面主体 ---------- */
.container { max-width: 860px; margin: 0 auto; padding: 16px; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 14px; }

.ritual-title {
    font-size: 20px;
    font-weight: 600;
    color: #6b5b2f;
    text-align: center;
    padding: 10px 0 4px;
    letter-spacing: 1px;
}

/* ---------- 仪轨正文 ---------- */
.ritual-body {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 22px 26px;
    margin: 10px 0;
    font-size: 18px;
    line-height: 2;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: calc(100vh - 220px);
    max-height: calc(100dvh - 220px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    -webkit-user-select: text;
    user-select: text;
    -webkit-touch-callout: default;
    position: relative;
    overscroll-behavior: contain;
}
.ritual-body p { margin: 0; padding: 2px 0; border-radius: 4px; transition: background .15s; }
.ritual-body p.hl { background: var(--hl); }
.ritual-body p.hl-flash { background: var(--hl); }

/* ---------- 仪轨正文 HTML 排版（h/列表/分隔线） ---------- */
.ritual-body div { margin: 0; }
.ritual-body .syncplay-edge { height: 50vh; }
.ritual-body h1, .ritual-body h2, .ritual-body h3,
.ritual-body h4, .ritual-body h5, .ritual-body h6 {
    margin: .7em 0 .35em;
    font-weight: 600;
    line-height: 1.5;
    color: #6b5b2f;
}
.ritual-body h1 { font-size: 24px; letter-spacing: 1px; }
.ritual-body h2 { font-size: 21px; }
.ritual-body h3 { font-size: 18px; }
.ritual-body h4 { font-size: 17px; }
.ritual-body h5, .ritual-body h6 { font-size: 16px; }
.ritual-body ul, .ritual-body ol {
    margin: .4em 0 .4em 1.8em;
    padding: 0;
}
.ritual-body ul { list-style: disc; }
.ritual-body ol { list-style: decimal; }
.ritual-body li { margin: .15em 0; padding-left: .2em; }
.ritual-body li p, .ritual-body li div { margin: 0; }
.ritual-body hr {
    border: none;
    border-top: 1px solid var(--line);
    margin: 16px 0;
}
.ritual-body span, .ritual-body b, .ritual-body i, .ritual-body u { color: inherit; }
.ritual-body font[size="7"] { font-size: 26px; }
.ritual-body font[size="6"] { font-size: 22px; font-weight: 600; }
.ritual-body font[size="5"] { font-size: 18px; font-weight: 600; }
.ritual-body font[size="4"] { font-size: 16px; }

/* ---------- 未开始共修时的仪轨列表 ---------- */
.ritual-pick { padding: 8px 0; }
.ritual-pick .pick-title { text-align: center; color: #6b5b2f; font-size: 15px; margin-bottom: 14px; }
.ritual-card {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    width: 100%; box-sizing: border-box; margin: 0 0 12px; padding: 14px 16px;
    background: #fff; border: 1px solid var(--line); border-radius: 10px;
    font-size: 15px; color: #333; cursor: pointer; text-align: left;
    transition: border-color .15s, box-shadow .15s;
}
.ritual-card:hover { border-color: #c3a55c; box-shadow: 0 2px 8px rgba(0,0,0,.05); }
.ritual-card .name { flex: 1; }
.ritual-card .tag { font-size: 13px; color: #3f6733; background: #edf5e8; border-radius: 20px; padding: 2px 10px; white-space: nowrap; }
.ritual-card.off .tag { color: #aaa; background: #f2f2f2; }
.ritual-card.off { cursor: not-allowed; opacity: .75; }
.ritual-card.sel { border-color: #c3a55c; background: #faf6ea; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.ritual-card.private { border-color: #c3a55c; background: #fbf6e8; }
.ritual-card.private .tag { color: #8a6d1f; background: #f4e7c3; }
.home-pick { flex: 0 1 auto; min-height: 0; overflow-y: auto; margin: 0 0 14px; padding: 0; }
a.btn { display: inline-block; text-decoration: none; text-align: center; box-sizing: border-box; }
.help-link { color: var(--muted); font-size: 13px; text-decoration: none; border-bottom: 1px dashed var(--line); }
.help h1 { margin: 24px 0 6px; }
.help h2 { font-size: 17px; color: #6b5b2f; margin: 26px 0 10px; border-left: 3px solid #c3a55c; padding-left: 10px; }
.help h3 { font-size: 15px; margin: 14px 0 6px; }
.help p, .help li { line-height: 1.75; color: #4a4a4a; }
.help ol, .help ul { padding-left: 1.4em; }
.help li { margin: 2px 0; }
.help .panel { margin: 8px 0 14px; }
.help code { background: #f4f1e8; border-radius: 4px; padding: 1px 6px; font-size: 13px; margin: 0 2px; }

/* ---------- 移动端通用修复 ---------- */
/* 防止内容溢出 */
html, body {
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

/* 修复移动端100vh问题 */
:root {
    --vh: 1vh;
}

@supports (height: 100dvh) {
    .page-home {
        height: 100dvh;
    }
}

.page-home {
    height: calc(var(--vh, 1vh) * 100);
}

/* 移动端输入框聚焦修复 */
input[type="text"], input[type="password"], textarea, select {
    -webkit-appearance: none;
    appearance: none;
    border-radius: 8px;
}

/* 移动端按钮点击反馈 */
.btn:active {
    transform: scale(0.98);
    transition: transform 0.1s;
}

/* ---------- 控制条 ---------- */
.control-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 12px;
    margin: 8px 0;
    font-size: 15px;
}
.control-bar .group { display: flex; align-items: center; gap: 8px; }
.conn-status { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.status-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #999;
    flex: 0 0 auto;
}
.status-dot.ok { background: #36833d; box-shadow: 0 0 0 3px rgba(54, 131, 61, .12); }
.status-dot.warn { background: #b26a00; box-shadow: 0 0 0 3px rgba(178, 106, 0, .12); }
.conn-banner {
    display: none;
    padding: 8px 14px;
    text-align: center;
    font-size: 14px;
    border-bottom: 1px solid transparent;
}
.conn-banner.show { display: block; }
.conn-banner.warn { color: #704400; background: #fff4e0; border-color: #efd29b; }
.conn-banner.error { color: #7f1d1d; background: #fdecea; border-color: #efb9b4; }
.conn-banner.ok { color: #245d2a; background: #e7f4e8; border-color: #b9dcbc; }

/* ---------- 模态 ---------- */
.modal-mask {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}
.modal-mask.show { display: flex; }
.modal-box {
    background: #fff;
    border-radius: 12px;
    max-width: 520px;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
    font-size: 16px;
    font-weight: 600;
}
.modal-head .x { cursor: pointer; color: var(--muted); font-size: 20px; line-height: 1; }
.modal-body { padding: 16px 18px; overflow-y: auto; flex: 1; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- 消息列表 ---------- */
.msg-list { display: flex; flex-direction: column; gap: 10px; }
.msg-item { background: #f5f2e8; border-radius: 8px; padding: 8px 12px; font-size: 14px; }
.msg-item .from { color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.msg-item .text { color: var(--ink); }
.msg-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    margin-left: 4px;
    padding: 0 5px;
    border-radius: 999px;
    background: #c0392b;
    color: #fff;
    font-size: 12px;
    line-height: 1;
}
.modal-help-link { margin-top: 14px; text-align: right; font-size: 14px; }
.join-more-actions { display: grid; gap: 10px; }
.join-more-actions .btn { width: 100%; }

/* ---------- 冲突告警 ---------- */
.alert-banner {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: #7f1d1d;
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    display: none;
    box-shadow: 0 6px 20px rgba(0,0,0,.25);
    z-index: 200;
    gap: 12px;
    align-items: center;
}
.alert-banner.show { display: flex; }

.resume-follow {
    position: fixed;
    right: 16px;
    bottom: 18px;
    z-index: 80;
    display: none;
    max-width: calc(100vw - 32px);
    padding: 10px 14px;
    font-size: 15px;
    white-space: nowrap;
}
.resume-follow.show { display: inline-block; }
.resume-follow.paused {
    color: #5f3d00;
    border-color: #c98a19;
    background: linear-gradient(180deg, #ffe8ae 0%, #f2c765 100%);
}

/* ---------- 二维码 ---------- */
.qr-wrap { text-align: center; }
.qr-wrap canvas, .qr-wrap img { max-width: 220px; width: 100%; }
.share-qr-hint { text-align: center; margin-top: 10px; color: var(--muted); font-size: 14px; }
.share-wechat-tip {
    margin-top: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    background: #edf5e8;
    color: #31552a;
    font-size: 14px;
}
.share-label { margin-top: 14px; color: var(--ink); font-size: 14px; }
.share-invite { min-height: 112px; font-family: inherit; font-size: 15px; line-height: 1.7; }
.share-actions { display: flex; gap: 8px; margin-top: 10px; }
.share-actions .btn { flex: 1; }
.share-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 4px;
    margin-bottom: 16px;
    border-radius: 8px;
    background: #f2eee3;
}
.share-tabs button {
    min-height: 42px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    font-size: 15px;
    cursor: pointer;
}
.share-tabs button.active {
    background: #fff;
    color: #5e4505;
    font-weight: 650;
    box-shadow: 0 1px 4px rgba(59,45,8,.12);
}
.share-pane[hidden] { display: none; }
.share-warning {
    margin-bottom: 12px;
    padding: 10px 12px;
    border: 1px solid #efd29b;
    border-radius: 8px;
    background: #fff7e8;
    color: #704400;
    font-size: 14px;
}
.share-link-details, .share-host {
    margin-top: 12px;
    border-top: 1px solid var(--line);
    padding-top: 10px;
}
.share-link-details summary, .share-host summary {
    cursor: pointer;
    color: #6f5205;
    font-size: 14px;
}
.share-link-row { display: flex; gap: 8px; margin-top: 8px; }
.share-link-row input { min-width: 0; flex: 1 1 auto; }
.share-link-row .btn {
    flex: 0 0 auto;
    min-width: 88px;
    padding-left: 12px;
    padding-right: 12px;
    white-space: nowrap;
}
.share-host .hint { margin: 8px 0; }
.help-steps { padding-left: 1.4em; }
.help-steps li { margin: 6px 0; }

.login-privacy { margin-top: 10px; color: var(--muted); font-size: 14px; text-align: center; }
.login-mobile-tip {
    margin-top: 10px;
    padding: 8px;
    text-align: left;
    line-height: 1.6;
    background: rgba(0, 0, 0, .04);
    border-radius: 8px;
}

.session-state-card {
    max-width: 480px;
    margin: 72px auto 0;
    padding: 30px 24px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    text-align: center;
    box-shadow: 0 8px 24px rgba(80, 60, 20, .08);
}
.session-state-icon {
    width: 52px;
    height: 52px;
    margin: 0 auto 14px;
    border-radius: 50%;
    background: #e7f4e8;
    color: #2f7137;
    font-size: 28px;
    line-height: 52px;
}
.session-state-card h1 { color: #5e4505; font-size: 22px; margin-bottom: 8px; }
.session-state-card p { color: var(--muted); margin-bottom: 20px; }
.flow-guide {
    margin-bottom: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    background: #faf6ea;
    color: #5f512c;
    font-size: 14px;
}

/* ---------- 超管后台 ---------- */
.sa-list table { width: 100%; border-collapse: collapse; font-size: 14px; }
.sa-list { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.sa-list th, .sa-list td { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; }
.sa-list th { color: var(--muted); font-weight: 500; }
.status-badge { padding: 2px 10px; border-radius: 20px; font-size: 12px; }

/* 待审核数量红点 */
.review-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    margin-left: 6px;
    border-radius: 999px;
    background: #e53935;
    color: #fff;
    font-size: 12px;
    line-height: 1;
    font-weight: 600;
    vertical-align: middle;
}
.btn .review-badge { color: #fff; }

/* 审核查看：仪轨全文 */
.review-content {
    max-height: 60vh;
    overflow-y: auto;
    font-size: 15px;
    line-height: 1.8;
    color: #333;
}
.review-content p { margin: 0 0 10px; }
.review-content h1, .review-content h2, .review-content h3 { color: #6b5b2f; margin: 16px 0 8px; }
.status-on { background: #e3f2e5; color: #2e7d32; }
.status-sub { background: #fff4e0; color: #b26a00; }
.status-off { background: #fbe9e7; color: #c62828; }
.status-rej { background: #fdecea; color: #c62828; }

.sa-edit textarea.content { min-height: 320px; font-family: inherit; font-size: 15px; }

/* ---------- toast ---------- */
.toast {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(30, 30, 30, .9);
    color: #fff;
    padding: 10px 22px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 300;
    opacity: 0;
    transition: opacity .3s;
    pointer-events: none;
}
.toast.show { opacity: 1; }
.toast.success { background: rgba(35, 92, 41, .95); }
.toast.error { background: rgba(127, 29, 29, .95); }
.toast.info { background: rgba(30, 30, 30, .9); }

.sa-editor-tabs {
    display: flex;
    gap: 6px;
    margin: 12px 0 8px;
}
.sa-editor-tabs button {
    flex: 1;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    font-size: 15px;
    cursor: pointer;
}
.sa-editor-tabs button.active {
    border-color: #a97f11;
    background: #f7eed4;
    color: #5e4505;
    font-weight: 600;
}
.sa-plain-wrap,
.sa-rich-wrap {
    display: flex;
    flex: 1;
    min-height: 0;
    flex-direction: column;
}
.sa-plain-wrap .hint { margin-top: 6px; }
.sa-edit-modal #sa-plain {
    flex: 1;
    min-height: 240px;
    resize: none;
    font-family: inherit;
    font-size: 16px;
    line-height: 1.8;
}
.sa-advanced {
    margin-top: 8px;
    color: var(--muted);
    font-size: 14px;
}
.sa-advanced summary { cursor: pointer; }
.sa-advanced button { margin-top: 8px; }

@media (max-width: 560px) {
    .ritual-body { font-size: 18px; padding: 16px; }
    .home-card { padding: 30px 20px; }
    .modal-mask { padding: 12px; }
    .modal-head, .modal-body, .modal-foot { padding-left: 14px; padding-right: 14px; }
    
    /* 移动端顶部栏适配 */
    .topbar {
        padding: 8px 12px;
        flex-wrap: wrap;
        gap: 8px;
    }
    .topbar .row {
        flex-wrap: wrap;
        gap: 6px;
    }
    .topbar .btn {
        min-height: 44px;
        font-size: 15px;
        padding: 9px 10px;
    }
    
    /* 移动端容器适配 */
    .container {
        padding: 12px;
    }
    
    /* 移动端控制栏适配 */
    .control-bar {
        flex-direction: column;
        gap: 8px;
        padding: 10px;
    }
    .control-bar .group {
        width: 100%;
        justify-content: center;
    }
    .alert-banner {
        left: 12px;
        right: 12px;
        bottom: 12px;
        transform: none;
        flex-wrap: wrap;
        justify-content: center;
        text-align: center;
    }
    .alert-banner > span { flex: 1 0 100%; }
    .resume-follow { right: 12px; bottom: 12px; }
}

/* 超小屏（320-375px）：入口卡片与表格进一步收紧，避免挤压/裁切 */
@media (max-width: 400px) {
    .home-card { padding: 22px 14px; }
    .home-card h1 { font-size: 22px; }
    .home-card .enter { flex-direction: column; }
    .home-card .enter .btn { width: 100%; }
    .ritual-title { font-size: 18px; }
    .ritual-body { padding: 12px; font-size: 18px; }
    .container { padding: 12px; }
    .control-bar { padding: 6px 8px; }
    .topbar { padding: 8px 10px; }
    .sa-list th, .sa-list td { padding: 6px 4px; font-size: 13px; }
    
    /* 超小屏幕额外修复 */
    .topbar .row {
        gap: 4px;
    }
    .topbar .btn {
        min-height: 44px;
        font-size: 15px;
        padding: 9px 8px;
    }
    
    /* 修复内容溢出 */
    .ritual-body {
        max-height: calc(100dvh - 200px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* 移动端模态框适配 */
    .modal-mask {
        padding: 8px;
    }
    .modal-box {
        max-height: 85vh;
    }
}

/* 按钮自适应屏幕宽度 */
.topbar .row {
    flex-wrap: nowrap;
    overflow: visible;
}
.topbar .btn {
    min-height: 44px;
    font-size: 15px;
    padding: 9px 10px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ---------- 超管后台（仅 PC 使用） ---------- */
.sa-body .sa-container { max-width: 1100px; }
#sa-mobile-tip { display: none; }

/* 编辑/新增仪轨弹窗大屏化 */
body.sa-body .modal-mask { padding: 30px; }
.sa-edit-modal .modal-box {
    max-width: 900px;
    width: 100%;
    height: 90vh;
    max-height: none;
}
.sa-edit-modal .modal-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
    flex: 1;
}
.sa-edit-modal #sa-content {
    flex: 1;
    min-height: 0;
    resize: none;
    font-family: inherit;
    font-size: 15px;
}

/* ---------- 富文本编辑区 ---------- */
.sa-edit-modal .modal-head { display: none; }
.sa-edit-modal .sa-name-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 2px;
}
.sa-edit-modal .sa-name-row label {
    flex: 0 0 auto;
    margin: 0;
    white-space: nowrap;
}
.sa-edit-modal .sa-name-row input {
    flex: 0 1 340px;
    min-width: 0;
}
.sa-edit-modal .sa-name-row .sa-name-space { flex: 1; }
.sa-edit-modal .sa-name-row .sa-x {
    flex: 0 0 auto;
    cursor: pointer;
    color: var(--muted);
    font-size: 22px;
    line-height: 1;
    background: none;
    border: none;
    padding: 2px 8px;
}
.sa-edit-modal .sa-name-row .sa-x:hover { color: var(--warn); }
.sa-edit-modal .sa-edit-modes {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 12px 0 6px;
}
.sa-edit-modal .sa-edit-modes .modes-label {
    font-size: 13px;
    color: var(--muted);
}
.sa-edit-modal .sa-tb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    padding: 5px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #faf8f0;
    margin-bottom: 6px;
}
.sa-edit-modal .sa-tb button {
    min-width: 30px;
    padding: 3px 9px;
    font-size: 13px;
    line-height: 1.5;
    border: 1px solid transparent;
    border-radius: 5px;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
}
.sa-edit-modal .sa-tb button:hover {
    border-color: var(--gold);
    color: var(--gold-dark);
}
.sa-edit-modal .sa-tb .tb-sep {
    width: 1px;
    height: 18px;
    background: var(--line);
    margin: 0 4px;
}
.sa-edit-modal .sa-rich {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 12px 14px;
    font-size: 16px;
    line-height: 1.9;
    color: var(--ink);
    background: #fff;
    outline: none;
}
.sa-edit-modal .sa-rich:focus { border-color: var(--gold); }
.sa-edit-modal .sa-rich:empty::before {
    content: attr(data-placeholder);
    color: #b9b5a8;
    pointer-events: none;
}
.sa-edit-modal .sa-rich h1,
.sa-edit-modal .sa-rich h2,
.sa-edit-modal .sa-rich h3,
.sa-edit-modal .sa-rich h4,
.sa-edit-modal .sa-rich h5,
.sa-edit-modal .sa-rich h6 {
    margin: .6em 0 .3em;
    font-weight: 600;
    color: #6b5b2f;
    line-height: 1.5;
}
.sa-edit-modal .sa-rich h1 { font-size: 23px; }
.sa-edit-modal .sa-rich h2 { font-size: 20px; }
.sa-edit-modal .sa-rich h3 { font-size: 18px; }
.sa-edit-modal .sa-rich h4,
.sa-edit-modal .sa-rich h5,
.sa-edit-modal .sa-rich h6 { font-size: 16px; }
.sa-edit-modal .sa-rich ul,
.sa-edit-modal .sa-rich ol { margin: .4em 0 .4em 1.8em; padding: 0; }
.sa-edit-modal .sa-rich ul { list-style: disc; }
.sa-edit-modal .sa-rich ol { list-style: decimal; }
.sa-edit-modal .sa-rich li { margin: .1em 0; }
.sa-edit-modal .sa-rich p { margin: .2em 0; }
.sa-edit-modal .sa-rich hr { border: none; border-top: 1px solid var(--line); margin: 10px 0; }
.sa-edit-modal .sa-rich div { min-height: 1em; }
.sa-edit-modal .sa-rich span,
.sa-edit-modal .sa-rich b,
.sa-edit-modal .sa-rich i,
.sa-edit-modal .sa-rich u { color: inherit; }
.sa-edit-modal .modal-foot {
    justify-content: space-between;
    align-items: center;
}
.sa-edit-modal .modal-foot .sa-foot-left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
    flex: 1;
}
.sa-edit-modal .modal-foot .sa-foot-left .hint {
    font-size: 12px;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sa-edit-modal .modal-foot .sa-online {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    white-space: nowrap;
    font-size: 14px;
    color: var(--ink);
}
.sa-edit-modal .modal-foot .sa-online input { width: auto; margin: 0; }
.sa-edit-modal .modal-foot .sa-foot-right {
    display: flex;
    gap: 10px;
    flex: 0 0 auto;
}
.sa-edit-modal .sa-rich font[size="7"] { font-size: 26px; }
.sa-edit-modal .sa-rich font[size="6"] { font-size: 22px; font-weight: 600; }
.sa-edit-modal .sa-rich font[size="5"] { font-size: 18px; font-weight: 600; }
.sa-edit-modal .sa-rich font[size="4"] { font-size: 16px; }

@media (max-width: 768px) {
    body.sa-body { display: block; background: var(--bg); padding: 0; }
    body.sa-body .topbar,
    body.sa-body .sa-container { display: none; }
    #sa-mobile-tip {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 100vh;
        min-height: 100dvh;
        padding: 30px;
        text-align: center;
        line-height: 1.8;
        color: var(--ink);
    }
    #sa-mobile-tip > div {
        width: 100%;
        max-width: 430px;
        padding: 26px 20px;
        border: 1px solid var(--line);
        border-radius: 10px;
        background: #fff;
    }
    #sa-mobile-tip h1 {
        color: #5e4505;
        font-size: 21px;
        margin-bottom: 10px;
    }
    #sa-mobile-tip p {
        margin-bottom: 18px;
        color: var(--muted);
        font-size: 15px;
    }
    body.sa-body .modal-mask { padding: 0; }
    body.sa-body .modal-box,
    .sa-edit-modal .modal-box {
        width: 100%;
        height: 100%;
        max-height: none;
        border-radius: 0;
    }
}
