:root {
  color-scheme: light;
  --bg: #f7f7f1;
  --panel: #ffffff;
  --ink: #050505;
  --muted: #5f6268;
  --line: #050505;
  --blue: #31caff;
  --green: #3ce5a0;
  --yellow: #f3f661;
  --pink: #ffc1e6;
  --pink-strong: #f7a7db;
  --mint-soft: #c6f8e6;
  --blue-soft: #c5efff;
  --cream: #fbf4e8;
  --shadow: 8px 8px 0 #050505;
  --soft-shadow: 0 18px 44px rgba(5, 5, 5, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Neue Haas Grotesk Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 193, 230, 0.72), transparent 24rem),
    radial-gradient(circle at 82% 8%, rgba(49, 202, 255, 0.62), transparent 25rem),
    linear-gradient(135deg, #fffdf2 0%, #eefbff 48%, #fff1fa 100%);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: 22px 0 40px;
}

.workspace {
  display: grid;
  gap: 18px;
}

.topbar,
.topbar-actions,
.brand-lockup,
.section-title,
.clip-card,
.clip-main,
.clip-actions,
.tool-row {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0 4px;
}

.topbar-actions {
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.brand-lockup {
  gap: 18px;
  min-width: 0;
}

.logo-mark {
  display: grid;
  justify-items: center;
  gap: 0;
  flex: 0 0 auto;
}

.app-logo {
  width: clamp(76px, 10vw, 116px);
  height: clamp(76px, 10vw, 116px);
  overflow: visible;
  filter: drop-shadow(6px 7px 0 #050505);
}

.logo-wordmark {
  margin-top: -15px;
  padding: 4px 10px 5px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--yellow);
  color: var(--ink);
  font-size: clamp(0.82rem, 1.8vw, 1.05rem);
  font-weight: 950;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  box-shadow: 4px 4px 0 var(--ink);
  transform: rotate(-2deg);
}

.logo-wordmark span {
  color: #315d36;
}

.eyebrow {
  display: inline-flex;
  margin: 0 0 10px;
  padding: 7px 13px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--yellow);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: 0;
  box-shadow: 4px 4px 0 var(--ink);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  max-width: 620px;
  font-size: clamp(3rem, 5.2vw, 4.7rem);
  line-height: 0.94;
  letter-spacing: 0;
  font-weight: 950;
}

h2 {
  font-size: 1.18rem;
  font-weight: 950;
}

.status-pill {
  min-width: 168px;
  padding: 11px 15px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--pink);
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 950;
  text-align: center;
  box-shadow: 4px 4px 0 var(--ink);
}

.control-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(280px, 0.64fr);
  gap: 22px;
  align-items: start;
}

.player-section {
  display: none;
}

.player-brand {
  display: grid;
  justify-items: center;
  margin: 4px auto 18px;
}

.player-logo {
  width: clamp(92px, 18vw, 148px);
  height: clamp(92px, 18vw, 148px);
  overflow: visible;
  filter: drop-shadow(6px 7px 0 #050505);
}

.player-wordmark {
  margin-top: -18px;
}

.player-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px;
  min-height: calc(100vh - 64px);
  align-content: start;
  padding: 8px;
}

.sound-pad {
  min-height: 124px;
  border: 3px solid var(--ink);
  border-radius: 24px;
  background: var(--green);
  color: var(--ink);
  cursor: pointer;
  font-size: clamp(1.05rem, 3vw, 1.55rem);
  font-weight: 950;
  line-height: 1.15;
  padding: 18px;
  text-align: center;
  overflow-wrap: anywhere;
  box-shadow: var(--shadow);
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.sound-pad:nth-child(4n + 1) {
  background: var(--blue);
}

.sound-pad:nth-child(4n + 2) {
  background: var(--green);
}

.sound-pad:nth-child(4n + 3) {
  background: var(--yellow);
}

.sound-pad:nth-child(4n + 4) {
  background: var(--pink);
}

.sound-pad:active {
  transform: translate(5px, 5px);
  box-shadow: 3px 3px 0 var(--ink);
}

.player-empty {
  display: none;
  min-height: calc(100vh - 64px);
  place-items: center;
  color: var(--muted);
  font-size: 1.1rem;
  font-weight: 800;
  text-align: center;
}

body.player-mode {
  background:
    radial-gradient(circle at 18% 10%, rgba(255, 193, 230, 0.74), transparent 24rem),
    radial-gradient(circle at 82% 0%, rgba(49, 202, 255, 0.5), transparent 24rem),
    linear-gradient(135deg, #fffdf5 0%, #f8ecf3 46%, #effaff 100%);
}

body.player-mode .app-shell {
  width: min(100% - 18px, 980px);
  padding: 9px 0;
}

body.player-mode .topbar,
body.player-mode .admin-only {
  display: none;
}

body.player-mode .player-section {
  display: grid;
}

body.player-mode .player-empty.is-visible {
  display: grid;
}

.panel,
.library-section {
  border: 2px solid var(--ink);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.setup-panel,
.help-panel,
.api-panel,
.library-section {
  padding: 22px;
}

.setup-panel {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.88), rgba(255, 193, 230, 0.42)),
    var(--panel);
}

.setup-panel {
  display: grid;
  gap: 16px;
}

.help-panel {
  align-self: start;
  background: var(--yellow);
}

.help-panel h2 {
  margin-bottom: 12px;
}

.help-panel ul {
  display: grid;
  gap: 10px;
  margin: 0 0 18px;
  padding-left: 18px;
  color: var(--ink);
  font-weight: 750;
  line-height: 1.45;
}

.section-title {
  justify-content: space-between;
  gap: 12px;
}

.section-title span {
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 950;
}

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

.field span {
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 950;
}

.field-hint {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 750;
  line-height: 1.25;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="file"] {
  width: 100%;
  min-height: 48px;
  border: 2px solid var(--ink);
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  padding: 11px 14px;
  font-weight: 750;
}

.upload-dropzone {
  display: grid;
  justify-items: center;
  gap: 10px;
  width: min(100%, 440px);
  margin: 4px auto 2px;
  padding: 24px 18px;
  border: 3px dashed var(--ink);
  border-radius: 28px;
  background:
    radial-gradient(circle at 18% 18%, rgba(243, 246, 97, 0.75), transparent 8rem),
    linear-gradient(135deg, #ffffff 0%, #eafaff 100%);
  color: var(--ink);
  cursor: pointer;
  text-align: center;
  box-shadow: 6px 6px 0 var(--ink);
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.upload-dropzone:hover,
.upload-dropzone.is-dragging {
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 193, 230, 0.85), transparent 8rem),
    linear-gradient(135deg, #ffffff 0%, #dfffee 100%);
  transform: translate(-2px, -2px);
  box-shadow: 9px 9px 0 var(--ink);
}

.upload-dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: var(--green);
  box-shadow: 4px 4px 0 var(--ink);
  font-size: 2rem;
  font-weight: 950;
  line-height: 1;
}

.upload-title {
  font-size: 1.35rem;
  font-weight: 950;
  line-height: 1;
}

.upload-copy {
  max-width: 330px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.25;
}

.upload-file {
  display: inline-flex;
  max-width: 100%;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--pink);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 950;
  overflow-wrap: anywhere;
}

.upload-dropzone.has-file .upload-file {
  background: var(--yellow);
}

input:focus,
button:focus-visible {
  outline: 4px solid rgba(49, 202, 255, 0.4);
  outline-offset: 2px;
}

.range-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.key-capture {
  min-height: 56px;
  border: 2px dashed var(--ink);
  border-radius: 18px;
  background: var(--blue-soft);
  color: var(--ink);
  font-weight: 950;
  cursor: pointer;
}

.key-capture.is-listening {
  background: var(--yellow);
  color: var(--ink);
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  cursor: pointer;
  font-weight: 950;
  box-shadow: 4px 4px 0 var(--ink);
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

[data-icon]::before {
  content: attr(data-icon);
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #fff;
  font-size: 0.86em;
  line-height: 1;
}

.primary-button:active,
.secondary-button:active,
.ghost-button:active,
.icon-button:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 var(--ink);
}

.primary-button {
  min-height: 48px;
  background: var(--green);
  color: var(--ink);
}

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

.secondary-button,
.ghost-button {
  min-height: 40px;
  padding: 0 14px;
  background: #fff;
  color: var(--ink);
}

.ghost-button {
  background: var(--pink);
}

.tool-row {
  gap: 10px;
  flex-wrap: wrap;
}

.import-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.import-label input {
  display: none;
}

.library-section {
  display: grid;
  gap: 16px;
}

.api-panel {
  display: grid;
  gap: 18px;
  background:
    radial-gradient(circle at 12% 18%, rgba(243, 246, 97, 0.82), transparent 9rem),
    linear-gradient(135deg, var(--green) 0%, #c6f8e6 100%);
}

.section-note {
  margin-top: 5px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 750;
}

.text-link {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-weight: 950;
  text-decoration: none;
  box-shadow: 4px 4px 0 var(--ink);
}

.text-link:hover {
  text-decoration: underline;
}

.api-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: end;
  padding: 12px;
  border: 2px solid var(--ink);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 5px 5px 0 var(--ink);
}

.api-fields {
  display: grid;
  grid-template-columns: minmax(210px, 0.9fr) minmax(240px, 1.1fr);
  gap: 12px;
}

.api-submit {
  align-self: end;
  min-width: 154px;
}

.api-results {
  display: grid;
  gap: 8px;
}

.api-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 68px;
  padding: 10px 12px;
  border: 2px solid var(--ink);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 4px 4px 0 var(--ink);
}

.api-result-body {
  min-width: 0;
}

.api-result h3 {
  margin-bottom: 3px;
  font-size: 0.98rem;
  font-weight: 950;
  overflow-wrap: anywhere;
}

.api-result p {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
  font-weight: 700;
}

.api-result-controls {
  display: flex;
  align-items: center;
  gap: 7px;
}

.api-key-field {
  display: grid;
  gap: 3px;
  justify-items: center;
}

.api-key-field span {
  color: var(--ink);
  font-size: 0.68rem;
  font-weight: 950;
  line-height: 1;
}

.api-key-input {
  width: 76px;
  min-height: 34px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 7px 9px;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 950;
}

.api-result-controls .icon-button {
  min-width: 68px;
  min-height: 34px;
  padding: 0 9px;
  font-size: 0.82rem;
}

.clip-list {
  display: grid;
  gap: 10px;
}

.clip-row {
  display: grid;
  gap: 6px;
  min-height: 52px;
  padding: 10px 12px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #fff;
}

.simple-list {
  border: 2px solid var(--ink);
  border-radius: 20px;
  overflow: hidden;
  background: #fff;
}

.simple-list .clip-row {
  display: grid;
  border-width: 0 0 1px;
  border-radius: 0;
  box-shadow: none;
}

.simple-list .clip-row:last-child {
  border-bottom: 0;
}

.clip-line {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 48px;
  height: 34px;
  padding: 0 8px;
  border: 2px solid var(--ink);
  border-bottom-width: 3px;
  border-radius: 10px;
  background: var(--blue);
  font-weight: 950;
  font-size: 0.82rem;
}

.clip-line h3 {
  font-size: 0.98rem;
  font-weight: 950;
  overflow-wrap: anywhere;
}

.clip-row p {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  padding-left: 58px;
}

.clip-actions {
  gap: 8px;
  flex-shrink: 0;
}

.clip-actions .icon-button {
  width: 34px;
  min-width: 34px;
  min-height: 34px;
  padding: 0;
}

.clip-actions .icon-button span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.icon-button {
  min-width: 78px;
  min-height: 38px;
  padding: 0 10px;
}

.play-button {
  background: var(--green);
  color: var(--ink);
}

.delete-button {
  background: var(--pink);
  color: var(--ink);
}

.empty-state {
  padding: 24px;
  border: 2px dashed var(--ink);
  border-radius: 20px;
  background: #fff;
  color: var(--muted);
  font-weight: 850;
  text-align: center;
}

.empty-state.is-hidden {
  display: none;
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 1120px);
    padding: 18px 0;
  }

  .topbar,
  .topbar-actions,
  .brand-lockup,
  .control-grid,
  .range-row,
  .api-search,
  .api-result,
  .clip-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .status-pill {
    width: 100%;
  }

  .brand-lockup {
    align-items: start;
  }

  .app-logo {
    width: 72px;
    height: 72px;
  }

  .logo-wordmark {
    margin-top: -10px;
    font-size: 0.72rem;
  }

  .player-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    min-height: auto;
  }

  .player-brand {
    margin-top: 0;
    margin-bottom: 14px;
  }

  .player-logo {
    width: 96px;
    height: 96px;
  }

  .sound-pad {
    min-height: 104px;
    padding: 14px;
  }

  .clip-actions {
    justify-content: stretch;
  }

  .clip-line {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .clip-row p {
    padding-left: 0;
  }

  .api-result-controls,
  .api-result .icon-button {
    flex: 1;
  }

  .api-result-controls {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
  }

  .api-key-input {
    width: 100%;
  }

  .api-fields {
    grid-template-columns: 1fr;
  }

  .api-submit {
    min-width: 0;
  }
}


/* Production layout polish */
@media (min-width: 900px) {
  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 24px;
    padding: 0 0 2px;
  }

  .brand-lockup {
    display: grid;
    grid-template-columns: 126px minmax(0, 1fr);
    align-items: center;
    gap: 24px;
  }

  .topbar-actions {
    display: grid;
    justify-items: end;
    align-content: start;
    gap: 12px;
    padding-top: 48px;
  }

  .app-logo {
    width: 104px;
    height: 104px;
  }

  .logo-wordmark {
    margin-top: -13px;
    font-size: 0.86rem;
  }

  .eyebrow {
    margin-bottom: 8px;
  }

  .setup-panel,
  .help-panel,
  .api-panel,
  .library-section {
    padding: 22px;
  }

  .setup-panel {
    gap: 14px;
  }

  .help-panel {
    max-width: 100%;
  }

  .help-panel ul {
    font-size: 0.92rem;
  }

  .api-panel {
    gap: 14px;
  }

  .api-fields {
    grid-template-columns: minmax(210px, 0.82fr) minmax(260px, 1.18fr);
  }

  .library-section {
    margin-top: 2px;
  }
}

@media (min-width: 1180px) {
  .app-shell {
    width: min(1220px, calc(100% - 56px));
  }

  .control-grid {
    grid-template-columns: minmax(0, 760px) minmax(300px, 1fr);
  }
}

@media (max-width: 899px) {
  .app-shell {
    width: min(100% - 22px, 760px);
    padding: 16px 0 28px;
  }

  .topbar {
    display: grid;
    gap: 14px;
  }

  .topbar-actions {
    justify-items: stretch;
  }

  h1 {
    font-size: clamp(2.5rem, 14vw, 4.3rem);
    max-width: none;
  }

  .control-grid {
    grid-template-columns: 1fr;
  }

  .api-search {
    grid-template-columns: 1fr;
  }
}

/* Freesound internal search */
.api-query-field {
  min-width: min(100%, 520px);
}

.api-save-name {
  display: grid;
  gap: 5px;
  margin-top: 8px;
}

.api-save-name span,
.api-time-field span {
  color: var(--ink);
  font-size: 0.68rem;
  font-weight: 950;
  line-height: 1;
}

.api-name-input,
.api-time-field input {
  width: 100%;
  min-height: 34px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  padding: 7px 10px;
  font-size: 0.82rem;
  font-weight: 850;
}

.api-time-field {
  display: grid;
  gap: 3px;
  justify-items: center;
}

.api-time-field input {
  width: 74px;
  text-align: center;
}

.api-result-controls {
  flex-wrap: wrap;
  justify-content: flex-end;
}

@media (min-width: 900px) {
  .api-search {
    grid-template-columns: minmax(260px, 1fr) auto;
  }

  .api-result {
    grid-template-columns: minmax(280px, 1fr) minmax(330px, auto);
  }
}

@media (max-width: 760px) {
  .api-result-controls {
    grid-template-columns: 1fr 1fr;
  }

  .api-time-field input {
    width: 100%;
  }
}
