* { box-sizing: border-box; }
html, body { height: 100%; }
:root {
  --bg: #0b0e12;
  --panel: #0f1318;
  --text: #eaeaea;
  --muted: #9fb2bf;
  --accent: #ff4d4f;
  --accent-2: #ff6b6f;
  --shadow: 0 12px 30px rgba(0,0,0,.35);
  --bg-tint: #12161d;
  --scroll-thumb: #2a2f3a;
  --scroll-track: #141821;
  --toolbar-tint: rgba(255,77,79,.08);
  --input-bg: #0f1318;
  --input-border: var(--accent);
}

/* 浅色主题变量覆盖 */
:root[data-theme="light"] {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --text: #1b2430;
  --muted: #6b7785;
  --accent: #ff4d4f;
  --accent-2: #ff6b6f;
  --shadow: 0 10px 26px rgba(22,28,38,.12);
  --bg-tint: #eef2f7;
  --scroll-thumb: #cfd6e2;
  --scroll-track: #e9edf3;
  --toolbar-tint: rgba(255,77,79,.03);
  --input-bg: #ffffff;
  --input-border: #e3e8ef;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', 'Microsoft Yahei', sans-serif;
  background: radial-gradient(1200px 600px at 70% 10%, var(--bg-tint) 0%, var(--bg) 55%);
  color: var(--text);
  overflow: hidden; /* 防止整页滚动 */
}

.app {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: 100vh;
  backdrop-filter: saturate(1.2);
}

.sidebar {
  border-right: 2px solid var(--accent);
  padding: 16px;
  background: linear-gradient(180deg, rgba(255,77,79,.06), transparent 40%);
  overflow: auto; /* 侧栏独立滚动 */
}
.sidebar-header { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.sidebar h1 { margin:0; font-size:18px; letter-spacing:.5px; }
.actions { display:flex; gap:8px; }

.btn {
  background: #1a1f27;
  border: 1px solid var(--accent);
  color: #ffd6d6;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all .18s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(255,77,79,.25); }
.btn.primary { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { background:#2a0f12; color:#ff9aa0; border-color:var(--accent); }
.btn[disabled] { opacity:.6; cursor:not-allowed; box-shadow:none; transform:none; }

/* 浅色主题按钮更柔和 */
:root[data-theme="light"] .btn { background:#f6f8fb; color:#3b4450; border-color:#e3e8ef; }
:root[data-theme="light"] .btn:hover { box-shadow: 0 6px 16px rgba(22,28,38,.12); }
:root[data-theme="light"] .btn.danger { background:#ffe8ea; color:#d33; border-color:#ffc2c5; }

.doc-list { list-style:none; padding:0; margin:12px 0 0; display:flex; flex-direction:column; gap:8px; }
.doc-item {
  position: relative;
  padding: 8px 10px 8px 32px;
  border: 1.5px solid var(--accent);
  border-radius: 8px;
  cursor: pointer;
  background: var(--panel);
  transition: all .2s ease;
  font-size: 14px;
  min-height: 40px;
  display: flex; align-items: center;
}
.doc-item::before {
  content: '\1F4C2'; /* folder emoji */
  position: absolute; left: 10px; top: 8px; opacity:.8;
}
.doc-item:hover { filter: brightness(1.05); transform: translateY(-1px); }
.doc-item.active { outline: 2px solid rgba(255,77,79,.25); background: var(--panel); box-shadow: 0 0 0 3px rgba(255,77,79,.06) inset; }

.editor { display:flex; flex-direction:column; height: 100vh; }
.toolbar {
  position: sticky; top: 0; z-index: 5;
  display:flex; gap:12px; align-items:center; padding:12px;
  border-bottom:2px solid var(--accent);
  background: linear-gradient(180deg, var(--toolbar-tint), transparent 90%), var(--panel);
  box-shadow: var(--shadow);
}
.title-input {
  flex:1; padding:10px 12px; background: var(--input-bg); color:var(--text);
  border:1px solid var(--input-border); border-radius:8px; outline:none; transition: box-shadow .15s;
}
.title-input:focus { box-shadow: 0 0 0 3px rgba(255,77,79,.3); }

.editor-area {
  flex:1; padding:18px 24px; overflow:auto; background: var(--panel);
  line-height: 1.7; font-size: 15px;
}
.editor-area:empty::before { content:'在此编辑内容…'; color: var(--muted); }
.editor-area img { max-width:100%; height:auto; border-radius: 8px; box-shadow: 0 4px 22px rgba(0,0,0,.35); }
.editor-area p { margin: .7em 0; }
.editor-area h1, .editor-area h2, .editor-area h3 { margin: 1em 0 .6em; color:#2b2f36; }
.editor-area a { color:#ff9aa0; }

.status { border-top:2px solid var(--accent); padding:8px 12px; font-size:12px; color:var(--muted); background: var(--panel); }

/* 精致滚动条 */
* { scrollbar-width: thin; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 6px; border:2px solid var(--scroll-track); }
::-webkit-scrollbar-thumb:hover { filter: brightness(1.1); }
::-webkit-scrollbar-track { background: var(--scroll-track); }

/* 响应式 */
@media (max-width: 960px) {
  .app { grid-template-columns: 240px 1fr; }
}
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 2px solid var(--accent); }
}
/* 分享弹窗与通知条 */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: none; align-items: center; justify-content: center; z-index: 999; }
.modal { background: var(--panel); color: var(--text); border: 1px solid var(--input-border); border-radius: 12px; box-shadow: var(--shadow); width: 520px; max-width: 92vw; padding: 16px; }
.modal h3 { margin: 0 0 10px; font-size: 18px; }
.modal .options { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.modal .options .btn { padding: 8px 12px; }
.modal .link-box { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.modal .link-box input { flex: 1; padding: 8px 10px; background: var(--input-bg); border: 1px solid var(--input-border); border-radius: 8px; color: var(--text); }
.modal .footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 16px; background: var(--panel); color: var(--text); border: 1px solid var(--input-border); border-radius: 10px; box-shadow: var(--shadow); padding: 10px 14px; z-index: 998; display: none; }
.toast a { color: var(--accent); text-decoration: none; }
