/* ============================================================
   网络数据中心 Net Data Center · 全站样式表
   ----------------------------------------------------------
   目录
     1. 设计令牌（浅色 / 深色）
     2. 基础重置与排版
     3. 布局骨架（侧栏 / 顶栏 / 内容区 / 页脚）
     4. 通用工具类
     5. 页面头部统一模式（标题 + 说明 + 操作）
     6. 组件：卡片 / 按钮 / 表单 / 表格 / 徽章 / 提示
     7. 业务区块：仪表盘 / 工具箱 / 端口 / 知识库 / 笔记 / 文章 / 管理后台
     8. 预览器
     9. 响应式与可访问性
   ============================================================ */

/* ============================================================
   1. 设计令牌
   ============================================================ */

:root {
    color-scheme: light;

    /* ---- 间距：8px 栅格 ---- */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 20px;
    --sp-6: 24px;
    --sp-7: 32px;
    --sp-8: 40px;
    --gutter: var(--sp-7);

    /* ---- 圆角梯度 ---- */
    --radius-xs: 6px;
    --radius-sm: 8px;
    --radius-md: 10px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-pill: 999px;

    /* ---- 阴影层级 ---- */
    --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04), 0 3px 10px rgba(16, 24, 40, .05);
    --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 14px rgba(16, 24, 40, .05);
    --shadow-lg: 0 8px 30px rgba(16, 24, 40, .10);
    --shadow-xl: 0 18px 48px rgba(16, 24, 40, .14);

    /* ---- 中性色 ---- */
    --bg: #f3f5f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #eef2f8;
    --surface-hover: #f1f5fb;
    --border: #e4e8ef;
    --border-strong: #d3d9e3;
    --text: #1c2434;
    --text-2: #4f5866;
    --text-3: #5f6879;
    --text-inverse: #ffffff;
    --on-brand: #ffffff;

    /* ---- 品牌与语义色 ---- */
    --primary: #2a5fe0;
    --primary-strong: #1f4fc4;
    --primary-soft: #eaf0ff;
    --primary-soft-2: #dbe6ff;
    --on-primary: #ffffff;
    --green: #16a34a;
    --green-soft: #e7f7ee;
    --green-ink: #116b32;
    --green-strong: #15803d;
    --on-green: #ffffff;
    --red: #dc2626;
    --red-soft: #fdecec;
    --red-ink: #b91c1c;
    --amber: #b45309;
    --amber-soft: #fdf3e3;
    --amber-ink: #92400e;
    --purple: #7c3aed;
    --purple-soft: #f1eafd;
    --purple-ink: #6d28d9;

    /* ---- 品牌渐变 / 强调面 ---- */
    --brand-gradient: linear-gradient(135deg, #2f6bff, #6a3df5);
    --brand-shadow: 0 2px 8px rgba(47, 107, 255, .18);
    --hero-bg: linear-gradient(120deg, #eef3ff 0%, #f6f1ff 100%);
    --hero-border: #dfe6fb;
    --announce-bg: linear-gradient(90deg, #fff8e6, #ffffff);
    --announce-border: #f5e3b3;
    --announce-fg: #92600a;
    --announce-icon-bg: #b45309;
    --announce-icon-fg: #ffffff;

    /* ---- 代码 / 等宽区域 ---- */
    --code-bg: #0f172a;
    --code-fg: #cbd5e1;
    --code-muted: #93a4c3;
    --code-accent: #7dd3fc;
    --code-inline-fg: #b3326b;
    --code-inline-bg: #f1f5f9;

    /* ---- 浮层 ---- */
    --overlay: rgba(15, 23, 42, .55);
    --backdrop: rgba(10, 16, 28, .48);
    --glass: rgba(255, 255, 255, .82);
    --preview-canvas: #ffffff;
    --preview-video-bg: #000000;

    /* ---- 焦点 ---- */
    --focus: #2a5fe0;
    --focus-halo: rgba(42, 95, 224, .18);

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    --mono: "Cascadia Code", Consolas, "JetBrains Mono", "SF Mono", Menlo, monospace;
}

/* ============ 深色主题（由 app.js 写入 html[data-theme="dark"]） ============ */
[data-theme="dark"] {
    color-scheme: dark;

    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 20px;
    --sp-6: 24px;
    --sp-7: 32px;
    --sp-8: 40px;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, .22);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .20);
    --shadow: 0 1px 2px rgba(0, 0, 0, .24), 0 4px 14px rgba(0, 0, 0, .28);
    --shadow-lg: 0 8px 28px rgba(0, 0, 0, .44);
    --shadow-xl: 0 18px 44px rgba(0, 0, 0, .52);

    --bg: #0f1420;
    --surface: #171e2e;
    --surface-2: #1e2739;
    --surface-3: #242f45;
    --surface-hover: #222c40;
    --border: #2f3b52;
    --border-strong: #414f6b;
    --text: #e7edf8;
    --text-2: #aab7cf;
    --text-3: #8092ac;
    --text-inverse: #0b1120;
    --on-brand: #ffffff;

    --primary: #6d97ff;
    --primary-strong: #8fafff;
    --primary-soft: #1e2c4d;
    --primary-soft-2: #27375c;
    --on-primary: #0b1120;
    --green: #3fd18b;
    --green-soft: #16362a;
    --green-ink: #5fdba0;
    --green-strong: #3fd18b;
    --on-green: #0b1120;
    --red: #f87b7b;
    --red-soft: #3b2026;
    --red-ink: #ff9c9c;
    --amber: #f2b661;
    --amber-soft: #3a2c17;
    --amber-ink: #f5c179;
    --purple: #af8bff;
    --purple-soft: #2b2247;
    --purple-ink: #bda2ff;

    --brand-gradient: linear-gradient(135deg, #3d78ff, #7a4cf5);
    --brand-shadow: 0 6px 18px rgba(0, 0, 0, .38);
    --hero-bg: linear-gradient(120deg, #18233c 0%, #241f3d 100%);
    --hero-border: #2c3752;
    --announce-bg: linear-gradient(90deg, #3a2c17, #1c2231);
    --announce-border: #5a4522;
    --announce-fg: #f2c983;
    --announce-icon-bg: #f2b661;
    --announce-icon-fg: #1c1409;

    --code-bg: #0b1120;
    --code-fg: #d7e0f0;
    --code-muted: #93a4c3;
    --code-accent: #8fd8ff;
    --code-inline-fg: #f4a4d0;
    --code-inline-bg: #1e2739;

    --overlay: rgba(3, 7, 15, .66);
    --backdrop: rgba(4, 8, 16, .58);
    --glass: rgba(23, 30, 46, .82);
    --preview-canvas: #eef1f6;
    --preview-video-bg: #05080f;

    --focus: #8fafff;
    --focus-halo: rgba(143, 175, 255, .26);
}

/* ============================================================
   2. 基础重置与排版
   ============================================================ */

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

h1, h2, h3, h4 { margin: 0; line-height: 1.3; }

code, .mono { font-family: var(--mono); font-size: .92em; }

img { max-width: 100%; }

::selection { background: var(--primary-soft); color: var(--text); }

/* 统一焦点指示：所有可聚焦元素 */
:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

/* ============================================================
   3. 布局骨架
   ============================================================ */

.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 232px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 30;
}

.brand {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-5) var(--sp-4);
    border-bottom: 1px solid var(--border);
    min-height: 72px;
}

.brand-logo {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--brand-gradient);
    color: var(--on-brand);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: .5px;
    flex-shrink: 0;
    box-shadow: var(--brand-shadow);
}

.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 15px; line-height: 1.35; }
.brand-text span { font-size: 11px; color: var(--text-3); letter-spacing: .4px; }

.nav {
    flex: 1;
    padding: var(--sp-3) var(--sp-2);
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.nav a {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    min-height: 36px;
    padding: 7px 10px 7px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-size: 14px;
    transition: background .15s, color .15s;
}

.nav a svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav a:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.nav a:active { background: var(--surface-3); }

.nav a.active {
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 600;
}

.nav a.active::before {
    content: "";
    position: absolute;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 16px;
    border-radius: var(--radius-pill);
    background: var(--primary);
}

.sidebar-foot {
    padding: var(--sp-3) var(--sp-4);
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
}

.status-line { display: flex; align-items: center; gap: 7px; color: var(--text-2); }

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 0 3px var(--green-soft);
    flex-shrink: 0;
}

.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
    padding: var(--sp-3) var(--gutter);
    min-height: 56px;
    background: var(--glass);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

.topbar h1 {
    font-size: 18px;
    font-weight: 650;
    letter-spacing: -.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-heading { min-width: 0; }

.topbar-header-actions {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-wrap: wrap;
}

.topbar-header-actions .btn { min-height: 32px; }

.topbar-sub {
    font-size: 12px;
    color: var(--text-3);
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-meta {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: 13px;
    white-space: nowrap;
    flex: none;
}

.topbar-meta > .muted { white-space: nowrap; }

.content { padding: var(--sp-6) var(--gutter) var(--sp-7); flex: 1; }

.footer {
    padding: var(--sp-4) var(--gutter) var(--sp-6);
    font-size: 12px;
    color: var(--text-3);
    border-top: 1px solid var(--border);
}

/* 面包屑（可选，由 ViewData["Breadcrumb"] 提供） */
.breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: var(--sp-2) var(--gutter);
    font-size: 12.5px;
    color: var(--text-3);
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.breadcrumb .crumb { display: inline-flex; align-items: center; gap: 6px; }
.breadcrumb .crumb + .crumb::before {
    content: "/";
    color: var(--text-3);
    opacity: .65;
    margin-right: 6px;
}
.breadcrumb a { color: var(--text-2); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .crumb-current { color: var(--text); font-weight: 600; }

/* ============================================================
   4. 通用工具类
   ============================================================ */

.muted { color: var(--text-2); }
.strong { font-weight: 600; }
.mt-8 { margin-top: var(--sp-2); }
.wrap { word-break: break-all; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: var(--sp-4);
    top: -60px;
    z-index: 200;
    padding: var(--sp-2) var(--sp-4);
    background: var(--primary);
    color: var(--on-primary);
    border-radius: var(--radius-sm);
    font-weight: 600;
    transition: top .15s ease;
}

.skip-link:focus { top: var(--sp-3); text-decoration: none; }

/* ============================================================
   5. 页面头部统一模式（标题 + 说明 + 操作）
   ============================================================ */

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-4);
    flex-wrap: wrap;
    margin: 0 0 var(--sp-5);
}

.page-head-body { min-width: 0; flex: 1 1 340px; }

.page-head h2,
.page-head .page-head-title {
    font-size: 20px;
    font-weight: 650;
    letter-spacing: -.01em;
    margin: 0 0 6px;
    color: var(--text);
}

.page-head p,
.page-head .page-head-desc {
    margin: 0;
    font-size: 13px;
    line-height: 1.7;
    color: var(--text-2);
    max-width: 76ch;
}

.page-head-actions {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-wrap: wrap;
    flex: none;
}

/* 兼容既有页面的两种头部写法，视觉上完全一致 */
.page-intro,
.admin-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-4);
    flex-wrap: wrap;
    margin: 0 0 var(--sp-5);
}

.page-intro > *,
.admin-head > * { min-width: 0; }

.page-intro h2,
.admin-head h2 {
    font-size: 20px;
    font-weight: 650;
    letter-spacing: -.01em;
    margin: 0 0 6px;
    color: var(--text);
}

.page-intro p,
.admin-head p {
    margin: 0;
    font-size: 13px;
    line-height: 1.7;
    color: var(--text-2);
    max-width: 76ch;
}

.page-intro p + p,
.admin-head p + p { margin-top: 8px; }

.list-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--sp-3);
    margin: var(--sp-1) 0 var(--sp-3);
}

.list-head h3 { font-size: 15px; font-weight: 650; }

.section-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-3);
    letter-spacing: 1px;
    margin: var(--sp-6) 0 var(--sp-3);
}

.section-title:first-child { margin-top: 0; }

/* ============================================================
   6. 组件
   ============================================================ */

/* ---------------- 卡片 ---------------- */

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

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    margin-bottom: var(--sp-3);
}

.card-head h3 { font-size: 15px; font-weight: 650; }
.card-link { font-size: 13px; flex-shrink: 0; }

/* ---------------- 按钮 ---------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 34px;
    padding: 6px var(--sp-4);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 13.5px;
    line-height: 1.5;
    font-family: var(--font);
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
    white-space: nowrap;
    text-decoration: none;
}

.btn:hover { border-color: var(--primary); color: var(--primary); background: var(--surface); text-decoration: none; }
.btn:active { background: var(--primary-soft); }

.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--on-primary);
    font-weight: 600;
    box-shadow: var(--shadow-xs);
}

.btn-primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); color: var(--on-primary); }
.btn-primary:active { background: var(--primary-strong); }

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

.btn-sm { min-height: 28px; padding: 3px 10px; font-size: 12.5px; }

.btn-danger-ghost { color: var(--red-ink); border-color: transparent; background: var(--red-soft); }
.btn-danger-ghost:hover { background: var(--red); color: var(--on-primary); border-color: var(--red); }

/* 禁用态：整站统一（不靠单独描边，保留辨识度） */
.btn:disabled,
.btn[aria-disabled="true"],
.btn.is-disabled {
    opacity: .55;
    cursor: not-allowed;
    pointer-events: none;
    box-shadow: none;
    background: var(--surface-2);
    border-color: var(--border);
    color: var(--text-3);
}

.btn-primary:disabled,
.btn-primary[aria-disabled="true"] {
    background: var(--surface-3);
    border-color: var(--border);
    color: var(--text-3);
    opacity: 1;
}

/* ---------------- 表单 ---------------- */

.form-row {
    display: flex;
    gap: var(--sp-3);
    flex-wrap: wrap;
    margin-bottom: var(--sp-3);
}

.form-row:last-child { margin-bottom: 0; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 140px; }
.field.grow { flex: 1; min-width: 200px; }
.field.align-end { justify-content: flex-end; }

.label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }

.input, .select, .textarea {
    width: 100%;
    min-height: 34px;
    padding: 6px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 13.5px;
    line-height: 1.5;
    font-family: var(--font);
    transition: border-color .15s, box-shadow .15s, background .15s;
}

.input:hover:not(:disabled),
.select:hover:not(:disabled),
.textarea:hover:not(:disabled) { border-color: var(--primary); }

.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--focus-halo);
}

.input:focus-visible, .select:focus-visible, .textarea:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 1px;
}

.input::placeholder, .textarea::placeholder { color: var(--text-3); }

.textarea { resize: vertical; line-height: 1.6; }

.select { cursor: pointer; }

.range { width: 100%; accent-color: var(--primary); }

.check-row { display: flex; flex-wrap: wrap; gap: var(--sp-3); }

.check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-2);
    cursor: pointer;
}

.check input { accent-color: var(--primary); width: 15px; height: 15px; }

/* 禁用态：与可用态明确区分 */
.input:disabled, .select:disabled, .textarea:disabled {
    background: var(--surface-2);
    color: var(--text-3);
    border-color: var(--border);
    cursor: not-allowed;
    opacity: .8;
}

.input[aria-invalid="true"], .textarea[aria-invalid="true"] {
    border-color: var(--red);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--red) 14%, transparent);
}

/* ---------------- 仪表盘 ---------------- */

.hero {
    display: flex;
    gap: var(--sp-6);
    justify-content: space-between;
    align-items: stretch;
    background: var(--hero-bg);
    border: 1px solid var(--hero-border);
    border-radius: var(--radius-lg);
    padding: var(--sp-7);
    margin-bottom: var(--sp-5);
}

.hero-body h2 { font-size: 24px; font-weight: 650; letter-spacing: -.02em; margin-bottom: var(--sp-2); }
.hero-body p { color: var(--text-2); max-width: 620px; margin: 0 0 18px; }

.hero-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

.hero-side { display: flex; gap: var(--sp-3); align-items: center; }

.hero-stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--sp-4) var(--sp-5);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 130px;
    box-shadow: var(--shadow-sm);
}

.hero-num { font-size: 28px; font-weight: 700; color: var(--primary); font-family: var(--mono); letter-spacing: -.02em; }
.hero-label { font-size: 12px; color: var(--text-2); margin-top: 2px; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--sp-3);
    margin-bottom: var(--sp-5);
}

.stat { text-align: center; padding: 18px var(--sp-3); }

.stat-num { font-size: 26px; font-weight: 700; font-family: var(--mono); color: var(--text); letter-spacing: -.02em; }
.stat-label { font-size: 12.5px; color: var(--text-2); margin-top: 4px; }

.two-col {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: var(--sp-4);
    margin-bottom: var(--sp-5);
}

.quick-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-2);
}

.quick-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--sp-3) var(--sp-4);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    transition: background .15s, border-color .15s, transform .15s;
}

.quick-item:hover { border-color: var(--primary); background: var(--primary-soft); text-decoration: none; }
.quick-item:active { transform: translateY(1px); }
.quick-item strong { font-size: 13.5px; }
.quick-item span { font-size: 12px; color: var(--text-3); }

.tech-chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-1); }

.tech-chip {
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: 12.5px;
    color: var(--text-2);
}

/* ---------------- 工具箱 ---------------- */

.tool-section { margin-bottom: var(--sp-2); }

.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(430px, 1fr));
    gap: var(--sp-4);
}

.tool { display: flex; flex-direction: column; gap: var(--sp-3); }

.tool-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.tool-head h3 { font-size: 15.5px; font-weight: 650; }
.tool-desc { margin: 0; color: var(--text-2); font-size: 13px; }

.tool-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

.tag {
    font-size: 11.5px;
    line-height: 1.6;
    padding: 1px 10px;
    border-radius: var(--radius-pill);
    font-weight: 600;
    background: var(--surface-2);
    color: var(--text-2);
    border: 1px solid var(--border);
    white-space: nowrap;
}

.tag-blue { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.tag-purple { background: var(--purple-soft); color: var(--purple-ink); border-color: transparent; }
.tag-green { background: var(--green-soft); color: var(--green-ink); border-color: transparent; }
.tag-amber { background: var(--amber-soft); color: var(--amber-ink); border-color: transparent; }
.tag-red { background: var(--red-soft); color: var(--red-ink); border-color: transparent; }

/* ---------------- 结果展示 ---------------- */

.result { min-height: 0; }
.result:empty { display: none; }

.kv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--sp-2);
}

.kv {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px var(--sp-3);
}

.kv-k { font-size: 11.5px; color: var(--text-3); margin-bottom: 2px; }
.kv-v { font-size: 13.5px; font-weight: 600; word-break: break-all; }

.bin-box {
    margin-top: var(--sp-3);
    background: var(--code-bg);
    border-radius: var(--radius-sm);
    padding: var(--sp-3) var(--sp-4);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.bin-row { display: flex; align-items: center; gap: var(--sp-2); }
.bin-label { color: var(--code-muted); font-size: 12px; width: 36px; flex-shrink: 0; }
.bin {
    color: var(--code-accent);
    font-size: 12.5px;
    letter-spacing: .5px;
    word-break: break-all;
}

.output-row { display: flex; align-items: flex-start; gap: var(--sp-2); }

.output {
    flex: 1;
    margin: 0;
    padding: 10px var(--sp-3);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    word-break: break-all;
    white-space: pre-wrap;
    min-height: 20px;
    color: var(--text);
}

/* ---------------- 状态：加载 / 空 / 错误 ---------------- */

.loading {
    padding: var(--sp-5);
    text-align: center;
    color: var(--text-3);
    font-size: 13px;
}

.loading::after {
    content: "";
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-left: var(--sp-2);
    border: 2px solid var(--border-strong);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    vertical-align: -2px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.alert {
    padding: 10px var(--sp-4);
    border-radius: var(--radius-sm);
    font-size: 13px;
    line-height: 1.7;
    border: 1px solid transparent;
    display: block;
}

/* 带图标时（.alert > svg）改为行内弹性布局，保证图标与文字基线对齐 */
.alert:has(> svg) { display: flex; align-items: flex-start; gap: var(--sp-2); }
.alert > svg { width: 17px; height: 17px; flex: none; margin-top: 2px; }

.alert-error { background: var(--red-soft); color: var(--red-ink); border-color: color-mix(in srgb, var(--red) 26%, transparent); }
.alert-warn { background: var(--amber-soft); color: var(--amber-ink); border-color: color-mix(in srgb, var(--amber) 26%, transparent); }
.alert-info { background: var(--primary-soft); color: var(--primary); border-color: color-mix(in srgb, var(--primary) 26%, transparent); }
.alert-ok { background: var(--green-soft); color: var(--green-ink); border-color: color-mix(in srgb, var(--green) 26%, transparent); }

.empty {
    padding: var(--sp-5) var(--sp-4);
    text-align: center;
    color: var(--text-3);
    font-size: 13px;
    background: var(--surface-2);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
}

/* 表格单元格内的占位不需要边框与底色 */
.table td.empty { background: transparent; border: 0; padding: var(--sp-6) var(--sp-3); }

/* ---------------- 表格 ---------------- */

.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.table th {
    text-align: left;
    padding: 10px var(--sp-3);
    background: var(--surface-2);
    color: var(--text-2);
    font-weight: 600;
    font-size: 12.5px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table td {
    padding: 9px var(--sp-3);
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr.is-selected,
.table tbody tr[aria-selected="true"] { background: var(--primary-soft); }
.table .empty:hover { background: transparent; }

/* ---------------- 徽章 / 分类片 ---------------- */

.badge {
    display: inline-block;
    padding: 1px 10px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    line-height: 1.7;
    font-weight: 600;
    background: var(--surface-2);
    color: var(--text-2);
    border: 1px solid var(--border);
    white-space: nowrap;
}

.badge-ok { background: var(--green-soft); color: var(--green-ink); border-color: transparent; }
.badge-bad { background: var(--red-soft); color: var(--red-ink); border-color: transparent; }

.badge-cat { background: var(--primary-soft); color: var(--primary); border-color: transparent; }

.chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-3); }

.chip {
    padding: 4px 14px;
    min-height: 30px;
    display: inline-flex;
    align-items: center;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text-2);
    font-size: 13px;
    cursor: pointer;
    font-family: var(--font);
    transition: background .15s, border-color .15s, color .15s;
}

.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip:active { background: var(--primary-soft); }

.chip.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--on-primary);
    font-weight: 600;
}

.chip:disabled, .chip[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }

/* ---------------- 端口页 ---------------- */

.ports-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    margin-bottom: var(--sp-3);
    flex-wrap: wrap;
}

.ports-toolbar .input { max-width: 460px; }
.ports-toolbar .muted { white-space: nowrap; font-size: 13px; }

/* ---------------- 知识库 ---------------- */

.kn-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--sp-4);
}

.kn-card {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    color: var(--text);
    transition: transform .15s, box-shadow .15s, border-color .15s;
}

.kn-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); text-decoration: none; }

.kn-card-top { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.kn-views { font-size: 12px; color: var(--text-3); }
.kn-card h3 { font-size: 16px; font-weight: 650; }
.kn-card p { margin: 0; color: var(--text-2); font-size: 13px; flex: 1; }
.kn-date { font-size: 12px; color: var(--text-3); }

/* ---------------- 文章 ---------------- */

.article { max-width: 860px; margin: 0 auto; }

.article-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-3); }

.back-link { font-size: 13px; color: var(--text-2); }
.back-link:hover { color: var(--primary); }

.article-title { font-size: 24px; font-weight: 650; letter-spacing: -.02em; margin-bottom: 6px; }
.article-meta { font-size: 12.5px; color: var(--text-3); margin-bottom: 18px; }

.article-content { border-top: 1px solid var(--border); padding-top: 18px; color: var(--text-2); }

.article-content h3 {
    font-size: 16px;
    margin: 22px 0 10px;
    padding-left: 10px;
    border-left: 3px solid var(--primary);
    color: var(--text);
}

.article-content h3:first-child { margin-top: 0; }
.article-content p { margin: 0 0 var(--sp-3); color: var(--text-2); }

.article-content ul, .article-content ol { margin: 0 0 var(--sp-3); padding-left: 22px; color: var(--text-2); }
.article-content li { margin-bottom: 6px; }

.article-content table { width: 100%; border-collapse: collapse; margin: 0 0 var(--sp-3); font-size: 13px; }

.article-content th {
    background: var(--surface-2);
    text-align: left;
    padding: 8px 10px;
    border: 1px solid var(--border);
    font-weight: 600;
}

.article-content td { padding: 8px 10px; border: 1px solid var(--border); }

.article-content code {
    background: var(--code-inline-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 1px 6px;
    color: var(--code-inline-fg);
}

.article-content strong { color: var(--text); }

/* ---------------- 笔记 ---------------- */

.notes-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: var(--sp-4);
    align-items: start;
}

.note-form { display: flex; flex-direction: column; gap: var(--sp-3); position: sticky; top: 84px; }
.note-form h3 { font-size: 15px; font-weight: 650; }

.notes-list { display: flex; flex-direction: column; gap: var(--sp-3); }

.note-card { display: flex; flex-direction: column; gap: var(--sp-2); }

.note-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.note-card p { margin: 0; color: var(--text-2); font-size: 13px; white-space: pre-wrap; word-break: break-word; }

/* ---------------- API 文档 ---------------- */

.doc-title { font-size: 16px; font-weight: 650; margin: 22px 0 var(--sp-3); }
.doc-title:first-child { margin-top: 0; }

.method {
    display: inline-block;
    padding: 1px 9px;
    border-radius: var(--radius-xs);
    font-size: 11.5px;
    font-weight: 700;
    font-family: var(--mono);
    letter-spacing: .5px;
}

.method-get { background: var(--green-soft); color: var(--green-ink); }
.method-post { background: var(--primary-soft); color: var(--primary); }
.method-del { background: var(--red-soft); color: var(--red-ink); }

.code-block {
    margin: 0 0 var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    background: var(--code-bg);
    color: var(--code-fg);
    border-radius: var(--radius-sm);
    font-family: var(--mono);
    font-size: 12.5px;
    line-height: 1.7;
    overflow-x: auto;
    white-space: pre;
}

.api-test { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-3); }

/* ---------------- Toast ---------------- */

#toast-root {
    position: fixed;
    right: var(--sp-5);
    bottom: var(--sp-5);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}

.toast {
    padding: 10px var(--sp-4);
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    font-size: 13px;
    color: var(--text);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .25s, transform .25s;
    max-width: 320px;
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { border-left: 3px solid var(--green); }
.toast-error { border-left: 3px solid var(--red); }
.toast-warn { border-left: 3px solid var(--amber); }
.toast-info { border-left: 3px solid var(--primary); }

/* ---------------- 公告栏 ---------------- */

.announce {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    margin: 0 var(--gutter);
    padding: 10px var(--sp-4);
    background: var(--announce-bg);
    border: 1px solid var(--announce-border);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    color: var(--announce-fg);
}

.announce-icon {
    width: 22px;
    height: 22px;
    border-radius: var(--radius-xs);
    background: var(--announce-icon-bg);
    color: var(--announce-icon-fg);
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

/* ---------------- 侧栏补充 ---------------- */

.nav-divider {
    height: 1px;
    background: var(--border);
    margin: 10px 6px;
}

.nav-badge {
    margin-left: auto;
    font-size: 10.5px;
    padding: 1px 8px;
    border-radius: var(--radius-pill);
    background: var(--purple-soft);
    color: var(--purple-ink);
    font-weight: 600;
}

/* 已登录时的「管理后台」入口：紫色弱强调，不与当前项高亮混淆 */
.nav a.nav-accent { color: var(--purple-ink); }
.nav a.nav-accent:hover { color: var(--purple-ink); }

/* ---------------- 文件管理器 ---------------- */

.fm-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    flex-wrap: wrap;
    margin-bottom: var(--sp-3);
}

.fm-toolbar-actions { display: flex; align-items: center; gap: var(--sp-2); }

.fm-breadcrumb {
    padding: 10px var(--sp-4);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    margin-bottom: var(--sp-3);
    word-break: break-all;
}

.fm-search {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    margin-bottom: var(--sp-3);
    flex-wrap: wrap;
}

.fm-search .input { max-width: 460px; }
.fm-search .muted { white-space: nowrap; font-size: 13px; }

.fm-table td { vertical-align: middle; }

.fm-icon {
    width: 17px;
    height: 17px;
    vertical-align: -3px;
    margin-right: 4px;
    flex-shrink: 0;
}

.fm-icon.folder { color: var(--amber); }
.fm-icon.file { color: var(--text-3); }

.fm-up td { background: var(--surface-2); }

.fm-hint { margin-top: var(--sp-3); font-size: 12.5px; color: var(--text-3); }

/* ---------------- 管理后台 ---------------- */

.admin-nav {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--sp-2);
    margin-bottom: var(--sp-5);
}

.admin-nav-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--sp-3) var(--sp-4);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    transition: background .15s, border-color .15s, color .15s;
}

.admin-nav-item:hover { border-color: var(--purple); background: var(--surface-hover); text-decoration: none; }
.admin-nav-item strong { font-size: 13.5px; font-weight: 650; }
.admin-nav-item span { font-size: 11.5px; color: var(--text-3); }

.admin-nav-item.active {
    background: var(--purple-soft);
    border-color: transparent;
    color: var(--purple-ink);
}

.admin-nav-item.active span { color: var(--purple-ink); opacity: .8; }

.settings-layout {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: var(--sp-4);
    align-items: start;
}

.settings-actions {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    margin-top: 6px;
}

/* ============================================================
   7. 导航分组 / 顶栏按钮 / 抽屉 / 仪表盘
   ============================================================ */

/* ---------- 侧栏分组标题与图标 ---------- */
.nav-group {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-4) 10px 6px 16px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.2px;
    color: var(--text-3);
}

.nav-group:first-child { padding-top: var(--sp-1); }
.nav-group-icon { width: 14px; height: 14px; flex-shrink: 0; }
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }

/* ---------- 网络工具折叠区 ---------- */
.nav-fold { display: block; }
.nav-fold-summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
    min-height: 36px;
}

.nav-fold-summary::-webkit-details-marker { display: none; }
.nav-fold-summary::marker { content: ""; }
.nav-fold-summary > span { flex: 1; }
.nav-chevron {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--text-3);
    transition: transform .2s ease;
}

.nav-fold[open] .nav-chevron { transform: rotate(180deg); }
.nav-fold[open] .nav-fold-summary { color: var(--text); }
.nav-fold > a { padding-left: 24px; font-size: 13.5px; }

/* ---------- 管理组：退出登录表单按钮 ---------- */
.nav-logout { margin: 0; padding: 0; }
.nav-action {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    width: 100%;
    min-height: 36px;
    padding: 7px 10px 7px 16px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-size: 14px;
    font-family: var(--font);
    text-align: left;
    cursor: pointer;
    transition: background .15s, color .15s;
}

.nav-action:hover { background: var(--surface-hover); color: var(--text); }
.nav-action:active { background: var(--surface-3); }
.nav-action svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ---------- 顶栏图标按钮 ---------- */
.topbar-left, .topbar-actions { display: flex; align-items: center; gap: var(--sp-3); }
.topbar-left { min-width: 0; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text-2);
    cursor: pointer;
    flex-shrink: 0;
    transition: background .15s, color .15s, border-color .15s;
}

.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
.icon-btn:active { background: var(--primary-soft-2); }

#nav-toggle { display: none; }

/* ---------- 移动端抽屉遮罩（桌面默认不显示） ---------- */
.nav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 50;
    background: var(--backdrop);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

/* ---------- 首页仪表盘 ---------- */
.dash-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: var(--sp-3);
    margin-bottom: var(--sp-2);
}

.dash-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 18px 18px 16px;
    min-width: 0;
    transition: border-color .15s, box-shadow .15s;
}

.dash-card:hover { border-color: var(--border-strong); }

.dash-stat {
    font-size: 26px;
    font-weight: 700;
    font-family: var(--mono);
    color: var(--text);
    line-height: 1.25;
    letter-spacing: -.02em;
    word-break: break-all;
}

.dash-stat-label { font-size: 12.5px; color: var(--text-3); margin-bottom: var(--sp-2); }
.dash-card-meta { font-size: 12px; color: var(--text-2); margin-top: var(--sp-2); }
.dash-placeholder { color: var(--text-3); font-size: 13px; font-family: var(--font); font-weight: 400; }

/* ---------- 首页快捷入口卡片 ---------- */
.quick-card {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-4);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-sm);
    transition: transform .15s, border-color .15s, box-shadow .15s;
}

.quick-card:hover { transform: translateY(-2px); border-color: var(--primary); box-shadow: var(--shadow-lg); text-decoration: none; }
.quick-card:active { transform: translateY(-1px); }

.quick-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    background: var(--primary-soft);
    color: var(--primary);
    flex-shrink: 0;
}

.quick-icon svg { width: 20px; height: 20px; }
.quick-text { display: flex; flex-direction: column; min-width: 0; }
.quick-card strong { font-size: 14px; display: block; font-weight: 650; }
.quick-card .quick-desc { font-size: 12px; color: var(--text-3); display: block; margin-top: 1px; }

/* ============================================================
   8. 预览器
   ============================================================ */

.preview-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--sp-6);
}

.preview-modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xl);
    width: min(1080px, 96vw);
    height: min(86vh, 900px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.preview-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}

.preview-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.preview-actions { display: flex; gap: var(--sp-2); flex: none; }
.preview-body {
    flex: 1;
    overflow: auto;
    background: var(--surface-2);
    position: relative;
}

.preview-loading, .preview-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-3);
    font-size: 14px;
    padding: var(--sp-6);
    text-align: center;
}

.preview-img-wrap { display: flex; align-items: center; justify-content: center; min-height: 100%; padding: var(--sp-4); }
.preview-img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: var(--radius-sm); box-shadow: var(--shadow); background: var(--preview-canvas); }
.preview-frame { width: 100%; height: 100%; border: 0; background: var(--preview-canvas); }
.preview-video { width: 100%; height: 100%; background: var(--preview-video-bg); }
.preview-audio-wrap { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-4); min-height: 100%; padding: var(--sp-6); }
.preview-audio-wrap audio { width: min(560px, 90%); }

.preview-text {
    margin: 0;
    padding: var(--sp-5) var(--sp-6);
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.7;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
    background: var(--surface);
    min-height: 100%;
}

.preview-doc { padding: var(--sp-6) var(--sp-7); max-width: 860px; margin: 0 auto; background: var(--surface); min-height: 100%; color: var(--text); line-height: 1.75; }
.preview-doc h1, .preview-doc h2, .preview-doc h3 { color: var(--text); margin: 1.2em 0 .5em; line-height: 1.3; }
.preview-doc h3 { font-size: 16px; padding-bottom: 4px; border-bottom: 1px solid var(--border); }
.preview-doc p { margin: .5em 0; }
.preview-doc .slide { margin-bottom: 18px; padding-bottom: var(--sp-3); border-bottom: 1px dashed var(--border); }
.preview-doc .doc-table { border-collapse: collapse; width: 100%; margin: .6em 0; font-size: 13px; }
.preview-doc .doc-table th, .preview-doc .doc-table td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; vertical-align: top; }
.preview-doc .doc-table tr:nth-child(even) { background: var(--surface-2); }
.preview-doc .doc-empty { color: var(--text-3); font-style: italic; }

/* ============================================================
   9. 响应式
   ============================================================ */

@media (max-width: 1080px) {
    .two-col { grid-template-columns: 1fr; }
    .notes-layout { grid-template-columns: 1fr; }
    .note-form { position: static; }
}

@media (max-width: 960px) {
    .layout { flex-direction: column; }

    /* 侧栏改为移动端抽屉：默认移出视口，body.nav-open 时滑入 */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 264px;
        max-width: 84vw;
        height: 100vh;
        z-index: 60;
        border-right: 1px solid var(--border);
        border-bottom: none;
        box-shadow: var(--shadow-xl);
        transform: translateX(-100%);
        transition: transform .25s ease;
        visibility: hidden;
    }

    body.nav-open .sidebar { transform: translateX(0); visibility: visible; }

    .nav { flex-direction: column; flex-wrap: nowrap; }
    .sidebar-foot { display: flex; }

    #nav-toggle { display: inline-flex; }
    body.nav-open .nav-backdrop { display: block; }

    .hero { flex-direction: column; padding: var(--sp-6); }
    .hero-side { justify-content: stretch; }
    .hero-stat { flex: 1; }

    .tool-grid { grid-template-columns: 1fr; }
    .quick-grid { grid-template-columns: 1fr; }

    .content { padding: var(--sp-4); }
    .topbar { padding: var(--sp-3) var(--sp-4); }
    .announce { margin: 0 var(--sp-4); }
    .footer { padding: var(--sp-4) var(--sp-4) var(--sp-6); }
}

/* 触摸目标：移动端按钮 / 图标按钮 / 可点行不小于 40×40 CSS px */
@media (max-width: 960px) {
    .btn { min-height: 40px; padding: 8px var(--sp-4); }
    .btn-sm { min-height: 40px; padding: 6px var(--sp-3); }
    .icon-btn { width: 40px; height: 40px; }
    .nav a, .nav-action, .nav-fold-summary { min-height: 42px; }
    .chip { min-height: 40px; }
    .input, .select, .textarea { min-height: 40px; }
    .toast { max-width: calc(100vw - 32px); }
    #toast-root { left: var(--sp-4); right: var(--sp-4); bottom: var(--sp-4); }
    /* 顶栏操作区按钮在窄屏下不缩小，保持可点 */
    .topbar-header-actions .btn { min-height: 40px; }
}

@media (max-width: 640px) {
    .hero { padding: var(--sp-5); }
    .hero-body h2 { font-size: 21px; }
    .article-title { font-size: 20px; }
    .page-head, .page-intro, .admin-head { margin-bottom: var(--sp-4); }
    .card { padding: var(--sp-4); }
    /* 窄屏顶栏：隐藏「服务器时间」标签，只保留时钟数值 */
    .topbar-meta > .muted { display: none; }
    .topbar-sub { display: none; }
    .topbar { gap: var(--sp-2); }
}

/* 粗指针设备（触屏）统一放大触摸目标 */
@media (pointer: coarse) {
    .icon-btn { width: 40px; height: 40px; }
    .btn-sm { min-height: 32px; }
}

/* ============================================================
   10. 可访问性
   ============================================================ */

/* 尊重系统的「减少动态效果」偏好 */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
        scroll-behavior: auto !important;
    }
}

/* 打印：去掉装饰性外壳 */
@media print {
    .sidebar, .topbar, .footer, .nav-backdrop, #toast-root, .announce { display: none !important; }
    .layout { display: block; }
    .content { padding: 0; }
    .card { box-shadow: none; border-color: #ccc; }
}
