:root {
  --color-papel-credencial: #f3ede0;
  --font-titulo-credencial: Georgia, "Times New Roman", serif;
  --textura-papel-credencial: url("/assets/textura-credencial.jpeg");
}

.toolbar .tool-btn,
.toolbar a.tool-btn,
.toolbar button.tool-btn {
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.92rem;
  font-weight: 700;
  font-style: normal;
  padding: 4px 14px;
  height: 32px;
  border-radius: 20px;
  border: 1px solid #d4d4d4;
  background: #ffffff;
  color: #111111;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
}

.toolbar .tool-btn:hover,
.toolbar a.tool-btn:hover,
.toolbar button.tool-btn:hover {
  background: #f5f5f5;
  border-color: #bbbbbb;
}

.credential-workspace {
  width: 100%;
  max-width: 1120px;
  margin: 28px auto;
  padding: 0 20px 48px;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 28px;
  align-items: start;
  box-sizing: border-box;
  font-family: 'Cormorant Garamond', serif;
}

.credential-preview-panel {
  width: 100%;
  min-width: 0;
  flex: 1 1 auto;
  box-sizing: border-box;
  container-type: inline-size;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 440px;
  padding: 12px 0;
  background: transparent;
  border: none;
  box-shadow: none;
  position: sticky;
  top: 76px;
}

.library-card {
  --card-ink: #26231f;
  --card-ink-soft: rgba(38, 35, 31, 0.86);
  --card-line: rgba(38, 35, 31, 0.55);
  --card-border: rgba(60, 50, 38, 0.22);
  --card-photo-bg: rgba(255, 255, 255, 0.18);
  position: relative;
  width: 100%;
  max-width: 660px;
  aspect-ratio: 1.72 / 1;
  padding: clamp(12px, 3.6cqw, 24px) clamp(14px, 4.8cqw, 32px) clamp(12px, 3.3cqw, 22px);
  border-radius: clamp(10px, 2.1cqw, 14px);
  background-color: var(--color-papel-credencial);
  color: var(--card-ink);
  border: 1px solid var(--card-border);
  box-shadow:
    0 20px 45px rgba(0, 0, 0, 0.22),
    0 6px 16px rgba(0, 0, 0, 0.12),
    inset 0 1px 0.5px rgba(255, 255, 255, 0.58),
    inset 0 -1px 1px rgba(45, 35, 25, 0.14),
    inset 0 0 0 1px rgba(45, 35, 25, 0.06);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  isolation: isolate;
  text-transform: uppercase;
  transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.library-card.is-dark-paper {
  --card-ink: #f4efe4;
  --card-ink-soft: rgba(244, 239, 228, 0.88);
  --card-line: rgba(244, 239, 228, 0.55);
  --card-border: rgba(244, 239, 228, 0.24);
  --card-photo-bg: rgba(255, 255, 255, 0.08);
  box-shadow:
    0 20px 45px rgba(0, 0, 0, 0.34),
    0 6px 16px rgba(0, 0, 0, 0.18),
    inset 0 1px 0.5px rgba(255, 255, 255, 0.16),
    inset 0 -1px 1px rgba(0, 0, 0, 0.32),
    inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.library-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  border-radius: inherit;
  background-image: var(--textura-papel-credencial);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0.35;
  mix-blend-mode: multiply;
}

.library-card.is-dark-paper::before {
  opacity: 0.28;
  mix-blend-mode: soft-light;
  filter: contrast(1.25) brightness(0.85);
}

.library-card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  border-radius: inherit;
  mix-blend-mode: soft-light;
  background:
    linear-gradient(
      125deg,
      rgba(255, 255, 255, 0.18) 0%,
      rgba(255, 255, 255, 0.03) 38%,
      rgba(0, 0, 0, 0.02) 68%,
      rgba(255, 255, 255, 0.06) 100%
    ),
    radial-gradient(
      circle at 96% 94%,
      rgba(60, 48, 35, 0.06) 0%,
      transparent 28%
    ),
    radial-gradient(
      circle at 4% 92%,
      rgba(60, 48, 35, 0.045) 0%,
      transparent 24%
    );
}

.library-card-top,
.library-card-grid {
  position: relative;
  z-index: 3;
  mix-blend-mode: normal;
}

.credential-stickers-layer {
  position: absolute;
  inset: 0;
  z-index: auto;
  isolation: auto;
  pointer-events: none;
}

.credential-stickers-layer .sticker-item.layer-plastificado {
  opacity: 0.56;
}

.credential-stickers-layer .sticker-item.layer-plastificado img {
  opacity: 0.56;
  filter: saturate(1.1) contrast(1.04) brightness(1.06);
}

.credential-stickers-layer .sticker-item:not(.layer-plastificado) img {
  opacity: 1;
}

.credential-stickers-layer .sticker-item {
  pointer-events: auto;
}

.library-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: clamp(8px, 2.4cqw, 16px);
}

.library-main-title {
  margin: 0;
  font-family: var(--font-titulo-credencial);
  font-size: clamp(1.05rem, 5.8cqw, 2.5rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1;
  text-transform: uppercase;
}

.library-subtitle {
  margin: clamp(3px, 0.9cqw, 6px) 0 0;
  font-family: "Courier New", Courier, monospace;
  font-size: clamp(0.46rem, 1.9cqw, 0.85rem);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  opacity: 0.88;
}

.library-file-no {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: clamp(6px, 1.6cqw, 12px);
  padding-top: clamp(2px, 0.9cqw, 6px);
  border-bottom: 1.5px solid var(--card-ink);
  padding-bottom: clamp(2px, 0.45cqw, 3px);
  flex-shrink: 0;
}

.library-file-label {
  font-family: "Courier New", Courier, monospace;
  font-size: clamp(0.46rem, 1.65cqw, 0.72rem);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.85;
}

.library-file-value {
  font-family: "Courier New", Courier, monospace;
  font-style: normal;
  font-size: clamp(0.56rem, 2.1cqw, 0.92rem);
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1;
  text-align: right;
}

.library-card-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(86px, 25cqw, 165px);
  gap: clamp(10px, 3.6cqw, 24px);
  align-items: end;
  margin-top: clamp(4px, 1.2cqw, 8px);
}

.library-fields {
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 2.1cqw, 14px);
  padding-bottom: clamp(2px, 0.6cqw, 4px);
  min-width: 0;
}

.library-field-row {
  display: flex;
  flex-direction: column;
  gap: clamp(2px, 0.6cqw, 4px);
}

.library-line-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: clamp(8px, 2cqw, 14px);
  min-height: clamp(0.75rem, 2.6cqw, 1.2rem);
}

.library-field-label {
  font-family: "Courier New", Courier, monospace;
  font-size: clamp(0.46rem, 1.75cqw, 0.76rem);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
  opacity: 0.85;
}

.library-field-value {
  font-family: "Courier New", Courier, monospace;
  font-size: clamp(0.54rem, 2cqw, 0.88rem);
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1.1;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-underline {
  width: 100%;
  height: 1.2px;
  opacity: 0.55;
  background: var(--card-line);
}

.library-photo-column {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: clamp(4px, 1cqw, 7px);
}

.library-photo-outer {
  position: relative;
  padding: clamp(3px, 0.9cqw, 6px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.library-photo-frame {
  position: relative;
  width: clamp(76px, 22cqw, 146px);
  aspect-ratio: 146 / 184;
  border: 1.5px solid var(--card-ink);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card-photo-bg);
  user-select: none;
  isolation: isolate;
}

.library-photo-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background-image: var(--textura-papel-credencial);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0.12;
  mix-blend-mode: overlay;
}

.library-photo-frame img {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  transform-origin: center center;
  z-index: 1;
}

.library-photo-placeholder {
  font-family: "Courier New", Courier, monospace;
  font-size: clamp(0.48rem, 1.65cqw, 0.72rem);
  letter-spacing: 0.16em;
  opacity: 0.6;
  z-index: 1;
}

.corner-mark {
  position: absolute;
  width: clamp(7px, 2cqw, 13px);
  height: clamp(7px, 2cqw, 13px);
  border-color: var(--card-ink);
  border-style: solid;
  z-index: 3;
  pointer-events: none;
}

.corner-mark.tl {
  top: 0;
  left: 0;
  border-width: 2px 0 0 2px;
}

.corner-mark.tr {
  top: 0;
  right: 0;
  border-width: 2px 2px 0 0;
}

.corner-mark.bl {
  bottom: 0;
  left: 0;
  border-width: 0 0 2px 2px;
}

.corner-mark.br {
  bottom: 0;
  right: 0;
  border-width: 0 2px 2px 0;
}

.library-barcode-wrap {
  width: clamp(82px, 23.8cqw, 158px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--card-ink);
}

.library-barcode-svg {
  width: 100%;
  height: clamp(14px, 3.6cqw, 24px);
  display: block;
}

.library-barcode-code {
  font-family: "Courier New", Courier, monospace;
  font-size: clamp(0.38rem, 1.15cqw, 0.54rem);
  letter-spacing: 0.22em;
  line-height: 1;
  opacity: 0.84;
  white-space: nowrap;
}

.credential-range-input {
  width: 100%;
  accent-color: #2b2620;
  cursor: pointer;
}

.credential-range-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.76rem;
  color: #555048;
}

.credential-controls-panel {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow: hidden;
  padding: 20px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(0, 0, 0, 0.1);
  color: #1c1a17;
  display: flex;
  flex-direction: column;
  gap: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#credential-recent-resources.recent-resources {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  max-height: 156px;
  overflow-y: auto;
  padding: 8px;
  box-sizing: border-box;
  border-radius: 10px;
  border: 1px solid #dfd7c8;
  background: #fdfbf7;
}

#credential-recent-resources .empty-resources {
  grid-column: 1 / -1;
  font-size: 0.8rem;
  color: #777066;
  text-align: center;
  padding: 10px 4px;
}

#credential-recent-resources .resource-thumb-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  border: 1px solid #d6cec0;
  background: #ffffff;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  box-sizing: border-box;
}

#credential-recent-resources .resource-thumb-wrapper img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

#credential-recent-resources .delete-resource-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: rgba(20, 20, 20, 0.78);
  color: #ffffff;
  font-size: 12px;
  line-height: 1;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.credential-stickers-layer .sticker-item {
  position: absolute;
  cursor: grab;
  user-select: none;
  box-sizing: border-box;
  border: 1px dashed transparent;
}

.credential-stickers-layer .sticker-item.active-transform {
  border-color: rgba(38, 35, 31, 0.65);
}

.credential-stickers-layer .sticker-item img {
  width: 100%;
  height: auto;
  display: block;
  pointer-events: none;
}

.credential-stickers-layer .sticker-actions {
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  gap: 3px;
  background: #ffffff;
  border: 1px solid #d4d4d4;
  border-radius: 999px;
  padding: 2px 5px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.14);
  z-index: 10;
}

.credential-stickers-layer .sticker-item.active-transform .sticker-actions {
  display: flex;
}

.credential-stickers-layer .sticker-mini-btn {
  border: none;
  background: transparent;
  color: #111111;
  font-size: 11px;
  width: 18px;
  height: 18px;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.credential-stickers-layer .rotate-handle,
.credential-stickers-layer .resize-handle {
  display: none;
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid #26231f;
  color: #26231f;
  font-size: 10px;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.credential-stickers-layer .sticker-item.active-transform .rotate-handle,
.credential-stickers-layer .sticker-item.active-transform .resize-handle {
  display: flex;
}

.credential-stickers-layer .rotate-handle {
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  cursor: grab;
}

.credential-stickers-layer .resize-handle {
  right: -8px;
  bottom: -8px;
  cursor: nwse-resize;
}

.credential-controls-panel h2 {
  margin: 0;
  font-size: 1.05rem;
}

.credential-hint {
  margin: 0;
  font-size: 0.82rem;
  color: #555048;
}

.credential-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.credential-field label {
  font-size: 0.8rem;
  font-weight: 600;
}

.credential-color-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.credential-color-row input[type="color"] {
  width: 44px;
  height: 36px;
  padding: 2px;
  border-radius: 8px;
  border: 1px solid #cfc6b6;
  background: #fdfbf7;
  cursor: pointer;
  flex-shrink: 0;
}

.credential-field input[type="text"],
.credential-field select {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #cfc6b6;
  background: #fdfbf7;
  color: #1c1a17;
  font-family: inherit;
  font-size: 0.88rem;
}

.credential-photo-upload-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #cfc6b6;
  background: #fdfbf7;
  color: #1c1a17;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.credential-photo-upload-btn:hover {
  background: #f3ede0;
  border-color: #b5aa96;
}

.credential-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

@media (max-width: 900px) {
  .credential-workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .credential-preview-panel {
    position: static;
    min-height: auto;
    padding: 12px 0;
  }
}

.credential-stickers-layer .sticker-item,
.credential-stickers-layer .sticker-item img {
    isolation: auto;
}

body[data-page="credential"] .credential-stickers-layer .sticker-item {
  pointer-events: none !important;
}

body[data-page="credential"] .credential-stickers-layer .sticker-item.active-transform,
body[data-page="credential"] .credential-stickers-layer .sticker-item.active-transform * {
  pointer-events: auto !important;
}

body[data-page="credential"] .credential-stickers-layer .sticker-item.active-transform img {
  pointer-events: none !important;
}