/* Edit icon styling */
.edit-icon {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background-color: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: background-color 0.2s ease, transform 0.2s ease;
    opacity: 0.7;
}

.edit-icon svg {
    width: 14px;
    height: 14px;
    fill: #fff;
}

.edit-icon:hover {
    background-color: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
    opacity: 1;
}

.character-card {
    position: relative;
}

/* In compact and ultra-compact modes, adjust the edit icon position */
.compact-mode .edit-icon {
    width: 20px;
    height: 20px;
}

.compact-mode .edit-icon svg {
    width: 12px;
    height: 12px;
}

.ultra-compact-mode .edit-icon {
    top: 5px;
    right: 5px;
    width: 18px;
    height: 18px;
}

.ultra-compact-mode .edit-icon svg {
    width: 10px;
    height: 10px;
}

@keyframes alias-reveal {
    0% {
        text-shadow: 0 0 5px rgba(255, 165, 0, 0.2);
    }
    100% {
        text-shadow: 0 0 10px rgba(255, 165, 0, 0.8);
    }
}

@keyframes name-reveal {
    0% {
        text-shadow: 0 0 5px rgba(255, 215, 0, 0.2);
    }
    100% {
        text-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
    }
}

/* Ultra-compact mode styling */
.ultra-compact-mode #characters-container {
    grid-template-columns: repeat(auto-fill, minmax(100%, 1fr));
    gap: 10px;
}

.ultra-compact-mode .character-card {
    display: flex;
    flex-direction: row;
    max-height: 120px;
    font-size: 0.85em;
    padding: 0;
    overflow: visible; /* Changed from hidden to visible to allow tooltips to show */
}

.ultra-compact-mode .image-container {
    display: none;
}

.ultra-compact-mode .character-info {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    padding: 10px;
}

.ultra-compact-mode .character-name {
    font-size: 15px;
    margin: 0;
    padding: 0;
    flex: 1 0 60%;
    max-width: 60%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ultra-compact-mode .character-alias {
    font-size: 12px;
    margin-left: 4px;
}

.ultra-compact-mode .character-affiliation {
    flex: 0 0 35%;
    max-width: 35%;
    margin: 0;
    text-align: right;
    justify-content: flex-end;
    margin-left: auto;
}

.ultra-compact-mode .affiliation-label {
    display: none;
}

.ultra-compact-mode .affiliation-value {
    padding: 2px 6px;
    font-size: 10px;
}

.ultra-compact-mode .character-description {
    flex: 1 0 100%;
    margin: 4px 0;
    max-height: 38px;
    overflow: hidden;
    font-size: 12px;
    line-height: 1.3;
    text-overflow: ellipsis;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    display: -webkit-box;
    -webkit-box-orient: vertical;
}

.ultra-compact-mode .character-attributes {
    flex: 1 0 100%;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    margin-top: 2px;
}

.ultra-compact-mode .attribute {
    padding: 2px 5px;
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ultra-compact-mode .character-detail {
    display: none;
}

.ultra-compact-mode .chapter-intro {
    position: absolute;
    right: 8px;
    bottom: 8px;
    margin: 0;
    transform: scale(0.75);
    transform-origin: bottom right;
    opacity: 0.8;
    z-index: 1;
}

/* Hover effect in ultra-compact mode */
.ultra-compact-mode .character-card:hover {
    max-height: none;
    z-index: 10;
    transform: none;
}

.ultra-compact-mode .character-card:hover .character-description {
    max-height: none;
    -webkit-line-clamp: initial;
    line-clamp: initial;
}

/* Mobile responsiveness for ultra-compact mode */
@media (max-width: 768px) {
    .ultra-compact-mode .character-name {
        flex: 1 0 50%;
        max-width: 50%;
    }

    .ultra-compact-mode .character-affiliation {
        flex: 0 0 45%;
        max-width: 45%;
    }

    .ultra-compact-mode .character-attributes {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Edit Modal Overlay */
.edit-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.7);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s;
}

/* Edit Modal */
.edit-modal {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25), 0 1.5px 6px rgba(0,0,0,0.08);
  padding: 32px 24px 24px 24px;
  max-width: 600px;
  width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  animation: modalPopIn 0.25s cubic-bezier(.23,1.01,.32,1) both;
}

.edit-modal h2 {
  margin-top: 0;
  margin-bottom: 18px;
  font-size: 1.7rem;
  font-weight: 700;
  color: #2a2a2a;
  letter-spacing: 0.01em;
}

.edit-modal label {
  /* display: block; */
  font-weight: 500;
  /* margin-bottom: 8px; */
  color: #333;
}

.edit-modal input[type="text"],
.edit-modal input[type="number"],
.edit-modal textarea {
  width: 100%;
  padding: 8px 10px;
  margin-top: 2px;
  /* margin-bottom: 14px; */
  border: 1px solid #d1d5db;
  border-radius: 5px;
  font-size: 1rem;
  background: #fafbfc;
  transition: border 0.2s;
}

.edit-modal input[type="text"]:focus,
.edit-modal input[type="number"]:focus,
.edit-modal textarea:focus {
  border: 1.5px solid #007bff;
  outline: none;
  background: #fff;
}

.edit-modal button[type="submit"] {
  background: #007bff;
  color: #fff;
  border: none;
  padding: 10px 0;
  border-radius: 5px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s;
}

.edit-modal button[type="submit"]:hover {
  background: #0056b3;
}

.edit-modal button#cancel-edit {
  background: #e0e0e0;
  color: #222;
  border: none;
  padding: 10px 0;
  border-radius: 5px;
  font-size: 1.1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.18s;
}

.edit-modal button#cancel-edit:hover {
  background: #c2c2c2;
}

.edit-modal button[aria-label="Close"] {
  position: absolute;
  top: 12px;
  right: 16px;
  font-size: 2rem;
  background: none;
  border: none;
  color: #888;
  cursor: pointer;
  z-index: 2;
  transition: color 0.18s;
}

.edit-modal button[aria-label="Close"]:hover {
  color: #007bff;
}

@media (max-width: 600px) {
  .edit-modal {
    padding: 18px 6vw 18px 6vw;
    max-width: 98vw;
  }
  .edit-modal h2 {
    font-size: 1.2rem;
  }
}

@keyframes modalPopIn {
  0% {
    opacity: 0;
    transform: scale(0.95) translateY(30px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.json-hint {
  display: inline-block;
  background: #f4f4f4;
  color: #666;
  font-size: 0.92em;
  font-family: "Fira Mono", "Consolas", "Menlo", monospace;
  border-radius: 4px;
  padding: 2px 6px;
  margin-left: 6px;
  margin-bottom: 2px;
  vertical-align: middle;
  opacity: 0.85;
  border: 1px solid #e0e0e0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
