/* Edgenotes — Notion 风格样式 */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #ffffff;
  --sidebar-bg: #f7f7f5;
  --border: #e9e9e7;
  --text: #37352f;
  --text-light: #9b9a97;
  --accent: #2383e2;
  --hover: rgba(55, 53, 47, 0.06);
  --danger: #eb5757;
  --menu-shadow: 0 4px 24px rgba(15, 15, 15, 0.15), 0 0 0 1px rgba(15, 15, 15, 0.05);
}

html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.6;
}
.hidden { display: none !important; }

/* ---------- 登录 ---------- */
#login-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: var(--sidebar-bg);
}
.login-card {
  text-align: center;
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  padding: 40px 48px; box-shadow: var(--menu-shadow); width: 320px;
}
.login-logo { width: 84px; height: auto; margin: 0 auto; display: block; }
.login-card h1 { font-size: 22px; margin: 8px 0 4px; }
.login-card p { color: var(--text-light); font-size: 13px; margin-bottom: 16px; }
.login-card input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px; margin-bottom: 12px; outline: none;
}
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(35, 131, 226, 0.2); }
.login-card button {
  width: 100%; padding: 9px; border: none; border-radius: 6px; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 14px; font-weight: 500;
}
.login-card button:hover { filter: brightness(1.05); }
.login-error { color: var(--danger) !important; min-height: 18px; }

/* ---------- 布局 ---------- */
.app { display: flex; height: 100vh; }

/* ---------- 侧边栏 ---------- */
.sidebar {
  width: 250px; min-width: 250px; background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 12px 6px;
}
.workspace-name { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 7px; }
.workspace-logo { width: 66px; height: 66px; object-fit: contain; }
.icon-btn {
  border: none; background: transparent; cursor: pointer; color: var(--text-light);
  font-size: 15px; border-radius: 4px; width: 24px; height: 24px; line-height: 1;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }

.sidebar-tree { flex: 1; overflow-y: auto; padding: 4px 8px; }
.tree-item {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 8px; border-radius: 5px; cursor: pointer;
  font-size: 14px; user-select: none; position: relative;
}
.tree-item:hover { background: var(--hover); }
.tree-item.active { background: rgba(35, 131, 226, 0.12); font-weight: 500; }
.tree-item .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-item .caret {
  width: 16px; font-size: 10px; color: var(--text-light); text-align: center;
  transition: transform 0.15s; flex-shrink: 0;
}
.tree-item .caret.open { transform: rotate(90deg); }
.tree-item .caret.leaf { visibility: hidden; }
.tree-item .item-actions { display: none; gap: 2px; }
.tree-item:hover .item-actions { display: flex; }
.tree-children { margin-left: 18px; }
.sidebar-footer { padding: 10px 14px; border-top: 1px solid var(--border); }
.user-row { display: flex; align-items: center; gap: 4px; margin-bottom: 4px; }
.current-user { flex: 1; font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mode-badge { font-size: 11px; color: var(--text-light); }

/* ---------- 管理面板 ---------- */
.modal {
  position: fixed; inset: 0; z-index: 95;
  background: rgba(15, 15, 15, 0.4);
  display: flex; align-items: center; justify-content: center;
}
.modal-card {
  width: 460px; max-width: 92vw; max-height: 78vh; overflow-y: auto;
  background: #fff; border-radius: 10px; box-shadow: var(--menu-shadow); padding: 16px 18px;
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 17px; font-weight: 600; margin-bottom: 10px;
}
.modal-tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.mail-form { display: flex; flex-direction: column; gap: 10px; }
.mail-form input, .mail-form textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px; font-family: inherit; outline: none; box-sizing: border-box; resize: vertical;
}
.mail-form input:focus, .mail-form textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(35, 131, 226, 0.2); }
.mail-actions { display: flex; justify-content: flex-end; align-items: center; gap: 12px; }
.mail-status { font-size: 13px; color: #d44; }
.tab-btn {
  border: none; background: transparent; cursor: pointer; padding: 7px 14px;
  font-size: 14px; color: var(--text-light); border-bottom: 2px solid transparent;
}
.tab-btn.active { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }
.add-user-row { display: flex; gap: 6px; margin-bottom: 12px; }
.add-user-row input {
  flex: 1; min-width: 0; padding: 7px 10px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 13px; outline: none;
}
.add-user-row input:focus { border-color: var(--accent); }
.primary-btn.small { margin: 0; padding: 7px 14px; font-size: 13px; flex-shrink: 0; }
.user-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 8px; border-radius: 6px; font-size: 14px;
}
.user-item:hover { background: var(--hover); }
.act-item { display: flex; gap: 10px; padding: 6px 4px; font-size: 13px; border-bottom: 1px solid var(--border); }
.act-item:last-child { border-bottom: none; }
.act-time { color: var(--text-light); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.act-empty { color: var(--text-light); font-size: 13px; text-align: center; padding: 20px; }

/* ---------- 主区 ---------- */
.main { flex: 1; overflow: hidden; display: flex; flex-direction: column; }

.empty-state {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; color: var(--text-light);
}
.empty-logo { width: 88px; height: auto; }
.empty-state h2 { color: var(--text); }
.primary-btn {
  margin-top: 8px; padding: 8px 18px; border: none; border-radius: 6px; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 14px;
}
.primary-btn:hover { filter: brightness(1.05); }

.editor { flex: 1; overflow-y: auto; }
.editor.drag-over {
  outline: 3px dashed var(--accent);
  outline-offset: -10px;
  background: rgba(35, 131, 226, 0.04);
}

/* 拖拽全屏投放遮罩 */
#drop-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(35, 131, 226, 0.08);
  outline: 4px dashed var(--accent);
  outline-offset: -14px;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
#drop-overlay .hint {
  background: #fff; border-radius: 10px; padding: 14px 30px;
  box-shadow: var(--menu-shadow);
  font-size: 15px; font-weight: 600; color: var(--accent);
}
.editor-scroll { max-width: 720px; margin: 0 auto; padding: 60px 48px 120px; }

.page-head { margin-bottom: 8px; }
.page-icon {
  font-size: 40px; border: none; background: transparent; width: 60px;
  outline: none; padding: 4px 0; border-radius: 6px;
}
.page-icon:focus { background: var(--hover); }
.page-title { font-size: 34px; font-weight: 700; line-height: 1.2; outline: none; }
.page-title:empty::before { content: attr(data-placeholder); color: var(--text-light); }
.page-meta {
  display: flex; align-items: center; gap: 10px; margin-top: 10px;
  font-size: 12px; color: var(--text-light);
}
.ghost-btn {
  border: none; background: transparent; cursor: pointer; color: var(--text-light);
  font-size: 12px; border-radius: 4px; padding: 3px 8px;
}
.ghost-btn:hover { background: var(--hover); color: var(--danger); }

/* ---------- 块 ---------- */
.blocks { min-height: 200px; }
.block-row { position: relative; display: flex; align-items: flex-start; }
.block-gutter {
  display: flex; gap: 1px; position: absolute; left: -46px; top: 3px;
}
.gutter-btn {
  border: none; background: transparent; cursor: pointer; color: var(--text-light);
  width: 22px; height: 22px; border-radius: 4px; font-size: 13px;
  opacity: 0; transition: opacity 0.15s;
}
/* 每行常驻一个淡淡的 +，悬停该行时所有按钮变清晰 */
.gutter-btn.gutter-plus { opacity: 0.28; }
.gutter-btn.gutter-plus:hover { opacity: 1; background: var(--hover); color: var(--text); }
.block-row:hover .gutter-btn { opacity: 1; }
.block-row:hover .gutter-btn:hover { background: var(--hover); color: var(--text); }

.block-content {
  flex: 1; outline: none; padding: 3px 2px; min-height: 30px; white-space: pre-wrap;
  word-break: break-word; border-radius: 3px;
}
.block-content:empty::before { content: attr(data-placeholder); color: var(--text-light); pointer-events: none; }

.b-h1 { font-size: 26px; font-weight: 700; margin-top: 14px; }
.b-h2 { font-size: 21px; font-weight: 700; margin-top: 10px; }
.b-h3 { font-size: 17px; font-weight: 600; margin-top: 8px; }

.todo-row { display: flex; align-items: flex-start; gap: 8px; flex: 1; }
.todo-row input[type="checkbox"] { margin-top: 6px; width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
.todo-row .done { text-decoration: line-through; color: var(--text-light); }

.divider-block { border: none; border-top: 1px solid var(--border); margin: 10px 0; width: 100%; }

/* 表格 */
.table-wrap { flex: 1; overflow-x: auto; margin: 4px 0; }
.block-table { border-collapse: collapse; width: 100%; }
.block-table td {
  border: 1px solid var(--border); padding: 6px 10px; min-width: 100px;
  outline: none; font-size: 14px; vertical-align: top;
}
.block-table td:focus { background: rgba(35, 131, 226, 0.05); }
.block-table tr:first-child td { background: #f7f7f5; font-weight: 600; }
.table-toolbar { display: flex; gap: 4px; margin-top: 4px; }
.table-toolbar button {
  border: 1px solid var(--border); background: #fff; cursor: pointer;
  font-size: 12px; color: var(--text-light); border-radius: 4px; padding: 2px 8px;
}
.table-toolbar button:hover { background: var(--hover); color: var(--text); }

/* 图片 / 文件块 */
.image-block img { max-width: 100%; border-radius: 6px; display: block; cursor: zoom-in; margin: 4px 0; }
.file-block {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; margin: 4px 0;
  border: 1px solid var(--border); border-radius: 6px; text-decoration: none; color: var(--text);
  max-width: 480px;
}
.file-block:hover { background: var(--hover); }
.file-block .file-icon { font-size: 20px; }
.file-block .file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.file-block .file-size { color: var(--text-light); font-size: 12px; }

.uploading { color: var(--text-light); font-size: 13px; padding: 4px 2px; font-style: italic; }

.editor-tail { margin-top: 8px; }
/* 内容下方的大片可点击区域：点一下就开始输入文本 */
.editor-tail-space { min-height: 45vh; cursor: text; }
.add-block-btn {
  border: none; background: transparent; cursor: pointer; color: var(--text-light);
  font-size: 13px; padding: 6px 2px; border-radius: 4px;
}
.add-block-btn:hover { background: var(--hover); color: var(--text); }

/* ---------- 插入菜单 ---------- */
.type-menu {
  position: fixed; z-index: 50; width: 220px; background: #fff;
  border-radius: 8px; box-shadow: var(--menu-shadow); padding: 6px;
  max-height: 340px; overflow-y: auto;
}
.menu-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px;
  border-radius: 5px; cursor: pointer; font-size: 14px;
}
.menu-item:hover, .menu-item.hovered { background: var(--hover); }
.menu-item .mi-icon {
  width: 32px; height: 32px; border: 1px solid var(--border); border-radius: 5px;
  display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0;
}
.menu-item .mi-sub { font-size: 11px; color: var(--text-light); }

/* ---------- 其他 ---------- */
.hidden-input { display: none; }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #2f2f2b; color: #fff; padding: 9px 18px; border-radius: 8px;
  font-size: 13px; z-index: 99; box-shadow: var(--menu-shadow);
}

::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 5px; }
::-webkit-scrollbar-track { background: transparent; }
