:root {
  --text-color: #373c44;
  --panel-bg: #ffffff;
  --modal-box-shadow: rgba(0, 0, 0, 0.4);
  --modal-size: 50vh;
}

[data-theme="dark"] {
  --text-color: #c2c7d0;
  --panel-bg: #13171f;
  --modal-box-shadow: rgba(255, 255, 255, 0.4);
}

.bottom-sheet {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  opacity: 0;
  pointer-events: none;
  align-items: center;
  flex-direction: column;
  justify-content: flex-end;
  transition: opacity 0.15s linear;
  z-index: 5011;
}
.bottom-sheet.show {
  transition: opacity 0.15s linear;
  opacity: 1;
  pointer-events: auto;
}

.bottom-sheet .content {
  width: 100%;
  position: relative;
  max-height: 90vh;
  height: 50vh;
  padding: 25px 20px;
  border-radius: 12px 12px 0 0;
  background: var(--panel-bg);
  box-shadow: 0 10px 20px var(--modal-box-shadow);
  container-type: inline-size;
  container-name: modal;
}

.bottom-sheet.dragging .content {
  transition: none;
}
.bottom-sheet.fullscreen .content {
  border-radius: 0;
  overflow-y: hidden;
}
.bottom-sheet .header-modal {
  display: flex;
  justify-content: center;
}
.header-modal {
  cursor: grab;
}
.header-modal .drag-icon {
  cursor: grab;
  user-select: none;
  padding: 15px;
  margin-top: -15px;
}
.header-modal .drag-icon span {
  height: 4px;
  width: 40px;
  display: block;
  background: #c7d0e1;
  border-radius: 50px;
}
.bottom-sheet .body-modal {
  height: 100%;
  overflow-y: auto;
  padding: 15px 0 40px;
  scrollbar-width: none;
}
.bottom-sheet .body-modal::-webkit-scrollbar {
  width: 0;
}
.modal-div {
  display: flex;
  flex-direction: column;
}
.modal-title {
  text-align: center;
  margin-top: 0 !important;
  color: var(--text-color) !important;
}
.modal-grid {
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  grid-gap: 5px;
  display: grid;
}
.modal-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 2px;
  border-radius: 10px;
}
.modal-cell:focus {
  background-color: #555461;
}
.modal-cell:hover {
  background-color: #63626e52;
  cursor: pointer;
}
.modal-image {
  max-width: 200px !important;
  min-width: 100px !important;
  width: 100%;
  border-radius: 15px;
}
.modal-button {
  margin-top: 20px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  min-width: 300px;
}
.modal-button-fov {
  margin-top: 20px !important;
  margin-left: auto !important;
  margin-right: auto !important;
}
.modal-button-fov.outline:hover {
  background: var(--pico-text-selection-color);
}
.modal-button-fov.outline {
  background: var(--pico-muted-border-color);
  color: var(--text-color);
}
.modal-button-fov.active {
  background: var(--pico-primary-underline);
}
.button-group {
  border-radius: 0 !important;
  margin-top: 0 !important;
}
#sliderValue {
  margin-left: auto !important;
  margin-right: auto !important;
  font-weight: bold;
}
.modal-slider-input {
  max-width: 400px;
  margin-left: auto !important;
  margin-right: auto !important;
}
.modal-flex-buttons {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap-reverse;
}
.modal-flex-buttons-fov {
  display: flex;
  flex-direction: row;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}
@container modal (max-width: 480px) {
  .modal-flex-buttons-fov {
    flex-direction: column;
  }
  .modal-flex-buttons-fov>button {
    width: 100% !important;
    border-radius: 0;
    border: var(--pico-border-width) solid var(--pico-border-color) !important;
    margin-left: 0 !important;
  }
}
#modal-arrow-direction {
  height: 100px !important;
  width: 50px !important;
  margin-left: auto;
  margin-right: auto;
}
#overlay-arrow-direction {
  height: 200px !important;
  position: absolute;
  z-index: 5200;
  left: calc(50% - 50px);
}
[data-theme="dark"] #modal-arrow-direction {
  filter: invert(20%);
}
.modal-table {
  max-width: 600px;
  margin-left: auto !important;
  margin-right: auto !important;
}
.modal-content {
  max-width: 750px;
  margin-left: auto !important;
  margin-right: auto !important;
  text-align: justify;
}
.info-bubble {
  cursor: pointer;
  height: 1.25rem !important;
}
[data-theme="dark"] .info-bubble {
  filter: invert(79%) sepia(7%) saturate(407%) hue-rotate(182deg)
    brightness(95%) contrast(86%);
}
[data-theme="light"] .info-bubble {
  filter: invert(33%) sepia(9%) saturate(707%) hue-rotate(180deg)
    brightness(90%) contrast(88%);
}
.modal-rich-img {
  padding-bottom: 1rem;
}
.modal-attribution {
  display: block;
  margin-top: -0.75rem;
  /* Pull it closer to the image above */
  margin-bottom: 1.5rem;
  font-size: 0.75rem;
  color: var(--pico-muted-color);
  text-align: right;
  /* Standard for image credits */
  font-style: italic;
}

/* Ensure links inside attribution don't stand out too much */
.modal-attribution a {
  color: var(--pico-muted-color);
  text-decoration: underline;
}

.modal-attribution a:hover {
  color: var(--pico-primary);
}

.table-img {
  max-width: 120px;
  display: block;
  margin-top: 5px;
  border-radius: 4px;
}

@media (min-width: 920px) {
  .bottom-sheet.display-right .content {
    display: flex;
    flex-direction: row;
    justify-content: flex-end;
    height: 100% !important;
    /* Full height for sidebar */
    width: var(--modal-size);
    /* Width is now controlled by our variable */
    max-height: 100vh;
    border-radius: 12px 0 0 12px;
    padding: 25px 10px;
  }

  /* Adjust drag icon for vertical line if on right */
  .bottom-sheet.display-right .header-modal .drag-icon span {
    width: 4px;
    height: 40px;
  }

  .bottom-sheet.display-right .header-modal {
    align-items: center;
    padding-right: 5px;
  }

  .bottom-sheet.display-right .body-modal {
    align-content: center;
    padding: 0;
    padding-bottom: 100px;
    width: 100%;
  }
}

.close-modal-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: transparent;
  border: none;
  padding: 8px;
  cursor: pointer;
  z-index: 10;
  color: var(--pico-muted-color);
  /* Uses Pico's secondary text color */
  line-height: 0;
  transition: color 0.2s ease, transform 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-modal-btn:hover {
  color: var(--pico-primary);
  transform: scale(1.1);
}

/* Adjust for the drag handle on mobile so they don't overlap */
@media (max-width: 1023px) {
  .close-modal-btn {
    top: 5px;
    right: 5px;
  }
}

/* Dark theme tweak if needed */
[data-theme="dark"] .close-modal-btn {
  color: #fff;
}