/*
 * LuminaCloud — Page Editor styles
 *
 * Cache-buster: ?v=5 (bumped Phase 3r — coordinated with
 * page-editor.js?v=9 + builtin-tile-customizer.js?v=1).
 *
 * Loaded by every user-created page. Defines the tile-grid base, the
 * Web Dev affordances (⋯ button, drag state, "+" creation tile), and
 * the tile-edit modal (with icon picker). Keyed off body.web-dev-active
 * so non-editors see a read-only tile grid and nothing else.
 */

/* ── Tile grid base ───────────────────────────────────────────────────── */
.quick-row{
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:12px;
  margin-bottom:18px;
}
.qa{
  position:relative;
  background:var(--surface);
  border:var(--bubble-border);
  border-radius:var(--r);
  padding:18px 16px;
  display:flex;
  flex-direction:column;
  align-items:flex-start;
  gap:10px;
  cursor:pointer;
  transition:box-shadow .15s, border-color .15s;
  box-shadow:var(--bubble-shadow);
  min-height:96px;
}
.qa:hover{
  border-color:rgba(0,0,0,0.12);
  box-shadow:0 4px 16px rgba(0,0,0,0.1);
}
.qa-icon{
  width:36px;height:36px;
  border-radius:var(--r-sm);
  background:var(--red-pale);
  color:var(--red);
  display:flex;align-items:center;justify-content:center;
}
.qa-icon svg{width:20px;height:20px}
.qa-label{font-size:13px;font-weight:700;line-height:1.25}
.qa-sub{
  font-size:10px; font-family:var(--mono); color:var(--dim);
  text-transform:uppercase; letter-spacing:.05em;
}

/* Empty state — shown on a new page when no tiles yet AND no edit mode. */
.page-empty{
  grid-column:1/-1;
  padding:48px 20px; text-align:center;
  font-family:var(--mono); font-size:12px; color:var(--dim);
  background:var(--surface); border:1px dashed var(--border);
  border-radius:var(--r);
}

/* ── ⋯ overflow button (Web Dev Mode only) ────────────────────────────── */
/* Phase 3k consistency — ⋯ lives in the LOWER right corner of every
   tile across the app (home, user pages, hub pages, accounts). Keeps
   the editing affordance in one predictable spot for users. */
.qa-more{
  position:absolute; bottom:8px; right:8px;
  width:24px; height:24px;
  display:flex; align-items:center; justify-content:center;
  background:transparent; border:none; border-radius:var(--r-sm);
  color:var(--dim); cursor:pointer; font-weight:700;
  font-family:var(--display); font-size:16px; line-height:1;
  opacity:0; transition:opacity .15s, background .15s, color .15s;
}
.qa:hover .qa-more, .qa-more:focus, .qa-more.open{opacity:1}
.qa-more:hover{background:var(--surface2); color:var(--text)}
@media(hover:none){ .qa-more{opacity:.7} }

/* Shared overflow popover — one instance, appended to <body> on first use. */
.tile-menu{
  position:absolute; z-index:900;
  min-width:140px;
  background:var(--surface); border:var(--bubble-border);
  border-radius:var(--r-sm); box-shadow:var(--bubble-shadow);
  padding:4px; display:none;
}
.tile-menu.visible{display:block}
.tile-menu button{
  display:block; width:100%; text-align:left;
  padding:8px 12px; border:none; background:transparent;
  font-family:var(--display); font-size:13px; color:var(--text);
  cursor:pointer; border-radius:var(--r-sm);
}
.tile-menu button:hover{background:var(--surface2)}
.tile-menu button.danger{color:var(--red)}
.tile-menu button.danger:hover{background:var(--red); color:#fff}

/* Drag state — same pattern the home page uses. */
body.web-dev-active .qa-pagetile{cursor:grab}
body.web-dev-active .qa-pagetile:active{cursor:grabbing}
.qa-dragging{opacity:.4}
.qa-drop-target{outline:2px solid var(--purple); outline-offset:-2px}
/* Cross-section drop highlight — applied to a destination grid when a
   tile from another grid is dragged over its bare background. The same
   purple outline as a per-tile drop target, but framing the whole grid
   so the user sees the destination zone. */
.qa-grid-drop-target{
  outline:2px dashed var(--purple);
  outline-offset:4px;
  border-radius:var(--r-sm);
}

/* Phase 3i — shared tile-drag.js wires up draggable tiles inside any
   row that opts in. Two opt-in markers exist:
     • .quick-row[data-row]    — hub page tile rows (curated <a class="qa">)
     • [data-tile-drag-row]    — generic grids, e.g. accounts page's
                                  .acc-grid with [data-slug] cards
   Keep the cursor affordance in sync with the user-tile drag above.
   Direct-child selectors so descendants nested deep inside don't get
   styled — only the row's immediate children. */
body.web-dev-active .quick-row[data-row]    > .qa[draggable="true"],
body.web-dev-active [data-tile-drag-row]    > [draggable="true"][data-slug]{cursor:grab}
body.web-dev-active .quick-row[data-row]    > .qa[draggable="true"]:active,
body.web-dev-active [data-tile-drag-row]    > [draggable="true"][data-slug]:active{cursor:grabbing}

/* ── "+" creation tile ────────────────────────────────────────────────── */
.qa-new{
  border:2px dashed var(--border);
  background:transparent;
  box-shadow:none;
  color:var(--dim);
  transition:border-color .15s, color .15s, background .15s;
}
.qa-new:hover{
  border-color:var(--red);
  color:var(--red);
  background:var(--surface);
}
.qa-new .qa-icon{
  background:transparent;
  color:inherit;
  font-size:28px;
  font-weight:300;
  line-height:1;
}
.qa-new-label{
  font-size:11px; font-family:var(--mono);
  text-transform:uppercase; letter-spacing:.08em;
  color:inherit;
}

/* CSS gates — hide all edit affordances when mode is off. */
body:not(.web-dev-active) .qa-more,
body:not(.web-dev-active) .qa-new{
  display:none !important;
}

/* ── Tile-edit modal ──────────────────────────────────────────────────── */
.modal-overlay{
  position:fixed; inset:0;
  background:rgba(0,0,0,0.45);
  z-index:1000;
  display:none;
  align-items:center; justify-content:center;
}
.modal-overlay.visible{display:flex}
.modal{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--modal-r);
  padding:24px 28px;
  width:100%; max-width:460px;
  max-height:90vh; overflow-y:auto;
  box-shadow:var(--modal-shadow);
}
.modal-title{font-size:16px;font-weight:700;margin-bottom:4px}
.modal-sub{font-size:11px;color:var(--dim);font-family:var(--mono);margin-bottom:20px}
.modal-field{margin-bottom:14px}
.modal-label{
  font-size:11px; font-weight:600; font-family:var(--mono);
  color:var(--dim); text-transform:uppercase; letter-spacing:.06em;
  margin-bottom:5px;
}
.modal-input{
  width:100%; padding:8px 12px;
  border:1px solid var(--border); border-radius:var(--r-sm);
  font-family:var(--mono); font-size:13px;
  background:var(--surface2); color:var(--text); outline:none;
  transition:border-color .15s;
}
.modal-input:focus{box-shadow:var(--focus-ring)}
.modal-error{
  font-size:11px; color:var(--red); font-family:var(--mono);
  margin-top:6px; min-height:14px;
}
.modal-footer{
  display:flex; gap:8px; justify-content:flex-end;
  margin-top:20px; padding-top:16px;
  border-top:1px solid var(--border);
}
.btn-modal-cancel{
  padding:7px 16px; border-radius:var(--r-sm);
  font-family:var(--display); font-size:13px; font-weight:600;
  cursor:pointer; background:var(--surface);
  color:var(--muted); border:1px solid var(--border);
}
.btn-modal-cancel:hover{color:var(--text)}
.btn-modal-save{
  padding:7px 16px; border-radius:var(--r-sm);
  font-family:var(--display); font-size:13px; font-weight:600;
  cursor:pointer; background:var(--red); color:#fff;
  border:none; transition:filter .15s;
}
.btn-modal-save:hover{filter:brightness(1.08)}
.btn-modal-save:disabled{opacity:.5;cursor:not-allowed;filter:none}

/* ── Kind picker (chip row) ───────────────────────────────────────────── */
/*
 * Three radio-style chips at the top of the create modal: "LuminaCloud page",
 * "External URL", "Sub-page". Picking one swaps the kind-specific fields
 * below (page dropdown / url input / slug input). Edit mode hides the row
 * entirely via .modal.is-editing — kind is set at creation and stays put.
 */
.kind-options{
  display:flex; flex-wrap:wrap; gap:6px;
}
.kind-opt{
  flex:1 1 0; min-width:90px;
  padding:10px 10px;
  border:1px solid var(--border); border-radius:var(--r-sm);
  background:var(--surface2); color:var(--muted);
  font-family:var(--display); font-size:12px; font-weight:600;
  cursor:pointer; text-align:center;
  transition:all .12s;
}
.kind-opt:hover{border-color:var(--red); color:var(--text)}
.kind-opt.active{
  background:var(--red); color:#fff; border-color:var(--red);
}
.kind-opt .kind-sub{
  display:block; font-family:var(--mono); font-weight:400;
  font-size:10px; color:inherit; opacity:.8; margin-top:2px;
  letter-spacing:.04em; text-transform:lowercase;
}

/* Kind-specific field groups — only one is visible at a time, switched
   by adding / removing .visible based on the selected kind. */
.kind-panel{display:none}
.kind-panel.visible{display:block}

.modal-hint{
  font-size:11px; color:var(--dim); font-family:var(--mono);
  margin-top:6px; line-height:1.4;
}

.modal-select{
  width:100%; padding:8px 12px;
  border:1px solid var(--border); border-radius:var(--r-sm);
  font-family:var(--mono); font-size:13px;
  background:var(--surface2); color:var(--text); outline:none;
}
.modal-select:focus{box-shadow:var(--focus-ring)}

/* ── Searchable page picker (Phase 3d) ───────────────────────────────── */
/*
 * Replaces the old <select> for the "LuminaCloud page" tile kind.
 * Shows built-in + user-created pages, filterable via the input above,
 * with a fixed-height scrollable list. The visible-row count is tuned
 * via max-height — enough to show five cards before scrolling kicks in.
 */
.lc-page-list{
  border:1px solid var(--border);
  border-radius:var(--r-sm);
  background:var(--surface2);
  /* Exactly 5 rows visible — 44px min-height per row × 5 = 220px.
     Row 6+ lives below the fold and is reachable via scroll. Keep
     this value in lockstep with .lc-page-row min-height below; if
     you change one, change the other. */
  max-height:220px;
  overflow-y:auto;
  margin-top:6px;
}
.lc-page-row{
  min-height:44px;        /* anchors the list max-height math */
  padding:8px 12px;
  cursor:pointer;
  border-bottom:1px solid var(--border);
  display:flex; align-items:center; gap:10px;
  transition:background .1s;
}
.lc-page-row:last-child{border-bottom:none}
.lc-page-row:hover{background:var(--surface)}
.lc-page-row.selected{
  background:var(--surface);
  box-shadow:inset 3px 0 0 var(--red);
}
.lc-page-row .lcp-title{
  flex:1; min-width:0;
  font-size:13px; font-weight:600;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.lc-page-row .lcp-slug{
  font-family:var(--mono); font-size:10.5px; color:var(--dim);
  margin-left:auto; white-space:nowrap;
}
.lc-page-row .lcp-kind{
  font-family:var(--mono); font-size:9px; font-weight:700;
  text-transform:uppercase; letter-spacing:.06em;
  padding:2px 6px; border-radius:3px;
  color:var(--muted); background:var(--border);
}
.lc-page-row .lcp-kind.is-user{
  color:var(--purple); background:rgba(109,63,190,0.12);
}
.lc-page-list-empty{
  padding:20px 12px; text-align:center;
  font-family:var(--mono); font-size:11px;
  color:var(--dim);
}

.modal-textarea{
  width:100%; padding:10px 12px;
  border:1px solid var(--border); border-radius:var(--r-sm);
  font-family:var(--mono); font-size:13px;
  background:var(--surface2); color:var(--text); outline:none;
  resize:vertical; min-height:140px; line-height:1.45;
  transition:border-color .15s;
}
.modal-textarea:focus{box-shadow:var(--focus-ring)}

/* Edit mode — hide the kind picker; the fields the user sees mirror
   whatever kind the tile was created with. */
.modal.is-editing .kind-options-field,
.modal.is-editing .kind-panel.for-create-only{display:none}

/* ── Icon picker grid ─────────────────────────────────────────────────── */
.lc-icon-grid{
  display:grid;
  grid-template-columns:repeat(8, 1fr);
  gap:6px;
  padding:8px;
  border:1px solid var(--border);
  border-radius:var(--r-sm);
  background:var(--surface2);
}
.lc-icon-btn{
  display:flex; align-items:center; justify-content:center;
  aspect-ratio:1;
  padding:6px;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--r-sm);
  color:var(--muted);
  cursor:pointer;
  transition:all .12s;
}
.lc-icon-btn svg{width:18px;height:18px}
.lc-icon-btn:hover{
  border-color:var(--red);
  color:var(--red);
}
.lc-icon-btn.selected{
  background:var(--red);
  border-color:var(--red);
  color:#fff;
}
@media(max-width:520px){
  .lc-icon-grid{grid-template-columns:repeat(6, 1fr)}
}

/* ── Custom icon upload (Phase 3g) ────────────────────────────────────── */
/*
 * The icon picker now supports user uploads and pasted URLs. The grid
 * mixes three tile kinds: 16 built-in SVG icons, an optional "custom"
 * thumbnail showing the currently-selected URL icon, and a dashed "+"
 * upload button that opens a file picker. Below the grid, a URL row
 * lets users paste any same-origin path or http(s) image URL.
 */

/* Custom-icon thumbnail — same slot shape as built-ins, but displays
   the uploaded/pasted image instead of an SVG. */
.lc-icon-btn.lc-icon-custom img{
  width:20px; height:20px; object-fit:contain;
}

/* Dashed "+" upload tile — visually matches the qa-new / pb-new pattern
   so users recognize it as "create something new". */
.lc-icon-btn.lc-icon-upload{
  border-style:dashed;
  color:var(--dim);
  font-family:var(--display);
  font-size:18px;
  font-weight:300;
  line-height:1;
  background:transparent;
}
.lc-icon-btn.lc-icon-upload:hover{
  border-color:var(--red);
  color:var(--red);
  background:var(--surface2);
}

/* Tile-level: render user-uploaded icons as an <img>. Swap out the red
   pill background for a transparent box so the user's artwork isn't
   tinted by the container. */
.qa-icon img{
  width:22px; height:22px; object-fit:contain;
}
.qa-icon.has-custom-icon{
  background:transparent; color:inherit;
}

/* ── Text blocks (page-blocks.js) ─────────────────────────────────────── */
/*
 * Full-width bubble cards rendered below the tile grid. Users can add
 * any number of these to annotate a page. In Web Dev Mode, each block
 * gets a ⋯ menu; a dashed "+" bar at the bottom creates new blocks.
 */
.page-blocks{display:flex; flex-direction:column; gap:14px; margin-top:8px}

.pb-block{
  position:relative;
  background:var(--surface);
  border:var(--bubble-border);
  border-radius:var(--r);
  box-shadow:var(--bubble-shadow);
  padding:0;
  overflow:hidden;
  transition:box-shadow .15s, border-color .15s;
}
body.web-dev-active .pb-block{cursor:grab}
body.web-dev-active .pb-block:active{cursor:grabbing}

.pb-head{
  display:flex; align-items:center; justify-content:space-between;
  padding:13px 18px;
  border-bottom:1px solid var(--border);
}
.pb-head.is-empty{display:none}  /* no head if block has no title */
.pb-title{
  font-size:11px; font-weight:700; font-family:var(--mono);
  text-transform:uppercase; letter-spacing:.08em; color:var(--text);
}

.pb-body{
  padding:16px 20px;
  font-family:var(--display);
  font-size:14px; line-height:1.6; color:var(--text);
}
.pb-body > :first-child{margin-top:0}
.pb-body > :last-child{margin-bottom:0}
.pb-body h2{font-size:16px; font-weight:700; margin:16px 0 8px}
.pb-body h3{font-size:14px; font-weight:700; margin:14px 0 6px; color:var(--muted); text-transform:uppercase; letter-spacing:.04em; font-family:var(--mono)}
.pb-body p{margin:0 0 10px}
.pb-body ul, .pb-body ol{padding-left:20px; margin:0 0 10px}
.pb-body li{margin-bottom:4px}
.pb-body a{color:var(--blue); text-decoration:underline}
.pb-body a:hover{filter:brightness(1.1)}
.pb-body code{
  font-family:var(--mono); font-size:12.5px;
  background:var(--surface2); padding:1px 5px; border-radius:3px;
}
.pb-body pre{
  background:var(--surface2);
  border:1px solid var(--border);
  border-radius:var(--r-sm);
  padding:10px 12px; margin:0 0 10px;
  overflow-x:auto;
}
.pb-body pre code{
  background:transparent; padding:0; border-radius:0; font-size:12.5px;
}
.pb-body strong{font-weight:700}
.pb-body em{font-style:italic}

/* ⋯ menu on each block (Web Dev only). Same motif as .qa-more but sized
   to sit in the bubble head. */
.pb-more{
  width:28px; height:28px;
  display:flex; align-items:center; justify-content:center;
  background:transparent; border:none; border-radius:var(--r-sm);
  color:var(--dim); cursor:pointer;
  font-family:var(--display); font-size:16px; font-weight:700; line-height:1;
  opacity:0; transition:opacity .15s, background .15s, color .15s;
}
.pb-block:hover .pb-more,
.pb-more:focus, .pb-more.open{opacity:1}
.pb-more:hover{background:var(--surface2); color:var(--text)}
@media(hover:none){ .pb-more{opacity:.7} }

/* Drag state for blocks — shared class names with qa-dragging/qa-drop-target
   would collide with the tile drag handlers, so blocks use their own. */
.pb-dragging{opacity:.4}
.pb-drop-target{outline:2px solid var(--purple); outline-offset:-2px}

/* Dashed "+" bar at the bottom. Only rendered in Web Dev Mode (injected
   by page-blocks.js); the CSS gate below is a belt-and-braces cleanup. */
.pb-new{
  border:2px dashed var(--border);
  background:transparent;
  box-shadow:none;
  padding:20px;
  text-align:center;
  color:var(--dim);
  font-family:var(--mono); font-size:12px;
  text-transform:uppercase; letter-spacing:.08em;
  border-radius:var(--r);
  cursor:pointer;
  transition:border-color .15s, color .15s, background .15s;
}
.pb-new:hover{
  border-color:var(--red); color:var(--red); background:var(--surface);
}

body:not(.web-dev-active) .pb-more,
body:not(.web-dev-active) .pb-new{display:none !important}

/* Opt-out: when the page-blocks mount carries data-always-editable="1",
   the editor affordances stay visible regardless of web-dev mode. Used on
   pages where free-form notes are part of the everyday flow (e.g.
   Licensing & Pricing). Higher specificity than the body:not() rule
   above so it wins. .pb-more keeps its native flex layout (icon button);
   .pb-new is a block-level dashed bar so it stays block. */
.page-blocks[data-always-editable="1"] .pb-more{display:flex !important}
.page-blocks[data-always-editable="1"] .pb-new{display:block !important}
.page-blocks[data-always-editable="1"] .pb-block{cursor:grab}
.page-blocks[data-always-editable="1"] .pb-block:active{cursor:grabbing}

/* ── Note-card pattern (page-blocks ≥ v3) ─────────────────────────────
   Mirrors the account-detail.html Notes section verbatim so notes look
   and behave identically site-wide: blue source stripe → red on hover,
   mono uppercase date in the head, 4-line body clamp with click-to-
   expand, Edit / Delete buttons in the foot. Lifted from
   account-detail.html lines ~3908–4093 — keep the two in sync if either
   diverges. */
.page-blocks{display:flex; flex-direction:column; gap:12px;}

.page-blocks .note-empty{
  background:var(--surface);
  border:var(--bubble-border);
  border-radius:var(--r);
  padding:26px 20px;
  text-align:center;
  color:var(--muted);
  font-size:13px;
}

.page-blocks .note-card{
  background:var(--surface);
  border:var(--bubble-border);
  border-left:3px solid var(--blue);
  border-radius:var(--r);
  box-shadow:var(--bubble-shadow);
  padding:18px 20px;
  transition:box-shadow .15s, border-color .15s, border-left-color .15s;
}
.page-blocks .note-card:hover{
  box-shadow:0 4px 16px rgba(0,0,0,0.08);
  border-left-color:var(--red);
}
.page-blocks .note-card.is-truncated{cursor:pointer;}
.page-blocks .note-card.is-truncated:hover{
  border-color:var(--red);
  border-left-color:var(--red);
}
.page-blocks .note-card.note-expanded .note-body{
  -webkit-line-clamp:unset;
  display:block;
  overflow:visible;
}

.page-blocks .note-expand-hint{
  display:none;
  font-family:var(--mono);
  font-size:10px; font-weight:600;
  text-transform:uppercase; letter-spacing:.05em;
  color:var(--blue);
  margin:-4px 0 10px;
  user-select:none;
}
.page-blocks .note-card.is-truncated .note-expand-hint{display:inline-block;}
.page-blocks .note-card.is-truncated:hover .note-expand-hint{text-decoration:underline;}

.page-blocks .note-head{
  display:flex; justify-content:space-between; align-items:flex-start;
  gap:12px; margin-bottom:6px;
}
.page-blocks .note-title{
  font-size:15px; font-weight:700; color:var(--text);
  line-height:1.3; word-break:break-word;
}
.page-blocks .note-date{
  font-family:var(--mono); font-size:10px; color:var(--dim);
  text-transform:uppercase; letter-spacing:.05em;
  white-space:nowrap; flex-shrink:0; padding-top:3px;
}

.page-blocks .note-body{
  font-size:13px; color:var(--muted); line-height:1.55;
  word-break:break-word; margin-bottom:10px;
  display:-webkit-box; -webkit-line-clamp:4; -webkit-box-orient:vertical;
  overflow:hidden;
}
.page-blocks .note-body ul,
.page-blocks .note-body ol{margin:4px 0 8px 22px; padding:0;}
.page-blocks .note-body li{margin:2px 0;}
/* Paragraph spacing — generous enough that pasted multi-paragraph
   content (Word, Google Docs, web pages) keeps the visible breathing
   room between paragraphs the user expects. Headings get a touch more
   air on top to separate them from the paragraph that came before. */
.page-blocks .note-body p{margin:0 0 10px 0}
.page-blocks .note-body p:last-child{margin-bottom:0}
.page-blocks .note-body h1,
.page-blocks .note-body h2,
.page-blocks .note-body h3,
.page-blocks .note-body h4{
  font-size:14px; font-weight:700; color:var(--text);
  margin:14px 0 6px 0;
}
.page-blocks .note-body h1:first-child,
.page-blocks .note-body h2:first-child,
.page-blocks .note-body h3:first-child,
.page-blocks .note-body h4:first-child{margin-top:0}
.page-blocks .note-body strong, .page-blocks .note-body b{font-weight:700; color:var(--text);}
.page-blocks .note-body em, .page-blocks .note-body i{font-style:italic;}
.page-blocks .note-body u{text-decoration:underline;}
.page-blocks .note-body blockquote{
  margin:6px 0 10px 0; padding:6px 12px;
  border-left:3px solid var(--border);
  color:var(--muted); font-style:italic;
}
.page-blocks .note-body code{
  font-family:var(--mono); font-size:12px;
  background:var(--surface2);
  padding:1px 5px; border-radius:3px;
}
.page-blocks .note-body pre{
  font-family:var(--mono); font-size:12px;
  background:var(--surface2);
  padding:8px 10px; border-radius:var(--r-sm);
  overflow-x:auto; margin:6px 0 10px 0;
}
.page-blocks .note-body a{
  color:var(--blue); text-decoration:underline; cursor:pointer;
}
.page-blocks .note-body a:hover{filter:brightness(0.85);}
.page-blocks .note-body mark{
  background:#fff3a0; color:inherit;
  padding:0 2px; border-radius:2px;
}
[data-theme="dark"] .page-blocks .note-body mark{
  background:rgba(224,168,74,0.45);
}

.page-blocks .note-foot{
  display:flex; justify-content:space-between; align-items:center;
  gap:10px; flex-wrap:wrap;
}
.page-blocks .note-chips{display:flex; flex-wrap:wrap; gap:6px; min-height:0;}
.page-blocks .note-actions{display:flex; gap:6px; flex-shrink:0;}
.page-blocks .note-action{
  padding:6px 10px; font-family:var(--mono); font-size:10px; font-weight:600;
  background:var(--surface2); color:var(--muted);
  border:1px solid var(--border); border-radius:var(--r-sm);
  cursor:pointer; text-transform:uppercase; letter-spacing:.04em;
  transition:all .12s;
}
.page-blocks .note-action:hover{color:var(--text); border-color:rgba(0,0,0,0.18);}
.page-blocks .note-action.danger:hover{color:var(--red); border-color:var(--red);}

/* ── Modal pattern (page-blocks New Note / Edit Note) ───────────────────
   Lifted verbatim from account-detail.html lines 4556-4734 so the New
   Note modal launched by page-blocks.js looks identical to the one on
   the Notes section of an account. Pages that load page-editor.css
   (security.html, licensing.html, any user-page using the multicloud
   template) get these for free. */
.lcblk-modal-overlay{
  position:fixed; inset:0;
  background:rgba(0,0,0,0.45);
  z-index:1000;
  display:none;
  align-items:center; justify-content:center;
  padding:20px;
}
.lcblk-modal-overlay.visible{display:flex}
.lcblk-modal-overlay .modal{
  background:var(--surface);
  border-radius:var(--r);
  box-shadow:0 10px 40px rgba(0,0,0,0.25);
  max-width:460px; width:100%;
  max-height:90vh;
  display:flex; flex-direction:column;
  overflow:hidden;
}
.lcblk-modal-overlay .modal.modal-lg{max-width:672px}
.lcblk-modal-overlay .modal{
  /* Resizable: drag the bottom-right corner to grow when bodies get
     long. Mirrors #noteModal on account-detail.html. */
  resize:both;
  overflow:auto;
  min-width:380px; min-height:320px;
  max-width:95vw;  max-height:90vh;
}
.lcblk-modal-overlay .modal-head{
  padding:16px 20px;
  border-bottom:1px solid var(--border);
  display:flex; align-items:center; justify-content:space-between;
}
.lcblk-modal-overlay .modal-title{
  font-size:15px; font-weight:700;
}
.lcblk-modal-overlay .modal-close{
  width:26px; height:26px;
  background:none; border:none;
  color:var(--dim); cursor:pointer;
  font-size:20px; line-height:1;
  border-radius:6px;
  display:flex; align-items:center; justify-content:center;
  padding:0;
}
.lcblk-modal-overlay .modal-close:hover{background:var(--surface2); color:var(--red)}
.lcblk-modal-overlay .modal-body{
  padding:20px; overflow-y:auto; flex:1;
}
.lcblk-modal-overlay .modal-field{margin-bottom:16px}
.lcblk-modal-overlay .modal-field:last-child{margin-bottom:0}
.lcblk-modal-overlay .modal-label{
  display:block;
  font-size:10px; font-family:var(--mono); font-weight:700;
  color:var(--red);
  text-transform:uppercase; letter-spacing:.08em;
  margin-bottom:6px;
}
.lcblk-modal-overlay .modal-input{
  width:100%;
  padding:10px 12px;
  border:1px solid var(--border);
  border-radius:var(--r-sm);
  font-family:var(--display); font-size:13px;
  background:var(--surface); color:var(--text);
  outline:none; box-sizing:border-box;
  transition:border-color .12s, box-shadow .12s;
}
.lcblk-modal-overlay .modal-input:focus{
  border-color:var(--red);
  box-shadow:var(--focus-ring, 0 0 0 3px rgba(192,57,43,0.15));
}
.lcblk-modal-overlay textarea.modal-input{
  resize:vertical; min-height:70px;
  font-family:var(--display); line-height:1.4;
}

/* Title + Date side-by-side, matches account-detail.html line 4538. */
.lcblk-modal-overlay .modal-row{
  display:grid; grid-template-columns:1fr 1fr;
  gap:12px; margin-bottom:16px;
}
.lcblk-modal-overlay .modal-row .modal-field{margin-bottom:0}

/* Rich-editor — lifted from account-detail.html lines 3720-3882. The
   modal body is a contenteditable div wrapped in this shell with a
   toolbar of B / I / U / Highlight / Link / Bullet / Numbered buttons
   above it. document.execCommand handles Bold/Italic/Underline natively;
   a tiny sanitizer in page-blocks.js scrubs the HTML on save. */
.lcblk-modal-overlay .rich-editor{
  border:1px solid var(--border);
  border-radius:var(--r-sm, 8px);
  background:var(--surface);
  overflow:hidden;
  display:flex; flex-direction:column;
}
.lcblk-modal-overlay .rich-editor:focus-within{
  border-color:rgba(0,0,0,0.24);
  box-shadow:0 0 0 3px rgba(192,57,43,0.08);
}
[data-theme="dark"] .lcblk-modal-overlay .rich-editor:focus-within{
  border-color:rgba(255,255,255,0.25);
}
.lcblk-modal-overlay .rich-bar{
  display:flex; align-items:center; gap:2px;
  padding:5px 6px;
  border-bottom:1px solid var(--border);
  background:var(--surface2);
  flex-wrap:wrap;
}
.lcblk-modal-overlay .rich-btn{
  min-width:26px; height:26px;
  padding:0 7px;
  border:1px solid transparent;
  background:transparent; color:var(--muted);
  font-family:var(--mono); font-size:12px; font-weight:600;
  cursor:pointer; border-radius:4px;
  transition:background .12s, color .12s;
  display:inline-flex; align-items:center; justify-content:center;
  line-height:1;
}
.lcblk-modal-overlay .rich-btn:hover{
  background:var(--surface); color:var(--text);
}
.lcblk-modal-overlay .rich-btn.active{
  background:var(--red); color:#fff; border-color:var(--red);
}
.lcblk-modal-overlay .rich-btn b{font-weight:800}
.lcblk-modal-overlay .rich-btn i{font-style:italic}
.lcblk-modal-overlay .rich-btn u{text-decoration:underline}
.lcblk-modal-overlay .rich-btn .rich-hl-swatch{
  display:inline-block; padding:0 4px;
  border-radius:2px;
  background:#fff3a0; color:#5a4a00; font-weight:700;
}
[data-theme="dark"] .lcblk-modal-overlay .rich-btn .rich-hl-swatch{
  background:#d6c75a; color:#1a1a1a;
}
.lcblk-modal-overlay .rich-btn.active .rich-hl-swatch{
  background:#fff; color:var(--red);
}
.lcblk-modal-overlay .rich-sep{
  width:1px; height:16px;
  background:var(--border);
  margin:0 4px;
}

/* Reskin LCEmoji's auto-mounted trigger when it's anchored inside our
   rich-bar. Without this it carries its floating-style defaults
   (22px, opacity 0.55, absolute positioning) which look completely
   alien next to the .rich-btn icons. Mirrors account-detail.html
   lines 3803-3824 verbatim except for the namespace. */
.lcblk-modal-overlay .rich-bar .lc-emoji-trigger{
  position:static;
  min-width:26px; width:auto; height:26px;
  padding:0 7px;
  border:1px solid transparent;
  border-radius:4px;
  background:transparent;
  color:var(--muted);
  opacity:1;
  font-size:14px; line-height:1;
  cursor:pointer;
  display:inline-flex; align-items:center; justify-content:center;
  transition:background .12s, color .12s;
}
.lcblk-modal-overlay .rich-bar .lc-emoji-trigger:hover{
  background:var(--surface);
  color:var(--text);
}
.lcblk-modal-overlay .rich-content{
  padding:10px 14px;
  min-height:140px;
  font-family:var(--display); font-size:13px; line-height:1.55;
  color:var(--text);
  outline:none;
  overflow-y:auto;
  max-height:360px;
}
.lcblk-modal-overlay .rich-content[data-placeholder]:empty::before{
  content:attr(data-placeholder);
  color:var(--dim); font-style:italic;
  pointer-events:none;
}
.lcblk-modal-overlay .rich-content ul,
.lcblk-modal-overlay .rich-content ol{margin:6px 0 6px 22px; padding:0;}
.lcblk-modal-overlay .rich-content li{margin:2px 0;}
.lcblk-modal-overlay .rich-content p{margin:0 0 6px 0;}
.lcblk-modal-overlay .rich-content p:last-child{margin-bottom:0}
.lcblk-modal-overlay .rich-content a{color:var(--blue); text-decoration:underline;}
.lcblk-modal-overlay .rich-content mark{
  background:#fff3a0; color:inherit;
  padding:0 2px; border-radius:2px;
}
[data-theme="dark"] .lcblk-modal-overlay .rich-content mark{
  background:rgba(224,168,74,0.45);
}
.lcblk-modal-overlay .modal-error{
  font-size:11px; color:var(--red);
  font-family:var(--mono);
  margin-top:4px; min-height:14px;
}
.lcblk-modal-overlay .modal-foot{
  padding:14px 20px;
  border-top:1px solid var(--border);
  display:flex; justify-content:flex-end; gap:8px;
}
.lcblk-modal-overlay .btn-modal-cancel,
.lcblk-modal-overlay .btn-modal-save{
  padding:9px 18px;
  border-radius:var(--r-sm);
  font-family:var(--mono); font-size:11px; font-weight:600;
  cursor:pointer;
  transition:all .12s;
  border:1px solid var(--border);
}
.lcblk-modal-overlay .btn-modal-cancel{
  background:var(--surface); color:var(--muted);
}
.lcblk-modal-overlay .btn-modal-cancel:hover{
  border-color:rgba(0,0,0,0.2); color:var(--text);
}
.lcblk-modal-overlay .btn-modal-save{
  background:var(--red); color:#fff; border-color:var(--red);
}
.lcblk-modal-overlay .btn-modal-save:hover{filter:brightness(1.08)}

/* Empty hint — no blocks yet, not in edit mode → render nothing at all.
   (The tile-grid empty state is enough; we don't want two "empty" messages
   stacked on top of each other.) */

/* Phase 3r — make sure the dashed "+ Add page" tile always sorts as the
   LAST visual cell of the grid, regardless of DOM order. renderTiles()
   already appends it after user tiles, but legacy inline orchestrators
   sometimes interleave the "+" earlier. CSS `order` runs in CSS Grid
   the same way it does in flexbox: items default to 0, higher values
   render after. Pinning the "+" at 999 guarantees it lands last no
   matter what the DOM says. */
.qa-new{order:999}

/* ── AI Summary kind panel (Phase 3r) ──────────────────────────────────
   Length pills, Preview button, status text, and the editable summary
   textarea. Reuses .modal-input for fields that already match the
   modal's standard input chrome. */
.lc-ai-len{
  display:flex; gap:8px; flex-wrap:wrap;
}
.lc-ai-len-pill{
  padding:7px 14px;
  border:1px solid var(--border);
  border-radius:20px;
  background:var(--surface);
  color:var(--muted);
  font-family:var(--mono); font-size:11px; font-weight:600;
  cursor:pointer;
  transition:background .12s, color .12s, border-color .12s;
}
.lc-ai-len-pill:hover{
  color:var(--text);
  border-color:rgba(0,0,0,0.2);
}
.lc-ai-len-pill.active{
  color:#fff;
  background:var(--purple);
  border-color:var(--purple);
}
.lc-ai-preview-btn{
  padding:8px 16px;
  background:var(--purple);
  color:#fff;
  border:none;
  border-radius:var(--r-sm);
  font-family:var(--display); font-size:12px; font-weight:600;
  cursor:pointer;
  transition:filter .12s;
}
.lc-ai-preview-btn:hover{filter:brightness(1.08)}
.lc-ai-preview-btn:disabled{opacity:.5; cursor:wait}
.lc-ai-status{
  font-family:var(--mono); font-size:11px; color:var(--dim);
  flex:1;
}
.lc-ai-status.is-error{color:var(--red)}
.lc-ai-summary{
  min-height:180px;
  font-family:var(--mono); font-size:12px;
  line-height:1.5;
  resize:vertical;
}

/* ── Mobile ───────────────────────────────────────────────────────────── */
@media(max-width:760px){
  .quick-row{grid-template-columns:1fr 1fr}
}
@media(max-width:600px){
  .qa{padding:14px 12px; min-height:88px}
  input,textarea,select{font-size:16px !important}
  .pb-body{padding:14px 16px; font-size:13.5px}
  .pb-head{padding:11px 14px}
}
