:root {
  color-scheme: dark;
  --bg: #050807;
  --surface: #0b1510;
  --surface-strong: #111f18;
  --surface-soft: #08100c;
  --border: #244636;
  --border-strong: #3c7a58;
  --text: #ffffff;
  --muted: #9fc5ae;
  --accent: #ff8a24;
  --accent-hover: #ffa24d;
  --focus: #76ff9f;
  --danger: #ff7a7a;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(#0d1b14 1px, transparent 1px),
    linear-gradient(90deg, #0d1b14 1px, transparent 1px),
    var(--bg);
  background-size: 48px 48px;
  color: var(--text);
}

button,
input,
a {
  font: inherit;
}

img {
  max-width: 100%;
}

.app-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.nut-studio {
  width: 100%;
}

.state-view {
  min-height: calc(100vh - 56px);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 28px 80px rgb(0 0 0 / 35%);
}

.state-view.is-entering {
  animation: state-enter 420ms cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

.file-input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  inset-inline-start: -9999px;
  opacity: 0;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 900;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--accent);
  color: #190800;
  font-weight: 950;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 800;
}

h1,
h2 {
  margin: 0;
  color: var(--text);
  line-height: 0.98;
}

h1 {
  font-size: 3.2rem;
}

h2 {
  font-size: 2.35rem;
}

p {
  overflow-wrap: anywhere;
}

.upload-view {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 24px;
  max-width: 560px;
  min-height: min(720px, calc(100vh - 56px));
  margin: 0 auto;
  padding: 32px;
  text-align: center;
}

.upload-view.is-entering {
  animation-name: upload-enter;
}

.intro {
  display: grid;
  gap: 10px;
}

.intro p:last-child,
.fine-print,
.selected-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.fine-print {
  font-size: 0.92rem;
}

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 220px;
  width: 100%;
  padding: 22px;
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgb(255 138 36 / 14%) 0 25%, transparent 25% 50%, rgb(255 138 36 / 14%) 50% 75%, transparent 75%),
    var(--surface-strong);
  background-size: 24px 24px;
  color: var(--text);
  cursor: pointer;
  text-align: center;
  transition: border-color 160ms ease, transform 160ms ease;
}

.drop-zone:hover,
.drop-zone.is-dragging {
  border-color: var(--focus);
  transform: translateY(-1px) rotate(-0.35deg);
}

.drop-zone:focus-within {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.drop-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  margin-bottom: 14px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 0 12px;
  background: #08100c;
  color: var(--focus);
  font-size: 0.8rem;
  font-weight: 900;
}

.drop-title {
  display: block;
  font-size: 1.25rem;
  font-weight: 900;
}

.drop-copy {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.selected-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
  gap: 24px;
  align-items: center;
  padding: 24px;
}

.selected-view.is-entering {
  animation-name: selected-enter;
}

.selected-preview,
.result-frame {
  display: grid;
  place-items: center;
  min-height: 540px;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background:
    linear-gradient(45deg, #07100c 25%, transparent 25% 75%, #07100c 75%),
    linear-gradient(45deg, #07100c 25%, transparent 25% 75%, #07100c 75%),
    #0b1812;
  background-position: 0 0, 14px 14px;
  background-size: 28px 28px;
}

.selected-preview img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 720px;
  object-fit: contain;
}

.selected-copy {
  display: grid;
  gap: 18px;
  align-content: center;
}

.actions {
  display: grid;
  gap: 10px;
}

button,
.download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  max-width: 100%;
  border-radius: 8px;
  padding: 0 20px;
  font-weight: 900;
  text-decoration: none;
}

button {
  border: 0;
  background: var(--accent);
  color: #1b0b00;
  cursor: pointer;
  box-shadow: 0 8px 0 #5d2504;
}

button:hover:not(:disabled) {
  background: var(--accent-hover);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
  box-shadow: none;
}

.secondary-button,
.download-link {
  border: 1px solid var(--border);
  background: #07100c;
  color: var(--text);
  box-shadow: none;
}

.secondary-button:hover:not(:disabled),
.download-link:hover {
  background: #102219;
}

.status {
  min-height: 1.5em;
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.status.is-error {
  color: var(--danger);
}

.processing-view {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 28px;
  padding: 32px;
  text-align: center;
}

.processing-view.is-entering {
  animation-name: processing-enter;
}

.processing-copy {
  display: grid;
  gap: 12px;
  justify-items: center;
}

.processing-phrase {
  min-height: 1.6em;
  margin: 0;
  color: var(--muted);
  font-size: 1.08rem;
  font-weight: 900;
}

.processing-phrase.is-changing {
  animation: phrase-change 460ms cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

.nut-loader {
  position: relative;
  width: 184px;
  height: 178px;
  animation: nut-daddy-stage 1.6s ease-in-out infinite;
}

.nut-shell {
  position: absolute;
  inset-block-start: 18px;
  inset-inline-start: 48px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 88px;
  height: 112px;
  border: 3px solid #5d2504;
  border-radius: 8px;
  background: var(--accent);
  color: #190800;
  font-size: 2.35rem;
  font-weight: 950;
  box-shadow: inset 14px 0 0 rgb(141 61 12 / 60%);
  transform-origin: 50% 86%;
  animation: nut-daddy-shell 900ms cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.nut-face {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 3px solid #190800;
  border-radius: 8px;
  background: #ffb15f;
  font-size: 1.55rem;
  line-height: 1;
  animation: nut-daddy-face 900ms ease-in-out infinite;
}

.nut-arm,
.nut-leg {
  position: absolute;
  z-index: 1;
  display: block;
  width: 64px;
  height: 12px;
  border-radius: 8px;
  background: var(--accent);
  transform-origin: 8px 50%;
}

.nut-arm-left {
  inset-block-start: 70px;
  inset-inline-start: 14px;
  animation: nut-arm-left 650ms ease-in-out infinite;
}

.nut-arm-right {
  inset-block-start: 72px;
  inset-inline-start: 108px;
  animation: nut-arm-right 650ms ease-in-out infinite;
}

.nut-leg {
  width: 54px;
  height: 14px;
  inset-block-start: 128px;
}

.nut-leg-left {
  inset-inline-start: 44px;
  animation: nut-leg-left 500ms ease-in-out infinite;
}

.nut-leg-right {
  inset-inline-start: 88px;
  animation: nut-leg-right 500ms ease-in-out infinite;
}

.nut-shadow {
  position: absolute;
  inset-block-end: 10px;
  inset-inline-start: 50%;
  z-index: 0;
  display: block;
  width: 118px;
  height: 16px;
  border-radius: 8px;
  background: rgb(0 0 0 / 42%);
  transform: translateX(-50%);
  animation: nut-shadow 900ms ease-in-out infinite;
}

.result-view {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 12px;
  height: calc(100vh - 56px);
  min-height: 0;
  padding: 12px;
}

.result-view.is-entering {
  animation-name: result-enter;
}

.result-frame {
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  background: #050807;
}

.result-frame img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.result-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: min(100%, 860px);
  justify-self: center;
}

@keyframes state-enter {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.985);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes upload-enter {
  from {
    opacity: 0;
    transform: translateY(18px) rotate(-0.5deg) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) rotate(0) scale(1);
  }
}

@keyframes selected-enter {
  from {
    opacity: 0;
    transform: translateX(18px) scale(0.985);
  }

  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes processing-enter {
  from {
    opacity: 0;
    transform: translateY(18px) rotate(0.65deg) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) rotate(0) scale(1);
  }
}

@keyframes result-enter {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.985);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes phrase-change {
  0% {
    opacity: 0;
    transform: translateY(10px) rotate(-1deg);
  }

  60% {
    opacity: 1;
    transform: translateY(-2px) rotate(0.4deg);
  }

  100% {
    opacity: 1;
    transform: translateY(0) rotate(0);
  }
}

@keyframes nut-daddy-stage {
  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-8px);
  }

  75% {
    transform: translateX(8px);
  }
}

@keyframes nut-daddy-shell {
  0%,
  100% {
    transform: translateY(0) rotate(-12deg) scaleX(1);
  }

  24% {
    transform: translateY(-18px) rotate(14deg) scaleX(0.96);
  }

  48% {
    transform: translateY(2px) rotate(-20deg) scaleX(1.04);
  }

  72% {
    transform: translateY(-12px) rotate(18deg) scaleX(0.98);
  }
}

@keyframes nut-daddy-face {
  0%,
  100% {
    transform: rotate(6deg) scale(1);
  }

  50% {
    transform: rotate(-7deg) scale(1.08);
  }
}

@keyframes nut-arm-left {
  0%,
  100% {
    transform: rotate(34deg);
  }

  50% {
    transform: rotate(-62deg) translateX(-12px);
  }
}

@keyframes nut-arm-right {
  0%,
  100% {
    transform: rotate(148deg);
  }

  50% {
    transform: rotate(218deg) translateX(12px);
  }
}

@keyframes nut-leg-left {
  0%,
  100% {
    transform: rotate(88deg);
  }

  50% {
    transform: rotate(28deg) translateX(-10px);
  }
}

@keyframes nut-leg-right {
  0%,
  100% {
    transform: rotate(92deg);
  }

  50% {
    transform: rotate(150deg) translateX(10px);
  }
}

@keyframes nut-shadow {
  0%,
  100% {
    transform: translateX(-50%) scaleX(1);
    opacity: 0.44;
  }

  50% {
    transform: translateX(-50%) scaleX(0.62);
    opacity: 0.25;
  }
}

@media (max-width: 920px) {
  .app-shell {
    width: min(100% - 24px, 1180px);
    padding: 12px 0;
  }

  .state-view {
    min-height: auto;
  }

  .upload-view,
  .processing-view {
    min-height: calc(100vh - 24px);
    padding: 18px;
  }

  .result-view {
    height: calc(100vh - 24px);
    padding: 10px;
  }

  .selected-view {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  .selected-preview {
    min-height: 300px;
  }

  h1 {
    font-size: 2.65rem;
    line-height: 1;
  }

  h2 {
    font-size: 2rem;
  }
}

@media (max-width: 420px) {
  .app-shell {
    width: 100%;
    padding: 0;
  }

  .state-view {
    border-inline: 0;
    border-radius: 0;
  }

  .brand-lockup {
    font-size: 0.95rem;
  }

  h1 {
    font-size: 2.2rem;
  }

  h2 {
    font-size: 1.7rem;
  }

  .drop-zone {
    min-height: 168px;
  }

  button,
  .download-link {
    width: 100%;
    min-height: 46px;
    padding: 0 8px;
    font-size: 0.9rem;
  }

  .result-view {
    height: 100vh;
    padding: 8px;
  }

  .result-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }
}

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