body {
  margin: 0;
  padding: 0;
  background-image: url("background.png");
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center center;
  background-attachment: fixed;
  font-family: 'MedievalSharp', cursive;
  min-height: 100vh;
  width: auto;
  height: auto;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: auto;
}

.book {
  width: min(90vw, 900px);
  height: auto;
  aspect-ratio: 16 / 9;
  display: flex;
  perspective: 2000px;
  background: #4d0d0d url('https://www.transparenttextures.com/patterns/leather.png');
  border: 12px solid #710000;
  border-radius: 24px;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.9);
  position: relative;
  overflow: hidden;
}

/* Añadimos media queries adicionales para pantallas grandes */
@media (min-width: 1200px) {
  .book {
    width: 1000px;
    aspect-ratio: 16 / 9;
  }
}

.page {
  width: 50%;
  height: 100%;
  padding: 30px;
  box-sizing: border-box;
  background: #f4e5c0 url('https://www.transparenttextures.com/patterns/paper-fibers.png');
  background-repeat: repeat;
  background-size: auto;
  box-shadow: inset 0 0 15px rgba(0,0,0,0.3);
  transition: transform 1s ease-in-out;
  backface-visibility: hidden;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  scrollbar-width: thin;
  scrollbar-color: #a68c5e46 #f4e5c000;
}

.page::-webkit-scrollbar {
  width: 7px;
  background: transparent;
}
.page::-webkit-scrollbar-thumb {
  background: #a68c5e46;
  border-radius: 6px;
}
.category-block,
.paged-content,
.formContainer,
.entry-image {
  max-width: 100%;
  box-sizing: border-box;
}

.page h2 {
  font-size: 28px;
  margin-top: 0;
  color: #3a1f0f;
}

.page ul {
  list-style: none;
  padding-left: 0;
  width: 100%;
}

.page li {
  margin-bottom: 10px;
}

.page button {
  margin-top: 10px;
  font-size: 16px;
  color: white;
  border: none;
  padding: 6px 12px;
  cursor: pointer;
  border-radius: 6px;
}

.page button:hover {
  background-color: #941f1f;
}

#formOverlayCategory,
#formOverlayEntry {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.formContainer {
  background: #f4e5c0;
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 0 20px black;
  width: 400px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.formContainer input, .formContainer textarea {
  font-family: 'MedievalSharp', cursive;
  font-size: 16px;
  padding: 6px;
  width: 100%;
  box-sizing: border-box;
}

input, textarea {
  user-select: text;
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
}

.hidden {
  display: none !important;
}

#categoryList {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.category-block {
  text-align: left;
  width: 90%;
  margin-bottom: 12px;
  cursor: pointer;
}

.category-title {
  font-weight: bold;
  font-size: 20px;
  padding: 6px;
  border: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.category-content {
  margin-left: 16px;
  margin-top: 4px;
  display: none;
  animation: fadeIn 0.3s ease-in-out;
}

.category-content a {
  display: inline-block;
  font-size: 17px;
  margin: 6px 0;
  color: #3a1f0f;
  text-decoration: none;
}

.category-content a:hover {
  text-decoration: underline;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.edit-button {
  display: block;
  margin: 24px auto 0 auto;
  padding: 8px 18px;
  background: #e3d3aa;
  color: #3a1f0f;
  border: 1.5px solid #a68c5e;
  border-radius: 8px;
  font-family: 'MedievalSharp', cursive;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(60,40,10,0.08);
  transition: background 0.2s, transform 0.2s;
}
.edit-button:hover {
  background: #f4e5c0;
  color: #7a4b13;
  transform: scale(1.04);
}

.add-entry-link {
  font-family: 'MedievalSharp', cursive;
  font-size: 14px;
  margin-top: 4px;
  color: #6d4a2f;
  text-decoration: none;
  display: inline-block;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s ease;
  margin-left: 10px;
}

.add-entry-link:hover {
  opacity: 1;
  text-decoration: underline;
  color: #3a1f0f;
}

.paged-content {
  width: 100%;
  max-width: 700px;
  overflow-y: visible;
  overflow-x: hidden;
  text-align: justify;
  margin: 0 auto 20px auto;
  position: relative;
  background: transparent;
  padding: 0 10px 40px 10px;
  box-sizing: border-box;
  border-radius: 12px;
  scrollbar-width: thin;
  scrollbar-color: #a68c5e46 #f4e5c000;
}

.page-navigation {
  position: absolute;
  bottom: 20px;
  right: 10px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 6px;
  color: #3a1f0f;
}

.page-navigation button {
  font-family: 'MedievalSharp', cursive;
  font-size: 10px;
  padding: 4px 10px;
  background: #d4c097;
  color: #3a1f0f;
  border: 1px solid #a68c5e;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 1px 1px 2px rgba(0,0,0,0.3);
  transition: background 0.2s, transform 0.2s;
}
.page-navigation button:hover {
  background: #e3d3aa;
  transform: scale(1.03);
}

.page-navigation span {
  font-weight: bold;
}

.entry-image {
  display: block;
  margin: 16px auto 20px auto;
  max-width: 150px;
  width: auto;
  height: auto;
  border: 2px solid #3a1f0f;
  border-radius: 8px;
  background: #f8f5e6;
  box-shadow: 0 2px 8px rgba(60,40,10,0.08);
}

.edit-icon-button {
  position: absolute;
  top: 12px;
  right: 18px;
  background: none;
  border: none;
  color: #a68c5e;
  font-size: 22px;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s, color 0.2s, transform 0.2s;
  z-index: 2;
  padding: 0;
  outline: none;
}
.edit-icon-button:hover {
  opacity: 1;
  color: #3a1f0f;
  transform: scale(1.15);
  text-shadow: 0 2px 8px #f4e5c0;
}
.page-content-block {
  position: relative;
}

.side-tab-buttons {
  position: absolute;
  bottom: 40px;
  left: -8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 30;
}

.side-tab-buttons button {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 18px 7px 10px;
  background: linear-gradient(90deg, #e3d3aa 85%, #f4e5c0 100%);
  color: #3a1f0f;
  border: 2px solid #a68c5e;
  border-left: 4px solid #a68c5e;
  border-radius: 0 18px 18px 0;
  font-family: 'MedievalSharp', cursive;
  font-size: 15px;
  font-weight: bold;
  box-shadow: 2px 2px 8px rgba(60,40,10,0.10);
  cursor: pointer;
  opacity: 0.93;
  transition: background 0.2s, color 0.2s, transform 0.2s, opacity 0.2s;
  outline: none;
  min-width: 120px;
}

.side-tab-buttons button:hover {
  background: linear-gradient(90deg, #f4e5c0 80%, #e3d3aa 100%);
  color: #a33;
  opacity: 1;
  transform: translateX(3px) scale(1.04);
}

.side-tab-buttons .tab-icon {
  font-size: 18px;
  margin-right: 2px;
}

*,
*:hover,
*:active {
  cursor: url('Feather.png') 0 24, auto !important;
}

body,
.book,
.page,
* {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.ink-blot {
  position: fixed;
  pointer-events: none;
  border-radius: 50% 60% 55% 65% / 60% 55% 65% 50%;
  background: radial-gradient(ellipse at 60% 70%, #2d0a0a 80%, transparent 100%);
  opacity: 0.32;
  z-index: 9999;
  animation: ink-blot-pop 0.7s cubic-bezier(.4,2,.6,.9) forwards;
}

@keyframes ink-blot-pop {
  0% { opacity: 0.6; transform: scale(0.7); }
  60% { opacity: 0.32; transform: scale(1.1); }
  100% { opacity: 0; transform: scale(1.3); }
}

.color-palette {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
  background: none;
  border: none;
  box-shadow: none;
}
.color-palette.hidden { display: none; }

.color-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #a68c5e;
  cursor: pointer;
  outline: none;
  margin: 0;
  transition: transform 0.15s;
}
.color-swatch:hover {
  transform: scale(1.18);
  border-color: #3a1f0f;
}

.top-bar-buttons {
  position: absolute;
  top: 18px;
  left: 18px;
  display: flex;
  gap: 14px;
  z-index: 50;
  align-items: center;
}

.top-bar-buttons button {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px 6px 8px;
  background: linear-gradient(90deg, #e3d3aa 85%, #f4e5c0 100%);
  color: #3a1f0f;
  border: 2px solid #a68c5e;
  border-radius: 12px;
  font-family: 'MedievalSharp', cursive;
  font-size: 15px;
  font-weight: bold;
  box-shadow: 2px 2px 8px rgba(60,40,10,0.10);
  cursor: pointer;
  opacity: 0.93;
  transition: background 0.2s, color 0.2s, transform 0.2s, opacity 0.2s;
  outline: none;
}

.top-bar-buttons button:hover {
  background: linear-gradient(90deg, #f4e5c0 80%, #e3d3aa 100%);
  color: #a33;
  opacity: 1;
  transform: scale(1.04);
}

.top-bar-menu {
  position: fixed;
  top: 18px;
  right: 24px;
  z-index: 200;
  display: flex;
  align-items: center;
}

.menu-toggle { display: none; }
.menu-icon { display: none; font-size: 32px; cursor: pointer; background: #f4e5c0; border: 2px solid #a68c5e; border-radius: 8px; padding: 4px 10px; z-index: 201; box-shadow: 1px 1px 8px rgba(60,40,10,0.10); }

.menu-dropdown {
  display: flex;
  flex-direction: row;
  gap: 12px;
  align-items: center;
}

.top-bar-menu .menu-dropdown .lang-flags-bar {
  position: static !important;
  top: unset !important;
  right: unset !important;
  z-index: auto !important;
  background: none;
  box-shadow: none;
  gap: 10px;
  align-items: center;
  margin: 0;
  padding: 0;
}
.lang-flags-bar img {
  width: 22px;
  height: 16px;

  margin-right: 0;
  transition: box-shadow 0.2s;
}
.lang-flags-bar img:hover { box-shadow: 0 0 6px #e3d3aa; }

/* ESTA ES LA REGLA CLAVE: Oculta por defecto el botón del menú móvil */
.color-menu-hamburguesa {
  display: none;
}

@media (max-width: 950px), (max-height: 600px) {
  .menu-icon { display: block; }
  .menu-dropdown { display: none; flex-direction: column; background: #f4e5c0; border: 2px solid #a68c5e; border-radius: 12px; position: absolute; top: 44px; right: 0; padding: 12px 18px; gap: 12px; box-shadow: 0 4px 16px rgba(60,40,10,0.18); z-index: 202; }
  .menu-toggle:checked ~ .menu-dropdown { display: flex; }
  .top-bar-menu .menu-dropdown .lang-flags-bar { display: flex !important; }
  /* Muestra el botón de color dentro del menú hamburguesa */
  .color-menu-hamburguesa { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
  /* Oculta el botón de color original de la barra superior */
  .top-bar-buttons { display: none !important; }
}

@media (max-width: 950px) and (orientation: landscape) {
  .book {
    width: 80vw;
    max-width: 700px;
    height: auto;
    aspect-ratio: 16 / 9;
    margin: 30px auto;
    border-width: 8px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
    background-size: auto;
  }
  body {
    overflow: auto;
  }
}

/* --- ESTILOS PARA BOTONES DE CATEGORÍA MÁS DISCRETOS --- */

.category-btn-group {
  display: flex;
  gap: 8px;
  align-items: center;
  opacity: 0;
  transition: opacity 0.2s ease-in-out;
}

.category-block:hover .category-btn-group {
  opacity: 1;
}

.category-add,
.category-remove,
.category-edit {
  display: inline-block;
  font-size: 18px;
  padding: 2px 4px;
  border-radius: 4px;
  cursor: pointer;
  background: none;
  border: none;
  color: #a68c5e;
  transition: transform 0.2s, color 0.2s;
}

.category-edit:hover {
  color: #3f7a13;
  transform: scale(1.2);
}

.category-add:hover {
  color: #7a4b13;
  transform: scale(1.2);
}

.category-remove:hover {
  color: #a33;
  transform: scale(1.2);
}

/* --- ESTILOS PARA EDICIÓN DE CATEGORÍA --- */

.category-title-text {
  flex-grow: 1;
}

.category-title-input {
  font-family: 'MedievalSharp', cursive;
  font-size: 20px;
  color: #3a1f0f;
  background-color: #f4e5c0;
  border: none;
  border-bottom: 1px dashed #a68c5e;
  flex-grow: 1;
  outline: none;
  padding: 0;
  margin-right: 10px;
  user-select: text;
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
}


/* --- NUEVOS ESTILOS PARA ADAPTACIÓN A MÓVIL --- */

@media (max-width: 950px) and (orientation: landscape) {
  .book {
    width: 85vw;
    max-width: 900px;
    height: auto;
    max-height: 80vh;
    aspect-ratio: 16 / 9;
    margin: 5vh auto;
    border-width: 8px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
    background-size: auto;
  }
  body {
    overflow: auto;
  }
  .side-tab-buttons {
    position: fixed;
    top: 18px;
    left: 10px;
    flex-direction: row;
    gap: 8px;
    z-index: 1001;
    bottom: unset;
    background: none;
  }
  .side-tab-buttons button {
    min-width: 80px;
    font-size: 13px;
    padding: 5px 10px 5px 7px;
    border-radius: 10px;
    gap: 5px;
  }
}

.book img,
.page-content-block img,
.entry-image {
  border: none !important;
  box-shadow: none !important;
  background: none !important;
  padding: 0 !important;
  margin: 0 auto !important;
  display: block;
  max-width: 100%;
  height: auto;
}


.entry-image.small {
  width: 100px;
}

.entry-image.medium {
  width: 200px;
}

.entry-image.large {
  width: 350px;
}

