:root {
  --bg: #f6f1ea;
  --ink: #1f1d1a;
  --muted: #645f58;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-border: rgba(31, 29, 26, 0.12);
  --primary: #0f766e;
  --primary-hover: #0b5d57;
  --secondary: #aa3d17;
  --secondary-hover: #8e3213;
  --ring: rgba(15, 118, 110, 0.25);
  --shadow: 0 10px 24px rgba(31, 29, 26, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 0%, #fdd8aa 0%, rgba(253, 216, 170, 0) 32%),
    radial-gradient(circle at 80% 0%, #b8d8ff 0%, rgba(184, 216, 255, 0) 28%),
    var(--bg);
  overflow-x: hidden;
}

.bg-orb {
  position: fixed;
  width: 420px;
  height: 420px;
  border-radius: 999px;
  filter: blur(60px);
  opacity: 0.32;
  z-index: -1;
  animation: drift 18s ease-in-out infinite;
}

.orb-1 {
  left: -130px;
  top: 35%;
  background: #fb923c;
}

.orb-2 {
  right: -130px;
  top: 10%;
  background: #22d3ee;
  animation-delay: -6s;
}

.layout {
  width: min(1040px, calc(100% - 2rem));
  margin: 2rem auto 4rem;
  display: grid;
  gap: 1.25rem;
}

.hero h1 {
  font-family: "Instrument Serif", serif;
  font-size: clamp(2rem, 4vw, 3.3rem);
  line-height: 1.03;
  margin: 0.4rem 0 0.8rem;
  letter-spacing: 0.01em;
}

.kicker {
  display: inline-block;
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--primary);
}

.subtitle {
  margin: 0;
  max-width: 65ch;
  color: var(--muted);
}

.helper-text {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.field-inline {
  margin-top: 0.85rem;
  display: flex;
  gap: 0.55rem;
  align-items: center;
}

.field-inline input {
  flex: 1;
  min-width: 160px;
  border: 1px solid var(--surface-border);
  border-radius: 11px;
  padding: 0.62rem 0.7rem;
  font-family: inherit;
  font-size: 0.92rem;
  background: rgba(255, 255, 255, 0.85);
}

.field-inline input:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 1px;
}

.quick-search {
  margin-top: 1rem;
  border-top: 1px dashed var(--surface-border);
  padding-top: 0.9rem;
}

.quick-search label {
  color: var(--muted);
  font-size: 0.86rem;
}

.results-list.compact {
  margin-top: 0.7rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 18px;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  padding: 1rem;
}

.input-head,
.results-head,
.bulk-actions,
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

h2 {
  margin: 0;
  font-size: 1.08rem;
}

.toggle-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--muted);
  user-select: none;
}

textarea {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  border: 1px solid var(--surface-border);
  border-radius: 14px;
  padding: 0.9rem;
  font-size: 0.96rem;
  line-height: 1.5;
  font-family: inherit;
  background: rgba(255, 255, 255, 0.85);
}

textarea:focus-visible,
.btn:focus-visible,
.btn-inline:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 1px;
}

.actions {
  margin-top: 0.85rem;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 0.62rem 1rem;
  font-family: inherit;
  font-size: 0.92rem;
  cursor: pointer;
  transition:
    transform 150ms ease,
    opacity 150ms ease,
    background-color 150ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  color: #fff;
  background: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  color: #fff;
  background: var(--secondary);
}

.btn-secondary:hover {
  background: var(--secondary-hover);
}

.btn-ghost {
  color: var(--ink);
  border: 1px solid var(--surface-border);
  background: rgba(255, 255, 255, 0.76);
}

.results-list {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.2rem;
}

.result-item {
  border: 1px solid var(--surface-border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition:
    transform 150ms ease,
    box-shadow 150ms ease;
}

.result-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 16px rgba(31, 29, 26, 0.12);
}

.artwork {
  width: 100%;
  height: 200px;
  object-fit: cover;
  background: #ede5dc;
}

.card-content {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  flex: 1;
}

.meta {
  flex: 1;
}

.meta .title {
  margin: 0;
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.3;
}

.meta .query {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.meta .artist {
  margin: 0.4rem 0 0;
  color: var(--ink);
  font-size: 0.85rem;
}

.badges {
  margin-top: 0.6rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.1);
  color: var(--primary);
  font-size: 0.75rem;
  line-height: 1;
}

.preview-player {
  margin-top: 0.55rem;
  width: 100%;
  height: 32px;
}

.item-actions {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}

.btn-inline {
  text-decoration: none;
  color: #fff;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  flex: 1;
  text-align: center;
  border: none;
  cursor: pointer;
  transition: opacity 150ms ease;
}

.btn-inline:hover {
  opacity: 0.85;
}

.youtube {
  background: #dc2626;
}

.spotify {
  background: #0ea85e;
}

.meta {
  min-width: 0;
}

.meta .title {
  margin: 0;
  font-weight: 700;
}

.meta .query {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meta .artist {
  margin: 0.2rem 0 0;
  color: var(--ink);
  font-size: 0.9rem;
}

.badges {
  margin-top: 0.45rem;
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--surface-border);
  background: rgba(255, 255, 255, 0.8);
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1;
}

.preview-player {
  margin-top: 0.55rem;
  width: min(270px, 100%);
  height: 32px;
}

.preview-empty {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.item-actions {
  display: inline-flex;
  gap: 0.45rem;
  flex-shrink: 0;
}

.btn-inline {
  text-decoration: none;
  color: #fff;
  border-radius: 999px;
  padding: 0.42rem 0.75rem;
  font-size: 0.83rem;
}

.youtube {
  background: #dc2626;
}

.spotify {
  background: #0ea85e;
}

.reveal {
  opacity: 0;
  transform: translateY(14px);
  animation: reveal 420ms ease-out forwards;
}

.panel.reveal:nth-of-type(2) {
  animation-delay: 120ms;
}

.panel.reveal:nth-of-type(3) {
  animation-delay: 180ms;
}

@keyframes reveal {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes drift {
  0%,
  100% {
    transform: translate(0, 0);
  }

  50% {
    transform: translate(40px, 24px);
  }
}

/* Two-column input layout */
.input-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 0.9rem;
}

.input-left {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.input-left textarea {
  margin-top: 0;
}

.input-right {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.feature-box {
  padding: 1rem;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--surface-border);
  border-radius: 12px;
}

.feature-header {
  margin: 0 0 0.7rem;
  font-size: 0.95rem;
}

.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: 0.4rem;
  font-size: 0.75rem;
  font-weight: bold;
  color: var(--primary);
  background: rgba(15, 118, 110, 0.1);
  border-radius: 50%;
  cursor: help;
  position: relative;
}

.info-icon:hover::after {
  content: attr(title);
  position: absolute;
  bottom: 120%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: normal;
  white-space: nowrap;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(31, 29, 26, 0.2);
  pointer-events: none;
}

/* FAQ Section */
.faq-section {
  margin-top: 2rem;
}

.faq-section h2 {
  margin-bottom: 1.2rem;
}

.faq-item {
  margin-bottom: 0.8rem;
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.5);
}

.faq-question {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--ink);
  transition: background-color 150ms ease;
  user-select: none;
}

.faq-question:hover {
  background-color: rgba(15, 118, 110, 0.05);
}

.faq-question strong {
  flex: 1;
  text-align: left;
}

.faq-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  font-weight: bold;
  color: var(--primary);
  transition: transform 200ms ease;
  flex-shrink: 0;
}

.faq-item[open] .faq-toggle {
  transform: rotate(45deg);
}

.faq-answer {
  padding: 0 1rem 1rem;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--muted);
}

.faq-answer p {
  margin: 0;
}

@media (max-width: 720px) {
  .layout {
    width: min(1040px, calc(100% - 1rem));
    margin: 1rem auto 2.5rem;
  }

  .panel {
    padding: 0.8rem;
  }

  .input-container {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .field-inline {
    flex-direction: column;
    align-items: stretch;
  }
}

.results-list {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.8rem;
}

.artwork {
  height: 150px;
}

.card-content {
  padding: 0.8rem;
  gap: 0.6rem;
}

.meta .title {
  font-size: 0.85rem;
}

.item-actions {
  gap: 0.3rem;
}

/* Final overrides: keep action buttons fully visible on narrow cards */
.result-item .item-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  width: 100%;
  min-width: 0;
  gap: 0.4rem;
}

.result-item .btn-inline {
  min-width: 0;
  width: 100%;
  padding: 0.5rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8rem;
  line-height: 1.1;
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
}

/* Final result-view system (overrides legacy duplicate rules above) */
.results-head {
  align-items: flex-start;
}

.results-controls {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.view-toggle {
  display: inline-flex;
  gap: 0.4rem;
}

.btn-view {
  width: 38px;
  height: 38px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
}

.view-icon {
  display: inline-block;
  width: 16px;
  height: 16px;
}

.view-icon-list {
  background:
    linear-gradient(var(--ink), var(--ink)) 0 2px / 16px 2px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 0 7px / 16px 2px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 0 12px / 16px 2px no-repeat;
}

.view-icon-grid {
  background:
    linear-gradient(var(--ink), var(--ink)) 0 0 / 7px 7px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 9px 0 / 7px 7px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 0 9px / 7px 7px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 9px 9px / 7px 7px no-repeat;
}

.btn-view.is-active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-view.is-active .view-icon-list {
  background:
    linear-gradient(#fff, #fff) 0 2px / 16px 2px no-repeat,
    linear-gradient(#fff, #fff) 0 7px / 16px 2px no-repeat,
    linear-gradient(#fff, #fff) 0 12px / 16px 2px no-repeat;
}

.btn-view.is-active .view-icon-grid {
  background:
    linear-gradient(#fff, #fff) 0 0 / 7px 7px no-repeat,
    linear-gradient(#fff, #fff) 9px 0 / 7px 7px no-repeat,
    linear-gradient(#fff, #fff) 0 9px / 7px 7px no-repeat,
    linear-gradient(#fff, #fff) 9px 9px / 7px 7px no-repeat;
}

#results.grid-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

#results.grid-view .result-item {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#results.grid-view .artwork {
  width: 100%;
  height: 220px;
  object-fit: cover;
}

#results.grid-view .card-content {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  flex: 1;
}

#results.grid-view .item-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  width: 100%;
}

#results.grid-view .btn-inline {
  width: 100%;
  min-width: 0;
  padding: 0.56rem 0.65rem;
  font-size: 0.95rem;
  text-align: center;
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
}

#results.list-view {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

#results.list-view .result-item {
  border: 1px solid var(--surface-border);
  border-radius: 12px;
  padding: 0.7rem;
  background: rgba(255, 255, 255, 0.7);
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.7rem;
}

#results.list-view .artwork {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  object-fit: cover;
}

#results.list-view .card-content {
  padding: 0;
  display: contents;
}

#results.list-view .meta {
  min-width: 0;
}

#results.list-view .meta .query {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#results.list-view .item-actions {
  display: inline-flex;
  gap: 0.45rem;
  flex-shrink: 0;
}

#results.list-view .btn-inline {
  width: auto;
  padding: 0.42rem 0.8rem;
  font-size: 0.86rem;
}

@media (max-width: 720px) {
  #results.grid-view {
    grid-template-columns: 1fr;
  }

  #results.grid-view .result-item {
    max-width: 100%;
  }

  #results.grid-view .artwork {
    height: 210px;
  }

  #results.grid-view .btn-inline {
    font-size: 0.9rem;
  }

  #results.list-view .result-item {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  #results.list-view .item-actions {
    grid-column: 1 / -1;
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

/* Final theme/layout overrides */
:root {
  --bg-gradient-a: #fdd8aa;
  --bg-gradient-b: #b8d8ff;
}

body {
  position: relative;
  isolation: isolate;
  background:
    radial-gradient(
      circle at 15% 10%,
      var(--bg-gradient-a) 0%,
      transparent 35%
    ),
    radial-gradient(
      circle at 85% 15%,
      var(--bg-gradient-b) 0%,
      transparent 32%
    ),
    var(--bg);
  background-size: 140% 140%;
  animation: bgFlow 12s ease-in-out infinite;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: -20%;
  pointer-events: none;
  z-index: -3;
}

body::before {
  background:
    radial-gradient(
      circle at 20% 20%,
      color-mix(in srgb, var(--bg-gradient-a) 68%, transparent) 0%,
      transparent 52%
    ),
    radial-gradient(
      circle at 75% 70%,
      color-mix(in srgb, var(--bg-gradient-b) 62%, transparent) 0%,
      transparent 50%
    );
  filter: blur(28px);
  opacity: 0.6;
  animation: gradientFloatA 18s ease-in-out infinite;
}

body::after {
  background:
    radial-gradient(
      circle at 78% 18%,
      color-mix(in srgb, var(--bg-gradient-b) 58%, transparent) 0%,
      transparent 46%
    ),
    radial-gradient(
      circle at 18% 78%,
      color-mix(in srgb, var(--bg-gradient-a) 55%, transparent) 0%,
      transparent 48%
    );
  filter: blur(34px);
  opacity: 0.5;
  animation: gradientFloatB 22s ease-in-out infinite;
}

.top-header {
  position: relative;
  z-index: 10;
  width: 100%;
  margin: 0;
  padding: 0.55rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--surface-border);
  background: var(--surface);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.header-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-coffee {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--surface-border);
  box-shadow: 0 6px 16px rgba(31, 29, 26, 0.2);
  animation: coffeeJump 1.7s ease-in-out infinite;
}

.btn-coffee:hover {
  animation-play-state: paused;
  transform: translateY(-2px) scale(1.03);
}

.theme-toggle {
  width: 42px;
  height: 42px;
  min-width: 42px;
  border-radius: 999px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(31, 29, 26, 0.2);
}

.coffee-logo {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.theme-icon {
  font-size: 1.2rem;
  line-height: 1;
  font-weight: 700;
}

.layout {
  margin-top: 0.75rem;
  position: relative;
  z-index: 2;
}

.hero {
  text-align: center;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  margin: 0 auto 0.25rem;
}

.brand-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
  border-radius: 10px;
}

.brand-name {
  font-size: clamp(1.5rem, 3.2vw, 2.3rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.01em;
  color: var(--primary);
}

.hero .subtitle {
  margin-inline: auto;
}

.hero .subtitle {
  max-width: 80ch;
}

body.dark-mode {
  --bg: #0f1218;
  --ink: #e8edf5;
  --muted: #a8b3c3;
  --surface: rgba(20, 24, 33, 0.78);
  --surface-border: rgba(232, 237, 245, 0.14);
  --primary: #38bdf8;
  --primary-hover: #0ea5e9;
  --secondary: #fb7185;
  --secondary-hover: #f43f5e;
  --ring: rgba(56, 189, 248, 0.35);
  --shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  --bg-gradient-a: #1d4ed8;
  --bg-gradient-b: #be185d;
}

body.dark-mode .btn-ghost {
  background: rgba(255, 255, 255, 0.06);
}

body.dark-mode .btn-coffee {
  background: rgba(31, 41, 55, 0.95);
  border-color: rgba(232, 237, 245, 0.2);
}

body.dark-mode .theme-toggle {
  background: rgba(31, 41, 55, 0.95);
  border-color: rgba(232, 237, 245, 0.2);
}

body.dark-mode .artwork {
  background: #1f2937;
}

@keyframes bgFlow {
  0% {
    background-position:
      0% 0%,
      100% 0%,
      0 0;
  }

  50% {
    background-position:
      20% 20%,
      80% 25%,
      0 0;
  }

  100% {
    background-position:
      0% 0%,
      100% 0%,
      0 0;
  }
}

@keyframes gradientFloatA {
  0% {
    transform: translate3d(-6%, -4%, 0) scale(1);
  }

  50% {
    transform: translate3d(8%, 6%, 0) scale(1.08);
  }

  100% {
    transform: translate3d(-6%, -4%, 0) scale(1);
  }
}

@keyframes gradientFloatB {
  0% {
    transform: translate3d(7%, -5%, 0) scale(1.02);
  }

  50% {
    transform: translate3d(-9%, 8%, 0) scale(1.1);
  }

  100% {
    transform: translate3d(7%, -5%, 0) scale(1.02);
  }
}

@keyframes coffeeJump {
  0%,
  100% {
    transform: translateY(0);
  }

  35% {
    transform: translateY(-4px);
  }

  60% {
    transform: translateY(0);
  }
}

@media (max-width: 720px) {
  .top-header {
    padding: 0.45rem 0.7rem;
  }

  .brand-name {
    font-size: 1.2rem;
  }

  .brand-logo {
    width: 34px;
    height: 34px;
  }
}
