* {
  box-sizing: border-box;
}

:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --border: #e5e7eb;
  --border-light: #f0f1f3;
  --text: #1f2328;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

/* ---------------- 登录页 ---------------- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px 28px;
}

.login-card h1 {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 500;
}

.login-card .sub {
  margin: 0 0 24px;
  font-size: 13px;
  color: var(--muted);
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--muted);
}

input[type="text"],
input[type="password"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
}

textarea {
  resize: vertical;
  min-height: 88px;
  line-height: 1.7;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover {
  background: #fafafa;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-danger {
  color: var(--danger);
  border-color: #f3d3d3;
}

.btn-danger:hover {
  background: #fdf3f3;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.alert {
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  background: #fdeceb;
  color: #b91c1c;
  border: 1px solid #f7d4d1;
}

/* ---------------- 后台框架 ---------------- */

.topbar {
  height: 56px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-title {
  font-size: 15px;
  font-weight: 500;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
}

.main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.toolbar .spacer {
  flex: 1;
}

.toolbar select,
.toolbar input[type="search"] {
  width: auto;
  min-width: 140px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  text-align: left;
  font-weight: 500;
  font-size: 13px;
  color: var(--muted);
  padding: 12px 16px;
  background: #fafbfc;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

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

tbody tr:hover {
  background: #fafbfc;
}

.cell-title {
  font-weight: 500;
  max-width: 380px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-sub {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  max-width: 380px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.6;
  white-space: nowrap;
}

.tag-notice { background: #eef2ff; color: #4338ca; }
.tag-event { background: #ecfdf5; color: #047857; }
.tag-maintenance { background: #fff7ed; color: #c2410c; }
.tag-published { background: #ecfdf5; color: #047857; }
.tag-draft { background: #f3f4f6; color: #6b7280; }
.tag-pinned { background: #fef3c7; color: #b45309; }

.row-actions {
  display: flex;
  gap: 8px;
  white-space: nowrap;
}

.link-btn {
  background: none;
  border: none;
  padding: 2px 4px;
  color: var(--primary);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}

.link-btn:hover {
  text-decoration: underline;
}

.link-btn.danger {
  color: var(--danger);
}

.empty {
  padding: 56px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  font-size: 13px;
  color: var(--muted);
}

/* ---------------- 编辑弹层 ---------------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.35);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 16px;
  overflow-y: auto;
  z-index: 50;
}

.overlay.open {
  display: flex;
}

.panel {
  width: 100%;
  max-width: 720px;
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 24px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.panel-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
}

.checkline input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.blocks {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.block {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fafbfc;
}

.block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--muted);
}

.block-tools {
  display: flex;
  gap: 4px;
}

.icon-btn {
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.icon-btn.danger:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.block textarea {
  min-height: 72px;
  border-color: var(--border);
  background: #fff;
}

.block-image img {
  max-width: 100%;
  max-height: 240px;
  border-radius: 6px;
  display: block;
  border: 1px solid var(--border);
}

.block-image .missing {
  font-size: 13px;
  color: var(--muted);
}

.add-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.panel-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%) translateY(12px);
  background: #1f2328;
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  background: #b91c1c;
}

/* ================= 左侧导航布局 ================= */

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 208px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--border-light);
}

.brand-name {
  font-size: 15px;
  font-weight: 500;
}

.brand-sub {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

.nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: block;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover {
  background: #f5f6f8;
}

.nav-item.active {
  background: #eef2ff;
  color: var(--primary);
  font-weight: 500;
}

.sidebar-foot {
  padding: 14px 10px 18px;
  border-top: 1px solid var(--border-light);
}

.logout-btn {
  width: 100%;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}

.logout-btn:hover {
  color: var(--danger);
  border-color: #f3d3d3;
}

.content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.page-head {
  height: 56px;
  flex-shrink: 0;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.page-title {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
}

.page-body {
  padding: 24px 28px 48px;
}

.view[hidden] {
  display: none;
}

/* ================= 标签胶囊 ================= */

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.6;
  white-space: nowrap;
}

.pill-version {
  background: #e8f0fe;
  color: #2563eb;
}

.pill-guide {
  background: #e8f9ef;
  color: #1a7f45;
}

.pill-event {
  background: #fff4e6;
  color: #c2410c;
}

.pill-pin {
  background: #fff7d6;
  color: #b07d00;
}

.pill-custom {
  background: #f2f3f5;
  color: #6b7280;
}

.pill-popup {
  background: #fdeceb;
  color: #c0392b;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* ================= 图标选择 ================= */

.icon-picker {
  display: flex;
  align-items: center;
  gap: 14px;
}

.icon-preview {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: #f5f6f8;
}

.icon-preview.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--tertiary, #b4b2a9);
}

.icon-cell {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: #f5f6f8;
  display: block;
}

.hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
}

@media (max-width: 900px) {
  .sidebar {
    width: 64px;
  }
  .brand-sub,
  .nav-item {
    font-size: 0;
  }
  .nav-item {
    text-align: center;
    padding: 12px 0;
  }
  .nav-item::first-letter {
    font-size: 14px;
  }
  .page-body {
    padding: 16px;
  }
}

@media (max-width: 640px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
  .main {
    padding: 16px;
  }
  .cell-title,
  .cell-sub {
    max-width: 200px;
  }
}

/* ================= 左右分栏编辑器 ================= */

#aOverlay,
#nOverlay {
  align-items: stretch;
  padding: 24px;
}

.editor {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  background: #fff;
  border-radius: 14px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: calc(100vh - 48px);
}

.editor-bar {
  height: 56px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}

.editor-bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.editor-title {
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.editor-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
  border-radius: 7px;
}

.btn.active {
  background: #fff7d6;
  border-color: #f0d78c;
  color: #b07d00;
}

.editor-body {
  display: flex;
  min-height: 0;
  flex: 1;
}

.editor-pane {
  flex: 1;
  min-width: 0;
  padding: 24px 28px 28px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.title-input {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 6px 0 14px;
  font-size: 22px;
  font-weight: 500;
  color: var(--text);
  outline: none;
  background: transparent;
  font-family: inherit;
}

.title-input::placeholder {
  color: #c0c4cc;
  font-weight: 400;
}

.title-input:focus {
  border-bottom-color: var(--primary);
}

.field-row {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.field-row select {
  width: 124px;
  flex-shrink: 0;
}

.field-row input {
  flex: 1;
  min-width: 0;
}

.pane-label {
  margin: 22px 0 10px;
  font-size: 13px;
  color: var(--muted);
}

.pane-sub {
  font-size: 13px;
  color: var(--muted);
}

.icon-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}

.icon-row .icon-preview {
  width: 44px;
  height: 44px;
  border-radius: 8px;
}

.editor-pane .block textarea {
  min-height: 132px;
  font-size: 14px;
  line-height: 1.8;
}

/* ================= 预览面板 ================= */

.preview-pane {
  width: 380px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: #fafbfc;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.preview-head {
  height: 44px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 0 20px;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--border-light);
}

.preview-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.preview-card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 20px 18px;
  min-height: 120px;
}

.pv-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.pv-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  flex-shrink: 0;
  object-fit: cover;
  border: 1px solid var(--border);
  background: #f5f6f8;
}

.pv-icon-ph {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #9aa0a6;
  background: #f2f3f5;
}

.pv-title {
  font-size: 17px;
  font-weight: 500;
  color: #222;
  line-height: 1.45;
  word-break: break-word;
}

.pv-title.placeholder {
  color: #c0c4cc;
  font-weight: 400;
}

.pv-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-light);
}

.pv-time {
  margin-left: auto;
  font-size: 12px;
  color: #aaa;
}

.pv-content {
  margin-top: 14px;
}

.pv-para {
  font-size: 13px;
  color: #444;
  line-height: 1.8;
  margin: 0 0 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.pv-img {
  width: 100%;
  border-radius: 8px;
  margin-bottom: 12px;
  display: block;
  background: #f5f6f8;
}

.pv-empty {
  font-size: 13px;
  color: #bbb;
  padding: 28px 0;
  text-align: center;
}

@media (max-width: 1000px) {
  .preview-pane {
    display: none;
  }
}
