:root {
  --bg: #eef3f9;
  --bg-deep: #e4ecf6;
  --surface: #ffffff;
  --text: #0b1220;
  --muted: #5b6b7c;
  --faint: #8a97a8;
  --accent: #2d7ff9;
  --accent-hover: #1a6ae8;
  --accent-soft: rgba(45, 127, 249, 0.12);
  --border: #dce5f0;
  --danger: #dc2626;
  --ok: #059669;
  --radius: 14px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-display: "Segoe UI Variable", "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --shadow: 0 12px 36px rgba(15, 35, 70, 0.08);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(900px 420px at 0% -10%, rgba(45, 127, 249, 0.14), transparent 55%),
    linear-gradient(180deg, #f8fbff 0%, var(--bg) 45%, var(--bg-deep) 100%);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button {
  border: 0;
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  line-height: 1.3;
}
button:hover { background: var(--accent-hover); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
button.ghost:hover { background: var(--accent-soft); color: var(--accent); }
button.danger { background: var(--danger); color: #fff; }
button.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.topbar {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}
.brand .mark {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(145deg, #3b8bff, #1f6fe8);
  color: #fff; display: grid; place-items: center; font-size: 15px;
}
.brand small { font-weight: 500; color: var(--faint); font-family: var(--font); margin-left: 4px; }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.status {
  font-size: 13px; color: var(--muted);
  min-width: 100px; text-align: right;
}
.status.ok { color: var(--ok); }
.status.warn { color: #c47a00; }
.status.err { color: var(--danger); }

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 320px) minmax(0, 1fr) minmax(260px, 300px);
  gap: 12px;
  padding: 12px;
  height: calc(100vh - 60px);
  min-height: 520px;
  align-items: stretch;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  position: relative;
}
.panel h2 {
  margin: 0;
  padding: 14px 16px 10px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex: 0 0 auto;
}

/* 关键：纵向流式排布，禁止子项绝对定位叠在一起 */
.panel-body {
  flex: 1 1 auto;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 14px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

.stack-block {
  display: block;
  position: relative;
  width: 100%;
  flex: 0 0 auto;
  min-width: 0;
}

.field { margin: 0; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 6px;
  line-height: 1.4;
}
.field input,
.field select,
.field textarea {
  display: block;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fbfcfe;
  margin: 0;
}
.field textarea {
  min-height: 120px;
  resize: vertical;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}
.field-check { margin: 0; }
.check-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-size: 13px !important;
  font-weight: 500 !important;
  color: var(--text) !important;
  cursor: pointer;
  margin: 0 !important;
}
.check-label input { width: auto !important; margin: 0; }

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  min-height: 88px;
  border: 1.5px dashed #b7c7da;
  border-radius: 12px;
  padding: 16px 12px;
  text-align: center;
  color: var(--muted);
  background: #f7fafc;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  user-select: none;
}
.dropzone:hover,
.dropzone.drag,
.dropzone:focus {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  outline: none;
}
.dropzone strong {
  display: block;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
}
.dropzone:hover strong,
.dropzone.drag strong { color: var(--accent); }
.dropzone-sub {
  display: block;
  font-size: 12px;
  line-height: 1.4;
  color: inherit;
}

.cat-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
}
.cat-list:empty { display: none; }
.cat-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  background: #fbfcfe;
}
.cat-item.active { border-color: var(--accent); background: var(--accent-soft); }
.cat-item .name {
  font-weight: 600;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.cat-item .meta { font-size: 11px; color: var(--faint); flex-shrink: 0; }

.item-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
}
.item-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: #fbfcfe;
}
.item-card .row { display: flex; gap: 6px; margin-top: 6px; }
.item-card .row > * { flex: 1; min-width: 0; }
.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  justify-content: flex-end;
}

.preview-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
  min-height: 360px;
  flex: 1 1 auto;
}
.preview-wrap { min-width: 0; }
.preview-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  font-size: 12px;
  color: var(--muted);
  flex: 0 0 auto;
}
.preview-toolbar .spacer { flex: 1; }

.hint {
  font-size: 12px;
  color: var(--faint);
  line-height: 1.5;
  margin: 0;
}
.block-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 8px;
}
.layout-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.layout-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fbfcfe;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
}
.layout-card:hover { border-color: var(--accent); background: var(--accent-soft); }
.layout-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
  background: #fff;
}
.layout-card .desc {
  font-size: 11px;
  font-weight: 500;
  color: var(--faint);
}
.theme-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.theme-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fbfcfe;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  line-height: 1.3;
}
.theme-card:hover { border-color: var(--accent); background: var(--accent-soft); }
.theme-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
  background: #fff;
}
.theme-card .swatch {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  margin-bottom: 2px;
}
.theme-card .desc {
  font-size: 11px;
  font-weight: 500;
  color: var(--faint);
}
.auth-box {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: #f8fafc;
}
.auth-box .row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.auth-box .row > input { flex: 1 1 100px; min-width: 0; }
.doc-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow: auto;
  margin-top: 8px;
}
.doc-chip {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 6px;
  background: #fff;
}
.doc-chip:hover { border-color: var(--accent); }

.publish-box {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: #f0f7ff;
}
.publish-box .row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.dropzone.raw {
  background: linear-gradient(135deg, #fff7ed, #fff);
  border-color: #fdba74;
}
.dropzone.raw:hover,
.dropzone.raw.drag {
  border-color: #ea580c;
  background: #ffedd5;
}
.dropzone.incremental {
  background: linear-gradient(135deg, #ecfdf5, #fff);
  border-color: #6ee7b7;
}
.dropzone.incremental:hover,
.dropzone.incremental.drag {
  border-color: #059669;
  background: #d1fae5;
}

.auth-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
}
.auth-tab {
  flex: 1;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
  cursor: pointer;
  color: var(--muted);
}
.auth-tab.active {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, #fff);
  font-weight: 600;
}
.account-panel {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.acct-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: #fff;
}
.acct-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13px;
}
.acct-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
}
.acct-empty {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}
.acct-empty.bad { color: #b91c1c; }
.acct-item {
  border: 1px solid #eef2f7;
  border-radius: 8px;
  padding: 8px;
  background: #fafbfc;
}
.acct-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.acct-meta, .acct-id {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  word-break: break-all;
}
.acct-urls { margin-top: 6px; display: flex; flex-direction: column; gap: 8px; }
.acct-url {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 4px 8px;
  align-items: center;
  font-size: 12px;
}
.acct-url-label {
  font-size: 11px;
  color: var(--muted);
}
.acct-url a {
  color: var(--accent);
  word-break: break-all;
  grid-column: 2 / 3;
}
.acct-qr {
  grid-column: 1 / -1;
  justify-self: start;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
}

.publish-result {
  margin-top: 10px;
  padding: 10px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--border);
  font-size: 12px;
  line-height: 1.5;
  word-break: break-all;
}
.publish-result a { color: var(--accent); font-weight: 600; }
.publish-result img { display: block; margin-top: 8px; width: 120px; height: 120px; }

/* ===== 功能计费弹窗（对齐 Kore-Bookmark） ===== */
.fb-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.fb-modal.hidden { display: none; }
.fb-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}
.fb-panel {
  position: relative;
  width: min(440px, 100%);
  max-height: min(90vh, 720px);
  overflow: auto;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.2);
  padding: 22px 22px 18px;
  color: #0f172a;
}
.fb-x {
  position: absolute;
  top: 10px;
  right: 12px;
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  color: #94a3b8;
  cursor: pointer;
}
.fb-title { margin: 0 0 8px; font-size: 17px; font-weight: 700; }
.fb-desc { margin: 0 0 14px; font-size: 13px; line-height: 1.55; color: #64748b; }
.fb-status {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 14px;
}
.fb-status .ok { color: #059669; }
.fb-status .bad { color: #dc2626; }
.fb-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}
.fb-btn {
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #0f172a;
}
.fb-btn.primary {
  background: #2d7ff9;
  border-color: #2d7ff9;
  color: #fff;
}
.fb-btn.primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.fb-btn.ghost { background: #fff; }
.fb-btn.sm { padding: 6px 10px; font-size: 12px; }
.fb-link {
  display: block;
  width: 100%;
  margin-top: 12px;
  border: none;
  background: none;
  color: #2d7ff9;
  font-size: 13px;
  cursor: pointer;
  text-align: center;
}
.fb-balance {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
}
.fb-balance-label { font-size: 12px; color: #64748b; }
.fb-balance-val { font-size: 20px; font-weight: 700; color: #1d4ed8; }
.fb-pay-tabs { display: flex; gap: 8px; margin: 10px 0; }
.fb-pay-tab {
  flex: 1;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.fb-pay-tab.on {
  border-color: #2d7ff9;
  background: #eff6ff;
  color: #1d4ed8;
}
.fb-qr-box { text-align: center; margin-bottom: 14px; }
.fb-qr-box img {
  width: min(220px, 70vw);
  height: auto;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}
.fb-qr-hint {
  margin-top: 8px;
  font-size: 12px;
  color: #64748b;
  line-height: 1.5;
  text-align: left;
}
.fb-sub { margin: 4px 0 8px; font-size: 13px; }
.fb-skus { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fb-sku {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #fff;
  cursor: pointer;
  text-align: left;
}
.fb-sku:hover { border-color: #2d7ff9; background: #f8fbff; }
.fb-sku-name { font-size: 13px; font-weight: 600; }
.fb-sku-price { font-size: 14px; color: #1d4ed8; font-weight: 700; }
.fb-codes {
  margin-top: 12px;
  padding: 10px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
}
.fb-codes-title { font-size: 12px; color: #64748b; margin-bottom: 6px; }
.fb-codes pre {
  margin: 0;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
}
.fb-empty { font-size: 13px; color: #94a3b8; padding: 8px; }
.fb-view.hidden { display: none; }
body.fb-modal-open { overflow: hidden; }

.nav-toast-box {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10001;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.nav-toast {
  background: #0f172a;
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.25);
}
.nav-toast.ok { background: #059669; }
.nav-toast.err { background: #dc2626; }

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 1fr;
    height: auto;
  }
  .preview-wrap { height: 60vh; }
  .panel-left, .panel-right { max-height: none; }
}
