/* ═══════════════════════ DISCORD EMBED ═══════════════════════ */
.dc-embed {
  display: flex;
  border-radius: 4px;
  overflow: visible;
  background: var(--dc-embed-bg);
  border: 1px solid var(--dc-embed-border);
  border-left: 4px solid var(--embed-color, #5865f2);
  position: relative;
  transition: box-shadow .14s, border-left-color .14s;
}
.edit-mode .dc-embed:hover {
  box-shadow: 0 0 0 1.5px rgba(88,101,242,.3);
}

.embed-color-btn {
  position: absolute;
  left: -32px;
  top: 8px;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--embed-color, #5865f2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 1;
  transform: translateX(0) scale(1);
  transition: opacity .12s, transform .12s, color .12s, border-color .12s;
  box-shadow: var(--shadow);
  z-index: 2;
}
.preview-mode .embed-color-btn { display: none; }
.embed-color-btn:hover {
  border-color: var(--border-focus);
  color: var(--accent);
}

/* Floating color input (rendered by JS) */
.floating-color-input {
  position: fixed;
  z-index: 10001;
  width: 1px;
  height: 1px;
  padding: 0;
  border: none;
  background: transparent;
  opacity: 0.001;
  pointer-events: none;
  left: -200px;
  top: -200px;
}

/* Content grid */
.dc-embed-content {
  padding: 8px 16px 14px 12px;
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  column-gap: 12px;
  overflow: hidden;
}
.dc-embed-content.has-thumbnail {
  grid-template-columns: minmax(0, 1fr) auto;
}

/* Grid placement */
.dc-embed-author        { grid-column: 1; }
.dc-embed-title         { grid-column: 1; }
.dc-embed-desc          { grid-column: 1; }
.dc-embed-fields        { grid-column: 1; }
.add-field-btn          { grid-column: 1; margin-bottom: 4px; }
.dc-img-ph              { grid-column: 1; }
.dc-embed-image         { grid-column: 1; }
.dc-embed-footer        { grid-column: 1; }
.dc-embed-thumbnail-slot {
  grid-column: 2;
  grid-row: 1 / span 4;
  align-self: start;
  margin-top: 6px;
}

.dc-embed-content.has-thumbnail .dc-embed-image,
/* .dc-embed-content.has-thumbnail .dc-img-ph,
.dc-embed-content.has-thumbnail .add-field-btn, */
.dc-embed-content.has-thumbnail .dc-embed-footer {
  grid-column: 1 / 3;
}

/* ── Author ── */
.dc-embed-author {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  min-height: 24px;
}

.dc-embed-author-icon {
  width: 24px; height: 24px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  cursor: pointer;
  transition: opacity .15s;
}
.dc-embed-author-icon:hover { opacity: .8; }

.dc-author-icon-ph {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 1.5px dashed var(--border);
  flex-shrink: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--dc-muted);
  cursor: pointer;
  transition: border-color .13s, color .13s;
}
.dc-author-icon-ph:hover { border-color: var(--accent); color: var(--accent); }
.edit-mode .dc-author-icon-ph { display: flex; }

.dc-embed-author-name {
  font-family: var(--font-dc);
  font-size: .875rem;
  font-weight: 600;
  color: var(--dc-hi);
  padding: 1px 3px;
  margin: 0 -3px;
  border-radius: 3px;
}

/* Link icon wrapper — used on author name + title in edit mode */
.embed-linkable {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  position: relative;
}

.embed-link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 4px;
  border-radius: 4px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  opacity: 1;
  transition: opacity .15s, background .12s, color .12s, border-color .12s;
  flex-shrink: 0;
}
.embed-linkable:hover .embed-link-btn {
  color: var(--accent);
  background: var(--bg-active);
}
.embed-link-btn.has-url {
  color: var(--accent);
  border-color: var(--border);
  background: var(--bg-input);
}

/* ── Title ── */
.dc-embed-title {
  font-family: var(--font-dc);
  font-size: 1rem;
  font-weight: 600;
  color: var(--dc-link);
  margin-bottom: 8px;
  padding: 1px 3px;
  margin-left: -3px;
  border-radius: 3px;
  word-break: break-word;
  line-height: 1.375;
}
.dc-embed-title.no-url { color: var(--dc-hi); }
.dc-embed-title-link { color: inherit; text-decoration: none; }

/* ── Description ── */
.dc-embed-desc {
  font-family: var(--font-dc);
  font-size: .875rem;
  color: var(--dc-text);
  line-height: 1.125rem;
  white-space: pre-line;
  word-break: break-word;
  margin-bottom: 4px;
  padding: 1px 3px;
  margin-left: -3px;
  border-radius: 3px;
}

/* ── Thumbnail ── */
.dc-embed-thumbnail-img {
  width: auto;
  height: auto;
  max-width: 80px;
  max-height: 80px;
  border-radius: 4px;
  object-fit: contain;
  display: block;
  cursor: pointer;
  transition: opacity .15s;
}
.dc-embed-thumbnail-img:hover { opacity: .85; }

.dc-thumb-ph {
  width: 80px; height: 80px;
  border-radius: 4px;
  border: 1.5px dashed rgba(255,255,255,.1);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  color: var(--dc-muted);
  font-size: 10px;
  text-align: center;
  line-height: 1.3;
  transition: border-color .13s, color .13s;
}
[data-theme="light"] .dc-thumb-ph { border-color: rgba(0,0,0,.1); }
.dc-thumb-ph:hover { border-color: var(--accent); color: var(--accent); }
.edit-mode .dc-thumb-ph { display: flex; }

/* ── Fields ── */
.dc-embed-fields {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: 8px;
  margin-bottom: 6px;
}

.dc-field {
  grid-column: span 3;
  position: relative;
}
.dc-field.inline { grid-column: span 1; }

.dc-field-name {
  font-family: var(--font-dc);
  font-size: .875rem;
  font-weight: 600;
  color: var(--dc-hi);
  margin-bottom: 2px;
  line-height: 1.125rem;
  padding: 1px 3px;
  margin-left: -3px;
  border-radius: 3px;
}

.dc-field-value {
  font-family: var(--font-dc);
  font-size: .875rem;
  color: var(--dc-text);
  line-height: 1.125rem;
  word-break: break-word;
  padding: 1px 3px;
  margin-left: -3px;
  border-radius: 3px;
}

/* Field toolbar */
.field-tools {
  position: absolute;
  top: -1px; right: 0;
  display: none;
  gap: 1px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
  box-shadow: var(--shadow-sm);
  z-index: 10;
}
.edit-mode .dc-field:hover .field-tools { display: flex; }

/* Hide empty field name/value in preview (no content = no space) */
.preview-mode .dc-field-name:empty,
.preview-mode .dc-field-value:empty { display: none; }
/* Hide entire field container when both name and value are empty */
.preview-mode .dc-field:has(.dc-field-name:empty):has(.dc-field-value:empty) { display: none; }
/* Hide the fields grid (and its margin-bottom) when all fields are empty */
.preview-mode .dc-embed-fields:not(:has(.dc-field-name:not(:empty))):not(:has(.dc-field-value:not(:empty))) { display: none; }

.field-tool-btn {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 3px 7px;
  border: none;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font);
  transition: background .1s, color .1s;
  white-space: nowrap;
}
.field-tool-btn:hover { background: var(--bg-hover); color: var(--text); }
.field-tool-btn.del:hover { background: var(--red-bg); color: var(--red); }
.field-tool-inline label { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.field-tool-inline input { accent-color: var(--accent); margin: 0; }

/* Add field button */
.add-field-btn {
  display: none;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: var(--r-sm);
  border: 1.5px dashed var(--border);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .13s, color .13s, background .13s;
  margin-top: 4px;
  width: 100%;
  justify-content: center;
}
.add-field-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--bg-active);
}
.edit-mode .add-field-btn { display: flex; }

/* ── Main image ── */
.dc-embed-image {
  width: auto;
  height: auto;
  max-width: 400px;
  max-height: 300px;
  border-radius: 4px;
  display: block;
  margin-bottom: 8px;
  cursor: pointer;
  transition: opacity .15s;
}
.dc-embed-image:hover { opacity: .85; }

/* Discord-like preview sizing: content-sized cards, with tighter max width when a main image exists. */
.preview-mode .dc-embed {
  width: fit-content;
  max-width: 100%;
}

.preview-mode .dc-embed.has-image {
  max-width: 432px;
}

.dc-img-ph {
  width: 100%;
  max-width: 400px;
  height: 80px;
  border-radius: 4px;
  border: 1.5px dashed rgba(255,255,255,.1);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  margin-bottom: 8px;
  color: var(--dc-muted);
  font-size: 12px;
  transition: border-color .13s, color .13s;
}
[data-theme="light"] .dc-img-ph { border-color: rgba(0,0,0,.1); }
.dc-img-ph:hover { border-color: var(--accent); color: var(--accent); }
.edit-mode .dc-img-ph { display: flex; }

/* ── Footer ── */
.dc-embed-footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
  clear: both;
}

.dc-embed-footer-icon {
  width: 20px; height: 20px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  cursor: pointer;
  transition: opacity .15s;
}
.dc-embed-footer-icon:hover { opacity: .8; }

.dc-footer-icon-ph {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 1.5px dashed rgba(255,255,255,.1);
  flex-shrink: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--dc-muted);
  cursor: pointer;
  transition: border-color .13s, color .13s;
}
[data-theme="light"] .dc-footer-icon-ph { border-color: rgba(0,0,0,.1); }
.dc-footer-icon-ph:hover { border-color: var(--accent); color: var(--accent); }
.edit-mode .dc-footer-icon-ph { display: flex; }

.dc-embed-footer-text {
  font-family: var(--font-dc);
  font-size: .75rem;
  font-weight: 500;
  color: var(--dc-muted);
  padding: 1px 3px;
  margin-left: -3px;
  border-radius: 3px;
}

.dc-footer-sep {
  font-family: var(--font-dc);
  font-size: .75rem;
  color: var(--dc-muted);
}

.dc-embed-footer-ts {
  font-family: var(--font-dc);
  font-size: .75rem;
  font-weight: 500;
  color: var(--dc-muted);
}

.dc-embed-footer-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.dc-embed-ts-mode,
.dc-embed-ts-custom {
  appearance: none;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  min-height: 28px;
  padding: 4px 8px;
  outline: none;
  transition: border-color .12s;
}
.dc-embed-ts-mode:focus,
.dc-embed-ts-custom:focus { border-color: var(--border-focus); }
.dc-embed-ts-mode  { min-width: 148px; }
.dc-embed-ts-custom { min-width: 188px; }

/* ── Delete button ── */
.embed-del-btn {
  display: none;
  position: absolute;
  top: -8px; right: -8px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--red);
  border: 2px solid var(--dc-embed-bg);
  cursor: pointer;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  align-items: center;
  justify-content: center;
  z-index: 10;
  opacity: 0;
  transition: opacity .17s;
  line-height: 1;
}
.edit-mode .embed-del-btn { display: flex; }
.edit-mode .dc-embed:hover .embed-del-btn { opacity: 1; }
