.work-richtext {
  border: 1px solid var(--border, #cbd5e1);
  border-radius: 8px;
  background: var(--surface, #fff);
  overflow: hidden;
}

.work-richtext__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem;
  padding: 0.35rem 0.45rem;
  border-bottom: 1px solid var(--border, #e2e8f0);
  background: var(--surface-2, #f8fafc);
}

.work-richtext__btn {
  border: 0;
  background: transparent;
  color: var(--text, #334155);
  border-radius: 5px;
  padding: 0.2rem 0.45rem;
  font-size: 0.78rem;
  cursor: pointer;
  line-height: 1.2;
}

.work-richtext__btn:hover:not(:disabled) {
  background: rgba(37, 99, 235, 0.08);
  color: #1d4ed8;
}

.work-richtext__btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

.work-richtext__btn--photo {
  font-weight: 600;
}

.work-richtext__btn--highlight {
  font-weight: 700;
}

.work-richtext__hl-ico {
  display: inline-block;
  min-width: 0.85em;
  padding: 0 0.08em 0.05em;
  border-radius: 3px;
  background: #fde047;
  color: #0f172a;
  line-height: 1.15;
  box-shadow: inset 0 -0.12em 0 rgba(15, 23, 42, 0.12);
}

.work-richtext__sep {
  width: 1px;
  height: 1.1rem;
  background: #cbd5e1;
  margin: 0 0.15rem;
}

.work-richtext__editor {
  padding: 0.55rem 0.65rem;
  font-size: 0.92rem;
  line-height: 1.5;
  outline: none;
  overflow-y: auto;
  max-height: 18rem;
}

.work-richtext__editor mark,
.work-richtext-readonly mark {
  background: #fde047;
  color: inherit;
}

.work-richtext__editor mark,
.work-richtext__editor span[style*='background'],
.work-richtext-readonly mark,
.work-richtext-readonly span[style*='background'] {
  border-radius: 0.15em;
  padding: 0 0.08em;
}

.work-richtext__editor:empty::before {
  content: attr(data-placeholder);
  color: #94a3b8;
  pointer-events: none;
}

.work-richtext__editor img {
  max-width: min(100%, 420px);
  height: auto;
  border-radius: 6px;
  margin: 0.35rem 0;
  display: block;
  border: 1px solid #e2e8f0;
}

.work-richtext__status {
  margin: 0;
  padding: 0.25rem 0.65rem 0.45rem;
}

.work-richtext-host {
  width: 100%;
}

.work-richtext-readonly {
  line-height: 1.55;
  word-break: break-word;
}

.work-richtext-readonly p {
  margin: 0.35rem 0;
}

.work-richtext-readonly ul,
.work-richtext-readonly ol {
  margin: 0.35rem 0 0.5rem 1.1rem;
  padding: 0;
}

.work-richtext-readonly img {
  max-width: min(100%, 420px);
  height: auto;
  border-radius: 6px;
  margin: 0.35rem 0;
  display: block;
  border: 1px solid #e2e8f0;
  cursor: zoom-in;
}

.tm-update-row__text .work-richtext-readonly,
.tm-detail-spec__desc.work-richtext-readonly {
  font-size: inherit;
}

.tm-add-update-panel .work-richtext__editor {
  min-height: 8.5rem;
  max-height: 22rem;
}

.inat-create__input.work-richtext-host .work-richtext {
  border-color: var(--inat-create-border, #cbd5e1);
}

/* Separate photo gallery below description */
.work-photo-gallery {
  margin-top: 0.65rem;
  padding: 0.65rem 0.7rem 0.75rem;
  border: 1px solid var(--border, #d8dee6);
  border-radius: var(--radius-sm, 8px);
  background: color-mix(in srgb, var(--panel, #fff) 92%, var(--surface-2, #f8fafc));
}

.work-photo-gallery--readonly {
  margin-top: 0.55rem;
  padding: 0.55rem;
  background: transparent;
}

.work-photo-gallery__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.75rem;
  margin-bottom: 0.55rem;
}

.work-photo-gallery__titles {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
  flex: 1 1 auto;
}

.work-photo-gallery__label {
  font-size: 0.78rem;
  font-weight: 650;
  color: var(--text, #0f172a);
}

.work-photo-gallery__hint {
  font-size: 0.7rem;
  line-height: 1.35;
}

.work-photo-gallery__add {
  flex-shrink: 0;
}

.work-photo-gallery__grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: stretch;
}

.work-photo-gallery__empty {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.4;
}

.work-photo-gallery__item {
  position: relative;
  width: 4.75rem;
  height: 4.75rem;
  flex: 0 0 auto;
}

.work-photo-gallery__thumb,
.work-photo-gallery__item[data-work-photo-open],
.work-photo-gallery--readonly .work-photo-gallery__item {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 1px solid var(--border, #d8dee6);
  border-radius: 0.45rem;
  overflow: hidden;
  background: var(--panel, #fff);
  cursor: zoom-in;
}

.work-photo-gallery--readonly .work-photo-gallery__item {
  width: 4.75rem;
  height: 4.75rem;
}

.work-photo-gallery__thumb img,
.work-photo-gallery__item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.work-photo-gallery__remove {
  position: absolute;
  top: 0.15rem;
  right: 0.15rem;
  width: 1.25rem;
  height: 1.25rem;
  border: 0;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.work-photo-gallery__remove:hover {
  background: #b91c1c;
}

.work-photo-gallery__status {
  margin: 0.45rem 0 0;
}

.work-photo-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.work-photo-lightbox.hidden {
  display: none !important;
}

.work-photo-lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.72);
}

.work-photo-lightbox__panel {
  position: relative;
  z-index: 1;
  max-width: min(92vw, 56rem);
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.work-photo-lightbox__img {
  display: block;
  max-width: 100%;
  max-height: 86vh;
  width: auto;
  height: auto;
  border-radius: 0.4rem;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  background: #0f172a;
}

.work-photo-lightbox__close {
  position: absolute;
  top: -0.35rem;
  right: -0.35rem;
  z-index: 2;
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: #0f172a;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

.work-photo-lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 2.25rem;
  height: 2.25rem;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #0f172a;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}

.work-photo-lightbox__nav--prev {
  left: -0.35rem;
}

.work-photo-lightbox__nav--next {
  right: -0.35rem;
}

@media (max-width: 640px) {
  .work-photo-gallery__item,
  .work-photo-gallery--readonly .work-photo-gallery__item {
    width: 4.25rem;
    height: 4.25rem;
  }
  .work-photo-lightbox__nav--prev {
    left: 0.25rem;
  }
  .work-photo-lightbox__nav--next {
    right: 0.25rem;
  }
}
