/* ═══════════════════════════════════════════════════════════
   Editor v2.0 — Ghost-inspired writing shell
   Layered on styles.css; body.v2 activates.
   ═══════════════════════════════════════════════════════════ */

body.v2 {
  /* 寫作區約占編輯欄 80%（原 Ghost 式 720px 偏窄） */
  --write-max: 80%;
  /* 右側設定欄寬（SEO／文章） */
  --settings-w: 400px;
  background: #fff;
  min-height: 100vh;
}

body.v2 .v2-hidden,
body.v2 #capability-banner {
  display: none !important;
}

/* ── Top bar ── */
body.v2 .v2-top {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 52px;
  padding: 0 16px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(20, 24, 40, 0.06);
}
body.v2 .v2-top-left,
body.v2 .v2-top-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
body.v2 .v2-top .logo-text {
  font-size: 15px;
  font-weight: 800;
  color: var(--pd-ink, #14181f);
}
body.v2 .v2-top .logo-zh { display: none; }
body.v2 .v2-icon-btn,
body.v2 .v2-text-btn {
  border: 0;
  background: transparent;
  color: var(--pd-ink-2, #3a4150);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
}
body.v2 .v2-icon-btn:hover,
body.v2 .v2-text-btn:hover {
  background: var(--pd-accent-soft, #eaeaff);
  color: var(--pd-accent-deep, #6056db);
}
body.v2 .v2-primary-btn {
  border: 0;
  background: var(--pd-accent, #9999ff);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 4px 12px var(--pd-accent-glow, rgba(153, 153, 255, 0.28));
}
body.v2 .v2-primary-btn:hover {
  background: var(--pd-accent-deep, #6056db);
}
body.v2 .v2-article-pick select {
  max-width: 160px;
  border: 1px solid rgba(20, 24, 40, 0.1);
  border-radius: 8px;
  padding: 5px 8px;
  font: inherit;
  font-size: 12px;
  background: #fff;
  color: var(--pd-ink-2);
}

/* ── Workspace ── */
body.v2 .v2-workspace {
  min-height: calc(100vh - 52px);
  background: #fff;
  display: flex;
  align-items: stretch;
}
body.v2.list-collapsed .pane-list,
body.v2 .pane-list[hidden] {
  display: none !important;
}
body.v2:not(.list-collapsed) .pane-list {
  display: flex !important;
}
body.v2 .v2-pane {
  padding: 0 !important;
  max-width: none;
  flex: 1 1 auto;
  min-width: 0;
}

/* ── Ghost-like right settings (SEO / post) ── */
body.v2 .pane-settings {
  display: none;
  flex: 0 0 var(--settings-w, 400px);
  width: var(--settings-w, 400px);
  max-width: 100%;
  border-left: 1px solid rgba(20, 24, 40, 0.08);
  background: #fafafb;
  flex-direction: column;
  min-height: calc(100vh - 52px);
  max-height: calc(100vh - 52px);
  position: sticky;
  top: 52px;
  align-self: flex-start;
  /* above purple insert/drop lines (55–57) so they never cover settings */
  z-index: 60;
}
body.v2.settings-open .pane-settings {
  display: flex;
}
body.v2 .settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid rgba(20, 24, 40, 0.06);
  background: #fff;
  flex-shrink: 0;
}
body.v2 .settings-head strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: #1a1d26;
}
body.v2 .settings-sub {
  display: block;
  font-size: 11px;
  color: #8b91a1;
  margin-top: 2px;
  font-weight: 500;
}
body.v2 .settings-scroll {
  overflow: auto;
  padding: 8px 14px 28px;
  flex: 1 1 auto;
  -webkit-overflow-scrolling: touch;
}
body.v2 .settings-section {
  padding: 14px 0 6px;
  border-bottom: 1px solid rgba(20, 24, 40, 0.06);
}
body.v2 .settings-section:last-of-type {
  border-bottom: 0;
}
body.v2 .settings-h {
  margin: 0 0 12px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8b91a1;
}
body.v2 .sf-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}
body.v2 .sf-label {
  font-size: 12px;
  font-weight: 600;
  color: #3a4050;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
body.v2 .sf-count {
  font-style: normal;
  font-weight: 500;
  font-size: 11px;
  color: #9aa0b0;
}
body.v2 .sf-count.is-over {
  color: #d94848;
  font-weight: 700;
}
body.v2 .sf-field input[type="text"],
body.v2 .sf-field input[type="url"],
body.v2 .sf-field textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid rgba(20, 24, 40, 0.12);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  background: #fff;
  color: #222;
  resize: vertical;
}
body.v2 .sf-field input:focus,
body.v2 .sf-field textarea:focus {
  outline: none;
  border-color: var(--pd-accent, #9999ff);
  box-shadow: 0 0 0 3px rgba(153, 153, 255, 0.18);
}
body.v2 .sf-hint {
  font-size: 11px;
  color: #9aa0b0;
  line-height: 1.35;
}
body.v2 .sf-slug-row {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid rgba(20, 24, 40, 0.12);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}
body.v2 .sf-slug-prefix {
  flex: 0 0 auto;
  font-size: 11px;
  color: #9aa0b0;
  padding: 0 0 0 8px;
  white-space: nowrap;
  max-width: 42%;
  overflow: hidden;
  text-overflow: ellipsis;
}
body.v2 .sf-slug-row input {
  border: 0 !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  min-width: 0;
}
body.v2 .serp-preview {
  background: #fff;
  border: 1px solid rgba(20, 24, 40, 0.08);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(20, 24, 40, 0.04);
}
body.v2 .serp-url {
  font-size: 12px;
  color: #202124;
  margin-bottom: 4px;
  word-break: break-all;
}
body.v2 .serp-title {
  font-size: 16px;
  line-height: 1.3;
  color: #1a0dab;
  font-weight: 500;
  margin-bottom: 4px;
  word-break: break-word;
}
body.v2 .serp-desc {
  font-size: 13px;
  line-height: 1.45;
  color: #4d5156;
  word-break: break-word;
}
body.v2 .sf-og-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}
body.v2 .sf-og-thumb {
  width: 88px;
  height: 66px;
  border-radius: 8px;
  border: 1px dashed rgba(20, 24, 40, 0.15);
  background: #f0f1f5;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
body.v2 .sf-og-thumb.has-img {
  border-style: solid;
}
body.v2 .sf-og-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
body.v2 .sf-og-empty {
  font-size: 10px;
  color: #9aa0b0;
  text-align: center;
  padding: 4px;
  line-height: 1.3;
}
body.v2 .sf-og-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  justify-content: center;
}
body.v2 .sf-og-actions .ghost {
  font-size: 12px;
  padding: 6px 10px;
}
body.v2 .settings-footnote {
  font-size: 11px;
  color: #9aa0b0;
  line-height: 1.45;
  margin: 16px 0 0;
}
body.v2 #btn-settings-toggle.is-on {
  background: var(--pd-accent-soft, #eaeaff);
  color: var(--pd-accent-deep, #6056db);
  font-weight: 700;
}

@media (max-width: 1099px) {
  body.v2.settings-open .pane-settings {
    position: fixed;
    top: 52px;
    right: 0;
    bottom: 0;
    width: min(var(--settings-w, 400px), 92vw);
    max-height: none;
    box-shadow: -8px 0 28px rgba(20, 24, 40, 0.12);
  }
}
@media (max-width: 640px) {
  body.v2 .v2-top-right .v2-article-pick {
    max-width: 110px;
  }
}
body.v2 .v2-chrome {
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  background: #fff !important;
  min-height: calc(100vh - 52px);
}
body.v2 .v2-scroll {
  max-width: var(--write-max);
  width: var(--write-max);
  margin: 0 auto;
  padding: 28px 28px 120px;
  box-sizing: border-box;
}

/* Title + body paper */
body.v2 .writing-sheet {
  max-width: 100%;
  width: 100%;
  margin: 0 auto;
}
body.v2 .ed-meta {
  display: none; /* hide chips — Ghost is quiet */
}
body.v2 .title-input {
  width: 100%;
  border: 0 !important;
  outline: none !important;
  box-shadow: none !important;
  font-size: clamp(28px, 4vw, 36px) !important;
  font-weight: 800 !important;
  line-height: 1.25 !important;
  letter-spacing: -0.03em;
  padding: 8px 0 12px !important;
  margin: 0 !important;
  background: transparent !important;
  color: var(--pd-ink);
}
body.v2 .title-input::placeholder {
  color: #c5c5d0;
  font-weight: 700;
}
body.v2 .title-hint {
  display: none;
}
body.v2 .cover-slot {
  margin: 8px 0 20px;
  border-radius: 12px;
  border-style: dashed;
  border-color: rgba(20, 24, 40, 0.1);
  min-height: 120px;
}
body.v2 .cover-slot.has-img {
  border: 0;
  min-height: 0;
}
body.v2 .cover-slot:hover {
  border-color: var(--pd-accent, #9999ff);
}
body.v2 .tiptap-wrap {
  border: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
}
body.v2 .ProseMirror {
  font-size: 18px !important;
  line-height: 1.75 !important;
  min-height: 50vh;
  padding: 0 !important;
  color: #222;
}
body.v2 .ProseMirror p.is-editor-empty:first-child::before,
body.v2 .ProseMirror .is-empty::before {
  color: #b8b8c4;
  font-weight: 400;
}
body.v2 .ProseMirror h2 {
  font-size: 1.45rem;
  margin-top: 1.6em;
  letter-spacing: -0.02em;
}
body.v2 .ProseMirror h3 {
  font-size: 1.2rem;
  margin-top: 1.3em;
}

/* Module cards quieter */
body.v2 .pd-mod {
  border-radius: 12px;
  border-color: rgba(20, 24, 40, 0.08);
  background: #fafafc;
}
body.v2 .pd-mod-head {
  background: transparent;
  border-bottom-color: rgba(20, 24, 40, 0.06);
}
body.v2 .pd-toc-hint {
  display: none;
}

/* Foot minimal */
body.v2 .v2-foot {
  position: sticky;
  bottom: 0;
  max-width: var(--write-max);
  margin: 0 auto;
  padding: 10px 24px 16px !important;
  background: linear-gradient(180deg, transparent, #fff 35%);
  border: 0 !important;
  opacity: 0.85;
  font-size: 12px;
}
body.v2 .v2-foot .primary {
  background: var(--pd-accent) !important;
  border-radius: 999px;
}

/* ── Bubble toolbar ── */
.v2-bubble {
  position: fixed;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  background: #1a1b22;
  color: #fff;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
  transform: translateX(-50%);
}
.v2-bubble[hidden] { display: none !important; }
.v2-bubble button {
  border: 0;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  min-width: 32px;
  height: 32px;
  border-radius: 7px;
  cursor: pointer;
}
.v2-bubble button:hover {
  background: rgba(255, 255, 255, 0.12);
}
.v2-bubble button.is-active {
  background: var(--pd-accent, #9999ff);
}
.v2-bubble-sep {
  width: 1px;
  height: 18px;
  background: rgba(255, 255, 255, 0.15);
  margin: 0 3px;
}
#v2-bubble-card {
  background: rgba(153, 153, 255, 0.25);
  color: #e8e8ff;
}

/* ── FAB + ── */
.v2-fab-plus {
  position: fixed;
  left: max(16px, calc(50% - var(--write-max) / 2 - 48px));
  bottom: 28px;
  z-index: 50;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(20, 24, 40, 0.1);
  background: #fff;
  color: var(--pd-accent-deep, #6056db);
  font-size: 22px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(20, 24, 40, 0.1);
}
.v2-fab-plus:hover {
  background: var(--pd-accent-soft, #eaeaff);
  border-color: var(--pd-accent);
}
@media (max-width: 900px) {
  .v2-fab-plus {
    left: auto;
    right: 16px;
    bottom: 72px;
  }
}

/* ── Picker ── */
body.v2 .v2-picker .v2-picker-section {
  margin: 12px 4px 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--pd-muted);
}
body.v2 .v2-picker .v2-picker-section:first-child {
  margin-top: 0;
}
body.v2 .block-card {
  border-radius: 12px;
}
body.v2 .block-card:hover {
  background: var(--pd-accent-soft);
  border-color: var(--pd-accent);
}
body.v2 kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 4px;
  background: #f0f0f5;
  border: 1px solid #e0e0ea;
}

/* Source mode still usable */
body.v2.source-mode .v2-fab-plus,
body.v2.source-mode .v2-bubble {
  display: none !important;
}
body.v2.source-mode .source-wrap {
  max-width: var(--write-max);
  margin: 0 auto;
}

/* List drawer when open */
body.v2:not(.list-collapsed) .pane-list {
  position: fixed;
  left: 0;
  top: 52px;
  bottom: 0;
  width: min(300px, 86vw);
  z-index: 45;
  background: #fff;
  border-right: 1px solid rgba(20, 24, 40, 0.08);
  box-shadow: 8px 0 24px rgba(20, 24, 40, 0.06);
}

/* ═══════════════════════════════════════════════════════════
   Block cards — Ghost-like「每一段都是一張卡」
   ═══════════════════════════════════════════════════════════ */

body.v2 .ProseMirror {
  /* room for left + gutter */
  padding-left: 8px !important;
}

/* Every top-level block = a soft card */
body.v2 .ProseMirror > * {
  position: relative;
  margin: 6px 0 !important;
  padding: 10px 14px 10px 16px !important;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  transition:
    background 0.12s ease,
    border-color 0.12s ease,
    box-shadow 0.12s ease;
}

/* Paragraph / list / quote cards on hover */
body.v2 .ProseMirror > p:hover,
body.v2 .ProseMirror > h2:hover,
body.v2 .ProseMirror > h3:hover,
body.v2 .ProseMirror > ul:hover,
body.v2 .ProseMirror > ol:hover,
body.v2 .ProseMirror > blockquote:hover,
body.v2 .ProseMirror > .pd-module-host:hover {
  background: #f7f7fb;
  border-color: rgba(153, 153, 255, 0.22);
  box-shadow: 0 1px 0 rgba(20, 24, 40, 0.03);
}

/* Focused / selected text block (ProseMirror selection in empty-ish) */
body.v2 .ProseMirror > .has-focus,
body.v2 .ProseMirror > *.ProseMirror-selectednode {
  background: #f3f3ff !important;
  border-color: rgba(153, 153, 255, 0.45) !important;
  box-shadow: 0 0 0 3px rgba(153, 153, 255, 0.12);
}

/* Selected atom module */
body.v2 .ProseMirror-selectednode.pd-module-host,
body.v2 .pd-module-host.ProseMirror-selectednode {
  outline: none;
  background: #f3f3ff !important;
  border: 1px solid rgba(153, 153, 255, 0.5) !important;
  box-shadow: 0 0 0 3px rgba(153, 153, 255, 0.14);
  border-radius: 14px;
}

/* Module host always reads as a card */
body.v2 .pd-module-host {
  margin: 10px 0 !important;
  padding: 0 !important;
  border: 1px solid rgba(20, 24, 40, 0.08) !important;
  border-radius: 14px !important;
  background: #fafafc !important;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(20, 24, 40, 0.04);
}
body.v2 .pd-module-host:hover {
  border-color: rgba(153, 153, 255, 0.35) !important;
  box-shadow: 0 6px 18px rgba(153, 153, 255, 0.12);
}
body.v2 .pd-module-toolbar {
  opacity: 0;
  transition: opacity 0.12s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: linear-gradient(180deg, #f0f0fa, #eaeaff);
  border-bottom: 1px solid rgba(153, 153, 255, 0.2);
  font-size: 12px;
}
body.v2 .pd-module-host:hover .pd-module-toolbar,
body.v2 .pd-module-host.ProseMirror-selectednode .pd-module-toolbar {
  opacity: 1;
}
body.v2 .pd-module-body {
  padding: 4px 0 8px;
}
body.v2 .pd-module-body .pd-mod {
  margin: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

/* Headings slightly stronger as cards */
body.v2 .ProseMirror > h2 {
  font-size: 1.4rem !important;
  font-weight: 800;
  letter-spacing: -0.02em;
  padding-top: 14px !important;
  padding-bottom: 12px !important;
}
body.v2 .ProseMirror > h3 {
  font-size: 1.15rem !important;
  font-weight: 700;
}

/* Nested list items shouldn't double-card */
body.v2 .ProseMirror li > p {
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

/* Gap insert slot — width set in JS to editor column only (not settings) */
.v2-insert-slot {
  position: fixed;
  z-index: 55;
  left: 0;
  right: auto;
  width: 0;
  height: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateY(-50%);
  box-sizing: border-box;
  /* never paint over the right settings rail */
  max-width: 100%;
}
.v2-insert-slot.is-visible {
  pointer-events: auto;
}
.v2-insert-slot-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  border-radius: 2px;
  background: var(--pd-accent, #9999ff);
  box-shadow: 0 0 0 3px rgba(153, 153, 255, 0.2);
}
.v2-insert-slot-btn {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--pd-accent, #9999ff);
  background: #fff;
  color: var(--pd-accent-deep, #6056db);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 12px 4px 8px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(153, 153, 255, 0.28);
  pointer-events: auto;
}
.v2-insert-slot-btn:hover {
  background: var(--pd-accent-soft, #eaeaff);
}
.v2-insert-slot-plus {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--pd-accent, #9999ff);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
}
body.v2.source-mode .v2-insert-slot {
  display: none !important;
}

/* Highlight block that insert is relative to */
body.v2 .ProseMirror > *.v2-insert-anchor {
  border-color: rgba(153, 153, 255, 0.55) !important;
  background: #f0f0ff !important;
  box-shadow: 0 0 0 3px rgba(153, 153, 255, 0.15);
}
body.v2 .ProseMirror > *.v2-just-inserted {
  animation: v2FlashIn 0.9s ease;
}
@keyframes v2FlashIn {
  0% { box-shadow: 0 0 0 0 rgba(153, 153, 255, 0.5); background: #e8e8ff; }
  100% { box-shadow: none; }
}

/* Picker: show where insert goes */
.v2-insert-where {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0 16px 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f3f3ff;
  border: 1px solid rgba(153, 153, 255, 0.35);
  font-size: 13px;
  font-weight: 600;
  color: var(--pd-accent-deep, #6056db);
  line-height: 1.4;
}
.v2-insert-where[hidden] { display: none !important; }
.v2-insert-where-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--pd-accent, #9999ff);
  box-shadow: 0 0 0 3px rgba(153, 153, 255, 0.25);
}

/* Empty first paragraph invitation */
body.v2 .ProseMirror > p.is-empty:first-child,
body.v2 .ProseMirror > p.is-editor-empty:first-child {
  border-style: dashed;
  border-color: rgba(153, 153, 255, 0.25);
  background: #fafaff;
  min-height: 2.4em;
}

/* ═══════════════════════════════════════════════════════════
   RWD — phone / tablet (v2)
   ═══════════════════════════════════════════════════════════ */

/* Safe area (iOS notch / home bar) */
body.v2 {
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
}

/* ── Tablet ≤ 900 ── */
@media (max-width: 900px) {
  body.v2 {
    --write-max: 100%;
  }
  body.v2 .v2-top {
    height: auto;
    min-height: 48px;
    padding: 8px 10px;
    gap: 8px;
    flex-wrap: nowrap;
  }
  body.v2 .v2-top-left,
  body.v2 .v2-top-right {
    gap: 4px;
    min-width: 0;
  }
  body.v2 .v2-top-right {
    flex: 1 1 auto;
    justify-content: flex-end;
    flex-wrap: wrap;
  }
  body.v2 .v2-top .logo-text {
    font-size: 14px;
  }
  body.v2 .v2-article-pick select {
    max-width: 110px;
    font-size: 11px;
    padding: 4px 6px;
  }
  body.v2 .v2-text-btn {
    font-size: 12px;
    padding: 5px 8px;
  }
  body.v2 .v2-primary-btn {
    font-size: 12px;
    padding: 6px 12px;
  }
  body.v2 .v2-scroll {
    padding: 16px 14px 100px;
  }
  body.v2 .title-input {
    font-size: 26px !important;
  }
  body.v2 .ProseMirror {
    font-size: 16.5px !important;
  }
  /* block cards: less horizontal padding so text breathes */
  body.v2 .ProseMirror > * {
    padding: 10px 12px !important;
    margin: 5px 0 !important;
  }
  .v2-insert-slot-line {
    left: 0 !important;
    right: 0 !important;
  }
  .v2-insert-slot-label {
    font-size: 11px;
  }
  body.v2 .v2-foot {
    padding: 8px 12px calc(12px + env(safe-area-inset-bottom, 0px)) !important;
  }
  body.v2 .v2-picker .block-picker-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  body.v2 .modal-panel-picker {
    width: min(100vw - 16px, 720px);
    max-height: min(88vh, 720px);
    margin: 0 8px;
  }
  /* list drawer full-ish width */
  body.v2:not(.list-collapsed) .pane-list {
    width: min(320px, 92vw);
    top: 0;
    padding-top: env(safe-area-inset-top, 0);
    z-index: 70;
  }
}

/* ── Phone ≤ 640 ── */
@media (max-width: 640px) {
  body.v2 .v2-top .logo-text {
    display: none; /* icon only */
  }
  body.v2 .v2-top {
    padding: 6px 8px;
    gap: 6px;
  }
  /* hide secondary chrome: 示範 / HTML — keep 預覽 + 文章 + 庫 */
  body.v2 #btn-showcase,
  body.v2 #btn-view-source,
  body.v2 #btn-view-visual {
    display: none !important;
  }
  body.v2 .v2-article-pick select {
    max-width: 96px;
  }
  body.v2 .v2-scroll {
    padding: 12px 10px 110px;
  }
  body.v2 .title-input {
    font-size: 22px !important;
    line-height: 1.3 !important;
    padding: 4px 0 8px !important;
  }
  body.v2 .ProseMirror {
    font-size: 16px !important;
    line-height: 1.7 !important;
    padding-left: 0 !important;
  }
  body.v2 .ProseMirror > * {
    padding: 10px 10px !important;
    border-radius: 10px;
  }
  body.v2 .ProseMirror > h2 {
    font-size: 1.25rem !important;
  }
  body.v2 .ProseMirror > h3 {
    font-size: 1.08rem !important;
  }
  /* bubble: horizontal scroll, never overflow viewport */
  .v2-bubble {
    max-width: calc(100vw - 16px);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 3px;
    gap: 0;
  }
  .v2-bubble::-webkit-scrollbar { display: none; }
  .v2-bubble button {
    min-width: 30px;
    height: 30px;
    font-size: 12px;
    flex: 0 0 auto;
  }
  /* FAB bottom-right, above home indicator */
  .v2-fab-plus {
    left: auto !important;
    right: max(12px, env(safe-area-inset-right, 0px));
    bottom: max(72px, calc(56px + env(safe-area-inset-bottom, 0px)));
    width: 44px;
    height: 44px;
    font-size: 24px;
  }
  body.v2 .v2-foot {
    flex-wrap: wrap;
    gap: 6px;
    font-size: 11px;
  }
  body.v2 .v2-foot .stats {
    width: 100%;
    order: 3;
  }
  /* picker: 1 col on very small via 480 below; 2 cols here */
  body.v2 .block-card {
    padding: 12px 10px;
    gap: 8px;
  }
  body.v2 .block-card-ico {
    width: 34px;
    height: 34px;
    font-size: 15px;
  }
  body.v2 .block-card-title {
    font-size: 13px;
  }
  body.v2 .modal-panel,
  body.v2 .modal-panel-wide {
    width: calc(100vw - 12px) !important;
    max-height: min(92vh, 900px);
    border-radius: 14px 14px 0 0;
  }
  body.v2 .modal-root {
    align-items: flex-end;
  }
  body.v2 .modal-body {
    max-height: 60vh;
    overflow: auto;
  }
  /* cover less tall on phone */
  body.v2 .cover-slot {
    min-height: 80px;
  }
  body.v2 .cover-slot img {
    max-height: 180px;
    object-fit: cover;
    width: 100%;
  }
}

/* ── Narrow phone ≤ 420 ── */
@media (max-width: 420px) {
  body.v2 .v2-picker .block-picker-grid,
  body.v2 #block-picker-grid-primary,
  body.v2 #block-picker-grid {
    grid-template-columns: 1fr !important;
  }
  body.v2 .v2-article-pick {
    display: none; /* open via ☰ list instead */
  }
  body.v2 .title-input {
    font-size: 20px !important;
  }
}

/* Touch: larger hit targets, less hover-only reliance */
@media (hover: none) {
  body.v2 .pd-module-toolbar {
    opacity: 1; /* always show edit chrome on touch */
  }
  body.v2 .ProseMirror > p,
  body.v2 .ProseMirror > h2,
  body.v2 .ProseMirror > h3,
  body.v2 .ProseMirror > ul,
  body.v2 .ProseMirror > ol,
  body.v2 .ProseMirror > blockquote {
    /* subtle always-on card edge so blocks readable without hover */
    border-color: rgba(20, 24, 40, 0.05);
    background: #fbfbfd;
  }
  body.v2 .ProseMirror > *.ProseMirror-selectednode,
  body.v2 .ProseMirror > .has-focus {
    border-color: rgba(153, 153, 255, 0.45) !important;
    background: #f3f3ff !important;
  }
}

/* Landscape phone */
@media (max-height: 480px) and (orientation: landscape) {
  body.v2 .v2-scroll {
    padding-top: 8px;
    padding-bottom: 72px;
  }
  body.v2 .v2-top {
    min-height: 40px;
    padding: 4px 8px;
  }
  .v2-fab-plus {
    bottom: 12px;
    width: 36px;
    height: 36px;
  }
}

/* ── Real card chrome (no demo badge) ── */
body.v2 .pd-mod-head { display: none !important; }
body.v2 .pd-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 120px;
  padding: 24px 16px;
  color: #7a8294;
  text-align: center;
}
body.v2 .pd-empty-ico {
  font-size: 28px;
  line-height: 1;
  opacity: 0.85;
}
body.v2 .pd-empty p {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}
body.v2 .pd-empty-figure {
  min-height: 160px;
  border: 1px dashed rgba(153, 153, 255, 0.35);
  border-radius: 12px;
  background: #fafaff;
}
body.v2 .pd-embed-iframe,
body.v2 .pd-place-map {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: 12px;
  display: block;
  background: #111;
}
body.v2 .pd-place-map {
  aspect-ratio: 4 / 3;
  margin-top: 10px;
}
body.v2 .pd-embed-real {
  padding: 8px;
}
body.v2 .pd-embed-fallback,
body.v2 .pd-embed-caption {
  padding: 8px 12px 12px;
  font-size: 13px;
}
body.v2 .pd-embed-link {
  word-break: break-all;
  color: var(--pd-accent-deep);
  font-weight: 700;
}
body.v2 .pd-linkcard-a {
  display: flex;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(20, 24, 40, 0.08);
  background: #fff;
}
body.v2 .pd-linkcard-thumb {
  flex: 0 0 96px;
  width: 96px;
  height: 72px;
  border-radius: 8px;
  overflow: hidden;
  background: #f0f0f5;
}
body.v2 .pd-linkcard-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
body.v2 .pd-linkcard-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
body.v2 .pd-linkcard-meta strong {
  font-size: 15px;
  line-height: 1.35;
}
body.v2 .pd-link-domain {
  font-size: 11px;
  font-weight: 700;
  color: #888;
  text-transform: lowercase;
}
body.v2 .pd-link-desc {
  font-size: 13px;
  color: #666;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
body.v2 .pd-mod-figure img {
  width: 100%;
  border-radius: 12px;
}
body.v2 .pd-mod-figure figcaption {
  margin-top: 8px;
  font-size: 13px;
  color: #666;
  text-align: center;
}
body.v2 .pd-mod-quote blockquote {
  margin: 0;
  padding: 16px 18px;
  border-left: 4px solid var(--pd-accent);
  background: #f7f7ff;
  border-radius: 0 12px 12px 0;
}
body.v2 .pd-mod-cta {
  text-align: center;
  padding: 20px 16px;
  background: linear-gradient(180deg, #f7f7ff, #fff);
  border: 1px solid rgba(153, 153, 255, 0.25);
  border-radius: 14px;
}
body.v2 .pd-cta-btn {
  display: inline-block;
  margin-top: 10px;
  padding: 10px 20px;
  border-radius: 999px;
  background: var(--pd-accent);
  color: #fff !important;
  font-weight: 700;
  text-decoration: none !important;
}
body.v2 .embed-live-preview,
body.v2 .place-map-preview,
body.v2 .link-preview-box {
  margin-top: 10px;
}
body.v2 .link-preview-box .pd-linkcard-a {
  pointer-events: none;
}

/* ── Block drag reorder ── */
.v2-drag-handle {
  position: fixed;
  z-index: 56;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid rgba(20, 24, 40, 0.12);
  background: #fff;
  color: #555;
  font-size: 14px;
  line-height: 1;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(20, 24, 40, 0.12);
  opacity: 0;
  pointer-events: none;
  user-select: none;
  touch-action: none;
  /* prevent browser from starting text selection / native drag */
  -webkit-user-drag: none;
}
.v2-drag-handle.is-visible {
  opacity: 1;
  pointer-events: auto;
}
.v2-drag-handle:active,
.v2-drag-handle.is-dragging {
  cursor: grabbing;
  opacity: 1;
  pointer-events: auto;
  background: var(--pd-accent-soft, #eaeaff);
  border-color: var(--pd-accent);
  color: var(--pd-accent-deep);
  box-shadow: 0 6px 18px rgba(96, 86, 219, 0.25);
  z-index: 80;
}
.v2-drop-line {
  position: fixed;
  z-index: 57;
  height: 3px;
  border-radius: 2px;
  background: var(--pd-accent, #9999ff);
  box-shadow: 0 0 0 3px rgba(153, 153, 255, 0.22);
  pointer-events: none;
  left: 0;
  width: 0;
}
.v2-drop-line.is-visible {
  display: block;
}
body.v2 .ProseMirror > *.v2-dragging {
  opacity: 0.35;
  border-style: dashed !important;
}
body.v2 .pd-module-drag {
  cursor: grab;
  color: #888;
  font-size: 13px;
  padding: 0 4px;
  user-select: none;
}
body.v2.source-mode .v2-drag-handle {
  display: none !important;
}
@media (max-width: 640px) {
  .v2-drag-handle {
    width: 32px;
    height: 32px;
  }
}

/* ── Text as first-class cards ── */
body.v2 .ProseMirror > *[data-text-card="1"] {
  position: relative;
  border: 1px solid rgba(20, 24, 40, 0.08) !important;
  background: #fbfbfd !important;
  box-shadow: 0 1px 4px rgba(20, 24, 40, 0.03);
  padding-top: 14px !important;
  padding-bottom: 12px !important;
  /* room for ⠿ grip on the left inside the card */
  padding-left: 36px !important;
  padding-right: 14px !important;
}
body.v2 .ProseMirror > .pd-module-host {
  position: relative;
}
/* While reordering, avoid text selection */
body.v2-is-dragging {
  cursor: grabbing !important;
  user-select: none !important;
}
body.v2-is-dragging .ProseMirror {
  cursor: grabbing !important;
}
body.v2 .ProseMirror > *[data-text-card="1"]::before {
  content: attr(data-card-kind);
  position: absolute;
  top: 6px;
  right: 10px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #a0a6b5;
  pointer-events: none;
}
body.v2 .ProseMirror > *[data-card-kind="paragraph"]::before { content: "文字"; }
body.v2 .ProseMirror > *[data-card-kind="h2"]::before { content: "大標"; }
body.v2 .ProseMirror > *[data-card-kind="h3"]::before { content: "小標"; }
body.v2 .ProseMirror > *[data-card-kind="list"]::before { content: "列表"; }
body.v2 .ProseMirror > *[data-card-kind="quote"]::before { content: "引用"; }
body.v2 .ProseMirror > *[data-card-kind="module"]::before {
  content: none;
}

body.v2 .ProseMirror > *[data-text-card="1"]:hover {
  border-color: rgba(153, 153, 255, 0.35) !important;
  background: #f6f6ff !important;
  box-shadow: 0 4px 14px rgba(153, 153, 255, 0.1);
}
body.v2 .ProseMirror > *[data-text-card="1"].ProseMirror-selectednode,
body.v2 .ProseMirror > *[data-text-card="1"].v2-insert-anchor {
  border-color: rgba(153, 153, 255, 0.55) !important;
  background: #f0f0ff !important;
}

/* Empty text card invitation */
body.v2 .ProseMirror > p[data-text-card="1"].is-empty,
body.v2 .ProseMirror > p[data-text-card="1"].is-editor-empty,
body.v2 .ProseMirror > h2[data-text-card="1"]:empty,
body.v2 .ProseMirror > h3[data-text-card="1"]:empty {
  min-height: 2.6em;
}

body.v2 .block-card.is-text-card {
  border-style: dashed;
  border-color: rgba(153, 153, 255, 0.35);
  background: #fafaff;
}
body.v2 .block-card.is-text-card .block-card-sub {
  color: var(--pd-accent-deep, #6056db);
  font-weight: 700;
}
