/* The carry case: the tape box and a collection's sheet are
   an open cassette case (a truck-blue shell, a felt lining, tapes standing
   spine-out), and the "add" sheets (a cassette, a collection) are a ruled
   index card on the bench. Loaded after sheets.css, which it dresses: every
   rule here is scoped to .sheet--case or .sheet--card. */

:root {
  --felt: #1b2638;
  --felt-ink: #e6d8b8;
  --card: #f9f1dd;
  --spine-paper: #f4ead2;
  --spine-stripe: var(--rust);
}

/* ==== the case ================================================================== */

.sheet--case {
  padding: 0 12px 18px;
  border-radius: 22px;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0) 120px),
    radial-gradient(rgba(23, 36, 60, 0.07) 1px, transparent 1.3px) 0 0 / 3px 3px,
    var(--blue);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.45),
    inset 0 -3px 0 rgba(43, 66, 94, 0.35),
    0 24px 70px rgba(0, 0, 0, 0.7);
}

/* The lid: stitched round its edge, a paper title plate, brass hinges below. */
.sheet--case .sheet__head {
  margin: 0 -12px 12px;
  padding: 16px 18px 16px;
  border-bottom: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0.04) 60%, rgba(0, 0, 0, 0.08)),
    var(--blue);
  box-shadow: 0 3px 0 rgba(43, 66, 94, 0.45), 0 6px 10px rgba(23, 36, 60, 0.25);
  outline: 1.5px dashed rgba(23, 36, 60, 0.4);
  outline-offset: -8px;
}

.sheet--case .sheet__head::after {
  content: '';
  position: absolute;
  left: 44px;
  right: 44px;
  bottom: -7px;
  height: 9px;
  background:
    repeating-linear-gradient(90deg, var(--brass-hi) 0 2px, var(--brass) 2px 12px, var(--brass-lo) 12px 14px) left / 56px 100% no-repeat,
    repeating-linear-gradient(90deg, var(--brass-hi) 0 2px, var(--brass) 2px 12px, var(--brass-lo) 12px 14px) right / 56px 100% no-repeat;
  border-radius: 3px;
  pointer-events: none;
}

.sheet--case h2 {
  flex: 0 1 auto;
  min-width: 0;
  padding: 8px 14px 7px;
  border-radius: 3px;
  background: var(--paper);
  font-size: 25px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 2px 4px rgba(23, 36, 60, 0.35);
  transform: rotate(-0.7deg);
  overflow-wrap: anywhere;
}

.sheet--case .sheet__close {
  margin: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--cream-hi), var(--cream) 55%, var(--cream-lo));
  box-shadow: 0 3px 0 var(--cream-edge), 0 5px 8px rgba(23, 36, 60, 0.35);
  color: var(--key-ink);
  font-size: 26px;
}

.sheet--case .sheet__close:hover {
  background: radial-gradient(circle at 35% 30%, #fffaf0, var(--cream-hi) 55%, var(--cream));
}

.sheet--case .sheet__close:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--cream-edge);
}

.sheet--case .sheet__lede {
  margin: 4px 4px 14px;
  font-size: 16px;
  color: var(--ink);
}

.sheet--case :focus-visible {
  outline-color: var(--ink);
}

/* ---- the felt-lined inside ---- */

.case__tray {
  container-type: inline-size;
  margin: 0 0 4px;
  padding: 16px 10px 18px;
  border-radius: 8px;
  color: var(--felt-ink);
  background:
    radial-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1.4px) 0 0 / 4px 4px,
    linear-gradient(180deg, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0) 22px),
    var(--felt);
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.7), inset 0 0 0 1px rgba(0, 0, 0, 0.5), 0 1px 0 rgba(255, 255, 255, 0.35);
}

.case__tray:has(> .libs:empty):has(> .tapes:empty):has(> .lib__note[hidden]) {
  display: none;
}

.case__tray :focus-visible {
  outline-color: var(--focus-on-dark);
}

/* Divider tabs: a library's name on a card tab, the card's edge running across. */
.case__tray .lib__name,
.sheet--case .case__tray h3.lib__name {
  position: relative;
  flex: 0 1 auto;
  width: fit-content;
  max-width: 100%;
  margin: 22px 0 14px;
  padding: 7px 12px 5px;
  border-radius: 7px 7px 0 0;
  background: var(--cream);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--ink);
}

.case__tray .lib__name::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -4px;
  width: 100cqw;
  height: 4px;
  border-radius: 0 2px 2px 2px;
  background: inherit;
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.5);
}

.case__tray > .lib__name:first-child,
.case__tray > .libs:first-child > .lib:first-child .lib__name {
  margin-top: 0;
}

.case__tray .libs:empty + .lib__name {
  margin-top: 0;
}

/* A curator's own collection gets a brass tab. */
.case__tray .lib[data-mine] .lib__name {
  background: var(--brass-hi);
}

.case__tray .lib__head {
  align-items: flex-end;
}

.case__tray .lib__head .lib__name {
  margin-bottom: 14px;
}

@media (max-width: 480px) {
  .case__tray .lib[data-mine] .lib__name {
    flex-basis: auto;
    margin-bottom: 14px;
  }

  .case__tray .lib[data-mine] .lib__keys {
    order: -1;
    flex-basis: 100%;
    justify-content: flex-end;
  }
}

.sheet--case .case__tray .btn--plain {
  color: var(--cream);
  text-decoration-color: rgba(239, 227, 198, 0.5);
  margin-bottom: 4px;
}

.case__tray .lib__note {
  margin: 0 2px 12px;
  color: var(--felt-ink);
}

.case__tray .lib[data-status='gone'] .lib__note,
.case__tray .lib[data-status='bad'] .lib__note {
  background: var(--paper);
}

.case__tray .lib__confirm {
  background: var(--paper);
  color: #2a1f16;
}

/* Nothing on this device yet: a paper slip left in the empty case. */
.case__tray #ownEmpty {
  margin: 4px 8px 4px;
  padding: 14px 16px;
  border-radius: 3px;
  background: var(--card);
  transform: rotate(-1.5deg);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.55);
  font-family: var(--tb-hand);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  color: var(--ink);
}

/* ---- tapes standing spine-out ---- */

.sheet--case .tapes {
  gap: 9px;
  padding: 0 3px;
}

.sheet--case .tape {
  --paper: var(--spine-paper);
  --stripe: var(--spine-stripe);
  padding-left: 12px;
  border: 0;
  border-radius: 3px;
  background: var(--paper);
  color: #2a1f16;
  /* The paper spine, its colour stripe, and the clear case's edge round it. */
  box-shadow:
    inset 12px 0 0 var(--stripe),
    inset 13px 0 0 rgba(0, 0, 0, 0.18),
    0 0 0 3px rgba(255, 255, 255, 0.3),
    0 0 0 4px rgba(0, 0, 0, 0.55),
    0 6px 6px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.sheet--case .tape:nth-child(5n + 2) { --paper: #e3ead9; --stripe: var(--sage-lo); }
.sheet--case .tape:nth-child(5n + 3) { --paper: #dde6ee; --stripe: var(--blue-shade); }
.sheet--case .tape:nth-child(5n + 4) { --paper: #f1dcc4; --stripe: var(--brass-lo); }
.sheet--case .tape:nth-child(5n + 5) { --paper: #efe3c6; --stripe: var(--ink); }

.sheet--case .tape__load,
.sheet--case .tape__info {
  min-height: 58px;
  padding: 7px 10px 7px 12px;
}

.sheet--case .tape__load:hover {
  background: rgba(23, 36, 60, 0.05);
}

.sheet--case .tape__title {
  font-size: 20px;
  line-height: 1.15;
}

.sheet--case .tape__meta {
  font-family: var(--tb-label);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #55463a;
}

.sheet--case .tape__edit {
  min-width: 60px;
  padding: 0 10px;
  border-left: 1px dashed rgba(23, 36, 60, 0.35);
  background: rgba(23, 36, 60, 0.04);
  font-family: var(--tb-label);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sheet--case .tape :focus-visible {
  outline-color: var(--ink);
  outline-offset: -4px;
}

.sheet--case .tape__cover {
  width: 48px;
  height: 48px;
  border-radius: 2px;
}

.sheet--case .tape__keep {
  border-top: 1px dashed rgba(23, 36, 60, 0.3);
  padding-left: 12px;
}

.sheet--case .tape__keep[aria-checked='true'] .tape__keep-switch {
  border-color: var(--sage-lo);
  background: var(--sage-lo);
}

/* The tape that is in the player has left its slot empty. */
.sheet--case .tape[data-current] {
  padding-left: 0;
  background: rgba(0, 0, 0, 0.32);
  box-shadow: inset 0 3px 7px rgba(0, 0, 0, 0.7);
  outline: 2px dashed rgba(239, 227, 198, 0.42);
  outline-offset: -2px;
  color: var(--felt-ink);
}

.sheet--case .tape[data-current] .tape__title {
  color: var(--felt-ink);
}

.sheet--case .tape[data-current] .tape__meta,
.sheet--case .tape[data-current] .tape__keep {
  color: var(--felt-ink);
}

.sheet--case .tape[data-current] .tape__edit {
  border-left-color: rgba(239, 227, 198, 0.35);
  background: none;
  color: var(--cream);
}

.sheet--case .tape[data-current] :focus-visible {
  outline-color: var(--focus-on-dark);
}

.sheet--case .tape[data-current] .tape__load:hover,
.sheet--case .tape[data-current] .tape__edit:hover {
  background: rgba(255, 255, 255, 0.06);
}

/* ---- the keys on the case's front ---- */

.sheet--case .btn,
.sheet--card .btn {
  border: 0;
  border-radius: 10px;
  background: linear-gradient(180deg, var(--cream-hi), var(--cream) 60%, var(--cream-lo));
  box-shadow: 0 3px 0 var(--cream-edge), 0 5px 8px rgba(0, 0, 0, 0.25);
  color: var(--key-ink);
  font-family: var(--tb-label);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sheet--case .btn--primary,
.sheet--card .btn--primary {
  background: linear-gradient(180deg, var(--brass-hi), var(--brass) 60%, #a8803c);
  box-shadow: 0 3px 0 var(--brass-lo), 0 5px 8px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  color: var(--ink);
}

.sheet--case .btn--danger,
.sheet--card .btn--danger {
  background: linear-gradient(180deg, #a1482a, #7c2c16);
  box-shadow: 0 3px 0 #4f1a0b, 0 5px 8px rgba(0, 0, 0, 0.3);
  color: #fff6ea;
}

.sheet--case .btn--plain,
.sheet--card .btn--plain {
  background: none;
  box-shadow: none;
  font-family: var(--tb-body);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.sheet--case .btn:active:not(:disabled):not(.btn--plain),
.sheet--card .btn:active:not(:disabled):not(.btn--plain) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--cream-edge);
}

#libraryActions {
  position: relative;
  margin-top: 0;
  padding: 24px 2px 2px;
  justify-content: stretch;
}

/* Brass latches on the case's front edge. */
#libraryActions::before,
#libraryActions::after {
  content: '';
  position: absolute;
  top: 2px;
  width: 34px;
  height: 14px;
  border-radius: 3px 3px 7px 7px;
  background: linear-gradient(180deg, var(--brass-hi), var(--brass) 50%, var(--brass-lo));
  box-shadow: 0 2px 3px rgba(23, 36, 60, 0.45);
}

#libraryActions::before {
  left: 14px;
}

#libraryActions::after {
  right: 14px;
}

#libraryActions .btn {
  flex: 1 1 150px;
}

#libraryActions .btn--primary {
  order: -1;
  flex-basis: 100%;
  min-height: 52px;
  font-size: 18px;
  letter-spacing: 0.1em;
}

/* Make a collection, and any word about an owner code: first thing in the box. */
.curating {
  margin: 0 2px 14px;
  padding: 12px 14px 14px;
  border-radius: 10px;
  background: var(--paper);
  box-shadow: 0 2px 0 var(--cream-edge), 0 4px 8px rgba(23, 36, 60, 0.25);
  color: var(--ink);
}

.curating__note {
  margin: 6px 0 0;
  font-family: var(--tb-body);
  font-size: 14px;
}

.curating__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.curating__actions .btn {
  flex: 1 1 140px;
}

.curating__carry {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid rgba(23, 36, 60, 0.14);
}

.curating__carry .side__hint {
  margin-top: 0;
}

.sheet--case .code-form {
  border-top-color: rgba(23, 36, 60, 0.25);
}

.sheet--case .sheet__error {
  background: var(--paper);
}

.sheet--case .sheet__status {
  color: var(--ink);
}

.sheet--case .sheet__foot {
  margin: 18px -12px -18px;
  background: var(--blue);
  border-top-color: rgba(23, 36, 60, 0.25);
}

.sheet--case .field input,
.sheet--case .field select {
  background: #fffaf0;
}

/* ---- the card under the lid's strap: a link to send ---- */

.case__card {
  position: relative;
  margin: 10px 6px 18px;
  padding: 18px 14px 14px;
  border: 0;
  border-radius: 3px;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0) 0 34px, rgba(165, 103, 58, 0.22) 34px 35px, rgba(0, 0, 0, 0) 35px),
    var(--card);
  box-shadow: 0 4px 10px rgba(23, 36, 60, 0.45);
  transform: rotate(0.4deg);
  color: #2a1f16;
}

.case__card::before {
  content: '';
  position: absolute;
  top: -6px;
  left: -12px;
  right: -12px;
  height: 14px;
  background: repeating-linear-gradient(90deg, var(--ink-soft) 0 3px, #1f2c44 3px 6px);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.45);
  transform: rotate(-0.4deg);
}

.case__card .field {
  margin-top: 4px;
}

.case__card .sheet__actions {
  margin-top: 12px;
}

.case__card .btn {
  flex: 1 1 auto;
}

.case__card .btn--primary {
  background: linear-gradient(180deg, var(--ink-soft), var(--ink));
  box-shadow: 0 3px 0 #0b1322;
  color: var(--cream-hi);
}

/* ---- a collection: what is in the case, and the tapes on the bench beside it ---- */

/* One empty slot after the last tape: room for another. */
.sheet--case #collectionTapes:not(:empty)::after {
  content: 'room for another tape';
  min-height: 52px;
  display: grid;
  place-items: center;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.3);
  box-shadow: inset 0 3px 7px rgba(0, 0, 0, 0.7), inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  font-family: var(--tb-hand);
  font-size: 17px;
  font-weight: 700;
  color: rgba(230, 216, 184, 0.65);
}

.sheet--case #collectionAddTitle {
  margin: 26px 4px 4px;
  font-family: var(--tb-head);
  font-size: 19px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
}

.sheet--case #collectionAddNote {
  margin: 0 4px 12px;
  color: var(--ink);
}

.sheet--case #collectionAdd .tape {
  box-shadow:
    inset 12px 0 0 var(--stripe),
    inset 13px 0 0 rgba(0, 0, 0, 0.18),
    0 0 0 3px rgba(255, 255, 255, 0.35),
    0 0 0 4px rgba(0, 0, 0, 0.5),
    0 9px 12px rgba(23, 36, 60, 0.5);
}

.sheet--case #collectionAdd .tape:nth-child(odd) {
  transform: rotate(-0.8deg);
}

.sheet--case #collectionAdd .tape:nth-child(even) {
  transform: rotate(0.6deg);
}

/* Settings: the flap at the back of the case. */
.sheet--case .manage {
  margin-top: 22px;
  padding: 0 14px;
  border-top: 0;
  border-radius: 10px;
  background: var(--paper);
  box-shadow: 0 4px 10px rgba(23, 36, 60, 0.35);
  color: #2a1f16;
}

.sheet--case .manage .btn--plain {
  color: #6b2a18;
}

/* ==== the index card on the bench: adding a cassette, or a collection ============ */

.sheet--card {
  color: var(--cream);
  background: radial-gradient(120% 50% at 50% 0%, #3a2416 0%, var(--wood) 60%, #1a0f08 100%), var(--wood);
}

.sheet--card .sheet__head {
  margin: 0 -20px 18px;
  border-bottom: 0;
  border-radius: 0 0 14px 14px;
  background: var(--paper);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.sheet--card .sheet__head--form h2 {
  font-size: 21px;
}

.sheet--card :focus-visible {
  outline-color: var(--focus-on-dark);
}

.sheet--card .sheet__head :focus-visible,
.sheet--card .card :focus-visible,
.sheet--card .side :focus-visible {
  outline-color: #1c5fb8;
}

/* The ruled card, with its red margin line. */
.sheet--card .card {
  position: relative;
  padding: 14px 16px 18px 34px;
  border-radius: 4px;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0) 22px, rgba(165, 103, 58, 0.45) 22px 24px, rgba(0, 0, 0, 0) 24px),
    repeating-linear-gradient(180deg, rgba(0, 0, 0, 0) 0 31px, rgba(93, 122, 150, 0.18) 31px 32px) 0 12px,
    var(--card);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.5);
  color: #2a1f16;
}

.sheet--card .card .sheet__lede {
  margin: 0 0 6px;
  font-size: 16px;
  color: #2a1f16;
}

.sheet--card .card .field__name,
.sheet--card .side .field__name {
  font-family: var(--tb-label);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #4a3b2e;
}

.sheet--card .card .field__name em,
.sheet--card .side .field__name em {
  font-family: var(--tb-body);
  font-size: 14px;
  font-style: italic;
  letter-spacing: 0;
  text-transform: none;
}

/* Written on the card, not typed into boxes: a line to write on. */
.sheet--card .card .field input,
.sheet--card .card .field textarea,
.sheet--card .side .field input,
.sheet--card .side .field textarea {
  padding: 6px 2px;
  border: 0;
  border-bottom: 2px solid rgba(23, 36, 60, 0.55);
  border-radius: 0;
  background: transparent;
  font-family: var(--tb-hand);
  font-size: 21px;
  font-weight: 700;
  color: var(--ink);
}

.sheet--card .card .field input[name='title'],
.sheet--card .card .field input[name='name'] {
  font-size: 24px;
  border-bottom-color: var(--ink);
}

.sheet--card .card .field input[name='code'] {
  font-family: var(--tb-body);
  font-size: 17px;
  font-weight: 400;
}

.sheet--card .card .field input::placeholder,
.sheet--card .side .field input::placeholder {
  color: #8a7a66;
  font-weight: 400;
}

.sheet--card .card .field input[aria-invalid='true'] {
  border-bottom-color: #a23b23;
}

.sheet--card .card .side__hint {
  margin: 8px 0 0;
  font-family: var(--tb-body);
  color: #55463a;
  overflow-wrap: anywhere;
}

/* Each side: a strip of label of its own, with its letter in a circle. */
.sheet--card .side {
  margin-top: 18px;
  padding: 16px 14px 16px;
  border: 0;
  border-radius: 6px;
  background: var(--cream);
  box-shadow: inset 0 6px 0 var(--rust), 0 4px 10px rgba(0, 0, 0, 0.45);
  color: #2a1f16;
}

.sheet--card .side[data-side='B'] {
  box-shadow: inset 0 6px 0 var(--blue-shade), 0 4px 10px rgba(0, 0, 0, 0.45);
}

.sheet--card .side legend {
  float: left;
  width: 100%;
  margin: 2px 0 8px;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
}

.sheet--card .side legend + * {
  clear: both;
}

.sheet--card .side legend::before {
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: var(--cream-hi);
  font-size: 18px;
}

.sheet--card .side[data-side='A'] legend::before {
  content: 'A';
}

.sheet--card .side[data-side='B'] legend::before {
  content: 'B';
  box-sizing: border-box;
  border: 2px solid var(--ink);
  background: none;
  color: var(--ink);
}

.sheet--card .side legend em {
  font-family: var(--tb-body);
  font-size: 15px;
  font-style: italic;
}

.sheet--card .side .file__name {
  font-family: var(--tb-label);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sheet--card .file input[type='file']::file-selector-button {
  min-height: 46px;
  border: 2px dashed rgba(23, 36, 60, 0.5);
  background: rgba(255, 255, 255, 0.5);
  font: 700 15px var(--tb-label);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sheet--card .side__hint,
.sheet--card .side__current {
  font-family: var(--tb-body);
}

/* What sits on the bench, around the card. */
.sheet--card > form > .sheet__note,
.sheet--card .sheet__status {
  margin-left: 4px;
  margin-right: 4px;
  font-family: var(--tb-body);
  color: #d9c9a6;
}

.sheet--card .sheet__error {
  background: var(--paper);
}

.sheet--card .sheet__actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
  margin-top: 20px;
}

.sheet--card .sheet__actions .btn {
  min-height: 52px;
}

.sheet--card .sheet__actions .btn--primary {
  font-size: 17px;
  letter-spacing: 0.1em;
}

.sheet--card .danger {
  border-top-color: rgba(239, 227, 198, 0.3);
}

.sheet--card .danger .btn--plain {
  color: #f7efe2;
}

.sheet--card .danger__confirm p {
  color: var(--cream);
}

/* ---- the blank cassette whose label fills in ---- */

.label-preview {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  margin: 4px 0 20px;
}

/* ---- the empty case whose tab fills in ---- */

.case-preview {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  margin: 4px 0 40px;
}

.case-preview__case {
  position: relative;
  width: min(310px, 100%);
  padding: 8px 8px 22px;
  border-radius: 8px 8px 18px 18px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.18), rgba(255, 255, 255, 0.08) 30%, rgba(0, 0, 0, 0.18)), var(--blue);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.6);
  transform: rotate(-1.2deg);
}

.case-preview__tray {
  padding: 12px 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
  border-radius: 5px;
  background:
    radial-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1.4px) 0 0 / 4px 4px,
    linear-gradient(180deg, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0) 18px),
    var(--felt);
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.7);
}

.case-preview__tab {
  justify-self: start;
  max-width: 85%;
  margin-bottom: 4px;
  padding: 6px 12px 5px;
  border-radius: 7px 7px 0 0;
  background: var(--brass-hi);
  box-shadow: 0 4px 0 var(--brass-hi);
  font-family: var(--tb-label);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.case-preview__tab[data-blank] {
  color: rgba(23, 36, 60, 0.5);
}

.case-preview__tray i {
  height: 28px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.3);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.7);
}

.case-preview__tray i:first-of-type {
  margin-top: 4px;
}

/* A luggage tag hanging off the latch: the link it will have. */
.case-preview__tag {
  position: absolute;
  right: -6px;
  bottom: -24px;
  max-width: 78%;
  padding: 6px 10px 6px 18px;
  border-radius: 4px 10px 10px 4px;
  background: var(--card);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
  transform: rotate(4deg);
  font-family: var(--tb-body);
  font-size: 12px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.case-preview__tag::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 50%;
  width: 6px;
  height: 6px;
  margin-top: -3px;
  border-radius: 50%;
  background: var(--wood);
}

@media (prefers-reduced-motion: reduce) {
  .sheet--case .btn:active,
  .sheet--card .btn:active,
  .sheet--case .sheet__close:active {
    transform: none;
  }
}

/* ==== redesign: real cassettes, device keys, label-maker strips ==================
   The tape box drawer holds each tape spine-out (the 110 x 17 mm edge of a
   standard case). Tapping a spine pulls it out face up, drawn to the case's
   110 x 70 mm, with the cassette seen through the clear back. Keys are the
   transport's chunky off-white keys in a recessed bay; small actions are strips
   of embossed label-maker tape. */

/* ---- the drawer ---- */

.sheet--case .tapes:has(> .tape--case) {
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
  padding: 0;
}

.sheet--case .tape.tape--case {
  --band: linear-gradient(180deg, #b5754a, #9a5e33);
  --band-flat: #a8693e;
  display: block;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  outline: 0;
  overflow: visible;
  color: var(--felt-ink);
}

/* The colour band on each spine: rust for a shared library, brass for a
   curator's own collection, truck-blue for this device's tapes. */
.sheet--case .lib[data-mine] .tape--case {
  --band: linear-gradient(180deg, #c99a52, #9c7232);
  --band-flat: #b0843f;
}

.sheet--case #tapeList .tape--case {
  --band: linear-gradient(180deg, #5f7b97, #4b6580);
  --band-flat: #557089;
}

.sheet--case .tape.tape--case :focus-visible {
  outline: 3px solid var(--focus-on-dark);
  outline-offset: 3px;
}

.tape__spine {
  appearance: none;
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: none;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

/* The clear plastic edge, its end caps and hinge pins, and the J-card spine inside. */
.tape__case {
  position: relative;
  display: block;
  height: 47px;
  padding: 5px 15px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.38) 0, rgba(255, 255, 255, 0.1) 22%, rgba(255, 255, 255, 0.05) 70%, rgba(255, 255, 255, 0.2) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.65),
    inset 0 -1px 0 rgba(0, 0, 0, 0.35),
    0 2px 0 rgba(0, 0, 0, 0.4),
    0 5px 7px rgba(0, 0, 0, 0.4);
  transition: transform 0.18s ease;
}

.tape__case::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(100deg, transparent 18%, rgba(255, 255, 255, 0.22) 20%, transparent 27%, transparent 74%, rgba(255, 255, 255, 0.12) 76%, transparent 80%);
}

.tape__pin {
  position: absolute;
  left: 4px;
  top: 50%;
  width: 6px;
  height: 16px;
  margin-top: -8px;
  border-radius: 3px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.15));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.tape__pin--r {
  left: auto;
  right: 4px;
}

.tape__card {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 100%;
  border-radius: 2px;
  overflow: hidden;
  background: linear-gradient(180deg, #f8efda, #ecdfbf);
  box-shadow: inset 0 0 0 1px rgba(120, 90, 40, 0.15);
  color: var(--ink);
}

.tape__band {
  flex: 0 0 36px;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--band);
  box-shadow: inset -1px 0 0 rgba(0, 0, 0, 0.2);
  color: #fbf2dc;
  font-family: var(--tb-label);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.sheet--case .tape.tape--case .tape__title {
  flex: 1 1 auto;
  min-width: 0;
  padding-top: 2px;
  font-family: var(--tb-hand);
  font-size: 19px;
  font-weight: 700;
  line-height: 1.15;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  overflow-wrap: normal;
}

.tape__end {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 42%;
  display: flex;
  align-items: center;
  gap: 6px;
  padding-right: 10px;
  font-family: var(--tb-label);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  line-height: 1.1;
  text-transform: uppercase;
  color: #5a4632;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tape__end:empty {
  display: none;
}

.tape__status {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tape__lamp {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #fff4c4, #f1b84a 60%, #a86a1a);
  box-shadow: 0 0 7px 2px rgba(241, 184, 74, 0.6);
}

@media (hover: hover) {
  .tape__spine:hover .tape__case {
    transform: translateX(4px);
  }
}

/* Pulled out: its place in the stack is an empty slot. */
.tape--case[data-open] .tape__case {
  border: 1.5px dashed rgba(233, 220, 189, 0.3);
  background: rgba(0, 0, 0, 0.22);
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.45);
  transform: none;
}

.tape--case[data-open] .tape__case::after,
.tape--case[data-open] .tape__pin {
  display: none;
}

.tape--case[data-open] .tape__card {
  opacity: 0.35;
}

/* ---- pulled out: the face and its keys ---- */

.tape__out {
  container-type: inline-size;
  display: grid;
  justify-items: start;
  gap: 12px;
  padding: 14px 0 12px;
}

.tape--case[data-pulling] .tape__out {
  transform-origin: top center;
  animation: tape-pull 0.38s cubic-bezier(0.2, 0.8, 0.25, 1) both;
}

@keyframes tape-pull {
  from {
    opacity: 0;
    transform: perspective(700px) rotateX(62deg) translateY(-14px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .tape--case[data-pulling] .tape__out {
    animation: tape-fade 0.15s ease both;
  }
}

@keyframes tape-fade {
  from {
    opacity: 0;
  }
}

/* One unit (--u) is one point of the 306 x 195 drawing, so the face keeps a real
   case's proportions at any width up to 340px. */
.tape-face {
  --u: calc(min(100cqw, 340px) / 306);
  position: relative;
  flex: none;
  width: calc(306 * var(--u));
  height: calc(195 * var(--u));
  border-radius: calc(9 * var(--u));
  border: 1px solid rgba(255, 255, 255, 0.46);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.08) 40%, rgba(255, 255, 255, 0.15));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.65),
    inset 0 -2px 4px rgba(0, 0, 0, 0.3),
    0 3px 0 rgba(0, 0, 0, 0.35),
    0 16px 24px rgba(0, 0, 0, 0.55);
}

.tape-face::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 5;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(118deg, transparent 22%, rgba(255, 255, 255, 0.2) 25%, rgba(255, 255, 255, 0.04) 36%, transparent 40%, transparent 72%, rgba(255, 255, 255, 0.1) 74%, transparent 78%);
}

.tape-face__edge {
  position: absolute;
  left: calc(12 * var(--u));
  right: calc(12 * var(--u));
  top: calc(3 * var(--u));
  height: calc(5 * var(--u));
  border-radius: 2px;
  background: linear-gradient(90deg, var(--band-flat) 0 calc(36 * var(--u)), #efe3c6 0);
}

.tape-face__cassette {
  position: absolute;
  inset: calc(11 * var(--u)) calc(14 * var(--u)) calc(8 * var(--u));
  border-radius: calc(7 * var(--u));
  background: linear-gradient(180deg, #4a4038, #2e2823);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), inset 0 -2px 0 rgba(0, 0, 0, 0.45), 0 2px 4px rgba(0, 0, 0, 0.5);
}

.tape-face__screw {
  position: absolute;
  width: calc(7 * var(--u));
  height: calc(7 * var(--u));
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #9aa0a7, #3a3d42);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.5);
}

.tape-face__screw--tl { left: calc(5 * var(--u)); top: calc(5 * var(--u)); }
.tape-face__screw--tr { right: calc(5 * var(--u)); top: calc(5 * var(--u)); }
.tape-face__screw--bl { left: calc(5 * var(--u)); bottom: calc(5 * var(--u)); }
.tape-face__screw--br { right: calc(5 * var(--u)); bottom: calc(5 * var(--u)); }

.tape-face__label {
  position: absolute;
  left: calc(12 * var(--u));
  right: calc(12 * var(--u));
  top: calc(9 * var(--u));
  height: calc(116 * var(--u));
  border-radius: calc(4 * var(--u));
  background:
    radial-gradient(circle at 86% 18%, rgba(150, 110, 50, 0.14), transparent 30%),
    radial-gradient(circle at 10% 90%, rgba(150, 110, 50, 0.12), transparent 26%),
    linear-gradient(180deg, #f8efda, #ecdfbf);
  box-shadow: inset 0 0 0 1px rgba(120, 90, 40, 0.15);
}

.tape-face__side {
  position: absolute;
  left: calc(9 * var(--u));
  top: calc(6 * var(--u));
  font-family: var(--tb-head);
  font-size: calc(22 * var(--u));
  font-weight: 800;
  line-height: 1;
  color: var(--ink);
}

.tape-face__title,
.tape-face__jtitle {
  position: absolute;
  left: calc(34 * var(--u));
  right: calc(30 * var(--u));
  top: calc(6 * var(--u));
  font-family: var(--tb-hand);
  font-size: calc(21 * var(--u));
  font-weight: 700;
  line-height: 1.1;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tape-face__heart {
  position: absolute;
  right: calc(9 * var(--u));
  top: calc(10 * var(--u));
  width: calc(17 * var(--u));
  height: calc(15 * var(--u));
  fill: none;
  stroke: #c0463a;
  stroke-width: 1.7;
  stroke-linejoin: round;
}

.tape-face__rule {
  position: absolute;
  left: calc(8 * var(--u));
  right: calc(8 * var(--u));
  top: calc(34 * var(--u));
  height: max(1.5px, calc(2 * var(--u)));
  border-radius: 1px;
  background: #c0463a;
  opacity: 0.9;
}

.tape-face__window {
  position: absolute;
  left: calc(39 * var(--u));
  top: calc(43 * var(--u));
  width: calc(176 * var(--u));
  height: calc(50 * var(--u));
  border-radius: calc(25 * var(--u));
  overflow: hidden;
  background: #120f0d;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.85), 0 0 0 calc(2 * var(--u)) rgba(90, 70, 45, 0.35);
}

/* The tape pack: all on the left reel, as a side waits to be played. */
.tape-face__pack {
  position: absolute;
  left: calc(-9 * var(--u));
  top: calc(-14 * var(--u));
  width: calc(78 * var(--u));
  height: calc(78 * var(--u));
  border-radius: 50%;
  background: repeating-radial-gradient(circle, #5c3b22 0 1px, #6d472a 1px 2.6px);
}

.tape-face__pack--r {
  left: calc(120 * var(--u));
  top: calc(-1 * var(--u));
  width: calc(52 * var(--u));
  height: calc(52 * var(--u));
}

.tape-face__hub {
  position: absolute;
  left: calc(15 * var(--u));
  top: calc(10 * var(--u));
  width: calc(30 * var(--u));
  height: calc(30 * var(--u));
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #fbf5e6, #d4c7aa);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
}

.tape-face__hub--r {
  left: calc(131 * var(--u));
}

.tape-face__hub::after {
  content: '';
  position: absolute;
  inset: calc(7 * var(--u));
  border-radius: 50%;
  background:
    radial-gradient(circle, #120f0d 0 calc(4 * var(--u)), transparent calc(4.5 * var(--u))),
    repeating-conic-gradient(#120f0d 0 32deg, #c9bc9f 32deg 60deg);
}

.tape-face__glass {
  position: absolute;
  inset: 0;
  background: linear-gradient(172deg, rgba(255, 255, 255, 0.2), transparent 45%);
}

.tape-face__foot {
  position: absolute;
  left: calc(10 * var(--u));
  right: calc(10 * var(--u));
  bottom: calc(6 * var(--u));
  display: flex;
  justify-content: space-between;
  gap: calc(8 * var(--u));
  font-family: var(--tb-label);
  font-size: calc(11 * var(--u));
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #5a4632;
  white-space: nowrap;
  overflow: hidden;
}

.tape-face__trap {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: calc(196 * var(--u));
  height: calc(40 * var(--u));
  margin-left: calc(-98 * var(--u));
  background: linear-gradient(180deg, #463c34, #28221d);
  clip-path: polygon(9% 0, 91% 0, 100% 100%, 0 100%);
}

.tape-face__hole {
  position: absolute;
  left: calc(34 * var(--u));
  top: calc(15 * var(--u));
  width: calc(10 * var(--u));
  height: calc(10 * var(--u));
  border-radius: 50%;
  background: #0d0b09;
}

.tape-face__hole--r {
  left: auto;
  right: calc(34 * var(--u));
}

/* In the player: the empty case, its J-card's side list, the two clear posts. */
.tape-face__jcard {
  position: absolute;
  inset: calc(11 * var(--u)) calc(14 * var(--u)) calc(8 * var(--u));
  border-radius: calc(5 * var(--u));
  background:
    radial-gradient(circle at 80% 85%, rgba(150, 110, 50, 0.12), transparent 30%),
    linear-gradient(180deg, #f6ecd4, #eadcb9);
  box-shadow: inset 0 0 0 1px rgba(120, 90, 40, 0.18);
}

.tape-face__jtitle {
  left: calc(14 * var(--u));
  right: calc(14 * var(--u));
  top: calc(7 * var(--u));
  font-size: calc(20 * var(--u));
}

.tape-face__jcard .tape-face__rule {
  left: calc(12 * var(--u));
  right: calc(12 * var(--u));
}

.tape-face__post {
  position: absolute;
  left: calc(66 * var(--u));
  top: calc(63 * var(--u));
  width: calc(30 * var(--u));
  height: calc(30 * var(--u));
  border-radius: 50%;
  background:
    repeating-conic-gradient(rgba(40, 60, 90, 0.35) 0 14deg, transparent 14deg 60deg),
    radial-gradient(circle, rgba(255, 255, 255, 0.6) 0 calc(5 * var(--u)), rgba(255, 255, 255, 0.25) calc(6 * var(--u)));
  box-shadow: inset 0 0 0 calc(2 * var(--u)) rgba(40, 60, 90, 0.35), 0 2px 3px rgba(0, 0, 0, 0.25);
}

.tape-face__post--r {
  left: calc(182 * var(--u));
}

.tape-face__ledger {
  position: absolute;
  left: calc(14 * var(--u));
  right: calc(14 * var(--u));
  bottom: calc(9 * var(--u));
}

.tape-face__line {
  display: flex;
  align-items: center;
  gap: calc(7 * var(--u));
  font-family: var(--tb-label);
  font-size: calc(13 * var(--u));
  font-weight: 500;
  line-height: 1.6;
  color: var(--ink-soft);
  white-space: nowrap;
}

.tape-face__line > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tape-face__leader {
  flex: 1;
  min-width: calc(10 * var(--u));
  border-bottom: 1.5px dotted rgba(43, 59, 88, 0.45);
  transform: translateY(calc(-3 * var(--u)));
}

.tape__about {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.sheet--case .tape--case .tape__meta {
  margin: 0;
  font-family: var(--tb-label);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #c9bb9c;
}

.sheet--case .tape--case .tape__cover {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 3px;
}

.tape__keys {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  width: 100%;
}

/* "Put in player": green, like the player's PLAY key. */
.sheet--case .tape--case .tape__load {
  flex: 1 1 100%;
  min-height: 54px;
  margin-bottom: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 16px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(180deg, #b3c4a7 0%, #97ab8b 55%, #86997a 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.45),
    inset 0 -4px 0 rgba(0, 0, 0, 0.1),
    0 5px 0 #5f7056,
    0 8px 10px rgba(0, 0, 0, 0.35);
  color: #1f2a1b;
  font-family: var(--tb-label);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.sheet--case .tape.tape--case .tape__load:hover {
  background: linear-gradient(180deg, #bccdb0 0%, #a0b494 55%, #8fa283 100%);
}

.sheet--case .tape--case .tape__load:active {
  transform: translateY(4px);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.35), 0 1px 0 #5f7056, 0 2px 3px rgba(0, 0, 0, 0.3);
}

.tape__icon {
  flex: none;
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linejoin: round;
}

.tape__icon[data-fill] {
  width: 15px;
  height: 17px;
  fill: currentColor;
  stroke: none;
}

/* "Keep on this device": a small brass slide, kin to the SOUND EFFECTS switch. */
.sheet--case .tape--case .tape__keep {
  gap: 12px;
  min-height: 44px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--felt-ink);
  font-family: var(--tb-label);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.sheet--case .tape--case .tape__keep:hover:not([data-busy]) {
  background: none;
  color: #fff3d6;
}

.sheet--case .tape--case .tape__keep .tape__keep-switch,
.sheet--case .tape--case .tape__keep[aria-checked='true'] .tape__keep-switch {
  width: 46px;
  height: 22px;
  border: 0;
  border-radius: 11px;
  background: linear-gradient(180deg, #0c1322, #1d2a40);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.7), 0 0 0 2px var(--brass), 0 0 0 3px rgba(0, 0, 0, 0.4);
}

.sheet--case .tape--case .tape__keep .tape__keep-switch::after {
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: radial-gradient(circle at 35% 30%, #fff1c4, #d1a457 55%, #7b5624);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.6);
}

.sheet--case .tape--case .tape__keep[aria-checked='true'] .tape__keep-switch::after {
  background: radial-gradient(circle at 35% 30%, #fff1c4, #d1a457 55%, #7b5624);
  transform: translateX(24px);
}

.sheet--case .tape--case .tape__keep[aria-checked='true'] {
  color: var(--brass-hi);
}

.sheet--case .tape--case .tape__keep-note {
  padding: 0 4px;
  color: #f3c0ad;
}

/* ---- label-maker tape: the small actions ----
   Embossed letters on a strip of red tape, cut at a slant. The strip is drawn by
   ::before so the key itself stays a full 44px to tap. */

.sheet--case .tape.tape--case .tape__edit,
.sheet--case .tape.tape--case .tape__collect,
.sheet--case .tape.tape--case .tape__back,
.sheet--case .case__tray .btn--plain,
.sheet--case .manage .btn--plain,
.sheet--card .btn--plain,
.sheet--card .sheet__cancel {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  min-width: 0;
  margin: 0;
  padding: 0 13px 0 12px;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: #f7efe2;
  font-family: var(--tb-label);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.16em;
  line-height: 1.1;
  text-transform: uppercase;
  text-decoration: none;
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.4), 0 1px 0 rgba(255, 255, 255, 0.2);
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.45));
  transform: rotate(-1deg);
}

.sheet--case .tape.tape--case .tape__edit::before,
.sheet--case .tape.tape--case .tape__collect::before,
.sheet--case .tape.tape--case .tape__back::before,
.sheet--case .case__tray .btn--plain::before,
.sheet--case .manage .btn--plain::before,
.sheet--card .btn--plain::before,
.sheet--card .sheet__cancel::before {
  content: '';
  position: absolute;
  inset: 7px 0;
  z-index: -1;
  background: linear-gradient(180deg, #9b3529, #7e271e);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), inset 0 -1px 0 rgba(0, 0, 0, 0.25);
  clip-path: polygon(0 10%, 4px 0, 100% 0, calc(100% - 2px) 50%, 100% 100%, 3px 100%, 0 88%);
}

.sheet--case .tape.tape--case .tape__back,
.sheet--case .case__tray .btn--plain:nth-child(even),
.sheet--card .btn--plain:nth-child(even) {
  transform: rotate(1deg);
}

.sheet--case .tape.tape--case .tape__edit:hover::before,
.sheet--case .tape.tape--case .tape__collect:hover::before,
.sheet--case .tape.tape--case .tape__back:hover::before,
.sheet--case .case__tray .btn--plain:hover:not(:disabled)::before,
.sheet--case .manage .btn--plain:hover:not(:disabled)::before,
.sheet--card .btn--plain:hover:not(:disabled)::before,
.sheet--card .sheet__cancel:hover::before {
  background: linear-gradient(180deg, #ac3c2f, #8a2c22);
}

.sheet--case .tape.tape--case .tape__edit:active,
.sheet--case .tape.tape--case .tape__collect:active,
.sheet--case .tape.tape--case .tape__back:active,
.sheet--case .case__tray .btn--plain:active:not(:disabled),
.sheet--case .manage .btn--plain:active:not(:disabled),
.sheet--card .btn--plain:active:not(:disabled),
.sheet--card .sheet__cancel:active {
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.45));
  translate: 0 1px;
}

.sheet--case .case__tray .btn--plain:disabled,
.sheet--card .btn--plain:disabled {
  opacity: 0.45;
}

.sheet--case .case__tray .lib__add::after {
  content: '+';
  order: -1;
  font-size: 16px;
  letter-spacing: 0;
}

.sheet--case .case__tray .lib__keys {
  gap: 4px 12px;
}

/* ---- keys: the transport's chunky off-white keys ---- */

.sheet--case .btn:not(.btn--plain):not(.btn--primary):not(.btn--danger),
.sheet--card .btn:not(.btn--plain):not(.btn--primary):not(.btn--danger) {
  background: linear-gradient(180deg, #fbf4e2 0%, var(--cream) 55%, #e2d1aa 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.8),
    inset 0 -4px 0 rgba(120, 90, 40, 0.12),
    0 5px 0 var(--cream-edge),
    0 8px 10px rgba(0, 0, 0, 0.3);
}

.sheet--case .btn:not(.btn--plain):active:not(:disabled),
.sheet--card .btn:not(.btn--plain):active:not(:disabled) {
  transform: translateY(4px);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.6), 0 1px 0 var(--cream-edge), 0 2px 3px rgba(0, 0, 0, 0.3);
}

/* A key with its icon above a one-line legend. */
.sheet--case .btn--key {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 70px;
  padding: 9px 8px 10px;
  font-size: 13px;
  letter-spacing: 0.12em;
  line-height: 1.15;
  text-align: center;
}

.key__icon {
  flex: none;
  width: 30px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* The bay the keys sit down in, as on the player. */
.curating__actions,
#libraryActions {
  border-radius: 16px;
  background: linear-gradient(180deg, #728ca6, #8aa4bc);
  box-shadow: inset 0 4px 9px rgba(0, 0, 0, 0.45), inset 0 -1px 0 rgba(255, 255, 255, 0.35), 0 1px 0 rgba(255, 255, 255, 0.4);
}

.curating__actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin: 0;
  padding: 10px 10px 16px;
}

#libraryActions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px 10px;
  margin: 30px 0 0;
  padding: 12px 12px 18px;
}

#libraryActions::before,
#libraryActions::after {
  top: -20px;
}

#libraryActions .btn {
  flex: none;
}

/* On the case's front the smaller keys lie flat: icon, then a one-line legend. */
.sheet--case #libraryActions .btn--key {
  flex-direction: row;
  gap: 12px;
  min-height: 54px;
  padding: 0 14px;
}

.curating__actions .btn--key {
  letter-spacing: 0.08em;
}

/* "Add a cassette": the wide key across the top of the bay. */
.sheet--case #libraryActions .btn--primary {
  grid-column: 1 / -1;
  order: -1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 58px;
  border-radius: 12px;
  background: linear-gradient(180deg, #fbf4e2 0%, var(--cream) 55%, #e2d1aa 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.8),
    inset 0 -4px 0 rgba(120, 90, 40, 0.12),
    0 5px 0 var(--cream-edge),
    0 8px 10px rgba(0, 0, 0, 0.3);
  color: var(--key-ink);
  font-size: 18px;
  letter-spacing: 0.16em;
}

.sheet--case #libraryActions .btn--primary .key__icon {
  width: 32px;
  height: 21px;
}

/* A device with nothing on it: the bay holds just two choices, each a wide key,
   the code someone was sent first. */
.sheet--case[data-first-run] #libraryActions .btn--key {
  grid-column: 1 / -1;
  order: -2;
  justify-content: center;
  min-height: 58px;
  font-size: 18px;
}

/* ---- Make a collection: a bay of keys at the top of the box ---- */

.curating {
  display: grid;
  gap: 12px;
  margin: 0 2px 16px;
  padding: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
}

.curating .curating__note {
  margin: 0 4px;
}

.curating .curating__carry {
  margin-top: 0;
}

/* ---- under a pulled-out tape: Label, Add to collection, Put back ---- */

.tape__strips > button {
  white-space: nowrap;
}

.tape__strips {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
}

.sheet--case .tape.tape--case .tape__collect {
  transform: rotate(-0.4deg);
}

/* Three strips across a phone-width drawer: set a little tighter. */
@container (max-width: 360px) {
  .sheet--case .tape.tape--case .tape__strips > button {
    gap: 4px;
    padding: 0 8px 0 7px;
    font-size: 12px;
    letter-spacing: 0.06em;
  }

  .tape__strips .tape__icon {
    width: 12px;
    height: 12px;
  }
}

/* "Add it to which collection?": one key per collection. */
.tape__choose {
  width: 100%;
  padding: 10px 12px 14px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.25);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.5);
}

.tape__choose-q {
  margin: 0 0 10px;
  font-family: var(--tb-label);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--brass-hi);
}

.tape__choose-list {
  display: grid;
  gap: 12px;
}

.sheet--case .tape--case .tape__choose-pick {
  min-height: 46px;
  padding: 6px 14px;
  font-size: 15px;
  letter-spacing: 0.1em;
  overflow-wrap: anywhere;
}

/* The tape sent here by "Add to collection", marked in the collection's list. */
.sheet--case #collectionAdd .tape[data-picked] {
  outline: 3px solid var(--brass-hi);
  outline-offset: 3px;
}

/* ==== a collection's sheet: its tapes as spines, as in the tape box ===========
   Each tape is the spine of its case; below it, its side lengths, any note,
   and its keys (Add, Update, Remove) as label strips. */

.sheet--case #collectionTapes,
.sheet--case #collectionAdd {
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  padding: 0;
}

.sheet--case #collectionAdd .tape.tape--case {
  box-shadow: none;
  transform: none;
}

.tape__below {
  display: grid;
  gap: 4px;
  padding: 8px 2px 0;
}

.sheet--case #collectionAdd .tape--listed .tape__meta {
  color: var(--ink-soft);
}

.sheet--case .tape--listed .tape__why {
  margin: 2px 0 0;
  padding: 0;
  border: 0;
  background: none;
  font-family: var(--tb-body);
  font-size: 15px;
  line-height: 1.4;
  color: #f3c0ad;
}

.sheet--case #collectionAdd .tape--listed .tape__why {
  color: #6b2a18;
}

.sheet--case .tape--listed .tape__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px 12px;
  padding: 0;
  border: 0;
}

.sheet--case .tape--listed .tape__actions:empty {
  display: none;
}

/* "Yes, remove": black tape, so it is not mistaken for the others. */
.sheet--case .tape.tape--case .tape__edit--danger {
  color: #f7efe2;
}

.sheet--case .tape.tape--case .tape__edit--danger::before,
.sheet--case .tape.tape--case .tape__edit--danger:hover::before {
  background: linear-gradient(180deg, #34302d, #151312);
}

/* The empty slot at the end of the collection's row of spines. */
.sheet--case #collectionTapes:not(:empty)::after {
  min-height: 47px;
  border-radius: 4px;
  border: 1.5px dashed rgba(233, 220, 189, 0.3);
  background: rgba(0, 0, 0, 0.22);
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.45);
}

/* Bands as in the tape box: brass for the curator's collection, truck-blue for this device's tapes. */
.sheet--case #collectionTapes .tape--case {
  --band: linear-gradient(180deg, #c99a52, #9c7232);
  --band-flat: #b0843f;
}

.sheet--case #collectionAdd .tape--case {
  --band: linear-gradient(180deg, #5f7b97, #4b6580);
  --band-flat: #557089;
}

/* ==== the cassette form: a real cassette, keys and label strips ===============
   The blank cassette above the form is the tape box's cassette, drawn to its
   real 100 x 64 mm, bare of its case; its label fills in as it is written.
   The file pickers are off-white keys; Cancel in the head is a label strip. */

.label-preview {
  container-type: inline-size;
  margin: 6px 0 24px;
}

.tape-face--bare {
  --u: calc(min(100cqw, 320px) / 278);
  width: calc(278 * var(--u));
  height: calc(176 * var(--u));
  border: 0;
  border-radius: calc(7 * var(--u));
  background: none;
  box-shadow: 0 14px 22px rgba(0, 0, 0, 0.6);
  transform: rotate(-1.5deg);
}

.tape-face--bare .tape-face__cassette {
  inset: 0;
}

.tape-face__title[data-blank] {
  color: rgba(23, 36, 60, 0.4);
}

/* The keys a recording is chosen with. */
.sheet--card .file input[type='file']::file-selector-button {
  min-height: 46px;
  margin: 0 12px 6px 0;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(180deg, #fbf4e2 0%, var(--cream) 55%, #e2d1aa 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.8),
    inset 0 -3px 0 rgba(120, 90, 40, 0.12),
    0 4px 0 var(--cream-edge),
    0 6px 8px rgba(0, 0, 0, 0.25);
  color: var(--key-ink);
  font: 700 15px var(--font-label);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.sheet--card .file--add {
  min-height: 52px;
  margin: 6px 0 16px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(180deg, #fbf4e2 0%, var(--cream) 55%, #e2d1aa 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.8),
    inset 0 -4px 0 rgba(120, 90, 40, 0.12),
    0 5px 0 var(--cream-edge),
    0 8px 10px rgba(0, 0, 0, 0.25);
}

.sheet--card .file--add:hover {
  border-style: none;
  background: linear-gradient(180deg, #fffaf0 0%, var(--cream-hi) 55%, var(--cream) 100%);
}

.sheet--card .file--add:active {
  translate: 0 4px;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.6), 0 1px 0 var(--cream-edge), 0 2px 3px rgba(0, 0, 0, 0.25);
}

.sheet--card .side .file--add .file__name {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 2px 8px;
  padding: 10px 14px;
  color: var(--key-ink);
  font-size: 15px;
  letter-spacing: 0.1em;
}

.sheet--card .file--add .file__name em {
  font-family: var(--font-read);
  font-size: 14px;
  font-style: italic;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: #6b5a44;
}
