.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

#add-component {
  padding: 8px 16px;
  background: var(--teal);
  color: var(--navy);
  border: 0;
  border-radius: 99px;
  font-weight: 700;
  cursor: pointer;
}

#add-component-menu {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  display: grid;
  min-width: 14rem;
  max-height: min(70vh, calc(100vh - 10rem));
  overflow-y: auto;
  overscroll-behavior: contain;
  gap: 4px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  z-index: 30;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

#add-component-menu[hidden] { display: none; }

#add-component-menu button {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: transparent;
  color: var(--ink);
  border: 1px solid transparent;
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
}

#add-component-menu button:hover {
  background: var(--surface-lift);
  border-color: var(--teal);
  color: var(--teal);
}

#add-component-menu button img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  border-radius: 4px;
  background: #fff; /* help see some icons if they are dark */
}

.add-component-icon {
  display: grid;
  flex: 0 0 24px;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 5px;
  background: #f00;
  color: #fff;
  font-size: 12px;
}

.add-component-icon--image { background: #243247; color: #9cc8ff; }

.editor-canvas {
  position: relative;
  width: 100%;
  height: calc(100vh - 5.8rem - 4rem);
  min-height: 480px;
  background: var(--navy);
  border: 1px solid var(--line);
  overflow: auto;
  cursor: crosshair;
  --editor-workspace-height: 3000px;
}

/* Keep a generous empty workspace so authors can scroll and place content far below the first screen. */
.editor-canvas::after {
  content: '';
  position: absolute;
  top: var(--editor-workspace-height);
  left: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.editor-component {
  position: absolute;
  cursor: move;
  box-sizing: border-box;
  padding: 5px;
  border: 1px solid transparent;
  user-select: none;
  min-width: 20px;
  min-height: 20px;
}

.editor-component > h1,
.editor-component > h2,
.editor-component > h3,
.editor-component > p,
.editor-component > img,
.editor-component > article,
.editor-component > button,
.editor-component > .editor-social-button {
  box-sizing: border-box;
  max-width: 100%;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.editor-component > h1,
.editor-component > h2,
.editor-component > h3,
.editor-component > p {
  overflow: visible;
}

.resize-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--teal);
  border-radius: 50%;
  display: none;
  padding: 0;
  border: 2px solid var(--navy);
  z-index: 4;
  touch-action: none;
}

.editor-component.selected .resize-handle {
  display: block;
}

.resize-handle-nw { top: -5px; left: -5px; cursor: nwse-resize; }
.resize-handle-ne { top: -5px; right: -5px; cursor: nesw-resize; }
.resize-handle-sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
.resize-handle-se { bottom: -5px; right: -5px; cursor: nwse-resize; }

.editor-component:hover {
  border: 1px dashed var(--teal);
}

.editor-component.selected {
  outline: 2px solid var(--teal);
  outline-offset: 4px;
  background: rgba(121, 229, 197, 0.05);
}

.editor-component.text-overflowed.selected {
  outline: none;
  background: transparent;
}

.editor-component.text-overflowed.selected::after {
  content: '';
  position: absolute;
  z-index: 3;
  pointer-events: none;
  top: calc(0px - var(--text-overflow-half-y));
  left: calc(0px - var(--text-overflow-half-x));
  width: calc(100% + var(--text-overflow-full-x));
  height: calc(100% + var(--text-overflow-full-y));
  border: 2px solid var(--teal);
  outline: 4px solid transparent;
}

.editor-component.text-overflowed.selected .resize-handle-nw { top: calc(-5px - var(--text-overflow-half-y)); left: calc(-5px - var(--text-overflow-half-x)); }
.editor-component.text-overflowed.selected .resize-handle-ne { top: calc(-5px - var(--text-overflow-half-y)); right: calc(-5px - var(--text-overflow-half-x)); }
.editor-component.text-overflowed.selected .resize-handle-sw { bottom: calc(-5px - var(--text-overflow-half-y)); left: calc(-5px - var(--text-overflow-half-x)); }
.editor-component.text-overflowed.selected .resize-handle-se { bottom: calc(-5px - var(--text-overflow-half-y)); right: calc(-5px - var(--text-overflow-half-x)); }

.editor-component.editing {
  cursor: text;
  user-select: text;
}

.editor-component.editing > h1,
.editor-component.editing > h2,
.editor-component.editing > h3,
.editor-component.editing > p {
  cursor: text;
  user-select: text;
  outline: 1px dashed var(--teal);
  outline-offset: 4px;
}

.terminal-window {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid #334155;
  border-radius: 10px;
  background: #0b1120;
  box-shadow: 0 14px 30px rgba(0, 0, 0, .35);
  color: #e2e8f0;
  font-family: 'DM Mono', monospace;
}

.terminal-chrome {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: #1e293b;
  color: #94a3b8;
  font-size: .72rem;
}

.terminal-chrome span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ef4444;
}

.terminal-chrome span:nth-child(2) { background: #f59e0b; }
.terminal-chrome span:nth-child(3) { background: #22c55e; }
.terminal-chrome b { margin-left: 8px; font-weight: 500; }
.terminal-copy {
  margin-left: auto;
  padding: 3px 8px;
  border: 1px solid #64748b;
  border-radius: 4px;
  background: transparent;
  color: #cbd5e1;
  cursor: pointer;
  font: inherit;
  font-size: .68rem;
}
.terminal-copy:hover { border-color: var(--teal); color: var(--teal); }

.terminal-content {
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  padding: 18px;
  white-space: pre-wrap;
  overflow: auto;
  overflow-wrap: anywhere;
  color: #cbd5e1;
  font-size: .9rem;
}

.terminal-prompt { color: #79e5c5; }
.terminal-copy-status {
  display: block;
  min-height: 1.2em;
  padding: 0 18px 8px;
  color: var(--teal);
  font: .68rem 'DM Mono', monospace;
}

.editor-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  white-space: nowrap;
  font-family: 'DM Mono', monospace;
  font-weight: 400;
}

.editor-divider--one {
  color: #79e3c3;
  font-size: .72rem;
}

.editor-divider--one::before {
  content: '';
  flex: 0 0 46px;
  height: 1px;
  background: #79e3c3;
}

.editor-divider--two {
  color: #657081;
  font-size: .68rem;
}

.editor-divider--two::before {
  content: '';
  flex: 0 0 28px;
  height: 1px;
  background: currentColor;
}

.editor-divider--three {
  color: #526171;
  font-size: .62rem;
  letter-spacing: .08em;
}

.editor-divider--three::after {
  content: '';
  flex: 0 0 80px;
  height: 1px;
  background: #293447;
}

.editor-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  overflow: hidden;
  padding: calc(27px * var(--card-scale, 1));
  border: 1px solid #2a3446;
  background: #111827;
  color: var(--ink);
  text-align: left;
}

.editor-card-number {
  margin: calc(8px * var(--card-scale, 1)) 0 calc(37px * var(--card-scale, 1));
  color: #718096;
  font: 400 calc(11px * var(--card-scale, 1)) / 1.2 'DM Mono', monospace;
}

.editor-card-symbol {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  box-sizing: border-box;
  width: calc(45px * var(--card-scale, 1));
  height: calc(45px * var(--card-scale, 1));
  margin-bottom: calc(17px * var(--card-scale, 1));
  border: 1px solid var(--card-accent, #79e3c3);
  border-radius: calc(12px * var(--card-scale, 1));
  color: var(--card-accent, #79e3c3);
  font: 500 calc(12px * var(--card-scale, 1)) / 1 'DM Mono', monospace;
}

.editor-card-symbol--emoji {
  color: transparent;
  background: var(--card-accent, #79e3c3);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font: 500 calc(25px * var(--card-scale, 1)) / 1 sans-serif;
}

.editor-card h2 {
  max-width: 100%;
  margin: 0;
  color: #f3f5fa;
  font-size: calc(20px * var(--card-scale, 1));
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.editor-card p {
  max-width: min(100%, calc(245px * var(--card-scale, 1)));
  margin: calc(10px * var(--card-scale, 1)) 0 0;
  color: #94a3b8;
  font-size: calc(13px * var(--card-scale, 1));
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.editor-card-bottom-line {
  flex: 0 0 auto;
  align-self: flex-end;
  width: calc(40px * var(--card-scale, 1));
  height: 1px;
  margin-top: auto;
  background: var(--card-accent, #79e3c3);
}

.editor-youtube-video {
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  gap: 7px;
  overflow: hidden;
}

.editor-youtube-video iframe {
  display: block;
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  min-height: 0;
  border: 0;
  border-radius: 8px;
  background: #000;
}

.editor-youtube-open {
  align-self: flex-end;
  flex: 0 0 auto;
  padding: 2px 4px;
  color: #f87171;
  font: 600 .72rem 'DM Mono', monospace;
  text-decoration: none;
}

.editor-youtube-open:hover { color: #fff; text-decoration: underline; }

.editor-action-button[aria-disabled="true"] {
  cursor: not-allowed !important;
  opacity: .72;
  filter: saturate(.72);
}

.editor-youtube-error {
  display: grid;
  flex: 1 1 auto;
  place-items: center;
  min-height: 0;
  border: 1px dashed #64748b;
  border-radius: 8px;
  background: #080b12;
  color: #cbd5e1;
  font-size: .9rem;
  text-align: center;
}

.editor-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  user-select: none;
}

.youtube-url-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(3, 7, 16, .78);
  backdrop-filter: blur(5px);
}

.youtube-url-backdrop[hidden] { display: none; }

.youtube-url-dialog {
  box-sizing: border-box;
  width: min(460px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .55);
}

.youtube-url-dialog .eyebrow { margin: 0 0 8px; color: #f87171; }
.youtube-url-dialog h2 { margin: 0 0 20px; color: var(--ink); font-size: 1.3rem; }
.youtube-url-dialog label { display: block; margin-bottom: 7px; color: #aab4c5; font-size: .85rem; }

.youtube-url-dialog input {
  box-sizing: border-box;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--navy);
  color: var(--ink);
}

.youtube-url-dialog input:focus-visible,
.youtube-url-dialog button:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.youtube-url-error { margin: 8px 0 0; color: #fca5a5; font-size: .82rem; }

.youtube-url-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 20px;
}

.youtube-url-actions button {
  min-height: 42px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.youtube-url-cancel { background: transparent; color: var(--ink); }
.youtube-url-submit { border-color: #f87171 !important; background: #f87171; color: #0b0f1c; font-weight: 700; }

.button-login-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(3, 7, 16, .78);
  backdrop-filter: blur(5px);
}

.button-login-backdrop[hidden] { display: none; }

.button-login-dialog {
  box-sizing: border-box;
  width: min(420px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .55);
}

.button-login-dialog .eyebrow { margin: 0 0 8px; color: var(--teal); }
.button-login-dialog h2 { margin: 0 0 8px; color: var(--ink); font-size: 1.3rem; }
.button-login-dialog p:not(.eyebrow) { margin: 0; color: #aab4c5; }

.button-login-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 20px;
}

.button-login-actions button,
.button-login-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.button-login-actions a { border-color: var(--teal); background: var(--teal); color: var(--navy); font-weight: 700; }
.button-login-actions button:focus-visible,
.button-login-actions a:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

.image-library-backdrop,
.image-preview-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(3, 7, 16, .8);
  backdrop-filter: blur(5px);
}

.image-library-backdrop { z-index: 1300; }
.image-preview-backdrop { z-index: 1400; }
.image-library-backdrop.image-library-for-cover { z-index: 1520; }
.image-preview-backdrop.image-preview-for-cover { z-index: 1530; }
.image-library-backdrop[hidden],
.image-preview-backdrop[hidden] { display: none; }

.image-library,
.image-preview-dialog {
  box-sizing: border-box;
  width: min(1000px, 100%);
  max-height: min(860px, 90vh);
  padding: 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .58);
}

.image-library {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.image-library-header {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.image-library-header h2,
.image-preview-dialog h2 {
  margin: 0;
  color: var(--ink);
  font-size: 1.45rem;
}

.image-library-header p {
  margin: 5px 0 0;
  color: #aab4c5;
  font-size: .9rem;
}

.image-library-back,
.image-preview-actions button {
  min-height: 44px;
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-lift);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.image-library-back:hover,
.image-preview-actions button:hover { border-color: var(--teal); }
.image-library-back:focus-visible,
.image-preview-actions button:focus-visible,
.image-upload-card:focus-visible,
.image-library-item:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

.image-library-status {
  flex: 0 0 auto;
  min-height: 1.2em;
  margin: 12px 0 4px;
  color: #aab4c5;
  font-size: .82rem;
}

.image-library-status.is-error { color: #fca5a5; }
.image-library-status.is-success { color: var(--teal); }

.image-upload-progress {
  flex: 0 0 auto;
  margin: 2px 0 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #101827;
}

.image-upload-progress[hidden] { display: none; }
.image-upload-progress-label { margin-bottom: 8px; color: var(--ink); font: .76rem 'DM Mono', monospace; }
.image-upload-progress progress { display: block; width: 100%; height: 8px; accent-color: var(--teal); }

.image-library-grid {
  display: grid;
  flex: 1 1 auto;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-content: start;
  gap: 14px;
  min-height: 0;
  padding: 2px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.image-upload-card,
.image-library-item {
  box-sizing: border-box;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #101827;
  color: var(--ink);
}

.image-upload-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 178px;
  padding: 18px;
  border-style: dashed;
  cursor: pointer;
  text-align: center;
}

.image-upload-card:hover { border-color: var(--teal); background: rgba(121, 227, 195, .06); }

.image-upload-plus {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid var(--teal);
  border-radius: 50%;
  color: var(--teal);
  font-size: 1.8rem;
  line-height: 1;
}

.image-upload-card strong { font-size: .95rem; }
.image-upload-card small { color: #94a3b8; font-size: .7rem; }

.image-library-item {
  display: flex;
  flex-direction: column;
  padding: 0;
  cursor: pointer;
  text-align: left;
}

.image-library-item:hover { border-color: var(--teal); transform: translateY(-1px); }

.image-library-item img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #080b12;
}

.image-library-item time {
  padding: 9px 10px 10px;
  color: #b5c0d0;
  font: .72rem 'DM Mono', monospace;
  text-align: center;
}

.image-library-empty {
  grid-column: 2 / -1;
  display: grid;
  place-items: center;
  min-height: 178px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  color: #94a3b8;
  text-align: center;
}

.image-preview-dialog {
  display: flex;
  flex-direction: column;
  width: min(900px, 100%);
  gap: 16px;
}

.image-preview-frame {
  display: grid;
  place-items: center;
  min-height: 180px;
  max-height: 65vh;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #080b12;
}

.image-preview-frame img {
  display: block;
  max-width: 100%;
  max-height: 62vh;
  object-fit: contain;
}

.image-preview-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.image-preview-actions button:last-child { border-color: var(--teal); background: var(--teal); color: var(--navy); font-weight: 700; }

.card-symbol-picker {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-lift);
  color: var(--ink);
  cursor: pointer;
}

.card-symbol-picker span:first-child {
  display: grid;
  place-items: center;
  min-width: 30px;
  color: var(--teal);
  font: 600 14px 'DM Mono', monospace;
}

.card-symbol-picker:hover { border-color: var(--teal); }

.symbol-library-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(3, 7, 16, .78);
  backdrop-filter: blur(5px);
}

.symbol-library-backdrop[hidden] { display: none; }

.symbol-library {
  display: flex;
  flex-direction: column;
  width: min(780px, 100%);
  max-height: min(780px, 90vh);
  min-height: 0;
  padding: 22px;
  overflow: hidden;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .55);
}

.symbol-library-header {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.symbol-library-header .eyebrow { margin: 0 0 6px; color: var(--teal); }
.symbol-library-header h2 { margin: 0; color: var(--ink); font-size: 1.3rem; }

.symbol-library-close {
  display: grid;
  flex: 0 0 44px;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  font-size: 1.6rem;
  cursor: pointer;
}

.symbol-library-search-label {
  flex: 0 0 auto;
  margin: 20px 0 7px;
  color: var(--ink-muted, #94a3b8);
  font-size: .8rem;
}

.symbol-library-search {
  flex: 0 0 auto;
  box-sizing: border-box;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: var(--navy);
  color: var(--ink);
}

.symbol-library-search:focus-visible,
.symbol-library button:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.symbol-library-categories {
  display: flex;
  flex: 0 0 auto;
  gap: 7px;
  margin: 16px 0 12px;
  padding: 2px 2px 6px;
  overflow-x: auto;
}

.symbol-category {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: transparent;
  color: #aab4c5;
  cursor: pointer;
}

.symbol-category:hover,
.symbol-category.is-active {
  border-color: var(--teal);
  background: rgba(121, 227, 195, .1);
  color: var(--teal);
}

.symbol-library-grid {
  display: grid;
  flex: 1 1 auto;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 9px;
  min-height: 0;
  padding: 2px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.symbol-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  min-height: 76px;
  padding: 7px 4px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--navy);
  color: var(--ink);
  cursor: pointer;
}

.symbol-choice:hover {
  border-color: var(--teal);
  background: rgba(121, 227, 195, .08);
}

.symbol-choice > span {
  display: grid;
  place-items: center;
  min-height: 26px;
  color: var(--teal);
  font: 600 19px / 1 'DM Mono', monospace;
}

.symbol-choice small {
  max-width: 100%;
  overflow: hidden;
  color: #94a3b8;
  font-size: .63rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.symbol-library-empty {
  margin: 20px 0;
  color: #aab4c5;
  text-align: center;
}

@media (max-width: 600px) {
  .symbol-library { padding: 16px; }
  .symbol-library-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .image-library, .image-preview-dialog { padding: 16px; }
  .image-library-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .image-upload-card { min-height: 145px; padding: 12px; }
}

.editor-social-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .55em;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  padding: .55em 1em;
  border: 2px solid transparent;
  border-radius: 999px;
  color: #fff;
  font-size: .9rem;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}

.editor-social-button svg {
  flex: 0 0 1.25em;
  width: 1.25em;
  height: 1.25em;
  fill: currentColor;
}

.editor-social-button--discord {
  border-color: #fff;
  background: #5966f1;
  box-shadow: 0 2px 0 rgba(0, 0, 0, .35);
}

.editor-social-button--github {
  border-color: #222;
  background: #151515;
  font-weight: 600;
}

.editor-social-button:hover {
  transform: translateY(-2px) scale(1.04);
  filter: brightness(1.12);
  box-shadow: 0 7px 18px rgba(0, 0, 0, .28);
}

.highlighted-text,
.highlighted-text * {
  color: #79e3c3 !important;
  font-weight: 700 !important;
}

.typing-animation {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  border-right: .15em solid var(--teal);
  white-space: nowrap;
  margin: 0;
  letter-spacing: normal;
  /* Use variable delay if set, otherwise fallback to 3.5s */
  animation:
    typing var(--typing-delay, 3.5s) steps(40, end),
    blink-caret .75s step-end infinite;
}

@keyframes typing {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}

@keyframes blink-caret {
  from, to { border-color: transparent }
  50% { border-color: var(--teal); }
}

#property-panel {
  position: fixed;
  right: 20px;
  top: 100px;
  background: var(--surface);
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  z-index: 1000;
  color: var(--ink);
  min-width: 220px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
}

.property-panel h3 {
  margin: 0 0 15px 0;
  font-size: 0.9rem;
  text-transform: uppercase;
  color: var(--teal);
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.editor-property-field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.editor-property-field label {
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: .68rem;
  text-transform: uppercase;
}

.editor-property-field input,
.editor-property-field select,
.editor-property-field textarea {
  padding: 8px;
  background: var(--navy);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
}

.editor-property-field textarea {
  min-height: 8rem;
  resize: vertical;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: 'DM Mono', monospace;
}

.editor-multiselect-summary {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: .8rem;
}

.editor-multiselect-actions {
  display: grid;
  gap: 8px;
}

.editor-multiselect-actions button {
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--navy);
  color: var(--ink);
  cursor: pointer;
}

.editor-multiselect-actions button:hover:not(:disabled) { border-color: var(--teal); }
.editor-multiselect-actions button:disabled { cursor: not-allowed; opacity: .5; }
.editor-multiselect-actions button:nth-child(2) { color: #fca5a5; }

.editor-page {
  display: block;
  min-height: auto;
  padding: 0;
  place-items: stretch;
}

#editor-header[hidden], #editor-main[hidden] { display: none; }

.editor-toast {
  position: fixed;
  z-index: 1600;
  top: 88px;
  left: 50%;
  max-width: min(90vw, 360px);
  padding: 9px 16px;
  border: 1px solid rgba(121, 229, 197, .4);
  border-radius: 999px;
  background: var(--surface);
  color: var(--teal);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .32);
  font-size: .82rem;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -8px);
  transition: opacity .18s ease, transform .18s ease;
}

.editor-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.layout-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1450;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(3, 7, 16, .82);
  backdrop-filter: blur(7px);
}

.layout-backdrop[hidden] { display: none; }
.layout-backdrop--preview { z-index: 1460; }
.layout-backdrop--options { z-index: 1470; }
.save-post-backdrop { z-index: 1480; }
.save-post-preview-backdrop { z-index: 1490; }

.layout-dialog {
  box-sizing: border-box;
  width: min(520px, 100%);
  max-height: min(860px, 92vh);
  padding: 26px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 28px 90px rgba(0, 0, 0, .55);
}

.layout-dialog--compact { width: min(460px, 100%); }
.layout-dialog--library { display: flex; flex-direction: column; width: min(1050px, 100%); height: min(780px, 90vh); }
.layout-dialog h2 { margin: 0; font-size: 1.55rem; }
.layout-dialog-copy,
.layout-dialog-header p:not(.eyebrow) { margin: 6px 0 18px; color: #aab4c5; font-size: .9rem; }
.layout-dialog .eyebrow { margin: 0 0 7px; color: var(--teal); font: .68rem 'DM Mono', monospace; letter-spacing: .1em; }
.layout-dialog > label:not(.layout-choice-group label),
.layout-search-label { display: block; margin: 16px 0 7px; color: #bdc7d5; font-size: .78rem; }
.layout-dialog input[type="text"],
.layout-search {
  box-sizing: border-box;
  width: 100%;
  min-height: 46px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  background: #0b101b;
  color: var(--ink);
  font: inherit;
}
.layout-dialog input:focus-visible { border-color: var(--teal); outline: 2px solid rgba(121, 229, 197, .2); }
.layout-dialog-status { min-height: 1.3em; margin: 8px 0; color: #aab4c5; font-size: .8rem; }
.layout-dialog-status.is-error { color: #fca5a5; }
.layout-dialog-status.is-success { color: var(--teal); }

.layout-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.layout-actions button,
.layout-back {
  min-height: 44px;
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-lift);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.layout-actions button:last-child { border-color: var(--teal); background: var(--teal); color: var(--navy); font-weight: 750; }
.layout-actions button:hover, .layout-back:hover { border-color: var(--teal); }
.layout-actions button:focus-visible, .layout-back:focus-visible, .layout-card:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

.save-post-cover-row { display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 10px; margin-top: 16px; color: #bdc7d5; font-size: .82rem; }
.save-post-cover-row > span:last-child { overflow: hidden; color: #9aa8ba; text-overflow: ellipsis; white-space: nowrap; }
#post-card-subheading, #post-card-keywords { box-sizing: border-box; width: 100%; min-height: 76px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 9px; background: #0b101b; color: var(--ink); font: inherit; resize: vertical; }
#post-card-subheading:focus-visible, #post-card-keywords:focus-visible { border-color: var(--teal); outline: 2px solid rgba(121, 229, 197, .2); }
.post-card-preview { overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: #101827; cursor: grab; user-select: none; touch-action: none; }
.post-card-preview:active { cursor: grabbing; }
.post-card-preview img { display: block; width: 100%; height: 230px; object-fit: cover; object-position: 50% 50%; pointer-events: none; }
.post-card-preview > div { padding: 18px; }
.post-card-preview h3 { margin: 0; color: var(--ink); font-size: 1.1rem; }
.post-card-preview p { margin: 8px 0 0; color: #aab4c5; line-height: 1.55; }
.layout-dialog--compact .layout-choice-group { margin: 15px 0; }
@media (max-width: 520px) { .save-post-cover-row { grid-template-columns: 1fr auto; } .save-post-cover-row > span:last-child { grid-column: 1 / -1; } .post-card-preview img { height: 190px; } }

.layout-dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.layout-dialog-header p:not(.eyebrow) { margin-bottom: 0; }
.layout-dialog--library .layout-search-label { margin-top: 13px; }
.layout-dialog--library .layout-dialog-status { flex: 0 0 auto; }
.layout-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-content: start; gap: 12px; min-height: 0; overflow: auto; }
.layout-card {
  display: flex;
  min-height: 132px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #101827;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: border-color .16s ease, transform .16s ease;
}
.layout-card:hover { transform: translateY(-2px); border-color: var(--teal); }
.layout-card strong { overflow-wrap: anywhere; font-size: .88rem; }
.layout-card small { color: #9aa8ba; font: .68rem 'DM Mono', monospace; }
.layout-card-mark { display: grid; width: 30px; height: 30px; place-items: center; border: 1px solid rgba(121, 229, 197, .35); border-radius: 8px; color: var(--teal); font-size: .9rem; }
.layout-empty { grid-column: 1 / -1; display: grid; min-height: 130px; place-items: center; color: #9aa8ba; text-align: center; }

.layout-dialog--preview { width: min(680px, 100%); }
.layout-preview-canvas { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; max-height: 45vh; padding: 12px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; background: #0b101b; }
.layout-preview-item { min-width: 0; padding: 10px; overflow: hidden; border: 1px solid rgba(219, 228, 244, .1); border-radius: 8px; background: #111a28; }
.layout-preview-item strong { display: block; margin-bottom: 4px; color: var(--teal); font-size: .68rem; text-transform: uppercase; }
.layout-preview-item span { display: block; overflow: hidden; color: #d6deea; font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.layout-choice-group { display: grid; gap: 8px; margin: 18px 0; padding: 0; border: 0; }
.layout-choice-group legend { margin-bottom: 9px; color: var(--teal); font: .72rem 'DM Mono', monospace; text-transform: uppercase; }
.layout-choice-group label { display: flex; align-items: flex-start; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #101827; cursor: pointer; }
.layout-choice-group label:has(input:checked) { border-color: var(--teal); background: rgba(121, 229, 197, .06); }
.layout-choice-group input { margin-top: 4px; accent-color: var(--teal); }
.layout-choice-group strong, .layout-choice-group small { display: block; }
.layout-choice-group strong { font-size: .84rem; }
.layout-choice-group small { margin-top: 3px; color: #9aa8ba; font-size: .74rem; }

@media (max-width: 760px) {
  .layout-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout-dialog { padding: 20px; }
  .layout-dialog-header { gap: 10px; }
}

.editor-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

#editor-toolbar {
  position: sticky;
  top: 5.8rem;
  z-index: 20;
}
