/* ============================================================
   云笔记系统 —— 样式表
   ============================================================ */

:root {
    --ink:        #0f172a;
    --ink-soft:   #334155;
    --muted:      #64748b;
    --line:       #e2e8f0;
    --line-soft:  #eef2f7;
    --bg:         #f5f6fb;
    --card:       #ffffff;
    --primary:    #4f46e5;
    --primary-dk: #4338ca;
    --primary-lt: #eef2ff;
    --danger:     #dc2626;
    --danger-lt:  #fef2f2;
    --success:    #059669;
    --success-lt: #ecfdf5;
    --info-lt:    #eff6ff;
    --radius-sm:  8px;
    --radius:     14px;
    --radius-lg:  20px;
    --shadow-sm:  0 1px 2px rgba(15, 23, 42, .06);
    --shadow:     0 6px 20px rgba(15, 23, 42, .07);
    --shadow-lg:  0 18px 44px rgba(15, 23, 42, .12);
    --font: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Helvetica Neue", Arial, "Noto Sans CJK SC", sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.7;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dk); }

h1, h2, h3, h4 { margin: 0; line-height: 1.35; font-weight: 700; }

p { margin: 0 0 12px; }

.muted { color: var(--muted); }

/* ---------------- 顶部导航 ---------------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--line);
}

.topbar-inner {
    max-width: 1240px;
    margin: 0 auto;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 18px;
}

.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); }
.brand:hover { color: var(--ink); }

.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #6366f1, #4f46e5 55%, #7c3aed);
    box-shadow: 0 6px 14px rgba(79, 70, 229, .32);
    flex: none;
}

.brand-mark-lg { width: 46px; height: 46px; border-radius: 14px; font-size: 20px; }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: .3px; }

.main-nav { display: flex; gap: 4px; flex: 1; min-width: 0; }

.nav-item {
    padding: 7px 14px;
    border-radius: 999px;
    color: var(--ink-soft);
    font-size: 14px;
    white-space: nowrap;
}

.nav-item:hover { background: var(--line-soft); color: var(--ink); }

.nav-item.is-active {
    background: var(--primary-lt);
    color: var(--primary-dk);
    font-weight: 600;
}

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

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px 4px 4px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
}

.avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--primary-lt);
    color: var(--primary-dk);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
}

.user-name { font-size: 13px; color: var(--ink-soft); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.inline-form { display: inline; margin: 0; }

/* ---------------- 页面容器 ---------------- */
.page {
    max-width: 1240px;
    margin: 0 auto;
    padding: 26px 20px 72px;
}

.page-auth {
    max-width: none;
    padding: 0;
}

.site-foot {
    border-top: 1px solid var(--line);
    padding: 22px 20px 34px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}

.site-foot p { margin: 0; }

/* ---------------- 提示条 ---------------- */
.flash-stack { display: grid; gap: 8px; margin-bottom: 18px; }

.page-auth .flash-stack { max-width: 440px; margin: 26px auto -8px; padding: 0 20px; }

.flash {
    padding: 11px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    border: 1px solid transparent;
}

.flash-success { background: var(--success-lt); border-color: #a7f3d0; color: #065f46; }
.flash-error   { background: var(--danger-lt);  border-color: #fecaca; color: #991b1b; }
.flash-info    { background: var(--info-lt);    border-color: #bfdbfe; color: #1e40af; }

.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: 14px; }
.alert ul { margin: 0; padding-left: 18px; }
.alert li { margin: 2px 0; }
.alert-error { background: var(--danger-lt); border: 1px solid #fecaca; color: #991b1b; }
.alert-info  { background: var(--info-lt);   border: 1px solid #bfdbfe; color: #1e40af; }

/* ---------------- 按钮 ---------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 10px;
    border: 1px solid transparent;
    font-size: 14px;
    font-family: inherit;
    font-weight: 600;
    line-height: 1.4;
    cursor: pointer;
    transition: all .18s ease;
    text-align: center;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(180deg, #5b52ea, var(--primary));
    color: #fff;
    box-shadow: 0 6px 16px rgba(79, 70, 229, .26);
}
.btn-primary:hover { color: #fff; background: linear-gradient(180deg, var(--primary), var(--primary-dk)); transform: translateY(-1px); }

.btn-outline { background: #fff; border-color: var(--line); color: var(--ink-soft); }
.btn-outline:hover { border-color: #c7d2fe; color: var(--primary-dk); background: #fbfbff; }

.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--line-soft); color: var(--ink); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { color: #fff; background: #b91c1c; }

.btn-sm { padding: 7px 14px; font-size: 13px; border-radius: 9px; }
.btn-xs { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }

.link { color: var(--primary); font-size: 14px; }
.link:hover { text-decoration: underline; }
.link-danger { color: var(--danger); background: none; border: 0; padding: 0; cursor: pointer; font: inherit; font-size: 14px; }
.link-danger:hover { text-decoration: underline; }
.back-link { color: var(--muted); font-size: 14px; }
.back-link:hover { color: var(--primary-dk); }

/* ---------------- 表单 ---------------- */
.field { display: block; margin-bottom: 16px; }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.field-hint { display: inline-block; margin-top: 6px; font-size: 12px; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
select,
textarea,
.form-textarea {
    width: 100%;
    padding: 10px 13px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    font-family: inherit;
    font-size: 14px;
    color: var(--ink);
    transition: border-color .16s ease, box-shadow .16s ease;
}

input:focus, select:focus, textarea:focus, .form-textarea:focus {
    outline: none;
    border-color: #a5b4fc;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, .14);
}

.form-textarea { min-height: 220px; line-height: 1.7; }

.form-stack .field { margin-bottom: 16px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ---------------- 登录 / 注册 ---------------- */
.auth-page {
    background:
        radial-gradient(900px 420px at 12% -10%, #e0e7ff 0%, rgba(224, 231, 255, 0) 60%),
        radial-gradient(700px 380px at 96% 4%, #ede9fe 0%, rgba(237, 233, 254, 0) 62%),
        var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.auth-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px 60px;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 34px 32px 28px;
    box-shadow: var(--shadow-lg);
}

.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.auth-brand h1 { font-size: 21px; }
.auth-brand p { margin: 4px 0 0; font-size: 13px; color: var(--muted); }

.auth-foot { margin: 20px 0 0; text-align: center; font-size: 13px; color: var(--muted); }

.auth-page .site-foot { border-top: 0; }

/* ---------------- 工作台布局 ---------------- */
.workspace { display: grid; grid-template-columns: 264px minmax(0, 1fr); gap: 24px; align-items: start; }

.sidebar {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 82px;
}

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 20px; }
.stat { text-align: center; padding: 10px 4px; background: var(--line-soft); border-radius: var(--radius-sm); }
.stat-value { display: block; font-size: 19px; font-weight: 700; color: var(--primary-dk); }
.stat-label { display: block; font-size: 12px; color: var(--muted); }

.sidebar-title { font-size: 12px; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; margin-bottom: 10px; }

.cat-nav { display: grid; gap: 2px; margin-bottom: 16px; max-height: 46vh; overflow-y: auto; }

.cat-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 9px;
    color: var(--ink-soft);
    font-size: 14px;
}
.cat-link:hover { background: var(--line-soft); }
.cat-link.is-active { background: var(--primary-lt); color: var(--primary-dk); font-weight: 600; }
.cat-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-count { font-size: 12px; color: var(--muted); background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; flex: none; }
.cat-link.is-active .cat-count { color: var(--primary-dk); border-color: #c7d2fe; }

.content { min-width: 0; }

.content-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.content-title { font-size: 23px; }
.content-sub { margin: 5px 0 0; font-size: 13px; color: var(--muted); }
.content-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.search-form { display: flex; align-items: center; gap: 8px; }
.search-form input[type="search"] { width: 210px; }

/* ---------------- 笔记卡片 ---------------- */
.note-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(272px, 1fr)); gap: 16px; }

.note-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 18px 14px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.note-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: #dbe1f0; }

.note-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }

.badge {
    display: inline-block;
    padding: 3px 11px;
    border-radius: 999px;
    background: var(--primary-lt);
    color: var(--primary-dk);
    font-size: 12px;
    font-weight: 600;
    max-width: 62%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.badge-muted { background: #f1f5f9; color: var(--muted); }

.note-time { font-size: 12px; color: var(--muted); }

.note-title { font-size: 16.5px; margin-bottom: 8px; }
.note-title a { color: var(--ink); }
.note-title a:hover { color: var(--primary-dk); }

.note-excerpt {
    font-size: 13.5px;
    color: var(--ink-soft);
    margin: 0 0 14px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-clamp: 3;
    min-height: 60px;
}

.note-card-foot {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px dashed var(--line);
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 13px;
}

/* ---------------- 分页 ---------------- */
.pagination { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 26px; }

.page-link {
    min-width: 36px;
    height: 36px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #fff;
    color: var(--ink-soft);
    font-size: 13px;
}
.page-link:hover { border-color: #c7d2fe; color: var(--primary-dk); }
.page-link.is-active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.page-info { margin-left: auto; font-size: 13px; color: var(--muted); }

/* ---------------- 空状态 ---------------- */
.empty {
    background: var(--card);
    border: 1px dashed #d8dfef;
    border-radius: var(--radius);
    padding: 52px 24px;
    text-align: center;
}

.empty h2, .empty h3 { font-size: 17px; margin-bottom: 8px; }
.empty p { color: var(--muted); font-size: 14px; }
.empty-mark {
    width: 54px;
    height: 54px;
    margin: 0 auto 14px;
    border-radius: 16px;
    background: var(--primary-lt);
    color: var(--primary-dk);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
}
.empty-sm { padding: 30px 20px; }

/* ---------------- 笔记详情 ---------------- */
.detail { max-width: 880px; margin: 0 auto; }

.detail-bar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.detail-actions { display: flex; align-items: center; gap: 8px; }

.note-sheet {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 34px 38px 40px;
    box-shadow: var(--shadow-sm);
}

.note-head { padding-bottom: 16px; border-bottom: 1px solid var(--line-soft); margin-bottom: 22px; }
.note-head-title { font-size: 26px; margin-bottom: 12px; word-break: break-word; }
.note-meta { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.note-meta .meta-item { position: relative; }
.meta-item + .meta-item::before { content: "·"; margin-right: 14px; color: var(--line); }

.note-content {
    font-size: 16px;
    line-height: 1.85;
    color: var(--ink);
    word-wrap: break-word;
    overflow-wrap: anywhere;
}
.note-content p { margin: 0 0 14px; }
.note-content h1, .note-content h2 { font-size: 21px; margin: 26px 0 12px; }
.note-content h3 { font-size: 18px; margin: 22px 0 10px; }
.note-content h4, .note-content h5, .note-content h6 { font-size: 16px; margin: 18px 0 8px; }
.note-content ul, .note-content ol { padding-left: 24px; margin: 0 0 14px; }
.note-content li { margin: 5px 0; }
.note-content blockquote {
    margin: 16px 0;
    padding: 10px 18px;
    border-left: 4px solid #c7d2fe;
    background: #f8faff;
    color: var(--ink-soft);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.note-content pre {
    background: #0f172a;
    color: #e2e8f0;
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 13.5px;
    line-height: 1.65;
}
.note-content code { background: #f1f5f9; padding: 1px 6px; border-radius: 5px; font-size: .92em; }
.note-content pre code { background: none; padding: 0; }
.note-content img, .note-content video {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    margin: 8px 0;
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    display: block;
}
.note-content a { text-decoration: underline; }
.note-content hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
.note-content table { border-collapse: collapse; width: 100%; margin: 14px 0; font-size: 14px; }
.note-content th, .note-content td { border: 1px solid var(--line); padding: 8px 12px; }
.note-content th { background: var(--line-soft); }

/* ---------------- 窄容器页面（分类管理等） ---------------- */
.narrow { max-width: 880px; margin: 0 auto; }

.panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}
.panel-title { font-size: 15px; margin-bottom: 14px; }

.inline-create { display: flex; gap: 10px; flex-wrap: wrap; }
.inline-create input[type="text"] { flex: 1; min-width: 220px; }

.cat-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }

.cat-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: #fcfdff;
}

.cat-rename { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cat-rename input[type="text"] { min-width: 0; }
.cat-meta { display: flex; align-items: center; gap: 12px; font-size: 12.5px; white-space: nowrap; }

/* ---------------- 素材库 ---------------- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 16px; }

.media-card {
    margin: 0;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
}

.media-preview { position: relative; background: #0f172a0d; aspect-ratio: 16 / 10; display: flex; align-items: center; justify-content: center; }
.media-preview img, .media-preview video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-preview video { background: #000; object-fit: contain; }
.media-type {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(15, 23, 42, .72);
    color: #fff;
    font-size: 11px;
    padding: 2px 9px;
    border-radius: 999px;
}

.media-info { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.media-name { margin: 0; font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-meta { margin: 0; font-size: 12px; color: var(--muted); }
.media-actions { margin-top: auto; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ---------------- 编辑器 ---------------- */
.editor-page-wrap { max-width: 1000px; margin: 0 auto; }
.editor-head { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }

.note-form-top { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 16px; }
.field-title input { font-size: 17px; font-weight: 600; padding: 12px 15px; }
.field-cat select { padding: 12px 13px; }
.field-title, .field-cat { margin-bottom: 18px; }

.editor-shell {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    /* 这里不能用 overflow: hidden：它会让内部 .editor-toolbar 的 sticky 以本容器为滚动容器，
       而本容器本身不滚动，工具栏就会被 top 值整体下移、盖住正文首行。
       圆角改由工具栏与状态栏各自的 border-radius 收住。 */
    box-shadow: var(--shadow-sm);
}

.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 9px 12px;
    background: #f8fafc;
    border-bottom: 1px solid var(--line);
    border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0;
    position: sticky;
    top: 56px;
    z-index: 10;
}

.tb-group { display: flex; align-items: center; gap: 4px; padding-right: 8px; border-right: 1px solid var(--line); }
.tb-group:last-child { border-right: 0; padding-right: 0; }
.tb-group-end { margin-left: auto; }

.tb-btn {
    min-width: 32px;
    height: 32px;
    padding: 0 9px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--ink-soft);
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all .15s ease;
}
.tb-btn:hover { background: #fff; border-color: var(--line); color: var(--ink); }
.tb-btn.is-active { background: var(--primary-lt); border-color: #c7d2fe; color: var(--primary-dk); }
.tb-btn-accent { color: var(--primary-dk); font-weight: 600; }

.tb-select {
    height: 32px;
    padding: 0 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    font-family: inherit;
    font-size: 13px;
    color: var(--ink-soft);
    cursor: pointer;
    width: auto;
}

.tb-color {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 32px;
    padding: 0 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    font-size: 12px;
    color: var(--ink-soft);
    cursor: pointer;
}
.tb-color input[type="color"] { width: 22px; height: 22px; padding: 0; border: 0; background: none; cursor: pointer; }

/* 「无高亮」按钮：带一个划掉的色块图标，一眼看出是“取消/恢复原色” */
.tb-nohighlight { gap: 6px; padding: 0 10px; }
.tb-nohighlight-swatch {
    position: relative;
    flex: none;
    width: 14px;
    height: 14px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: #fff;
    overflow: hidden;
}
.tb-nohighlight-swatch::after {
    content: "";
    position: absolute;
    left: 50%;
    top: -1px;
    width: 1.5px;
    height: calc(100% + 2px);
    background: #ef4444;
    transform: translateX(-50%) rotate(45deg);
}

.editor-area {
    min-height: 380px;
    padding: 24px 28px;
    font-size: 16px;
    line-height: 1.85;
    outline: none;
    overflow-wrap: anywhere;
}

.editor-area:empty::before { content: attr(data-placeholder); color: #94a3b8; pointer-events: none; }
.editor-area img, .editor-area video { max-width: 100%; border-radius: 10px; margin: 6px 0; }
.editor-area video { display: block; }
.editor-area blockquote { margin: 14px 0; padding: 8px 16px; border-left: 4px solid #c7d2fe; background: #f8faff; color: var(--ink-soft); }
.editor-area pre { background: #0f172a; color: #e2e8f0; padding: 12px 16px; border-radius: 8px; overflow-x: auto; }

.editor-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 14px;
    border-top: 1px solid var(--line-soft);
    background: #fcfdff;
    border-radius: 0 0 calc(var(--radius) - 1px) calc(var(--radius) - 1px);
    font-size: 12.5px;
    color: var(--muted);
    min-height: 34px;
}
.upload-status { color: var(--primary-dk); }
.upload-status.is-error { color: var(--danger); }
.upload-status.is-busy { color: var(--ink-soft); }

.form-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 18px; }
.form-tip { font-size: 12.5px; color: var(--muted); }

/* 正文中的上传媒体 */
.note-content .note-video, .editor-area .note-video { max-width: 100%; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1000px) {
    .workspace { grid-template-columns: minmax(0, 1fr); }
    .sidebar { position: static; }
    .cat-nav { max-height: none; }
    .stat-grid { grid-template-columns: repeat(3, 1fr); }
    .note-form-top { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 720px) {
    .topbar-inner { flex-wrap: wrap; gap: 10px; padding: 10px 14px; }
    .main-nav { order: 3; width: 100%; overflow-x: auto; padding-bottom: 2px; }
    .topbar-actions { margin-left: auto; }
    .user-name { display: none; }
    .page { padding: 18px 14px 56px; }
    .content-head { align-items: stretch; }
    .search-form { width: 100%; }
    .search-form input[type="search"] { flex: 1; width: auto; }
    .note-sheet { padding: 24px 20px 30px; }
    .note-head-title { font-size: 22px; }
    .field-row { grid-template-columns: minmax(0, 1fr); }
    .cat-row { grid-template-columns: minmax(0, 1fr); }
    .cat-meta { white-space: normal; }
    .editor-toolbar { position: static; }
    .editor-area { padding: 18px 16px; min-height: 300px; }
}

@media (max-width: 480px) {
    .auth-card { padding: 26px 20px 22px; }
    .note-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ============================================================
   用户管理后台（admin/）
   ============================================================ */

.nav-item-admin { background: var(--primary-lt); color: var(--primary-dk); font-weight: 600; }
.nav-item-admin:hover { background: #e3e8ff; color: var(--primary-dk); }

/* 角色 / 状态标签 */
.role-tag {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    background: #f1f5f9;
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}
.role-tag-admin { background: var(--primary-lt); color: var(--primary-dk); }
.user-chip .role-tag { margin-left: 2px; }

.status-tag {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}
.status-on  { background: var(--success-lt); color: var(--success); }
.status-off { background: #f1f5f9; color: #94a3b8; }

.self-tag {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid #c7d2fe;
    color: var(--primary-dk);
    font-size: 11px;
    font-weight: 600;
}

/* 概览数据块 */
.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.admin-stat {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}
.admin-stat-label { font-size: 12.5px; color: var(--muted); }
.admin-stat-value { font-size: 22px; font-weight: 700; color: var(--primary-dk); line-height: 1.3; overflow-wrap: anywhere; }
.admin-stat-foot { font-size: 12px; color: var(--muted); }

.admin-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
}

.admin-list { list-style: none; margin: 0; padding: 0; }
.admin-list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 10px 0;
    border-bottom: 1px dashed var(--line);
}
.admin-list-row:last-child { border-bottom: 0; }
.admin-list-main { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.admin-list-side { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.admin-note-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; }

.admin-notes { margin: 0; padding-left: 20px; font-size: 13.5px; color: var(--ink-soft); }
.admin-notes li { margin: 5px 0; }
.admin-notes code { background: var(--line-soft); padding: 1px 6px; border-radius: 6px; font-size: 12.5px; }

/* 列表工具条 */
.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.panel-head .panel-title { margin-bottom: 0; }

.filter-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-form input[type="search"] { width: 200px; }
.filter-form select { padding: 8px 11px; font-size: 13.5px; }

/* 账号表格 */
.table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }

.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
    text-align: left;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--muted);
    padding: 8px 12px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.data-table td { padding: 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.data-table tbody tr:hover { background: #fafbff; }
.data-table tr.row-self { background: var(--primary-lt); }
.data-table tr.row-self:hover { background: var(--primary-lt); }
.data-table .col-actions { min-width: 300px; }

.cell-title { display: block; font-weight: 600; }
.cell-sub { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); }
.cell-mono, .cell-time { color: var(--ink-soft); white-space: nowrap; }

.row-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.row-actions form { margin: 0; }

.row-more { position: relative; }
.row-more > summary { list-style: none; display: inline-block; cursor: pointer; }
.row-more > summary::-webkit-details-marker { display: none; }
.row-more-form {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px;
    border: 1px dashed var(--line);
    border-radius: var(--radius-sm);
    background: #fcfdff;
}
.row-more-form input[type="password"] { width: 150px; padding: 7px 10px; font-size: 13px; }

/* 账号表单（新增 / 编辑） */
.account-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0 16px;
}
.account-form .field { margin-bottom: 14px; }
.account-form-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 4px; }

@media (max-width: 720px) {
    .data-table .col-actions { min-width: 240px; }
    .filter-form { width: 100%; }
    .filter-form input[type="search"] { flex: 1; width: auto; }
    .admin-columns { grid-template-columns: minmax(0, 1fr); }
    .admin-note-title { max-width: 200px; }
}
/* ============================================================
   用户管理后台 —— 左侧竖向菜单外壳
   （.admin-shell / .admin-side / .admin-menu / .admin-topbar / .admin-content）
   ============================================================ */
body.admin-body { background: var(--bg); }

.admin-shell {
    display: grid;
    grid-template-columns: 238px minmax(0, 1fr);
    min-height: 100vh;
    background: var(--bg);
}

/* ---------------- 左侧竖向菜单 ---------------- */
.admin-side {
    position: sticky;
    top: 0;
    align-self: start;
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 18px 14px 14px;
    background: var(--card);
    border-right: 1px solid var(--line);
    overflow-y: auto;
    z-index: 20;
}
.admin-side-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px 13px;
}
.admin-side-brand .brand-mark {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
}
.admin-side-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.admin-side-caption {
    margin: 0 0 10px;
    padding: 0 8px;
    font-size: 11px;
    letter-spacing: .1em;
    color: var(--muted);
}
.admin-menu { display: grid; gap: 2px; }
.admin-menu-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 10px;
    color: var(--ink-soft);
    font-size: 14px;
    transition: background .16s ease, color .16s ease;
}
.admin-menu-item:hover { background: var(--line-soft); color: var(--ink); }
.admin-menu-item.is-active { background: var(--primary-lt); color: var(--primary-dk); font-weight: 600; }
.admin-menu-item.is-active::before {
    content: "";
    position: absolute;
    left: -14px;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--primary);
}
.admin-menu-item .am-ico { flex: none; display: flex; width: 18px; height: 18px; }
.admin-menu-item .am-ico svg { width: 18px; height: 18px; display: block; }
.admin-menu-item .am-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-side-foot {
    margin-top: auto;
    padding: 14px 8px 2px;
    border-top: 1px solid var(--line);
}
.admin-side-link { font-size: 13px; color: var(--muted); }
.admin-side-link:hover { color: var(--primary-dk); }

/* ---------------- 右侧主体 ---------------- */
.admin-main { display: flex; flex-direction: column; min-width: 0; }
.admin-topbar {
    position: sticky;
    top: 0;
    z-index: 15;
    display: flex;
    align-items: center;
    gap: 14px;
    height: 62px;
    padding: 0 22px;
    background: rgba(255, 255, 255, .94);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
}
.admin-burger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 36px;
    height: 36px;
    padding: 0 8px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #fff;
    cursor: pointer;
}
.admin-burger span { display: block; height: 2px; border-radius: 2px; background: var(--ink-soft); }
.admin-topbar-title {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    font-size: 15px;
    font-weight: 600;
}
.admin-crumb { color: var(--muted); font-weight: 400; }
.admin-crumb-sep { color: var(--line); }
.admin-crumb-current { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.admin-content { flex: 1; width: 100%; max-width: 1220px; padding: 22px 24px 44px; }
.admin-content > .flash-stack { margin-bottom: 16px; }

/* 抽屉遮罩：桌面端常隐藏，窄屏展开菜单时由脚本去掉 hidden 属性 */
.admin-scrim { display: none; }

@media (max-width: 880px) {
    .admin-shell { grid-template-columns: minmax(0, 1fr); }
    .admin-side {
        position: fixed;
        inset: 0 auto 0 0;
        width: 252px;
        height: 100vh;
        transform: translateX(-100%);
        transition: transform .24s ease;
        box-shadow: var(--shadow-lg);
        z-index: 40;
    }
    .admin-shell.is-nav-open .admin-side { transform: none; }
    .admin-burger { display: flex; }
    .admin-scrim {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, .42);
        z-index: 30;
    }
    .admin-topbar { padding: 0 14px; }
    .admin-content { padding: 18px 16px 36px; }
}

@media (max-width: 560px) {
    .admin-topbar { height: auto; min-height: 58px; padding: 10px 14px; flex-wrap: wrap; }
    .admin-topbar-title { font-size: 14px; }
    .admin-topbar-actions { gap: 8px; }
    .user-chip .user-name { display: none; }
}
