/*
  McCord Journal editor — the writing app chrome.
  The page itself (title, cover, body) uses the real post styles from
  styles.css + journal.css so the canvas matches the live post exactly.
*/

body.je-body-root {
  background: var(--warm-cream);
  min-height: 100vh;
}
body.je-body-root::before { display: none; } /* no paper grain over the editor */

.je-hidden { display: none !important; }

/* ---- Top bar ------------------------------------------------------------- */
.je-top {
  position: sticky;
  top: 0;
  z-index: 60;
  background: var(--warm-cream);
  border-bottom: var(--line);
}
.je-top .stripe-bar { height: 10px; }
.je-topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  min-height: 60px;
}
.je-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--radius-pill);
  font-weight: 800;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.je-back:hover { background: rgba(0, 0, 0, 0.06); }
.je-back svg { width: 18px; height: 18px; flex: none; }
.je-docinfo { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; }
.je-docname {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-family: 'Lobster', Georgia, serif;
  font-size: 1.25rem;
  color: var(--ink);
}
.je-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
  padding: 5px 11px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.05);
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--ink-soft);
  white-space: nowrap;
}
.je-status i { width: 8px; height: 8px; border-radius: 50%; background: var(--emerald); flex-shrink: 0; }
.je-status[data-state="pending"] i,
.je-status[data-state="saving"] i { background: var(--gold); animation: je-pulse 1s ease-in-out infinite; }
.je-status[data-state="offline"] { background: #fde2d0; color: #8a3b12; }
.je-status[data-state="offline"] i { background: var(--sb-orange); }
.je-status[data-state="error"] { background: #fbd5d5; color: var(--candy-red-dark); }
.je-status[data-state="error"] i { background: var(--candy-red); }
@keyframes je-pulse { 50% { opacity: 0.35; } }

.je-top-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.je-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 13px;
  border: 1.5px solid transparent;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}
.je-ghost:hover { background: rgba(0, 0, 0, 0.06); }
.je-ghost.is-on { border-color: var(--ink); background: var(--soft-white); }
.je-ghost svg { width: 18px; height: 18px; }
.je-publish {
  min-height: 44px;
  padding: 10px 20px;
  font-size: 0.95rem;
}
.je-publish[data-state="live"] { background: var(--emerald); }
.je-publish[disabled] { opacity: 0.6; cursor: progress; }

/* ---- Formatting toolbar ------------------------------------------------- */
.je-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 12px;
  overflow-x: auto;
  scrollbar-width: thin;
  background: var(--soft-white);
  border-top: 1.5px dashed rgba(41, 32, 24, 0.25);
}
.je-tb-group { display: flex; align-items: center; gap: 2px; padding: 0 6px; border-right: 1.5px solid rgba(41, 32, 24, 0.14); flex-shrink: 0; }
.je-tb-group:last-child { border-right: 0; }
.je-tb {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  border: 1.5px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 800;
  cursor: pointer;
  flex-shrink: 0;
}
.je-tb:hover { background: rgba(0, 0, 0, 0.06); }
.je-tb.is-active { background: var(--butter-pale); border-color: var(--ink); }
.je-tb[disabled] { opacity: 0.35; cursor: default; background: transparent; }
.je-tb svg { width: 19px; height: 19px; flex-shrink: 0; }
.je-tb .je-caret { width: 12px; height: 12px; opacity: 0.6; }
.je-tb-style { min-width: 148px; justify-content: space-between; border-color: rgba(41, 32, 24, 0.25); background: #fff; }
.je-tb-insert { background: var(--candy-red); color: #fff; padding: 0 12px; }
.je-tb-insert:hover { background: var(--candy-red-dark); }
.je-color-bar { position: absolute; left: 9px; right: 9px; bottom: 5px; height: 4px; border-radius: 2px; background: var(--ink); }

/* ---- Tooltips ------------------------------------------------------------ */
[data-tip] { position: relative; }
.je-tip {
  position: fixed;
  z-index: 200;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--near-black);
  color: var(--butter-pale);
  font-size: 0.78rem;
  font-weight: 700;
  pointer-events: none;
  white-space: nowrap;
}
.je-tip kbd { font: inherit; opacity: 0.7; margin-left: 6px; }

/* ---- Banner (restore / conflicts / sign-in) ----------------------------- */
.je-banner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin: 14px auto 0;
  max-width: 900px;
  padding: 12px 16px;
  border: var(--line);
  border-radius: var(--radius-md);
  background: var(--butter-pale);
  box-shadow: var(--shadow-sm);
  font-weight: 700;
}
.je-banner p { flex: 1; min-width: 220px; margin: 0; }
.je-banner[data-tone="warn"] { background: #fde2d0; }

/* ---- Layout -------------------------------------------------------------- */
.je-layout { display: flex; align-items: flex-start; }
.je-canvas { flex: 1; min-width: 0; padding: 30px 20px 140px; }
.je-paper {
  max-width: 900px;
  margin: 0 auto;
  padding: 44px clamp(20px, 5vw, 64px) 60px;
  background: var(--soft-white);
  border: var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.je-paper .eyebrow { margin-bottom: 8px; }

.je-title {
  display: block;
  width: 100%;
  margin: 0 0 8px;
  padding: 0;
  border: 0;
  outline: none;
  resize: none;
  overflow: hidden;
  background: transparent;
  color: var(--ink);
  font-family: 'Lobster', Georgia, serif;
  font-size: clamp(2.4rem, 5.5vw, 4rem);
  line-height: 1.08;
}
.je-title::placeholder { color: rgba(41, 32, 24, 0.3); }

.je-dateline { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; }
.je-date {
  padding: 4px 8px;
  border: 1.5px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--candy-red-dark);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.je-date:hover, .je-date:focus { border-color: rgba(41, 32, 24, 0.3); background: #fff; outline: none; }

/* Cover photo */
.je-cover { margin: 0 0 30px; }
.je-cover-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 22px;
  border: 2px dashed rgba(41, 32, 24, 0.35);
  border-radius: var(--radius-lg);
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.je-cover-empty:hover { border-color: var(--candy-red); color: var(--candy-red-dark); background: #fff; }
.je-cover-empty svg { width: 22px; height: 22px; }
.je-cover .post-hero { position: relative; margin: 0; }
.je-cover-actions {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: flex;
  gap: 8px;
}
.je-chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 7px 13px;
  border: var(--line);
  border-radius: var(--radius-pill);
  background: var(--soft-white);
  color: var(--ink);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 2px 2px 0 #000;
  white-space: nowrap;
}
.je-chip-btn:hover { background: var(--butter-pale); }
.je-chip-btn.is-danger:hover { background: var(--candy-red); color: #fff; }
.je-chip-btn svg { width: 16px; height: 16px; }
.je-cover-uploading { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(255, 250, 240, 0.72); font-weight: 900; }

/* ---- The writing surface ------------------------------------------------- */
.je-editor .ProseMirror { outline: none; min-height: 50vh; }
.je-editor .ProseMirror > *:first-child { margin-top: 0; }
.je-editor .ProseMirror p.is-editor-empty:first-child::before,
.je-editor .ProseMirror p.is-empty::before {
  content: attr(data-placeholder);
  float: left;
  height: 0;
  color: rgba(41, 32, 24, 0.32);
  pointer-events: none;
}
.je-editor .ProseMirror a { cursor: text; }
.je-editor .ProseMirror-selectednode { outline: none; }
.je-editor .ProseMirror .mc-figure.is-selected .mc-frame,
.je-editor .ProseMirror .mc-gallery.is-selected,
.je-editor .ProseMirror .mc-embed.is-selected,
.je-editor .ProseMirror .mc-button-row.is-selected,
.je-editor .ProseMirror hr.ProseMirror-selectednode {
  outline: 3px solid var(--sb-blue);
  outline-offset: 5px;
}
.je-editor .ProseMirror .mc-gallery.is-selected { border-radius: 12px; }
.je-editor .ProseMirror .mc-figure,
.je-editor .ProseMirror .mc-gallery,
.je-editor .ProseMirror .mc-embed,
.je-editor .ProseMirror .mc-button-row { cursor: pointer; }
.je-editor .ProseMirror .mc-button-row a { pointer-events: none; }
.je-editor .ProseMirror .mc-callout.has-focus { outline: 2px dashed var(--sb-blue); outline-offset: 4px; }
.je-editor .ProseMirror table .selectedCell { background: #dbe8ff; }
.je-editor .ProseMirror td, .je-editor .ProseMirror th { position: relative; min-width: 60px; }

/* Editable captions inside photo blocks */
.je-editor .mc-caption-edit {
  outline: none;
  cursor: text;
  min-height: 1.4em;
}
.je-editor .mc-caption-edit:empty { display: none; }
.je-editor .is-selected .mc-caption-edit:empty,
.je-editor .mc-caption-edit:focus { display: block; }
.je-editor .mc-caption-edit:empty::before { content: "Add a caption (optional)…"; color: rgba(41, 32, 24, 0.35); }

/* Upload states */
.je-editor .mc-frame .je-upl {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 16px;
  background: rgba(255, 250, 240, 0.78);
  color: var(--ink);
  font-weight: 900;
  font-size: 0.9rem;
  text-align: center;
}
.je-editor .je-upl-bar { width: 60%; height: 8px; border: var(--line); border-radius: 99px; background: #fff; overflow: hidden; }
.je-editor .je-upl-bar i { display: block; height: 100%; width: 0; background: var(--candy-red); transition: width 0.2s; }
.je-editor .je-upl-bar.is-busy i { width: 40%; animation: je-indet 1.1s ease-in-out infinite; }
@keyframes je-indet { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
.je-editor .je-upl[data-state="error"] { background: rgba(253, 226, 226, 0.92); color: var(--candy-red-dark); }
.je-editor .je-missing {
  display: grid;
  place-items: center;
  min-height: 180px;
  padding: 20px;
  background: repeating-linear-gradient(45deg, #f7ecd8 0 12px, #fbf3e3 12px 24px);
  color: var(--ink-soft);
  font-weight: 800;
  text-align: center;
}

/* Gallery editing */
.je-editor .mc-gallery .mc-frame { cursor: pointer; }
.je-gal-tools {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  display: none;
  gap: 4px;
}
.je-editor .mc-gallery.is-selected .je-gal-tools { display: flex; }
.je-gal-tools button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: var(--line);
  border-radius: 50%;
  background: var(--soft-white);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 2px 2px 0 #000;
}
.je-gal-tools button:hover { background: var(--butter-pale); }
.je-gal-tools button.is-danger:hover { background: var(--candy-red); color: #fff; }
.je-gal-tools svg { width: 14px; height: 14px; }
.je-gal-add {
  display: none;
  place-items: center;
  align-content: center;
  gap: 6px;
  min-height: 140px;
  border: 2px dashed rgba(41, 32, 24, 0.4);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.je-editor .mc-gallery.is-selected .je-gal-add { display: grid; }
.je-gal-add:hover { border-color: var(--candy-red); color: var(--candy-red-dark); background: #fff; }
.je-gal-add svg { width: 26px; height: 26px; }

/* Embed card in the editor */
.je-embed-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  border: var(--line);
  border-radius: var(--radius-md);
  background: #fff;
  box-shadow: var(--shadow-sm);
}
.je-embed-card img { width: 132px; aspect-ratio: 16 / 9; object-fit: cover; border: var(--line); border-radius: 10px; flex-shrink: 0; }
.je-embed-ic {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: var(--line);
  border-radius: 14px;
  background: var(--butter-pale);
  flex-shrink: 0;
}
.je-embed-ic svg { width: 28px; height: 28px; }
.je-embed-card strong { display: block; font-size: 1rem; color: var(--ink); }
.je-embed-card > div > span { display: block; overflow: hidden; max-width: 100%; font-size: 0.82rem; color: var(--ink-soft); white-space: nowrap; text-overflow: ellipsis; }
.je-embed-card .je-embed-ic svg { display: block; }
.je-embed-card > div { min-width: 0; }

/* ---- Floating block bar (appears on the selected photo/button/etc.) ------ */
.je-blockbar {
  position: fixed;
  z-index: 70;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  max-width: min(760px, calc(100vw - 24px));
  padding: 6px;
  border: var(--line);
  border-radius: 16px;
  background: var(--soft-white);
  box-shadow: var(--shadow-sm);
}
.je-bb-sep { width: 1.5px; align-self: stretch; margin: 4px 3px; background: rgba(41, 32, 24, 0.16); }
.je-bb-label { padding: 0 4px 0 6px; font-size: 0.72rem; font-weight: 900; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft); }
.je-seg { display: inline-flex; padding: 2px; border-radius: 10px; background: rgba(0, 0, 0, 0.05); }
.je-seg .je-tb { height: 32px; min-width: 32px; }
.je-bb-input {
  height: 34px;
  padding: 0 10px;
  border: 1.5px solid rgba(41, 32, 24, 0.3);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
}
.je-bb-input:focus { outline: 2px solid var(--sb-blue); outline-offset: 1px; }

/* ---- Popovers (menus, color pickers, link box, frame chooser) ----------- */
.je-pop {
  position: fixed;
  z-index: 90;
  min-width: 220px;
  max-width: min(420px, calc(100vw - 20px));
  max-height: min(70vh, 560px);
  overflow-y: auto;
  padding: 8px;
  border: var(--line);
  border-radius: 16px;
  background: var(--soft-white);
  box-shadow: var(--shadow-md);
}
.je-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}
.je-menu-item:hover, .je-menu-item:focus-visible { background: var(--butter-pale); outline: none; }
.je-menu-item.is-active { background: rgba(0, 0, 0, 0.06); }
.je-menu-item .je-mi-ic {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: var(--line);
  border-radius: 10px;
  background: #fff;
  flex-shrink: 0;
}
.je-menu-item .je-mi-ic svg { width: 20px; height: 20px; }
.je-menu-item small { display: block; font-size: 0.78rem; font-weight: 600; color: var(--ink-soft); }
.je-menu-item .je-style-sample { flex: 1; }
.je-pop h5 { margin: 6px 8px 8px; font-family: inherit; font-size: 0.72rem; font-weight: 900; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }

.je-swatches { display: grid; grid-template-columns: repeat(6, 34px); gap: 8px; padding: 4px 8px 8px; }
.je-swatch {
  width: 34px;
  height: 34px;
  padding: 0;
  border: var(--line);
  border-radius: 50%;
  cursor: pointer;
}
.je-swatch:hover { transform: scale(1.1); }
.je-swatch.is-active { box-shadow: 0 0 0 3px var(--soft-white), 0 0 0 5px var(--ink); }
.je-swatch-none { background: linear-gradient(135deg, #fff 45%, var(--candy-red) 45% 55%, #fff 55%); }

.je-frames { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 4px; width: 380px; max-width: 100%; }
.je-frame-opt {
  display: grid;
  gap: 6px;
  justify-items: center;
  padding: 8px 4px;
  border: 1.5px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.74rem;
  font-weight: 800;
  cursor: pointer;
}
.je-frame-opt:hover { background: var(--butter-pale); }
.je-frame-opt.is-active { border-color: var(--ink); background: #fff; }
.je-frame-opt .post-body { font-size: 0; }
.je-frame-opt .mc-figure { width: 58px !important; margin: 4px !important; float: none !important; }
.je-frame-opt .mc-frame { transform: none !important; }
.je-frame-opt .mc-figure[data-frame="stripe"] .mc-frame,
.je-frame-opt .mc-figure[data-frame="gold"] .mc-frame { padding: 5px; border-radius: 12px; background-size: auto; }
.je-frame-opt .mc-figure[data-frame="stripe"] .mc-frame { background: repeating-linear-gradient(45deg, var(--candy-red) 0 5px, var(--soft-white) 5px 10px); }
.je-frame-opt .mc-figure[data-frame="gold"] .mc-frame { background: repeating-linear-gradient(45deg, var(--gold) 0 5px, var(--warm-cream) 5px 10px); }
.je-frame-opt .mc-figure[data-frame="stripe"] img,
.je-frame-opt .mc-figure[data-frame="gold"] img { border-radius: 8px; }
.je-frame-opt .mc-figure[data-frame="polaroid"] .mc-frame { padding: 4px 4px 12px; }
.je-frame-opt .mc-figure[data-frame="mat"] .mc-frame { padding: 7px; box-shadow: 3px 3px 0 #000, inset 0 0 0 3px var(--soft-white), inset 0 0 0 4px var(--ink); }
.je-frame-opt .mc-frame { box-shadow: 3px 3px 0 #000 !important; }
.je-frame-opt .mc-figure[data-frame="plain"] .mc-frame { box-shadow: none !important; }
.je-frame-opt img { aspect-ratio: 1 / 1; object-fit: cover; }

.je-field { display: grid; gap: 6px; margin: 4px 6px 10px; }
.je-field span { font-size: 0.8rem; font-weight: 900; color: var(--ink-soft); }
.je-field input, .je-field textarea, .je-field select {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid rgba(41, 32, 24, 0.35);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
}
.je-field input:focus, .je-field textarea:focus { outline: 2px solid var(--sb-blue); outline-offset: 1px; }
.je-hint { margin: 0 6px 10px; font-size: 0.8rem; font-weight: 600; color: var(--ink-soft); }
.je-err { margin: 0 6px 10px; font-size: 0.84rem; font-weight: 800; color: var(--candy-red-dark); }
.je-pop-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 4px 6px 4px; }
.je-check { display: flex; align-items: center; gap: 8px; margin: 0 6px 10px; font-size: 0.88rem; font-weight: 700; cursor: pointer; }
.je-check input { width: 18px; height: 18px; accent-color: var(--candy-red); }

/* ---- Side panel (Post settings / History) ------------------------------- */
.je-panel {
  position: sticky;
  top: 118px;
  width: 360px;
  flex-shrink: 0;
  max-height: calc(100vh - 130px);
  overflow-y: auto;
  margin: 30px 18px 30px 0;
  padding: 20px;
  border: var(--line);
  border-radius: var(--radius-lg);
  background: var(--soft-white);
  box-shadow: var(--shadow-md);
}
.je-panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.je-panel-head h3 { margin: 0; font-size: 1.5rem; }
.je-x {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  color: var(--ink);
}
.je-x:hover { background: rgba(0, 0, 0, 0.07); }
.je-x svg { width: 20px; height: 20px; }
.je-panel section { padding: 14px 0; border-top: 1.5px dashed rgba(41, 32, 24, 0.25); }
.je-panel section:first-of-type { border-top: 0; padding-top: 0; }
.je-panel h4 { margin: 0 0 8px; font-family: inherit; font-size: 0.78rem; font-weight: 900; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
.je-panel .je-field { margin: 0 0 10px; }
.je-panel .je-hint { margin: 0 0 8px; }
.je-thumb-row { display: flex; align-items: center; gap: 12px; }
.je-thumb-row img { width: 96px; height: 72px; object-fit: cover; border: var(--line); border-radius: 12px; background: var(--aged-paper); }
.je-thumb-row > div { display: flex; flex-wrap: wrap; gap: 6px; }
.je-state-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: var(--line);
  border-radius: var(--radius-pill);
  font-size: 0.82rem;
  font-weight: 900;
  background: var(--butter-pale);
}
.je-state-pill[data-s="published"] { background: #d6ecd0; }
.je-state-pill[data-s="changed"] { background: #fde2d0; }
.je-state-pill[data-s="hidden"] { background: #e7e1d8; }
.je-panel .je-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.je-panel .je-chip-btn { white-space: normal; text-align: left; }
.je-thumb-row > div { min-width: 0; }
.je-kbd-list { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin: 0; font-size: 0.85rem; font-weight: 700; }
.je-kbd-list kbd { padding: 2px 7px; border: 1.5px solid rgba(41, 32, 24, 0.35); border-radius: 6px; background: #fff; font: inherit; font-size: 0.78rem; font-weight: 800; }

.je-hist-actions { margin: 4px 0 16px; }
.je-hist-list { display: grid; gap: 10px; }
.je-hist-item {
  display: grid;
  gap: 4px;
  padding: 12px;
  margin: 0;
  border: 1.5px solid rgba(41, 32, 24, 0.25);
  border-radius: 12px;
  background: #fff;
}
.je-hist-item strong { font-size: 0.95rem; }
.je-hist-item span { font-size: 0.8rem; font-weight: 700; color: var(--ink-soft); }
.je-hist-item .je-row { margin-top: 6px; }

.je-wordcount { margin-top: 30px; font-size: 0.82rem; font-weight: 800; color: var(--ink-soft); text-align: right; }

/* ---- Toast --------------------------------------------------------------- */
.je-toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 300;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100vw - 30px);
  padding: 12px 18px;
  border: var(--line);
  border-radius: var(--radius-md);
  background: var(--near-black);
  color: var(--butter-pale);
  font-weight: 800;
  box-shadow: var(--shadow-sm);
  transform: translate(-50%, calc(100% + 60px));
  visibility: hidden;
  transition: transform 0.25s cubic-bezier(.22, .8, .2, 1), visibility 0s linear 0.25s;
}
.je-toast.is-on { transform: translate(-50%, 0); visibility: visible; transition-delay: 0s; }
.je-toast button, .je-toast a {
  padding: 4px 10px;
  border: 1.5px solid var(--butter-pale);
  border-radius: 99px;
  background: transparent;
  color: var(--butter-pale);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

/* ---- Drop overlay -------------------------------------------------------- */
.je-drop {
  position: fixed;
  inset: 0;
  z-index: 250;
  display: grid;
  place-items: center;
  background: rgba(255, 241, 213, 0.82);
  pointer-events: none;
}
.je-drop div {
  padding: 26px 34px;
  border: 3px dashed var(--candy-red);
  border-radius: var(--radius-xl);
  background: var(--soft-white);
  font-family: 'Lobster', Georgia, serif;
  font-size: 1.8rem;
  color: var(--candy-red-dark);
}

/* ---- Lock / loading screens --------------------------------------------- */
.je-screen {
  display: grid;
  place-items: center;
  min-height: 70vh;
  padding: 30px;
  text-align: center;
}
.je-screen > div {
  max-width: 460px;
  padding: 34px;
  border: var(--line);
  border-radius: var(--radius-lg);
  background: var(--soft-white);
  box-shadow: var(--shadow-md);
}
.je-screen h2 { margin-bottom: 10px; }


/* ==========================================================================
   Preview — the real post page in a frame, at desktop or phone width
   ========================================================================== */
.je-preview {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  flex-direction: column;
  background: #eadcc0;
}
.je-pv-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--soft-white);
  border-bottom: var(--line);
}
.je-pv-modes {
  display: inline-flex;
  padding: 3px;
  border: var(--line);
  border-radius: var(--radius-pill);
  background: #fff;
}
.je-pv-mode {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 800;
  cursor: pointer;
}
.je-pv-mode svg { width: 17px; height: 17px; }
.je-pv-mode.is-on { background: var(--ink); color: var(--butter-pale); }
.je-pv-note { display: flex; align-items: center; gap: 10px; margin-left: auto; font-size: 0.8rem; font-weight: 800; color: var(--ink-soft); white-space: nowrap; }
.je-pv-draft { padding: 4px 10px; border: 1.5px solid var(--ink); border-radius: var(--radius-pill); background: var(--butter-pale); color: var(--ink); }
.je-pv-stage {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 28px 20px 56px;
}
.je-pv-wrap {
  position: relative;
  margin: 0 auto;
  overflow: hidden;
  border: var(--line);
  border-radius: 14px;
  background: var(--warm-cream);
  box-shadow: var(--shadow-md);
}
.je-pv-wrap.is-phone { border-radius: 26px; border-width: 2px; }
.je-pv-frame {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  border: 0;
  background: var(--warm-cream);
  transform-origin: 0 0;
}
.je-pv-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: start center;
  padding-top: 80px;
  background: var(--warm-cream);
  font-weight: 800;
  color: var(--ink-soft);
}

/* ==========================================================================
   Layout guards so nothing collides at in-between widths
   ========================================================================== */
.je-more { display: none; }
.je-dock { display: none; }
.je-scrim {
  position: fixed;
  inset: 0;
  z-index: 85;
  background: rgba(23, 20, 17, 0.4);
}
@media (max-width: 1180px) {
  .je-ghost .je-lbl { display: none; }
  .je-ghost { padding: 8px 11px; }
}
@media (max-width: 1100px) and (min-width: 761px) {
  .je-panel {
    position: fixed;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 80;
    width: auto;
    max-height: 78vh;
    margin: 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -6px 0 rgba(0, 0, 0, 0.9);
  }
}

/* Touch screens: no hover tooltips, bigger targets on photo tools */
@media (hover: none) {
  .je-tip { display: none !important; }
  .je-gal-tools button { width: 36px; height: 36px; }
  .je-gal-tools svg { width: 16px; height: 16px; }
}

/* ==========================================================================
   Phone (≤ 760px) — a writing app: compact top bar, toolbar docked at the
   bottom on top of the keyboard, menus as bottom sheets, panels full screen.
   ========================================================================== */
@media (max-width: 760px) {
  .je-top .stripe-bar { height: 6px; }
  .je-topbar { gap: 6px; min-height: 56px; padding: 6px 8px 6px 4px; }
  .je-back { padding: 8px 6px; gap: 0; }
  .je-back svg { width: 24px; height: 24px; display: block; }
  .je-back-lbl { display: none; }
  .je-docinfo { flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; }
  .je-docname { max-width: 100%; font-size: 1.05rem; line-height: 1.2; }
  .je-status { padding: 0; background: none !important; font-size: 0.74rem; gap: 6px; }
  .je-status i { width: 7px; height: 7px; }
  .je-top-actions { gap: 2px; }
  .je-desk-only { display: none !important; }
  .je-more { display: inline-flex; }
  .je-ghost { min-height: 42px; min-width: 42px; padding: 0; justify-content: center; }
  .je-ghost svg { width: 21px; height: 21px; }
  .je-publish { min-height: 40px; padding: 8px 14px; margin-left: 4px; font-size: 0.86rem; box-shadow: 3px 3px 0 #000; }

  .je-toolbar { display: none; }
  .je-blockbar { display: none !important; }

  .je-canvas { padding: 12px 10px calc(96px + env(safe-area-inset-bottom)); }
  .je-paper { padding: 22px 16px 30px; border-radius: var(--radius-md); box-shadow: var(--shadow-sm); }
  .je-title { font-size: clamp(2rem, 9vw, 2.6rem); }
  .je-date { font-size: 16px; }
  .je-cover-hint { display: none; }
  .je-cover-empty { padding: 18px; }
  .je-cover-actions { right: 10px; bottom: 10px; }
  .je-cover-actions .je-chip-btn { min-height: 38px; padding: 6px 11px; font-size: 0.8rem; }
  .je-banner { margin: 10px 10px 0; }
  .je-wordcount { margin-top: 22px; }
  .je-embed-card { gap: 12px; padding: 12px; }
  .je-embed-card img { width: 96px; }
  .je-embed-ic { width: 46px; height: 46px; }

  /* Bottom toolbar ------------------------------------------------------ */
  .je-dock {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: var(--je-kb, 0px);
    z-index: 75;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: var(--soft-white);
    border-top: var(--line);
    box-shadow: 0 -3px 0 rgba(0, 0, 0, 0.08);
  }
  body.je-kb-open .je-dock { padding-bottom: 6px; }
  body.je-previewing .je-dock,
  body.je-panel-open .je-dock { display: none; }
  .je-dock-row { display: flex; align-items: center; gap: 4px; min-height: 46px; }
  .je-dock-scroll {
    display: flex;
    align-items: center;
    gap: 3px;
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 22px, #000 calc(100% - 26px), transparent);
            mask-image: linear-gradient(to right, transparent 0, #000 22px, #000 calc(100% - 26px), transparent);
    padding: 0 24px 0 18px;
  }
  .je-dock-scroll::-webkit-scrollbar { display: none; }
  .je-dock-pin { display: flex; align-items: center; gap: 2px; flex: none; padding-left: 6px; border-left: 1.5px solid rgba(41, 32, 24, 0.16); }
  .je-dock .je-tb { min-width: 44px; height: 44px; border-radius: 12px; }
  .je-dock .je-tb svg { width: 21px; height: 21px; }
  .je-dock .je-tb-insert { padding: 0 13px 0 10px; gap: 5px; color: #fff; }
  .je-dock .je-tb-insert:active { background: var(--candy-red-dark); }
  .je-dock .je-bb-sep { height: 26px; align-self: center; margin: 0 3px; }
  .je-aa { font-family: Georgia, serif; font-size: 1.15rem; font-weight: 700; letter-spacing: -0.02em; }
  .je-kb-only { display: none; }
  body.je-kb-open .je-kb-only { display: inline-flex; }
  .je-list-only { display: none; }
  body.je-in-list .je-list-only { display: inline-flex; }
  .je-dock-done {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    flex: none;
    height: 44px;
    padding: 0 14px 0 11px;
    border: 0;
    border-radius: 12px;
    background: var(--ink);
    color: var(--butter-pale);
    font: inherit;
    font-size: 0.88rem;
    font-weight: 800;
    cursor: pointer;
  }
  .je-dock-done svg { width: 19px; height: 19px; }
  .je-dock-blockrow .je-dock-scroll { gap: 4px; }
  .je-dock-row > .je-dock-scroll:first-child { margin-left: -12px; }
  .je-dock-blockrow { gap: 6px; }
  .je-dock-blockrow .je-tb span { white-space: nowrap; }
  .je-dock-blockrow .je-seg { flex: none; }
  .je-dock-blockrow .je-seg .je-tb { height: 38px; min-width: 38px; }
  .je-dock-blockrow .je-bb-label { flex: none; }
  .je-dot { display: block; width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--ink); }

  /* Bottom sheets ---------------------------------------------------- */
  .je-pop.je-sheet {
    top: auto !important;
    left: 0 !important;
    right: 0;
    bottom: var(--je-kb, 0px);
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0;
    max-width: none;
    max-height: calc(var(--je-vvh, 100vh) - 48px);
    padding: 0 0 env(safe-area-inset-bottom);
    overflow: hidden;
    border-width: 1.5px 0 0;
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -4px 0 rgba(0, 0, 0, 0.85);
    animation: je-sheet-in 0.22s cubic-bezier(.22, .8, .2, 1);
  }
  body.je-kb-open .je-pop.je-sheet { padding-bottom: 0; }
  @keyframes je-sheet-in { from { transform: translateY(28px); opacity: 0; } to { transform: none; opacity: 1; } }
  .je-sheet-head {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex: none;
    padding: 20px 16px 12px;
    border-bottom: 1.5px dashed rgba(41, 32, 24, 0.25);
  }
  .je-grab { position: absolute; top: 7px; left: 50%; width: 40px; height: 5px; border-radius: 3px; background: rgba(41, 32, 24, 0.22); transform: translateX(-50%); }
  .je-sheet-title { font-family: 'Lobster', Georgia, serif; font-size: 1.4rem; font-weight: 400; line-height: 1.1; color: var(--ink); }
  .je-sheet-done {
    height: 38px;
    padding: 0 18px;
    border: 0;
    border-radius: var(--radius-pill);
    background: var(--ink);
    color: var(--butter-pale);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 800;
    cursor: pointer;
  }
  .je-sheet-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 12px 14px 18px; }
  .je-sheet-h5 { display: none; }
  .je-sheet .je-menu-item { min-height: 58px; padding: 10px 8px; }
  .je-sheet .je-field input,
  .je-sheet .je-field textarea { font-size: 16px; padding: 12px; }
  .je-sheet .je-pop-actions { padding-top: 6px; }
  .je-sheet .je-pop-actions .button { min-height: 46px; padding: 10px 22px; }
  .je-sheet .je-swatches { grid-template-columns: repeat(auto-fill, 40px); justify-content: space-between; gap: 12px; padding: 4px 2px 8px; }
  .je-sheet .je-swatch { width: 40px; height: 40px; }
  .je-sheet .je-frames { width: 100%; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .je-sheet .je-frame-opt { padding: 8px 2px; }

  /* Format sheet (Aa) */
  .je-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 3px; margin-bottom: 4px; border-radius: 12px; background: rgba(0, 0, 0, 0.06); }
  .je-tab { height: 38px; border: 1.5px solid transparent; border-radius: 10px; background: transparent; color: var(--ink-soft); font: inherit; font-size: 0.9rem; font-weight: 800; cursor: pointer; }
  .je-tab.is-on { border-color: var(--ink); background: #fff; color: var(--ink); }
  .je-sec { margin: 16px 2px 8px; font-family: inherit; font-size: 0.72rem; font-weight: 900; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
  .je-style-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .je-style-opt {
    display: flex;
    align-items: center;
    min-height: 52px;
    padding: 8px 12px;
    border: 1.5px solid rgba(41, 32, 24, 0.22);
    border-radius: 12px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    text-align: left;
    cursor: pointer;
    overflow: hidden;
  }
  .je-style-opt.is-active { border-color: var(--ink); background: var(--butter-pale); box-shadow: 2px 2px 0 #000; }
  .je-seg-wide { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; width: 100%; margin-top: 12px; }
  .je-sec + .je-seg-wide { margin-top: 0; }
  .je-seg-wide .je-tb { height: 46px; width: 100%; }
  .je-color-row { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 8px; scrollbar-width: none; }
  .je-color-row::-webkit-scrollbar { display: none; }
  .je-color-row .je-swatch { flex: none; width: 40px; height: 40px; }
  .je-wide-btn { width: 100%; justify-content: center; min-height: 46px; margin-top: 16px; }

  /* Post settings / History: full screen ---------------------------- */
  .je-panel {
    position: fixed;
    inset: 0;
    z-index: 95;
    width: auto;
    max-height: none;
    margin: 0;
    padding: 0 16px calc(28px + env(safe-area-inset-bottom));
    border: 0;
    border-radius: 0;
    box-shadow: none;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .je-panel-head {
    position: sticky;
    top: 0;
    z-index: 2;
    margin: 0 -16px 16px;
    padding: max(12px, env(safe-area-inset-top)) 12px 12px 16px;
    background: var(--soft-white);
    border-bottom: var(--line);
  }
  .je-panel-head h3 { font-size: 1.6rem; }
  .je-x { width: 44px; height: 44px; }
  .je-panel .je-field input, .je-panel .je-field textarea { font-size: 16px; }
  .je-panel .je-chip-btn { min-height: 42px; }
  body.je-panel-open { overflow: hidden; }

  /* Preview on a phone */
  .je-pv-bar { gap: 8px; padding: 8px 10px; padding-top: max(8px, env(safe-area-inset-top)); }
  .je-pv-close { min-width: 42px; padding: 0 8px; }
  .je-pv-close span { display: none; }
  .je-pv-modes { margin: 0 auto; }
  .je-pv-mode { height: 36px; padding: 0 13px; }
  .je-pv-note { display: none; }
  .je-pv-stage { padding: 14px 10px 32px; }

  /* Toasts sit above the bottom toolbar */
  .je-toast { bottom: calc(var(--je-kb, 0px) + 74px + env(safe-area-inset-bottom)); width: max-content; max-width: calc(100vw - 24px); font-size: 0.9rem; }
  body.je-previewing .je-toast,
  body.je-panel-open .je-toast { bottom: calc(18px + env(safe-area-inset-bottom)); }
}
