/* ==========================================================================
   应用布局：桌面三栏 + 移动端单栏（抽屉 / 全屏编辑器）
   ========================================================================== */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) var(--list-w) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* 首页（无编辑器）时隐藏第三栏 */
.app[data-mode='list-only'] {
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
}

.app[data-mode='list-only'] .editor-pane {
  display: none;
}

.app[data-mode='list-only'] .list-pane {
  max-width: none;
}

/* -------------------------------- 左栏导航 -------------------------------- */

.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--header-h);
  padding: 0 14px;
  flex: 0 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.brand-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: linear-gradient(135deg, #ffd259, #f5a623);
  color: #fff;
  font-size: 14px;
}

.sidebar-nav {
  flex: 1 1 auto;
  padding: 4px 8px 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: 14px;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.nav-item .icon {
  font-size: 17px;
}

.nav-item .nav-label {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item .nav-count {
  font-size: 12px;
  color: var(--text-3);
}

.nav-item .nav-caret {
  font-size: 14px;
  color: var(--text-3);
  transition: transform 0.15s;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.nav-item.is-active {
  background: var(--bg-active);
  color: var(--text);
  font-weight: 500;
}

.nav-group + .nav-group {
  margin-top: 0;
}

.nav-sub {
  display: none;
  padding: 2px 0 4px;
}

.nav-sub.is-open {
  display: block;
}

.nav-item.is-collapsed .nav-caret {
  transform: rotate(-90deg);
}

.nav-sub .nav-item {
  height: 34px;
  padding-left: 38px;
  font-size: 13px;
}

.nav-sub .nav-item .nav-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  opacity: 0.55;
  flex: 0 0 auto;
}

.nav-hint {
  padding: 4px 12px 4px 38px;
  font-size: 12px;
  color: var(--text-3);
}

.sidebar-foot {
  flex: 0 0 auto;
  padding: 10px;
  border-top: 1px solid var(--border);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 8px;
  border-radius: var(--radius);
  transition: background 0.15s;
}

.user-chip:hover {
  background: var(--bg-hover);
}

.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.user-name {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: var(--text-2);
  text-align: left;
}

.user-chip .icon {
  font-size: 15px;
  color: var(--text-3);
}

/* -------------------------------- 中栏列表 -------------------------------- */

.list-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: var(--header-h);
  padding: 0 12px 0 16px;
  flex: 0 0 auto;
}

.list-title {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}

.list-title h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-title .list-count {
  font-size: 12px;
  color: var(--text-3);
}

.list-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
}

.search-bar {
  position: relative;
  padding: 0 12px 8px;
  flex: 0 0 auto;
}

.search-bar .icon {
  position: absolute;
  left: 22px;
  top: 50%;
  transform: translateY(-50%);
  margin-top: -4px;
  font-size: 15px;
  color: var(--text-3);
  pointer-events: none;
}

.search-bar input {
  width: 100%;
  height: 32px;
  padding: 0 28px 0 32px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--bg-sunken);
  outline: none;
  font-size: 13px;
}

.search-bar input:focus {
  border-color: var(--brand);
  background: var(--bg-panel);
}

.search-clear {
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  margin-top: -4px;
  font-size: 15px;
  color: var(--text-3);
}

.notes {
  flex: 1 1 auto;
  padding: 0 8px 12px;
}

.note-card {
  position: relative;
  display: block;
  width: 100%;
  padding: 12px 12px 10px 14px;
  border-radius: var(--radius);
  text-align: left;
  transition: background 0.12s;
}

.note-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: transparent;
}

.note-card:hover {
  background: var(--bg-hover);
}

.note-card.is-active {
  background: var(--bg-hover);
}

.note-card.is-active::before {
  background: var(--yellow);
}

.note-card-title {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.45;
}

.note-card-title .pin-mark {
  font-size: 13px;
  color: var(--yellow);
}

.note-card-title .star-mark {
  font-size: 13px;
  color: var(--yellow);
}

.note-card-title span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-card-body {
  margin-top: 3px;
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.note-card-body:empty {
  display: none;
}

.note-card-thumb {
  float: right;
  width: 54px;
  height: 34px;
  margin: 2px 0 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--bg-sunken);
}

.note-card-date {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-3);
}

.note-card-flag {
  display: inline-block;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 3px;
  background: var(--bg-sunken);
  color: var(--text-3);
  font-size: 11px;
  line-height: 16px;
  vertical-align: 1px;
}

.note-card.color-yellow::before { background: var(--yellow); }
.note-card.color-green::before { background: var(--green); }
.note-card.color-blue::before { background: var(--blue); }
.note-card.color-pink::before { background: var(--pink); }
.note-card.color-purple::before { background: var(--purple); }
.note-card.color-gray::before { background: var(--gray); }

/* 回收站里的操作条 */
.note-card-tools {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.note-card-tools .btn {
  height: 26px;
  padding: 0 9px;
  font-size: 12px;
  border: 1px solid var(--border-strong);
  background: var(--bg-panel);
}

/* 列表底部的「载入更多」 */
.list-more {
  padding: 12px;
  text-align: center;
}

/* ------------------------------- 右栏编辑器 ------------------------------- */

.editor-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-panel);
  overflow: hidden;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 1px;
  height: var(--header-h);
  padding: 0 10px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  overflow-y: hidden;
  flex: 0 0 auto;
  scrollbar-width: none;
}

.editor-toolbar::-webkit-scrollbar {
  height: 0;
}

.tool-sep {
  width: 1px;
  height: 18px;
  margin: 0 6px;
  background: var(--border);
  flex: 0 0 auto;
}

.tool-spacer {
  flex: 1 1 auto;
  min-width: 8px;
}

.tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 4px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 500;
  color: var(--text-2);
  flex: 0 0 auto;
  transition: background 0.12s, color 0.12s;
}

.tool:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.tool.is-active {
  background: var(--brand-weak);
  color: var(--brand);
}

.tool:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  background: none;
}

.tool-label {
  font-size: 13px;
  font-weight: 600;
  padding: 0 7px;
  letter-spacing: 0.2px;
}

/* 返回按钮只在手机端出现，桌面端由下面的媒体查询切换 */
.tool-back {
  display: none;
}

.tool-sep.tool-back {
  display: none;
}

.tool-color {
  position: relative;
  flex-direction: column;
  gap: 0;
  padding: 0 5px;
}

.tool-color .color-bar {
  width: 15px;
  height: 3px;
  border-radius: 2px;
  background: currentColor;
}

.tool-picker {
  position: relative;
}

.picker-pop {
  position: absolute;
  top: 34px;
  left: 0;
  z-index: 60;
  display: none;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
  box-shadow: var(--shadow);
}

.picker-pop.is-open {
  display: block;
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(5, 22px);
  gap: 6px;
}

.color-swatch {
  width: 22px;
  height: 22px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
}

.color-swatch:hover {
  transform: scale(1.12);
}

.heading-list {
  display: flex;
  flex-direction: column;
  min-width: 116px;
}

.heading-list button {
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  text-align: left;
  color: var(--text);
}

.heading-list button:hover {
  background: var(--bg-hover);
}

.heading-list .h1 {
  font-size: 19px;
  font-weight: 700;
}

.heading-list .h2 {
  font-size: 16px;
  font-weight: 600;
}

.heading-list .h3 {
  font-size: 14px;
  font-weight: 600;
}

.heading-list .body {
  font-size: 14px;
}

.editor-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  padding-right: 4px;
}

.editor-body {
  flex: 1 1 auto;
  overflow-y: auto;
}

.editor-body .ProseMirror-like {
  min-height: 100%;
}

.note-content {
  max-width: 820px;
  margin: 0 auto;
  padding: 40px 48px 160px;
  outline: none;
  font-size: 15px;
  line-height: 1.75;
  color: var(--text);
  word-break: break-word;
  overflow-wrap: anywhere;
  caret-color: var(--brand);
}

.note-content:empty::before,
.note-content.is-empty::before {
  content: attr(data-placeholder);
  color: var(--text-3);
  pointer-events: none;
}

.note-content h1 {
  margin: 0.7em 0 0.35em;
  font-size: 24px;
  line-height: 1.4;
}

.note-content h2 {
  margin: 0.7em 0 0.35em;
  font-size: 20px;
  line-height: 1.4;
}

.note-content h3 {
  margin: 0.7em 0 0.3em;
  font-size: 17px;
}

.note-content p {
  margin: 0.4em 0;
}

.note-content ul,
.note-content ol {
  padding-left: 1.6em;
  margin: 0.4em 0;
}

.note-content ul {
  list-style: disc;
}

.note-content ol {
  list-style: decimal;
}

.note-content li {
  margin: 0.15em 0;
}

.note-content blockquote {
  margin: 0.6em 0;
  padding: 4px 0 4px 14px;
  border-left: 3px solid var(--border-strong);
  color: var(--text-2);
}

.note-content pre {
  margin: 0.6em 0;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--bg-sunken);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  overflow-x: auto;
}

.note-content code {
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}

.note-content hr {
  margin: 1em 0;
  border: none;
  border-top: 1px solid var(--border-strong);
}

.note-content img {
  display: block;
  max-width: 100%;
  margin: 12px auto;
  border-radius: var(--radius);
}

/* 选中的图片与四角缩放手柄 */
.note-content img.is-selected {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

.note-content {
  position: relative;
}

.img-handle {
  position: absolute;
  z-index: 20;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  touch-action: none;
  cursor: nwse-resize;
}

.img-handle-ne,
.img-handle-sw {
  cursor: nesw-resize;
}

.img-handle::after {
  /* 扩大触摸热区，手机上更好抓 */
  content: '';
  position: absolute;
  inset: -10px;
}

.img-size-badge {
  position: absolute;
  z-index: 20;
  transform: translateX(-50%);
  padding: 1px 7px;
  border-radius: 10px;
  background: rgba(31, 35, 41, 0.82);
  color: #fff;
  font-size: 11px;
  line-height: 16px;
  pointer-events: none;
  white-space: nowrap;
}

body.is-resizing-image {
  cursor: nwse-resize;
  user-select: none;
}

/* 图片全屏预览 */
.image-preview {
  position: fixed;
  inset: 0;
  z-index: 950;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(12, 14, 18, 0.88);
  animation: fade-in 0.16s ease-out;
  cursor: zoom-out;
}

.image-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.image-preview-close {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 18px;
}

.image-preview-close:hover {
  background: rgba(255, 255, 255, 0.26);
}

.note-content table {
  border-collapse: collapse;
  margin: 0.6em 0;
}

.note-content td,
.note-content th {
  border: 1px solid var(--border-strong);
  padding: 6px 10px;
}

.editor-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-3);
  flex: 0 0 auto;
  min-height: 40px;
}

.editor-meta .meta-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

/* 手机端顶部信息区（保存状态 + 标签）；桌面端由下面的媒体查询显示 */
.editor-topbar {
  display: none;
  flex-direction: column;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.topbar-status {
  font-size: 12px;
  color: var(--text-3);
}

.topbar-tags {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* 编辑器底部的标签行 */
.meta-tags {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.meta-tags::-webkit-scrollbar {
  height: 0;
}

.tag-empty {
  color: var(--text-3);
  white-space: nowrap;
}

/* 标签胶囊 */
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  height: 22px;
  padding: 0 8px;
  border-radius: 11px;
  background: var(--brand-weak);
  color: var(--brand);
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
  transition: background 0.14s;
}

.tag-chip .icon {
  font-size: 12px;
}

button.tag-chip:hover {
  background: rgba(43, 108, 246, 0.2);
}

.tag-chip.is-static {
  padding-right: 3px;
}

.tag-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  color: inherit;
  opacity: 0.6;
}

.tag-remove:hover {
  background: rgba(43, 108, 246, 0.22);
  opacity: 1;
}

.tag-remove .icon {
  font-size: 11px;
}

.tag-add {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex: 0 0 auto;
  height: 22px;
  padding: 0 8px;
  border: 1px dashed var(--border-strong);
  border-radius: 11px;
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
}

.tag-add:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.tag-add .icon {
  font-size: 12px;
}

/* 列表卡片上的标签：贴在日期右侧 */
.note-card-date {
  display: flex;
  align-items: center;
  gap: 4px;
}

.note-card-tags {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  padding-left: 8px;
  max-width: 64%;
  overflow: hidden;
}

.note-card-tags .tag-chip {
  height: 19px;
  padding: 0 7px;
  font-size: 11px;
  background: var(--bg-sunken);
  color: var(--text-2);
}

.note-card-tags button.tag-chip:hover {
  background: var(--brand-weak);
  color: var(--brand);
}

.note-card-tags .tag-chip .icon {
  font-size: 11px;
}

/* 插入符号面板 */
.symbol-panel {
  width: 300px;
  max-height: min(60vh, 460px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px 4px 6px;
}

.symbol-group-name {
  padding: 8px 4px 4px;
  font-size: 11px;
  color: var(--text-3);
}

.symbol-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 2px;
}

.symbol-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  line-height: 1;
  color: var(--text);
  transition: background 0.12s;
}

.symbol-btn:hover {
  background: var(--brand-weak);
  color: var(--brand);
}

/* 标签选择弹层 */
.tag-picker-search {
  position: relative;
  padding: 2px 4px 6px;
}

.tag-picker-search .icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  margin-top: -2px;
  font-size: 14px;
  color: var(--text-3);
  pointer-events: none;
}

.tag-picker-search .tag-picker-input {
  width: 100%;
  padding-left: 28px;
}

.tag-picker-list {
  max-height: min(38vh, 220px);
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 0 0 4px;
}

.tag-picker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  text-align: left;
  color: var(--text);
}

.tag-picker-item:hover {
  background: var(--bg-hover);
}

.tag-picker-item.is-on {
  color: var(--brand);
}

.tag-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  color: var(--brand);
}

.tag-check .icon {
  font-size: 14px;
}

.tag-picker-name {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-picker-count {
  font-size: 11px;
  color: var(--text-3);
  flex: 0 0 auto;
}

.tag-picker-new {
  display: flex;
  gap: 6px;
  padding: 6px 4px 2px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

.tag-picker-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
  font-size: 13px;
  outline: none;
}

.tag-picker-input:focus {
  border-color: var(--brand);
}

/* 未选择便签时的占位 */
.editor-empty {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-3);
}

.editor-empty .brand-logo {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  font-size: 28px;
}

/* -------------------------------- 日历视图 -------------------------------- */

.view-pane {
  display: none;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-panel);
  overflow: hidden;
}

/* 日历 / 账号管理 占用中栏 + 右栏的整块区域；同一时刻只显示其中一个 */
.app[data-view='calendar'],
.app[data-view='admin'] {
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
}

.app[data-view='calendar'] .view-pane,
.app[data-view='admin'] .view-pane {
  display: none;
}

.app[data-view='calendar'] #calendar-pane,
.app[data-view='admin'] #admin-pane {
  display: flex;
  grid-column: 2;
  grid-row: 1;
}

.app[data-view='calendar'] .list-pane,
.app[data-view='calendar'] .editor-pane,
.app[data-view='admin'] .list-pane,
.app[data-view='admin'] .editor-pane {
  display: none;
}

.calendar-wrap {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 20px 24px 60px;
}

.calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.calendar-nav {
  display: flex;
  align-items: center;
  gap: 10px;
}

.calendar-nav h2 {
  margin: 0;
  font-size: 19px;
  min-width: 128px;
  text-align: center;
}

.calendar-grid {
  max-width: 1000px;
}

.calendar-weekdays,
.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar-weekdays div {
  padding: 6px 8px;
  font-size: 12px;
  color: var(--text-3);
}

.calendar-days {
  gap: 6px;
  margin-top: 2px;
}

.calendar-day {
  min-height: 92px;
  padding: 6px 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
  text-align: left;
  overflow: hidden;
  transition: border-color 0.15s, background 0.15s;
}

.calendar-day:hover {
  border-color: var(--border-strong);
}

.calendar-day.is-out {
  opacity: 0.42;
}

.calendar-day.is-today {
  border-color: var(--brand);
}

.calendar-day.is-selected {
  background: var(--brand-weak);
  border-color: var(--brand);
}

.calendar-day .day-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  font-size: 12px;
  color: var(--text-2);
}

.calendar-day.is-today .day-num {
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
}

.calendar-day .day-notes {
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.calendar-day .day-note {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.calendar-day .day-note:hover {
  color: var(--brand);
}

.calendar-day .day-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--yellow);
  flex: 0 0 auto;
}

.calendar-day .day-more {
  font-size: 11px;
  color: var(--text-3);
}

/* 日历选中的那天的便签列表 */
.calendar-daylist {
  max-width: 1000px;
  margin-top: 22px;
}

.calendar-daylist h3 {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--text-2);
}

/* ============================== 账号管理后台 ============================== */

.admin-wrap {
  flex: 1 1 auto;
  min-height: 0;
  padding: 20px 24px 60px;
}

.admin-inner {
  max-width: 1080px;
}

.admin-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.admin-head h2 {
  margin: 0 0 4px;
  font-size: 19px;
}

.admin-head p {
  margin: 0;
  font-size: 13px;
  color: var(--text-3);
}

/* 站点总览卡片 */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.stat-card {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-sunken);
}

.stat-card .stat-value {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.3;
}

.stat-card .stat-label {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-3);
}

/* 账号表格 */
.admin-section {
  margin-bottom: 24px;
}

.admin-section > h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--text-2);
}

.admin-section > h3 .list-count {
  font-size: 12px;
  color: var(--text-3);
  font-weight: 400;
}

.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

table.users {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.users th,
table.users td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table.users thead th {
  background: var(--bg-sunken);
  color: var(--text-3);
  font-weight: 500;
  font-size: 12px;
  white-space: nowrap;
}

table.users tbody tr:last-child td {
  border-bottom: none;
}

table.users tbody tr:hover {
  background: var(--bg-hover);
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.user-cell .user-name-text {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: inline-block;
  margin-left: 5px;
  padding: 1px 6px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 400;
  line-height: 16px;
  vertical-align: 1px;
  background: var(--bg-active);
  color: var(--text-2);
}

.badge-admin {
  background: rgba(43, 108, 246, 0.14);
  color: var(--brand);
}

.badge-self {
  background: rgba(60, 196, 124, 0.16);
  color: var(--success);
}

.cell-muted {
  color: var(--text-3);
  font-size: 12px;
  white-space: nowrap;
}

/* 已用空间 + 配额进度 */
.usage {
  min-width: 118px;
}

.usage-text {
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
}

.usage-bar {
  height: 4px;
  margin-top: 5px;
  border-radius: 2px;
  background: var(--bg-active);
  overflow: hidden;
}

.usage-bar > span {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--brand);
}

.usage-bar.is-warn > span {
  background: var(--yellow);
}

.usage-bar.is-full > span {
  background: var(--danger);
}

.row-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
  flex-wrap: nowrap;
}

.row-actions .btn {
  height: 26px;
  padding: 0 8px;
  font-size: 12px;
  border: 1px solid var(--border-strong);
  background: var(--bg-panel);
}

.row-actions .btn:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-weak);
}

.row-actions .btn-danger:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(233, 75, 75, 0.08);
}

/* 设置区 */
.settings-grid {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-sunken);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.setting-row .setting-text strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
}

.setting-row .setting-text span {
  font-size: 12px;
  color: var(--text-3);
}

.setting-control {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.input-sm {
  width: 96px;
  height: 30px;
  padding: 0 9px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
  font-size: 13px;
  outline: none;
}

.input-sm:focus {
  border-color: var(--brand);
}

/* 开关 */
.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex: 0 0 auto;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

.switch .track {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  background: var(--border-strong);
  transition: background 0.18s;
  pointer-events: none;
}

.switch .track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.18s;
}

.switch input:checked + .track {
  background: var(--brand);
}

.switch input:checked + .track::after {
  transform: translateX(18px);
}

/* 窄屏：表格改为卡片式 */
@media (max-width: 720px) {
  .admin-wrap {
    padding: 14px 12px 60px;
  }

  .table-wrap {
    border: none;
  }

  table.users thead {
    display: none;
  }

  table.users,
  table.users tbody,
  table.users tr,
  table.users td {
    display: block;
    width: 100%;
  }

  table.users tr {
    position: relative;
    margin-bottom: 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-panel);
  }

  table.users td {
    padding: 0;
    border: none;
  }

  table.users td + td {
    margin-top: 6px;
  }

  table.users td.cell-actions {
    margin-top: 10px;
  }

  .row-actions {
    justify-content: flex-start;
  }
}

/* -------------------------------- 弹层菜单 -------------------------------- */
.menu-pop {
  position: fixed;
  z-index: 700;
  min-width: 150px;
  /* 不超出窗口：弹层内部自己滚动 */
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
  box-shadow: var(--shadow);
}

.menu-pop button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  text-align: left;
}

.menu-pop button:hover {
  background: var(--bg-hover);
}

.menu-pop button.is-danger {
  color: var(--danger);
}

.menu-pop .menu-sep {
  height: 1px;
  margin: 5px 4px;
  background: var(--border);
}

.menu-pop .menu-head {
  padding: 7px 10px 5px;
  font-size: 12px;
  color: var(--text-3);
}

/* -------------------------------- 移动端顶栏 -------------------------------- */

.mobile-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: var(--header-h);
  padding: 0 8px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  flex: 0 0 auto;
}

.mobile-header h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

.mobile-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* --------------------------------- 遮罩 --------------------------------- */

.drawer-mask {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 90;
  background: var(--bg-mask);
}

/* ==========================================================================
   响应式：<= 860px 走移动端布局
   ========================================================================== */

@media (max-width: 860px) {
  .app {
    display: block;
    height: 100dvh;
    position: relative;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    width: 260px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    transform: translateX(-102%);
    transition: transform 0.22s ease;
  }

  .app.drawer-open .sidebar {
    transform: none;
  }

  .app.drawer-open .drawer-mask {
    display: block;
  }

  .list-pane {
    height: 100dvh;
    border-right: none;
  }

  .mobile-header {
    display: flex;
  }

  .list-head {
    display: none;
  }

  /* 编辑器变成整屏滑出 */
  .editor-pane {
    position: fixed;
    inset: 0;
    z-index: 110;
    background: var(--bg-panel);
    transform: translateX(102%);
    transition: transform 0.22s ease;
    visibility: hidden;
  }

  .app.editor-open .editor-pane {
    transform: none;
    visibility: visible;
  }

  .app[data-mode='list-only'] .editor-pane {
    display: flex;
  }

  .editor-toolbar {
    padding: 0 6px;
    gap: 0;
  }

  .editor-toolbar .tool-hide-mobile {
    display: none;
  }

  /* 手机端左上角的返回按钮 */
  .editor-toolbar .tool-back {
    display: inline-flex;
  }

  .editor-toolbar .tool-sep.tool-back {
    display: block;
  }

  .tool-back {
    margin-right: 2px;
    color: var(--text);
  }

  .tool-spacer {
    display: none;
  }

  /* 手机端顶部信息区：保存状态 + 标签 */
  .editor-topbar {
    display: flex;
  }

  /* 手机端底部信息栏仍然隐藏（内容改到顶部了） */
  .editor-meta {
    display: none;
  }

  .note-content {
    padding: 18px 18px 140px;
    font-size: 16px;
  }

  .view-pane {
    position: fixed;
    inset: 0;
    z-index: 105;
  }

  /* 手机端日历 / 账号管理整屏显示，导航交给左上角抽屉按钮 */
  .app[data-view='calendar'],
  .app[data-view='admin'] {
    display: block;
  }

  .app[data-view='calendar'] .sidebar,
  .app[data-view='admin'] .sidebar {
    transform: translateX(-102%);
  }

  .app[data-view='calendar'].drawer-open .sidebar,
  .app[data-view='admin'].drawer-open .sidebar {
    transform: none;
  }

  .app[data-view='calendar'] #calendar-pane,
  .app[data-view='admin'] #admin-pane {
    grid-column: auto;
  }

  .app[data-view='calendar'] .list-pane,
  .app[data-view='admin'] .list-pane {
    display: none;
  }

  .calendar-wrap {
    padding: 14px 12px 60px;
  }

  .calendar-day {
    min-height: 62px;
    padding: 4px;
  }

  .calendar-day .day-note {
    font-size: 11px;
  }

  .note-card {
    padding: 12px 10px 10px 12px;
  }

  .toast-host {
    bottom: 24px;
  }
}

/* 中等屏幕收窄列表栏 */
@media (min-width: 861px) and (max-width: 1180px) {
  :root {
    --sidebar-w: 200px;
    --list-w: 290px;
  }

  .note-content {
    padding: 32px 32px 140px;
  }
}
