.xs-wysiwyg {
  position: relative;
  border: 1px solid rgba(0,0,0,.15);
  border-radius: .375rem;
  background: #fff;
  overflow: hidden;
}

.xs-wysiwyg-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem;
  padding: .5rem;
  border-bottom: 1px solid rgba(0,0,0,.1);
  background: rgba(0,0,0,.02);
  border-top-left-radius: .375rem;
  border-top-right-radius: .375rem;
}

.xs-wysiwyg-toolbar .xs-wysiwyg-format {
  width: auto;
  min-width: 170px;
}

.xs-wysiwyg-toolbar .xs-wysiwyg-font-size {
  width: auto;
  min-width: 120px;
}

.xs-wysiwyg-color-wrap {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: 0 .5rem;
  border: 1px solid rgba(0,0,0,.15);
  border-radius: .375rem;
  background: #fff;
  min-height: 31px;
}

.xs-wysiwyg-color-icon {
  color: rgba(0,0,0,.65);
  line-height: 1;
}

.xs-wysiwyg-color {
  width: 2rem;
  min-width: 2rem;
  height: 2rem;
  padding: .1rem;
  border: none;
  background: transparent;
}

.xs-wysiwyg-color::-webkit-color-swatch-wrapper {
  padding: 0;
}

.xs-wysiwyg-color::-webkit-color-swatch,
.xs-wysiwyg-color::-moz-color-swatch {
  border: 1px solid rgba(0,0,0,.15);
  border-radius: 50%;
}

.xs-wysiwyg-editor {
  position: relative;
  padding: .75rem;
  overflow: auto;
  outline: none;
  box-sizing: border-box;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

.xs-wysiwyg-editor > * {
  max-width: 100%;
}

.xs-wysiwyg-editor p,
.xs-wysiwyg-editor ul,
.xs-wysiwyg-editor ol,
.xs-wysiwyg-editor h1,
.xs-wysiwyg-editor h2,
.xs-wysiwyg-editor h3,
.xs-wysiwyg-editor h4,
.xs-wysiwyg-editor h5,
.xs-wysiwyg-editor h6,
.xs-wysiwyg-editor blockquote,
.xs-wysiwyg-editor pre {
  max-width: 100%;
}

.xs-wysiwyg-editor ul,
.xs-wysiwyg-editor ol {
  padding-left: 1.5rem;
  margin-left: 0;
}

.xs-wysiwyg-editor li {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.xs-wysiwyg-editor.is-col-resize,
.xs-wysiwyg-editor.is-col-resize * {
  cursor: col-resize !important;
}

.xs-wysiwyg-editor.is-row-resize,
.xs-wysiwyg-editor.is-row-resize * {
  cursor: row-resize !important;
}

.xs-wysiwyg-editor.is-table-resizing {
  user-select: none;
}

.xs-wysiwyg-editor:empty:before {
  content: attr(data-placeholder);
  color: rgba(0,0,0,.45);
}

/* textarea je v DOMu pro formuláře, ale v WYS režimu skrytá */
.xs-wysiwyg-textarea {
  display: none !important;
}

.xs-wysiwyg.is-text {
  border-style: dashed;
}

.xs-wysiwyg .btn i {
  line-height: 1;
}

.xs-wysiwyg-panel {
  position: absolute;
  z-index: 30;
}

.xs-wysiwyg-panel-card {
  background: #fff;
  border: 1px solid rgba(0,0,0,.16);
  border-radius: .75rem;
  box-shadow: 0 1rem 2rem rgba(15, 23, 42, .14);
  overflow: hidden;
}

.xs-wysiwyg-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .75rem 1rem;
  border-bottom: 1px solid rgba(0,0,0,.08);
  background: linear-gradient(180deg, #fff, #f8fafc);
}

.xs-wysiwyg-panel-title {
  font-size: .95rem;
  font-weight: 600;
  color: #1f2937;
}

.xs-wysiwyg-panel-body {
  max-height: min(28rem, 55vh);
  overflow: auto;
  padding: .9rem 1rem 1rem;
}

.xs-wysiwyg-panel-tabs {
  gap: .25rem;
  border-bottom: 1px solid rgba(0,0,0,.08);
}

.xs-wysiwyg-panel-tabs .nav-link {
  border: none;
  border-bottom: 2px solid transparent;
  color: #4b5563;
  border-radius: 0;
}

.xs-wysiwyg-panel-tabs .nav-link.active {
  color: #0d6efd;
  background: transparent;
  border-bottom-color: #0d6efd;
}

.xs-wysiwyg-ai-btn {
  font-weight: 700;
}

.xs-wysiwyg-ai-panel .xs-wysiwyg-panel-card {
  border-color: rgba(13,110,253,.18);
}

.xs-wysiwyg-ai-form {
  display: flex;
  align-items: flex-end;
  gap: .6rem;
}

.xs-wysiwyg-ai-input {
  min-height: 4.6rem;
  resize: vertical;
}

.xs-wysiwyg-ai-send {
  min-width: 7.5rem;
  white-space: nowrap;
}

.xs-wysiwyg-ai-hint {
  margin-top: .55rem;
  font-size: .8rem;
  color: #64748b;
}

.xs-wysiwyg-ai-status {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin-top: .65rem;
  padding: .6rem .75rem;
  border-radius: .7rem;
  background: rgba(13,110,253,.08);
  color: #0b5ed7;
  font-size: .82rem;
  font-weight: 600;
}

.xs-wysiwyg-ai-status.is-slow {
  background: rgba(255,193,7,.14);
  color: #9a6700;
}

.xs-wysiwyg-ai-status-time {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  opacity: .9;
}

.xs-wysiwyg-ai-selection-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.xs-wysiwyg-ai-selection-preview {
  position: absolute;
  background: linear-gradient(180deg, rgba(255,193,7,.28) 0%, rgba(255,193,7,.18) 100%);
  border-radius: .35rem;
  box-shadow: 0 0 0 2px rgba(255,193,7,.22);
  transition: background-color .18s ease, box-shadow .18s ease;
  pointer-events: none;
}

/* Obrázky vložené do editoru */
.xs-wysiwyg-editor img {
  max-width: 100%;
  height: auto;
  border-radius: .25rem;
  cursor: default;
}

.xs-wysiwyg-editor img.xs-wysiwyg-image-selected {
  outline: 2px solid rgba(13,110,253,.75);
  outline-offset: 2px;
}

.xs-wysiwyg-image-overlay {
  position: absolute;
  z-index: 32;
  pointer-events: none;
  box-sizing: border-box;
  border: 1px solid rgba(13,110,253,.75);
  border-radius: .35rem;
  box-shadow: 0 0 0 1px rgba(255,255,255,.85) inset;
}

.xs-wysiwyg-image-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #0d6efd;
  box-shadow: 0 2px 6px rgba(15,23,42,.25);
  pointer-events: auto;
  padding: 0;
}

.xs-wysiwyg-image-handle.is-nw {
  top: -7px;
  left: -7px;
  cursor: nwse-resize;
}

.xs-wysiwyg-image-handle.is-ne {
  top: -7px;
  right: -7px;
  cursor: nesw-resize;
}

.xs-wysiwyg-image-handle.is-sw {
  bottom: -7px;
  left: -7px;
  cursor: nesw-resize;
}

.xs-wysiwyg-image-handle.is-se {
  right: -7px;
  bottom: -7px;
  cursor: nwse-resize;
}

.xs-wysiwyg-image-bubble {
  position: absolute;
  z-index: 33;
  width: 220px;
}

.xs-wysiwyg-image-bubble-card {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .45rem .55rem;
  background: rgba(17,24,39,.94);
  color: #fff;
  border-radius: .75rem;
  box-shadow: 0 .75rem 1.5rem rgba(15,23,42,.24);
}

.xs-wysiwyg-image-bubble-label,
.xs-wysiwyg-image-bubble-unit {
  font-size: .78rem;
  white-space: nowrap;
}

.xs-wysiwyg-image-bubble input {
  width: 74px;
  background: #fff;
}

.xs-wysiwyg-editor table {
  width: 100%;
  margin: .75rem 0;
  border-collapse: collapse;
}

.xs-wysiwyg-editor table td,
.xs-wysiwyg-editor table th {
  border: 1px solid #d0d7de;
  padding: .5rem;
  vertical-align: top;
}

.xs-wysiwyg-editor table.xs-wysiwyg-table-selected {
  outline: 2px solid rgba(13,110,253,.55);
  outline-offset: 2px;
}

.xs-wysiwyg-table-bubble {
  position: absolute;
  z-index: 33;
  width: 260px;
}

.xs-wysiwyg-table-bubble-card {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .45rem .55rem;
  background: rgba(17,24,39,.94);
  color: #fff;
  border-radius: .75rem;
  box-shadow: 0 .75rem 1.5rem rgba(15,23,42,.24);
}

.xs-wysiwyg-table-bubble-label,
.xs-wysiwyg-table-bubble-unit {
  font-size: .78rem;
  white-space: nowrap;
}

.xs-wysiwyg-table-bubble input[type="number"] {
  width: 62px;
  background: #fff;
}

.xs-wysiwyg-table-bubble input[type="color"] {
  width: 42px;
  min-width: 42px;
  height: 32px;
  padding: .15rem;
  border-radius: .5rem;
  border: 1px solid rgba(255,255,255,.2);
  background: #fff;
}

/* ── Drag & drop – stav "přetahování nad editorem" ─────────────────────────── */
.xs-wysiwyg-editor.xs-drag-over {
  outline: 2px dashed #0d6efd;
  background: rgba(13,110,253,.04);
}

/* ── Drop zóna v modálu ─────────────────────────────────────────────────────── */
.xs-wysiwyg-drop-zone {
  border: 2px dashed rgba(0,0,0,.18);
  border-radius: .375rem;
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  user-select: none;
}

.xs-wysiwyg-drop-zone:hover,
.xs-wysiwyg-drop-zone.is-over {
  background: rgba(13,110,253,.06);
  border-color: #0d6efd;
}

.xs-wysiwyg-drop-zone i {
  font-size: 2.25rem;
  color: rgba(0,0,0,.3);
  display: block;
}

/* ── URL náhled ─────────────────────────────────────────────────────────────── */
.xs-wysiwyg-url-preview img {
  max-height: 220px;
  max-width: 100%;
  border-radius: .25rem;
  border: 1px solid rgba(0,0,0,.1);
}

/* ── Galerie ────────────────────────────────────────────────────────────────── */
.xs-wysiwyg-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: .5rem;
  max-height: 400px;
  overflow-y: auto;
  padding: .25rem;
}

.xs-wysiwyg-gallery-item {
  position: relative;
  aspect-ratio: 1 / 1;
  border: 1px solid rgba(0,0,0,.1);
  border-radius: .375rem;
  overflow: hidden;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .1s;
}

.xs-wysiwyg-gallery-item:hover {
  border-color: #0d6efd;
  box-shadow: 0 0 0 2px rgba(13,110,253,.25);
  transform: scale(1.03);
}

.xs-wysiwyg-gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

/* Tlačítko smazání – zobrazí se po najetí myší */
.xs-wysiwyg-gallery-item-del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(220,53,69,.85);
  color: #fff;
  border: none;
  font-size: 13px;
  line-height: 22px;
  text-align: center;
  padding: 0;
  cursor: pointer;
  display: none;
  transition: background .1s;
  z-index: 1;
}

.xs-wysiwyg-gallery-item:hover .xs-wysiwyg-gallery-item-del {
  display: block;
}

.xs-wysiwyg-gallery-item-del:hover {
  background: rgba(220,53,69,1);
}

/* ── Upload status ──────────────────────────────────────────────────────────── */
.xs-wysiwyg-upload-status {
  font-size: .875rem;
  color: #495057;
}

.xs-wysiwyg-table-picker {
  display: grid;
  grid-template-columns: repeat(8, 24px);
  gap: .25rem;
  width: max-content;
}

.xs-wysiwyg-table-cell {
  width: 24px;
  height: 24px;
  border: 1px solid #c9ced6;
  background: #f8f9fa;
  border-radius: .25rem;
  padding: 0;
  transition: background .12s ease, border-color .12s ease;
}

.xs-wysiwyg-table-cell.is-active,
.xs-wysiwyg-table-cell:hover,
.xs-wysiwyg-table-cell:focus {
  background: rgba(13,110,253,.14);
  border-color: #fd7e14;
  outline: none;
}

/* ── Responzivita ───────────────────────────────────────────────────────────── */
@media (max-width: 576px) {
  .xs-wysiwyg-toolbar {
    padding: .4rem;
  }
  .xs-wysiwyg-toolbar .xs-wysiwyg-format {
    min-width: 150px;
  }
  .xs-wysiwyg-toolbar .xs-wysiwyg-font-size {
    min-width: 110px;
  }
  .xs-wysiwyg-ai-form {
    flex-direction: column;
    align-items: stretch;
  }
  .xs-wysiwyg-ai-send {
    width: 100%;
  }
  .xs-wysiwyg-gallery {
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  }
  .xs-wysiwyg-panel {
    left: .5rem !important;
    right: .5rem;
    width: auto !important;
  }
}
