/* Annotation add menu */
.annotation-add-menu-wrap {
  position: relative;
  z-index: 5002;
}

#annotationsPanel:has(#addAnnotationMenu:not([hidden])) {
  position: relative;
  z-index: 5000;
}

.annotation-add-menu {
  position: absolute;
  z-index: 5003;
  top: calc(100% + 6px);
  right: 20px;
  min-width: 132px;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: rgb(12, 12, 12);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.42);
}

.annotation-add-menu [role="menuitem"] {
  width: 100%;
  min-height: 30px;
  display: flex;
  align-items: center;
  padding: 0 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.78rem;
  font-weight: 650;
  text-align: left;
  cursor: pointer;
}

.annotation-add-menu [role="menuitem"]:hover,
.annotation-add-menu [role="menuitem"]:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  outline: none;
}

/* Annotation readonly states */
.group.readonly .annotation-item,
.annotation-item.locked {
  pointer-events: none;
  opacity: 1;
}

/* Annotation title field base */
.annotation-title-row input {
  font-weight: 700;
  font-size: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.annotation-title-row input:focus {
  border-color: var(--text);
}

/* Annotation modal styling aligned with rename-layer modal */
#annotationModal .modal {
  width: min(560px, 100%);
  padding: 0;
  border-radius: 10px;
  overflow: hidden;
  background: transparent;

  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

#annotationModal .modal-header {
  margin: 0;
  padding: 1rem;
  padding-left: 1rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.2);
}

#annotationModal .modal-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: rgb(255, 255, 255);
}

#annotationModal .modal-close {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid transparent;
  background: rgba(0, 0, 0, 0.5);
  color: rgb(255, 255, 255);
}

#annotationModal .modal-close:hover {
  background: var(--canvas-button-bg-hover);
  border-color: rgba(255, 255, 255, 0.22);
}

#annotationModal .annotation-type-chooser {
  padding: 0.75rem;
  background: var(--canvas-button-bg);
  gap: 0.6rem;
  margin-bottom: 0;
}

#annotationModal .annotation-type-chooser .muted {
  margin: 0;
  font-size: 0.84rem;
  opacity: 0.65;
  color: rgb(255, 255, 255);
}

#annotationModal .annotation-type-chooser .actions.wide {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

#annotationModal [data-annotation-type] {
  min-height: 36px;
  padding: 0 0.65rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.5);
  color: rgb(255, 255, 255);
  font-size: 0.86rem;
  font-weight: 600;
}

#annotationModal [data-annotation-type]:hover,
#annotationModal [data-annotation-type]:focus-visible {
  background: var(--canvas-button-bg-hover);
  border-color: rgba(255, 255, 255, 0.22);
}

#annotationModal [data-annotation-type][disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

#annotationModal #annotationForm {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.75rem;
}

#annotationModal #annotationForm[hidden] {
  display: none !important;
}

#annotationModal .form-row {
  margin-bottom: 0;
  gap: 0.35rem;
}

#annotationModal .form-row label {
  opacity: 0.5;
  font-size: 0.9rem;
  font-weight: 500;
  color: rgb(255, 255, 255);
  text-transform: none;
  letter-spacing: normal;
  padding-left: 5px;
}

#annotationModal .annotation-title-row input,
#annotationModal .annotation-text-row textarea {
  width: 100%;
  border: none;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.5);
  color: rgb(255, 255, 255);
  font-size: 0.9rem;
}

#annotationModal .annotation-title-row input {
  height: 40px;
  padding: 0 10px;
  font-weight: 600;
}

#annotationModal .annotation-text-row textarea {
  min-height: 96px;
  max-height: 220px;
  padding: 10px;
  line-height: 1.45;
  resize: vertical;
}

#annotationModal .annotation-title-row input::placeholder,
#annotationModal .annotation-text-row textarea::placeholder {
  color: rgba(255, 255, 255, 0.45);
}

#annotationModal .annotation-title-row input:focus,
#annotationModal .annotation-text-row textarea:focus {
  outline: none;
}

#annotationModal .annotation-image-row {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.3);
}

#annotationModal #annotationImageSelect {
  width: 100%;
  min-height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.5);
  color: rgb(255, 255, 255);
  font-size: 0.9rem;
  font-weight: 500;
}

#annotationModal #annotationImageSelect:hover,
#annotationModal #annotationImageSelect:focus-visible {
  background: var(--canvas-button-bg-hover);
  border-color: rgba(255, 255, 255, 0.22);
  color: rgb(255, 255, 255);
  outline: none;
}

#annotationModal .annotation-image-preview {
  margin-top: 0.55rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

#annotationModal .annotation-image-preview img {
  width: 100%;
  max-height: 190px;
  object-fit: cover;
  display: block;
}

#annotationModal .modal-actions {
  margin-top: 0;
  gap: 0.75rem;
}

#annotationModal .modal-actions button {
  flex: 1 1 0;
  min-height: 36px;
  border-radius: 10px;
  background-color: rgba(0, 0, 0, 0.5);
  color: rgb(255, 255, 255);
  font-size: 0.9rem;
}

#annotationModal #cancelAnnotation {
}

#annotationModal .modal-actions .primary {
  background-color: rgba(0, 0, 0, 0.5);
  color: rgb(255, 255, 255);
  border-color: rgba(255, 255, 255, 0.22);
  font-weight: 600;
}

/* Annotation modal responsive layout */
@media (max-width: 640px) {
  #annotationModal .annotation-type-chooser .actions.wide {
    grid-template-columns: 1fr;
  }
}

/* Annotation list, lightbox, and information modal */
.annotation-type-chooser {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.annotation-type-chooser[hidden] {
  display: none !important;
}

.annotations-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.annotation-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.28rem;
  padding: 0.45rem 0.5rem;
  border-radius: 12px;
  color: rgb(255, 255, 255);
  border: 1px solid transparent;
  background-color: rgb(38, 38, 38);
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background-color 0.15s ease;
}

.annotation-item:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.annotation-item.active {
  background-color: rgb(39, 88, 208);
}

.annotation-row-header {
  min-width: 0;
}

.annotation-meta {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: 1;
  min-width: 0;
}

.annotation-type {
  font-size: 0.8rem;
  opacity: 0.7;
}

.annotation-title {
  color: rgb(255, 255, 255);
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.2;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.annotation-image-preview {
  margin-top: 0.35rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
}

.annotation-image-preview img {
  display: block;
  width: 100%;
  height: auto;
}

.annotation-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 70;
  padding: 1rem;
}

.annotation-lightbox.show {
  display: flex;
}

.annotation-lightbox-content {
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
}

.annotation-lightbox img {
  max-width: 90vw;
  max-height: 80vh;
  border-radius: 15px;
}

.annotation-lightbox-title {
  color: white;
  font-size: 1.1rem;
  font-weight: 700;
}

.annotation-label-modal {
  z-index: 72;
}

.annotation-label-modal-content {
  width: min(860px, 94vw);
  min-height: 260px;
  max-height: min(84vh, 720px);
  display: flex;
  flex-direction: column;
  gap: 0;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(30, 30, 30, 0.96);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.48);
}

.annotation-label-modal-content.no-image {
  min-height: 0;
}

.annotation-label-modal-image {
  display: flex;
  gap: 0.55rem;
  width: 100%;
  min-height: 220px;
  max-height: 250px;
  padding: 0.65rem;
  border-radius: 0;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.28) transparent;
  background: rgba(20, 20, 20, 0.98);
  transition:
    min-height 0.18s ease,
    max-height 0.18s ease;
}

.annotation-label-modal-image[hidden] {
  display: none !important;
}

.annotation-label-modal-image img {
  flex: 0 0 min(360px, 78vw);
  display: block;
  width: min(360px, 78vw);
  height: 220px;
  object-fit: cover;
  border-radius: 10px;
  cursor: zoom-in;
  transition:
    flex-basis 0.18s ease,
    width 0.18s ease,
    height 0.18s ease,
    opacity 0.18s ease;
}

.annotation-label-modal-content.is-image-expanded .annotation-label-modal-image {
  min-height: min(56vh, 430px);
  max-height: min(56vh, 430px);
}

.annotation-label-modal-content.is-image-expanded .annotation-label-modal-image img {
  flex-basis: min(150px, 34vw);
  width: min(150px, 34vw);
  height: min(52vh, 405px);
  opacity: 0.52;
}

.annotation-label-modal-content.is-image-expanded .annotation-label-modal-image img.is-expanded {
  flex-basis: 100%;
  width: 100%;
  object-fit: contain;
  background: rgba(0, 0, 0, 0.45);
  opacity: 1;
  cursor: zoom-out;
}

.annotation-label-modal-body {
  min-width: 0;
  max-height: min(42vh, 340px);
  padding: 1.1rem 1.15rem;
  display: flex;
  flex-direction: column;
  justify-content: start;
  gap: 0.32rem;
  overflow-y: auto;
  border-radius: 0;
  background: transparent;
}

.annotation-label-modal-content.no-image .annotation-label-modal-body {
  border-top: 0;
}

.annotation-label-modal-content.is-image-expanded .annotation-label-modal-body {
  max-height: min(24vh, 210px);
}

.annotation-label-modal-title {
  color: #ffffff;
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.2;
  word-break: break-word;
}

.annotation-label-modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.42rem;
  margin: 0.12rem 0 0.3rem;
}

.annotation-label-modal-meta[hidden] {
  display: none !important;
}

.annotation-label-modal-meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.34rem;
  max-width: 100%;
  min-height: 28px;
  padding: 0.25rem 0.58rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
}

.annotation-label-modal-meta-pill strong {
  min-width: 0;
  overflow: hidden;
  color: #ffffff;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.annotation-label-modal-description {
  color: rgba(255, 255, 255, 0.82);
  font-size: 1rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.annotation-label-modal-link {
  margin-top: 0.5rem;
  display: inline-flex;
  align-self: flex-start;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0.26rem 0.86rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(0, 0, 0, 0.42);
  color: #ffffff;
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
}

.annotation-label-modal-link:hover {
  border-color: rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.14);
}

.annotation-label-modal-link[hidden] {
  display: none !important;
}

@media (max-width: 700px) {
  .annotation-label-modal-content {
    width: min(95vw, 520px);
    max-height: 84vh;
  }

  .annotation-label-modal-image {
    min-height: 180px;
    max-height: 208px;
  }

  .annotation-label-modal-image img {
    flex-basis: min(310px, 82vw);
    width: min(310px, 82vw);
    height: 180px;
  }

  .annotation-label-modal-content.is-image-expanded .annotation-label-modal-image {
    min-height: min(48vh, 360px);
    max-height: min(48vh, 360px);
  }

  .annotation-label-modal-content.is-image-expanded .annotation-label-modal-image img {
    flex-basis: min(118px, 30vw);
    width: min(118px, 30vw);
    height: min(44vh, 336px);
  }

  .annotation-label-modal-content.is-image-expanded .annotation-label-modal-image img.is-expanded {
    flex-basis: calc(95vw - 1.3rem);
    width: calc(95vw - 1.3rem);
  }

  .annotation-label-modal-body {
    max-height: min(48vh, 360px);
  }

  .annotation-label-modal-content.is-image-expanded .annotation-label-modal-body {
    max-height: min(25vh, 210px);
  }
}

/* Annotation information panel */
.annotation-actions {
  display: flex;
  flex-direction: row;
  justify-content: flex-end;
  flex: 0 0 auto;
  gap: 0.25rem;
  margin-top: 0;
}

.annotation-actions button {
  border: 0;
  border-radius: 999px;
  font-size: 0.72rem;
  line-height: 1;
  margin: 0;
  min-height: 24px;
  min-width: 0;
  padding: 0 0.48rem;
}

.annotation-actions button.danger {
  color: rgb(255, 212, 212);
}

.annotation-tooltip {
  position: absolute;
  min-width: 180px;
  max-width: 260px;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  background: var(--canvas-button-bg);
  border: none;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  z-index: 6;
  pointer-events: none;
}

.annotation-tooltip-title {
  color: #ffffff;
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.annotation-tooltip-body {
  color: #ffffff;
  font-size: 0.85rem;
  opacity: 1;
}

#annotationInformationPanel .group-content {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.annotation-information-editor {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.annotation-information-editor[hidden],
.annotation-information-image-preview[hidden] {
  display: none !important;
}

.annotation-information-title {
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.25;
}

.annotation-information-description {
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.85rem;
  line-height: 1.4;
  white-space: pre-wrap;
}

.annotation-information-link {
  display: flex;
  align-items: center;
}

.annotation-information-link a {
  color: #ffffff;
  font-size: 0.84rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-word;
}

.annotation-information-link a:hover {
  opacity: 0.85;
}

.annotation-information-image,
.annotation-information-image-preview {
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
}

.annotation-information-image img,
.annotation-information-image-preview img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 260px;
  object-fit: cover;
}

.annotation-information-image-actions {
  margin: 0;
}

.annotation-information-plugin-data {
  display: grid;
  gap: 0.5rem;
  padding: 0.65rem 0;
}

.annotation-information-plugin-data[hidden] {
  display: none !important;
}

.annotation-information-plugin-data-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-width: 0;
}

.annotation-information-plugin-data-header span {
  overflow: hidden;
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.annotation-information-plugin-data-header small {
  overflow: hidden;
  max-width: 45%;
  color: rgba(255, 255, 255, 0.52);
  font-size: 0.7rem;
  font-weight: 650;
  line-height: 1.2;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.annotation-information-plugin-data-body {
  display: grid;
  gap: 0.42rem;
}

.annotation-information-plugin-data-row {
  display: grid;
  grid-template-columns: minmax(72px, 0.42fr) minmax(0, 1fr);
  gap: 0.65rem;
  align-items: start;
  min-width: 0;
}

.annotation-information-plugin-data-row span {
  color: rgba(255, 255, 255, 0.52);
  font-size: 0.72rem;
  font-weight: 650;
  line-height: 1.35;
}

.annotation-information-plugin-data-row strong {
  overflow-wrap: anywhere;
  color: rgba(255, 255, 255, 0.86);
  font-size: 0.76rem;
  font-weight: 650;
  line-height: 1.35;
}

.annotation-information-plugin-data-empty {
  color: rgba(255, 255, 255, 0.52);
  font-size: 0.74rem;
  font-weight: 650;
  line-height: 1.35;
}

.annotation-information-plugin-data-image {
  display: block;
  width: 100%;
  max-height: 160px;
  object-fit: cover;
  border-radius: 10px;
}

.annotation-information-plugin-data-link {
  color: #ffffff;
  font-size: 0.76rem;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

#annotationInformationEditor textarea {
  min-height: 84px;
  resize: vertical;
}

/* Annotation information actions */
.annotation-information-clear-btn {
  background: rgb(38, 38, 38) !important;
}

/* Annotation modal platform styling */
#annotationModal.modal-backdrop {
  background: rgba(0, 0, 0, 0.62);
}

#annotationModal .modal {
  width: min(560px, calc(100vw - 32px));
  padding: 0;
  overflow: hidden;
  background: rgb(30, 30, 30);
  border-radius: 15px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.42);
  color: rgb(255, 255, 255);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

#annotationModal .modal-header {
  margin: 0;
  padding: 14px 16px;
  border-bottom: 1px solid rgb(38, 38, 38);
}

#annotationModal .modal-header h3 {
  color: rgb(255, 255, 255);
  font-size: 1rem;
  font-weight: 600;
}

#annotationModal .modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  padding: 0;
  background: rgb(30, 30, 30);
  border: 0;
  border-radius: 999px;
  color: rgb(255, 255, 255);
  line-height: 0;
}

#annotationModal .modal-close svg {
  display: block;
  width: 18px;
  height: 18px;
}

#annotationModal .modal-close:hover,
#annotationModal .modal-close:focus-visible {
  background: rgb(38, 38, 38);
  border: 0;
  outline: none;
}

#annotationModal .annotation-type-chooser,
#annotationModal #annotationForm {
  padding: 16px;
}

#annotationModal #annotationForm {
  gap: 10px;
}

#annotationModal .annotation-type-chooser .muted,
#annotationModal .form-row label {
  color: rgba(255, 255, 255, 0.58);
  opacity: 1;
}

#annotationModal .form-row {
  gap: 6px;
}

#annotationModal .annotation-title-row input,
#annotationModal .annotation-text-row textarea {
  background: rgb(38, 38, 38);
  border-radius: 10px;
  color: rgb(255, 255, 255);
}

#annotationModal .annotation-title-row input:focus,
#annotationModal .annotation-text-row textarea:focus {
  background: rgb(38, 38, 38);
  border-color: rgb(54, 54, 54);
  outline: none;
}

#annotationModal .annotation-title-row input::placeholder,
#annotationModal .annotation-text-row textarea::placeholder {
  color: rgba(255, 255, 255, 0.42);
}

#annotationModal .annotation-image-row {
  background: rgb(30, 30, 30);
  border: 0;
  border-radius: 12px;
}

#annotationModal #annotationImageSelect,
#annotationModal [data-annotation-type],
#annotationModal .modal-actions button {
  background: rgb(38, 38, 38);
  border: 0;
  border-radius: 999px;
  color: rgb(255, 255, 255);
  box-shadow: none;
}

#annotationModal #annotationImageSelect:hover,
#annotationModal #annotationImageSelect:focus-visible,
#annotationModal [data-annotation-type]:hover,
#annotationModal [data-annotation-type]:focus-visible,
#annotationModal .modal-actions button:hover,
#annotationModal .modal-actions button:focus-visible {
  background: rgb(38, 38, 38);
  border: 0;
  outline: none;
}

#annotationModal .modal-actions .primary {
  background: rgb(39, 88, 208);
  border: 0;
  color: rgb(255, 255, 255);
  font-weight: 600;
}

#annotationModal .modal-actions .primary:hover,
#annotationModal .modal-actions .primary:focus-visible {
  background: rgb(35, 79, 192);
}

#annotationModal .annotation-image-preview {
  background: rgb(12, 12, 12);

  border-radius: 10px;
}
