:root {
  --metal-light: #f7f7f7;
  --metal-mid: #e2e2e2;
  --metal-dark: #bcbcbc;
  --edge-dark: #777;
  --edge-light: #fff;
  --paper: #fff;
  --ink: #1d1d1d;
  --lcd: #f1f1f1;
  --selection: #666;
  --selection-dark: #444;
  --stripe: #f2f2f2;
  --sidebar: #f7f7f7;
  --focus: #222;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  min-height: 100vh;
  margin: 0;
  padding: 16px clamp(12px, 3vw, 34px) clamp(12px, 3vw, 34px);
  background: #fff;
  color: var(--ink);
  font-family: "Lucida Grande", "Lucida Sans Unicode", Geneva, Verdana, sans-serif;
  font-size: 13px;
}

button,
input { font: inherit; }

button { color: inherit; }

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.scotify-window {
  display: flex;
  flex-direction: column;
  width: min(1180px, 100%);
  min-height: min(760px, calc(100vh - 24px));
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid #777;
  border-radius: 5px;
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,.18) 0, rgba(255,255,255,.18) 1px, rgba(0,0,0,.035) 1px, rgba(0,0,0,.035) 2px),
    linear-gradient(#f8f8f8, #ddd);
  box-shadow: 0 18px 60px rgba(0,0,0,.25), inset 0 1px var(--edge-light);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, .75fr) minmax(330px, 1.15fr) minmax(220px, .75fr);
  gap: 22px;
  align-items: center;
  min-height: 112px;
  padding: 13px 20px 12px;
  border-bottom: 1px solid var(--edge-dark);
  box-shadow: inset 0 1px rgba(255,255,255,.65), inset 0 -1px rgba(255,255,255,.35);
}

.transport-cluster {
  display: grid;
  gap: 9px;
  justify-items: start;
}

.transport-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
}

.round-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid #888;
  border-radius: 50%;
  background: radial-gradient(circle at 45% 28%, #fff 0 20%, #e4e4e4 55%, #aaa 100%);
  box-shadow: 0 1px 2px rgba(0,0,0,.3), inset 0 0 0 2px rgba(255,255,255,.72);
  cursor: pointer;
}

.round-button:hover { filter: brightness(1.07); }
.round-button:active { background: radial-gradient(circle at 50% 60%, #fafafa, #bbb); }
.round-button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.play-button {
  width: 56px;
  height: 56px;
}

.play-button span {
  width: 0;
  height: 0;
  margin-left: 4px;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  border-left: 16px solid #383838;
  filter: drop-shadow(0 1px #fff);
}

.play-button.is-playing span {
  width: 15px;
  height: 20px;
  margin: 0;
  border: 0;
  border-right: 5px solid #383838;
  border-left: 5px solid #383838;
}

.skip-back span,
.skip-forward span {
  position: relative;
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
}

.skip-back span { border-right: 12px solid #444; }
.skip-forward span { border-left: 12px solid #444; }

.skip-back span::after,
.skip-forward span::after {
  content: "";
  position: absolute;
  top: -8px;
  width: 3px;
  height: 16px;
  background: #444;
}

.skip-back span::after { left: -2px; }
.skip-forward span::after { right: -2px; }

.volume-control {
  display: grid;
  grid-template-columns: 14px minmax(80px, 130px) 14px;
  gap: 5px;
  align-items: center;
  color: #444;
  font-size: 14px;
  text-align: center;
}

.volume-control input,
.lcd-display input {
  accent-color: #555;
  cursor: pointer;
}

.volume-control input { width: 100%; }

.lcd-display {
  min-width: 0;
  padding: 9px 20px 10px;
  border: 1px solid #888;
  border-radius: 28px;
  background: var(--lcd);
  box-shadow: inset 0 1px 5px rgba(0,0,0,.25), 0 1px rgba(255,255,255,.8);
  text-align: center;
}

.display-title {
  overflow: hidden;
  margin: 0;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.display-meta {
  overflow: hidden;
  margin: 1px 0 5px;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lcd-display input {
  display: block;
  width: 100%;
  height: 12px;
  margin: 0;
}

.library-tools {
  display: none;
}

.search-input {
  width: min(160px, 100%);
  height: 29px;
  padding: 4px 12px;
  border: 1px solid #999;
  border-radius: 16px;
  background: #fff;
  box-shadow: inset 0 1px 4px rgba(0,0,0,.25), 0 1px rgba(255,255,255,.7);
  color: var(--ink);
  outline: none;
}

.search-input:focus { border-color: var(--focus); box-shadow: 0 0 0 2px rgba(0,0,0,.2), inset 0 1px 3px rgba(0,0,0,.2); }

.library-layout {
  display: grid;
  grid-template-columns: 188px minmax(0, 1fr);
  flex: 1;
  min-height: 0;
  border-bottom: 1px solid var(--edge-dark);
}

.source-sidebar {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-right: 1px solid var(--edge-dark);
  background: var(--sidebar);
}

.source-sidebar h2,
.browser-column h2 {
  height: 24px;
  margin: 0;
  padding: 3px 8px;
  border-bottom: 1px solid #999;
  background: linear-gradient(#fff, #d5d5d5);
  box-shadow: inset 0 1px #fff;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  text-shadow: 0 1px #fff;
}

.source-sidebar nav { display: grid; }

.source-button {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 7px;
  align-items: center;
  width: 100%;
  min-height: 31px;
  padding: 3px 7px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.source-button img,
.source-glyph {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  object-fit: cover;
  border: 1px solid #999;
  background: #fff;
  font-size: 14px;
}

.source-button:hover { background: #e5e5e5; }
.source-button.is-selected { background: linear-gradient(#777, #555); color: #fff; text-shadow: 0 1px #333; }
.source-button:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.source-button[hidden],
.browser-choice[hidden] { display: none; }

.source-artwork {
  display: grid;
  gap: 8px;
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid #aaa;
}

.artwork-button {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.artwork-button img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  border: 1px solid #999;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0,0,0,.28);
}

.artwork-button:hover img { filter: brightness(1.04); }
.artwork-button:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

.lyrics-button {
  width: 100%;
  min-height: 29px;
  padding: 4px 10px;
  border: 1px solid #999;
  border-radius: 3px;
  background: linear-gradient(#fff, #ddd);
  box-shadow: inset 0 1px #fff, 0 1px 2px rgba(0,0,0,.2);
  color: var(--ink);
  cursor: pointer;
}

.lyrics-button:hover { background: linear-gradient(#fff, #eee); }
.lyrics-button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.lyrics-button[hidden] { display: none; }

.library-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: #fff;
}

.browser-panel {
  display: block;
  min-height: 122px;
  border-bottom: 1px solid #999;
}

.browser-panel[hidden] { display: none; }

.browser-column {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #fff;
}

.browser-choice {
  display: block;
  width: 100%;
  min-height: 24px;
  padding: 3px 8px;
  overflow: hidden;
  border: 0;
  background: #fff;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.browser-choice:hover { background: #e5e5e5; }
.browser-choice.is-selected { background: #666; color: #fff; }
.browser-choice:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }

.track-table-wrap {
  position: relative;
  flex: 1;
  min-height: 280px;
  overflow: auto;
  background: #fff;
}

.track-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  font-size: 12px;
}

.track-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

.track-table th {
  height: 25px;
  padding: 3px 7px;
  overflow: hidden;
  border-right: 1px solid #bbb;
  border-bottom: 1px solid #999;
  background: linear-gradient(#fff, #ddd);
  box-shadow: inset 0 1px #fff;
  font-weight: 400;
  text-align: left;
  text-overflow: ellipsis;
  text-shadow: 0 1px #fff;
  white-space: nowrap;
}

.track-table th:last-child { border-right: 0; }
.song-column { width: 43%; }
.time-column { width: 60px; text-align: right !important; }
.album-column { width: auto; }

.track-table td {
  height: 25px;
  padding: 3px 7px;
  overflow: hidden;
  border-right: 1px solid rgba(150,150,150,.28);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-table td:last-child { border-right: 0; }
.track-table tr:nth-child(even) td { background: var(--stripe); }
.track-table tr { cursor: default; }
.track-table tr:hover td { background: #e5e5e5; }
.track-table tr.is-selected td { background: var(--selection); color: #fff; text-shadow: 0 1px var(--selection-dark); }
.time-cell { text-align: right; font-variant-numeric: tabular-nums; }

.song-button {
  width: 100%;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: default;
}

.song-button:focus-visible { outline: 1px dotted currentColor; outline-offset: 1px; }

.empty-message {
  margin: 40px auto;
  padding: 0 20px;
  color: #666;
  text-align: center;
}

.status-bar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 5px 12px;
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,.2) 0, rgba(255,255,255,.2) 1px, rgba(0,0,0,.025) 1px, rgba(0,0,0,.025) 2px),
    linear-gradient(#f5f5f5, #d5d5d5);
  box-shadow: inset 0 1px #fff;
  color: #444;
  font-size: 11px;
  text-shadow: 0 1px #fff;
}

.status-bar p { margin: 0; }
#statusText { text-align: center; }

.artwork-dialog,
.lyrics-dialog {
  max-width: none;
  max-height: none;
  padding: 0;
  border: 1px solid #777;
  border-radius: 4px;
  background: #e4e4e4;
  box-shadow: 0 20px 80px rgba(0,0,0,.6), inset 0 1px #fff;
}

.artwork-dialog::backdrop,
.lyrics-dialog::backdrop { background: rgba(0,0,0,.72); }

.artwork-dialog-frame {
  position: relative;
  padding: 34px 12px 12px;
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,.18) 0, rgba(255,255,255,.18) 1px, rgba(0,0,0,.035) 1px, rgba(0,0,0,.035) 2px),
    linear-gradient(#fafafa, #ddd);
}

.artwork-dialog img {
  display: block;
  width: auto;
  height: auto;
  max-width: min(82vw, 780px);
  max-height: 82vh;
  object-fit: contain;
  border: 1px solid #999;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
}

.artwork-credit {
  margin: 9px 0 0;
  color: #444;
  font-size: 13px;
  text-align: center;
}

.modal-close {
  position: absolute;
  top: 5px;
  right: 7px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0 0 2px;
  border: 1px solid #999;
  border-radius: 50%;
  background: linear-gradient(#fff, #ddd);
  box-shadow: inset 0 1px #fff;
  font: 21px/1 Arial, sans-serif;
  cursor: pointer;
}

.modal-close:hover { background: #fff; }
.modal-close:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.lyrics-dialog {
  width: min(560px, 90vw);
}

.lyrics-dialog-frame {
  position: relative;
  max-height: min(78vh, 720px);
  padding: 32px clamp(22px, 5vw, 50px) 38px;
  overflow-y: auto;
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,.16) 0, rgba(255,255,255,.16) 1px, rgba(0,0,0,.025) 1px, rgba(0,0,0,.025) 2px),
    linear-gradient(#fff, #e6e6e6);
}

.lyrics-kicker {
  margin: 0 0 3px;
  color: #555;
  font-size: 12px;
  letter-spacing: .08em;
  text-align: center;
  text-transform: uppercase;
}

.lyrics-dialog h2 {
  margin: 0 30px 24px;
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: clamp(21px, 4vw, 30px);
  line-height: 1.1;
  text-align: center;
}

.lyrics-text {
  font-size: 15px;
  line-height: 1.55;
  text-align: center;
}

.lyrics-text p { margin: 0 0 1.35em; }
.lyrics-text p:last-child { margin-bottom: 0; }

.album-info-text {
  font-size: 14px;
  line-height: 1.55;
}

.album-info-text p { margin: 0 0 1em; }
.album-info-downloads { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.album-info-downloads a {
  display: inline-block;
  padding: 7px 12px;
  border: 1px solid #999;
  border-radius: 3px;
  background: linear-gradient(#fff, #ddd);
  color: var(--ink);
  text-decoration: none;
}
.album-info-downloads a:hover { background: #fff; }
.album-info-downloads a:focus-visible { outline: 2px solid var(--focus); }

@media (max-width: 860px) {
  body { padding: 12px 0 0; background: #fff; }
  .scotify-window { min-height: calc(100vh - 57px); border: 0; border-radius: 0; }
  .toolbar { grid-template-columns: 1fr; gap: 10px; padding: 12px; }
  .transport-cluster { grid-template-columns: auto minmax(120px, 1fr); align-items: center; gap: 18px; }
  .volume-control { width: min(220px, 100%); }
  .lcd-display { grid-row: 1; }
  .library-tools { justify-content: center; }
  .search-input { width: min(320px, 75vw); }
  .library-layout { grid-template-columns: 1fr; }
  .source-sidebar { border-right: 0; border-bottom: 1px solid var(--edge-dark); }
  .source-sidebar nav { display: none; }
  .source-sidebar h2 { display: none; }
  .source-artwork { grid-template-columns: min(128px, 34vw); place-items: center; justify-content: center; margin-top: 0; padding: 9px; border-top: 0; }
  .artwork-button { width: 100%; }
  .browser-panel { min-height: 104px; }
  .track-table-wrap { min-height: 390px; }
}

@media (max-width: 570px) {
  .toolbar { min-height: 0; }
  .transport-cluster { grid-template-columns: 1fr; justify-items: center; gap: 8px; }
  .volume-control { display: none; }
  .round-button { width: 40px; height: 40px; }
  .play-button { width: 50px; height: 50px; }
  .library-tools { gap: 10px; }
  .track-table { min-width: 0; }
  .song-column { width: 46%; }
  .time-column { width: 54px; }
  .artwork-dialog-frame { padding: 32px 8px 8px; }
  .artwork-dialog img { max-width: 90vw; max-height: 78vh; }
  .lyrics-dialog-frame { padding: 32px 18px 30px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
