/* 内嵌编辑器样式 — 长按关于我触发 */
.admin-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(30,20,12,.92);
  display: flex; align-items: center; justify-content: center;
  animation: adminFadeIn .25s ease;
}
@keyframes adminFadeIn { from { opacity: 0 } to { opacity: 1 } }

.admin-dialog {
  width: min(calc(100vw - 40px), 440px);
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--rule);
  padding: 28px 30px;
  font-family: "Noto Serif SC", "Songti SC", Georgia, serif;
}
.admin-dialog h2 { margin: 0 0 8px; font-size: 1.3rem; }
.admin-dialog p { margin: 0 0 16px; color: var(--muted); font-size: .85rem; }
.admin-dialog input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--rule);
  background: var(--bg, #f2e8d3); color: var(--ink);
  font: inherit; font-size: .95rem; outline: none;
}
.admin-dialog input:focus { border-color: var(--accent) }
.admin-dialog .err { color: #c0392b; font-size: .82rem; margin-top: 8px; display: none }
.admin-dialog .actions { display: flex; gap: 8px; margin-top: 16px; justify-content: flex-end }
.admin-dialog .btn {
  padding: 7px 18px; border: 1px solid var(--rule);
  background: transparent; color: var(--ink);
  cursor: pointer; font: inherit; font-size: .85rem;
}
.admin-dialog .btn.primary { background: var(--accent); color: #fff8eb; border-color: var(--accent) }

/* 编辑面板 */
.editor-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--paper);
  display: flex; flex-direction: column;
  animation: adminFadeIn .2s ease;
}
.editor-toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; border-bottom: 1px solid var(--rule);
  background: var(--paper-deep);
}
.editor-toolbar .brand { font-family: Georgia, serif; font-size: 1.2rem; font-weight: 700; text-decoration: none; color: var(--ink) }
.editor-toolbar .spacer { flex: 1 }
.editor-toolbar .btn {
  padding: 6px 14px; border: 1px solid var(--rule);
  background: transparent; color: var(--ink);
  cursor: pointer; font: inherit; font-size: .82rem;
}
.editor-toolbar .btn:hover { border-color: var(--ink) }
.editor-toolbar .btn.primary { background: var(--accent); color: #fff8eb; border-color: var(--accent) }
.editor-toolbar .btn.danger { color: #c0392b; border-color: #c0392b }

.editor-body { display: flex; flex: 1; overflow: hidden }
.editor-sidebar { width: 240px; border-right: 1px solid var(--rule); overflow-y: auto; padding: 12px; background: var(--paper-deep) }
.editor-sidebar h3 { font-size: .82rem; color: var(--muted); margin: 0 0 8px }
.editor-post-item { padding: 8px 10px; cursor: pointer; margin-bottom: 3px; border: 1px solid transparent; font-size: .82rem }
.editor-post-item:hover { border-color: var(--rule); background: var(--paper) }
.editor-post-item.active { border-color: var(--accent); background: var(--paper) }
.editor-post-item .ptitle { font-weight: 600 }
.editor-post-item .pmeta { color: var(--muted); font-size: .72rem; margin-top: 2px }

.editor-main { flex: 1; overflow-y: auto; padding: 24px 30px }
.editor-main .field { margin-bottom: 14px }
.editor-main label { display: block; font-size: .78rem; font-weight: 600; color: var(--muted); margin-bottom: 3px }
.editor-main input, .editor-main textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--rule);
  background: var(--bg, #f2e8d3); color: var(--ink);
  font: inherit; font-size: .88rem; outline: none;
}
.editor-main input:focus, .editor-main textarea:focus { border-color: var(--accent) }
.editor-main textarea { resize: vertical; min-height: 260px; font-family: "Cascadia Code", Consolas, monospace; font-size: .82rem; line-height: 1.7 }
.editor-main .row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px }
.editor-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 40px; border: 1px solid var(--rule); padding: 6px 9px; background: var(--panel) }
.editor-tags .tag-pill { display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px; border: 1px solid var(--accent); color: var(--accent); font-size: .75rem }
.editor-tags .tag-pill button { border: none; background: none; color: var(--accent); cursor: pointer; font-size: .9rem; padding: 0 2px; line-height: 1 }
.editor-tags input { border: none !important; flex: 1; min-width: 80px; background: transparent !important; padding: 4px 0 !important }
.tag-suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px }
.tag-suggestions button {
  border: 1px solid var(--rule); background: transparent; color: var(--muted);
  padding: 3px 9px; cursor: pointer; font: inherit; font-size: .74rem;
}
.tag-suggestions button:hover { border-color: var(--accent); color: var(--accent) }
.markdown-field { min-height: 0 }
.md-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px }
.md-head label { margin: 0 }
.md-mode button, .md-toolbar button {
  border: 1px solid var(--rule); background: transparent; color: var(--ink);
  cursor: pointer; font: inherit; font-size: .78rem;
}
.md-mode button { padding: 4px 10px }
.md-mode button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff8eb }
.md-toolbar {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; border: 1px solid var(--rule);
  border-bottom: 0; background: var(--paper-deep);
}
.md-toolbar button { min-width: 34px; min-height: 30px; padding: 3px 9px }
.md-toolbar button:hover { border-color: var(--accent); color: var(--accent) }
.md-workbench {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  border: 1px solid var(--rule); min-height: 460px; background: var(--panel);
}
.md-workbench.dragging { outline: 2px solid var(--accent); outline-offset: 3px }
.md-workbench textarea {
  min-height: 460px; resize: none; border: 0; border-right: 1px solid var(--rule);
  background: rgba(255,249,237,.22); line-height: 1.8; tab-size: 2;
}
.md-preview {
  min-width: 0; max-height: 620px; overflow: auto; padding: 16px 18px; background: rgba(255,249,237,.16);
}
.md-preview img { max-width: 100%; height: auto; border: 1px solid var(--rule); display: block; margin: 12px 0 }
.md-preview table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: .84rem; }
.md-preview th, .md-preview td { border: 1px solid var(--rule); padding: 8px 10px; text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.md-preview th { background: var(--paper-deep); font-weight: 700; }
.md-workbench.preview-off { grid-template-columns: 1fr }
.md-workbench.preview-off .md-preview { display: none }
.md-workbench.preview-off textarea { border-right: 0 }
.md-help { margin-top: 7px; color: var(--muted); font-size: .74rem }

.table-editor-overlay {
  position: fixed; inset: 0; z-index: 100000;
  background: rgba(30,20,12,.55); display: flex; align-items: center; justify-content: center; padding: 20px;
}
.table-editor-dialog {
  width: min(100%, 900px); max-height: calc(100vh - 40px); display: flex; flex-direction: column;
  background: var(--paper); color: var(--ink); border: 1px solid var(--rule); box-shadow: 0 18px 60px rgba(0,0,0,.28);
}
.table-editor-head { display: flex; align-items: center; gap: 20px; padding: 16px 18px 12px; border-bottom: 1px solid var(--rule); }
.table-editor-head h3 { margin: 0 0 3px; font-size: 1rem; }
.table-editor-head p { margin: 0; color: var(--muted); font-size: .76rem; }
.table-editor-size { margin-left: auto; color: var(--muted); font-size: .76rem; white-space: nowrap; }
.table-editor-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; padding: 10px 18px; border-bottom: 1px solid var(--rule); background: var(--paper-deep); }
.table-editor-toolbar .spacer { flex: 1; }
.table-editor-toolbar button {
  min-height: 31px; padding: 4px 11px; border: 1px solid var(--rule); background: transparent; color: var(--ink);
  cursor: pointer; font: inherit; font-size: .78rem;
}
.table-editor-toolbar button:hover { border-color: var(--accent); color: var(--accent); }
.table-editor-toolbar button.primary { background: var(--accent); border-color: var(--accent); color: #fff8eb; }
.table-editor-grid { overflow: auto; padding: 16px 18px 18px; }
.table-editor-grid table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.table-editor-grid th, .table-editor-grid td { min-width: 110px; padding: 0; border: 1px solid var(--rule); }
.table-editor-grid th { background: var(--paper-deep); }
.table-editor-grid input {
  width: 100%; min-width: 0; padding: 8px 9px; border: 0; background: transparent; color: var(--ink);
  font: inherit; font-size: .82rem; outline: none;
}
.table-editor-grid input:focus { background: rgba(255,249,237,.65); box-shadow: inset 0 0 0 2px var(--accent); }

.editor-toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 99999;
  padding: 10px 18px; font-size: .82rem; border-radius: 2px;
  box-shadow: 0 2px 10px rgba(0,0,0,.25); opacity: 0; transition: opacity .3s;
}
.editor-toast.show { opacity: 1 }
.editor-toast.ok { background: #27ae60; color: #fff }
.editor-toast.err { background: #c0392b; color: #fff }
.editor-toast.info { background: var(--ink); color: var(--paper) }

@media (max-width: 700px) {
  .editor-sidebar { display: none }
  .editor-main .row { grid-template-columns: 1fr }
  .editor-toolbar { flex-wrap: wrap }
  .md-workbench { grid-template-columns: 1fr }
  .md-workbench textarea { border-right: 0; border-bottom: 1px solid var(--rule) }
  .table-editor-overlay { padding: 10px; }
  .table-editor-dialog { max-height: calc(100vh - 20px); }
  .table-editor-head { align-items: flex-start; flex-direction: column; gap: 6px; }
  .table-editor-size { margin-left: 0; }
  .table-editor-toolbar button { flex: 1 1 88px; }
}
