/* Shared states, toast, search, and responsive polish */

:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

input, textarea {
  user-select: text;
  -webkit-user-select: text;
}

.app-logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  flex-shrink: 0;
}

.welcome-card .app-logo {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  margin: 0 auto var(--space-4);
}

.state-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: var(--space-3);
  padding: var(--space-16) var(--space-6);
  min-height: 240px;
}

.state-block--loading {
  min-height: 160px;
  color: var(--text-secondary);
}

.state-block--loading p,
.state-block__text {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  max-width: 28ch;
  line-height: 1.5;
}

.state-block__icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--surface-glass);
  color: var(--accent-primary);
}

.state-block__icon svg {
  width: 26px;
  height: 26px;
}

.state-block--error .state-block__icon {
  color: var(--danger);
  background: rgba(244, 67, 54, 0.1);
}

.state-block__title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
}

.search-skeleton {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.search-skeleton__row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 0;
}

.toast-container {
  top: auto;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + var(--space-3));
  left: 50%;
  transform: translateX(-50%);
  width: min(420px, calc(100% - var(--space-8)));
}

body.has-mini-player .toast-container {
  bottom: calc(var(--nav-height) + var(--mini-player-height) + var(--safe-bottom) + var(--space-3));
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(24, 24, 28, 0.94);
  border: 1px solid var(--border-medium);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(8px);
  animation: none;
  transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out);
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast__icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.toast__icon svg {
  width: 14px;
  height: 14px;
}

.toast--success .toast__icon { background: rgba(76, 175, 80, 0.16); color: var(--success); }
.toast--error .toast__icon { background: rgba(244, 67, 54, 0.16); color: var(--danger); }
.toast--info .toast__icon { background: rgba(255, 78, 69, 0.16); color: var(--accent-primary); }

.toast__message {
  flex: 1;
  font-size: var(--text-sm);
  line-height: 1.35;
}

.toast__close {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--text-tertiary);
  display: grid;
  place-items: center;
}

.import-page {
  width: min(560px, 100%);
  margin: 0 auto;
}

.import-input {
  padding-left: var(--space-4);
  min-height: 48px;
  font-size: 16px;
}

.import-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.import-btn {
  min-height: 48px;
}

.view-heading {
  margin-bottom: var(--space-5);
}

.view-heading h2 {
  font-size: var(--text-xl);
  letter-spacing: -0.03em;
}

.search-page {
  max-width: 760px;
}

.search-bar {
  position: sticky;
  top: 0;
  z-index: 4;
  background: var(--bg-primary);
  margin-bottom: var(--space-4);
  padding: var(--space-3) 0 var(--space-3);
}

.search-bar__input {
  min-height: 48px;
  font-size: 16px;
}

.search-bar__clear[hidden] {
  display: none;
}

.search-bar__clear:not([hidden]) {
  opacity: 1;
}

.search-suggestions {
  margin-top: -8px;
}

.search-suggestion {
  width: 100%;
}

.side-nav__item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.side-nav__item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.8;
}

.extra-btn {
  width: auto;
  min-width: 44px;
  height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  background: var(--surface-glass);
}

.full-player__context-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 0;
}

.full-player__context-name {
  font-size: var(--text-xs);
  color: var(--text-primary);
  max-width: 42vw;
}

.mini-player {
  border-top: 1px solid var(--border-subtle);
}

.mini-player__art[hidden] {
  display: block;
  background: var(--bg-tertiary);
}

.mini-player.is-buffering #mini-player-playpause,
.full-player.is-buffering #btn-playpause {
  position: relative;
}

.mini-player.is-buffering #mini-player-playpause::after,
.full-player.is-buffering #btn-playpause::after {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: currentColor;
  animation: spin 0.7s linear infinite;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark span {
  font-family: var(--font-heading);
  font-weight: var(--weight-bold);
  letter-spacing: -0.02em;
}

@media (min-width: 700px) {
  .genre-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .carousel-card {
    width: 176px;
  }

  .detail-hero__art {
    width: 200px;
    height: 200px;
  }
}

@media (min-width: 900px) {
  .toast-container {
    top: var(--space-6);
    bottom: auto;
    left: auto;
    right: var(--space-6);
    transform: none;
    width: 360px;
  }

  body.has-mini-player .toast-container {
    bottom: auto;
  }

  .side-nav__brand img,
  .side-nav__brand .app-logo {
    width: 32px;
    height: 32px;
    border-radius: 9px;
  }

  .view {
    max-width: 1120px;
    padding: var(--space-8) var(--space-8) calc(var(--mini-player-height) + var(--space-10));
  }

  .genre-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .carousel-card {
    width: 196px;
  }

  .full-player {
    left: 0;
    top: 0;
    max-width: none;
    max-height: none;
    width: 100%;
    height: 100%;
    border-radius: 0;
    transform: translateY(100%);
  }

  .full-player.open {
    transform: translateY(0);
  }

  .full-player__artwork {
    padding: var(--space-6);
  }

  .full-player__art-container {
    max-width: 380px;
  }

  .full-player__info,
  .full-player__progress,
  .full-player__controls,
  .full-player__extras {
    width: min(560px, 100%);
    margin-left: auto;
    margin-right: auto;
  }

  .mini-player {
    height: 80px;
    left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    bottom: 0;
    padding-bottom: 0;
  }

  .mini-player__content {
    height: 80px;
    padding: 12px 24px;
    gap: var(--space-5);
  }

  .mini-player__art {
    width: 56px;
    height: 56px;
    border-radius: 10px;
  }

  .mini-player__title {
    font-size: var(--text-base);
  }

  .mini-player__btn {
    width: 44px;
    height: 44px;
  }
}

.auth-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-4);
  padding: var(--space-4);
  margin-bottom: var(--space-5);
  border-radius: var(--radius-lg);
  background: var(--surface-glass);
  border: 1px solid var(--border-subtle);
}

.auth-banner div {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.auth-banner strong {
  font-size: var(--text-sm);
}

.auth-banner span {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.auth-banner--ok {
  border-color: rgba(76, 175, 80, 0.35);
}

.auth-banner__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.auth-banner__upload {
  cursor: pointer;
  margin: 0;
}

@media (max-width: 700px) {
  .auth-banner {
    flex-direction: column;
    align-items: stretch;
  }
}

.auth-sheet {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: var(--space-6);
  background: rgba(0, 0, 0, 0.62);
}

.auth-sheet[hidden] {
  display: none;
}

.auth-sheet__card {
  width: min(420px, 100%);
  background: var(--bg-secondary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  text-align: center;
}

.auth-sheet__code {
  font-family: var(--font-heading);
  font-size: 2rem;
  letter-spacing: 0.18em;
  font-weight: var(--weight-bold);
}

.auth-sheet__status {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

@media (min-width: 1280px) {
  :root {
    --content-max-width: 1280px;
    --sidebar-width: 240px;
  }

  .carousel-card {
    width: 208px;
  }
}
