:root {
  color-scheme: light;
  --background: #dfe3ee;
  --surface: #fbf8ff;
  --surface-strong: #ffffff;
  --surface-muted: #f0ebfb;
  --text: #161422;
  --muted: #756f82;
  --line: #e7e0f0;
  --accent: #8c56f0;
  --accent-dark: #6736cc;
  --accent-soft: #efe7ff;
  --spotify: #1db954;
  --danger: #b42318;
  --shadow: 0 10px 22px rgba(72, 62, 92, 0.13);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", "SF Pro Display", "Segoe UI", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--background);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(100%, 960px);
  margin: 0 auto;
  padding: 48px 18px 64px;
}

.screen {
  min-height: calc(100vh - 108px);
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-screen {
  position: relative;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 24px;
  text-align: center;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(30px, 5vw, 44px);
  line-height: 1.1;
  letter-spacing: -0.01em;
  font-weight: 600;
}

.generator-form > h1 {
  font-size: clamp(30px, 4.4vw, 42px);
  letter-spacing: -0.05em;
}

.auth-screen h1 {
  letter-spacing: -0.075em;
}

h2 {
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: 0;
  font-weight: 600;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 28px 14px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.profile {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(29, 185, 84, 0.55);
  background: var(--surface-muted);
}

.profile-label {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.profile-name {
  max-width: 42vw;
  overflow: hidden;
  font-weight: 600;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.generator-form {
  display: grid;
  gap: 16px;
  padding: 0 28px 28px;
}

.generator-form > h1 {
  padding: 10px 0 12px;
  text-align: center;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-strong);
  box-shadow: 0 4px 10px rgba(84, 76, 104, 0.05);
}

.segmented-control legend {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.segmented-control label {
  min-width: 0;
  cursor: pointer;
}

.segmented-control input {
  position: absolute;
  opacity: 0;
}

.segmented-control span {
  display: grid;
  min-height: 58px;
  align-content: center;
  justify-items: center;
  gap: 3px;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 600;
  line-height: 1.1;
  text-align: center;
}

.segmented-control small {
  display: block;
  color: inherit;
  font-size: 11px;
  font-weight: 600;
}

.segmented-control input:checked + span {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 5px 10px rgba(140, 86, 240, 0.2);
}

.field-stack {
  display: grid;
  gap: 8px;
}

.text-field {
  position: relative;
  display: grid;
  gap: 7px;
}

.text-field > .field-label,
.text-field > span:first-child {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.floating-field {
  gap: 0;
  padding-top: 8px;
}

.floating-field > .field-label {
  position: absolute;
  top: 0;
  left: 12px;
  z-index: 1;
  max-width: calc(100% - 24px);
  padding: 0 5px;
  overflow: hidden;
  background: var(--surface);
  line-height: 16px;
  opacity: 0;
  pointer-events: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.floating-field:focus-within > .field-label,
.floating-field:has(input:not(:placeholder-shown)) > .field-label {
  opacity: 1;
}

.text-field input {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-strong);
  color: var(--text);
  font-size: 16px;
  padding: 0 14px;
  outline: none;
  box-shadow: 0 3px 8px rgba(84, 76, 104, 0.035);
}

.text-field input[type="search"]::-webkit-search-cancel-button,
.text-field input[type="search"]::-webkit-search-decoration {
  appearance: none;
  display: none;
}

.input-shell {
  position: relative;
  display: block;
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
}

.input-shell input {
  padding-right: 44px;
}

.input-shell:has(.count-badge:not([hidden])) input,
.input-shell:has(.focus-count-control:not([hidden])) input {
  padding-right: 134px;
}

.input-clear-button {
  position: absolute;
  top: 50%;
  right: 10px;
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--surface-muted);
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
  transform: translateY(-50%);
}

.input-shell:has(.count-badge:not([hidden])) .input-clear-button,
.input-shell:has(.focus-count-control:not([hidden])) .input-clear-button {
  right: 88px;
}

.count-badge,
.focus-count-control {
  position: absolute;
  top: 50%;
  right: 10px;
  min-width: 68px;
  padding: 0 7px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 22px;
  pointer-events: none;
  text-align: center;
  transform: translateY(-50%);
  user-select: none;
}

.focus-count-control {
  display: inline-grid;
  grid-template-columns: 22px minmax(18px, auto) 22px;
  align-items: center;
  gap: 2px;
  padding: 0 4px;
  pointer-events: auto;
}

.focus-count-control button {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--accent-dark);
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
}

.focus-count-control button:disabled {
  color: #b9b2c4;
  cursor: not-allowed;
}

.input-clear-button:hover,
.input-clear-button:focus-visible {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.text-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(140, 86, 240, 0.13);
}

.text-field input.has-artwork {
  background-image: var(--selected-artwork);
  background-position: 12px center;
  background-repeat: no-repeat;
  background-size: 32px 32px;
  padding-left: 56px;
}

.text-field input:disabled {
  background: var(--surface-muted);
  color: var(--muted);
}

.text-field input:disabled + .input-clear-button + .count-badge,
.text-field input:disabled + .input-clear-button + .count-badge + .focus-count-control {
  display: none;
}

.check-row,
.switch-row {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  color: var(--text);
  font-weight: 500;
}

.filter-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 2px 0 8px;
}

.short-focus-note {
  margin: 0 0 12px;
}

.filter-chip {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  padding: 0 12px;
}

.filter-chip input {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
}

.filter-chip:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.check-row {
  justify-content: flex-start;
}

.check-row input,
.switch-row input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.advanced-panel {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 2px 0 10px;
}

.advanced-panel summary {
  min-height: 48px;
  cursor: pointer;
  color: var(--text);
  font-weight: 600;
  line-height: 48px;
}

.advanced-panel[open] {
  display: grid;
  gap: 0;
}

.advanced-panel > .text-field,
.advanced-panel > .field-stack {
  margin-bottom: 18px;
}

.advanced-panel > .field-stack {
  margin-bottom: 16px;
}

.advanced-panel > .check-row {
  min-height: 34px;
}

.advanced-panel > .check-row + .check-row {
  margin-top: 4px;
}

.advanced-panel > .switch-row {
  width: max-content;
  max-width: 100%;
  margin: 4px 0 16px;
}

.switch-row input {
  flex: 0 0 auto;
}

.custom-focus-row {
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin: 0 0 14px;
}

.custom-focus-row span {
  display: grid;
  gap: 3px;
}

.custom-focus-row small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.primary-button,
.secondary-button,
.text-button {
  min-height: 48px;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
}

.primary-button {
  width: 100%;
  background: var(--accent);
  color: #ffffff;
  padding: 0 18px;
  box-shadow: 0 6px 10px rgba(140, 86, 240, 0.2);
}

.auth-screen .primary-button {
  width: min(100%, 288px);
}

.primary-button:hover,
.primary-button:focus-visible {
  background: #9a66f4;
}

.primary-button:disabled {
  cursor: not-allowed;
  background: var(--line);
  color: var(--muted);
}

.secondary-button {
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-dark);
  padding: 0 18px;
}

.text-button {
  flex: 0 0 auto;
  background: transparent;
  color: var(--accent-dark);
  padding: 0 4px;
}

.help-button {
  position: relative;
  display: grid;
  width: 23px;
  height: 23px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid #c9c4d4;
  border-radius: 50%;
  background: var(--surface-strong);
  color: #8d8699;
  cursor: help;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
}

.tooltip-panel {
  position: absolute;
  display: grid;
  gap: 6px;
  right: 0;
  top: calc(100% + 10px);
  z-index: 10;
  width: min(430px, 82vw);
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.13);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.35;
  opacity: 0;
  padding: 12px;
  pointer-events: none;
  text-align: left;
  transform: translateY(4px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.tooltip-panel strong {
  color: var(--accent-dark);
  font-weight: 700;
}

.help-button:hover .tooltip-panel,
.help-button:focus-visible .tooltip-panel {
  opacity: 1;
  transform: translateY(0);
}

.message {
  width: 100%;
  min-height: 22px;
  text-align: center;
}

.helper-text {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
}

.error {
  color: var(--danger);
  font-weight: 700;
}

.search-results {
  display: grid;
  gap: 8px;
}

.search-result {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  width: 100%;
  min-height: 64px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 8px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  box-shadow: 0 3px 8px rgba(84, 76, 104, 0.04);
}

.search-result:hover,
.search-result:focus-visible {
  border-color: var(--accent);
}

.search-cover {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--surface-muted);
}

.search-title,
.search-subtitle {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result > span {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.search-title {
  font-size: 14px;
  font-weight: 600;
}

.search-subtitle {
  color: var(--muted);
  font-size: 12px;
}

.result-panel {
  display: grid;
  gap: 12px;
  border: 1px solid rgba(140, 86, 240, 0.24);
  border-radius: 8px;
  background: var(--accent-soft);
  padding: 16px;
  text-align: center;
}

@media (max-width: 540px) {
  .app-shell {
    padding: 16px 10px 36px;
  }

  .screen {
    min-height: calc(100vh - 52px);
    border-radius: 10px;
  }

  .top-bar,
  .generator-form {
    padding-inline: 16px;
  }

  .segmented-control {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .segmented-control span {
    min-height: 48px;
  }

  .profile-name {
    max-width: 50vw;
  }
}
