:root {
  color-scheme: light;
  --background: #f7f7f4;
  --surface: #ffffff;
  --surface-muted: #f0f2ec;
  --text: #1e241f;
  --muted: #637064;
  --line: #d9ded6;
  --accent: #1db954;
  --accent-dark: #16843e;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(23, 31, 25, 0.11);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--background);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 24px 16px 56px;
}

.screen {
  min-height: calc(100vh - 80px);
}

.auth-screen {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 18px;
  text-align: center;
}

.brand-mark {
  display: grid;
  width: 72px;
  height: 72px;
  place-items: center;
  border-radius: 18px;
  background: var(--text);
  color: var(--accent);
  font-size: 36px;
  font-weight: 800;
  box-shadow: var(--shadow);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 5vw, 38px);
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  font-size: 21px;
  line-height: 1.2;
  letter-spacing: 0;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0 20px;
}

.profile {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 50%;
  object-fit: cover;
  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: 700;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.generator-form {
  display: grid;
  gap: 16px;
}

.generator-form > h1 {
  padding: 4px 0 6px;
  text-align: center;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.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: 700;
  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(--text);
  color: #ffffff;
}

.field-stack {
  display: grid;
  gap: 8px;
}

.text-field {
  display: grid;
  gap: 7px;
}

.text-field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.text-field input {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 14px;
  outline: none;
}

.text-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(29, 185, 84, 0.14);
}

.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);
}

.check-row,
.switch-row {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text);
  font-weight: 650;
}

.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: 750;
  line-height: 48px;
}

.advanced-panel[open] {
  display: grid;
  gap: 14px;
}

.primary-button,
.secondary-button,
.text-button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
}

.primary-button {
  width: 100%;
  background: var(--accent);
  color: #07140b;
  padding: 0 18px;
}

.primary-button:hover,
.primary-button:focus-visible {
  background: #24d564;
}

.primary-button:disabled {
  cursor: not-allowed;
  background: var(--line);
  color: var(--muted);
}

.secondary-button {
  display: grid;
  place-items: center;
  background: var(--surface-muted);
  color: var(--text);
  padding: 0 18px;
}

.text-button {
  flex: 0 0 auto;
  background: transparent;
  color: var(--accent-dark);
  padding: 0 4px;
}

.message {
  width: 100%;
  min-height: 22px;
  text-align: center;
}

.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);
  padding: 8px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.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-weight: 800;
}

.search-subtitle {
  color: var(--muted);
  font-size: 13px;
}

.result-panel {
  display: grid;
  gap: 12px;
  border: 1px solid rgba(29, 185, 84, 0.35);
  border-radius: 8px;
  background: #f2fbf5;
  padding: 16px;
  text-align: center;
}

@media (max-width: 540px) {
  .app-shell {
    padding-inline: 14px;
  }

  .segmented-control {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .segmented-control span {
    min-height: 48px;
  }

  .profile-name {
    max-width: 50vw;
  }
}
