:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --bg: #f5f6fa;
    --text: #2b2f36;
    --text-2: #5b6270;
    --text-3: #9aa1ad;
    --border: #e8eaef;
    --card: #ffffff;
    --radius: 10px;
  }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  html, body { height: 100%; }
  body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
  }
  .hidden { display: none !important; }

  /* ---------- 顶部栏 ---------- */
  header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
  }
  .title {
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .title .dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--primary);
  }
  .actions { display: flex; gap: 8px; align-items: center; }
  .user-badge {
    font-size: 12px;
    color: var(--text-2);
    padding: 4px 10px;
    background: #f0f2f7;
    border-radius: 999px;
    white-space: nowrap;
  }
  .user-badge.admin { color: var(--primary); background: #eef2ff; }

  /* ---------- 登录 / 注册整页 ---------- */
  .auth-shell {
    min-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background:
      radial-gradient(ellipse 80% 60% at 20% 10%, rgba(37, 99, 235, 0.12), transparent 55%),
      radial-gradient(ellipse 70% 50% at 90% 90%, rgba(14, 165, 233, 0.10), transparent 50%),
      linear-gradient(160deg, #eef2f7 0%, #f7f8fb 45%, #e8eef8 100%);
  }
  .auth-shell.hidden { display: none !important; }
  .app-shell.hidden { display: none !important; }

  .auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px 24px 24px;
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.08);
  }
  .auth-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 8px;
  }
  .auth-brand h1 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.02em;
  }
  .auth-brand .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
  }
  .auth-subtitle {
    text-align: center;
    font-size: 13px;
    color: var(--text-2);
    margin-bottom: 20px;
    line-height: 1.5;
  }
  .login-tip { font-size: 13px; color: var(--text-2); margin-bottom: 14px; line-height: 1.6; }
  .login-form { display: flex; flex-direction: column; gap: 12px; }
  .login-form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: var(--text-2);
  }
  .login-form input {
    border: 1px solid #d9dce3;
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 14px;
    outline: none;
    font-family: inherit;
    width: 100%;
    box-sizing: border-box;
  }
  .login-form input:focus { border-color: var(--primary); }
  .login-error { font-size: 13px; color: #dc2626; margin-top: 10px; text-align: center; }
  .login-error.hidden { display: none; }
  .auth-actions {
    margin-top: 16px;
    display: flex;
  }
  .auth-actions button {
    flex: 1;
    padding: 10px 14px;
  }

  .auth-tabs {
    display: flex;
    gap: 4px;
    margin: 0 0 16px;
    padding: 4px;
    background: #f0f2f7;
    border-radius: 10px;
  }
  .auth-tab {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-2);
    cursor: pointer;
    font-family: inherit;
  }
  .auth-tab.active {
    background: #fff;
    color: var(--text);
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  }
  .auth-panel.hidden { display: none; }

  .admin-settings-modal {
    width: min(680px, 96vw);
    padding: 0;
    overflow: hidden;
  }
  .admin-settings-modal .modal-header {
    padding: 18px 20px 14px;
    margin: 0;
    border-bottom: 1px solid var(--border);
  }
  .admin-settings-title {
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .admin-settings-title-text {
    font-size: 17px;
    font-weight: 700;
  }
  .admin-settings-badge {
    font-size: 11px;
    font-weight: 600;
    color: var(--primary);
    background: #eef2ff;
    border-radius: 999px;
    padding: 2px 8px;
  }
  .admin-settings-body {
    padding: 16px 20px 8px;
    max-height: min(68vh, 560px);
    overflow: auto;
  }
  .admin-section {
    margin-bottom: 18px;
  }
  .admin-section + .admin-section {
    padding-top: 16px;
    border-top: 1px solid var(--border);
  }
  .admin-section-head { margin-bottom: 12px; }
  .admin-section-head-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
  }
  .admin-section-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 4px;
  }
  .admin-section-desc {
    font-size: 12px;
    line-height: 1.55;
    color: var(--text-2);
    margin: 0;
  }

  .admin-switch {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #f8fafc;
    cursor: pointer;
    user-select: none;
  }
  .admin-switch-text { min-width: 0; }
  .admin-switch-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
  }
  .admin-switch-hint {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    color: var(--text-3);
  }
  .admin-switch-control {
    position: relative;
    width: 44px;
    height: 26px;
    flex-shrink: 0;
  }
  .admin-switch-control input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    cursor: pointer;
    z-index: 2;
  }
  .admin-switch-slider {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: #cbd5e1;
    transition: background .18s ease;
  }
  .admin-switch-slider::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.2);
    transition: transform .18s ease;
  }
  .admin-switch-control input:checked + .admin-switch-slider {
    background: var(--primary);
  }
  .admin-switch-control input:checked + .admin-switch-slider::after {
    transform: translateX(18px);
  }
  .admin-switch-control input:focus-visible + .admin-switch-slider {
    outline: 2px solid rgba(37, 99, 235, 0.35);
    outline-offset: 2px;
  }

  .admin-user-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .admin-user-empty {
    padding: 16px;
    text-align: center;
    border: 1px dashed #d5dae3;
    border-radius: 12px;
    color: var(--text-2);
    font-size: 13px;
  }
  .admin-user-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
  }
  .admin-user-row.is-disabled {
    background: #f8fafc;
    opacity: 0.85;
  }
  .admin-user-meta {
    min-width: 0;
  }
  .admin-user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
  }
  .admin-user-sub {
    margin-top: 2px;
    font-size: 12px;
    color: var(--text-3);
  }
  .admin-user-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
  }
  .admin-user-tag {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
  }
  .admin-user-tag.admin {
    color: var(--primary);
    background: #eef2ff;
  }
  .admin-user-tag.off {
    color: #b45309;
    background: #fffbeb;
  }
  .admin-invite-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .admin-invite-empty {
    padding: 22px 16px;
    text-align: center;
    border: 1px dashed #d5dae3;
    border-radius: 12px;
    background: #fbfcfe;
    color: var(--text-2);
    font-size: 13px;
    line-height: 1.6;
  }
  .admin-invite-row {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr) auto;
    gap: 10px;
    align-items: end;
    background: #fff;
    transition: border-color .15s ease;
  }
  .admin-invite-row:focus-within {
    border-color: #bfdbfe;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
  }
  .admin-invite-row label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 12px;
    color: var(--text-2);
    min-width: 0;
  }
  .admin-invite-row label.webhook {
    grid-column: 1 / -1;
  }
  .admin-invite-row .field-label {
    font-weight: 600;
    letter-spacing: 0.01em;
  }
  .admin-invite-row input {
    border: 1px solid #d9dce3;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    width: 100%;
    background: #fff;
  }
  .admin-invite-row input:focus { border-color: var(--primary); }
  .admin-invite-row input.code-input {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-weight: 600;
    letter-spacing: 0.04em;
  }
  .admin-invite-row .row-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 1px;
  }
  .admin-settings-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 20px 18px;
    border-top: 1px solid var(--border);
    background: #fafbfc;
  }

  @media (max-width: 640px) {
    .admin-section-head-row {
      flex-direction: column;
      align-items: stretch;
    }
    .admin-invite-row {
      grid-template-columns: 1fr;
    }
    .admin-invite-row .row-actions {
      justify-content: stretch;
    }
    .admin-invite-row .row-actions button {
      width: 100%;
    }
  }

  /* ---------- 标签栏 ---------- */
  .tabbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 24px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    flex-wrap: nowrap;
    position: sticky;
    top: 58px;
    z-index: 15;
  }
  .tabbar::-webkit-scrollbar { height: 0; }
  .tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text-2);
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    transition: all .15s;
    flex-shrink: 0;
    user-select: none;
  }
  .tab:hover { border-color: #b9bec9; background: #f0f2f7; color: var(--text); }
  .tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(37, 99, 235, .3);
  }
  .tab .tab-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); flex-shrink: 0; }
  .tab.active .tab-dot { background: #fff; }
  .tab-warn { border-color: #f3c6c6; color: #b91c1c; }
  .tab-warn .tab-dot { background: #dc2626; }
  .tab-warn:hover { color: #b91c1c; border-color: #f0a8a8; }
  .tab-close {
    border: none; background: none; color: inherit; opacity: .6;
    font-size: 14px; line-height: 1; padding: 0 2px; cursor: pointer; border-radius: 4px;
  }
  .tab-close:hover { opacity: 1; background: rgba(0,0,0,.14); }
  /* 文件夹分组：文件夹标签与其内部文件标签延伸相连 */
  .tab-group {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0;
    flex-shrink: 0;
  }
  .tab-group .tab,
  .tab-group .tab-sub {
    height: 28px;
    padding: 0 10px;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
  }
  .tab-group .tab { background: transparent; border: none; box-shadow: none; }
  .tab-group .tab:hover { background: #eef0f5; }
  .tab-group .tab.active { background: var(--primary); }
  /* 子标签组从文件夹标签处延伸，左侧带连接线 */
  .tab-group .tab-sub-list {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding-left: 8px;
    position: relative;
  }
  .tab-group .tab-sub-list::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 8px;
    height: 1px;
    background: #c9cfdb;
  }
  .tab-group .tab-sub {
    font-size: 12px;
    padding: 0 9px;
    border: 1px solid #e3e7ef;
    background: #f4f6fb;
  }
  .tab-group .tab-sub.active {
    background: #f4f6fb;
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
    box-shadow: none;
  }
  /* 子标签选中时背景为浅色，圆点需保持主题色而非白色 */
  .tab-group .tab-sub.active .tab-dot { background: var(--primary); }
  .tab-group .tab-sub .tab-dot { width: 4px; height: 4px; }

  /* ---------- 按钮 ---------- */
  button {
    border: 1px solid #d9dce3;
    background: #fff;
    color: #3a3f4b;
    padding: 7px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all .15s;
    font-family: inherit;
  }
  button:hover { background: #f0f2f7; border-color: #b9bec9; }
  button:active { transform: scale(.97); }
  button.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
  button.primary:hover { background: var(--primary-dark); }
  button.danger { color: #dc2626; border-color: #f3c6c6; }
  button.danger:hover { background: #fef2f2; border-color: #f0a8a8; }
  button.small { padding: 2px 9px; font-size: 12px; border-radius: 6px; }

  /* ---------- 主体 ---------- */
  main { max-width: 1120px; margin: 0 auto; padding: 24px; width: 100%; box-sizing: border-box; }

  /* 文本/图片视图：工具栏固定，仅内容区滚动 */
  .app-shell:has(#textWrap:not(.hidden)) {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .app-shell:has(#textWrap:not(.hidden)) > header,
  .app-shell:has(#textWrap:not(.hidden)) > .tabbar {
    position: relative;
    top: auto;
    flex-shrink: 0;
  }
  .app-shell:has(#textWrap:not(.hidden)) > main {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-top: 16px;
    padding-bottom: 16px;
  }
  #textWrap:not(.hidden) {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
  }
  .text-body {
    display: flex;
    flex: 1;
    min-height: 0;
    gap: 12px;
    align-items: stretch;
  }
  .text-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    min-height: 0;
  }
  @keyframes viewIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
  }
  .view-enter { animation: viewIn .18s ease; }

  .cal-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 18px;
    position: relative;
  }
  .cal-toolbar .month-label {
    font-size: 18px;
    font-weight: 700;
    min-width: 130px;
    text-align: center;
  }
  .cal-toolbar .nav { padding: 6px 12px; }
  /* 导出按钮：悬停仅边框颜色变化 */
  /* #btnExport removed: 导出已并入企微推送 */  /* 标记按钮底色 */
  #btnMark { background: #eef2ff; color: var(--primary); border-color: #c7d2fe; }
  #btnMark:hover { background: #e0e7ff; border-color: #a5b4fc; }
  #btnMark.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
  #btnMark.primary:hover { background: var(--primary-dark); }
  .cal-status {
    position: absolute;
    right: 0;
    font-size: 12px;
    color: var(--text-3);
    white-space: nowrap;
  }

  .weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    margin-bottom: 6px;
  }
  .weekdays div {
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-3);
    padding: 4px 0;
  }

  .calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
  }

  .cell {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-height: 66px;
    padding: 7px 9px;
    cursor: pointer;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: hidden;
    transition: box-shadow .15s, transform .15s;
  }
  .cell:hover { box-shadow: 0 2px 10px rgba(0,0,0,.08); }
  /* 默认（窄/矮屏）：本周仍加高；宽且高时由下方 media 改为与其它行等高 */
  .cell.active-week {
    min-height: 132px;
    border-color: #bfdbfe;
    background: #f6f9ff;
  }
  .cell.other-month { opacity: .42; }
  .cell.selected { outline: 2px solid var(--primary); outline-offset: -2px; }

  .cell-top { display: flex; justify-content: space-between; align-items: center; }
  .day-num {
    font-size: clamp(13px, 1.05vw, 16px);
    font-weight: 600;
    width: 24px; height: 24px;
    line-height: 24px;
    text-align: center;
    border-radius: 50%;
  }
  .cell.today .day-num { background: var(--primary); color: #fff; }
  .cell-right { display: flex; align-items: center; gap: 4px; }
  .cell .mark {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
    flex-shrink: 0;
    line-height: 1;
  }
  .cell .mark.vac { color: #dc2626; }

  .duty-manual-modal {
    width: min(520px, 96vw);
  }
  .duty-manual-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 10px;
  }
  .duty-manual-weekdays {
    margin-bottom: 6px;
  }
  .duty-manual-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
  }
  .duty-manual-cell {
    min-height: 52px;
    border: 1px solid #e5e8ef;
    border-radius: 8px;
    background: #fff;
    padding: 6px 8px;
    cursor: pointer;
    user-select: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }
  .duty-manual-cell:hover { border-color: #93c5fd; background: #f8fbff; }
  .duty-manual-cell.other { opacity: 0.35; pointer-events: none; }
  .duty-manual-cell.vac {
    background: #f3f4f6;
    border-color: #d1d5db;
  }
  .duty-manual-cell .dn { font-size: 13px; font-weight: 700; }
  .duty-manual-cell .tag {
    font-size: 12px;
    font-weight: 700;
    color: #dc2626;
    align-self: flex-end;
  }
  .duty-manual-cell:not(.vac) .tag { color: var(--primary); }

  .log-preview {
    font-size: clamp(12px, 0.95vw, 14px);
    color: var(--text-2);
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .cell.active-week .log-preview { -webkit-line-clamp: 5; }
  .cell:not(.active-week) .log-preview { -webkit-line-clamp: 2; }
  .cell .empty-hint {
    font-size: 11px;
    color: var(--text-3);
    line-height: 1.5;
    display: none;
  }
  .cell.active-week .empty-hint { display: block; }

  /* 宽屏：仅日历可见时加宽主栏（文本/文件夹仍用 1120） */
  @media (min-width: 1201px) {
    main:has(#calendarWrap:not(.hidden)) {
      max-width: min(1600px, 96vw);
    }
  }

  /* 宽且高：占满可视高度、行等高；本周只靠底色区分，用更多预览行填满 */
  @media (min-width: 1201px) and (min-height: 850px) {
    main:has(#calendarWrap:not(.hidden)) {
      display: flex;
      flex-direction: column;
      /* header≈58 + tabbar≈44 + 余量；先 100vh 再覆盖 100dvh */
      min-height: calc(100vh - 160px);
      min-height: calc(100dvh - 160px);
    }
    #calendarWrap:not(.hidden) {
      display: flex;
      flex-direction: column;
      flex: 1;
      min-height: 0;
    }
    .calendar-grid {
      flex: 1;
      align-content: stretch;
      grid-auto-rows: minmax(clamp(66px, 11vh, 150px), 1fr);
      gap: 8px;
    }
    .weekdays { gap: 8px; }
    .weekdays div { font-size: 13px; }
    .cell {
      min-height: clamp(66px, 11vh, 150px);
    }
    .cell.active-week {
      min-height: clamp(66px, 11vh, 150px);
    }
    .cell:not(.active-week) .log-preview { -webkit-line-clamp: 4; }
    .cell.active-week .log-preview { -webkit-line-clamp: 8; }
  }

  /* ---------- 文本视图 ---------- */
  .text-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
    flex-shrink: 0;
    background: var(--bg);
    z-index: 5;
  }
  .text-meta { display: flex; align-items: center; gap: 10px; min-width: 0; }
  .text-name {
    font-size: 15px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 60vw;
  }
  .text-info { font-size: 12px; color: var(--text-3); white-space: nowrap; }
  .text-info .text-time {
    color: inherit;
    transition: color .2s ease;
  }
  .text-info .text-time.just-saved {
    color: #059669;
    font-weight: 600;
  }
  .auto-save-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-2);
    user-select: none;
    cursor: pointer;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card);
  }
  .auto-save-toggle input {
    margin: 0;
    accent-color: var(--primary);
  }
  .btn-text-save {
    display: inline-flex;
    align-items: center;
    gap: 7px;
  }
  .btn-text-save .save-dirty-dot {
    display: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ef4444;
    box-shadow: 0 0 0 2px #fff;
    flex-shrink: 0;
  }
  .btn-text-save.is-dirty {
    background: #fff;
    color: #dc2626;
    border-color: #fca5a5;
  }
  .btn-text-save.is-dirty:hover {
    background: #fef2f2;
    border-color: #f87171;
    color: #b91c1c;
  }
  .btn-text-save.is-dirty .save-dirty-dot {
    display: inline-block;
  }
  .text-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .doc-hl-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
  }
  .doc-hl-palette {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .12);
  }
  .doc-hl-swatch {
    width: 22px;
    height: 22px;
    padding: 0;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    cursor: pointer;
  }
  .doc-hl-swatch:hover { border-color: #64748b; transform: scale(1.06); }
  .doc-hl-swatch-yellow { background: #fef08a; }
  .doc-hl-swatch-green { background: #bbf7d0; }
  .doc-hl-swatch-blue { background: #bfdbfe; }
  .doc-hl-swatch-pink { background: #fbcfe8; }
  .doc-hl-swatch-orange { background: #fed7aa; }
  .doc-hl-clear {
    margin-left: 2px;
    padding: 2px 8px;
    font-size: 12px;
    line-height: 1.4;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    color: var(--text-2);
    cursor: pointer;
  }
  .doc-hl-clear:hover { background: #f0f2f7; border-color: #b9bec9; }
  .doc-editor .doc-hl {
    border-radius: 3px;
    padding: 0 2px;
  }
  .doc-editor .doc-hl.doc-hl-yellow,
  .doc-editor .doc-hl.doc-hl-yellow:hover { background: #fef08a; }
  .doc-editor .doc-hl.doc-hl-green,
  .doc-editor .doc-hl.doc-hl-green:hover { background: #bbf7d0; }
  .doc-editor .doc-hl.doc-hl-blue,
  .doc-editor .doc-hl.doc-hl-blue:hover { background: #bfdbfe; }
  .doc-editor .doc-hl.doc-hl-pink,
  .doc-editor .doc-hl.doc-hl-pink:hover { background: #fbcfe8; }
  .doc-editor .doc-hl.doc-hl-orange,
  .doc-editor .doc-hl.doc-hl-orange:hover { background: #fed7aa; }
  .doc-editor {
    width: 100%;
    flex: 1;
    min-height: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    /* 宽屏时正文约 900px 居中；窄于该宽度时退回两侧 18px */
    padding: 16px max(18px, calc((100% - 900px) / 2));
    font-size: 15px;
    line-height: 1.75;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    outline: none;
    background: var(--card);
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
    transition: border-color .15s;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
  }
  .doc-editor:focus { border-color: var(--primary); }
  .doc-editor[contenteditable="false"] { background: #f7f8fb; color: var(--text-2); }
  .doc-editor a,
  .doc-editor a.auto-link,
  .md-preview a,
  .md-preview a.auto-link {
    color: #2563eb;
    font-weight: 700;
    cursor: pointer;
    text-decoration: underline;
    word-break: break-all;
  }
  .doc-editor a:hover,
  .md-preview a:hover {
    color: #1d4ed8;
  }
  .doc-editor:empty:before {
    content: attr(data-placeholder);
    color: var(--text-3);
    pointer-events: none;
  }
  .doc-editor img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 10px 0;
    border-radius: 6px;
  }
  .doc-editor .img-resizer {
    position: relative;
    display: inline-block;
    max-width: 100%;
    margin: 10px 0;
    line-height: 0;
    vertical-align: top;
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 6px;
    user-select: none;
  }
  .doc-editor .img-resizer img {
    margin: 0;
    display: block;
    max-width: 100%;
    height: auto;
    pointer-events: none;
  }
  .img-resizer-bar {
    position: absolute;
    left: 50%;
    top: -36px;
    transform: translateX(-50%);
    display: flex;
    gap: 4px;
    padding: 3px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,.12);
    z-index: 5;
    white-space: nowrap;
  }
  .img-resizer-bar button {
    border: 0;
    background: transparent;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text);
  }
  .img-resizer-bar button:hover { background: #f1f5f9; }
  .img-resizer-bar button.danger { color: #b91c1c; }
  .img-resizer-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #fff;
    border: 2px solid var(--primary);
    border-radius: 2px;
    z-index: 6;
    box-sizing: border-box;
  }
  .img-resizer-handle.nw { left: -5px; top: -5px; cursor: nwse-resize; }
  .img-resizer-handle.ne { right: -5px; top: -5px; cursor: nesw-resize; }
  .img-resizer-handle.sw { left: -5px; bottom: -5px; cursor: nesw-resize; }
  .img-resizer-handle.se { right: -5px; bottom: -5px; cursor: nwse-resize; }

  .md-mode-bar {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
  }
  .md-mode-bar .md-mode-btn {
    border: 0;
    border-radius: 0;
    margin: 0;
    background: var(--card);
    box-shadow: none;
  }
  .md-mode-bar .md-mode-btn + .md-mode-btn {
    border-left: 1px solid var(--border);
  }
  .md-mode-bar .md-mode-btn.active {
    background: #eff6ff;
    color: var(--primary);
    font-weight: 600;
  }
  .md-wrap {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    flex: 1;
    min-height: 0;
  }
  .md-wrap.mode-edit { grid-template-columns: 1fr; }
  .md-wrap.mode-edit .md-preview { display: none; }
  .md-wrap.mode-preview { grid-template-columns: 1fr; }
  .md-wrap.mode-preview .md-source { display: none; }
  .md-source {
    width: 100%;
    height: 100%;
    min-height: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    font-size: 14px;
    line-height: 1.65;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    resize: none;
    outline: none;
    background: var(--card);
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
    color: var(--text);
    overflow: auto;
  }
  .md-source:focus { border-color: var(--primary); }
  .md-source[readonly] { background: #f7f8fb; color: var(--text-2); }
  .md-preview {
    height: 100%;
    min-height: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    background: var(--card);
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
    overflow: auto;
    line-height: 1.75;
    font-size: 15px;
  }
  .md-preview > :first-child { margin-top: 0; }
  .md-preview h1, .md-preview h2, .md-preview h3,
  .md-preview h4, .md-preview h5, .md-preview h6 {
    margin: 1.1em 0 0.45em;
    line-height: 1.35;
    font-weight: 700;
  }
  .md-preview h1 { font-size: 1.7em; border-bottom: 1px solid var(--border); padding-bottom: 0.25em; }
  .md-preview h2 { font-size: 1.4em; border-bottom: 1px solid var(--border); padding-bottom: 0.2em; }
  .md-preview h3 { font-size: 1.2em; }
  .md-preview p { margin: 0.7em 0; }
  .md-preview ul, .md-preview ol { margin: 0.6em 0; padding-left: 1.5em; }
  .md-preview li { margin: 0.25em 0; }
  .md-preview blockquote {
    margin: 0.8em 0;
    padding: 0.2em 0 0.2em 0.9em;
    border-left: 3px solid #93c5fd;
    color: var(--text-2);
    background: #f8fafc;
  }
  .md-preview pre {
    margin: 0.8em 0;
    padding: 12px 14px;
    border-radius: 8px;
    background: #0f172a;
    color: #e2e8f0;
    overflow: auto;
    font-size: 13px;
    line-height: 1.55;
  }
  .md-preview code {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.92em;
  }
  .md-preview :not(pre) > code {
    background: #f1f5f9;
    padding: 0.12em 0.4em;
    border-radius: 4px;
  }
  .md-preview img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 10px 0;
    border-radius: 6px;
  }
  .md-preview hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 1.2em 0;
  }
  .md-preview .md-empty { color: var(--text-3); }
  .image-wrap {
    width: 100%;
    flex: 1;
    min-height: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    padding: 16px;
  }
  .image-wrap img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
  }
  @media (max-width: 860px) {
    .md-wrap.mode-split {
      grid-template-columns: 1fr;
      grid-template-rows: 1fr 1fr;
    }
    .md-wrap.mode-split .md-source,
    .md-wrap.mode-split .md-preview {
      min-height: 0;
      height: 100%;
    }
  }

  /* ---------- 文件夹视图 ---------- */
  .folder-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
  }
  .folder-path {
    font-size: 13px;
    color: var(--text-2);
    margin-left: auto;
    max-width: 60%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .folder-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px;
    min-height: 120px;
  }
  .folder-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background .12s;
  }
  .folder-item:hover { background: #f0f2f7; }
  .folder-item.directory { cursor: pointer; }
  .folder-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    border-radius: 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: #b45309;
    background: #fef3c7;
  }
  .folder-icon.file { color: #475569; background: #eef2f7; }
  .folder-name {
    flex: 1;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .folder-item.directory .folder-name { font-weight: 600; }
  .folder-meta {
    font-size: 12px;
    color: var(--text-3);
    white-space: nowrap;
    flex-shrink: 0;
  }
  .folder-loading { text-align: center; color: var(--text-3); font-size: 13px; padding: 40px 0; }
  .folder-empty { text-align: center; color: var(--text-3); font-size: 13px; padding: 40px 0; }
  .folder-perm {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 48px 0;
    color: var(--text-2);
    font-size: 14px;
  }

  /* ---------- 弹窗 ---------- */
  .modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 16px;
  }
  .modal.hidden { display: none; }
  .modal-content {
    background: #fff;
    border-radius: 14px;
    width: 560px;
    max-width: 100%;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
    animation: pop .18s ease;
  }
  @keyframes pop {
    from { transform: translateY(12px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
  }
  .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    gap: 10px;
  }
  .modal-date-nav { display: flex; align-items: center; gap: 8px; }
  .modal-date-nav .date-text { font-size: 17px; font-weight: 700; }
  .modal-close {
    background: none; border: none;
    font-size: 22px; line-height: 1;
    color: var(--text-3); padding: 2px 8px;
  }
  .modal-close:hover { color: var(--text); background: #f0f2f7; }
  .unsaved-modal { width: min(420px, 92vw); }
  .unsaved-msg {
    margin: 4px 0 18px;
    font-size: 14px;
    line-height: 1.65;
    color: var(--text-2);
  }
  .unsaved-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
  }

  /* ---------- 相关接口 ---------- */
  .api-ref {
    color: #1d4ed8;
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 2px;
    background: #eff6ff;
    border-radius: 3px;
    padding: 0 2px;
    cursor: pointer;
  }
  .api-ref:hover { background: #dbeafe; color: #1e40af; }
  .img-ref:not(.api-ref) {
    color: #0f766e;
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 2px;
    background: #ecfdf5;
    border-radius: 3px;
    padding: 0 2px;
    cursor: pointer;
  }
  .img-ref:not(.api-ref):hover { background: #d1fae5; color: #115e59; }
  .api-ref.img-ref { cursor: pointer; }
  .md-preview .api-ref,
  .md-preview .img-ref { cursor: pointer; }

  .api-catalog-modal {
    width: min(720px, 96vw);
    max-height: min(88vh, 900px);
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .api-link-modal { width: min(640px, 96vw); }
  .link-modal-tabs { margin: 0 0 12px; }
  .link-modal-panel { min-height: 120px; }
  .link-img-hint {
    margin: 0 0 10px;
    font-size: 13px;
    color: var(--text-3);
    line-height: 1.5;
  }
  .link-img-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
  }
  .link-img-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    max-height: min(42vh, 360px);
    overflow: auto;
    min-height: 120px;
    padding: 8px;
    border: 1px dashed var(--border);
    border-radius: 10px;
    background: #fafbfc;
    outline: none;
  }
  .link-img-preview:focus,
  .link-img-preview.link-img-dragover {
    border-color: #93c5fd;
    background: #f8fbff;
  }
  .link-img-preview-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
  }
  .link-img-preview-item img {
    display: block;
    width: 100%;
    height: 96px;
    object-fit: cover;
    background: #f8fafc;
  }
  .link-img-preview-item .name {
    font-size: 11px;
    color: var(--text-3);
    padding: 6px 8px;
    word-break: break-all;
  }
  .link-img-preview-empty {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-3);
    font-size: 13px;
    padding: 28px 12px;
    line-height: 1.6;
  }
  .api-catalog-modal > .api-catalog-header {
    align-items: flex-start;
    margin: 0;
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  .api-catalog-heading { min-width: 0; flex: 1; }
  .api-catalog-title {
    display: block;
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
  }
  .api-catalog-desc {
    margin: 6px 0 0;
    font-size: 12px;
    line-height: 1.55;
    color: var(--text-3);
  }
  .api-catalog-modal > .api-tabs {
    margin: 0;
    padding: 12px 20px 0;
    flex-shrink: 0;
  }
  .api-catalog-modal > .api-panel {
    padding: 12px 20px 18px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .api-catalog-modal .api-collection-bar { flex-shrink: 0; }
  .api-catalog-modal .api-collection-base { flex-shrink: 0; }
  .api-catalog-modal .api-list {
    flex: 1 1 auto;
    min-height: 160px;
    max-height: none;
    margin-bottom: 0;
  }
  .api-catalog-footer {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    margin-top: 12px;
    flex-shrink: 0;
  }
  .api-catalog-modal .api-all-tree {
    flex: 1;
    min-height: 0;
    max-height: none;
  }
  .api-list {
    overflow: auto;
    margin: 0 0 12px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #f8fafc;
  }
  .api-empty {
    color: var(--text-3);
    font-size: 13px;
    padding: 28px 12px;
    text-align: center;
    line-height: 1.6;
  }
  .api-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 12px;
    margin-bottom: 6px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    transition: border-color .15s ease, box-shadow .15s ease;
  }
  .api-item:last-child { margin-bottom: 0; }
  .api-item:hover {
    border-color: #c7d2fe;
    box-shadow: 0 1px 4px rgba(37, 99, 235, .08);
  }
  .api-item-main { display: flex; gap: 10px; min-width: 0; flex: 1; align-items: flex-start; }
  .api-item-text { min-width: 0; }
  .api-item-name { font-weight: 600; font-size: 14px; color: var(--text); line-height: 1.35; }
  .api-item-url {
    font-size: 12px;
    color: var(--text-2);
    word-break: break-all;
    margin-top: 4px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    line-height: 1.45;
  }
  .api-item-url a { color: var(--primary); text-decoration: none; }
  .api-item-url a:hover { text-decoration: underline; }
  .api-item-note { font-size: 12px; color: var(--text-3); margin-top: 6px; line-height: 1.45; }
  .api-item-actions { display: flex; gap: 6px; flex-shrink: 0; align-items: flex-start; }
  .api-method {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 54px;
    height: 24px;
    padding: 0 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .02em;
    flex-shrink: 0;
    background: #e2e8f0;
    color: #334155;
  }
  .api-method-get { background: #dcfce7; color: #166534; }
  .api-method-post { background: #dbeafe; color: #1e40af; }
  .api-method-put, .api-method-patch { background: #ffedd5; color: #9a3412; }
  .api-method-delete { background: #fee2e2; color: #991b1b; }
  .api-form {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #fff;
  }
  .api-entry-form-modal {
    width: min(520px, 96vw);
    padding: 0;
    overflow: hidden;
  }
  #apiEntryFormModal { z-index: 110; }
  .api-entry-form-modal > .modal-header {
    margin: 0;
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--border);
  }
  .api-form-modal-body {
    border: none;
    border-radius: 0;
    padding: 16px 20px 18px;
    box-shadow: none;
  }
  .api-form-title {
    font-weight: 700;
    font-size: 13px;
    color: var(--text);
    padding-bottom: 2px;
  }
  .api-form-row { display: grid; grid-template-columns: 1fr 120px; gap: 10px; }
  .api-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--text-2); font-weight: 500; }
  .api-form input, .api-form select, .api-form textarea {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 11px;
    font-size: 13px;
    font-family: inherit;
    background: #fff;
    color: var(--text);
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
  }
  .api-form input:focus, .api-form select:focus, .api-form textarea:focus {
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
  }
  .api-form textarea { resize: vertical; min-height: 64px; max-height: 140px; }
  .api-form-actions {
    margin-top: 2px;
    flex-shrink: 0;
  }
  .api-link-list { max-height: 42vh; overflow: auto; margin-bottom: 14px; }
  .api-link-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 10px;
    margin-bottom: 4px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
  }
  .api-link-item:hover { border-color: #c7d2fe; background: #f8fbff; }
  .api-link-name { font-size: 13px; }

  .api-related-panel {
    flex: 0 0 min(300px, 38vw);
    width: min(300px, 38vw);
    min-width: 220px;
    max-width: 340px;
    align-self: stretch;
    min-height: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
    display: flex;
    flex-direction: column;
    padding: 12px 12px 14px;
    overflow: hidden;
  }
  .api-related-panel.hidden { display: none; }
  .api-related-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
    flex-shrink: 0;
  }
  .api-related-header-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
  }
  .api-related-header-top > strong,
  .api-related-header > strong {
    font-size: 14px;
    line-height: 1.4;
    min-width: 0;
    flex: 1;
    word-break: break-word;
  }
  .api-related-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
  }
  #apiRelatedList {
    flex: 1;
    overflow: auto;
    max-height: none;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
  }
  #apiRelatedList .api-item { box-shadow: none; }

  .img-related-panel { /* 与左侧同套 api-related-panel 基类 */ }
  .img-related-list {
    flex: 1;
    overflow-x: hidden;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    padding: 2px 2px 8px;
  }
  .img-related-item {
    flex: 0 0 auto;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
  }
  .img-related-item img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 200px;
    object-fit: contain;
    background: #f8fafc;
    cursor: zoom-in;
  }
  .img-related-item-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 8px;
    border-top: 1px solid var(--border);
    background: #fafbfc;
  }
  .img-related-item-name {
    font-size: 12px;
    color: var(--text-3);
    word-break: break-all;
    flex: 1;
    min-width: 0;
  }
  .img-related-item-del {
    flex-shrink: 0;
    margin-left: auto;
  }
  .img-related-empty {
    color: var(--text-3);
    font-size: 13px;
    padding: 28px 12px;
    text-align: center;
  }

  /* 接口 + 图片双侧栏同时打开：加宽主栏、减小左右间距，侧栏宽度不变；正文用满中间区 */
  main:has(#apiRelatedPanel:not(.hidden)):has(#imgRelatedPanel:not(.hidden)) {
    max-width: min(1680px, 98vw);
    padding-left: 12px;
    padding-right: 12px;
  }
  main:has(#apiRelatedPanel:not(.hidden)):has(#imgRelatedPanel:not(.hidden)) .doc-editor {
    padding-left: 18px;
    padding-right: 18px;
  }
  .img-lightbox {
    position: fixed;
    inset: 0;
    z-index: 120;
    background: rgba(15, 23, 42, .72);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    cursor: zoom-out;
  }
  .img-lightbox.hidden { display: none; }
  .img-lightbox img {
    max-width: min(96vw, 1200px);
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 12px 40px rgba(0,0,0,.35);
  }

  @media (max-width: 720px) {
    .text-body { flex-direction: column; }
    .api-related-panel {
      flex: 0 0 auto;
      width: 100%;
      max-width: none;
      min-width: 0;
      max-height: 36vh;
    }
  }

  .api-tabs {
    display: inline-flex;
    gap: 0;
    margin-bottom: 12px;
    padding: 3px;
    border-radius: 10px;
    background: #f0f2f7;
    border: 1px solid var(--border);
  }
  .api-tab {
    border: none;
    background: transparent;
    color: var(--text-2);
    padding: 7px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background .15s ease, color .15s ease, box-shadow .15s ease;
  }
  .api-tab:hover { color: var(--text); }
  .api-tab.active {
    background: #fff;
    color: var(--primary);
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .08);
  }
  .api-collection-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
  }
  .api-collection-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-2);
    font-weight: 500;
  }
  .api-collection-label select {
    min-width: 160px;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    background: #fff;
    color: var(--text);
    outline: none;
  }
  .api-collection-label select:focus {
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
  }
  .api-collection-actions { display: flex; flex-wrap: wrap; gap: 6px; }
  .api-collection-base {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 10px;
    margin: 0 0 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
  }
  .api-collection-base-label {
    flex-shrink: 0;
    font-size: 13px;
    color: var(--text-2);
    font-weight: 500;
    white-space: nowrap;
  }
  .api-collection-base-input,
  #apiCollectionBaseUrl {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    background: #fff;
    color: var(--text);
    outline: none;
  }
  .api-collection-base-input:focus,
  #apiCollectionBaseUrl:focus {
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
  }
  .api-collection-base > .small {
    flex-shrink: 0;
  }
  .api-all-tree { overflow: auto; margin: 0; }
  .api-tree-user { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; overflow: hidden; background: #fff; }
  .api-tree-toggle {
    width: 100%;
    text-align: left;
    padding: 11px 14px;
    background: #f8fafc;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
  }
  .api-tree-toggle:hover { background: #f1f5f9; }
  .api-tree-body { display: none; padding: 10px; background: #f8fafc; }
  .api-tree-user.is-open > .api-tree-body { display: block; }
  .api-tree-col { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; background: #fff; overflow: hidden; }
  .api-tree-col:last-child { margin-bottom: 0; }
  .api-tree-col-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: #fff;
  }
  .api-tree-col-toggle {
    width: 24px;
    text-align: center;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-3);
    flex-shrink: 0;
  }
  .api-tree-col-toggle::before { content: '▸'; }
  .api-tree-col.is-open > .api-tree-col-head .api-tree-col-toggle::before { content: '▾'; }
  .api-tree-col-name {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
  }
  .api-tree-col-count { font-size: 12px; color: var(--text-3); }
  .api-tree-col-body { display: none; padding: 4px 8px 10px; }
  .api-tree-col.is-open > .api-tree-col-body { display: block; }
  .api-tree-empty { padding: 8px 4px; }
  .api-item-meta { font-size: 11px; color: var(--text-3); margin-bottom: 3px; }
  .api-link-group {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-2);
    padding: 10px 4px 6px;
    border-top: 1px solid var(--border);
    margin-top: 6px;
  }
  .api-link-group:first-child { border-top: none; margin-top: 0; }
  .api-copy-modal { width: min(420px, 96vw); }
  .api-copy-modal label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; margin-bottom: 12px; }
  .api-copy-modal input, .api-copy-modal select {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
  }

  @media (max-width: 640px) {
    .api-form-row { grid-template-columns: 1fr; }
    .api-collection-bar { align-items: stretch; }
    .api-collection-label { width: 100%; }
    .api-collection-label select { flex: 1; min-width: 0; width: 100%; }
    .api-collection-base {
      flex-wrap: wrap;
      align-items: center;
    }
    .api-collection-base-label { width: auto; }
    .api-collection-base-input { flex: 1 1 180px; }
    .api-collection-base > .small { margin-left: auto; }
    .api-item { flex-direction: column; }
    .api-item-actions { width: 100%; justify-content: flex-end; }
  }

  .share-hub-modal, .share-pick-modal { width: min(640px, 96vw); }
  .share-hub-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
  }
  .share-hub-panel { min-height: 200px; }
  .share-list { max-height: 48vh; overflow: auto; }
  .share-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 8px;
    border-bottom: 1px solid var(--border);
  }
  .share-item-main { min-width: 0; flex: 1; }
  .share-item-name { font-weight: 600; font-size: 14px; word-break: break-all; }
  .share-item-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
  }
  .share-item-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    padding: 3px 6px;
    border-radius: 4px;
    background: #e8f1ff;
    color: #1a5fb4;
    flex-shrink: 0;
  }
  .share-item-badge.is-new { background: #e8f8ef; color: #1b7a45; }
  .share-item-recipients {
    font-size: 12px;
    color: var(--text-2);
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .share-item-recipient-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }
  .share-item-meta { font-size: 12px; color: var(--text-3); margin-top: 4px; }
  .share-item-actions { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }
  .share-pick-item.is-disabled {
    opacity: 0.55;
    pointer-events: none;
  }
  .share-pick-item .share-pick-tag {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-3);
  }
  .share-pick-list { max-height: 42vh; overflow: auto; margin-bottom: 12px; }
  .share-pick-group {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-2);
    padding: 8px 4px 4px;
    border-top: 1px solid var(--border);
    margin-top: 4px;
  }
  .share-pick-group:first-child { border-top: none; margin-top: 0; }
  .share-pick-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 4px;
    cursor: pointer;
    font-size: 13px;
  }
  .share-pick-name { font-weight: 500; }
  .share-pick-user { color: var(--text-3); font-size: 12px; }

  .entries {
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 80px;
    max-height: 48vh;
  }
  .entry {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    background: #f7f8fb;
    border: 1px solid #eceef3;
    border-radius: 8px;
    padding: 8px 10px;
  }
  .entry .num {
    color: var(--text-3);
    font-size: 12px;
    margin-top: 3px;
    flex-shrink: 0;
    min-width: 16px;
    text-align: right;
  }
  .entry .text {
    flex: 1;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 14px;
  }
  .entry .text-edit {
    flex: 1;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.6;
    border: 1px solid var(--primary);
    border-radius: 6px;
    padding: 4px 8px;
    outline: none;
    resize: vertical;
  }
  .entry-actions { display: flex; gap: 4px; flex-shrink: 0; }

  .add-row { display: flex; gap: 8px; margin-top: 14px; }
  input[type="text"], input[type="date"] {
    flex: 1;
    border: 1px solid #d9dce3;
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 14px;
    outline: none;
    font-family: inherit;
  }
  input:focus { border-color: var(--primary); }

  .empty-tip {
    text-align: center;
    color: var(--text-3);
    font-size: 13px;
    padding: 30px 0;
  }

  /* ---------- 导出弹窗 ---------- */
  .export-week-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
  }
  .export-week-bar .week-text { font-size: 15px; font-weight: 600; }
  textarea.export-area {
    width: 100%;
    min-height: 320px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    font-size: 13px;
    line-height: 1.7;
    resize: vertical;
    background: #fafbfd;
    font-family: inherit;
    outline: none;
  }
  .export-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
  .export-note { font-size: 12px; color: var(--text-3); margin-top: 8px; }

  /* ---------- Toast ---------- */
  .toast {
    position: fixed;
    left: 50%;
    bottom: 40px;
    transform: translateX(-50%);
    background: #1f2937;
    color: #fff;
    padding: 9px 18px;
    border-radius: 8px;
    font-size: 13px;
    z-index: 200;
    opacity: 0;
    transition: opacity .25s, bottom .25s;
    pointer-events: none;
  }
  .toast.show { opacity: 1; bottom: 56px; }

  /* ---------- 企微推送 ---------- */
  .wecom-modal { width: min(680px, 96vw); }
  .wecom-settings-form {
    margin-bottom: 10px;
  }
  .wecom-settings-form input[type="url"] {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
  }
  .wecom-role-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
  @media (max-width: 520px) {
    .wecom-role-row { grid-template-columns: 1fr; }
  }
  .wecom-status {
    font-size: 12px;
    color: var(--text-3);
    background: #f4f6fb;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 12px;
  }
  .wecom-status.ok { color: #166534; background: #f0fdf4; border-color: #bbf7d0; }
  .wecom-status.warn { color: #92400e; background: #fffbeb; border-color: #fde68a; }
  .wecom-status.err { color: #991b1b; background: #fef2f2; border-color: #fecaca; }
  .wecom-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
  }
  .wecom-tab {
    border: none;
    background: transparent;
    color: var(--text-2);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
  }
  .wecom-tab:hover { background: #f0f2f7; color: var(--text); }
  .wecom-tab.active {
    background: #eef2ff;
    color: var(--primary);
    font-weight: 600;
  }
  .wecom-quick {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
  }
  .wecom-text {
    width: 100%;
    min-height: 180px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    font-size: 13px;
    line-height: 1.7;
    resize: vertical;
    font-family: inherit;
    outline: none;
    background: #fafbfd;
  }
  .wecom-text:focus { border-color: var(--primary); }
  .wecom-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 12px;
    flex-wrap: wrap;
  }
  .wecom-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-2);
    cursor: pointer;
    user-select: none;
  }
  .wecom-master {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    cursor: pointer;
  }
  .wecom-schedule-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 46vh;
    overflow-y: auto;
    margin-bottom: 4px;
  }
  .wecom-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    background: #fafbfd;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .wecom-card-top {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .wecom-card-top input[type="text"] {
    flex: 1;
    font-weight: 600;
  }
  .wecom-card-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
  }
  .wecom-card-row label { font-size: 12px; color: var(--text-3); }
  .wecom-card-row input[type="time"] {
    border: 1px solid #d9dce3;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 13px;
    font-family: inherit;
  }
  .wecom-select {
    border: 1px solid #d9dce3;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 13px;
    font-family: inherit;
    background: #fff;
    color: var(--text);
    outline: none;
  }
  .wecom-select:focus { border-color: var(--primary); }
  .wecom-days {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
  }
  .wecom-day {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: #fff;
    font-size: 12px;
    color: var(--text-2);
    cursor: pointer;
    user-select: none;
  }
  .wecom-day input { display: none; }
  .wecom-day.on {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    font-weight: 600;
  }
  .wecom-card textarea {
    width: 100%;
    min-height: 72px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13px;
    line-height: 1.6;
    resize: vertical;
    font-family: inherit;
    outline: none;
  }
  .wecom-hint {
    font-size: 12px;
    color: var(--text-3);
    margin-top: 10px;
  }
  .schedule-import-modal {
    width: min(920px, 96vw);
    max-height: 88vh;
    overflow: hidden;
  }
  .schedule-import-body {
    display: flex;
    gap: 14px;
    align-items: stretch;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
  }
  .schedule-import-main {
    flex: 1 1 0;
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    padding-right: 2px;
  }
  .schedule-import-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
  }
  .schedule-import-actions button {
    padding: 10px 18px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 10px;
    min-height: 42px;
  }
  .schedule-import-preview {
    margin-top: 0;
    margin-bottom: 4px;
    line-height: 1.6;
    word-break: break-word;
  }
  .schedule-import-footer {
    flex-shrink: 0;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #eceef3;
  }
  .schedule-import-log-panel {
    flex: 0 0 280px;
    width: 280px;
    border: 1px solid #e5e8ef;
    border-radius: 10px;
    background: #0f172a;
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
  }
  .schedule-import-log-title {
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 700;
    padding: 10px 12px 6px;
    color: #94a3b8;
    border-bottom: 1px solid #1e293b;
  }
  .schedule-import-log {
    margin: 0;
    padding: 10px 12px 12px;
    font-size: 11px;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
    overflow: auto;
    flex: 1 1 auto;
    min-height: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color: #cbd5e1;
  }
  .schedule-import-image-wrap {
    margin: 0 0 12px;
    border: 1px solid #e5e8ef;
    border-radius: 10px;
    background: #f7f8fb;
    overflow: hidden;
    text-align: center;
    padding: 8px;
  }
  .schedule-import-image-wrap.hidden { display: none; }
  .schedule-import-image-wrap canvas {
    display: block;
    max-width: 100%;
    max-height: min(280px, 36vh);
    width: auto;
    height: auto;
    margin: 0 auto;
  }
  @media (max-width: 760px) {
    .schedule-import-body { flex-direction: column; }
    .schedule-import-log-panel {
      flex: none;
      width: auto;
      max-height: 180px;
    }
  }

  @media (max-width: 640px) {
    main { padding: 12px; }
    header { padding: 10px 14px; top: 0; }
    .tabbar { padding: 6px 12px; top: 52px; }
    .actions button:not(.primary) { font-size: 12px; padding: 5px 9px; }
    .cell.active-week { min-height: 96px; }
    .cell { min-height: 56px; }
  }
