:root {
  --desk-deep: #2a2118;
  --desk-mid: #4a3728;
  --desk-grain: #3d2e22;
  --plastic: #c4b49a;
  --plastic-dark: #9a8a72;
  --plastic-light: #d9ccb4;
  --card: #f7f2e8;
  --card-rule: #d4cbb8;
  --ink: #1c1814;
  --ink-soft: #5c5348;
  --accent: #8b1e1e;
  --accent-soft: #b54545;
  --gold: #b8973d;
  --shadow: rgba(20, 12, 6, 0.55);
  --radius-card: 2px;
  --font-brand: "Source Serif 4", Georgia, serif;
  --font-ui: "Barlow Condensed", "Arial Narrow", sans-serif;
  --font-card: "Special Elite", "Courier New", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  color: var(--ink);
  font-family: var(--font-ui);
  overflow: hidden;
  background:
    radial-gradient(ellipse 90% 60% at 50% 0%, rgba(0, 255, 204, 0.05), transparent 50%),
    radial-gradient(ellipse 90% 60% at 50% 0%, rgba(255, 220, 160, 0.1), transparent 55%),
    linear-gradient(165deg, #1a1410 0%, var(--desk-deep) 40%, #1f1712 100%);
}

/* CRT scanlines — overlay ciberpunk sin bloquear interacción */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: linear-gradient(
    rgba(18, 16, 16, 0) 50%,
    rgba(0, 0, 0, 0.22) 50%
  );
  background-size: 100% 4px;
  z-index: 999;
  pointer-events: none;
  opacity: 0.55;
}

/* —— Splash boot —— */
.splash {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 70% 50% at 50% 40%, rgba(0, 255, 204, 0.08), transparent 60%),
    linear-gradient(165deg, #0d0a08 0%, #1a1410 45%, #12100e 100%);
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.splash.is-done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1rem;
  width: min(360px, 86vw);
  text-align: center;
}

.splash__logo {
  width: min(280px, 70vw);
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 0 18px rgba(0, 255, 204, 0.25));
  animation: splash-logo 1.2s ease-out both;
}

.splash__track {
  width: 100%;
  height: 8px;
  border: 1px solid rgba(0, 255, 204, 0.35);
  background: rgba(0, 0, 0, 0.45);
  overflow: hidden;
  box-shadow: 0 0 12px rgba(0, 255, 204, 0.15);
}

.splash__bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #008f72, #00ffcc);
  box-shadow: 0 0 10px rgba(0, 255, 204, 0.55);
}

.splash__pct {
  margin: 0;
  font-family: var(--font-card);
  font-size: 1.05rem;
  letter-spacing: 0.16em;
  color: #00ffcc;
  text-shadow: 0 0 8px rgba(0, 255, 204, 0.4);
}

.splash__label {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #ff4d7a;
  text-shadow: 0 0 8px rgba(255, 0, 85, 0.35);
}

@keyframes splash-logo {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

body:not(.splash-done) .desk,
body:not(.splash-done) .overlay {
  visibility: hidden;
}

.desk {
  height: 100%;
  min-height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 0.85rem clamp(0.85rem, 2vw, 1.75rem) 0.65rem;
  background-image:
    repeating-linear-gradient(
      90deg,
      transparent 0,
      transparent 2px,
      rgba(0, 0, 0, 0.03) 2px,
      rgba(0, 0, 0, 0.03) 3px
    ),
    radial-gradient(ellipse at 50% 85%, rgba(90, 60, 30, 0.35), transparent 55%);
}

.masthead {
  position: relative;
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
  animation: fade-rise 0.9s ease-out both;
}

.masthead__titles {
  text-align: center;
}

.menu-toggle {
  justify-self: start;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid rgba(0, 255, 204, 0.45);
  border-radius: 3px;
  background: linear-gradient(180deg, rgba(42, 33, 24, 0.92), rgba(26, 20, 16, 0.95));
  box-shadow:
    0 0 12px rgba(0, 255, 204, 0.2),
    0 8px 20px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  transition: filter 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.menu-toggle:hover {
  filter: brightness(1.08);
  box-shadow: 0 0 16px rgba(0, 255, 204, 0.35);
}

.menu-toggle:active {
  transform: translateY(1px);
}

.menu-toggle[aria-expanded="true"] {
  border-color: rgba(255, 0, 85, 0.55);
  box-shadow:
    0 0 12px rgba(255, 0, 85, 0.25),
    0 8px 20px rgba(0, 0, 0, 0.45);
}

.menu-toggle__bars,
.menu-toggle__bars::before,
.menu-toggle__bars::after {
  display: block;
  width: 20px;
  height: 2px;
  background: #00ffcc;
  border-radius: 1px;
  transition: transform 0.25s ease, opacity 0.2s ease, background 0.15s ease;
}

.menu-toggle__bars {
  position: relative;
}

.menu-toggle__bars::before,
.menu-toggle__bars::after {
  content: "";
  position: absolute;
  left: 0;
}

.menu-toggle__bars::before {
  top: -6px;
}

.menu-toggle__bars::after {
  top: 6px;
}

.menu-toggle[aria-expanded="true"] .menu-toggle__bars {
  background: transparent;
}

.menu-toggle[aria-expanded="true"] .menu-toggle__bars::before,
.menu-toggle[aria-expanded="true"] .menu-toggle__bars::after {
  top: 0;
  background: #ff4d7a;
}

.menu-toggle[aria-expanded="true"] .menu-toggle__bars::before {
  transform: rotate(45deg);
}

.menu-toggle[aria-expanded="true"] .menu-toggle__bars::after {
  transform: rotate(-45deg);
}

.brand {
  margin: 0;
  font-family: var(--font-brand);
  font-weight: 700;
  font-size: clamp(2rem, 4.5vw, 3.2rem);
  letter-spacing: 0.18em;
  line-height: 1;
  color: #7dffd6;
  text-shadow:
    0 0 6px rgba(0, 255, 204, 0.45),
    0 0 18px rgba(0, 255, 204, 0.28),
    0 2px 0 rgba(0, 0, 0, 0.55),
    0 12px 40px rgba(0, 0, 0, 0.35);
}

.tagline {
  margin: 0.3rem 0 0;
  font-size: 0.95rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #ff4d7a;
  text-shadow: 0 0 8px rgba(255, 0, 85, 0.45);
  opacity: 0.95;
}

.sys-status {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-card);
  font-size: 0.75rem;
  color: #00ffcc;
  letter-spacing: 0.12em;
  text-shadow: 0 0 6px rgba(0, 255, 204, 0.35);
}

.sys-status__led {
  width: 8px;
  height: 8px;
  background-color: #00ffcc;
  border-radius: 50%;
  box-shadow: 0 0 8px #00ffcc;
  animation: blink 2s infinite ease-in-out;
}

.sys-status__text {
  opacity: 0.9;
}

@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

.workspace {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  min-height: 0;
  align-items: stretch;
  overflow: hidden;
}

.import-scrim {
  position: absolute;
  inset: 0;
  z-index: 35;
  background: rgba(18, 12, 8, 0.45);
  border: none;
  padding: 0;
  cursor: pointer;
  animation: fade-in 0.2s ease-out;
}

.import-scrim[hidden] {
  display: none !important;
}

/* —— Import tray (left drawer) —— */
.import-tray {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(320px, 88vw);
  margin: 0;
  padding: 1rem 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  background:
    linear-gradient(180deg, #ebe2d0 0%, #d9ccb4 100%);
  border: 1px solid #8a7a62;
  border-radius: 0 4px 4px 0;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    8px 0 28px var(--shadow);
  z-index: 40;
  overflow: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  max-height: 100%;
  transform: translateX(-105%);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}

.import-tray.is-open {
  transform: translateX(0);
  pointer-events: auto;
}

.import-tray::-webkit-scrollbar {
  display: none;
}

.import-tray__head {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.55rem;
  margin-bottom: 0;
  padding-top: 0.85rem;
  border-top: 1px solid rgba(90, 80, 64, 0.35);
}

.menu-search {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.menu-search__label {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.import-tray__head h2 {
  margin: 0;
  font-family: var(--font-brand);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.02em;
}

.import-tray__formats {
  margin: 0;
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 0.35rem;
}

.import-tray__formats span {
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.25rem 0.45rem;
  background: rgba(42, 33, 24, 0.08);
  border: 1px solid rgba(90, 80, 64, 0.35);
  color: var(--ink-soft);
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  min-height: 120px;
  flex: 0 0 auto;
  padding: 1rem 0.85rem;
  border: 2px dashed #8a7a62;
  border-radius: 3px;
  background: rgba(247, 242, 232, 0.75);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.dropzone:hover,
.dropzone.is-dragover {
  border-color: var(--accent);
  background: #f7f2e8;
  box-shadow: inset 0 0 0 1px rgba(139, 30, 30, 0.2);
}

.dropzone__title {
  font-family: var(--font-ui);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
}

.dropzone__hint {
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
}

.export-db-btn {
  width: 100%;
  margin-top: 0.15rem;
}

.new-ficha-btn {
  width: 100%;
  margin-top: 0.15rem;
}

.import-tray__tools {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.65rem;
  margin-top: auto;
}

.search-wrap {
  position: relative;
  flex: none;
  max-width: none;
  width: 100%;
}

#searchInput {
  width: 100%;
  padding: 0.55rem 0.85rem;
  border: 1px solid #6a5a45;
  border-radius: 3px;
  background: #f7f2e8;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  outline: none;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

#searchInput:focus {
  border-color: var(--accent);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1), 0 0 0 2px rgba(139, 30, 30, 0.25);
}

.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 0.25rem 0;
  list-style: none;
  max-height: 220px;
  overflow-y: auto;
  background: #f7f2e8;
  border: 1px solid #8a7a62;
  border-radius: 3px;
  box-shadow: 0 12px 28px var(--shadow);
  z-index: 30;
}

.search-results li {
  padding: 0.45rem 0.85rem;
  cursor: pointer;
  font-size: 1rem;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--card-rule);
}

.search-results li:last-child {
  border-bottom: none;
}

.search-results li:hover,
.search-results li[aria-selected="true"] {
  background: #e8dcc8;
}

.search-results .meta {
  display: block;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.hint {
  margin: 0;
  flex: none;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  line-height: 1.35;
}

/* —— Stage / housing —— */
.stage {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  perspective: 1100px;
  perspective-origin: 50% 42%;
  outline: none;
  animation: fade-rise 1s 0.2s ease-out both;
  min-height: 0;
  min-width: 0;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.stage.is-dragging {
  cursor: grabbing;
}

.desk.view-table .stage {
  cursor: default;
  touch-action: auto;
  user-select: auto;
}

.housing {
  position: absolute;
  width: min(420px, 88vw);
  height: min(520px, 72vh);
  pointer-events: none;
  z-index: 1;
}

.housing-body {
  position: absolute;
  inset: 12% 8% 10%;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.18), transparent 18%, transparent 82%, rgba(0, 0, 0, 0.18)),
    linear-gradient(180deg, var(--plastic-dark), var(--plastic) 30%, var(--plastic-light) 55%, var(--plastic) 80%, var(--plastic-dark));
  border-radius: 28% / 10%;
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.12),
    inset 0 0 18px rgba(0, 255, 204, 0.12),
    inset 0 -20px 40px rgba(0, 0, 0, 0.45),
    0 30px 60px var(--shadow);
}

.housing-rim {
  position: absolute;
  left: 10%;
  right: 10%;
  height: 14%;
  background: linear-gradient(180deg, #a89478, var(--plastic-dark) 40%, #7a6a55);
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.housing-rim--top {
  top: 4%;
}

.housing-rim--bottom {
  bottom: 2%;
}

.axle {
  position: absolute;
  left: 50%;
  top: 18%;
  bottom: 16%;
  width: 10px;
  margin-left: -5px;
  background: linear-gradient(90deg, #5a5045, #c8b89a, #5a5045);
  border-radius: 4px;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.4);
  opacity: 0.55;
}

.rolodex {
  position: relative;
  width: 300px;
  height: 185px;
  transform-style: preserve-3d;
  z-index: 2;
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

.rolodex.is-spinning {
  transition-duration: 0.55s;
}

/* —— Cards —— */
.card {
  position: absolute;
  inset: 0;
  width: 300px;
  height: 185px;
  min-width: 300px;
  min-height: 185px;
  max-width: 300px;
  max-height: 185px;
  flex-shrink: 0;
  box-sizing: border-box;
  overflow: hidden;
  padding: 0.95rem 1.1rem 1.5rem;
  background:
    repeating-linear-gradient(
      transparent,
      transparent 1.15rem,
      var(--card-rule) 1.15rem,
      var(--card-rule) calc(1.15rem + 1px)
    ),
    linear-gradient(135deg, #fffdf8 0%, var(--card) 60%, #efe6d4 100%);
  color: var(--ink);
  border-radius: var(--radius-card);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.6) inset,
    0 8px 20px rgba(0, 0, 0, 0.35);
  border: 1px solid #cfc3ad;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  font-family: var(--font-card);
  transform-origin: center center;
  pointer-events: none;
}

.rolodex .card {
  padding-bottom: 1.55rem;
}

/*
 * Muesca inferior: eje/plástico oscuro pintado sobre el papel
 * (dentro de la ficha, sin agujero al fondo del escritorio).
 */
.rolodex .card::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  z-index: 3;
  width: 44px;
  height: 12px;
  margin-left: -22px;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.4) 0%, transparent 50%),
    linear-gradient(
      90deg,
      #1a1510 0%,
      #4a4034 20%,
      #8a7a62 40%,
      #d2c3a4 50%,
      #8a7a62 60%,
      #4a4034 80%,
      #1a1510 100%
    );
  border: 1px solid #2e2820;
  border-top-color: #12100c;
  border-radius: 0 0 5px 5px;
  clip-path: polygon(8% 0, 92% 0, 100% 100%, 0 100%);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.55);
  pointer-events: none;
}

/* En la vista tabla las fichas compactas no usan muesca de eje */


.card.is-active {
  pointer-events: auto;
  cursor: pointer;
  border-color: rgba(0, 255, 204, 0.55);
  box-shadow:
    0 0 14px rgba(0, 255, 204, 0.22),
    inset 0 0 10px rgba(0, 255, 204, 0.08),
    0 1px 0 rgba(255, 255, 255, 0.6) inset,
    0 14px 28px rgba(0, 0, 0, 0.5);
}

.card.is-active:hover {
  filter: brightness(1.03);
}

.card-index {
  position: absolute;
  top: 0.55rem;
  right: 0.75rem;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
}

.card h3 {
  margin: 0.15rem 0 0.45rem;
  font-size: 1.2rem;
  font-weight: 400;
  line-height: 1.25;
  max-width: 85%;
}

.card p {
  margin: 0.15rem 0;
  font-size: 0.95rem;
  color: var(--ink-soft);
  line-height: 1.3;
}

.card-mail {
  color: var(--ink-soft);
  font-family: var(--font-card);
  text-decoration: none;
  pointer-events: none;
  cursor: default;
}

.card.is-active .card-mail {
  pointer-events: auto;
  cursor: pointer;
}

.card.is-active .card-mail:hover {
  color: var(--ink);
  text-decoration: none;
}

.card .field-label {
  color: var(--accent);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
}

.card .badge {
  margin-top: auto;
  align-self: flex-start;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--desk-deep);
  border-bottom: 2px solid var(--gold);
  padding-bottom: 0.1rem;
}

.stage-tools {
  position: absolute;
  bottom: 5%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  pointer-events: none;
}

.desk.view-table .stage-tools,
.desk.view-table .wheel-sort {
  display: none;
}

.wheel-sort {
  position: absolute;
  top: 0.65rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  pointer-events: auto;
  padding: 0.28rem 0.55rem;
  border: 1px solid rgba(0, 255, 204, 0.4);
  background: rgba(18, 14, 10, 0.55);
  color: #7dffd6;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.wheel-sort:hover,
.wheel-sort:focus-visible {
  border-color: rgba(0, 255, 204, 0.75);
  background: rgba(0, 255, 204, 0.12);
  outline: none;
}

.wheel-sort[data-dir="-1"] {
  color: #ff7aa8;
  border-color: rgba(255, 77, 122, 0.45);
}

.counter {
  font-family: var(--font-ui);
  font-size: 1.1rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(240, 230, 212, 0.7);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

.foot {
  text-align: center;
  padding-top: 0.5rem;
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(240, 230, 212, 0.4);
}

.foot .sep {
  margin: 0 0.5rem;
}

.foot__link {
  color: rgba(0, 255, 204, 0.55);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.foot__link:hover,
.foot__link:focus-visible {
  color: #00ffcc;
  border-bottom-color: rgba(0, 255, 204, 0.45);
  outline: none;
}

.mute-toggle {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 90;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.85rem;
  border: 1px solid rgba(0, 255, 204, 0.45);
  background: linear-gradient(180deg, rgba(42, 33, 24, 0.92), rgba(26, 20, 16, 0.95));
  color: #00ffcc;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow:
    0 0 12px rgba(0, 255, 204, 0.2),
    0 8px 20px rgba(0, 0, 0, 0.45);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease, filter 0.15s ease;
}

.view-toggle {
  position: fixed;
  left: 1rem;
  bottom: 1rem;
  z-index: 90;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.85rem;
  border: 1px solid rgba(0, 255, 204, 0.45);
  background: linear-gradient(180deg, rgba(42, 33, 24, 0.92), rgba(26, 20, 16, 0.95));
  color: #00ffcc;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow:
    0 0 12px rgba(0, 255, 204, 0.2),
    0 8px 20px rgba(0, 0, 0, 0.45);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease, filter 0.15s ease;
}

.view-toggle:hover,
.mute-toggle:hover {
  filter: brightness(1.08);
  box-shadow: 0 0 16px rgba(0, 255, 204, 0.35);
}

.view-toggle[aria-pressed="true"] {
  color: #ff4d7a;
  border-color: rgba(255, 0, 85, 0.55);
  box-shadow:
    0 0 12px rgba(255, 0, 85, 0.25),
    0 8px 20px rgba(0, 0, 0, 0.45);
}

/* —— Table view —— */
.table-view {
  display: none;
  min-width: 0;
  min-height: 0;
  height: 100%;
}

.desk.view-table .stage {
  display: none;
}

.desk.view-table .table-view {
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.desk.view-table .workspace {
  overflow: hidden;
}

.table-view__scroll {
  height: 100%;
  overflow: auto;
  padding: 0.65rem 1rem 4.5rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 255, 204, 0.35) transparent;
  background:
    radial-gradient(ellipse 80% 40% at 50% 0%, rgba(0, 255, 204, 0.04), transparent 55%),
    linear-gradient(180deg, rgba(12, 10, 8, 0.35), transparent 120px);
}

.table-view__legend {
  margin: 0 auto 1.1rem;
  max-width: 1100px;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(0, 255, 204, 0.55);
  text-align: center;
}

/* Cajón / bandeja por curso */
.course-block {
  --course-card-w: 230px;
  --course-gap: 0.8rem;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto 1.35rem;
  padding: 0.85rem 0.95rem 1rem;
  border: 1px solid rgba(0, 255, 204, 0.22);
  border-radius: 4px;
  background:
    linear-gradient(180deg, rgba(36, 30, 24, 0.72), rgba(18, 15, 12, 0.78)),
    repeating-linear-gradient(
      90deg,
      transparent 0,
      transparent 11px,
      rgba(0, 255, 204, 0.03) 11px,
      rgba(0, 255, 204, 0.03) 12px
    );
  box-shadow:
    inset 0 1px 0 rgba(0, 255, 204, 0.08),
    inset 0 0 28px rgba(0, 0, 0, 0.45),
    0 10px 28px rgba(0, 0, 0, 0.35);
  transition:
    border-color 0.2s ease,
    background 0.2s ease,
    box-shadow 0.2s ease;
}

.course-block.is-drop-target {
  border-color: #00ffcc;
  background:
    linear-gradient(180deg, rgba(0, 255, 204, 0.12), rgba(18, 15, 12, 0.72)),
    repeating-linear-gradient(
      90deg,
      transparent 0,
      transparent 11px,
      rgba(0, 255, 204, 0.05) 11px,
      rgba(0, 255, 204, 0.05) 12px
    );
  box-shadow:
    0 0 22px rgba(0, 255, 204, 0.28),
    inset 0 0 22px rgba(0, 255, 204, 0.1),
    0 10px 28px rgba(0, 0, 0, 0.35);
}

.course-block__head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid rgba(0, 255, 204, 0.2);
}

.course-block__title {
  margin: 0;
  flex: 0 1 auto;
  font-family: var(--font-card);
  font-size: 1.05rem;
  font-weight: 400;
  color: #7dffd6;
  letter-spacing: 0.08em;
  text-shadow: 0 0 8px rgba(0, 255, 204, 0.28);
}

.course-block__tag {
  white-space: nowrap;
}

.course-block__rail {
  flex: 1 1 2rem;
  min-width: 1.5rem;
  height: 1px;
  background: linear-gradient(
    90deg,
    rgba(0, 255, 204, 0.45),
    rgba(0, 255, 204, 0.08) 70%,
    transparent
  );
}

.course-block__meta {
  margin: 0;
  flex: 0 0 auto;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(240, 230, 212, 0.55);
  white-space: nowrap;
}

.course-sort {
  flex: 0 0 auto;
  margin-left: auto;
  padding: 0.28rem 0.55rem;
  border: 1px solid rgba(0, 255, 204, 0.4);
  background: rgba(18, 14, 10, 0.55);
  color: #7dffd6;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.course-sort:hover,
.course-sort:focus-visible {
  border-color: rgba(0, 255, 204, 0.75);
  background: rgba(0, 255, 204, 0.12);
  outline: none;
}

.course-sort[data-dir="-1"] {
  color: #ff7aa8;
  border-color: rgba(255, 77, 122, 0.45);
}

.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--course-card-w), 1fr));
  gap: var(--course-gap);
  min-height: 6rem;
  align-content: start;
}

/* Ficha del clasificador: más ancha y con nombre completo legible */
.table-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 0.28rem;
  min-height: 6.4rem;
  padding: 1.35rem 0.85rem 0.7rem 1.7rem;
  box-sizing: border-box;
  border: 1px solid #b8aa92;
  border-radius: 2px;
  background:
    repeating-linear-gradient(
      transparent,
      transparent 0.95rem,
      rgba(180, 160, 130, 0.22) 0.95rem,
      rgba(180, 160, 130, 0.22) calc(0.95rem + 1px)
    ),
    linear-gradient(145deg, #fffdf8, #f0e6d4 70%, #e5d8c0);
  color: var(--ink);
  font-family: var(--font-card);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.5) inset,
    0 4px 12px rgba(0, 0, 0, 0.28);
  transition:
    transform 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    opacity 0.15s ease,
    filter 0.15s ease;
}

.table-card:active {
  cursor: grabbing;
}

.table-card:hover,
.table-card:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(0, 255, 204, 0.55);
  outline: none;
  box-shadow:
    0 0 12px rgba(0, 255, 204, 0.22),
    0 1px 0 rgba(255, 255, 255, 0.55) inset,
    0 8px 18px rgba(0, 0, 0, 0.35);
}

.table-card.is-dragging {
  opacity: 0.4;
  transform: scale(0.96);
  cursor: grabbing;
  border-style: dashed;
  border-color: #00ffcc;
  box-shadow: none;
}

.table-card__grip {
  position: absolute;
  top: 50%;
  left: 0.4rem;
  width: 0.75rem;
  height: 1.35rem;
  margin-top: -0.68rem;
  background:
    radial-gradient(circle, rgba(139, 30, 30, 0.7) 1.1px, transparent 1.3px) 0 0 / 0.35rem 0.35rem,
    radial-gradient(circle, rgba(139, 30, 30, 0.7) 1.1px, transparent 1.3px) 0.35rem 0 / 0.35rem 0.35rem;
  background-size: 0.35rem 0.35rem;
  background-repeat: repeat;
  opacity: 0.7;
  pointer-events: none;
}

.table-card:hover .table-card__grip {
  opacity: 1;
}

.table-card__index {
  position: absolute;
  top: 0.35rem;
  right: 0.5rem;
  font-family: var(--font-ui);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
  opacity: 0.75;
}

.table-card__name {
  display: block;
  margin: 0;
  padding-right: 0.15rem;
  font-size: 1.08rem;
  font-weight: 400;
  line-height: 1.25;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

.table-card__instrument {
  display: block;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  line-height: 1.25;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

.table-card__meta {
  display: block;
  margin-top: 0.1rem;
  font-family: var(--font-card);
  font-size: 0.88rem;
  line-height: 1.25;
  color: var(--ink-soft);
}

.table-view__scroll.is-dragging-card {
  cursor: grabbing;
}

.table-view__scroll.is-dragging-card .table-card:not(.is-dragging) {
  pointer-events: none;
}

.table-view__scroll.is-dragging-card .course-block:not(.is-drop-target) {
  opacity: 0.72;
}

.table-view__empty {
  margin: 2rem auto;
  text-align: center;
  color: rgba(240, 230, 212, 0.55);
  font-family: var(--font-ui);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

@media (max-width: 700px) {
  .course-block {
    --course-card-w: min(100%, 280px);
  }

  .course-block__rail {
    display: none;
  }

  .course-sort {
    margin-left: 0;
  }
}

.mute-toggle[aria-pressed="true"] {
  color: #ff4d7a;
  border-color: rgba(255, 0, 85, 0.55);
  box-shadow:
    0 0 12px rgba(255, 0, 85, 0.25),
    0 8px 20px rgba(0, 0, 0, 0.45);
}

body:not(.splash-done) .view-toggle,
body:not(.splash-done) .mute-toggle {
  visibility: hidden;
}

@keyframes fade-rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 640px) {
  body {
    overflow: auto;
  }

  body.is-modal-open {
    overflow: hidden !important;
  }

  .desk {
    min-height: 100dvh;
    height: auto;
    padding-bottom: 1.5rem;
  }

  .workspace {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .import-tray {
    max-height: none;
    height: 100%;
  }

  .import-tray__formats {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .dropzone {
    min-height: 88px;
  }

  .brand {
    font-size: 2rem;
    letter-spacing: 0.14em;
  }

  .tagline {
    font-size: 0.72rem;
    letter-spacing: 0.1em;
  }

  .sys-status__text {
    display: none;
  }

  .housing {
    height: min(460px, 68vh);
  }

  .hint {
    width: 100%;
    text-align: left;
  }

  .stage {
    min-height: 420px;
  }
}

/* —— Overlays —— */
.overlay {
  position: fixed;
  inset: 0;
  /* Por encima del CRT (body::before z-index 999) para recibir clics con seguridad */
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(18, 12, 8, 0.72);
  backdrop-filter: blur(4px);
  animation: fade-in 0.25s ease-out;
  overflow: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.overlay::-webkit-scrollbar {
  display: none;
}

.overlay[hidden] {
  display: none !important;
}

.panel {
  width: min(640px, 100%);
  max-height: min(90vh, 760px);
  display: flex;
  flex-direction: column;
  background: #efe6d6;
  border: 1px solid #8a7a62;
  border-radius: 4px;
  box-shadow: 0 24px 60px var(--shadow);
  overflow: hidden;
}

.panel--mode {
  width: min(420px, 100%);
}

.panel--dup {
  width: min(480px, 100%);
  max-height: min(92vh, 760px);
  overflow: auto;
}

.panel--dup .mode-actions {
  position: sticky;
  bottom: 0;
  background: #efe6d6;
  border-top: 1px solid var(--card-rule);
}

.mode-actions {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 1rem 1.25rem 1.25rem;
}

.mode-actions .btn {
  width: 100%;
}

.dup-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem 0.25rem;
}

.dup-compare__col {
  padding: 0.7rem 0.75rem;
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid var(--card-rule);
  border-radius: 3px;
  font-family: var(--font-card);
  font-size: 0.95rem;
  color: var(--ink);
  line-height: 1.35;
}

.dup-compare__label {
  display: block;
  margin-bottom: 0.4rem;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.dup-compare__col strong {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 700;
}

.dup-rename {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.5rem 1.25rem 0;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.dup-rename input {
  font-family: var(--font-card);
  font-size: 1.05rem;
  text-transform: none;
  letter-spacing: normal;
  padding: 0.45rem 0.55rem;
  border: 1px solid #b8aa92;
  border-radius: 2px;
  background: rgba(255, 253, 248, 0.9);
  color: var(--ink);
}

.dup-error {
  margin: 0.45rem 1.25rem 0;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  color: #b54545;
}

@media (max-width: 560px) {
  .dup-compare {
    grid-template-columns: 1fr;
  }
}

.panel-head {
  padding: 1.1rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--card-rule);
}

.panel-head h2 {
  margin: 0;
  font-family: var(--font-brand);
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--ink);
}

.panel-sub {
  margin: 0.35rem 0 0;
  font-size: 1rem;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
}

.import-preview {
  padding: 0.75rem 1.25rem;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  background: rgba(0, 0, 0, 0.04);
  border-bottom: 1px solid var(--card-rule);
}

.map-table-wrap {
  overflow: auto;
  flex: 1;
  min-height: 0;
  padding: 0.5rem 0;
}

.map-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1rem;
}

.map-table th,
.map-table td {
  padding: 0.55rem 1.1rem;
  text-align: left;
  border-bottom: 1px solid var(--card-rule);
  vertical-align: middle;
}

.map-table th {
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.map-table select {
  width: 100%;
  max-width: 220px;
  padding: 0.4rem 0.5rem;
  border: 1px solid #8a7a62;
  border-radius: 3px;
  background: #f7f2e8;
  font-family: var(--font-ui);
  font-size: 1rem;
}

.map-table .sample {
  font-family: var(--font-card);
  font-size: 0.9rem;
  color: var(--ink-soft);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  padding: 0.9rem 1.25rem;
  border-top: 1px solid var(--card-rule);
  background: rgba(255, 255, 255, 0.25);
}

.btn {
  font-family: var(--font-ui);
  font-size: 1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.5rem 1rem;
  border-radius: 3px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: filter 0.15s ease, transform 0.15s ease;
}

.btn:hover {
  filter: brightness(1.05);
}

.btn:active {
  transform: translateY(1px);
}

.btn--ghost {
  background: transparent;
  border-color: #8a7a62;
  color: var(--ink);
}

.btn--solid {
  background: linear-gradient(135deg, #ff0055, #8b1e1e);
  border-color: #ff0055;
  color: #f7f2e8;
  box-shadow:
    0 0 10px rgba(255, 0, 85, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
  text-shadow: 0 1px 2px #000;
  border-radius: 0;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
}

.btn--solid:hover {
  box-shadow:
    0 0 18px rgba(255, 0, 85, 0.65),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  filter: brightness(1.15);
}

.btn--danger {
  background: transparent;
  border-color: #ff0055;
  color: #ff4d7a;
  box-shadow: 0 0 8px rgba(255, 0, 85, 0.2);
  text-shadow: 0 0 6px rgba(255, 0, 85, 0.25);
}

.btn--danger:hover {
  background: rgba(255, 0, 85, 0.12);
  box-shadow: 0 0 14px rgba(255, 0, 85, 0.45);
  filter: brightness(1.1);
}

/* —— Ficha abierta: misma tarjeta del Rolodex en zoom —— */
.overlay--sheet {
  background: rgba(12, 10, 9, 0.52);
  backdrop-filter: blur(5px) saturate(0.85);
  -webkit-backdrop-filter: blur(5px) saturate(0.85);
  align-items: center;
  padding: 1.25rem 1rem 2rem;
}

.sheet-card {
  width: min(640px, 100%);
  max-height: min(90vh, 780px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 0 0 1.35rem;
  position: relative;
  background-color: var(--card);
  background-image:
    repeating-linear-gradient(
      transparent,
      transparent 1.45rem,
      rgba(180, 160, 130, 0.28) 1.45rem,
      rgba(180, 160, 130, 0.28) calc(1.45rem + 1px)
    ),
    linear-gradient(165deg, #fffdf8 0%, var(--card) 55%, #ebe2d0 100%);
  border: 1px solid rgba(0, 255, 204, 0.45);
  border-radius: 4px;
  box-shadow:
    0 0 28px rgba(0, 255, 204, 0.18),
    0 0 0 1px rgba(0, 255, 204, 0.08),
    0 28px 64px rgba(0, 0, 0, 0.72),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
  transform-origin: center center;
  animation: sheet-zoom-in 0.42s cubic-bezier(0.18, 0.9, 0.28, 1) both;
}

.sheet-card::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

/* Muesca metálica inferior — misma vibra que la rueda */
.sheet-card::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  z-index: 3;
  width: 52px;
  height: 14px;
  margin-left: -26px;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.4) 0%, transparent 50%),
    linear-gradient(
      90deg,
      #1a1510 0%,
      #4a4034 20%,
      #8a7a62 40%,
      #d2c3a4 50%,
      #8a7a62 60%,
      #4a4034 80%,
      #1a1510 100%
    );
  border: 1px solid #2e2820;
  border-top-color: #12100c;
  border-radius: 0 0 5px 5px;
  clip-path: polygon(8% 0, 92% 0, 100% 100%, 0 100%);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.55);
  pointer-events: none;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-shrink: 0;
  padding: 0.85rem 1.15rem 0.7rem 1.35rem;
  border-bottom: 1px solid rgba(139, 30, 30, 0.22);
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.65), transparent);
}

.sheet-num {
  font-family: var(--font-ui);
  font-size: 0.92rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.edit-badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border: 1px solid rgba(255, 0, 85, 0.5);
  border-radius: 2px;
  background: rgba(255, 0, 85, 0.12);
  color: #ff0055;
  font-family: var(--font-ui);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-shadow: 0 0 8px rgba(255, 0, 85, 0.35);
  animation: edit-badge-pulse 1.6s ease-in-out infinite;
}

@keyframes edit-badge-pulse {
  0%,
  100% {
    opacity: 1;
    box-shadow: 0 0 0 rgba(255, 0, 85, 0);
  }
  50% {
    opacity: 0.78;
    box-shadow: 0 0 10px rgba(255, 0, 85, 0.4);
  }
}

@media (prefers-reduced-motion: reduce) {
  .edit-badge {
    animation: none;
  }
}

.sheet-card--editing {
  border-color: rgba(0, 255, 204, 0.55);
  box-shadow:
    0 0 28px rgba(0, 255, 204, 0.22),
    0 0 0 1px rgba(0, 255, 204, 0.1),
    0 28px 64px rgba(0, 0, 0, 0.72),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.sheet-card--editing .sheet-head {
  border-bottom-color: rgba(0, 255, 204, 0.28);
  background: linear-gradient(180deg, rgba(0, 255, 204, 0.06), transparent);
}

.sheet-close {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 2px;
  background: transparent;
  color: var(--accent);
  font-family: var(--font-ui);
  font-size: 1.55rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.sheet-close:hover {
  color: #ff0055;
  border-color: rgba(255, 0, 85, 0.35);
  background: rgba(255, 0, 85, 0.06);
}

.sheet-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  scrollbar-width: thin;
  padding: 1.15rem 1.45rem 0.5rem;
}

.sheet-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem 1.25rem;
  margin-bottom: 0.85rem;
}

.sheet-view h3 {
  margin: 0;
  flex: 1 1 auto;
  font-family: var(--font-card);
  font-size: clamp(1.55rem, 3.2vw, 2rem);
  font-weight: 400;
  line-height: 1.2;
  color: var(--ink);
}

.sheet-view .badge {
  flex-shrink: 0;
  display: inline-block;
  margin: 0.2rem 0 0;
  padding: 0.28rem 0.55rem 0.22rem;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid rgba(139, 30, 30, 0.45);
  background: rgba(139, 30, 30, 0.06);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.sheet-rule {
  margin: 0 0 1.05rem;
  border: none;
  border-top: 1px dashed rgba(139, 30, 30, 0.32);
}

.sheet-grid {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.05rem 1.35rem;
}

.sheet-field--full {
  grid-column: 1 / -1;
}

.sheet-grid dt,
.sheet-label {
  margin: 0;
  font-family: var(--font-card);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.sheet-grid dd,
.sheet-value {
  margin: 0.28rem 0 0;
  font-family: var(--font-card);
  font-size: 1.08rem;
  line-height: 1.35;
  color: var(--ink);
  word-break: break-word;
}

.sheet-value a {
  color: inherit;
  text-decoration: none;
}

.sheet-value a:hover {
  color: #008f72;
}

.sheet-footer {
  flex-shrink: 0;
  margin-top: 0.35rem;
  padding: 0.95rem 1.25rem 0.35rem;
  border-top: 1px dashed rgba(139, 30, 30, 0.28);
  background: linear-gradient(0deg, rgba(235, 226, 208, 0.55), transparent);
}

.sheet-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.55rem;
}

.sheet-actions .sheet-key {
  flex: 1 1 auto;
  min-width: 5.5rem;
  padding: 0.55rem 0.75rem;
  border-radius: 2px;
  letter-spacing: 0.14em;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 2px 0 rgba(0, 0, 0, 0.12);
}

.sheet-actions .btn--ghost.sheet-key {
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.9), rgba(232, 222, 200, 0.85));
  border-color: #8a7a62;
  color: var(--ink);
}

.sheet-actions .btn--ghost.sheet-key:hover {
  border-color: rgba(0, 255, 204, 0.55);
  color: #006b56;
  box-shadow:
    0 0 12px rgba(0, 255, 204, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.sheet-form {
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem 1.1rem;
}

.sheet-form:not([hidden]) {
  display: grid;
}

.sheet-view[hidden],
.sheet-form[hidden] {
  display: none !important;
}

.sheet-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.sheet-form label.full,
.sheet-form .full {
  grid-column: 1 / -1;
}

.sheet-extras,
.extra-fields,
.extra-field-row {
  width: 100%;
  box-sizing: border-box;
}

.sheet-form span {
  font-family: var(--font-card);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

/* Cajetines de mecanografiado */
.sheet-form input,
.sheet-form textarea,
.sheet-form select,
.extra-field-row input {
  font-family: var(--font-card);
  font-size: 1.02rem;
  padding: 0.42rem 0.55rem;
  border: 1px solid rgba(139, 30, 30, 0.32);
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.08);
  transition:
    border-color 0.18s ease,
    background 0.18s ease,
    box-shadow 0.18s ease;
}

.sheet-form select {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  padding-right: 1.8rem;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--accent) 50%),
    linear-gradient(135deg, var(--accent) 50%, transparent 50%),
    linear-gradient(rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.55));
  background-position:
    calc(100% - 14px) calc(50% - 2px),
    calc(100% - 9px) calc(50% - 2px),
    0 0;
  background-size:
    5px 5px,
    5px 5px,
    100% 100%;
  background-repeat: no-repeat;
}

.sheet-form input:focus,
.sheet-form textarea:focus,
.sheet-form select:focus,
.extra-field-row input:focus {
  outline: none;
  background: #fff;
  border-color: #00ffcc;
  box-shadow:
    0 0 8px rgba(0, 255, 204, 0.4),
    inset 0 1px 2px rgba(0, 0, 0, 0.08);
}

.sheet-form select:focus {
  background-image:
    linear-gradient(45deg, transparent 50%, #008f72 50%),
    linear-gradient(135deg, #008f72 50%, transparent 50%),
    linear-gradient(#fff, #fff);
  background-position:
    calc(100% - 14px) calc(50% - 2px),
    calc(100% - 9px) calc(50% - 2px),
    0 0;
  background-size:
    5px 5px,
    5px 5px,
    100% 100%;
  background-repeat: no-repeat;
}

.sheet-form textarea {
  resize: vertical;
  min-height: 4.5rem;
  line-height: 1.45;
}

/* Teclas / sellos en modo edición */
.sheet-card--editing .sheet-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: stretch;
  gap: 0.55rem;
}

.sheet-card--editing .sheet-actions .sheet-key:not([hidden]) {
  flex: 1 1 6rem;
}

.sheet-card--editing .sheet-actions #sheetSave:not([hidden]) {
  flex: 1.2 1 7rem;
}

#sheetSave {
  background: linear-gradient(135deg, #ff0055, #a30036);
  border-color: #ff0055;
  color: #fffdf8;
  font-weight: 700;
  letter-spacing: 0.12em;
  box-shadow:
    0 0 12px rgba(255, 0, 85, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

#sheetSave:hover {
  filter: brightness(1.12);
  box-shadow:
    0 0 18px rgba(255, 0, 85, 0.65),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

#sheetCancelEdit {
  background: rgba(26, 22, 20, 0.05);
  border-color: rgba(26, 22, 20, 0.32);
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

#sheetCancelEdit:hover {
  background: rgba(26, 22, 20, 0.1);
  border-color: rgba(26, 22, 20, 0.45);
}

#sheetDelete {
  background: transparent;
  border: 1px dashed #ff0055;
  color: #ff0055;
  box-shadow: none;
}

#sheetDelete:hover {
  background: rgba(255, 0, 85, 0.1);
  border-style: solid;
}

.extra-fields {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.sheet-extras {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 0.35rem;
  padding-top: 0.85rem;
  border-top: 1px dashed rgba(139, 30, 30, 0.28);
}

.sheet-extras__label {
  margin: 0;
  font-family: var(--font-card);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.sheet-add-field {
  align-self: flex-start;
  padding: 0.4rem 0.75rem;
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  border-color: rgba(0, 255, 204, 0.35);
  color: #006b56;
  background: rgba(0, 255, 204, 0.06);
}

.sheet-add-field:hover {
  border-color: rgba(0, 255, 204, 0.65);
  background: rgba(0, 255, 204, 0.12);
}

.extra-field-row {
  display: grid;
  grid-template-columns: minmax(7rem, 0.9fr) minmax(8rem, 1.2fr) auto;
  gap: 0.55rem 0.65rem;
  align-items: end;
  padding: 0.55rem 0.6rem;
  border: 1px solid rgba(139, 30, 30, 0.18);
  border-radius: 2px;
  background: rgba(255, 253, 248, 0.45);
}

.extra-field-row label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}

.extra-field-row span {
  font-family: var(--font-card);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

.extra-field-row input {
  font-family: var(--font-card);
  font-size: 1.02rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid #b8aa92;
  border-radius: 2px;
  background: rgba(255, 253, 248, 0.9);
  color: var(--ink);
  width: 100%;
  box-sizing: border-box;
}

.extra-field-remove {
  width: 2rem;
  height: 2rem;
  margin-bottom: 0.05rem;
  padding: 0;
  border: 1px solid rgba(139, 30, 30, 0.35);
  border-radius: 2px;
  background: rgba(139, 30, 30, 0.06);
  color: var(--accent);
  font-family: var(--font-ui);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.extra-field-remove:hover {
  background: rgba(255, 0, 85, 0.1);
  border-color: rgba(255, 0, 85, 0.45);
  color: #ff0055;
}

body.is-modal-open,
html:has(body.is-modal-open) {
  overflow: hidden !important;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

body.is-modal-open::-webkit-scrollbar,
html:has(body.is-modal-open)::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes sheet-zoom-in {
  from {
    opacity: 0;
    transform: scale(0.72) translateY(36px);
    filter: blur(2px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
    filter: blur(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .rolodex {
    transition: none;
  }

  .import-tray {
    transition: none;
  }

  .masthead,
  .import-tray,
  .stage,
  .overlay,
  .sheet-card {
    animation: none;
  }

  .sys-status__led {
    animation: none;
  }

  body::before {
    opacity: 0.25;
  }

  .splash__logo {
    animation: none;
  }
}

@media (max-width: 560px) {
  .sheet-hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .sheet-grid,
  .sheet-form {
    grid-template-columns: 1fr;
  }

  .extra-field-row {
    grid-template-columns: 1fr auto;
  }

  .extra-field-row__key {
    grid-column: 1 / -1;
  }

  .extra-field-row__val {
    grid-column: 1;
  }

  .sheet-actions,
  .sheet-card--editing .sheet-actions {
    display: flex;
    flex-direction: column;
  }

  .sheet-actions .sheet-key {
    width: 100%;
  }
}

@media print {
  body::before,
  .splash,
  .desk,
  .mute-toggle,
  .view-toggle {
    display: none !important;
  }

  .overlay--sheet {
    position: static;
    display: block !important;
    background: none;
    backdrop-filter: none;
    padding: 0;
  }

  .overlay--sheet[hidden] {
    display: none !important;
  }

  .sheet-card {
    width: 100%;
    max-height: none;
    box-shadow: none;
    border-color: #999;
    animation: none;
  }

  .sheet-close,
  .sheet-footer {
    display: none !important;
  }

  .sheet-card::after {
    content: none !important;
    display: none !important;
  }
}
