.al-episode-panel {
  margin: 32px 0;
}

.al-episode-layout {
  --line-limit: 21rem;
  display: grid;
  grid-template-columns: clamp(9rem, 22%, 15rem) minmax(0, 1fr);
  min-height: 18rem;
  overflow: hidden;
  background: #181818;
  border: 1px solid #383337;
  border-radius: 16px;
}

.al-episode-sidebar {
  padding: 16px 0;
  min-width: 0;
  background: #202022;
  border-inline-end: 1px solid #383337;
}

.al-site .al-episode-sidebar h3,
.al-site .al-episode-line-header h3 {
  margin: 0;
  color: #eee8ed;
  font-size: 1rem;
  line-height: 1.35;
}

.al-site .al-episode-sidebar h3 {
  margin: 0 14px 12px;
  color: #b8b1b8;
  font-size: .85rem;
}

.al-line-viewport,
.al-episode-content {
  position: relative;
  min-width: 0;
}

.al-line-tabs {
  max-height: var(--line-limit);
  padding: 0 3px;
  overflow: auto;
}

.al-line-tabs,
.al-episode-scroll {
  scrollbar-width: thin;
  scrollbar-color: #776374 transparent;
  scrollbar-gutter: stable;
}

.al-line-tabs::-webkit-scrollbar,
.al-episode-scroll::-webkit-scrollbar {
  width: 7px;
}

.al-line-tabs::-webkit-scrollbar-thumb,
.al-episode-scroll::-webkit-scrollbar-thumb {
  background: #776374;
  border-radius: 8px;
}

.al-line-tabs button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  width: 100%;
  min-height: 41px;
  padding: 8px 11px;
  text-align: start;
  line-height: 1.3;
  overflow-wrap: anywhere;
  color: #d3cbd1;
  background: transparent;
  border: 0;
  border-inline-start: 3px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color .2s ease, color .2s ease;
}

.al-line-tabs button + button {
  margin-top: 3px;
}

.al-line-tabs button[aria-selected="true"] {
  color: #f5cf49;
  background: #322e2e;
  border-inline-start-color: #f5cf49;
}

.al-line-tabs button:hover {
  color: #f5cf49;
  background: #322e2e;
}

.al-line-count {
  flex: 0 0 auto;
  color: #b8afb6;
  font-size: .72rem;
  font-variant-numeric: tabular-nums;
}

.al-line-fade {
  position: absolute;
  inset: auto 7px 0 0;
  height: 43px;
  background: linear-gradient(transparent, #202022 96%);
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s ease;
}

.al-episode-layout[data-lines-faded] .al-line-fade {
  opacity: 1;
}

.al-episode-layout[data-lines-expanded] .al-line-tabs {
  max-height: none;
}

.al-line-expand {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 3px 4px;
  color: #f5cf49;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: .84rem;
}

.al-line-expand i {
  width: 7px;
  height: 7px;
  border: solid currentColor;
  border-width: 0 1px 1px 0;
  transform: translateY(-2px) rotate(45deg);
}

.al-line-expand[aria-expanded="true"] i {
  transform: translateY(2px) rotate(225deg);
}

.al-line-expand[hidden],
.al-episode-line[hidden] {
  display: none;
}

.al-episode-line {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.al-episode-line-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 16px 11px;
  border-bottom: 1px solid #383337;
}

.al-episode-sort {
  flex: none;
  padding: 4px 10px;
  border: 1px solid #73686f;
  border-radius: 8px;
  background: #242123;
  color: #eee8ed;
  font-size: .84rem;
  cursor: pointer;
}

.al-episode-sort:hover {
  color: #f5cf49;
  border-color: #b29941;
}

.al-episode-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 13px 13px 18px 16px;
}

.al-line-advice {
  margin: 0 0 12px;
  padding: 9px 11px;
  color: #ded6be;
  background: #282522;
  border-inline-start: 2px solid #b29843;
  border-radius: 3px 8px 8px 3px;
  font-size: .82rem;
  line-height: 1.5;
}

.al-site .al-line-advice a {
  margin-inline-start: 7px;
  color: #f5cf49;
  font-size: inherit;
  white-space: nowrap;
}

.al-episode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 106px), 1fr));
  gap: 8px;
}

.al-site .al-episode,
.al-episode {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2px;
  min-width: 0;
  min-height: 45px;
  padding: 7px 6px;
  border: 1px solid #423b42;
  border-radius: 8px;
  color: #ece5ea;
  background: #242123;
  text-align: center;
  font-size: .86rem;
  line-height: 1.35;
  transition: background-color .2s ease, color .2s ease;
}

.al-episode span,
.al-episode small {
  width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
}

.al-episode small {
  color: #bcb4b9;
  font-size: .7rem;
}

.al-site .al-episode:hover,
.al-site .al-episode.is-active,
.al-episode:hover,
.al-episode.is-active {
  color: #f5cf49;
  background: #322e27;
  border-color: #af9335;
}

.al-episode-layout :focus-visible {
  outline: 2px solid #f5cf49;
  outline-offset: -2px;
}

@media (max-width: 576px) {
  .al-episode-layout { grid-template-columns: minmax(90px, 34%) minmax(0, 1fr); }
  .al-line-tabs button { padding: 8px 6px; font-size: .79rem; }
  .al-episode-line-header { padding-inline: 10px; }
  .al-episode-scroll { padding-inline: 10px; }
  .al-episode-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 72px), 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .al-episode-layout * { transition: none; }
}
