:root {
  --bg: #101010;
  --surface: #141715;
  --surface-2: #181b19;
  --surface-hover: #1d211e;
  --text: #f1f1f1;
  --text-strong: #f2f2f2;
  --muted: #f7f7f7;
  --muted-2: #f8f8f8;
  --border: #909090;
  --border-strong: #808080;
  --focus: #817567;
  --selection-bg: #5a5044;
  --selection-text: #f0e6d6;
  --page-max: 980px;
  --player-height: 64px;
}

* {
  box-sizing: border-box;
  border-radius: 0 !important;
}

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

html {
  background: var(--bg);
}

body {
  min-height: 100vh;
  font-family: "Courier New", Courier, monospace;
  font-size: 13px;
  line-height: 1.15;
  color: var(--text);
  background: var(--bg);
  text-rendering: optimizeLegibility;
}

button,
input,
audio {
  font-family: inherit;
}

button {
  cursor: pointer;
}

::selection {
  background: var(--selection-bg);
  color: var(--selection-text);
}

.page {
  width: min(var(--page-max), calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 calc(var(--player-height) + 56px);
}

.search-form {
  margin-bottom: 10px;
}

.search-input {
  width: 100%;
  height: 36px;
  padding: 6px 8px;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-strong);
  font-size: 13px;
  outline: none;
  appearance: none;
}

.search-input::placeholder {
  color: var(--muted-2);
}

.search-input:focus {
  border-color: var(--focus);
  outline: 1px solid var(--focus);
  outline-offset: 2px;
}

.search-input::-webkit-search-decoration,
.search-input::-webkit-search-cancel-button {
  appearance: none;
}

.status {
  min-height: 24px;
  color: var(--muted);
  display: flex;
  align-items: center;
}

.view-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  justify-content: flex-start;
  align-items: center;
}

.tab-button {
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.tab-button.active {
  background: var(--surface-2);
  color: var(--text-strong);
}

.tab-button:focus-visible {
  outline: 1px solid var(--focus);
  outline-offset: 2px;
}

.results-section {
  width: 100%;
  max-height: min(77vh, 720px);
  overflow-y: auto;
  overflow-x: auto;
  border-top: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.results-section::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.results-section::-webkit-scrollbar-track {
  background: transparent;
}

.results-section::-webkit-scrollbar-thumb {
  background: var(--border-strong);
}

.results-table {
  width: 100%;
  min-width: 840px;
  border-collapse: collapse;
  border: none;
  table-layout: fixed;
}

.results-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg);
}

.results-table th,
.results-table td {
  border: none;
  padding: 7px 8px;
  vertical-align: top;
  text-align: left;
}

.results-table th {
  font-weight: 400;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.results-table td {
  color: var(--text);
  border-bottom: 1px solid rgba(58, 51, 43, 0.45);
}

.results-table tr:last-child td {
  border-bottom: none;
}

.results-table tr:hover td {
  background: var(--surface-hover);
}

.results-table th.col-index,
.results-table td.col-index {
  width: 42px;
  min-width: 42px;
  max-width: 42px;
  color: var(--muted-2);
}

.results-table th.col-title,
.results-table td.col-title {
  width: auto;
}

.results-table th.col-channel,
.results-table td.col-channel {
  width: 180px;
}

.results-table th.col-duration,
.results-table td.col-duration {
  width: 82px;
}

.results-table th.col-meta,
.results-table td.col-meta {
  width: 116px;
}

.results-table th.col-play,
.results-table td.col-play {
  width: 54px;
  min-width: 54px;
  max-width: 54px;
  text-align: center;
}

.results-table th.col-fav,
.results-table td.col-fav {
  width: 34px;
  min-width: 34px;
  max-width: 34px;
  padding-left: 0;
  padding-right: 4px;
  text-align: center;
  overflow: hidden;
}

.results-table th.col-playlist,
.results-table td.col-playlist {
  width: 72px;
  min-width: 72px;
  max-width: 72px;
  padding-left: 2px;
  padding-right: 2px;
  text-align: center;
  white-space: nowrap;
}

.results-table td.col-title,
.results-table td.col-channel {
  overflow: hidden;
}

.empty {
  color: var(--muted);
  padding: 16px 8px !important;
}

.link-button {
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  line-height: 1.15;
  text-decoration: underline;
  text-decoration-color: #6e6458;
  text-underline-offset: 2px;
  cursor: pointer;
}

.link-button:hover {
  color: var(--selection-text);
  text-decoration-color: #a89a88;
}

.link-button:focus-visible {
  outline: 1px solid var(--focus);
  outline-offset: 2px;
}

.title-button {
  max-width: 100%;
  text-align: left;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  display: inline-block;
  vertical-align: top;
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.badge {
  display: inline-block;
  padding: 2px 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text-strong);
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
}

.badge.live {
  border-color: #b15f5f;
  color: #ffd0d0;
  background: #2a1717;
}

.muted {
  color: var(--muted);
}

.star-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.star-button.favorited {
  color: #ffd86b;
}

.playlist-action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 20px;
  padding: 0 3px;
  margin: 0 1px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
}

.playlist-action-button:hover {
  color: var(--selection-text);
  background: var(--surface-2);
}

.playlist-action-button:focus-visible {
  outline: 1px solid var(--focus);
  outline-offset: 1px;
}

.create-playlist-button,
.playlist-rename-button,
.copy-share-button {
  white-space: nowrap;
}

.player {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  min-height: var(--player-height);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  gap: 16px;
  align-items: center;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.player.hidden {
  display: none;
}

.now-playing {
  min-width: 0;
}

#playerTitle {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--text-strong);
}

#playerMeta {
  margin-top: 3px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

audio {
  width: 100%;
  height: 34px;
  filter: sepia(0.32) contrast(0.86) brightness(0.82);
}

.scroll-sentinel {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 10px 8px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: transparent;
}

.scroll-sentinel::before {
  content: "> ";
  color: var(--muted-2);
}

.scroll-sentinel:empty {
  display: none;
}

.scroll-sentinel.loading::after,
tr.loading-row td::after {
  content: "";
  display: inline-block;
  width: 1ch;
  animation: loading-dots 1s steps(4, end) infinite;
}

tr.loading-row td {
  color: var(--muted);
}

tr.loading-row td::before {
  content: "> ";
  color: var(--muted-2);
}

@keyframes loading-dots {
  0% {
    content: "";
  }

  25% {
    content: ".";
  }

  50% {
    content: "..";
  }

  75%,
  100% {
    content: "...";
  }
}

@media (max-width: 900px) {
  :root {
    --page-max: 100%;
  }

  .page {
    width: calc(100% - 24px);
    padding-top: 24px;
  }

  .results-table td:nth-child(3),
  .results-table th:nth-child(3) {
    width: 145px;
  }

  .player {
    grid-template-columns: minmax(0, 1fr) minmax(240px, 360px);
  }
}

@media (max-width: 700px) {
  :root {
    --player-height: 104px;
  }

  body {
    font-size: 13px;
  }

  .page {
    width: calc(100% - 20px);
    padding-top: 18px;
    padding-bottom: calc(var(--player-height) + 36px);
  }

  .view-tabs {
    margin-bottom: 10px;
    gap: 6px;
  }

  .tab-button {
    padding: 6px 8px;
  }

  .search-input {
    height: 38px;
    font-size: 16px;
  }

  .status {
    min-height: 22px;
  }

  .results-section {
    max-height: 58vh;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .results-table {
    min-width: 0;
    table-layout: fixed;
  }

  .results-table th,
  .results-table td {
    padding: 7px 4px;
  }

  .results-table td:nth-child(3),
  .results-table th:nth-child(3) {
    display: none;
  }

  .results-table td:nth-child(5),
  .results-table th:nth-child(5) {
    display: none;
  }

  .results-table th.col-index,
  .results-table td.col-index {
    width: 30px;
    min-width: 30px;
    max-width: 30px;
  }

  .results-table th.col-duration,
  .results-table td.col-duration {
    width: 60px;
    min-width: 60px;
    max-width: 60px;
  }

  .results-table th.col-play,
  .results-table td.col-play {
    width: 46px;
    min-width: 46px;
    max-width: 46px;
  }

  .results-table th.col-fav,
  .results-table td.col-fav {
    width: 28px;
    min-width: 28px;
    max-width: 28px;
    padding-left: 0;
    padding-right: 2px;
  }

  .results-table th.col-playlist,
  .results-table td.col-playlist {
    width: 54px;
    min-width: 54px;
    max-width: 54px;
    padding-left: 0;
    padding-right: 0;
  }

  .playlist-action-button {
    min-width: 15px;
    height: 20px;
    padding: 0 1px;
    margin: 0;
    font-size: 13px;
  }

  .title-button {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .player {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px;
    min-height: var(--player-height);
  }

  audio {
    height: 32px;
  }

  .scroll-sentinel {
    min-height: 46px;
    padding: 12px 4px;
  }
}

@media (max-width: 420px) {
  .page {
    width: calc(100% - 16px);
  }

  .results-table th,
  .results-table td {
    padding-left: 3px;
    padding-right: 3px;
  }

  .results-table td:first-child,
  .results-table th:first-child {
    width: 24px;
    min-width: 24px;
    max-width: 24px;
  }

  .results-table td:nth-child(4),
  .results-table th:nth-child(4) {
    width: 52px;
    min-width: 52px;
    max-width: 52px;
  }

  .results-table th.col-play,
  .results-table td.col-play {
    width: 42px;
    min-width: 42px;
    max-width: 42px;
  }

  .results-table th.col-fav,
  .results-table td.col-fav {
    width: 24px;
    min-width: 24px;
    max-width: 24px;
    padding-left: 0;
    padding-right: 0;
  }

  .results-table th.col-playlist,
  .results-table td.col-playlist {
    width: 50px;
    min-width: 50px;
    max-width: 50px;
  }

  .link-button {
    font-size: 13px;
  }

  .playlist-action-button {
    min-width: 14px;
    font-size: 12px;
  }
}
