/* ==========================================================================
     1. 设计变量 —— 所有配色集中在这里，切换主题只换变量
     ========================================================================== */
  :root {
    --ui-font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
    --text-font: var(--ui-font);
    --text-size: 16px;

    --radius-lg: 8px;
    --radius-md: 6px;
    --radius-sm: 4px;

    --ease: cubic-bezier(.22, .61, .36, 1);
  }

  :root,
  :root[data-theme="light"] {
    --bg: #f7f4ef;
    --bg-soft: #efeae2;
    --panel: #ffffff;
    --panel-soft: #faf8f4;
    --ink: #23201c;
    --ink-soft: #5e584f;
    --muted: #8f887d;
    --faint: #b9b1a5;
    --line: #e7e1d8;
    --line-strong: #d8cfc2;
    --accent: #00a2b8;
    --accent-hover: #008a9e;
    --accent-soft: #e0f4f7;
    --accent-ink: #ffffff;
    --diary-soft: #e9eff5;
    --diary-ink: #4a6d8c;
    --danger: #b9563f;
    --danger-soft: #fbeeec;
    --overlay: rgba(38, 32, 26, .38);
    --hero: rgba(0, 162, 184, .06);
    --shadow-1: 0 1px 2px rgba(35, 28, 20, .05);
    --shadow-2: 0 1px 2px rgba(35, 28, 20, .04), 0 10px 30px rgba(35, 28, 20, .05);
    --shadow-3: 0 2px 4px rgba(35, 28, 20, .05), 0 18px 46px rgba(35, 28, 20, .1);
    color-scheme: light;
  }

  :root[data-theme="dark"] {
    --bg: #181716;
    --bg-soft: #211f1d;
    --panel: #222020;
    --panel-soft: #272423;
    --ink: #ece7df;
    --ink-soft: #b6ada2;
    --muted: #8b8377;
    --faint: #6b645b;
    --line: #322e2b;
    --line-strong: #423c37;
    --accent: #00a2b8;
    --accent-hover: #1cb9cd;
    --accent-soft: rgba(0, 162, 184, .18);
    --accent-ink: #04252a;
    --diary-soft: rgba(120, 160, 200, .16);
    --diary-ink: #9dc0dd;
    --danger: #e0806a;
    --danger-soft: rgba(224, 128, 106, .14);
    --overlay: rgba(0, 0, 0, .58);
    --hero: rgba(0, 162, 184, .08);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow-2: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
    --shadow-3: 0 2px 4px rgba(0, 0, 0, .4), 0 18px 46px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }

  :root[data-theme="sepia"] {
    --bg: #f2e9da;
    --bg-soft: #eae0cd;
    --panel: #fbf5e9;
    --panel-soft: #f8f2e5;
    --ink: #3c3226;
    --ink-soft: #6a5c49;
    --muted: #94856f;
    --faint: #b8a992;
    --line: #e2d6c0;
    --line-strong: #d2c2a6;
    --accent: #96703c;
    --accent-hover: #7f5d2f;
    --accent-soft: #efe1c8;
    --accent-ink: #fffaf0;
    --diary-soft: #e2e8e0;
    --diary-ink: #5d7159;
    --danger: #a3553f;
    --danger-soft: #f6e6dd;
    --overlay: rgba(60, 50, 38, .38);
    --hero: rgba(150, 112, 60, .06);
    --shadow-1: 0 1px 2px rgba(60, 50, 38, .05);
    --shadow-2: 0 1px 2px rgba(60, 50, 38, .04), 0 10px 30px rgba(60, 50, 38, .06);
    --shadow-3: 0 2px 4px rgba(60, 50, 38, .06), 0 18px 46px rgba(60, 50, 38, .11);
    color-scheme: light;
  }

  :root[data-theme="moss"] {
    --bg: #eef1e9;
    --bg-soft: #e5eadf;
    --panel: #fbfcfa;
    --panel-soft: #f5f8f2;
    --ink: #232a24;
    --ink-soft: #4f5c50;
    --muted: #7d8a7d;
    --faint: #a9b5a7;
    --line: #dde5d9;
    --line-strong: #cbd6c6;
    --accent: #4f7a52;
    --accent-hover: #426645;
    --accent-soft: #e4eee2;
    --accent-ink: #ffffff;
    --diary-soft: #e6ecf2;
    --diary-ink: #4d6b86;
    --danger: #a95a45;
    --danger-soft: #f6e9e4;
    --overlay: rgba(35, 42, 36, .38);
    --hero: rgba(79, 122, 82, .06);
    --shadow-1: 0 1px 2px rgba(35, 42, 36, .05);
    --shadow-2: 0 1px 2px rgba(35, 42, 36, .04), 0 10px 30px rgba(35, 42, 36, .05);
    --shadow-3: 0 2px 4px rgba(35, 42, 36, .06), 0 18px 46px rgba(35, 42, 36, .1);
    color-scheme: light;
  }

  /* ==========================================================================
     2. 基础
     ========================================================================== */
  * { box-sizing: border-box; }
  [hidden] { display: none !important; }
  html { -webkit-text-size-adjust: 100%; }

  body {
    margin: 0;
    padding: 44px 20px 140px;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--ui-font);
    font-size: 15px;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    /* 首屏不加颜色过渡：theme.js 已经在渲染前定好颜色，
       若这里也有 transition，浏览器仍会把第一帧当作变化而"闪"一下。
       等首屏稳定后 theme.js 给 <html> 加 .fx，切换主题才有平滑过渡。 */
  }

  html.fx body {
    transition: background-color .25s var(--ease), color .25s var(--ease);
  }

  body::before {
    content: "";
    position: fixed;
    inset: 0 0 auto 0;
    height: 220px;
    background: linear-gradient(180deg, var(--hero), transparent);
    pointer-events: none;
    z-index: 0;
  }

  ::selection { background: var(--accent-soft); color: var(--ink); }

  :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

  .wrap { max-width: 720px; margin: 0 auto; position: relative; z-index: 1; }

  /* 滚动条（深色下不至于刺眼） */
  .editor::-webkit-scrollbar, .sheet-body::-webkit-scrollbar { width: 8px; }
  .editor::-webkit-scrollbar-thumb, .sheet-body::-webkit-scrollbar-thumb {
    background: var(--line-strong); border-radius: 4px;
  }
  .editor::-webkit-scrollbar-track, .sheet-body::-webkit-scrollbar-track { background: transparent; }

  /* ==========================================================================
     3. 通用组件
     ========================================================================== */

  /* ---- 按钮 ---- */
  .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--ink-soft);
    font-family: inherit; font-size: 13px; line-height: 1;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color .16s, color .16s, border-color .16s, transform .08s;
    white-space: nowrap;
    user-select: none;
  }
  .btn:hover { background: var(--bg-soft); color: var(--ink); }
  .btn:active { transform: translateY(.5px); }
  .btn:disabled { opacity: .55; cursor: default; transform: none; }

  .btn.primary {
    background: var(--accent); color: var(--accent-ink);
    box-shadow: 0 2px 8px -2px color-mix(in srgb, var(--accent) 55%, transparent);
  }
  .btn.primary:hover { background: var(--accent-hover); color: var(--accent-ink); }

  .btn.outline { border-color: var(--line-strong); color: var(--ink-soft); }
  .btn.outline:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

  .btn.soft { background: var(--bg-soft); color: var(--ink-soft); }

  .btn.danger { color: var(--danger); }
  .btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

  .btn.sm { padding: 7px 12px; font-size: 12.5px; }

  .icon-btn {
    display: grid; place-items: center;
    width: 32px; height: 32px;
    border: 0; border-radius: var(--radius-sm);
    background: transparent; color: var(--muted);
    cursor: pointer;
    transition: background-color .15s, color .15s;
  }
  .icon-btn:hover { background: var(--panel); color: var(--ink); }
  .icon-btn svg { width: 16px; height: 16px; }
  html[data-mode="dark"] .icon-moon { display: none; }
  html:not([data-mode="dark"]) .icon-sun { display: none; }

  /* ---- 输入 ---- */
  .input, .select {
    width: 100%;
    font-family: inherit; font-size: 13px;
    color: var(--ink);
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 9px 11px;
    outline: 0;
    transition: border-color .16s, background-color .16s;
  }
  .input:focus, .select:focus { border-color: var(--accent); background: var(--panel); }
  .input[readonly] { color: var(--muted); font-family: var(--mono, ui-monospace, monospace); font-size: 12px; }
  .select {
    appearance: none;
    padding-right: 30px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23948d82' stroke-width='2' stroke-linecap='round'><path d='M6 9l6 6 6-6'/></svg>");
    background-repeat: no-repeat;
    background-position: right 9px center;
    background-size: 14px;
    cursor: pointer;
  }

  /* ---- 分段控件 ---- */
  .segmented {
    display: inline-flex; gap: 2px;
    background: var(--bg-soft);
    border-radius: 5px;
    padding: 3px;
  }
  .seg-btn {
    border: 0; background: transparent;
    font-family: inherit; font-size: 13px;
    color: var(--muted);
    padding: 5px 13px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color .18s, color .18s, box-shadow .18s;
    white-space: nowrap;
  }
  .seg-btn:hover { color: var(--ink-soft); }
  .seg-btn.active {
    background: var(--panel);
    color: var(--ink);
    font-weight: 500;
    box-shadow: var(--shadow-1);
  }

  /* ---- 标签 ---- */
  .chip {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 10.5px; line-height: 1.7;
    padding: 1px 7px;
    border-radius: 4px;
    background: var(--bg-soft);
    color: var(--muted);
    white-space: nowrap;
  }
  .chip.quick { background: var(--accent-soft); color: var(--accent); }
  .chip.diary { background: var(--diary-soft); color: var(--diary-ink); }
  .chip.tag { background: var(--bg-soft); color: var(--ink-soft); }
  .chip.tag::before { content: "#"; opacity: .55; }

  /* ---- 卡片 ---- */
  .card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-2);
    transition: background-color .25s var(--ease), border-color .25s var(--ease);
  }

  /* ---- 弹层：全站统一这一套结构 ---- */
  dialog:not([open]) { display: none; }   /* 覆盖下面的 flex，否则未打开的弹层也会显示 */

  .sheet {
    border: 0; padding: 0;
    width: min(640px, calc(100vw - 32px));
    max-height: min(86vh, 860px);
    background: var(--panel);
    color: var(--ink);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-3);
    overflow: hidden;
    display: flex; flex-direction: column;
  }
  .sheet.narrow { width: min(420px, calc(100vw - 32px)); }
  .sheet::backdrop { background: var(--overlay); backdrop-filter: blur(3px); }
  .sheet[open] { animation: sheet-in .2s var(--ease); }
  @keyframes sheet-in {
    from { opacity: 0; transform: translateY(10px) scale(.99); }
    to { opacity: 1; transform: none; }
  }

  .sheet-head {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--line);
    flex: none;
  }
  .sheet-head-main { flex: 1; min-width: 0; }
  .sheet-eyebrow {
    display: flex; align-items: center; gap: 8px;
    font-size: 11.5px; color: var(--muted);
    margin-bottom: 6px;
  }
  .sheet-title {
    margin: 0;
    font-size: 17px; font-weight: 600; line-height: 1.5;
    word-break: break-word;
  }

  .sheet-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
  }
  .sheet-foot {
    display: flex; align-items: center; gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid var(--line);
    background: var(--panel-soft);
    flex: none;
  }
  .sheet-foot .spacer { flex: 1; }

  .sheet-close {
    flex: none;
    display: grid; place-items: center;
    width: 30px; height: 30px;
    border: 0; border-radius: 4px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: background-color .15s, color .15s;
  }
  .sheet-close:hover { background: var(--bg-soft); color: var(--ink); }
  .sheet-close svg { width: 14px; height: 14px; }

  /* ---- 设置分块 ---- */
  .block { padding: 18px 0; border-bottom: 1px solid var(--line); }
  .block:first-child { padding-top: 0; }
  .block:last-child { border-bottom: 0; padding-bottom: 0; }
  .block-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
  .block-title { font-size: 13px; font-weight: 600; letter-spacing: .02em; }
  .block-desc { font-size: 11.5px; color: var(--faint); }
  .block-body { display: flex; flex-direction: column; gap: 14px; }

  .field { display: flex; flex-direction: column; gap: 6px; }
  .field-label { font-size: 12px; color: var(--muted); }
  .field-row { display: flex; align-items: flex-end; gap: 8px; }
  .field-row .input { flex: 1; }
  .field-hint { font-size: 11.5px; color: var(--faint); line-height: 1.7; }

  .field-hint code, .confirm-text code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 11px;
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 1px 5px;
    color: var(--ink-soft);
  }

  kbd {
    display: inline-block;
    font-family: inherit;
    font-size: 11px;
    line-height: 1.5;
    background: var(--panel);
    border: 1px solid var(--line-strong);
    border-bottom-width: 2px;
    border-radius: 3px;
    padding: 0 5px;
    color: var(--muted);
  }

  /* ---- 主题色卡 ---- */
  .theme-grid { display: flex; gap: 8px; flex-wrap: wrap; }
  .swatch {
    width: 76px;
    padding: 5px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--panel);
    cursor: pointer;
    transition: border-color .16s, box-shadow .16s;
  }
  .swatch:hover { border-color: var(--line-strong); }
  .swatch.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
  .swatch-preview {
    height: 32px; border-radius: 3px;
    display: flex; overflow: hidden;
    border: 1px solid rgba(0, 0, 0, .06);
    margin-bottom: 5px;
  }
  .swatch-preview i { flex: 1; }
  .swatch-preview i:last-child { flex: 0 0 9px; }
  .swatch-name { font-size: 11px; color: var(--muted); text-align: center; }
  .swatch.active .swatch-name { color: var(--accent); font-weight: 500; }

  /* ---- 字号滑块 ---- */
  .range-row { display: flex; align-items: center; gap: 12px; }
  input[type="range"] {
    flex: 1; height: 3px; appearance: none;
    background: var(--line-strong); border-radius: 2px; outline: 0;
  }
  input[type="range"]::-webkit-slider-thumb {
    appearance: none; width: 15px; height: 15px; border-radius: 50%;
    background: var(--accent); border: 2px solid var(--panel);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .2); cursor: pointer;
  }
  .range-value { font-size: 12px; color: var(--muted); min-width: 42px; text-align: right; font-variant-numeric: tabular-nums; }

  /* ---- 提示气泡 ---- */
  .toast {
    position: fixed; left: 50%; bottom: 34px;
    transform: translate(-50%, 14px);
    background: var(--ink); color: var(--bg);
    font-size: 13px;
    padding: 9px 18px;
    border-radius: 5px;
    box-shadow: var(--shadow-3);
    opacity: 0; pointer-events: none;
    transition: opacity .24s, transform .24s;
    z-index: 100;
    max-width: 86vw; text-align: center;
  }

  /* toast 用 popover 放进浏览器顶层，否则会被同样在顶层的 dialog 盖住。
     popover 自带 inset:0 / margin:auto 等默认样式，这里要清掉。 */
  .toast[popover] {
    inset: auto;
    left: 50%;
    bottom: 34px;
    margin: 0;
    border: 0;
    overflow: visible;
  }
  .toast.show { opacity: 1; transform: translate(-50%, 0); }
  .toast.error { background: var(--danger); color: #fff; }

  /* ---- 右键菜单 ---- */
  .ctx-menu {
    position: fixed;
    z-index: 120;
    min-width: 150px;
    padding: 4px;
    background: var(--panel);
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    box-shadow: var(--shadow-3);
  }
  .ctx-item {
    display: flex; align-items: center; gap: 8px;
    width: 100%;
    border: 0; border-radius: 4px;
    background: transparent;
    font-family: inherit; font-size: 12.5px;
    color: var(--ink-soft);
    text-align: left;
    padding: 7px 10px;
    cursor: pointer;
    transition: background-color .13s, color .13s;
  }
  .ctx-item:hover { background: var(--bg-soft); color: var(--ink); }
  .ctx-item svg { width: 13px; height: 13px; flex: none; color: var(--muted); }
  .ctx-sep { height: 1px; background: var(--line); margin: 3px 6px; }
  .ctx-menu.no-zoom .ctx-item[data-act^="zoom"],
  .ctx-menu.no-zoom .ctx-sep { display: none; }

  /* ---- 自定义配色 ---- */
  .custom-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
  .color-field {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: 12px; color: var(--muted);
    cursor: pointer;
  }
  .color-field input[type="color"] {
    width: 36px; height: 26px;
    padding: 0;
    border: 1px solid var(--line-strong);
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
  }
  .color-field input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
  .color-field input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 2px; }
  .color-field input[type="color"]::-moz-color-swatch { border: 0; border-radius: 2px; }

  /* ==========================================================================
     4. 页面区块
     ========================================================================== */
  header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 26px; padding: 0 4px;
  }
  .brand { display: flex; align-items: center; gap: 10px; }
  .logo {
    width: 28px; height: 28px;
    border-radius: 4px;
    background: var(--accent); color: var(--accent-ink);
    display: grid; place-items: center;
    font-size: 14px; font-weight: 600;
    box-shadow: 0 2px 8px -2px color-mix(in srgb, var(--accent) 60%, transparent);
    user-select: none;
  }
  .brand-name { font-size: 15px; font-weight: 600; letter-spacing: .03em; }
  .header-right { display: flex; align-items: center; gap: 4px; }

  .status {
    display: inline-flex; align-items: center; gap: 7px;
    font-size: 12px; color: var(--muted);
    padding: 5px 10px; border-radius: 4px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color .18s, border-color .18s;
    white-space: nowrap;
  }
  .status:hover { background: var(--panel); border-color: var(--line); }
  .status .dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--faint);
    transition: background-color .25s, box-shadow .25s;
  }
  .status.connected .dot { background: #5f9d72; box-shadow: 0 0 0 3px rgba(95, 157, 114, .16); }
  .status.offline .dot { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }

  /* ---- 欢迎语 ---- */
  .greet {
    display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
    margin-bottom: 14px; padding: 0 4px;
  }
  .greet-name { font-size: 17px; font-weight: 600; letter-spacing: .02em; }
  .greet-name em { font-style: normal; color: var(--accent); }
  .greet-date { font-size: 12px; color: var(--faint); letter-spacing: .02em; }

  .icon-btn.txt { font-size: 12px; font-weight: 600; letter-spacing: .02em; }
  .icon-btn.txt.active { background: var(--accent-soft); color: var(--accent); }

  /* ---- 编辑弹层里的输入区 ---- */
  #editDialog .sheet-body { padding: 16px 18px 18px; }
  #editDialog .composer { padding: 0; border: 0; box-shadow: none; }
  #editDialog .composer.is-focus { box-shadow: none; border-color: transparent; }
  #editDialog .composer-head { margin-bottom: 10px; }
  #editDialog .editor { min-height: 150px; max-height: 46vh; }

  /* ---- 输入区 ---- */
  .composer { padding: 16px 20px 12px; }
  .composer.is-focus { border-color: var(--line-strong); box-shadow: var(--shadow-3); }

  .composer-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; margin-bottom: 4px;
  }
  .composer-date { font-size: 12px; color: var(--faint); letter-spacing: .02em; }

  .title-input {
    width: 100%; border: 0; outline: 0;
    background: transparent;
    font-family: var(--text-font);
    font-size: 20px; font-weight: 600;
    color: inherit;
    padding: 12px 0 0;
    line-height: 1.4;
  }
  .title-input::placeholder { color: var(--faint); font-weight: 500; }

  .editor {
    min-height: 128px;
    max-height: 58vh;
    overflow-y: auto;
    outline: 0;
    padding: 10px 0 4px;
    font-family: var(--text-font);
    font-size: var(--text-size);
    line-height: 1.8;
    word-break: break-word;
    caret-color: var(--accent);
  }
  .editor:empty::before {
    content: attr(data-placeholder);
    color: var(--faint);
    pointer-events: none;
  }
  .editor p { margin: 0 0 .55em; }
  .editor h2 { font-size: 1.12em; margin: .7em 0 .35em; line-height: 1.5; }
  .editor h3 { font-size: 1em; margin: .7em 0 .35em; }
  .editor blockquote {
    margin: .6em 0; padding: 2px 0 2px 14px;
    border-left: 3px solid var(--line-strong);
    color: var(--ink-soft);
  }
  .editor pre {
    background: var(--bg-soft);
    border: 1px solid var(--line);
    padding: 10px 13px; border-radius: 4px;
    font-family: var(--mono, ui-monospace, monospace);
    font-size: .86em; line-height: 1.65;
    overflow-x: auto; white-space: pre-wrap; margin: .6em 0;
  }
  .editor ul, .editor ol { padding-left: 24px; margin: .4em 0; }
  .editor li { margin: .15em 0; }
  .editor a { color: var(--accent); text-underline-offset: 2px; }
  .editor hr { border: 0; border-top: 1px solid var(--line); margin: 1em 0; }

  .editor img, .reader-content img {
    max-width: 100%;
    height: auto;
    border-radius: 5px;
    display: block;
    margin: 10px 0;
    border: 1px solid var(--line);
  }

  /* ---- 标签行 ---- */
  .tag-row {
    display: flex; align-items: center; flex-wrap: wrap; gap: 5px;
    padding: 8px 0 2px;
    min-height: 30px;
  }
  .tag-row-icon { color: var(--faint); display: grid; place-items: center; width: 18px; flex: none; }
  .tag-row-icon svg { width: 12px; height: 12px; }
  .tag-chip {
    display: inline-flex; align-items: center; gap: 3px;
    font-size: 11px; line-height: 1.7;
    padding: 1px 4px 1px 8px;
    border-radius: 4px;
    background: var(--accent-soft); color: var(--accent);
  }
  .tag-chip-x {
    border: 0; background: transparent; color: inherit;
    width: 14px; height: 14px; padding: 0;
    display: grid; place-items: center;
    cursor: pointer; opacity: .6; border-radius: 50%;
    font-size: 12px; line-height: 1; font-family: inherit;
  }
  .tag-chip-x:hover { opacity: 1; background: rgba(0, 0, 0, .06); }
  .tag-input {
    flex: 1; min-width: 90px;
    border: 0; outline: 0; background: transparent;
    font-family: inherit; font-size: 12px;
    color: var(--ink);
    padding: 3px 0;
  }
  .tag-input::placeholder { color: var(--faint); }

  /* ---- 工具栏 ---- */
  .toolbar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 2px;
    padding-top: 10px; margin-top: 6px;
    border-top: 1px dashed var(--line);
  }
  .tool {
    min-width: 28px; height: 28px;
    padding: 0 7px;
    border: 0; border-radius: 3px;
    background: transparent;
    color: var(--ink-soft);
    font-family: inherit; font-size: 13px;
    display: inline-grid; place-items: center;
    cursor: pointer;
    transition: background-color .14s, color .14s;
    line-height: 1;
  }
  .tool:hover { background: var(--bg-soft); color: var(--ink); }
  .tool.active { background: var(--accent-soft); color: var(--accent); }
  .tool svg { width: 14px; height: 14px; }
  .tool[data-cmd="bold"] { font-weight: 700; }
  .tool[data-cmd="italic"] { font-style: italic; font-family: Georgia, serif; }
  .tool[data-cmd="underline"] { text-decoration: underline; text-underline-offset: 2px; }
  .tool[data-cmd="strikeThrough"] { text-decoration: line-through; }
  .sep { width: 1px; height: 14px; background: var(--line); margin: 0 5px; flex: none; }
  .toolbar .spacer { flex: 1; }

  .composer-foot {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; padding-top: 10px;
  }
  .meta { font-size: 12px; color: var(--faint); letter-spacing: .02em; }
  .meta .editing { color: var(--accent); }
  .actions { display: flex; align-items: center; gap: 4px; }

  /* ---- 时间线 ---- */
  .feed { margin-top: 40px; }
  .feed-head {
    display: flex; align-items: center; gap: 10px;
    padding: 0 2px; margin-bottom: 12px;
  }
  .feed-title { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .12em; }
  .feed-head .spacer { flex: 1; }

  .search {
    display: flex; align-items: center; gap: 5px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 5px 9px;
    transition: border-color .18s;
  }
  .search:focus-within { border-color: var(--line-strong); }
  .search svg { width: 13px; height: 13px; color: var(--faint); flex: none; }
  .search input {
    border: 0; outline: 0; background: transparent;
    font-family: inherit; font-size: 12.5px; color: inherit;
    width: 108px;
  }
  .search input::placeholder { color: var(--faint); }

  .tag-bar {
    display: flex; gap: 5px; flex-wrap: wrap;
    padding: 0 2px 4px;
    margin-bottom: 6px;
  }
  .tag-filter {
    border: 1px solid transparent;
    background: var(--panel);
    color: var(--muted);
    font-family: inherit; font-size: 11.5px;
    padding: 3px 9px; border-radius: 4px;
    cursor: pointer;
    transition: .15s;
  }
  .tag-filter:hover { color: var(--ink); border-color: var(--line); }
  .tag-filter.active {
    background: var(--accent-soft); color: var(--accent);
    border-color: color-mix(in srgb, var(--accent) 30%, transparent);
  }

  .day-label {
    display: flex; align-items: center; gap: 10px;
    font-size: 11.5px; color: var(--faint);
    margin: 20px 2px 9px; letter-spacing: .04em;
  }
  .day-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }

  .entry {
    position: relative;
    display: block;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 12px 15px 13px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: border-color .16s, box-shadow .16s, transform .16s;
  }
  .entry:hover {
    border-color: var(--line-strong);
    box-shadow: var(--shadow-2);
    transform: translateY(-1px);
  }
  .entry.is-active { border-color: color-mix(in srgb, var(--accent) 45%, transparent); box-shadow: 0 0 0 3px var(--accent-soft); }

  .entry-top { display: flex; align-items: center; gap: 7px; margin-bottom: 4px; flex-wrap: wrap; }
  .entry-time { font-size: 11px; color: var(--faint); }

  .entry-title {
    font-size: 14px; font-weight: 600;
    margin: 1px 0 3px;
    line-height: 1.55;
    padding-right: 26px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-family: var(--text-font);
  }
  .entry-text {
    font-size: 13.5px;
    font-family: var(--text-font);
    color: var(--ink-soft);
    line-height: 1.68;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    padding-right: 22px;
    word-break: break-word;
  }
  .entry-media {
    display: grid;
    gap: 4px;
    margin-top: 8px;
    grid-template-columns: repeat(3, 76px);
  }
  .entry-media[data-n="1"] { grid-template-columns: 132px; }
  .entry-media[data-n="2"],
  .entry-media[data-n="4"] { grid-template-columns: repeat(2, 76px); }
  .entry-media img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    display: block;
    border-radius: 2px;
    border: 1px solid var(--line);
    background: var(--bg-soft);
  }
  .entry-media[data-n="1"] img { border-radius: 3px; }

  .entry-del {
    position: absolute; top: 9px; right: 9px;
    width: 24px; height: 24px;
    display: grid; place-items: center;
    border: 0; border-radius: 3px;
    background: transparent; color: var(--faint);
    cursor: pointer; opacity: 0;
    transition: opacity .15s, background-color .15s, color .15s;
  }
  .entry:hover .entry-del { opacity: 1; }
  .entry-del:hover { background: var(--danger-soft); color: var(--danger); }
  .entry-del svg { width: 13px; height: 13px; }

  .empty {
    text-align: center; padding: 46px 20px;
    color: var(--faint); font-size: 13.5px; line-height: 1.9;
  }
  .empty strong { display: block; color: var(--ink-soft); font-size: 14px; font-weight: 500; margin-bottom: 4px; }
  .empty code {
    font-family: var(--mono, ui-monospace, monospace); font-size: 12px;
    background: var(--panel); border: 1px solid var(--line);
    border-radius: 3px; padding: 1.5px 6px; color: var(--ink-soft);
  }

  /* ---- 阅读弹层 ---- */
  .reader-content {
    font-family: var(--text-font);
    font-size: var(--text-size);
    line-height: 1.85;
    color: var(--ink);
    word-break: break-word;
  }
  .reader-content p { margin: 0 0 .7em; }
  .reader-content h2 { font-size: 1.15em; margin: 1em 0 .4em; }
  .reader-content blockquote {
    margin: .8em 0; padding: 2px 0 2px 14px;
    border-left: 3px solid var(--line-strong); color: var(--ink-soft);
  }
  .reader-content pre {
    background: var(--bg-soft); border: 1px solid var(--line);
    padding: 12px 14px; border-radius: 4px;
    font-family: var(--mono, ui-monospace, monospace);
    font-size: .86em; overflow-x: auto; white-space: pre-wrap;
  }
  .reader-content ul, .reader-content ol { padding-left: 24px; }
  .reader-content a { color: var(--accent); }
  .reader-content hr { border: 0; border-top: 1px solid var(--line); margin: 1.2em 0; }

  .reader-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }

  /* ---- 确认弹层 ---- */
  .confirm-text { font-size: 13.5px; color: var(--ink-soft); line-height: 1.8; margin: 0; }

  /* ---- 拖拽上传遮罩 ---- */
  .drop-mask {
    position: absolute; inset: 0;
    border-radius: var(--radius-lg);
    background: var(--accent-soft);
    border: 2px dashed var(--accent);
    display: none; place-items: center;
    color: var(--accent); font-size: 13px; font-weight: 500;
    z-index: 5;
    pointer-events: none;
  }
  .composer { position: relative; }
  .composer.dragging .drop-mask { display: grid; }

  /* ---- 高级设置折叠 ---- */
  .adv-block {
    margin-top: 18px;
    border-top: 1px solid var(--line);
  }
  .adv-block > summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 0 5px;
    user-select: none;
  }
  .adv-block > summary::-webkit-details-marker { display: none; }
  .adv-block > summary::before {
    content: "";
    width: 0; height: 0;
    border-left: 5px solid var(--faint);
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    transition: transform .18s var(--ease);
    flex: none;
  }
  .adv-block[open] > summary::before { transform: rotate(90deg); }
  .adv-block > summary:hover .adv-title { color: var(--accent); }
  .adv-title { font-size: 13px; font-weight: 600; transition: color .15s; }
  .adv-desc { font-size: 11.5px; color: var(--faint); }
  .adv-block .block:first-of-type { padding-top: 14px; }

  .btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

  .check-row {
    display: flex; align-items: center; gap: 8px;
    font-size: 12.5px; color: var(--ink-soft);
    cursor: pointer; user-select: none;
    margin-top: 2px;
  }
  .check-row input { width: 14px; height: 14px; accent-color: var(--accent); margin: 0; }

  .greet-edit {
    border: 0; background: transparent;
    color: var(--faint); cursor: pointer;
    padding: 2px; margin-left: 6px;
    border-radius: 3px;
    vertical-align: -2px;
    transition: background-color .15s, color .15s;
  }
  .greet-edit:hover { color: var(--accent); background: var(--accent-soft); }
  .greet-edit svg { width: 13px; height: 13px; display: block; }

  /* ---- 分享弹层 ---- */
  .share-meta { font-size: 11.5px; color: var(--faint); line-height: 1.7; margin-bottom: 14px; }
  .share-opts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
  .share-opt {
    display: flex; align-items: center; gap: 12px;
    text-align: left; padding: 13px 14px;
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: border-color .15s, background-color .15s;
  }
  .share-opt:hover { border-color: var(--accent); background: var(--accent-soft); }
  .share-opt:disabled { opacity: .55; cursor: default; }
  .share-opt-icon { flex: none; width: 32px; height: 32px; display: grid; place-items: center; color: var(--accent); }
  .share-opt-icon svg { width: 19px; height: 19px; }
  .share-opt-title { font-size: 13.5px; font-weight: 500; color: var(--ink); }
  .share-opt-desc { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

  .ctx-title { font-size: 11px; color: var(--faint); padding: 6px 12px 4px; }

  /* ==========================================================================
     5. 响应式
     ========================================================================== */
  @media (max-width: 640px) {
    body { padding: 24px 14px 120px; }
    .composer { padding: 14px 15px 10px; }
    .card { border-radius: 7px; }
    .composer-date { display: none; }
    .search input { width: 74px; }
    .feed-title { display: none; }
    .toolbar .spacer { display: none; }
    .sheet { width: calc(100vw - 20px); max-height: 90vh; }
    .sheet-body { padding: 16px; }
    .sheet-head { padding: 16px 16px 12px; }
    .sheet-foot { padding: 12px 16px; }

    /* 手机上所有圆角一律改直角 */
    *,
    *::before,
    *::after {
      border-radius: 0 !important;
    }
  }

  /* ==========================================================================
     6. 页脚 —— 首页 / 登录页 / 引导页共用
     ========================================================================== */
  .page-foot {
    margin-top: 26px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    font-size: 11.5px;
    line-height: 1.7;
    color: var(--faint);
    text-align: center;
  }

  .page-foot a {
    color: var(--muted);
    text-decoration: none;
  }

  .page-foot a:hover {
    color: var(--accent);
    text-decoration: underline;
  }

  @media (max-width: 640px) {
    .page-foot { margin-top: 20px; }
  }

  /* ==========================================================================
     7. 弹层滚动锁 —— dialog 打开时禁止背后页面滚动
     ========================================================================== */
  html.is-modal,
  html.is-modal body {
    overflow: hidden;
    overscroll-behavior: none;
  }

  /* 补掉被隐藏的滚动条宽度，避免弹层出现时页面横向抖动 */
  html.is-modal { padding-right: var(--sbw, 0px); }
