/* ===== 云笔记 CloudNote 样式 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --primary: #e0512c;        /* 有道橙 */
  --primary-soft: #fdf0ec;
  --primary-dark: #c7421f;
  --ink: #333;
  --ink-2: #666;
  --ink-3: #999;
  --border: #e5e5e5;
  --bg: #f7f7f5;
  --card: #fff;
  --sidebar-bg: #fafaf8;
  --sidebar-w: 250px;
  --list-w: 300px;
  --topbar-h: 56px;
  --radius: 8px;
  --shadow: 0 2px 16px rgba(0,0,0,.06);
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink); background: var(--bg); font-size: 14px; overflow: hidden;
}
.hidden { display: none !important; }
input, textarea, select, button { font-family: inherit; font-size: inherit; color: inherit; outline: none; }
button { cursor: pointer; }
a { color: var(--primary); text-decoration: none; }

/* ---------- 通用按钮 ---------- */
.btn { border: none; border-radius: 6px; padding: 8px 16px; font-size: 14px; cursor: pointer; transition: all .15s; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--ink-2); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn.danger { background: #fff; color: #e53935; border: 1px solid #f3c1c0; }
.btn.danger:hover { background: #fdecea; }
.btn.sm { padding: 5px 12px; font-size: 13px; }
.btn.block { width: 100%; }
.icon-btn { border: none; background: transparent; cursor: pointer; font-size: 18px; line-height: 1; padding: 6px; border-radius: 6px; color: var(--ink-2); }
.icon-btn:hover { background: #f0f0f0; }

/* ---------- 认证页 ---------- */
#auth-screen, .auth-wrap { position: fixed; inset: 0; }
.auth-wrap {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #ffe9e1 0%, #fff7e6 45%, #eaf3e3 100%);
  overflow: auto; padding: 20px;
}
.auth-card {
  width: 100%; max-width: 380px; background: var(--card); border-radius: 16px;
  padding: 36px 32px; box-shadow: 0 10px 40px rgba(0,0,0,.10); text-align: center;
}
.auth-logo { font-size: 52px; }
.auth-title { font-size: 24px; color: var(--ink); margin-top: 6px; }
.auth-sub { color: var(--ink-3); font-size: 13px; margin: 6px 0 22px; }
.auth-view h2 { font-size: 18px; margin-bottom: 6px; text-align: left; }
.auth-tip { font-size: 12px; color: var(--ink-3); text-align: left; margin-bottom: 14px; line-height: 1.5; }
.auth-view input, .auth-card input {
  width: 100%; padding: 11px 12px; margin: 8px 0; border: 1px solid var(--border);
  border-radius: 8px; background: #fbfbfb; text-align: left; transition: border .15s;
}
.auth-view input:focus { border-color: var(--primary); background: #fff; }
.auth-view .btn { margin-top: 12px; }
.auth-link { display: inline-block; margin-top: 14px; font-size: 13px; }
.err { color: #e53935; font-size: 13px; min-height: 18px; margin-top: 6px; text-align: left; }

/* ---------- 主布局 ---------- */
#app { height: 100vh; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); background: var(--card); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; flex-shrink: 0; z-index: 30; position: relative;
}
.topbar-inner { width: 100%; max-width: 1500px; margin: 0 auto; display: flex; align-items: center; gap: 12px; padding: 0 16px; height: 100%; }
.menu-btn { display: none; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; color: var(--ink); white-space: nowrap; }
.brand .logo { font-size: 22px; }
.search-box { flex: 1; max-width: 460px; margin: 0 auto; display: flex; align-items: center; background: var(--bg); border: 1px solid transparent; border-radius: 8px; padding: 0 10px; transition: all .15s; }
.search-box:focus-within { background: #fff; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(224,81,44,.08); }
.search-ico { color: var(--ink-3); font-size: 14px; }
.search-box input { flex: 1; border: none; background: transparent; padding: 9px 8px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary-soft); display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 18px; }

/* 布局：侧栏 + 列表 + 编辑区 */
.layout { flex: 1; display: flex; overflow: hidden; }
.sidebar {
  width: var(--sidebar-w); background: var(--sidebar-bg); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0; overflow-y: auto; padding-bottom: 8px;
}
.side-nav { flex: 1; padding: 12px 8px; }
.nav-group { margin-bottom: 18px; }
.side-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 7px;
  color: var(--ink-2); cursor: pointer; font-size: 14px; transition: background .1s; margin: 1px 0; user-select: none;
}
.side-item:hover { background: #f0efec; }
.side-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.side-item .si-ico { font-size: 16px; width: 20px; text-align: center; }
.side-item .count { margin-left: auto; font-size: 12px; color: var(--ink-3); background: #efefef; border-radius: 10px; padding: 1px 8px; }
.side-item.active .count { background: rgba(224,81,44,.12); color: var(--primary); }
.nav-title { display: flex; align-items: center; justify-content: space-between; padding: 4px 12px; color: var(--ink-3); font-size: 12px; font-weight: 600; letter-spacing: 1px; }
.mini-add { border: none; background: transparent; color: var(--ink-3); cursor: pointer; font-size: 16px; line-height: 1; padding: 2px 4px; border-radius: 4px; }
.mini-add:hover { color: var(--primary); background: var(--primary-soft); }
#notebook_list .side-item { padding-left: 26px; }
.nb-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.side-foot { padding: 10px 16px; color: var(--ink-3); font-size: 12px; border-top: 1px solid var(--border); }

/* 笔记列表 */
.note-list { width: var(--list-w); background: var(--card); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.list-head { padding: 14px 16px 10px; display: flex; align-items: baseline; gap: 8px; }
.list-title { font-size: 17px; font-weight: 700; }
.list-count { color: var(--ink-3); font-size: 12px; }
.list-body { flex: 1; overflow-y: auto; padding: 0 8px 20px; }
.note-card { display: block; padding: 12px 12px; border-radius: 8px; cursor: pointer; border-left: 3px solid transparent; margin-bottom: 2px; transition: background .12s; }
.note-card:hover { background: #f7f6f3; }
.note-card.active { background: var(--primary-soft); border-left-color: var(--primary); }
.note-card .nc-top { display: flex; align-items: center; gap: 6px; }
.note-card .nc-title { font-weight: 600; font-size: 14.5px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.note-card .nc-star { color: #f0a020; font-size: 13px; }
.note-card .nc-excerpt { color: var(--ink-3); font-size: 12.5px; margin-top: 3px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.note-card .nc-meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 11px; color: var(--ink-3); }
.nb-tag { display: inline-flex; align-items: center; gap: 4px; background: #f3f3f3; border-radius: 4px; padding: 1px 6px; font-size: 11px; }
.nb-tag .t-dot { width: 7px; height: 7px; border-radius: 2px; }
.empty-tip { text-align: center; color: var(--ink-3); padding: 60px 20px; }
.empty-tip .big { font-size: 60px; opacity: .5; margin-bottom: 12px; }
.empty-tip .btn { margin-top: 16px; }

/* 编辑器 */
.editor-pane { flex: 1; background: var(--card); display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.editor-empty { margin: auto; text-align: center; color: var(--ink-3); }
.editor-empty .big { font-size: 70px; opacity: .45; margin-bottom: 10px; }
.editor-empty .dim { color: var(--ink-3); font-size: 12px; }
.editor-wrap { display: flex; flex-direction: column; height: 100%; }
.editor-head { padding: 10px 20px; border-bottom: 1px solid var(--border); }
.note-title { width: 100%; border: none; font-size: 21px; font-weight: 700; background: transparent; padding: 4px 0; }
.note-title::placeholder { color: #ccc; }
.editor-tools { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.edit-mode-btn { font-size: 13px; color: var(--ink-3); cursor: pointer; padding: 3px 4px; border-bottom: 2px solid transparent; }
.edit-mode-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tool-sep { width: 1px; height: 16px; background: var(--border); }
.editor-tools select { border: 1px solid var(--border); border-radius: 5px; background: #fff; padding: 3px 6px; font-size: 12px; color: var(--ink-2); }
.star-btn.on { color: #f0a020; }
.save-state { font-size: 12px; color: var(--ink-3); margin-left: auto; }
.editor-body { flex: 1; overflow: hidden; display: flex; flex-direction: column; position: relative; }
.editor-tabs { display: flex; align-items: center; gap: 2px; padding: 6px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.editor-tabs button { border: none; background: transparent; font-size: 13px; color: var(--ink-2); padding: 4px 7px; min-width: 26px; border-radius: 5px; }
.editor-tabs button:hover { background: #f0efec; color: var(--ink); }
.edit-area, .preview-area { flex: 1; overflow-y: auto; }
.edit-area textarea { width: 100%; height: 100%; border: none; resize: none; padding: 20px 24px; font-size: 15px; line-height: 1.8; letter-spacing: .2px; background: #fff; font-family: "SF Mono", Menlo, Consolas, "Courier New", monospace; }
.preview-area { padding: 22px 28px; }
.preview-area.hidden { display: none; }

/* 编辑区两种模式（分栏） */
.editor-body.split .edit-area { width: 50%; }
.editor-body.split .preview-area { width: 50%; }
.editor-body:not(.split) .edit-area, .editor-body:not(.split) .preview-area { width: 100%; }
.editor-body.split { flex-direction: row; }
.editor-body.split .edit-area, .editor-body.split .preview-area { flex: none; }
.editor-body.split .edit-area { border-right: 1px solid var(--border); }

/* ---------- Markdown 渲染 ---------- */
.markdown-body { font-size: 15px; line-height: 1.8; color: var(--ink); word-wrap: break-word; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 { margin: 1.3em 0 .6em; line-height: 1.4; font-weight: 700; }
.markdown-body h1 { font-size: 1.6em; padding-bottom: .3em; border-bottom: 1px solid var(--border); }
.markdown-body h2 { font-size: 1.35em; }
.markdown-body h3 { font-size: 1.15em; }
.markdown-body h4 { font-size: 1em; }
.markdown-body p { margin: .6em 0; }
.markdown-body a { color: #0b7bd8; text-decoration: underline; }
.markdown-body ul, .markdown-body ol { padding-left: 1.6em; margin: .5em 0; }
.markdown-body ul { list-style: disc; }
.markdown-body ol { list-style: decimal; }
.markdown-body li { margin: .25em 0; }
.markdown-body li.task-item { list-style: none; margin-left: -1.1em; }
.markdown-body input[type=checkbox] { margin-right: 6px; accent-color: var(--primary); }
.markdown-body blockquote { border-left: 3px solid var(--primary); background: var(--primary-soft); padding: 8px 14px; margin: .8em 0; color: var(--ink-2); border-radius: 0 6px 6px 0; }
.markdown-body code { background: #f4f4f4; color: #c7254e; padding: 2px 5px; border-radius: 4px; font-size: .9em; font-family: "SF Mono", Menlo, Consolas, monospace; }
.markdown-body pre { background: #282c34; color: #abb2bf; padding: 14px 16px; border-radius: 8px; overflow-x: auto; margin: .8em 0; line-height: 1.5; }
.markdown-body pre code { background: transparent; color: inherit; padding: 0; font-size: 13.5px; }
.markdown-body table { border-collapse: collapse; margin: .8em 0; width: auto; max-width: 100%; }
.markdown-body th, .markdown-body td { border: 1px solid #ddd; padding: 7px 12px; }
.markdown-body th { background: #f6f6f6; font-weight: 600; }
.markdown-body img { max-width: 100%; border-radius: 6px; }
.markdown-body hr { border: none; border-top: 1px dashed #ccc; margin: 1.4em 0; }
.markdown-body del { color: var(--ink-3); }
code[class*="language-"], pre code { direction: ltr; text-align: left; }
[data-lang]::before { content: attr(data-lang); display: block; color: #5c6370; font-size: 11px; margin-bottom: 8px; }

/* ---------- Modal ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 100; }
.modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); background: #fff; border-radius: 12px; width: 92%; max-width: 380px; z-index: 101; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 600; }
.modal-body { padding: 18px; }
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.form-row input, .form-row select, .form-row textarea { width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 7px; background: #fbfbfb; }
.form-row textarea { resize: vertical; min-height: 60px; }
.color-swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.color-swatch { width: 26px; height: 26px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; transition: transform .1s; }
.color-swatch.sel { border-color: #333; transform: scale(1.15); }
.modal-body .btn { margin-top: 8px; }
.note-dialog-warn { color: #e53935; font-size: 13px; margin-top: 8px; line-height: 1.5; }
.menu-ver { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 7px; cursor: pointer; color: var(--ink-2); }
.menu-ver:hover { background: #f0f0f0; }
.menu-ver.danger { color: #e53935; }

/* ---------- 响应式适配（手机 / 平板 / 笔记本 / 宽屏） ---------- */
/* 移动端返回按钮（仅窄屏可见） */
.back-btn { display: none; font-size: 24px; color: var(--ink-2); padding: 4px 8px 4px 0; flex-shrink: 0; }
.back-btn:hover { color: var(--primary); }

/* ---------- 最大屏（宽屏台式） ---------- */
@media (min-width: 1600px) {
  :root { --sidebar-w: 270px; --list-w: 340px; }
  .note-title { font-size: 23px; }
  .edit-area textarea, .markdown-body { font-size: 16px; }
  .auth-card { max-width: 400px; }
}

/* ---------- 中宽（大平板横屏 / 普通笔记本 901–1100） ---------- */
/* 保持三栏，但收窄两栏给编辑区让位，避免编辑区被压扁 */
@media (min-width: 901px) and (max-width: 1100px) {
  :root { --sidebar-w: 210px; --list-w: 250px; }
  .brand-name { display: none; }
  .search-box { max-width: none; }
  .note-title { font-size: 19px; }
  .editor-head { padding: 10px 16px; }
  .edit-area textarea { padding: 18px 20px; }
}

/* ---------- 平板竖屏 / 手机横屏 / 窄笔记本（≤900） ---------- */
@media (max-width: 900px) {
  .back-btn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; }
  .editor-head { display: flex; align-items: center; gap: 8px; }
  .editor-head .note-title { flex: 1; min-width: 0; }
  .editor-head .editor-tools { flex-wrap: wrap; }
  /* 让编辑器整列负责往返：返回按钮 + 顶栏菜单都可见 */
  .menu-btn { display: block; }
  .brand-name { display: none; }
  .sidebar { position: fixed; left: 0; top: var(--topbar-h); bottom: 0; z-index: 50; transform: translateX(-100%); transition: transform .25s ease; box-shadow: 2px 0 12px rgba(0,0,0,.08); background: var(--card); }
  .sidebar.open { transform: translateX(0); }
  .mask { position: fixed; inset: var(--topbar-h) 0 0 0; background: rgba(0,0,0,.3); z-index: 40; display: none; }
  .mask.show { display: block; }
  .note-list { width: 100%; }
  .search-box { max-width: none; }
  .editor-pane { display: none; position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 60; }
  .editor-pane.show { display: flex; }
  .editor-body { overflow-y: auto; }
  .editor-body.split { flex-direction: column; }
  .editor-body.split .edit-area, .editor-body.split .preview-area { width: 100%; height: 50%; min-height: 40vh; }
  .editor-body.split .edit-area { border-right: none; border-bottom: 1px solid var(--border); }
  .editor-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .editor-tabs::-webkit-scrollbar, .editor-tabs button::-webkit-scrollbar { display: none; }
  .editor-tabs button { flex-shrink: 0; }
  .note-title { font-size: 18px; }
  .modal { width: calc(100% - 32px); }
}

/* ---------- 手机竖屏（≤640） ---------- */
@media (max-width: 640px) {
  :root { --topbar-h: 52px; }
  .topbar-inner { padding: 0 10px; gap: 6px; }
  .brand { font-size: 16px; }
  .brand .logo { font-size: 20px; }
  .search-box { padding: 0 8px; }
  .search-box input { padding: 8px 6px; font-size: 14px; }
  .search-ico { display: none; }           /* 小屏隐藏放大镜图标，输入框更宽 */
  .new-btn { padding: 9px 12px; font-size: 13px; }
  .avatar { width: 32px; height: 32px; font-size: 16px; }
  .list-head { padding: 12px 12px 8px; }
  .list-body { padding: 0 6px 16px; }
  .note-card { padding: 11px 10px; }
  .note-card .nc-title { font-size: 14px; }
  .editor-head { padding: 8px 12px; }
  .note-title { font-size: 17px; }
  .editor-tabs { padding: 6px 10px; }
  .editor-tabs button { padding: 6px 8px; min-width: 30px; }
  .edit-area textarea { padding: 16px 16px; font-size: 15px; }
  .preview-area { padding: 18px 18px; }
  .markdown-body { font-size: 15px; }
  .auth-card { padding: 28px 22px; }
  .auth-logo { font-size: 46px; }
  .side-item { padding: 11px 12px; }        /* 加大点击区 */
  .mini-add { padding: 6px 8px; }
}

/* ---------- 超小屏 / 触控适配（≤400） ---------- */
@media (max-width: 400px) {
  .topbar-inner { gap: 4px; }
  .brand { font-size: 15px; }
  .brand .logo { font-size: 18px; }
  .new-btn { padding: 8px 8px; font-size: 12px; }
  .hide-xs { display: none; }
  .editor-tools .save-state { font-size: 11px; }
  .editor-head .editor-tools select { padding: 4px 4px; font-size: 11px; }
}

/* ---------- 触控优化（任何窄屏/粗指针） ---------- */
@media (pointer: coarse) {
  .side-item, .note-card, .edit-mode-btn, .mini-add { min-height: 44px; }
  .icon-btn { min-width: 40px; min-height: 40px; }
  .list-body { touch-action: pan-y; }
}

/* ---------- 偏好减弱动画 ---------- */
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

