/* ============================================================
   个人笔记本 — Apple 风格
   纯白 / 深色 双主题，移动 / 平板 / 桌面自适应
   ============================================================ */

:root {
  --bg: #ffffff;
  --bg-elevated: #ffffff;
  --sidebar: #f5f5f7;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #98989d;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.16);
  --danger: #ff3b30;
  --success: #34c759;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.06);
  --radius: 12px;
  --radius-lg: 18px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
          "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #000000;
  --bg-elevated: #1c1c1e;
  --sidebar: #1c1c1e;
  --text: #f5f5f7;
  --text-2: #98989d;
  --text-3: #6d6d72;
  --accent: #0a84ff;
  --accent-hover: #409cff;
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.2);
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; }

/* ---------- 顶部条 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
}
.topbar .title { font-weight: 600; font-size: 16px; }
.topbar .spacer { flex: 1; }

/* ---------- 按钮 ---------- */
.btn {
  appearance: none; border: none; cursor: pointer;
  background: var(--accent); color: #fff;
  padding: 8px 16px; border-radius: 980px;
  font-size: 14px; font-weight: 500;
  transition: opacity .15s, transform .1s;
}
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: scale(.97); }
.btn.ghost {
  background: transparent; color: var(--accent);
}
.btn.ghost:hover { background: rgba(0,113,227,.08); }
[data-theme="dark"] .btn.ghost:hover { background: rgba(10,132,255,.15); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 5px 12px; font-size: 13px; }
.iconbtn {
  appearance: none; border: none; cursor: pointer;
  width: 34px; height: 34px; border-radius: 50%;
  background: transparent; color: var(--text-2);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 17px; transition: background .15s;
}
.iconbtn:hover { background: var(--border); color: var(--text); }

/* ---------- 布局 ---------- */
.shell { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: 280px; flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.nav { padding: 16px 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 8px;
  color: var(--text); cursor: pointer; font-size: 14px;
}
.nav-item:hover { background: var(--border); }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-item .ico { width: 18px; text-align: center; }

.search {
  margin: 8px 12px; padding: 7px 12px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; font-size: 13px; color: var(--text);
  outline: none;
}
.search:focus { border-color: var(--accent); }

.notelist { flex: 1; overflow-y: auto; padding: 4px 8px 16px; }
.note-item {
  padding: 10px 12px; border-radius: 10px; cursor: pointer;
  margin-bottom: 2px; border: 1px solid transparent;
}
.note-item:hover { background: var(--border); }
.note-item.active {
  background: var(--bg); border-color: var(--border);
  box-shadow: var(--shadow);
}
.note-item .t { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-item .p { font-size: 12px; color: var(--text-2); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-item .meta { font-size: 11px; color: var(--text-3); margin-top: 3px; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }

/* ---------- 编辑器 ---------- */
.editor-wrap { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.editor-title {
  border: none; outline: none; background: transparent;
  font-size: 26px; font-weight: 700; color: var(--text);
  padding: 24px 32px 8px; width: 100%;
  font-family: inherit;
}
.editor-meta { padding: 0 32px; font-size: 12px; color: var(--text-3); display: flex; gap: 12px; align-items: center; }
.toolbar {
  display: flex; gap: 4px; padding: 8px 24px; flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
}
.toolbar .tbtn {
  border: none; background: transparent; color: var(--text-2);
  width: 32px; height: 32px; border-radius: 6px; cursor: pointer;
  font-size: 14px; font-family: var(--mono);
}
.toolbar .tbtn:hover { background: var(--border); color: var(--text); }

.editor-body { flex: 1; display: flex; overflow: hidden; }
.editor-input {
  flex: 1; border: none; outline: none;
  background: transparent; color: var(--text);
  font-family: var(--font); font-size: 15px; line-height: 1.7;
  padding: 20px 32px; overflow-y: auto; min-height: 300px;
}
.editor-input:empty::before {
  content: attr(data-placeholder);
  color: var(--text-3);
}
.editor-input img { max-width: 100%; border-radius: 8px; }
.editor-input a { color: var(--accent); }

/* Markdown 排版 */
.md h1, .md h2, .md h3 { line-height: 1.3; margin: 1.2em 0 .5em; }
.md h1 { font-size: 1.8em; border-bottom: 1px solid var(--border); padding-bottom: .3em; }
.md h2 { font-size: 1.4em; }
.md h3 { font-size: 1.15em; }
.md p { margin: .6em 0; }
.md code {
  font-family: var(--mono); font-size: .9em;
  background: var(--border); padding: 2px 6px; border-radius: 5px;
}
.md pre {
  background: var(--sidebar); padding: 14px 16px; border-radius: 10px;
  overflow-x: auto; font-size: 13px;
}
.md pre code { background: transparent; padding: 0; }
.md blockquote {
  border-left: 3px solid var(--accent); margin: .8em 0;
  padding: 2px 16px; color: var(--text-2);
}
.md img { max-width: 100%; border-radius: 8px; }
.md table { border-collapse: collapse; width: 100%; }
.md th, .md td { border: 1px solid var(--border); padding: 6px 12px; }
.md hr { border: none; border-top: 1px solid var(--border); margin: 1.5em 0; }

/* 同步状态 */
.sync-dot {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--text-3);
}
.sync-dot .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); }
.sync-dot.saving .dot { background: #ff9f0a; }
.sync-dot.offline .dot { background: var(--danger); }

/* ---------- 云盘 / 剪贴板 ---------- */
.page { flex: 1; overflow-y: auto; padding: 24px 32px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.file-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; background: var(--bg-elevated);
  display: flex; flex-direction: column; gap: 6px;
}
.file-card .fname { font-size: 13px; word-break: break-all; }
.file-card .fmeta { font-size: 11px; color: var(--text-3); }
.file-card .actions { display: flex; gap: 6px; margin-top: 6px; }

.clip-list { display: flex; flex-direction: column; gap: 10px; max-width: 760px; }
.clip-input {
  font-family: var(--font); font-size: 14px;
  resize: vertical; min-height: 60px;
}
.clip-item {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; background: var(--bg-elevated);
  display: flex; gap: 10px; align-items: flex-start;
}
.clip-item.pinned { border-color: var(--accent); }
.clip-item .content { flex: 1; white-space: pre-wrap; word-break: break-all; font-size: 14px; }
.clip-item .acts { display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; }

/* ---------- 登录 ---------- */
.auth { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
body.reading { min-height: 100vh; padding: 40px 16px; }
.auth-card {
  width: 320px; padding: 32px; border-radius: var(--radius-lg);
  background: var(--bg-elevated); box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.auth-card h1 { font-size: 22px; margin: 0 0 4px; }
.auth-card p { color: var(--text-2); font-size: 13px; margin: 0 0 20px; }
.field {
  width: 100%; padding: 10px 12px; margin-bottom: 12px;
  border: 1px solid var(--border-strong); border-radius: 8px;
  font-size: 14px; background: var(--bg); color: var(--text); outline: none;
}
.field:focus { border-color: var(--accent); }
.auth-card .btn { width: 100%; padding: 10px; margin-top: 4px; }
.auth-switch { text-align: center; margin-top: 16px; font-size: 13px; color: var(--text-2); }

/* ---------- 提示条 ---------- */
.banner {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 980px; font-size: 13px;
  box-shadow: var(--shadow); z-index: 50;
  opacity: 0; transition: opacity .2s; pointer-events: none;
}
.banner.show { opacity: 1; }

.empty {
  text-align: center; color: var(--text-3); padding: 60px 20px;
}
.empty .big { font-size: 40px; margin-bottom: 10px; }

/* 抽屉遮罩（移动端） */
.scrim {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 15;
}

/* ============================================================
   响应式
   ============================================================ */

/* 平板：侧栏变抽屉 */
@media (max-width: 1024px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 30;
    transform: translateX(-100%); transition: transform .25s ease;
    box-shadow: var(--shadow);
  }
  .shell.sidebar-open .sidebar { transform: translateX(0); }
  .shell.sidebar-open .scrim { display: block; }
  .editor-title { padding: 20px 20px 6px; font-size: 22px; }
  .editor-input { padding: 16px 20px; }
  .page { padding: 20px; }
}

/* 手机：编辑框在上，实时渲染在下（图片直接可见） */
@media (max-width: 720px) {
  .topbar { padding: 10px 14px; }
  .editor-title { font-size: 20px; padding: 16px 16px 4px; }
  .editor-input { padding: 12px 16px; font-size: 15px; min-height: 400px; }
  .toolbar { padding: 6px 10px; }
  .page { padding: 16px; }
  .notelist { padding: 8px; }

  /* 手机端笔记列表（主区域） */
  .mobile-list {
    flex: 1; overflow-y: auto; padding: 10px;
    background: var(--sidebar);
  }
  .mobile-list .note-item {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    margin-bottom: 8px;
    border-radius: var(--radius);
    padding: 14px;
  }
  .mobile-list .note-item .t { font-size: 15px; }
}

/* 宽屏：编辑器限宽，阅读更舒适 */
@media (min-width: 1400px) {
  .editor-input { max-width: 900px; margin: 0 auto; width: 100%; }
  .editor-title { max-width: 900px; margin: 0 auto; width: 100%; }
  .editor-meta { max-width: 900px; margin: 0 auto; width: 100%; }
}

/* ---------- 分享弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-card {
  background: var(--bg-elevated); color: var(--text);
  border-radius: var(--radius-lg);
  padding: 22px; width: 100%; max-width: 480px;
  box-shadow: var(--shadow);
  max-height: 90vh; overflow-y: auto;
}
.modal-title { font-size: 17px; font-weight: 600; }
.visitor-list {
  max-height: 200px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 8px; padding: 8px;
}
.visitor-row {
  display: flex; gap: 10px; font-size: 12px;
  padding: 6px 4px; border-bottom: 1px solid var(--border);
  align-items: center;
}
.visitor-row:last-child { border-bottom: none; }
.visitor-row .vua { color: var(--text-3); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* （注：内容由AI生成） */
