:root {
  --paper: #f7f3ea;
  --ink: #221d17;
  --ink-soft: #5c5346;
  --line: #e3ddd0;
  --accent: #8a2b2b;
  --accent-soft: #c66b6b;
  --chrome: #1c1a17;
  --rail-w: 360px;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  color: var(--ink);
  background: var(--chrome);
  -webkit-font-smoothing: antialiased;
}

.app {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ---------- Left rail ---------- */
.rail {
  background: var(--chrome);
  border-right: 1px solid #000;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.rail__head {
  padding: 20px 22px 12px;
  color: #f1ece2;
}

.rail__title {
  font-size: 20px;
  letter-spacing: 0.02em;
  margin: 0;
}

.rail__sub {
  margin: 4px 0 0;
  font-size: 12.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #8d8675;
  font-family: ui-sans-serif, system-ui, sans-serif;
}

.rail__nav {
  margin: 12px 0 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 6px;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 12px;
}

.rail__navbtn {
  flex: 0 0 auto;
  text-align: left;
  padding: 6px 10px;
  border-radius: 7px;
  border: 1px solid #d8d2c6;
  background: #fff;
  color: #221d17;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.rail__navbtn:hover {
  background: #f1ece2;
  border-color: #c9c2b4;
  color: #221d17;
}

.rail__search {
  padding: 0 16px 10px;
}

.rail__search input {
  width: 100%;
  padding: 10px 12px 10px 34px;
  border-radius: 8px;
  border: 1px solid #3a3530;
  background: #26231f url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%238d8675' viewBox='0 0 24 24'%3E%3Cpath d='M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3C/svg%3E") no-repeat 10px center;
  color: #f1ece2;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.rail__search input::placeholder { color: #6f6860; }

.rail__search input:focus {
  border-color: var(--accent-soft);
  box-shadow: 0 0 0 2px rgba(138, 43, 43, 0.25);
}

.rail__search input:disabled {
  opacity: 0.55;
  cursor: wait;
}

.rail__list {
  overflow-y: auto;
  padding: 4px 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 0;
}

.rail__credit {
  flex: 0 0 auto;
  padding: 10px 16px 14px;
  border-top: 1px solid #2a2620;
  color: #8d8675;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  text-align: center;
}

.rail__credit a {
  color: var(--accent-soft);
  text-decoration: none;
}

.rail__credit a:hover { text-decoration: underline; }

.cat {
  position: relative;
  height: 96px;
  min-height: 96px;
  flex-shrink: 0;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid #000;
  outline: 0 solid transparent;
  background: transparent;
  padding: 0;
  text-align: left;
  width: 100%;
  transition: transform 0.18s ease, outline-color 0.18s ease, box-shadow 0.18s ease, opacity 0.2s ease;
  isolation: isolate;
}

.cat.is-dimmed { opacity: 0.38; pointer-events: none; }

.cat__img {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center 28%;
  transform: scale(1.02);
  filter: brightness(0.88) saturate(1);
  transition: filter 0.25s ease, transform 0.4s ease;
}

.cat__scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(8, 8, 8, 0.78) 0%, rgba(8, 8, 8, 0.3) 55%, rgba(8, 8, 8, 0.08) 100%);
}

.cat__body {
  position: relative;
  height: 100%;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  color: #fbf7ee;
}

.cat__name {
  font-size: 17px;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.55);
}

.cat__meta {
  margin-top: 2px;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #d8cfbd;
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.6);
}

.cat:hover .cat__img { filter: brightness(0.95) saturate(1.02); transform: scale(1.06); }
.cat:hover { transform: translateY(-1px); }

.cat.is-active {
  outline: 2px solid var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent) inset, 0 6px 20px rgba(0, 0, 0, 0.5);
}

.cat.is-active .cat__img { filter: brightness(1) saturate(1.05); }

.cat.is-active::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--accent-soft);
}

/* ---------- Right pane ---------- */
.pane {
  position: relative;
  background: var(--paper);
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.pane__bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center 20%;
  opacity: 0.22;
  filter: saturate(0.9);
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.pane__bgwash {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(130% 90% at 82% 4%, rgba(247, 243, 234, 0.05) 0%, rgba(247, 243, 234, 0.62) 52%, rgba(247, 243, 234, 0.92) 100%),
    linear-gradient(180deg, rgba(247, 243, 234, 0.35), rgba(247, 243, 234, 0.86));
  pointer-events: none;
}

.pane__head {
  position: relative;
  padding: 24px 34px 16px;
  border-bottom: 1px solid var(--line);
}

.crumb {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 11.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

.pane__title {
  margin: 6px 0 4px;
  font-size: 32px;
  letter-spacing: 0.01em;
}

.pane__desc {
  margin: 0;
  max-width: 60ch;
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.5;
}

.pane__stats {
  margin-top: 8px;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 12px;
  color: #8a8270;
}

.list {
  position: relative;
  overflow-y: auto;
  padding: 12px 22px 40px;
  flex: 1;
  min-height: 0;
}

.list--mass-table { padding-top: 16px; }

.row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 13px 14px;
  border-bottom: 1px solid rgba(199, 188, 168, 0.5);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease;
  text-decoration: none;
  color: inherit;
}

.row:hover { background: rgba(138, 43, 43, 0.06); }
.row.is-unavailable { cursor: default; opacity: 0.72; }
.row.is-unavailable:hover { background: transparent; }

.row__play {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  color: var(--accent);
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.5);
  transition: background 0.15s ease, color 0.15s ease;
  flex-shrink: 0;
}

.row:hover .row__play { background: var(--accent); color: #fff; }
.row.is-unavailable .row__play { border-color: #b5aa96; color: #b5aa96; }
.row.is-unavailable:hover .row__play { background: rgba(255, 255, 255, 0.5); color: #b5aa96; }

.row__play svg { width: 13px; height: 13px; transform: translateX(1px); }

.row__main { min-width: 0; }

.row__title {
  font-size: 17.5px;
  display: flex;
  align-items: center;
  gap: 9px;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #57913f;
  box-shadow: 0 0 0 3px rgba(87, 145, 63, 0.18);
  flex-shrink: 0;
}

.row__incipit {
  margin-top: 2px;
  color: var(--ink-soft);
  font-size: 13.5px;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row__meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: ui-sans-serif, system-ui, sans-serif;
  flex-shrink: 0;
}

.genre {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #8a8270;
}

.tag {
  font-size: 11.5px;
  letter-spacing: 0.06em;
  color: var(--accent);
  border: 1px solid rgba(138, 43, 43, 0.3);
  border-radius: 999px;
  padding: 3px 9px;
  background: rgba(255, 255, 255, 0.45);
  white-space: nowrap;
}

.avail {
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #57913f;
}

.empty-state {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--ink-soft);
  font-size: 15px;
}

.status {
  position: relative;
  padding: 2rem;
  text-align: center;
  color: var(--ink-soft);
}

.status.error { color: #8a2b2b; }

.list::-webkit-scrollbar,
.rail__list::-webkit-scrollbar { width: 10px; }

.list::-webkit-scrollbar-thumb { background: #cdbfa6; border-radius: 8px; }
.rail__list::-webkit-scrollbar-thumb { background: #38332d; border-radius: 8px; }

/* ---------- Mass table (filterable) ---------- */
.pane__filter {
  position: relative;
  z-index: 25;
  flex-shrink: 0;
}

.pane__filter.is-scrolled .mtoolbar {
  box-shadow: 0 10px 12px -8px rgba(44, 38, 32, 0.18);
}

.mtoolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px 18px;
  padding: 14px 34px;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: 0 10px 12px -8px rgba(44, 38, 32, 0);
  transition: box-shadow 0.18s ease;
  font-family: ui-sans-serif, system-ui, sans-serif;
}

.mtoolbar__filters {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 18px;
}

.fmeta {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 2px;
}

.fcount {
  font-size: 12.5px;
  color: #8a8270;
  white-space: nowrap;
}

/* Mass Ordinary multi-select dropdowns */
.mass-dd {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.mass-dd__label {
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #8a8270;
}

.mass-dd__wrap { position: relative; }

.mass-dd__btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 11rem;
  max-width: 20rem;
  min-height: 38px;
  font: inherit;
  font-size: 13px;
  padding: 5px 10px;
  border: 1px solid rgba(138, 43, 43, 0.3);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

.mass-dd__btn:hover { border-color: rgba(138, 43, 43, 0.55); }

.mass-dd__btn[aria-expanded="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(138, 43, 43, 0.14);
}

.mass-dd__summary {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  overflow: hidden;
}

.mass-dd__placeholder { color: #9a917f; }

.mass-dd__pill {
  display: inline-block;
  max-width: 8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(138, 43, 43, 0.1);
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
}

.mass-dd__more {
  font-size: 11.5px;
  color: #8a8270;
  white-space: nowrap;
}

.mass-dd__count {
  flex-shrink: 0;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
}

.mass-dd__caret {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  margin-left: auto;
  border-right: 1.5px solid #8a8270;
  border-bottom: 1.5px solid #8a8270;
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.16s ease;
}

.mass-dd__btn[aria-expanded="true"] .mass-dd__caret {
  transform: rotate(-135deg) translateY(-2px);
  border-color: var(--accent);
}

.mass-dd__panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 30;
  min-width: 100%;
  max-height: 17rem;
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffdf8;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.16);
}

.mass-dd__opt {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border-radius: 7px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease;
}

.mass-dd__opt:hover { background: rgba(138, 43, 43, 0.08); }
.mass-dd__opt.is-checked { background: rgba(138, 43, 43, 0.06); }

.mass-dd__opt input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mass-dd__box {
  flex-shrink: 0;
  width: 17px;
  height: 17px;
  border: 1.5px solid rgba(138, 43, 43, 0.4);
  border-radius: 5px;
  background: #fff;
  position: relative;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.mass-dd__opt.is-checked .mass-dd__box {
  background: var(--accent);
  border-color: var(--accent);
}

.mass-dd__opt.is-checked .mass-dd__box::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1.5px;
  width: 4px;
  height: 9px;
  border-right: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(45deg);
}

.mass-dd__opt-label { color: var(--ink); }

.mass-dd__clear {
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.02em;
  padding: 6px 14px;
  border: 1px solid rgba(138, 43, 43, 0.3);
  border-radius: 999px;
  background: transparent;
  color: #8a2b2b;
  cursor: pointer;
  transition: background 0.14s ease;
}

.mass-dd__clear:hover { background: rgba(138, 43, 43, 0.09); }

.mtable {
  width: 100%;
  border-collapse: collapse;
  font-family: ui-sans-serif, system-ui, sans-serif;
}

.mtable__h {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #8a8270;
  font-weight: 600;
  padding: 6px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.th-sort { cursor: pointer; user-select: none; }
.th-sort:hover { color: var(--accent); }
.th-sort.is-active { color: var(--accent); }
.mtable__h--avail { width: 56px; text-align: center; }

.sortarrow { margin-left: 5px; font-size: 9px; }

.mtable__row {
  border-bottom: 1px solid rgba(199, 188, 168, 0.5);
  cursor: pointer;
  transition: background 0.13s ease;
}

.mtable__row:hover { background: rgba(138, 43, 43, 0.06); }
.mtable__row.is-unavailable { cursor: default; opacity: 0.62; }
.mtable__row.is-unavailable:hover { background: transparent; }

.mtable td { padding: 11px 14px; vertical-align: baseline; }

.mtable__chant {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
}

.mtable__play {
  align-self: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  color: var(--accent);
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.5);
  flex-shrink: 0;
  transition: background 0.14s ease, color 0.14s ease;
}
.mtable__play svg { width: 11px; height: 11px; transform: translateX(1px); }
.mtable__row:hover .mtable__play { background: var(--accent); color: #fff; }
.mtable__row.is-unavailable .mtable__play { border-color: #b5aa96; color: #b5aa96; }
.mtable__row.is-unavailable:hover .mtable__play {
  background: rgba(255, 255, 255, 0.5);
  color: #b5aa96;
}

.mtable__title {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 16.5px;
  color: var(--ink);
  text-decoration: none;
}
.mtable__title:hover { color: var(--accent); text-decoration: underline; }

.mtable__incipit {
  color: var(--ink-soft);
  font-size: 12.5px;
  font-style: italic;
}

.mtable__cell { font-size: 13.5px; color: var(--ink); white-space: nowrap; }
.mtable__cell.is-none { color: #b0a892; }
.mtable__avail { text-align: center; }
.mtable__avail .dot { display: inline-block; }

.mtable__empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--ink-soft);
}

@media (max-width: 820px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: auto;
    min-height: 100vh;
  }

  .rail { max-height: 42vh; }
  .rail__list { flex-direction: row; overflow-x: auto; overflow-y: hidden; }
  .cat { min-width: 200px; height: 88px; min-height: 88px; flex-shrink: 0; }

  .fmeta { margin-left: 0; width: 100%; }
  .mtable__incipit { width: 100%; }
}
