:root {
  color-scheme: light;
  --bg: #f4f1e8;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --ink: #17201b;
  --muted: #687269;
  --line: #d9d1bf;
  --green: #246b4f;
  --green-strong: #174b39;
  --amber: #9b5a12;
  --blue: #285d86;
  --danger: #a72d2d;
  --shadow: 0 18px 45px rgba(43, 38, 27, 0.12);
  font-family: "Aptos", "Segoe UI", "Noto Sans SC", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  color: var(--ink);
  background:
    linear-gradient(120deg, rgba(36, 107, 79, 0.12), transparent 34%),
    linear-gradient(180deg, #f8f4ea 0%, #ebe5d5 100%);
}

button,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100dvh;
  padding: 28px;
}

.workspace {
  max-width: 1440px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 4.8rem);
  line-height: 0.95;
  letter-spacing: 0;
  max-width: 820px;
}

h2 {
  margin-bottom: 6px;
  font-size: 1.1rem;
}

.status-pill,
.icon-button,
.ghost-button,
.primary-button,
.record-button,
.upload-tile,
.model-tab {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 180ms ease, border-color 180ms ease, background-color 180ms ease;
}

.status-pill {
  flex: none;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--green-strong);
  font-size: 0.9rem;
  font-weight: 700;
}

.model-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.model-tab {
  justify-content: flex-start;
  padding: 14px 16px;
  background: rgba(255, 253, 248, 0.74);
  color: var(--ink);
  font-weight: 800;
}

.model-tab.active {
  background: var(--surface-strong);
  border-color: var(--green);
  box-shadow: var(--shadow);
}

.model-tab[data-accent="amber"].active {
  border-color: var(--amber);
}

.model-tab[data-accent="blue"].active {
  border-color: var(--blue);
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.28fr) minmax(360px, 0.72fr);
  gap: 18px;
  align-items: start;
}

.composer,
.result-pane {
  display: grid;
  gap: 16px;
}

.composer,
.player-surface,
.preview-surface {
  background: rgba(255, 253, 248, 0.88);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.composer {
  padding: 18px;
}

.section-heading,
.player-heading,
.preview-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.section-heading p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.6;
}

.sample-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.sample-strip button {
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f2e6;
  color: var(--ink);
  text-align: left;
}

.sample-strip strong,
.sample-strip span {
  display: block;
}

.sample-strip strong {
  margin-bottom: 5px;
}

.sample-strip span {
  color: var(--muted);
  font-size: 0.88rem;
}

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

.field > span {
  color: var(--green-strong);
  font-size: 0.86rem;
  font-weight: 800;
}

select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--ink);
}

select {
  min-height: 46px;
  padding: 0 12px;
}

textarea {
  min-height: 220px;
  padding: 14px;
  line-height: 1.65;
  resize: vertical;
}

.instruction-input {
  min-height: 96px;
}

.clone-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.advice-panel {
  grid-column: 1 / -1;
  padding: 12px 14px;
  border: 1px solid rgba(40, 93, 134, 0.24);
  border-radius: 8px;
  background: #eef5f6;
  color: #1d3f52;
}

.advice-panel strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.9rem;
}

.advice-panel p {
  margin: 0;
  line-height: 1.6;
  color: #365768;
}

.upload-tile,
.record-button {
  width: 100%;
  padding: 0 14px;
  background: #eff5f2;
  color: var(--green-strong);
  font-weight: 800;
}

.upload-tile input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.source-state {
  grid-column: 1 / -1;
  min-height: 44px;
  padding: 0 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.clone-notice {
  grid-column: 1 / -1;
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f8f1df;
  color: #70480f;
  line-height: 1.5;
  font-weight: 700;
}

.primary-button {
  width: 100%;
  min-height: 54px;
  border-color: var(--green-strong);
  background: var(--green-strong);
  color: #fffdf8;
  font-weight: 900;
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.ghost-button,
.icon-button {
  background: var(--surface-strong);
  color: var(--green-strong);
  padding: 0 12px;
  font-weight: 800;
  text-decoration: none;
}

.icon-button {
  width: 44px;
  padding: 0;
}

.player-surface,
.preview-surface {
  padding: 16px;
}

.player-surface audio {
  width: 100%;
  margin-top: 18px;
}

.empty-player {
  min-height: 132px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  gap: 8px;
  color: var(--muted);
}

.cache-state {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #eff5f2;
  color: var(--green-strong);
  font-weight: 800;
  line-height: 1.5;
}

.preview-surface pre {
  max-height: 520px;
  margin: 12px 0 0;
  padding: 14px;
  overflow: auto;
  border-radius: 8px;
  background: #17201b;
  color: #eaf2e6;
  font-size: 0.82rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.error-message {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid rgba(167, 45, 45, 0.32);
  border-radius: 8px;
  background: rgba(167, 45, 45, 0.08);
  color: var(--danger);
  font-weight: 700;
}

button:hover:not(:disabled),
.upload-tile:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

button:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(40, 93, 134, 0.4);
  outline-offset: 2px;
}

.spin {
  animation: spin 900ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 980px) {
  .app-shell {
    padding: 18px;
  }

  .topbar,
  .section-heading,
  .player-heading,
  .preview-header {
    align-items: stretch;
    flex-direction: column;
  }

  .model-tabs,
  .main-grid,
  .sample-strip {
    grid-template-columns: 1fr;
  }

  .status-pill {
    width: fit-content;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 12px;
  }

  .clone-tools {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 2.2rem;
  }
}
