:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --border: #e3e6ea;
  --text: #1f2329;
  --muted: #8a909a;
  --primary: #2f6fed;
  --danger: #e5484d;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  height: 100vh;
  overflow: hidden;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 6px 0 0; }

/* 登录遮罩 */
.overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #2f6fed 0%, #6a4cf0 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.login-card {
  background: var(--panel);
  padding: 32px;
  border-radius: 14px;
  width: 320px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  text-align: center;
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card input {
  width: 100%;
  padding: 11px 12px;
  margin: 16px 0 8px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 15px;
}
.login-card button {
  width: 100%;
  padding: 11px;
  border: none;
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
}
.login-card button:active { transform: translateY(1px); }

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

.sidebar {
  width: 300px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 600; font-size: 15px; }
#new-btn {
  width: 32px; height: 32px;
  border: none; border-radius: 8px;
  background: var(--primary); color: #fff;
  font-size: 20px; line-height: 1; cursor: pointer;
}
#search-input {
  margin: 12px 16px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}
.note-list {
  list-style: none;
  margin: 0;
  padding: 0 8px;
  flex: 1;
  overflow-y: auto;
}
.note-item {
  padding: 11px 12px;
  border-radius: 9px;
  cursor: pointer;
  margin-bottom: 4px;
}
.note-item:hover { background: #f0f3f8; }
.note-item.active { background: #e7efff; }
.note-item .ni-title {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.note-item .ni-snippet {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.link {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: 13px; text-decoration: underline;
}

/* 编辑器 */
.editor { flex: 1; display: flex; flex-direction: column; padding: 24px 32px; overflow: hidden; }
.empty { margin: auto; color: var(--muted); }
.editor-pane { display: flex; flex-direction: column; height: 100%; }
.title-input {
  border: none;
  font-size: 24px;
  font-weight: 700;
  padding: 4px 0;
  outline: none;
  background: transparent;
}
.editor-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 12px 0;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.editor-meta button {
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  margin-left: 8px;
}
.primary { background: var(--primary); color: #fff; }
.danger { background: #fff; color: var(--danger); border: 1px solid var(--danger) !important; }
#content-input {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font-size: 15px;
  line-height: 1.7;
  background: transparent;
  font-family: inherit;
}
.save-state { margin: 8px 0 0; min-height: 16px; }

/* 移动端返回栏（仅移动端显示） */
.mobile-bar { display: none; }

/* ---------- 移动端适配（≤768px） ---------- */
@media (max-width: 768px) {
  .login-card { width: 90%; }

  #app { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .editor { padding: 14px 16px; }

  /* 列表态隐藏编辑器；进入编辑态后隐藏列表、全屏显示编辑器 */
  .editor { display: none; }
  #app.editing .sidebar { display: none; }
  #app.editing .editor { display: flex; }

  .mobile-bar {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
  }
  .mobile-bar button {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 15px;
    cursor: pointer;
    padding: 6px 0;
  }

  .editor-meta { flex-wrap: wrap; gap: 8px 12px; }
  .editor-meta > span:last-child { display: flex; gap: 8px; }
  .editor-meta button { padding: 10px 18px; } /* 更大的点按区域 */
  .title-input { font-size: 20px; }
  #content-input { font-size: 16px; line-height: 1.6; } /* 16px 避免 iOS 聚焦缩放 */
  .note-item { padding: 13px 12px; }
}
