:root {
  --md-sys-color-surface: #f7f8ff;
  --md-sys-color-surface-container: #ebedff;
  --md-sys-color-on-surface: #1b1b23;
  --md-sys-color-primary: #3555d6;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-outline: #71718a;
  --widget-width: 760px;
  --widget-height: auto;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
}

body {
  margin: 0;
  font-family: "Noto Sans SC", sans-serif;
  color: var(--md-sys-color-on-surface);
  background: transparent;
  padding: 0;
}

.widget-shell {
  width: min(var(--widget-width), 100%);
  margin: 0;
}

.widget-shell.fixed-height {
  height: var(--widget-height);
}

.song-card {
  border-radius: 24px;
  padding: 20px;
  background: color-mix(in srgb, var(--md-sys-color-surface-container) 78%, white);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.1);
  display: grid;
  gap: 14px;
  width: 100%;
  max-height: 100%;
  overflow: auto;
}

body.dark-mode .song-card {
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.42);
}

.song-header {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

.cover {
  width: 160px;
  height: 160px;
  border-radius: 20px;
  object-fit: cover;
  background: #dadcec;
}

.song-meta {
  min-width: 0;
}

.title {
  margin: 0;
  font-size: 26px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta-line {
  margin: 8px 0 0;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0.86;
  font-size: 14px;
}

.material-symbols-rounded {
  font-size: 18px;
  font-variation-settings: "FILL" 1, "wght" 500, "GRAD" 0, "opsz" 24;
}

.controls {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  column-gap: 8px;
  align-items: center;
  justify-content: center;
  justify-items: center;
}

md-icon-button,
md-filled-tonal-icon-button {
  --md-icon-button-icon-size: 24px;
  width: 40px;
  height: 40px;
  margin: 0;
  align-self: center;
  justify-self: center;
}

.progress-wrap {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  gap: 8px;
  align-items: center;
}

.time-label {
  font-size: 11px;
  text-align: center;
  opacity: 0.74;
  font-variant-numeric: tabular-nums;
}

.progress-bar {
  width: 100%;
  appearance: none;
  height: 4px;
  border-radius: 999px;
  border: 0;
  outline: none;
  cursor: pointer;
  background: linear-gradient(
    to right,
    var(--md-sys-color-primary) 0%,
    var(--md-sys-color-primary) var(--progress-percent, 0%),
    color-mix(in srgb, var(--md-sys-color-outline) 42%, transparent) var(--progress-percent, 0%),
    color-mix(in srgb, var(--md-sys-color-outline) 42%, transparent) 100%
  );
}

.progress-bar::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: transparent;
}

.progress-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  margin-top: -4px;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: 2px solid var(--md-sys-color-on-primary);
  background: var(--md-sys-color-primary);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--md-sys-color-outline) 30%, transparent);
}

.progress-bar::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: transparent;
}

.progress-bar::-moz-range-progress {
  height: 4px;
  border-radius: 999px;
  background: var(--md-sys-color-primary);
}

.progress-bar::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: 2px solid var(--md-sys-color-on-primary);
  background: var(--md-sys-color-primary);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--md-sys-color-outline) 30%, transparent);
}

.progress-bar:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.compact-only {
  display: none;
}

.panel {
  border: 1px solid color-mix(in srgb, var(--md-sys-color-outline) 45%, transparent);
  border-radius: 16px;
  padding: 12px;
  background: color-mix(in srgb, var(--md-sys-color-surface) 88%, white);
}

.lyric-panel {
  min-height: 84px;
  max-height: 220px;
  overflow: auto;
}

.lyric-line {
  margin: 0;
  padding: 5px 0;
  font-size: 14px;
  opacity: 0.64;
  transition: opacity 0.2s ease;
}

.lyric-group.active .lyric-main {
  opacity: 1;
  color: var(--md-sys-color-primary);
  font-weight: 700;
}

.lyric-main {
  opacity: 0.92;
}

.lyric-translation {
  font-size: 12px;
  opacity: 0.68;
  padding-top: 0;
}

.lyric-romaji {
  font-size: 12px;
  opacity: 0.6;
  font-style: italic;
  padding-top: 0;
}

.queue-panel {
  max-height: 220px;
  overflow: auto;
}

.queue-row {
  width: 100%;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 9px 10px;
  cursor: pointer;
}

.queue-row.active {
  background: color-mix(in srgb, var(--md-sys-color-primary) 18%, transparent);
  font-weight: 700;
}

.empty-hint {
  margin: 0;
  font-size: 14px;
  opacity: 0.7;
}

.status {
  margin: 0;
  min-height: 18px;
  font-size: 12px;
  color: color-mix(in srgb, var(--md-sys-color-on-surface) 70%, transparent);
}

.hidden {
  display: none !important;
}

@media (max-width: 640px) {
  .song-card {
    padding: 14px;
    border-radius: 18px;
  }

  .song-header {
    grid-template-columns: 1fr;
  }

  .cover {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
  }

  .title {
    font-size: 21px;
  }
}

body.compact-mode .song-card {
  padding: 12px;
  border-radius: 16px;
  gap: 10px;
}

body.compact-mode .song-header {
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

body.compact-mode .cover {
  width: 84px;
  height: 84px;
  border-radius: 14px;
  aspect-ratio: auto;
}

body.compact-mode .title {
  font-size: 17px;
  white-space: nowrap;
}

body.compact-mode .meta-line {
  margin-top: 4px;
  font-size: 12px;
}

body.compact-mode .material-symbols-rounded {
  font-size: 15px;
}

body.compact-mode .controls {
  justify-content: center;
  column-gap: 4px;
}

body.compact-mode md-icon-button,
body.compact-mode md-filled-tonal-icon-button {
  width: 34px;
  height: 34px;
}

body.compact-mode .progress-wrap {
  grid-template-columns: 36px minmax(0, 1fr) 36px;
  gap: 6px;
}

body.compact-mode .time-label {
  font-size: 10px;
}

body.compact-mode .progress-bar {
  height: 3px;
}

body.compact-mode .progress-bar::-webkit-slider-runnable-track,
body.compact-mode .progress-bar::-moz-range-track,
body.compact-mode .progress-bar::-moz-range-progress {
  height: 3px;
}

body.compact-mode .progress-bar::-webkit-slider-thumb,
body.compact-mode .progress-bar::-moz-range-thumb {
  width: 10px;
  height: 10px;
}

body.compact-mode .compact-only {
  display: inline-flex;
}

body.compact-mode .panel {
  border-radius: 12px;
  padding: 9px;
}

body.compact-mode .lyric-panel {
  min-height: 56px;
  max-height: 92px;
}

body.compact-mode .queue-panel {
  max-height: 92px;
}

body.compact-mode .status {
  min-height: 14px;
  font-size: 11px;
}
